summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/CMakeLists.txt88
-rw-r--r--src/widgets/Makefile_insert123
-rw-r--r--src/widgets/arc-toolbar.cpp3
-rw-r--r--src/widgets/box3d-toolbar.cpp2
-rw-r--r--src/widgets/button.cpp29
-rw-r--r--src/widgets/calligraphy-toolbar.cpp1
-rw-r--r--src/widgets/connector-toolbar.cpp3
-rw-r--r--src/widgets/dash-selector.cpp14
-rw-r--r--src/widgets/dash-selector.h5
-rw-r--r--src/widgets/desktop-widget.cpp181
-rw-r--r--src/widgets/dropper-toolbar.cpp2
-rw-r--r--src/widgets/eek-preview.cpp148
-rw-r--r--src/widgets/ege-adjustment-action.cpp14
-rw-r--r--src/widgets/ege-output-action.cpp6
-rw-r--r--src/widgets/ege-select-one-action.cpp32
-rw-r--r--src/widgets/eraser-toolbar.cpp4
-rw-r--r--src/widgets/font-selector.cpp33
-rw-r--r--src/widgets/gimp/CMakeLists.txt13
-rw-r--r--src/widgets/gimp/gimpcolorwheel.c1467
-rw-r--r--src/widgets/gimp/gimpcolorwheel.h95
-rw-r--r--src/widgets/gimp/gimpspinscale.c969
-rw-r--r--src/widgets/gimp/gimpspinscale.h82
-rw-r--r--src/widgets/gimp/ruler.cpp (renamed from src/widgets/ruler.cpp)187
-rw-r--r--src/widgets/gimp/ruler.h (renamed from src/widgets/ruler.h)0
-rw-r--r--src/widgets/gradient-image.cpp45
-rw-r--r--src/widgets/gradient-selector.cpp13
-rw-r--r--src/widgets/gradient-selector.h8
-rw-r--r--src/widgets/gradient-toolbar.cpp4
-rw-r--r--src/widgets/gradient-vector.cpp65
-rw-r--r--src/widgets/gradient-vector.h8
-rw-r--r--src/widgets/icon.cpp51
-rw-r--r--src/widgets/ink-action.cpp482
-rw-r--r--src/widgets/ink-action.h124
-rw-r--r--src/widgets/ink-comboboxentry-action.cpp14
-rw-r--r--src/widgets/ink-radio-action.cpp185
-rw-r--r--src/widgets/ink-radio-action.h52
-rw-r--r--src/widgets/ink-toggle-action.cpp221
-rw-r--r--src/widgets/ink-toggle-action.h53
-rw-r--r--src/widgets/ink-tool-menu-action.cpp49
-rw-r--r--src/widgets/ink-tool-menu-action.h52
-rw-r--r--src/widgets/lpe-toolbar.cpp3
-rw-r--r--src/widgets/measure-toolbar.cpp3
-rw-r--r--src/widgets/mesh-toolbar.cpp4
-rw-r--r--src/widgets/node-toolbar.cpp3
-rw-r--r--src/widgets/paint-selector.cpp54
-rw-r--r--src/widgets/paint-selector.h8
-rw-r--r--src/widgets/pencil-toolbar.cpp4
-rw-r--r--src/widgets/select-toolbar.cpp9
-rw-r--r--src/widgets/sp-attribute-widget.cpp27
-rw-r--r--src/widgets/sp-attribute-widget.h9
-rw-r--r--src/widgets/sp-color-selector.cpp6
-rw-r--r--src/widgets/sp-color-selector.h9
-rw-r--r--src/widgets/sp-widget.cpp30
-rw-r--r--src/widgets/sp-xmlview-attr-list.cpp19
-rw-r--r--src/widgets/sp-xmlview-content.cpp19
-rw-r--r--src/widgets/sp-xmlview-tree.cpp20
-rw-r--r--src/widgets/spray-toolbar.cpp3
-rw-r--r--src/widgets/spw-utilities.cpp69
-rw-r--r--src/widgets/spw-utilities.h12
-rw-r--r--src/widgets/star-toolbar.cpp3
-rw-r--r--src/widgets/stroke-style.cpp60
-rw-r--r--src/widgets/stroke-style.h11
-rw-r--r--src/widgets/text-toolbar.cpp22
-rw-r--r--src/widgets/toolbox.cpp56
-rw-r--r--src/widgets/tweak-toolbar.cpp3
65 files changed, 3419 insertions, 1974 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 225afe317..b2071af4e 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -1,24 +1,25 @@
+add_subdirectory(gimp)
set(widgets_SRC
button.cpp
- arc-toolbar.cpp
- box3d-toolbar.cpp
- calligraphy-toolbar.cpp
- connector-toolbar.cpp
- dropper-toolbar.cpp
- eraser-toolbar.cpp
- lpe-toolbar.cpp
- measure-toolbar.cpp
- mesh-toolbar.cpp
- node-toolbar.cpp
- pencil-toolbar.cpp
- rect-toolbar.cpp
- spiral-toolbar.cpp
- spray-toolbar.cpp
- star-toolbar.cpp
- text-toolbar.cpp
- tweak-toolbar.cpp
- zoom-toolbar.cpp
+ arc-toolbar.cpp
+ box3d-toolbar.cpp
+ calligraphy-toolbar.cpp
+ connector-toolbar.cpp
+ dropper-toolbar.cpp
+ eraser-toolbar.cpp
+ lpe-toolbar.cpp
+ measure-toolbar.cpp
+ mesh-toolbar.cpp
+ node-toolbar.cpp
+ pencil-toolbar.cpp
+ rect-toolbar.cpp
+ spiral-toolbar.cpp
+ spray-toolbar.cpp
+ star-toolbar.cpp
+ text-toolbar.cpp
+ tweak-toolbar.cpp
+ zoom-toolbar.cpp
dash-selector.cpp
desktop-widget.cpp
eek-preview.cpp
@@ -33,10 +34,13 @@ set(widgets_SRC
gradient-toolbar.cpp
gradient-vector.cpp
icon.cpp
+ image-menu-item.c
ink-action.cpp
ink-comboboxentry-action.cpp
+ ink-radio-action.cpp
+ ink-toggle-action.cpp
+ ink-tool-menu-action.cpp
paint-selector.cpp
- ruler.cpp
select-toolbar.cpp
sp-attribute-widget.cpp
sp-color-selector.cpp
@@ -55,24 +59,24 @@ set(widgets_SRC
# -------
# Headers
button.h
- arc-toolbar.h
- box3d-toolbar.h
- calligraphy-toolbar.h
- connector-toolbar.h
- dropper-toolbar.h
- eraser-toolbar.h
- lpe-toolbar.h
- measure-toolbar.h
- mesh-toolbar.h
- node-toolbar.h
- pencil-toolbar.h
- rect-toolbar.h
- spiral-toolbar.h
- spray-toolbar.h
- star-toolbar.h
- text-toolbar.h
- tweak-toolbar.h
- zoom-toolbar.h
+ arc-toolbar.h
+ box3d-toolbar.h
+ calligraphy-toolbar.h
+ connector-toolbar.h
+ dropper-toolbar.h
+ eraser-toolbar.h
+ lpe-toolbar.h
+ measure-toolbar.h
+ mesh-toolbar.h
+ node-toolbar.h
+ pencil-toolbar.h
+ rect-toolbar.h
+ spiral-toolbar.h
+ spray-toolbar.h
+ star-toolbar.h
+ text-toolbar.h
+ tweak-toolbar.h
+ zoom-toolbar.h
dash-selector.h
desktop-widget.h
eek-preview.h
@@ -88,10 +92,13 @@ set(widgets_SRC
gradient-toolbar.h
gradient-vector.h
icon.h
+ image-menu-item.h
ink-action.h
ink-comboboxentry-action.h
+ ink-radio-action.h
+ ink-toggle-action.h
+ ink-tool-menu-action.h
paint-selector.h
- ruler.h
select-toolbar.h
sp-attribute-widget.h
sp-color-selector.h
@@ -108,11 +115,6 @@ set(widgets_SRC
widget-sizes.h
)
-if(${WITH_GTK3_EXPERIMENTAL})
- set(image_menu_item_SRC image-menu-item.h image-menu-item.c)
- add_inkscape_source("${image_menu_item_SRC}")
-endif()
-
# add_inkscape_lib(widgets_LIB "${widgets_SRC}")
add_inkscape_source("${widgets_SRC}")
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
deleted file mode 100644
index c9f04de14..000000000
--- a/src/widgets/Makefile_insert
+++ /dev/null
@@ -1,123 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-if WITH_GTKMM_3_0
-ink_common_sources += \
- widgets/image-menu-item.c \
- widgets/image-menu-item.h
-endif
-
-ink_common_sources += \
- widgets/arc-toolbar.cpp \
- widgets/arc-toolbar.h \
- widgets/box3d-toolbar.cpp \
- widgets/box3d-toolbar.h \
- widgets/button.cpp \
- widgets/button.h \
- widgets/calligraphy-toolbar.cpp \
- widgets/calligraphy-toolbar.h \
- widgets/connector-toolbar.cpp \
- widgets/connector-toolbar.h \
- widgets/dash-selector.cpp \
- widgets/dash-selector.h \
- widgets/desktop-widget.cpp \
- widgets/desktop-widget.h \
- widgets/dropper-toolbar.cpp \
- widgets/dropper-toolbar.h \
- widgets/eek-preview.cpp \
- widgets/eek-preview.h \
- widgets/ege-adjustment-action.cpp \
- widgets/ege-adjustment-action.h \
- widgets/ege-paint-def.cpp \
- widgets/ege-paint-def.h \
- widgets/ege-output-action.cpp \
- widgets/ege-output-action.h \
- widgets/ege-select-one-action.cpp \
- widgets/ege-select-one-action.h \
- widgets/eraser-toolbar.cpp \
- widgets/eraser-toolbar.h \
- widgets/fill-style.cpp \
- widgets/fill-style.h \
- widgets/fill-n-stroke-factory.h \
- widgets/font-selector.cpp \
- widgets/font-selector.h \
- widgets/gradient-image.cpp \
- widgets/gradient-image.h \
- widgets/gradient-selector.cpp \
- widgets/gradient-selector.h \
- widgets/gradient-toolbar.cpp \
- widgets/gradient-toolbar.h \
- widgets/gradient-vector.cpp \
- widgets/gradient-vector.h \
- widgets/icon.cpp \
- widgets/icon.h \
- widgets/ink-action.cpp \
- widgets/ink-action.h \
- widgets/ink-comboboxentry-action.cpp \
- widgets/ink-comboboxentry-action.h \
- widgets/lpe-toolbar.cpp \
- widgets/lpe-toolbar.h \
- widgets/measure-toolbar.cpp \
- widgets/measure-toolbar.h \
- widgets/mesh-toolbar.cpp \
- widgets/mesh-toolbar.h \
- widgets/node-toolbar.cpp \
- widgets/node-toolbar.h \
- widgets/paint-selector.cpp \
- widgets/paint-selector.h \
- widgets/pencil-toolbar.cpp \
- widgets/pencil-toolbar.h \
- widgets/rect-toolbar.cpp \
- widgets/rect-toolbar.h \
- widgets/ruler.cpp \
- widgets/ruler.h \
- widgets/select-toolbar.cpp \
- widgets/select-toolbar.h \
- widgets/spray-toolbar.cpp \
- widgets/spray-toolbar.h \
- widgets/spiral-toolbar.cpp \
- widgets/spiral-toolbar.h \
- widgets/sp-attribute-widget.cpp \
- widgets/sp-attribute-widget.h \
- widgets/sp-color-selector.cpp \
- widgets/sp-color-selector.h \
- widgets/spinbutton-events.cpp \
- widgets/spinbutton-events.h \
- widgets/sp-widget.cpp \
- widgets/sp-widget.h \
- widgets/spw-utilities.cpp \
- widgets/spw-utilities.h \
- widgets/sp-xmlview-attr-list.cpp \
- widgets/sp-xmlview-attr-list.h \
- widgets/sp-xmlview-content.cpp \
- widgets/sp-xmlview-content.h \
- widgets/sp-xmlview-tree.cpp \
- widgets/sp-xmlview-tree.h \
- widgets/star-toolbar.cpp \
- widgets/star-toolbar.h \
- widgets/stroke-marker-selector.cpp \
- widgets/stroke-marker-selector.h \
- widgets/stroke-style.cpp \
- widgets/stroke-style.h \
- widgets/swatch-selector.cpp \
- widgets/swatch-selector.h \
- widgets/text-toolbar.cpp \
- widgets/text-toolbar.h \
- widgets/toolbox.cpp \
- widgets/toolbox.h \
- widgets/tweak-toolbar.cpp \
- widgets/tweak-toolbar.h \
- widgets/widget-sizes.h \
- widgets/zoom-toolbar.cpp \
- widgets/zoom-toolbar.h \
- widgets/widget-sizes.h
-
-if HAVE_POTRACE
-
-ink_common_sources += \
- widgets/paintbucket-toolbar.cpp \
- widgets/paintbucket-toolbar.h
-
-endif
-
-widgets/button.$(OBJEXT): helper/sp-marshal.h
-widgets/menu.$(OBJEXT): helper/sp-marshal.h
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index bea7cb712..9b408a7b2 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -37,7 +37,8 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
#include "mod360.h"
#include "selection.h"
#include "sp-ellipse.h"
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index b8c67ee76..95de28cf2 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -37,7 +37,7 @@
#include "document-undo.h"
#include "document.h"
#include "widgets/ege-adjustment-action.h"
-#include "widgets/ink-action.h"
+#include "widgets/ink-toggle-action.h"
#include "inkscape.h"
#include "persp3d.h"
#include "toolbox.h"
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index bc59d1a39..3f4f1207a 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -21,15 +21,8 @@
#include "helper/action.h"
static void sp_button_dispose(GObject *object);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width);
-
static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
-#else
-static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition);
-#endif
-
static void sp_button_clicked(GtkButton *button);
static void sp_button_perform_action(SPButton *button, gpointer data);
static gint sp_button_process_event(SPButton *button, GdkEvent *event);
@@ -48,12 +41,8 @@ static void sp_button_class_init(SPButtonClass *klass)
GtkButtonClass *button_class = GTK_BUTTON_CLASS(klass);
object_class->dispose = sp_button_dispose;
-#if GTK_CHECK_VERSION(3, 0, 0)
widget_class->get_preferred_width = sp_button_get_preferred_width;
widget_class->get_preferred_height = sp_button_get_preferred_height;
-#else
- widget_class->size_request = sp_button_size_request;
-#endif
button_class->clicked = sp_button_clicked;
}
@@ -90,7 +79,6 @@ static void sp_button_dispose(GObject *object)
(G_OBJECT_CLASS(sp_button_parent_class))->dispose(object);
}
-#if GTK_CHECK_VERSION(3, 0, 0)
static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
@@ -134,23 +122,6 @@ static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_heig
*minimal_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom);
*natural_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom);
}
-#else
-static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
- GtkStyle *style = gtk_widget_get_style(widget);
-
- if (child) {
- gtk_widget_size_request(GTK_WIDGET(child), requisition);
- } else {
- requisition->width = 0;
- requisition->height = 0;
- }
-
- requisition->width += 2 + 2 * MAX(2, style->xthickness);
- requisition->height += 2 + 2 * MAX(2, style->ythickness);
-}
-#endif
static void sp_button_clicked(GtkButton *button)
{
diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp
index ba51499aa..031295ccd 100644
--- a/src/widgets/calligraphy-toolbar.cpp
+++ b/src/widgets/calligraphy-toolbar.cpp
@@ -37,6 +37,7 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
+#include "widgets/ink-toggle-action.h"
#include "toolbox.h"
#include "ui/icon-names.h"
#include "ui/uxmanager.h"
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 8fd7c4f8d..a078ecec4 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -38,7 +38,8 @@
#include "widgets/ege-adjustment-action.h"
#include "enums.h"
#include "graphlayout.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-toggle-action.h"
#include "inkscape.h"
#include "sp-namedview.h"
#include "toolbox.h"
diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp
index e1cb563a7..522705cec 100644
--- a/src/widgets/dash-selector.cpp
+++ b/src/widgets/dash-selector.cpp
@@ -59,18 +59,9 @@ SPDashSelector::SPDashSelector()
dash_combo.signal_changed().connect( sigc::mem_fun(*this, &SPDashSelector::on_selection) );
this->pack_start(dash_combo, false, false, 0);
-
-#if WITH_GTKMM_3_0
offset = Gtk::Adjustment::create(0.0, 0.0, 10.0, 0.1, 1.0, 0.0);
-#else
- offset = new Gtk::Adjustment(0.0, 0.0, 10.0, 0.1, 1.0, 0.0);
-#endif
offset->signal_value_changed().connect(sigc::mem_fun(*this, &SPDashSelector::offset_value_changed));
-#if WITH_GTKMM_3_0
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(offset, 0.1, 2);
-#else
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(*offset, 0.1, 2);
-#endif
+ auto sb = new Inkscape::UI::Widget::SpinButton(offset, 0.1, 2);
sb->set_tooltip_text(_("Pattern offset"));
sp_dialog_defocus_on_enter_cpp(sb);
sb->show();
@@ -97,9 +88,6 @@ SPDashSelector::SPDashSelector()
SPDashSelector::~SPDashSelector() {
// FIXME: for some reason this doesn't get called; does the call to manage() in
// sp_stroke_style_line_widget_new() not processed correctly?
-#if !WITH_GTKMM_3_0
- delete offset;
-#endif
}
void SPDashSelector::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) {
diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h
index ec5a1cbd5..f176acf04 100644
--- a/src/widgets/dash-selector.h
+++ b/src/widgets/dash-selector.h
@@ -85,12 +85,7 @@ private:
Glib::RefPtr<Gtk::ListStore> dash_store;
Gtk::ComboBox dash_combo;
Gtk::CellRendererPixbuf image_renderer;
-
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> offset;
-#else
- Gtk::Adjustment *offset;
-#endif
static gchar const *const _prefs_path;
int preview_width;
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index ec155ce4c..bd72560c6 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -57,16 +57,14 @@
// We're in the "widgets" directory, so no need to explicitly prefix these:
#include "button.h"
-#include "ruler.h"
+#include "gimp/ruler.h"
#include "spinbutton-events.h"
#include "spw-utilities.h"
#include "toolbox.h"
#include "widget-sizes.h"
#include "verbs.h"
-#if GTK_CHECK_VERSION(3,0,0)
-# include <gtkmm/cssprovider.h>
-#endif
+#include <gtkmm/cssprovider.h>
#include <gtkmm/paned.h>
#include <gtkmm/messagedialog.h>
@@ -248,16 +246,11 @@ Geom::Point
SPDesktopWidget::window_get_pointer()
{
gint x,y;
- GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(canvas));
-
-#if GTK_CHECK_VERSION(3,0,0)
- GdkDisplay *display = gdk_window_get_display(window);
- GdkDeviceManager *dm = gdk_display_get_device_manager(display);
- GdkDevice *device = gdk_device_manager_get_client_pointer(dm);
+ auto window = gtk_widget_get_window(GTK_WIDGET(canvas));
+ auto display = gdk_window_get_display(window);
+ auto dm = gdk_display_get_device_manager(display);
+ auto device = gdk_device_manager_get_client_pointer(dm);
gdk_window_get_device_position(window, device, &x, &y, NULL);
-#else
- gdk_window_get_pointer(window, &x, &y, NULL);
-#endif
return Geom::Point(x,y);
}
@@ -336,21 +329,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->_interaction_disabled_counter = 0;
/* Main table */
-#if GTK_CHECK_VERSION(3,0,0)
dtw->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(dtw->vbox, "DesktopMainTable");
-#else
- dtw->vbox = gtk_vbox_new (FALSE, 0);
-#endif
gtk_container_add( GTK_CONTAINER(dtw), GTK_WIDGET(dtw->vbox) );
-
-#if GTK_CHECK_VERSION(3,0,0)
dtw->statusbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(dtw->statusbar, "DesktopStatusBar");
-#else
- dtw->statusbar = gtk_hbox_new (FALSE, 0);
-#endif
- //gtk_widget_set_usize (dtw->statusbar, -1, BOTTOM_BAR_HEIGHT);
gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->statusbar, FALSE, TRUE, 0);
{
@@ -358,19 +341,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->panels = new SwatchesPanel("/embedded/swatches" /*false*/);
dtw->panels->setOrientation(SP_ANCHOR_SOUTH);
-#if GTK_CHECK_VERSION(3,0,0)
dtw->panels->set_vexpand(false);
-#endif
-
gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 );
}
-#if GTK_CHECK_VERSION(3,0,0)
dtw->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(dtw->hbox, "DesktopHbox");
-#else
- dtw->hbox = gtk_hbox_new(FALSE, 0);
-#endif
gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 );
gtk_widget_show(dtw->hbox);
@@ -394,14 +370,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
NULL,
INKSCAPE_ICON("object-locked"),
_("Toggle lock of all guides in the document"));
-#if GTK_CHECK_VERSION(3,0,0)
- Glib::RefPtr<Gtk::CssProvider> guides_lock_style_provider = Gtk::CssProvider::create();
+ auto guides_lock_style_provider = Gtk::CssProvider::create();
guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }");
- Gtk::Widget * wnd = Glib::wrap(dtw->guides_lock);
+ auto wnd = Glib::wrap(dtw->guides_lock);
wnd->set_name("LockGuides");
- Glib::RefPtr<Gtk::StyleContext> context = wnd->get_style_context();
+ auto context = wnd->get_style_context();
context->add_provider(guides_lock_style_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-#endif
/* Horizontal ruler */
GtkWidget *eventbox = gtk_event_box_new ();
@@ -416,29 +390,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_hruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_hruler_event), dtw);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tbl_wrapper = gtk_grid_new(); // Is this widget really needed?
+ auto tbl_wrapper = gtk_grid_new(); // Is this widget really needed?
gtk_widget_set_name(tbl_wrapper, "CanvasTableWrapper");
dtw->canvas_tbl = gtk_grid_new();
gtk_widget_set_name(dtw->canvas_tbl, "CanvasTable");
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->guides_lock, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1);
-#else
- GtkWidget *tbl_wrapper = gtk_table_new(2, 3, FALSE);
- dtw->canvas_tbl = gtk_table_new(3, 3, FALSE);
-
- gtk_table_attach(GTK_TABLE(dtw->canvas_tbl),
- dtw->guides_lock,
- 0, 1, 0, 1,
- GTK_FILL, GTK_FILL,
- 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->canvas_tbl),
- eventbox,
- 1, 2, 0, 1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-#endif
g_signal_connect (G_OBJECT (dtw->guides_lock), "toggled", G_CALLBACK (sp_update_guides_lock), dtw);
gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl_wrapper, TRUE, TRUE, 1 );
@@ -452,16 +410,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
sp_ruler_set_unit (SP_RULER (dtw->vruler), pt);
gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(pt->name_plural.c_str()));
gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler));
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 0, 1, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE (dtw->canvas_tbl),
- eventbox,
- 0, 1, 1, 2,
- GTK_FILL, GTK_FILL,
- 0, 0);
-#endif
g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_vruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_vruler_event), dtw);
@@ -469,19 +418,10 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Horizontal scrollbar
dtw->hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0));
-
-#if GTK_CHECK_VERSION(3,0,0)
dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj));
gtk_widget_set_name(dtw->hscrollbar, "HorizontalScrollbar");
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1);
dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-#else
- dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj));
- gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3,
- GTK_FILL, GTK_SHRINK,
- 0, 0);
- dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0);
-#endif
// Sticky zoom button
dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION,
@@ -496,23 +436,10 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Vertical scrollbar
dtw->vadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0));
-
-#if GTK_CHECK_VERSION(3,0,0)
dtw->vscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(dtw->vadj));
gtk_widget_set_name(dtw->vscrollbar, "VerticalScrollbar");
-#else
- dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj));
-#endif
-
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0);
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2);
-#else
- gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2,
- GTK_SHRINK, GTK_FILL,
- 0, 0);
-#endif
gchar const* tip = "";
Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE );
@@ -546,15 +473,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
cms_adjust_set_sensitive(dtw, FALSE);
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-#if GTK_CHECK_VERSION(3,0,0)
gtk_grid_attach( GTK_GRID(dtw->canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1);
-#else
- gtk_table_attach( GTK_TABLE(dtw->canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3,
- (GtkAttachOptions)(GTK_SHRINK),
- (GtkAttachOptions)(GTK_SHRINK),
- 0, 0);
-#endif
-
{
if (!watcher) {
watcher = new CMSPrefWatcher();
@@ -571,10 +490,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
sp_ruler_add_track_widget (SP_RULER(dtw->hruler), GTK_WIDGET(dtw->canvas));
sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas));
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkCssProvider *css_provider = gtk_css_provider_new();
- GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas));
+ auto css_provider = gtk_css_provider_new();
+ auto style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas));
gtk_css_provider_load_from_data(css_provider,
"SPCanvas {\n"
@@ -585,21 +502,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
gtk_style_context_add_provider(style_context,
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
-#else
- GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas)));
- style->bg[GTK_STATE_NORMAL] = style->white;
- gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style);
-#endif
-
g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE);
gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE);
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);
-#endif
/* Dock */
bool create_dock =
@@ -608,12 +515,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
if (create_dock) {
dtw->dock = new Inkscape::UI::Widget::Dock();
-#if WITH_GTKMM_3_0
- Gtk::Paned *paned = new Gtk::Paned();
+ auto paned = new Gtk::Paned();
paned->set_name("Canvas_and_Dock");
-#else
- Gtk::HPaned *paned = new Gtk::HPaned();
-#endif
paned->pack1(*Glib::wrap(dtw->canvas_tbl));
paned->pack2(dtw->dock->getWidget(), Gtk::FILL);
@@ -624,24 +527,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
paned_class->cycle_handle_focus = NULL;
}
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(GTK_WIDGET(paned->gobj()), TRUE);
gtk_widget_set_vexpand(GTK_WIDGET(paned->gobj()), TRUE);
gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (tbl_wrapper), GTK_WIDGET (paned->gobj()), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
-#endif
-
} else {
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE);
gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE);
gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
-#endif
}
// connect scrollbar signals
@@ -658,11 +550,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Separator
gtk_box_pack_start(GTK_BOX(dtw->statusbar),
-#if GTK_CHECK_VERSION(3,0,0)
gtk_separator_new(GTK_ORIENTATION_VERTICAL),
-#else
- gtk_vseparator_new(),
-#endif
FALSE, FALSE, 0);
// Layer Selector
@@ -681,12 +569,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
gtk_label_set_lines (GTK_LABEL(dtw->select_status), 2);
#endif
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(dtw->select_status, GTK_ALIGN_START);
-#else
- gtk_misc_set_alignment (GTK_MISC (dtw->select_status), 0.0, 0.5);
-#endif
-
gtk_widget_set_size_request (dtw->select_status, 1, -1);
// Display the initial welcome message in the statusbar
@@ -712,65 +595,36 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
// Cursor coordinates
-#if GTK_CHECK_VERSION(3,0,0)
dtw->coord_status = gtk_grid_new();
gtk_widget_set_name(dtw->coord_status, "CoordinateAndZStatus");
gtk_grid_set_row_spacing(GTK_GRID(dtw->coord_status), 0);
gtk_grid_set_column_spacing(GTK_GRID(dtw->coord_status), 2);
- GtkWidget* sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
+ auto sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
gtk_widget_set_name(sep, "CoordinateSeparator");
gtk_grid_attach(GTK_GRID(dtw->coord_status),
GTK_WIDGET(sep),
0, 0, 1, 2);
-#else
- dtw->coord_status = gtk_table_new(5, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(dtw->coord_status), 0);
- gtk_table_set_col_spacings(GTK_TABLE(dtw->coord_status), 2);
- gtk_table_attach(GTK_TABLE(dtw->coord_status),
- gtk_vseparator_new(),
- 0, 1, 0, 2,
- GTK_FILL, GTK_FILL, 0, 0);
-#endif
gtk_widget_set_tooltip_text (dtw->coord_status, _("Cursor coordinates"));
- GtkWidget *label_x = gtk_label_new(_("X:"));
- GtkWidget *label_y = gtk_label_new(_("Y:"));
-
-#if GTK_CHECK_VERSION(3,0,0)
+ auto label_x = gtk_label_new(_("X:"));
+ auto label_y = gtk_label_new(_("Y:"));
gtk_widget_set_halign(label_x, GTK_ALIGN_START);
gtk_widget_set_halign(label_y, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_x, 1, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1);
-#else
- gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), label_y, 1,2, 1,2, GTK_FILL, GTK_FILL, 0, 0);
-#endif
-
dtw->coord_status_x = gtk_label_new(NULL);
dtw->coord_status_y = gtk_label_new(NULL);
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" );
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" );
- GtkWidget* label_z = gtk_label_new(_("Z:"));
+ auto label_z = gtk_label_new(_("Z:"));
gtk_widget_set_name(label_z, "ZLabel");
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END);
gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2);
-#else
- gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0);
-#endif
sp_set_font_size_smaller (dtw->coord_status);
@@ -2203,7 +2057,6 @@ set_adjustment (GtkAdjustment *adj, double l, double u, double ps, double si, do
gtk_adjustment_set_page_size(adj, ps);
gtk_adjustment_set_step_increment(adj, si);
gtk_adjustment_set_page_increment(adj, pi);
- gtk_adjustment_changed (adj);
}
}
diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp
index f60955da5..4e26a99a0 100644
--- a/src/widgets/dropper-toolbar.cpp
+++ b/src/widgets/dropper-toolbar.cpp
@@ -33,7 +33,7 @@
#include "dropper-toolbar.h"
#include "document-undo.h"
#include "widgets/ege-output-action.h"
-#include "widgets/ink-action.h"
+#include "ink-toggle-action.h"
#include "preferences.h"
#include "widgets/spinbutton-events.h"
diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp
index 9951a8957..5f1997672 100644
--- a/src/widgets/eek-preview.cpp
+++ b/src/widgets/eek-preview.cpp
@@ -194,7 +194,6 @@ static void eek_preview_size_request( GtkWidget* widget, GtkRequisition* req )
req->height = height;
}
-#if GTK_CHECK_VERSION(3,0,0)
static void eek_preview_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
GtkRequisition requisition;
@@ -208,7 +207,6 @@ static void eek_preview_get_preferred_height(GtkWidget *widget, gint *minimal_he
eek_preview_size_request(widget, &requisition);
*minimal_height = *natural_height = requisition.height;
}
-#endif
enum {
CLICKED_SIGNAL,
@@ -219,22 +217,6 @@ enum {
static guint eek_preview_signals[LAST_SIGNAL] = { 0 };
-#if !GTK_CHECK_VERSION(3,0,0)
-static gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* /* event */ )
-{
- gboolean result = FALSE;
-
- if (gtk_widget_is_drawable(widget)) {
- GdkWindow* window = gtk_widget_get_window(widget);
- cairo_t* cr = gdk_cairo_create(window);
- result = eek_preview_draw(widget, cr);
- cairo_destroy(cr);
- }
-
- return result;
-}
-#endif
-
static
gboolean eek_preview_draw(GtkWidget *widget,
cairo_t *cr)
@@ -246,14 +228,6 @@ gboolean eek_preview_draw(GtkWidget *widget,
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
-#if !GTK_CHECK_VERSION(3,0,0)
- GdkColor fg = { 0,
- static_cast<guint16>(priv->r),
- static_cast<guint16>(priv->g),
- static_cast<guint16>(priv->b)
- };
-#endif
-
gint insetTop = 0, insetBottom = 0;
gint insetLeft = 0, insetRight = 0;
@@ -270,9 +244,7 @@ gboolean eek_preview_draw(GtkWidget *widget,
insetLeft = insetRight = 1;
}
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *context = gtk_widget_get_style_context(widget);
+ auto context = gtk_widget_get_style_context(widget);
gtk_render_frame(context,
cr,
@@ -283,22 +255,6 @@ gboolean eek_preview_draw(GtkWidget *widget,
cr,
0, 0,
allocation.width, allocation.height);
-#else
- GtkStyle *style = gtk_widget_get_style(widget);
- GdkWindow *window = gtk_widget_get_window(widget);
-
- gtk_paint_flat_box( style,
- window,
- (GtkStateType)gtk_widget_get_state(widget),
- GTK_SHADOW_NONE,
- NULL,
- widget,
- NULL,
- 0, 0,
- allocation.width, allocation.height);
-
- gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE );
-#endif
// Border
if (priv->border != BORDER_NONE) {
@@ -377,27 +333,12 @@ gboolean eek_preview_draw(GtkWidget *widget,
if (priv->linked & PREVIEW_LINK_IN)
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_render_arrow(context,
cr,
G_PI, // Down-pointing arrow
area.x, area.y,
min(area.width, area.height)
);
-#else
- gtk_paint_arrow( style,
- window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_IN,
- NULL, /* clip area. &area, */
- widget, /* may be NULL */
- NULL, /* detail */
- GTK_ARROW_DOWN,
- FALSE,
- area.x, area.y,
- area.width, area.height
- );
-#endif
}
if (priv->linked & PREVIEW_LINK_OUT)
@@ -407,27 +348,12 @@ gboolean eek_preview_draw(GtkWidget *widget,
otherArea.y = possible.y + (possible.height - otherArea.height);
}
-#if GTK_CHECK_VERSION(3,0,0)
gtk_render_arrow(context,
cr,
G_PI, // Down-pointing arrow
otherArea.x, otherArea.y,
min(otherArea.width, otherArea.height)
);
-#else
- gtk_paint_arrow( style,
- window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_OUT,
- NULL, /* clip area. &area, */
- widget, /* may be NULL */
- NULL, /* detail */
- GTK_ARROW_DOWN,
- FALSE,
- otherArea.x, otherArea.y,
- otherArea.width, otherArea.height
- );
-#endif
}
if (priv->linked & PREVIEW_LINK_OTHER)
@@ -437,27 +363,12 @@ gboolean eek_preview_draw(GtkWidget *widget,
otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
}
-#if GTK_CHECK_VERSION(3,0,0)
gtk_render_arrow(context,
cr,
1.5*G_PI, // Left-pointing arrow
otherArea.x, otherArea.y,
min(otherArea.width, otherArea.height)
);
-#else
- gtk_paint_arrow( style,
- window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_OUT,
- NULL, /* clip area. &area, */
- widget, /* may be NULL */
- NULL, /* detail */
- GTK_ARROW_LEFT,
- FALSE,
- otherArea.x, otherArea.y,
- otherArea.width, otherArea.height
- );
-#endif
}
@@ -469,22 +380,10 @@ gboolean eek_preview_draw(GtkWidget *widget,
if ( otherArea.height < possible.height ) {
otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
}
-#if GTK_CHECK_VERSION(3,0,0)
gtk_render_check(context,
cr,
otherArea.x, otherArea.y,
otherArea.width, otherArea.height );
-#else
- gtk_paint_check( style,
- window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_OUT,
- NULL,
- widget,
- NULL,
- otherArea.x, otherArea.y,
- otherArea.width, otherArea.height );
-#endif
}
if (priv->linked & PREVIEW_STROKE)
@@ -495,23 +394,11 @@ gboolean eek_preview_draw(GtkWidget *widget,
if ( otherArea.height < possible.height ) {
otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
}
-#if GTK_CHECK_VERSION(3,0,0)
// This should be a diamond too?
gtk_render_check(context,
cr,
otherArea.x, otherArea.y,
otherArea.width, otherArea.height );
-#else
- gtk_paint_diamond( style,
- window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_OUT,
- NULL,
- widget,
- NULL,
- otherArea.x, otherArea.y,
- otherArea.width, otherArea.height );
-#endif
}
}
@@ -519,21 +406,10 @@ gboolean eek_preview_draw(GtkWidget *widget,
if ( gtk_widget_has_focus(widget) ) {
gtk_widget_get_allocation (widget, &allocation);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_render_focus(context,
cr,
0 + 1, 0 + 1,
allocation.width - 2, allocation.height - 2 );
-#else
- gtk_paint_focus( style,
- window,
- GTK_STATE_NORMAL,
- NULL, /* GdkRectangle *area, */
- widget,
- NULL,
- 0 + 1, 0 + 1,
- allocation.width - 2, allocation.height - 2 );
-#endif
}
return FALSE;
@@ -547,11 +423,7 @@ static gboolean eek_preview_enter_cb( GtkWidget* widget, GdkEventCrossing* event
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->within = TRUE;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_state_flags( widget, priv->hot ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_PRELIGHT, false );
-#else
- gtk_widget_set_state( widget, priv->hot ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT );
-#endif
}
return FALSE;
@@ -564,11 +436,7 @@ static gboolean eek_preview_leave_cb( GtkWidget* widget, GdkEventCrossing* event
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->within = FALSE;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false );
-#else
- gtk_widget_set_state( widget, GTK_STATE_NORMAL );
-#endif
}
return FALSE;
@@ -593,11 +461,7 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton*
if ( priv->within )
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_ACTIVE, false );
-#else
- gtk_widget_set_state( widget, GTK_STATE_ACTIVE );
-#endif
}
}
}
@@ -612,11 +476,7 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->hot = FALSE;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false );
-#else
- gtk_widget_set_state( widget, GTK_STATE_NORMAL );
-#endif
if ( priv->within &&
(event->button == PRIME_BUTTON_MAGIC_NUMBER ||
@@ -697,15 +557,9 @@ static void eek_preview_class_init( EekPreviewClass *klass )
parent_class = (GtkWidgetClass*)g_type_class_peek_parent( klass );
-#if GTK_CHECK_VERSION(3,0,0)
widgetClass->get_preferred_width = eek_preview_get_preferred_width;
widgetClass->get_preferred_height = eek_preview_get_preferred_height;
widgetClass->draw = eek_preview_draw;
-#else
- widgetClass->size_request = eek_preview_size_request;
- widgetClass->expose_event = eek_preview_expose_event;
-#endif
-
widgetClass->button_press_event = eek_preview_button_press_cb;
widgetClass->button_release_event = eek_preview_button_release_cb;
widgetClass->enter_notify_event = eek_preview_enter_cb;
diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp
index 272217aa4..6678d1e5a 100644
--- a/src/widgets/ege-adjustment-action.cpp
+++ b/src/widgets/ege-adjustment-action.cpp
@@ -47,7 +47,7 @@
#include "icon-size.h"
#include "widgets/ege-adjustment-action.h"
-#include "ui/widget/gimpspinscale.h"
+#include "gimp/gimpspinscale.h"
#include "ui/icon-names.h"
@@ -813,12 +813,8 @@ static GtkWidget* create_tool_item( GtkAction* action )
if ( IS_EGE_ADJUSTMENT_ACTION(action) ) {
EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action );
GtkWidget* spinbutton = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget* hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget* hb = gtk_hbox_new( FALSE, 5 );
-#endif
GValue value;
memset( &value, 0, sizeof(value) );
g_value_init( &value, G_TYPE_STRING );
@@ -865,13 +861,7 @@ static GtkWidget* create_tool_item( GtkAction* action )
gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 );
} else {
GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" );
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(lbl, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 );
-#endif
-
gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 );
}
}
diff --git a/src/widgets/ege-output-action.cpp b/src/widgets/ege-output-action.cpp
index 5dece8e91..da29524a5 100644
--- a/src/widgets/ege-output-action.cpp
+++ b/src/widgets/ege-output-action.cpp
@@ -166,12 +166,8 @@ GtkWidget* create_tool_item( GtkAction* action )
if ( IS_EGE_OUTPUT_ACTION(action) )
{
GValue value;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget* hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget* hb = gtk_hbox_new( FALSE, 5 );
-#endif
GtkWidget* lbl = 0;
memset( &value, 0, sizeof(value) );
diff --git a/src/widgets/ege-select-one-action.cpp b/src/widgets/ege-select-one-action.cpp
index 2e106154e..5555663e4 100644
--- a/src/widgets/ege-select-one-action.cpp
+++ b/src/widgets/ege-select-one-action.cpp
@@ -632,12 +632,8 @@ GtkWidget* create_tool_item( GtkAction* action )
item = GTK_WIDGET( gtk_tool_item_new() );
if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
-#else
- GtkWidget* holder = gtk_hbox_new( FALSE, 0 );
-#endif
GtkRadioAction* ract = 0;
GSList* group = 0;
@@ -744,12 +740,8 @@ GtkWidget* create_tool_item( GtkAction* action )
gtk_container_add( GTK_CONTAINER(item), holder );
} else {
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
+ auto holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
-#else
- GtkWidget *holder = gtk_hbox_new( FALSE, 4 );
-#endif
GtkEntry *entry = 0;
GtkWidget *normal;
@@ -818,14 +810,8 @@ GtkWidget* create_tool_item( GtkAction* action )
gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 );
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(holder, GTK_ALIGN_START);
gtk_container_add(GTK_CONTAINER(item), holder);
-#else
- GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
- gtk_container_add( GTK_CONTAINER(align), holder);
- gtk_container_add( GTK_CONTAINER(item), align );
-#endif
}
}
@@ -861,13 +847,6 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override )
if ( children && children->data ) {
gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" );
-#if !GTK_CHECK_VERSION(3,0,0)
- if (!combodata && GTK_IS_ALIGNMENT(children->data)) {
- GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) );
- combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" );
- }
-#endif
-
if ( GTK_IS_COMBO_BOX(combodata) ) {
GtkComboBox* combo = GTK_COMBO_BOX(combodata);
if ((active == -1) && (gtk_combo_box_get_has_entry(combo))) {
@@ -925,13 +904,6 @@ void resync_sensitive( EgeSelectOneAction* act )
if ( children && children->data ) {
gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" );
-#if !GTK_CHECK_VERSION(3,0,0)
- if (!combodata && GTK_IS_ALIGNMENT(children->data)) {
- GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) );
- combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" );
- }
-#endif
-
if ( GTK_IS_COMBO_BOX(combodata) ) {
/* Not implemented */
} else if ( GTK_IS_BOX(children->data) ) {
diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index b30d542a6..7f710a777 100644
--- a/src/widgets/eraser-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -37,7 +37,9 @@
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "toolbox.h"
#include "ui/icon-names.h"
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 2ed6705d7..4822020be 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -31,11 +31,7 @@
struct SPFontSelector
{
-#if GTK_CHECK_VERSION(3,0,0)
GtkBox hbox;
-#else
- GtkHBox hbox;
-#endif
unsigned int block_emit : 1;
@@ -56,11 +52,7 @@ struct SPFontSelector
struct SPFontSelectorClass
{
-#if GTK_CHECK_VERSION(3,0,0)
GtkBoxClass parent_class;
-#else
- GtkHBoxClass parent_class;
-#endif
void (* font_set) (SPFontSelector *fsel, gchar *fontspec);
};
@@ -86,11 +78,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel );
static guint fs_signals[LAST_SIGNAL] = { 0 };
-#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_HBOX);
-#endif
static void sp_font_selector_class_init(SPFontSelectorClass *c)
{
@@ -155,8 +143,7 @@ static void sp_font_selector_init(SPFontSelector *fsel)
/* Muck with style, see text-toolbar.cpp */
gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" );
-#if GTK_CHECK_VERSION(3,0,0)
- GtkCssProvider *css_provider = gtk_css_provider_new();
+ auto css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider,
"#font_selector_family {\n"
" -GtkWidget-wide-separators: true;\n"
@@ -164,14 +151,10 @@ static void sp_font_selector_init(SPFontSelector *fsel)
"}\n",
-1, NULL);
- GdkScreen *screen = gdk_screen_get_default();
+ auto screen = gdk_screen_get_default();
gtk_style_context_add_provider_for_screen(screen,
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
-#else
- gtk_rc_parse_string (
- "widget \"*font_selector_family\" style \"fontfamily-separator-style\"");
-#endif
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
@@ -190,12 +173,8 @@ static void sp_font_selector_init(SPFontSelector *fsel)
gtk_widget_show(f);
gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
+ auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
-#else
- GtkWidget *vb = gtk_vbox_new(FALSE, 4);
-#endif
gtk_widget_show(vb);
gtk_container_set_border_width(GTK_CONTAINER (vb), 4);
gtk_container_add(GTK_CONTAINER(f), vb);
@@ -230,12 +209,8 @@ static void sp_font_selector_init(SPFontSelector *fsel)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 4);
-#endif
gtk_widget_show(hb);
gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0);
diff --git a/src/widgets/gimp/CMakeLists.txt b/src/widgets/gimp/CMakeLists.txt
new file mode 100644
index 000000000..7b3e834e3
--- /dev/null
+++ b/src/widgets/gimp/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(gimpwidgets_SRC
+ gimpcolorwheel.c
+ gimpspinscale.c
+ ruler.cpp
+
+ # -------
+ # Headers
+ gimpcolorwheel.h
+ gimpspinscale.h
+ ruler.h
+)
+
+add_inkscape_source("${gimpwidgets_SRC}")
diff --git a/src/widgets/gimp/gimpcolorwheel.c b/src/widgets/gimp/gimpcolorwheel.c
new file mode 100644
index 000000000..212391497
--- /dev/null
+++ b/src/widgets/gimp/gimpcolorwheel.c
@@ -0,0 +1,1467 @@
+/* HSV color selector for GTK+
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
+ * Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
+ * Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
+ * Michael Natterer <mitch@gimp.org> (ported back to GIMP)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+/*
+ * This widget was adopted by Inkscape by Alex Valavanis <valavanisalex@gmail.com>
+ * on 2013-01-08. Last merges with GIMP code were applied using the following
+ * commits from the GIMP git repository at
+ * http://git.gnome.org/browse/gimp/tree/modules/gimpcolorwheel.c
+ *
+ * Gtk+ 2 code merge: commit 632c5 (2013-01-06)
+ * Gtk+ 3 code merge: commit bcfc6, gtk3-port branch (2013-01-06)
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "gimpcolorwheel.h"
+#include <math.h>
+
+
+/* Default ring fraction */
+#define DEFAULT_FRACTION 0.1
+
+/* Default width/height */
+#define DEFAULT_SIZE 100
+
+/* Default ring width */
+#define DEFAULT_RING_WIDTH 10
+
+
+/* Dragging modes */
+typedef enum
+{
+ DRAG_NONE,
+ DRAG_H,
+ DRAG_SV
+} DragMode;
+
+/* Private part of the GimpColorWheel structure */
+typedef struct
+{
+ /* Color value */
+ gdouble h;
+ gdouble s;
+ gdouble v;
+
+ /* ring_width is this fraction of size */
+ gdouble ring_fraction;
+
+ /* Size and ring width */
+ gint size;
+ gint ring_width;
+
+ /* Window for capturing events */
+ GdkWindow *window;
+
+ /* Dragging mode */
+ DragMode mode;
+
+ guint focus_on_ring : 1;
+} GimpColorWheelPrivate;
+
+enum
+{
+ CHANGED,
+ MOVE,
+ LAST_SIGNAL
+};
+
+static void gimp_color_wheel_map (GtkWidget *widget);
+static void gimp_color_wheel_unmap (GtkWidget *widget);
+static void gimp_color_wheel_realize (GtkWidget *widget);
+static void gimp_color_wheel_unrealize (GtkWidget *widget);
+static void gimp_color_wheel_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static gboolean gimp_color_wheel_button_press (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean gimp_color_wheel_button_release (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean gimp_color_wheel_motion (GtkWidget *widget,
+ GdkEventMotion *event);
+static gboolean gimp_color_wheel_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void gimp_color_wheel_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gimp_color_wheel_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget,
+ GdkEventGrabBroken *event);
+static gboolean gimp_color_wheel_focus (GtkWidget *widget,
+ GtkDirectionType direction);
+static void gimp_color_wheel_move (GimpColorWheel *wheel,
+ GtkDirectionType dir);
+
+
+static guint wheel_signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (GimpColorWheel, gimp_color_wheel, GTK_TYPE_WIDGET)
+
+#define parent_class gimp_color_wheel_parent_class
+
+
+static void
+gimp_color_wheel_class_init (GimpColorWheelClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class);
+ GtkBindingSet *binding_set;
+
+ widget_class->map = gimp_color_wheel_map;
+ widget_class->unmap = gimp_color_wheel_unmap;
+ widget_class->realize = gimp_color_wheel_realize;
+ widget_class->unrealize = gimp_color_wheel_unrealize;
+ widget_class->size_allocate = gimp_color_wheel_size_allocate;
+ widget_class->button_press_event = gimp_color_wheel_button_press;
+ widget_class->button_release_event = gimp_color_wheel_button_release;
+ widget_class->motion_notify_event = gimp_color_wheel_motion;
+ widget_class->get_preferred_width = gimp_color_wheel_get_preferred_width;
+ widget_class->get_preferred_height = gimp_color_wheel_get_preferred_height;
+ widget_class->draw = gimp_color_wheel_draw;
+ widget_class->focus = gimp_color_wheel_focus;
+ widget_class->grab_broken_event = gimp_color_wheel_grab_broken;
+
+ wheel_class->move = gimp_color_wheel_move;
+
+ wheel_signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpColorWheelClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ wheel_signals[MOVE] =
+ g_signal_new ("move",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GimpColorWheelClass, move),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_DIRECTION_TYPE);
+
+ binding_set = gtk_binding_set_by_class (class);
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_UP);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_UP);
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_DOWN);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_DOWN);
+
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_RIGHT);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_RIGHT);
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_LEFT);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0,
+ "move", 1,
+ G_TYPE_ENUM, GTK_DIR_LEFT);
+
+ g_type_class_add_private (object_class, sizeof (GimpColorWheelPrivate));
+}
+
+static void
+gimp_color_wheel_init (GimpColorWheel *wheel)
+{
+ GimpColorWheelPrivate *priv;
+
+ priv = G_TYPE_INSTANCE_GET_PRIVATE (wheel, GIMP_TYPE_COLOR_WHEEL,
+ GimpColorWheelPrivate);
+
+ wheel->priv = priv;
+
+ gtk_widget_set_has_window (GTK_WIDGET (wheel), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (wheel), TRUE);
+
+ priv->ring_fraction = DEFAULT_FRACTION;
+ priv->size = DEFAULT_SIZE;
+ priv->ring_width = DEFAULT_RING_WIDTH;
+}
+
+static void
+gimp_color_wheel_map (GtkWidget *widget)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
+
+ gdk_window_show (priv->window);
+}
+
+static void
+gimp_color_wheel_unmap (GtkWidget *widget)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+
+ gdk_window_hide (priv->window);
+
+ GTK_WIDGET_CLASS (parent_class)->unmap (widget);
+}
+
+static void
+gimp_color_wheel_realize (GtkWidget *widget)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ GtkAllocation allocation;
+ GdkWindowAttr attr;
+ gint attr_mask;
+ GdkWindow *parent_window;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ attr.window_type = GDK_WINDOW_CHILD;
+ attr.x = allocation.x;
+ attr.y = allocation.y;
+ attr.width = allocation.width;
+ attr.height = allocation.height;
+ attr.wclass = GDK_INPUT_ONLY;
+ attr.event_mask = (gtk_widget_get_events (widget) |
+ GDK_KEY_PRESS_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK);
+
+ attr_mask = GDK_WA_X | GDK_WA_Y;
+
+ parent_window = gtk_widget_get_parent_window (widget);
+
+ gtk_widget_set_window (widget, parent_window);
+ g_object_ref (parent_window);
+
+ priv->window = gdk_window_new (parent_window, &attr, attr_mask);
+ gdk_window_set_user_data (priv->window, wheel);
+}
+
+static void
+gimp_color_wheel_unrealize (GtkWidget *widget)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+
+ gdk_window_set_user_data (priv->window, NULL);
+ gdk_window_destroy (priv->window);
+ priv->window = NULL;
+
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+}
+
+static void
+gimp_color_wheel_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ gint focus_width;
+ gint focus_pad;
+
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ *minimum_width = *natural_width = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
+}
+
+static void
+gimp_color_wheel_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ gint focus_width;
+ gint focus_pad;
+
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ *minimum_height = *natural_height = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
+}
+
+static void
+gimp_color_wheel_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gint focus_width;
+ gint focus_pad;
+
+ gtk_widget_set_allocation (widget, allocation);
+
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ priv->size = MIN (allocation->width - 2 * (focus_width + focus_pad),
+ allocation->height - 2 * (focus_width + focus_pad));
+
+ priv->ring_width = priv->size * priv->ring_fraction;
+
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (priv->window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+}
+
+
+/* Utility functions */
+
+#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
+
+/* Converts from HSV to RGB */
+static void
+hsv_to_rgb (gdouble *h,
+ gdouble *s,
+ gdouble *v)
+{
+ gdouble hue, saturation, value;
+ gdouble f, p, q, t;
+
+ if (*s == 0.0)
+ {
+ *h = *v;
+ *s = *v;
+ *v = *v; /* heh */
+ }
+ else
+ {
+ hue = *h * 6.0;
+ saturation = *s;
+ value = *v;
+
+ if (hue == 6.0)
+ hue = 0.0;
+
+ f = hue - (int) hue;
+ p = value * (1.0 - saturation);
+ q = value * (1.0 - saturation * f);
+ t = value * (1.0 - saturation * (1.0 - f));
+
+ switch ((int) hue)
+ {
+ case 0:
+ *h = value;
+ *s = t;
+ *v = p;
+ break;
+
+ case 1:
+ *h = q;
+ *s = value;
+ *v = p;
+ break;
+
+ case 2:
+ *h = p;
+ *s = value;
+ *v = t;
+ break;
+
+ case 3:
+ *h = p;
+ *s = q;
+ *v = value;
+ break;
+
+ case 4:
+ *h = t;
+ *s = p;
+ *v = value;
+ break;
+
+ case 5:
+ *h = value;
+ *s = p;
+ *v = q;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+ }
+}
+
+/* Computes the vertices of the saturation/value triangle */
+static void
+compute_triangle (GimpColorWheel *wheel,
+ gint *hx,
+ gint *hy,
+ gint *sx,
+ gint *sy,
+ gint *vx,
+ gint *vy)
+{
+ GimpColorWheelPrivate *priv = wheel->priv;
+ GtkAllocation allocation;
+ gdouble center_x;
+ gdouble center_y;
+ gdouble inner, outer;
+ gdouble angle;
+
+ gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
+
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+ angle = priv->h * 2.0 * G_PI;
+
+ *hx = floor (center_x + cos (angle) * inner + 0.5);
+ *hy = floor (center_y - sin (angle) * inner + 0.5);
+ *sx = floor (center_x + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+ *sy = floor (center_y - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+ *vx = floor (center_x + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+ *vy = floor (center_y - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+}
+
+/* Computes whether a point is inside the hue ring */
+static gboolean
+is_in_ring (GimpColorWheel *wheel,
+ gdouble x,
+ gdouble y)
+{
+ GimpColorWheelPrivate *priv = wheel->priv;
+ GtkAllocation allocation;
+ gdouble dx, dy, dist;
+ gdouble center_x;
+ gdouble center_y;
+ gdouble inner, outer;
+
+ gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
+
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+
+ dx = x - center_x;
+ dy = center_y - y;
+ dist = dx * dx + dy * dy;
+
+ return (dist >= inner * inner && dist <= outer * outer);
+}
+
+/* Computes a saturation/value pair based on the mouse coordinates */
+static void
+compute_sv (GimpColorWheel *wheel,
+ gdouble x,
+ gdouble y,
+ gdouble *s,
+ gdouble *v)
+{
+ GtkAllocation allocation;
+ gint ihx, ihy, isx, isy, ivx, ivy;
+ gdouble hx, hy, sx, sy, vx, vy;
+ gdouble center_x;
+ gdouble center_y;
+
+ gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
+
+ compute_triangle (wheel, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
+
+ hx = ihx - center_x;
+ hy = center_y - ihy;
+ sx = isx - center_x;
+ sy = center_y - isy;
+ vx = ivx - center_x;
+ vy = center_y - ivy;
+ x -= center_x;
+ y = center_y - y;
+
+ if (vx * (x - sx) + vy * (y - sy) < 0.0)
+ {
+ *s = 1.0;
+ *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy))
+ / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy)));
+
+ if (*v < 0.0)
+ *v = 0.0;
+ else if (*v > 1.0)
+ *v = 1.0;
+ }
+ else if (hx * (x - sx) + hy * (y - sy) < 0.0)
+ {
+ *s = 0.0;
+ *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy))
+ / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy)));
+
+ if (*v < 0.0)
+ *v = 0.0;
+ else if (*v > 1.0)
+ *v = 1.0;
+ }
+ else if (sx * (x - hx) + sy * (y - hy) < 0.0)
+ {
+ *v = 1.0;
+ *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) /
+ ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy)));
+
+ if (*s < 0.0)
+ *s = 0.0;
+ else if (*s > 1.0)
+ *s = 1.0;
+ }
+ else
+ {
+ *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx))
+ / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx)));
+
+ if (*v<= 0.0)
+ {
+ *v = 0.0;
+ *s = 0.0;
+ }
+ else
+ {
+ if (*v > 1.0)
+ *v = 1.0;
+
+ if (fabs (hy - vy) < fabs (hx - vx))
+ *s = (x - sx - *v * (vx - sx)) / (*v * (hx - vx));
+ else
+ *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy));
+
+ if (*s < 0.0)
+ *s = 0.0;
+ else if (*s > 1.0)
+ *s = 1.0;
+ }
+ }
+}
+
+/* Computes whether a point is inside the saturation/value triangle */
+static gboolean
+is_in_triangle (GimpColorWheel *wheel,
+ gdouble x,
+ gdouble y)
+{
+ gint hx, hy, sx, sy, vx, vy;
+ gdouble det, s, v;
+
+ compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
+
+ det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx);
+
+ s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det;
+ v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det;
+
+ return (s >= 0.0 && v >= 0.0 && s + v <= 1.0);
+}
+
+/* Computes a value based on the mouse coordinates */
+static double
+compute_v (GimpColorWheel *wheel,
+ gdouble x,
+ gdouble y)
+{
+ GtkAllocation allocation;
+ gdouble center_x;
+ gdouble center_y;
+ gdouble dx, dy;
+ gdouble angle;
+
+ gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
+
+ dx = x - center_x;
+ dy = center_y - y;
+
+ angle = atan2 (dy, dx);
+ if (angle < 0.0)
+ angle += 2.0 * G_PI;
+
+ return angle / (2.0 * G_PI);
+}
+
+static void
+set_cross_grab (GimpColorWheel *wheel,
+ guint32 time)
+{
+ GimpColorWheelPrivate *priv = wheel->priv;
+ GdkCursor *cursor;
+
+ cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (wheel)),
+ GDK_CROSSHAIR);
+
+ gdk_device_grab (gtk_get_current_event_device(),
+ priv->window,
+ GDK_OWNERSHIP_NONE,
+ FALSE,
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_RELEASE_MASK,
+ cursor, time);
+ g_object_unref (cursor);
+}
+
+static gboolean gimp_color_wheel_grab_broken(GtkWidget *widget, GdkEventGrabBroken *event)
+{
+ (void)event;
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+
+ priv->mode = DRAG_NONE;
+
+ return TRUE;
+}
+
+static gboolean
+gimp_color_wheel_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gdouble x, y;
+
+ if (priv->mode != DRAG_NONE || event->button != 1)
+ return FALSE;
+
+ x = event->x;
+ y = event->y;
+
+ if (is_in_ring (wheel, x, y))
+ {
+ priv->mode = DRAG_H;
+ set_cross_grab (wheel, event->time);
+
+ gimp_color_wheel_set_color (wheel,
+ compute_v (wheel, x, y),
+ priv->s,
+ priv->v);
+
+ gtk_widget_grab_focus (widget);
+ priv->focus_on_ring = TRUE;
+
+ return TRUE;
+ }
+
+ if (is_in_triangle (wheel, x, y))
+ {
+ gdouble s, v;
+
+ priv->mode = DRAG_SV;
+ set_cross_grab (wheel, event->time);
+
+ compute_sv (wheel, x, y, &s, &v);
+ gimp_color_wheel_set_color (wheel, priv->h, s, v);
+
+ gtk_widget_grab_focus (widget);
+ priv->focus_on_ring = FALSE;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gimp_color_wheel_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ DragMode mode;
+ gdouble x, y;
+
+ if (priv->mode == DRAG_NONE || event->button != 1)
+ return FALSE;
+
+ /* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
+ * can see that this is the final color state.
+ */
+
+ mode = priv->mode;
+ priv->mode = DRAG_NONE;
+
+ x = event->x;
+ y = event->y;
+
+ if (mode == DRAG_H)
+ {
+ gimp_color_wheel_set_color (wheel,
+ compute_v (wheel, x, y), priv->s, priv->v);
+ }
+ else if (mode == DRAG_SV)
+ {
+ gdouble s, v;
+
+ compute_sv (wheel, x, y, &s, &v);
+ gimp_color_wheel_set_color (wheel, priv->h, s, v);
+ }
+ else
+ g_assert_not_reached ();
+
+ gdk_device_ungrab (gtk_get_current_event_device(),
+ event->time);
+
+ return TRUE;
+}
+
+static gboolean
+gimp_color_wheel_motion (GtkWidget *widget,
+ GdkEventMotion *event)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gdouble x, y;
+
+ if (priv->mode == DRAG_NONE)
+ return FALSE;
+
+ gdk_event_request_motions (event);
+ x = event->x;
+ y = event->y;
+
+ if (priv->mode == DRAG_H)
+ {
+ gimp_color_wheel_set_color (wheel,
+ compute_v (wheel, x, y), priv->s, priv->v);
+ return TRUE;
+ }
+ else if (priv->mode == DRAG_SV)
+ {
+ gdouble s, v;
+
+ compute_sv (wheel, x, y, &s, &v);
+ gimp_color_wheel_set_color (wheel, priv->h, s, v);
+ return TRUE;
+ }
+
+ g_assert_not_reached ();
+
+ return FALSE;
+}
+
+
+/* Redrawing */
+
+/* Paints the hue ring */
+static void
+paint_ring (GimpColorWheel *wheel,
+ cairo_t *cr)
+{
+ GtkWidget *widget = GTK_WIDGET (wheel);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gint width, height;
+ gint xx, yy;
+ gdouble dx, dy, dist;
+ gdouble center_x;
+ gdouble center_y;
+ gdouble inner, outer;
+ guint32 *buf, *p;
+ gdouble angle;
+ gdouble hue;
+ gdouble r, g, b;
+ cairo_surface_t *source;
+ cairo_t *source_cr;
+ gint stride;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+
+ center_x = width / 2.0;
+ center_y = height / 2.0;
+
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+
+ /* Create an image initialized with the ring colors */
+
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
+ buf = g_new (guint32, height * stride / 4);
+
+ for (yy = 0; yy < height; yy++)
+ {
+ p = buf + yy * width;
+ dy = -(yy - center_y);
+
+ for (xx = 0; xx < width; xx++)
+ {
+ dx = xx - center_x;
+
+ dist = dx * dx + dy * dy;
+ if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1)))
+ {
+ *p++ = 0;
+ continue;
+ }
+
+ angle = atan2 (dy, dx);
+ if (angle < 0.0)
+ angle += 2.0 * G_PI;
+
+ hue = angle / (2.0 * G_PI);
+
+ r = hue;
+ g = 1.0;
+ b = 1.0;
+ hsv_to_rgb (&r, &g, &b);
+
+ *p++ = (((int)floor (r * 255 + 0.5) << 16) |
+ ((int)floor (g * 255 + 0.5) << 8) |
+ (int)floor (b * 255 + 0.5));
+ }
+ }
+
+ source = cairo_image_surface_create_for_data ((unsigned char *)buf,
+ CAIRO_FORMAT_RGB24,
+ width, height, stride);
+
+ /* Now draw the value marker onto the source image, so that it
+ * will get properly clipped at the edges of the ring
+ */
+ source_cr = cairo_create (source);
+
+ r = priv->h;
+ g = 1.0;
+ b = 1.0;
+ hsv_to_rgb (&r, &g, &b);
+
+ if (INTENSITY (r, g, b) > 0.5)
+ cairo_set_source_rgb (source_cr, 0.0, 0.0, 0.0);
+ else
+ cairo_set_source_rgb (source_cr, 1.0, 1.0, 1.0);
+
+ cairo_move_to (source_cr, center_x, center_y);
+ cairo_line_to (source_cr,
+ center_x + cos (priv->h * 2.0 * G_PI) * priv->size / 2,
+ center_y - sin (priv->h * 2.0 * G_PI) * priv->size / 2);
+ cairo_stroke (source_cr);
+ cairo_destroy (source_cr);
+
+ /* Draw the ring using the source image */
+
+ cairo_save (cr);
+
+ cairo_set_source_surface (cr, source, 0, 0);
+ cairo_surface_destroy (source);
+
+ cairo_set_line_width (cr, priv->ring_width);
+ cairo_new_path (cr);
+ cairo_arc (cr,
+ center_x, center_y,
+ priv->size / 2.0 - priv->ring_width / 2.0,
+ 0, 2 * G_PI);
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
+
+ g_free (buf);
+}
+
+/* Converts an HSV triplet to an integer RGB triplet */
+static void
+get_color (gdouble h,
+ gdouble s,
+ gdouble v,
+ gint *r,
+ gint *g,
+ gint *b)
+{
+ hsv_to_rgb (&h, &s, &v);
+
+ *r = floor (h * 255 + 0.5);
+ *g = floor (s * 255 + 0.5);
+ *b = floor (v * 255 + 0.5);
+}
+
+#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t))
+
+#define LERP(a, b, v1, v2, i) (((v2) - (v1) != 0) \
+ ? ((a) + ((b) - (a)) * ((i) - (v1)) / ((v2) - (v1))) \
+ : (a))
+
+/* Number of pixels we extend out from the edges when creating
+ * color source to avoid artifacts
+ */
+#define PAD 3
+
+/* Paints the HSV triangle */
+static void
+paint_triangle (GimpColorWheel *wheel,
+ cairo_t *cr,
+ gboolean draw_focus)
+{
+ GtkWidget *widget = GTK_WIDGET (wheel);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
+ gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
+ gint x2, y2, r2, g2, b2; /* Second vertex */
+ gint x3, y3, r3, g3, b3; /* Third vertex */
+ gint t;
+ guint32 *buf, *p, c;
+ gint xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */
+ gint xx, yy;
+ gint x_interp, y_interp;
+ gint x_start, x_end;
+ cairo_surface_t *source;
+ gdouble r, g, b;
+ gint stride;
+ gint width, height;
+ GtkStyleContext *context;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+
+ /* Compute triangle's vertices */
+
+ compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
+
+ x1 = hx;
+ y1 = hy;
+ get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1);
+
+ x2 = sx;
+ y2 = sy;
+ get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2);
+
+ x3 = vx;
+ y3 = vy;
+ get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3);
+
+ if (y2 > y3)
+ {
+ SWAP (x2, x3, t);
+ SWAP (y2, y3, t);
+ SWAP (r2, r3, t);
+ SWAP (g2, g3, t);
+ SWAP (b2, b3, t);
+ }
+
+ if (y1 > y3)
+ {
+ SWAP (x1, x3, t);
+ SWAP (y1, y3, t);
+ SWAP (r1, r3, t);
+ SWAP (g1, g3, t);
+ SWAP (b1, b3, t);
+ }
+
+ if (y1 > y2)
+ {
+ SWAP (x1, x2, t);
+ SWAP (y1, y2, t);
+ SWAP (r1, r2, t);
+ SWAP (g1, g2, t);
+ SWAP (b1, b2, t);
+ }
+
+ /* Shade the triangle */
+
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
+ buf = g_new (guint32, height * stride / 4);
+
+ for (yy = 0; yy < height; yy++)
+ {
+ p = buf + yy * width;
+
+ if (yy >= y1 - PAD && yy < y3 + PAD)
+ {
+ y_interp = CLAMP (yy, y1, y3);
+
+ if (y_interp < y2)
+ {
+ xl = LERP (x1, x2, y1, y2, y_interp);
+
+ rl = LERP (r1, r2, y1, y2, y_interp);
+ gl = LERP (g1, g2, y1, y2, y_interp);
+ bl = LERP (b1, b2, y1, y2, y_interp);
+ }
+ else
+ {
+ xl = LERP (x2, x3, y2, y3, y_interp);
+
+ rl = LERP (r2, r3, y2, y3, y_interp);
+ gl = LERP (g2, g3, y2, y3, y_interp);
+ bl = LERP (b2, b3, y2, y3, y_interp);
+ }
+
+ xr = LERP (x1, x3, y1, y3, y_interp);
+
+ rr = LERP (r1, r3, y1, y3, y_interp);
+ gr = LERP (g1, g3, y1, y3, y_interp);
+ br = LERP (b1, b3, y1, y3, y_interp);
+
+ if (xl > xr)
+ {
+ SWAP (xl, xr, t);
+ SWAP (rl, rr, t);
+ SWAP (gl, gr, t);
+ SWAP (bl, br, t);
+ }
+
+ x_start = MAX (xl - PAD, 0);
+ x_end = MIN (xr + PAD, width);
+ x_start = MIN (x_start, x_end);
+
+ c = (rl << 16) | (gl << 8) | bl;
+
+ for (xx = 0; xx < x_start; xx++)
+ *p++ = c;
+
+ for (; xx < x_end; xx++)
+ {
+ x_interp = CLAMP (xx, xl, xr);
+
+ *p++ = ((LERP (rl, rr, xl, xr, x_interp) << 16) |
+ (LERP (gl, gr, xl, xr, x_interp) << 8) |
+ LERP (bl, br, xl, xr, x_interp));
+ }
+
+ c = (rr << 16) | (gr << 8) | br;
+
+ for (; xx < width; xx++)
+ *p++ = c;
+ }
+ }
+
+ source = cairo_image_surface_create_for_data ((unsigned char *)buf,
+ CAIRO_FORMAT_RGB24,
+ width, height, stride);
+
+ /* Draw a triangle with the image as a source */
+
+ cairo_set_source_surface (cr, source, 0, 0);
+ cairo_surface_destroy (source);
+
+ cairo_move_to (cr, x1, y1);
+ cairo_line_to (cr, x2, y2);
+ cairo_line_to (cr, x3, y3);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+
+ g_free (buf);
+
+ /* Draw value marker */
+
+ xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
+ yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
+
+ r = priv->h;
+ g = priv->s;
+ b = priv->v;
+ hsv_to_rgb (&r, &g, &b);
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (context);
+
+ if (INTENSITY (r, g, b) > 0.5)
+ {
+ gtk_style_context_add_class (context, "light-area-focus");
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ }
+ else
+ {
+ gtk_style_context_add_class (context, "dark-area-focus");
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ }
+
+#define RADIUS 4
+#define FOCUS_RADIUS 6
+
+ cairo_new_path (cr);
+ cairo_arc (cr, xx, yy, RADIUS, 0, 2 * G_PI);
+ cairo_stroke (cr);
+
+ /* Draw focus outline */
+
+ if (draw_focus && ! priv->focus_on_ring)
+ {
+ gint focus_width;
+ gint focus_pad;
+
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ gtk_render_focus (context, cr,
+ xx - FOCUS_RADIUS - focus_width - focus_pad,
+ yy - FOCUS_RADIUS - focus_width - focus_pad,
+ 2 * (FOCUS_RADIUS + focus_width + focus_pad),
+ 2 * (FOCUS_RADIUS + focus_width + focus_pad));
+ }
+
+ gtk_style_context_restore (context);
+}
+
+static gboolean
+gimp_color_wheel_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gboolean draw_focus;
+
+ draw_focus = gtk_widget_has_visible_focus (widget);
+
+ paint_ring (wheel, cr);
+ paint_triangle (wheel, cr, draw_focus);
+
+ if (draw_focus && priv->focus_on_ring)
+ {
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+
+ gtk_render_focus (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gimp_color_wheel_focus (GtkWidget *widget,
+ GtkDirectionType dir)
+{
+ GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
+ GimpColorWheelPrivate *priv = wheel->priv;
+
+ if (!gtk_widget_has_focus (widget))
+ {
+ if (dir == GTK_DIR_TAB_BACKWARD)
+ priv->focus_on_ring = FALSE;
+ else
+ priv->focus_on_ring = TRUE;
+
+ gtk_widget_grab_focus (widget);
+ return TRUE;
+ }
+
+ switch (dir)
+ {
+ case GTK_DIR_UP:
+ if (priv->focus_on_ring)
+ return FALSE;
+ else
+ priv->focus_on_ring = TRUE;
+ break;
+
+ case GTK_DIR_DOWN:
+ if (priv->focus_on_ring)
+ priv->focus_on_ring = FALSE;
+ else
+ return FALSE;
+ break;
+
+ case GTK_DIR_LEFT:
+ case GTK_DIR_TAB_BACKWARD:
+ if (priv->focus_on_ring)
+ return FALSE;
+ else
+ priv->focus_on_ring = TRUE;
+ break;
+
+ case GTK_DIR_RIGHT:
+ case GTK_DIR_TAB_FORWARD:
+ if (priv->focus_on_ring)
+ priv->focus_on_ring = FALSE;
+ else
+ return FALSE;
+ break;
+ }
+
+ gtk_widget_queue_draw (widget);
+
+ return TRUE;
+}
+
+/**
+ * gimp_color_wheel_new:
+ *
+ * Creates a new HSV color selector.
+ *
+ * Return value: A newly-created HSV color selector.
+ *
+ * Since: 2.14
+ */
+GtkWidget*
+gimp_color_wheel_new (void)
+{
+ return g_object_new (GIMP_TYPE_COLOR_WHEEL, NULL);
+}
+
+/**
+ * gimp_color_wheel_set_color:
+ * @hsv: An HSV color selector
+ * @h: Hue
+ * @s: Saturation
+ * @v: Value
+ *
+ * Sets the current color in an HSV color selector.
+ * Color component values must be in the [0.0, 1.0] range.
+ *
+ * Since: 2.14
+ */
+void
+gimp_color_wheel_set_color (GimpColorWheel *wheel,
+ gdouble h,
+ gdouble s,
+ gdouble v)
+{
+ GimpColorWheelPrivate *priv;
+
+ g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel));
+ g_return_if_fail (h >= 0.0 && h <= 1.0);
+ g_return_if_fail (s >= 0.0 && s <= 1.0);
+ g_return_if_fail (v >= 0.0 && v <= 1.0);
+
+ priv = wheel->priv;
+
+ if(h == 0.0 && s == 0.0) {
+ h = priv->h;
+ }
+
+ priv->h = h;
+ priv->s = s;
+ priv->v = v;
+
+ g_signal_emit (wheel, wheel_signals[CHANGED], 0);
+
+ gtk_widget_queue_draw (GTK_WIDGET (wheel));
+}
+
+/**
+ * gimp_color_wheel_get_color:
+ * @hsv: An HSV color selector
+ * @h: (out): Return value for the hue
+ * @s: (out): Return value for the saturation
+ * @v: (out): Return value for the value
+ *
+ * Queries the current color in an HSV color selector.
+ * Returned values will be in the [0.0, 1.0] range.
+ *
+ * Since: 2.14
+ */
+void
+gimp_color_wheel_get_color (GimpColorWheel *wheel,
+ gdouble *h,
+ gdouble *s,
+ gdouble *v)
+{
+ GimpColorWheelPrivate *priv;
+
+ g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel));
+
+ priv = wheel->priv;
+
+ if (h) *h = priv->h;
+ if (s) *s = priv->s;
+ if (v) *v = priv->v;
+}
+
+/**
+ * gimp_color_wheel_set_ring_fraction:
+ * @ring: A wheel color selector
+ * @fraction: Ring fraction
+ *
+ * Sets the ring fraction of a wheel color selector.
+ *
+ * Since: GIMP 2.10
+ */
+void
+gimp_color_wheel_set_ring_fraction (GimpColorWheel *hsv,
+ gdouble fraction)
+{
+ GimpColorWheelPrivate *priv;
+
+ g_return_if_fail (GIMP_IS_COLOR_WHEEL (hsv));
+
+ priv = hsv->priv;
+
+ priv->ring_fraction = CLAMP (fraction, 0.01, 0.99);
+
+ gtk_widget_queue_draw (GTK_WIDGET (hsv));
+}
+
+/**
+ * gimp_color_wheel_get_ring_fraction:
+ * @ring: A wheel color selector
+ *
+ * Returns value: The ring fraction of the wheel color selector.
+ *
+ * Since: GIMP 2.10
+ */
+gdouble
+gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel)
+{
+ GimpColorWheelPrivate *priv;
+
+ g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), DEFAULT_FRACTION);
+
+ priv = wheel->priv;
+
+ return priv->ring_fraction;
+}
+
+/**
+ * gimp_color_wheel_is_adjusting:
+ * @hsv: A #GimpColorWheel
+ *
+ * An HSV color selector can be said to be adjusting if multiple rapid
+ * changes are being made to its value, for example, when the user is
+ * adjusting the value with the mouse. This function queries whether
+ * the HSV color selector is being adjusted or not.
+ *
+ * Return value: %TRUE if clients can ignore changes to the color value,
+ * since they may be transitory, or %FALSE if they should consider
+ * the color value status to be final.
+ *
+ * Since: 2.14
+ */
+gboolean
+gimp_color_wheel_is_adjusting (GimpColorWheel *wheel)
+{
+ GimpColorWheelPrivate *priv;
+
+ g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), FALSE);
+
+ priv = wheel->priv;
+
+ return priv->mode != DRAG_NONE;
+}
+
+static void
+gimp_color_wheel_move (GimpColorWheel *wheel,
+ GtkDirectionType dir)
+{
+ GimpColorWheelPrivate *priv = wheel->priv;
+ gdouble hue, sat, val;
+ gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
+ gint x, y; /* position in triangle */
+
+ hue = priv->h;
+ sat = priv->s;
+ val = priv->v;
+
+ compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
+
+ x = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
+ y = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
+
+#define HUE_DELTA 0.002
+ switch (dir)
+ {
+ case GTK_DIR_UP:
+ if (priv->focus_on_ring)
+ hue += HUE_DELTA;
+ else
+ {
+ y -= 1;
+ compute_sv (wheel, x, y, &sat, &val);
+ }
+ break;
+
+ case GTK_DIR_DOWN:
+ if (priv->focus_on_ring)
+ hue -= HUE_DELTA;
+ else
+ {
+ y += 1;
+ compute_sv (wheel, x, y, &sat, &val);
+ }
+ break;
+
+ case GTK_DIR_LEFT:
+ if (priv->focus_on_ring)
+ hue += HUE_DELTA;
+ else
+ {
+ x -= 1;
+ compute_sv (wheel, x, y, &sat, &val);
+ }
+ break;
+
+ case GTK_DIR_RIGHT:
+ if (priv->focus_on_ring)
+ hue -= HUE_DELTA
+ ;
+ else
+ {
+ x += 1;
+ compute_sv (wheel, x, y, &sat, &val);
+ }
+ break;
+
+ default:
+ /* we don't care about the tab directions */
+ break;
+ }
+
+ /* Wrap */
+ if (hue < 0.0)
+ hue = 1.0;
+ else if (hue > 1.0)
+ hue = 0.0;
+
+ gimp_color_wheel_set_color (wheel, hue, sat, val);
+}
diff --git a/src/widgets/gimp/gimpcolorwheel.h b/src/widgets/gimp/gimpcolorwheel.h
new file mode 100644
index 000000000..016fb593f
--- /dev/null
+++ b/src/widgets/gimp/gimpcolorwheel.h
@@ -0,0 +1,95 @@
+/* HSV color selector for GTK+
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
+ * Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
+ * Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GIMP_COLOR_WHEEL_H__
+#define __GIMP_COLOR_WHEEL_H__
+
+G_BEGIN_DECLS
+
+#define GIMP_TYPE_COLOR_WHEEL (gimp_color_wheel_get_type ())
+#define GIMP_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheel))
+#define GIMP_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
+#define GIMP_IS_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_WHEEL))
+#define GIMP_IS_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_WHEEL))
+#define GIMP_COLOR_WHEEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
+
+
+typedef struct _GimpColorWheel GimpColorWheel;
+typedef struct _GimpColorWheelClass GimpColorWheelClass;
+
+struct _GimpColorWheel
+{
+ GtkWidget parent_instance;
+
+ /* Private data */
+ gpointer priv;
+};
+
+struct _GimpColorWheelClass
+{
+ GtkWidgetClass parent_class;
+
+ /* Notification signals */
+ void (* changed) (GimpColorWheel *wheel);
+
+ /* Keybindings */
+ void (* move) (GimpColorWheel *wheel,
+ GtkDirectionType type);
+
+ /* Padding for future expansion */
+ void (*_gimp_reserved1) (void);
+ void (*_gimp_reserved2) (void);
+ void (*_gimp_reserved3) (void);
+ void (*_gimp_reserved4) (void);
+};
+
+
+GType gimp_color_wheel_get_type (void) G_GNUC_CONST;
+GtkWidget * gimp_color_wheel_new (void);
+
+void gimp_color_wheel_set_color (GimpColorWheel *wheel,
+ double h,
+ double s,
+ double v);
+void gimp_color_wheel_get_color (GimpColorWheel *wheel,
+ gdouble *h,
+ gdouble *s,
+ gdouble *v);
+
+void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
+ gdouble fraction);
+gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
+
+gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
+
+G_END_DECLS
+
+#endif /* __GIMP_COLOR_WHEEL_H__ */
diff --git a/src/widgets/gimp/gimpspinscale.c b/src/widgets/gimp/gimpspinscale.c
new file mode 100644
index 000000000..8d8c6c935
--- /dev/null
+++ b/src/widgets/gimp/gimpspinscale.c
@@ -0,0 +1,969 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpspinscale.c
+ * Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
+ * 2012 Øyvind Kolås <pippin@gimp.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "gimpspinscale.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_LABEL,
+ PROP_FOCUS_WIDGET
+};
+
+typedef enum
+{
+ TARGET_NUMBER,
+ TARGET_UPPER,
+ TARGET_LOWER,
+ TARGET_NONE
+} SpinScaleTarget;
+
+typedef enum
+{
+ APPEARANCE_FULL = 1, /* Full size suitable for tablets */
+ APPEARANCE_COMPACT, /* Compact, suitable for desktops with mouse control */
+} SpinScaleAppearance;
+
+typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate;
+
+struct _GimpSpinScalePrivate
+{
+ gchar *label;
+
+ gboolean scale_limits_set;
+ gdouble scale_lower;
+ gdouble scale_upper;
+ gdouble gamma;
+
+ PangoLayout *layout;
+ gboolean changing_value;
+ gboolean relative_change;
+ gdouble start_x;
+ gdouble start_value;
+
+ GtkWidget* focusWidget;
+ gboolean transferFocus;
+ SpinScaleAppearance appearanceMode;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ GIMP_TYPE_SPIN_SCALE, \
+ GimpSpinScalePrivate))
+
+
+static void gimp_spin_scale_dispose (GObject *object);
+static void gimp_spin_scale_finalize (GObject *object);
+static void gimp_spin_scale_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_spin_scale_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_spin_scale_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
+
+static void gimp_spin_scale_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gimp_spin_scale_get_preferred_height (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static gboolean gimp_spin_scale_draw (GtkWidget *widget,
+ cairo_t *cr);
+
+static gboolean gimp_spin_scale_button_press (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean gimp_spin_scale_button_release (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean gimp_spin_scale_motion_notify (GtkWidget *widget,
+ GdkEventMotion *event);
+static gboolean gimp_spin_scale_leave_notify (GtkWidget *widget,
+ GdkEventCrossing *event);
+static gboolean gimp_spin_scale_keypress( GtkWidget *widget,
+ GdkEventKey *event);
+
+static void gimp_spin_scale_defocus( GtkSpinButton *spin_button );
+
+static void gimp_spin_scale_value_changed (GtkSpinButton *spin_button);
+
+
+G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GTK_TYPE_SPIN_BUTTON);
+
+#define parent_class gimp_spin_scale_parent_class
+
+
+static void
+gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass);
+
+ object_class->dispose = gimp_spin_scale_dispose;
+ object_class->finalize = gimp_spin_scale_finalize;
+ object_class->set_property = gimp_spin_scale_set_property;
+ object_class->get_property = gimp_spin_scale_get_property;
+
+ widget_class->style_set = gimp_spin_scale_style_set;
+ widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width;
+ widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height;
+ widget_class->draw = gimp_spin_scale_draw;
+ widget_class->button_press_event = gimp_spin_scale_button_press;
+ widget_class->button_release_event = gimp_spin_scale_button_release;
+ widget_class->motion_notify_event = gimp_spin_scale_motion_notify;
+ widget_class->leave_notify_event = gimp_spin_scale_leave_notify;
+ widget_class->key_press_event = gimp_spin_scale_keypress;
+
+ spin_button_class->value_changed = gimp_spin_scale_value_changed;
+
+ g_object_class_install_property (object_class, PROP_LABEL,
+ g_param_spec_string ("label", NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (GimpSpinScalePrivate));
+}
+
+static void
+gimp_spin_scale_init (GimpSpinScale *scale)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (scale);
+
+ gtk_widget_add_events (GTK_WIDGET (scale),
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_LEAVE_NOTIFY_MASK);
+
+ gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE);
+
+ private->gamma = 1.0;
+ private->focusWidget = NULL;
+ private->transferFocus = FALSE;
+ private->appearanceMode = APPEARANCE_COMPACT;
+}
+
+static void
+gimp_spin_scale_dispose (GObject *object)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (object);
+
+ if (private->layout)
+ {
+ g_object_unref (private->layout);
+ private->layout = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+gimp_spin_scale_finalize (GObject *object)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (object);
+
+ if (private->label)
+ {
+ g_free (private->label);
+ private->label = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_spin_scale_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (object);
+ GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
+
+ switch (property_id)
+ {
+ case PROP_LABEL:
+ gimp_spin_scale_set_label (scale, g_value_get_string (value));
+ break;
+
+ case PROP_FOCUS_WIDGET:
+ {
+ /* TODO unhook prior */
+ private->focusWidget = GTK_WIDGET (g_value_get_pointer (value));
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_spin_scale_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (object);
+ GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
+
+ switch (property_id)
+ {
+ case PROP_LABEL:
+ g_value_set_string (value, gimp_spin_scale_get_label (scale));
+ break;
+
+ case PROP_FOCUS_WIDGET:
+ g_value_set_pointer (value, private->focusWidget);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+void
+gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget )
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (scale);
+
+ /* TODO unhook prior */
+
+ private->focusWidget = widget;
+}
+
+void
+gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+
+ if ( strcmp("full", appearance) == 0 ) {
+ private->appearanceMode = APPEARANCE_FULL;
+ } else if ( strcmp("compact", appearance) == 0 ) {
+ private->appearanceMode = APPEARANCE_COMPACT;
+ }
+}
+
+static void
+gimp_spin_scale_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ PangoContext *context = gtk_widget_get_pango_context (widget);
+ PangoFontMetrics *metrics;
+
+ GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
+ minimum_width,
+ natural_width);
+
+ metrics = pango_context_get_metrics (context,
+ pango_context_get_font_description (context),
+ pango_context_get_language (context));
+
+ if (private->label)
+ {
+ gint char_width;
+ gint digit_width;
+ gint char_pixels;
+
+ char_width = pango_font_metrics_get_approximate_char_width (metrics);
+ digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ char_pixels = PANGO_PIXELS (MAX (char_width, digit_width));
+
+ /* ~3 chars for the ellipse */
+ *minimum_width += char_pixels * 3;
+ *natural_width += char_pixels * 3;
+ }
+
+ pango_font_metrics_unref (metrics);
+}
+
+static void
+gimp_spin_scale_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ PangoContext *context = gtk_widget_get_pango_context (widget);
+ PangoFontMetrics *metrics;
+ //gint height;
+
+ GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget,
+ minimum_height,
+ natural_height);
+
+ metrics = pango_context_get_metrics (context,
+ pango_context_get_font_description (context),
+ pango_context_get_language (context));
+
+ //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+ // pango_font_metrics_get_descent (metrics));
+
+ *minimum_height += 1;
+ *natural_height += 1;
+
+ pango_font_metrics_unref (metrics);
+}
+
+static void
+gimp_spin_scale_style_set (GtkWidget *widget,
+ GtkStyle *prev_style)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+
+ GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+
+ if (private->layout)
+ {
+ g_object_unref (private->layout);
+ private->layout = NULL;
+ }
+}
+
+
+static gboolean
+ gimp_spin_scale_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ GtkStyleContext *style = gtk_widget_get_style_context(widget);
+ GtkAllocation allocation;
+ GdkRGBA color;
+
+ cairo_save (cr);
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ cairo_restore (cr);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ cairo_set_line_width (cr, 1.0);
+
+ if (private->label)
+ {
+ GdkRectangle text_area;
+ gint minimum_width;
+ gint natural_width;
+ PangoRectangle logical;
+ gint layout_offset_x;
+ gint layout_offset_y;
+ GtkStateFlags state;
+ GdkRGBA text_color;
+ GdkRGBA bar_text_color;
+ gdouble progress_fraction;
+ gint progress_x;
+ gint progress_y;
+ gint progress_width;
+ gint progress_height;
+
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+
+ GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
+ &minimum_width,
+ &natural_width);
+
+ if (! private->layout)
+ {
+ private->layout = gtk_widget_create_pango_layout (widget,
+ private->label);
+ pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END);
+ }
+
+ pango_layout_set_width (private->layout,
+ PANGO_SCALE *
+ (allocation.width - minimum_width));
+ pango_layout_get_pixel_extents (private->layout, NULL, &logical);
+
+ gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y);
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ layout_offset_x = text_area.x + text_area.width - logical.width - 4;
+ else
+ layout_offset_x = 4;
+
+ layout_offset_x -= logical.x;
+
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_color (style, state, &text_color);
+
+ gtk_style_context_save (style);
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR);
+ gtk_style_context_get_color (style, state, &bar_text_color);
+ gtk_style_context_restore (style);
+
+ progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget));
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ {
+ progress_fraction = 1.0 - progress_fraction;
+
+ progress_x = text_area.width * progress_fraction;
+ progress_y = 0;
+ progress_width = text_area.width - progress_x;
+ progress_height = text_area.height;
+ }
+ else
+ {
+ progress_x = 0;
+ progress_y = 0;
+ progress_width = text_area.width * progress_fraction;
+ progress_height = text_area.height;
+ }
+
+ cairo_save (cr);
+
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_rectangle (cr, 0, 0, text_area.width, text_area.height);
+ cairo_rectangle (cr, progress_x, progress_y,
+ progress_width, progress_height);
+ cairo_clip (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
+
+ cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
+ gdk_cairo_set_source_rgba (cr, &text_color);
+ pango_cairo_show_layout (cr, private->layout);
+ cairo_restore (cr);
+
+ cairo_rectangle (cr, progress_x, progress_y,
+ progress_width, progress_height);
+ cairo_clip (cr);
+
+ cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
+ gdk_cairo_set_source_rgba (cr, &bar_text_color);
+ pango_cairo_show_layout (cr, private->layout);
+ }
+
+ return FALSE;
+}
+
+/* Returns TRUE if a translation should be done */
+static gboolean
+gtk_widget_get_translation_to_window (GtkWidget *widget,
+ GdkWindow *window,
+ int *x,
+ int *y)
+{
+ GdkWindow *w, *widget_window;
+
+ if (!gtk_widget_get_has_window (widget))
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ *x = -allocation.x;
+ *y = -allocation.y;
+ }
+ else
+ {
+ *x = 0;
+ *y = 0;
+ }
+
+ widget_window = gtk_widget_get_window (widget);
+
+ for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
+ {
+ int wx, wy;
+ gdk_window_get_position (w, &wx, &wy);
+ *x += wx;
+ *y += wy;
+ }
+
+ if (w == NULL)
+ {
+ *x = 0;
+ *y = 0;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+gimp_spin_scale_event_to_widget_coords (GtkWidget *widget,
+ GdkWindow *window,
+ gdouble event_x,
+ gdouble event_y,
+ gint *widget_x,
+ gint *widget_y)
+{
+ gint tx, ty;
+
+ if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty))
+ {
+ event_x += tx;
+ event_y += ty;
+ }
+
+ *widget_x = event_x;
+ *widget_y = event_y;
+}
+
+static SpinScaleTarget
+gimp_spin_scale_get_target (GtkWidget *widget,
+ gdouble x,
+ gdouble y)
+{
+ GtkAllocation allocation;
+ PangoRectangle logical;
+ gint layout_x;
+ gint layout_y;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y);
+ pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)),
+ NULL, &logical);
+
+ GdkRectangle text_area;
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+
+ if (x >= text_area.x && x < text_area.width &&
+ y >= text_area.y && y < text_area.height)
+ {
+ x -= text_area.x;
+ y -= text_area.y;
+
+ if (x > layout_x && x < layout_x + logical.width &&
+ y > layout_y && y < layout_y + logical.height)
+ {
+ return TARGET_NUMBER;
+ }
+ else if (y > text_area.height / 2)
+ {
+ return TARGET_LOWER;
+ }
+
+ return TARGET_UPPER;
+ }
+
+ return TARGET_NONE;
+}
+
+static void
+gimp_spin_scale_get_limits (GimpSpinScale *scale,
+ gdouble *lower,
+ gdouble *upper)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (scale);
+
+ if (private->scale_limits_set)
+ {
+ *lower = private->scale_lower;
+ *upper = private->scale_upper;
+ }
+ else
+ {
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (scale);
+ GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
+
+ *lower = gtk_adjustment_get_lower (adjustment);
+ *upper = gtk_adjustment_get_upper (adjustment);
+ }
+}
+
+static void
+gimp_spin_scale_change_value (GtkWidget *widget,
+ gdouble x)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
+ GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
+ gdouble lower;
+ gdouble upper;
+ gdouble value;
+ GdkRectangle text_area;
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+ gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ x = text_area.width - x;
+
+ if (private->relative_change)
+ {
+ gdouble diff;
+ gdouble step;
+
+ step = (upper - lower) / text_area.width / 10.0;
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ diff = x - (text_area.width - private->start_x);
+ else
+ diff = x - private->start_x;
+
+ value = (private->start_value + diff * step);
+ }
+ else
+ {
+ gdouble fraction;
+
+ fraction = x / (gdouble) text_area.width;
+ if (fraction > 0.0)
+ fraction = pow (fraction, private->gamma);
+
+ value = fraction * (upper - lower) + lower;
+ }
+
+ gtk_adjustment_set_value (adjustment, value);
+}
+
+static gboolean
+gimp_spin_scale_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+
+ private->changing_value = FALSE;
+ private->relative_change = FALSE;
+
+ gint x, y;
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
+ switch (gimp_spin_scale_get_target (widget, x, y))
+ {
+ case TARGET_UPPER:
+ private->changing_value = TRUE;
+
+ gtk_widget_grab_focus (widget);
+
+ gimp_spin_scale_change_value (widget, x);
+
+ return TRUE;
+
+ case TARGET_LOWER:
+ private->changing_value = TRUE;
+
+ gtk_widget_grab_focus (widget);
+
+ private->relative_change = TRUE;
+ private->start_x = x;
+ private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
+
+ return TRUE;
+
+ default:
+ break;
+ }
+
+ return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
+}
+
+static gboolean
+gimp_spin_scale_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ gint x, y;
+
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
+
+ if (private->changing_value)
+ {
+ private->changing_value = FALSE;
+ gimp_spin_scale_change_value (widget, x);
+ return TRUE;
+ }
+
+ return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
+}
+
+static gboolean
+gimp_spin_scale_motion_notify (GtkWidget *widget,
+ GdkEventMotion *event)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+
+ gdk_event_request_motions (event);
+
+ gint x, y;
+
+ gimp_spin_scale_event_to_widget_coords (widget, event->window,
+ event->x, event->y,
+ &x, &y);
+
+ if (private->changing_value)
+ {
+ gimp_spin_scale_change_value (widget, x);
+
+ return TRUE;
+ }
+
+ GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
+
+ if (! (event->state &
+ (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))
+ )
+ {
+ GdkDisplay *display = gtk_widget_get_display (widget);
+ GdkCursor *cursor = NULL;
+
+ switch (gimp_spin_scale_get_target (widget, x, y))
+ {
+ case TARGET_NUMBER:
+ cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
+ break;
+
+ case TARGET_UPPER:
+ cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW);
+ break;
+
+ case TARGET_LOWER:
+ cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW);
+ break;
+
+ default:
+ break;
+ }
+
+ if (cursor)
+ {
+ gdk_window_set_cursor (event->window, cursor);
+ g_object_unref (cursor);
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gimp_spin_scale_leave_notify (GtkWidget *widget,
+ GdkEventCrossing *event)
+{
+ gdk_window_set_cursor (event->window, NULL);
+
+ return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
+}
+
+gboolean gimp_spin_scale_keypress( GtkWidget *widget, GdkEventKey *event)
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ guint key = 0;
+ gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display( gdk_display_get_default() ),
+ event->hardware_keycode, (GdkModifierType)event->state,
+ 0, &key, 0, 0, 0 );
+
+ switch ( key ) {
+
+ case GDK_KEY_Escape:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
+ {
+ private->transferFocus = TRUE;
+ gimp_spin_scale_defocus( GTK_SPIN_BUTTON(widget) );
+ }
+ break;
+
+ }
+
+ return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
+}
+
+static void
+gimp_spin_scale_defocus( GtkSpinButton *spin_button )
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
+
+ if ( private->transferFocus ) {
+ if ( private->focusWidget ) {
+ gtk_widget_grab_focus( private->focusWidget );
+ }
+ }
+}
+
+static void
+gimp_spin_scale_value_changed (GtkSpinButton *spin_button)
+{
+ GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
+ GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
+ gdouble lower;
+ gdouble upper;
+ gdouble value;
+
+ gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper);
+
+ value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper);
+
+ gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button),
+ pow ((value - lower) / (upper - lower),
+ 1.0 / private->gamma));
+
+ // TODO - Allow scrollwheel to change value then return focus,
+ // but clicks/keypress should keep focus in the control
+ //if ( gtk_widget_has_focus( GTK_WIDGET(spin_button) ) ) {
+ // gimp_spin_scale_defocus( spin_button );
+ //}
+}
+
+
+/* public functions */
+
+GtkWidget *
+gimp_spin_scale_new (GtkAdjustment *adjustment,
+ const gchar *label,
+ gint digits)
+{
+ g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
+
+ return g_object_new (GIMP_TYPE_SPIN_SCALE,
+ "adjustment", adjustment,
+ "label", label,
+ "digits", digits,
+ NULL);
+}
+
+void
+gimp_spin_scale_set_label (GimpSpinScale *scale,
+ const gchar *label)
+{
+ GimpSpinScalePrivate *private;
+
+ g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
+
+ private = GET_PRIVATE (scale);
+
+ if (label == private->label)
+ return;
+
+ g_free (private->label);
+ private->label = g_strdup (label);
+
+ if (private->layout)
+ {
+ g_object_unref (private->layout);
+ private->layout = NULL;
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (scale));
+
+ g_object_notify (G_OBJECT (scale), "label");
+}
+
+const gchar *
+gimp_spin_scale_get_label (GimpSpinScale *scale)
+{
+ g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL);
+
+ return GET_PRIVATE (scale)->label;
+}
+
+void
+gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
+ gdouble lower,
+ gdouble upper)
+{
+ GimpSpinScalePrivate *private;
+ GtkSpinButton *spin_button;
+ GtkAdjustment *adjustment;
+
+ g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
+
+ private = GET_PRIVATE (scale);
+ spin_button = GTK_SPIN_BUTTON (scale);
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+
+ g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment));
+ g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment));
+
+ private->scale_limits_set = TRUE;
+ private->scale_lower = lower;
+ private->scale_upper = upper;
+ private->gamma = 1.0;
+
+ gimp_spin_scale_value_changed (spin_button);
+}
+
+void
+gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale)
+{
+ GimpSpinScalePrivate *private;
+
+ g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
+
+ private = GET_PRIVATE (scale);
+
+ private->scale_limits_set = FALSE;
+ private->scale_lower = 0.0;
+ private->scale_upper = 0.0;
+
+ gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
+}
+
+gboolean
+gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
+ gdouble *lower,
+ gdouble *upper)
+{
+ GimpSpinScalePrivate *private;
+
+ g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE);
+
+ private = GET_PRIVATE (scale);
+
+ if (lower)
+ *lower = private->scale_lower;
+
+ if (upper)
+ *upper = private->scale_upper;
+
+ return private->scale_limits_set;
+}
+
+void
+gimp_spin_scale_set_gamma (GimpSpinScale *scale,
+ gdouble gamma)
+{
+ GimpSpinScalePrivate *private;
+
+ g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
+
+ private = GET_PRIVATE (scale);
+
+ private->gamma = gamma;
+
+ gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
+}
+
+gdouble
+gimp_spin_scale_get_gamma (GimpSpinScale *scale)
+{
+ g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
+
+ return GET_PRIVATE(scale)->gamma;
+}
diff --git a/src/widgets/gimp/gimpspinscale.h b/src/widgets/gimp/gimpspinscale.h
new file mode 100644
index 000000000..b42a0faf8
--- /dev/null
+++ b/src/widgets/gimp/gimpspinscale.h
@@ -0,0 +1,82 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpspinscale.h
+ * Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_SPIN_SCALE_H__
+#define __GIMP_SPIN_SCALE_H__
+
+#ifndef WITH_GIMP
+#include <gtk/gtk.h>
+#endif
+
+G_BEGIN_DECLS
+
+#define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ())
+#define GIMP_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScale))
+#define GIMP_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
+#define GIMP_IS_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_SCALE))
+#define GIMP_IS_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_SCALE))
+#define GIMP_SPIN_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
+
+
+typedef struct _GimpSpinScale GimpSpinScale;
+typedef struct _GimpSpinScaleClass GimpSpinScaleClass;
+
+struct _GimpSpinScale
+{
+ GtkSpinButton parent_instance;
+};
+
+struct _GimpSpinScaleClass
+{
+ GtkSpinButtonClass parent_class;
+};
+
+
+GType gimp_spin_scale_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment,
+ const gchar *label,
+ gint digits);
+
+void gimp_spin_scale_set_label (GimpSpinScale *scale,
+ const gchar *label);
+const gchar * gimp_spin_scale_get_label (GimpSpinScale *scale);
+
+void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
+ gdouble lower,
+ gdouble upper);
+void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale);
+gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
+ gdouble *lower,
+ gdouble *upper);
+
+void gimp_spin_scale_set_gamma (GimpSpinScale *scale,
+ gdouble gamma);
+gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale);
+
+void gimp_spin_scale_set_focuswidget (GtkWidget *scale,
+ GtkWidget *widget);
+
+void gimp_spin_scale_set_appearance (GtkWidget *scale,
+ const gchar *appearance);
+
+G_END_DECLS
+
+#endif /* __GIMP_SPIN_SCALE_H__ */
diff --git a/src/widgets/ruler.cpp b/src/widgets/gimp/ruler.cpp
index 1f6e4396c..bfb9c9071 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/gimp/ruler.cpp
@@ -119,7 +119,6 @@ static void sp_ruler_unmap (GtkWidget *widget);
static void sp_ruler_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_ruler_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
gint *natural_width);
@@ -128,21 +127,11 @@ static void sp_ruler_get_preferred_height (GtkWidget *widget,
gint *minimum_height,
gint *natural_height);
static void sp_ruler_style_updated (GtkWidget *widget);
-#else
-static void sp_ruler_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void sp_ruler_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-#endif
static gboolean sp_ruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gboolean sp_ruler_draw (GtkWidget *widget,
cairo_t *cr);
-#if !GTK_CHECK_VERSION(3,0,0)
-static gboolean sp_ruler_expose (GtkWidget *widget,
- GdkEventExpose *event);
-#endif
static void sp_ruler_draw_ticks (SPRuler *ruler);
static GdkRectangle sp_ruler_get_pos_rect (SPRuler *ruler,
gdouble position);
@@ -180,16 +169,10 @@ sp_ruler_class_init (SPRulerClass *klass)
widget_class->map = sp_ruler_map;
widget_class->unmap = sp_ruler_unmap;
widget_class->size_allocate = sp_ruler_size_allocate;
-#if GTK_CHECK_VERSION(3,0,0)
widget_class->get_preferred_width = sp_ruler_get_preferred_width;
widget_class->get_preferred_height = sp_ruler_get_preferred_height;
widget_class->style_updated = sp_ruler_style_updated;
widget_class->draw = sp_ruler_draw;
-#else
- widget_class->size_request = sp_ruler_size_request;
- widget_class->style_set = sp_ruler_style_set;
- widget_class->expose_event = sp_ruler_expose;
-#endif
widget_class->motion_notify_event = sp_ruler_motion_notify;
g_type_class_add_private (object_class, sizeof (SPRulerPrivate));
@@ -486,16 +469,10 @@ sp_ruler_realize (GtkWidget *widget)
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
-#if GTK_CHECK_VERSION(3,0,0)
attributes.event_mask = (gtk_widget_get_events (widget) |
GDK_EXPOSURE_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
-#else
- attributes.event_mask = (gtk_widget_get_events (widget) |
- GDK_EXPOSURE_MASK |
- GDK_POINTER_MOTION_MASK);
-#endif
attributes_mask = GDK_WA_X | GDK_WA_Y;
@@ -598,7 +575,6 @@ sp_ruler_size_request (GtkWidget *widget,
size = 2 + ink_rect.height * 1.7;
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkBorder border;
@@ -606,47 +582,25 @@ sp_ruler_size_request (GtkWidget *widget,
requisition->width = border.left + border.right;
requisition->height = border.top + border.bottom;
-#else
- GtkStyle *style = gtk_widget_get_style(widget);
-#endif
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
-#if GTK_CHECK_VERSION(3,0,0)
requisition->width += 1;
requisition->height += size;
-#else
- requisition->width = style->xthickness * 2 + 1;
- requisition->height = style->ythickness * 2 + size;
-#endif
}
else
{
-#if GTK_CHECK_VERSION(3,0,0)
requisition->width += size;
requisition->height += 1;
-#else
- requisition->width = style->xthickness * 2 + size;
- requisition->height = style->ythickness * 2 + 1;
-#endif
}
}
static void
-#if GTK_CHECK_VERSION(3,0,0)
sp_ruler_style_updated (GtkWidget *widget)
-#else
-sp_ruler_style_set (GtkWidget *widget,
- GtkStyle *prev_style)
-#endif
{
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (widget);
-#if GTK_CHECK_VERSION(3,0,0)
GTK_WIDGET_CLASS (sp_ruler_parent_class)->style_updated (widget);
-#else
- GTK_WIDGET_CLASS (sp_ruler_parent_class)->style_set (widget, prev_style);
-#endif
gtk_widget_style_get (widget,
"font-scale", &priv->font_scale,
@@ -659,7 +613,6 @@ sp_ruler_style_set (GtkWidget *widget,
}
}
-#if GTK_CHECK_VERSION(3,0,0)
static void
sp_ruler_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
@@ -683,33 +636,19 @@ sp_ruler_get_preferred_height (GtkWidget *widget,
*minimum_height = *natural_height = requisition.height;
}
-#else
-static gboolean
-sp_ruler_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
- GtkAllocation allocation;
-
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gboolean result = sp_ruler_draw (widget, cr);
-
- cairo_destroy (cr);
-
- return result;
-}
-#endif
static gboolean
sp_ruler_draw (GtkWidget *widget,
cairo_t *cr)
{
- SPRuler *ruler = SP_RULER (widget);
- SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ SPRuler *ruler = SP_RULER (widget);
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height);
+ gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height);
sp_ruler_draw_ticks (ruler);
@@ -735,7 +674,7 @@ sp_ruler_make_pixmap (SPRuler *ruler)
priv->backing_store =
gdk_window_create_similar_surface (gtk_widget_get_window (widget),
- CAIRO_CONTENT_COLOR,
+ CAIRO_CONTENT_COLOR_ALPHA,
allocation.width,
allocation.height);
@@ -748,13 +687,8 @@ sp_ruler_draw_pos (SPRuler *ruler,
{
GtkWidget *widget = GTK_WIDGET (ruler);
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GdkRGBA color;
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkStateType state = gtk_widget_get_state (widget);
-#endif
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
GdkRectangle pos_rect;
@@ -766,13 +700,9 @@ sp_ruler_draw_pos (SPRuler *ruler,
if ((pos_rect.width > 0) && (pos_rect.height > 0))
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
&color);
gdk_cairo_set_source_rgba (cr, &color);
-#else
- gdk_cairo_set_source_color (cr, &style->fg[state]);
-#endif
cairo_move_to (cr, pos_rect.x, pos_rect.y);
@@ -1111,16 +1041,9 @@ sp_ruler_draw_ticks (SPRuler *ruler)
{
GtkWidget *widget = GTK_WIDGET (ruler);
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkBorder border;
GdkRGBA color;
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkStateType state = gtk_widget_get_state (widget);
- gint xthickness;
- gint ythickness;
-#endif
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
GtkAllocation allocation;
@@ -1149,12 +1072,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
gtk_widget_get_allocation (widget, &allocation);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_border (context, static_cast<GtkStateFlags>(0), &border);
-#else
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-#endif
layout = sp_ruler_get_layout (widget, "0123456789");
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
@@ -1165,28 +1083,20 @@ sp_ruler_draw_ticks (SPRuler *ruler)
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
width = allocation.width;
-#if GTK_CHECK_VERSION(3,0,0)
height = allocation.height - (border.top + border.bottom);
-#else
- height = allocation.height - ythickness * 2;
-#endif
}
else
{
width = allocation.height;
-#if GTK_CHECK_VERSION(3,0,0)
height = allocation.width - (border.top + border.bottom);
-#else
- height = allocation.width - ythickness * 2;
-#endif
}
cr = cairo_create (priv->backing_store);
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height);
- gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height);
-
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+
gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
&color);
gdk_cairo_set_source_rgba (cr, &color);
@@ -1207,30 +1117,6 @@ sp_ruler_draw_ticks (SPRuler *ruler)
1,
allocation.height - (border.top + border.bottom));
}
-#else
- gdk_cairo_set_source_color (cr, &style->bg[state]);
-
- cairo_paint (cr);
-
- gdk_cairo_set_source_color(cr, &style->fg[state]);
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- cairo_rectangle (cr,
- xthickness,
- height + ythickness,
- allocation.width - 2 * xthickness,
- 1);
- }
- else
- {
- cairo_rectangle (cr,
- height + xthickness,
- ythickness,
- 1,
- allocation.height - 2 * ythickness);
- }
-#endif
sp_ruler_get_range (ruler, &lower, &upper, &max_size);
@@ -1311,7 +1197,6 @@ sp_ruler_draw_ticks (SPRuler *ruler)
// by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-))
pos = gint(Inkscape::round((cur - lower) * increment + 1e-12));
-#if GTK_CHECK_VERSION(3,0,0)
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
cairo_rectangle (cr,
@@ -1324,20 +1209,6 @@ sp_ruler_draw_ticks (SPRuler *ruler)
height + border.left - length, pos,
length, 1);
}
-#else
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- cairo_rectangle (cr,
- pos, height + ythickness - length,
- 1, length);
- }
- else
- {
- cairo_rectangle (cr,
- height + xthickness - length, pos,
- length, 1);
- }
-#endif
/* draw label */
double label_spacing_px = fabs(increment*(double)ruler_metric.ruler_scale[scale]/ruler_metric.subdivide[i]);
@@ -1355,15 +1226,9 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_set_text (layout, unit_str, -1);
pango_layout_get_extents (layout, &logical_rect, NULL);
-#if GTK_CHECK_VERSION(3,0,0)
cairo_move_to (cr,
pos + 2,
border.top + PANGO_PIXELS (logical_rect.y - digit_offset));
-#else
- cairo_move_to (cr,
- pos + 2,
- ythickness + PANGO_PIXELS (logical_rect.y - digit_offset));
-#endif
pango_cairo_show_layout(cr, layout);
}
@@ -1377,15 +1242,9 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_set_text (layout, digit_str, 1);
pango_layout_get_extents (layout, NULL, &logical_rect);
-#if GTK_CHECK_VERSION(3,0,0)
cairo_move_to (cr,
border.left + 1,
pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
-#else
- cairo_move_to (cr,
- xthickness + 1,
- pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
-#endif
pango_cairo_show_layout (cr, layout);
}
}
@@ -1422,7 +1281,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler,
gtk_widget_get_allocation (widget, &allocation);
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkBorder padding;
@@ -1430,11 +1288,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler,
xthickness = padding.left + padding.right;
ythickness = padding.top + padding.bottom;
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-#endif
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -1472,9 +1325,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler,
rect.y = ROUND ((position - lower) * increment) + (ythickness - rect.height) / 2 - 1;
}
- rect.x += allocation.x;
- rect.y += allocation.y;
-
return rect;
}
@@ -1497,18 +1347,21 @@ sp_ruler_queue_pos_redraw (SPRuler *ruler)
{
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
const GdkRectangle rect = sp_ruler_get_pos_rect (ruler, priv->position);
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (GTK_WIDGET(ruler), &allocation);
gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
- rect.x,
- rect.y,
+ rect.x + allocation.x,
+ rect.y + allocation.y,
rect.width,
rect.height);
if (priv->last_pos_rect.width != 0 || priv->last_pos_rect.height != 0)
{
gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
- priv->last_pos_rect.x,
- priv->last_pos_rect.y,
+ priv->last_pos_rect.x + allocation.x,
+ priv->last_pos_rect.y + allocation.y,
priv->last_pos_rect.width,
priv->last_pos_rect.height);
diff --git a/src/widgets/ruler.h b/src/widgets/gimp/ruler.h
index ed529d082..ed529d082 100644
--- a/src/widgets/ruler.h
+++ b/src/widgets/gimp/ruler.h
diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp
index 6901b8549..dff564feb 100644
--- a/src/widgets/gradient-image.cpp
+++ b/src/widgets/gradient-image.cpp
@@ -21,7 +21,6 @@
static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition);
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_image_destroy(GtkWidget *object);
static void sp_gradient_image_get_preferred_width(GtkWidget *widget,
gint *minimal_width,
@@ -30,11 +29,6 @@ static void sp_gradient_image_get_preferred_width(GtkWidget *widget,
static void sp_gradient_image_get_preferred_height(GtkWidget *widget,
gint *minimal_height,
gint *natural_height);
-#else
-static void sp_gradient_image_destroy(GtkObject *object);
-static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event);
-#endif
-
static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *cr);
static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im);
static void sp_gradient_image_gradient_modified (SPObject *, guint flags, SPGradientImage *im);
@@ -46,18 +40,10 @@ static void sp_gradient_image_class_init(SPGradientImageClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
-#if GTK_CHECK_VERSION(3,0,0)
widget_class->get_preferred_width = sp_gradient_image_get_preferred_width;
widget_class->get_preferred_height = sp_gradient_image_get_preferred_height;
widget_class->draw = sp_gradient_image_draw;
widget_class->destroy = sp_gradient_image_destroy;
-#else
- GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
-
- object_class->destroy = sp_gradient_image_destroy;
- widget_class->size_request = sp_gradient_image_size_request;
- widget_class->expose_event = sp_gradient_image_expose;
-#endif
}
static void
@@ -71,11 +57,7 @@ sp_gradient_image_init (SPGradientImage *image)
new (&image->modified_connection) sigc::connection();
}
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_image_destroy(GtkWidget *object)
-#else
-static void sp_gradient_image_destroy(GtkObject *object)
-#endif
{
SPGradientImage *image = SP_GRADIENT_IMAGE (object);
@@ -88,13 +70,8 @@ static void sp_gradient_image_destroy(GtkObject *object)
image->release_connection.~connection();
image->modified_connection.~connection();
-#if GTK_CHECK_VERSION(3,0,0)
if (GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy)
GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy(object);
-#else
- if (GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy)
- GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy(object);
-#endif
}
static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisition *requisition)
@@ -103,7 +80,6 @@ static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisitio
requisition->height = 12;
}
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_image_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
GtkRequisition requisition;
@@ -117,27 +93,6 @@ static void sp_gradient_image_get_preferred_height(GtkWidget *widget, gint *mini
sp_gradient_image_size_request(widget, &requisition);
*minimal_height = *natural_height = requisition.height;
}
-#endif
-
-#if !GTK_CHECK_VERSION(3,0,0)
-static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- gboolean result = TRUE;
- if(gtk_widget_is_drawable(widget)) {
- cairo_t *ct = gdk_cairo_create(gtk_widget_get_window (widget));
- cairo_rectangle(ct, event->area.x, event->area.y,
- event->area.width, event->area.height);
- cairo_clip(ct);
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
- cairo_translate(ct, allocation.x, allocation.y);
- result = sp_gradient_image_draw(widget, ct);
- cairo_destroy(ct);
- }
-
- return result;
-}
-#endif
static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct)
{
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 425eb9cbc..569f66c2b 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -57,11 +57,7 @@ static void sp_gradient_selector_delete_vector_clicked (GtkWidget *w, SPGradient
static guint signals[LAST_SIGNAL] = {0};
-#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_VBOX);
-#endif
static void sp_gradient_selector_class_init(SPGradientSelectorClass *klass)
{
@@ -113,9 +109,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
sel->safelyInit = true;
sel->blocked = false;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(sel), GTK_ORIENTATION_VERTICAL);
-#endif
new (&sel->nonsolid) std::vector<GtkWidget*>();
new (&sel->swatch_widgets) std::vector<GtkWidget*>();
@@ -177,13 +171,8 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
/* Create box for buttons */
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new( FALSE, 2 );
-#endif
- //sel->nonsolid.push_back(hb);
gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
sel->add = gtk_button_new();
diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h
index e090d7cbd..6b5d4ca60 100644
--- a/src/widgets/gradient-selector.h
+++ b/src/widgets/gradient-selector.h
@@ -45,11 +45,7 @@ class TreeView;
struct SPGradientSelector {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBox vbox;
-#else
- GtkVBox vbox;
-#endif
enum SelectorMode {
MODE_LINEAR,
@@ -131,11 +127,7 @@ struct SPGradientSelector {
};
struct SPGradientSelectorClass {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif
void (* grabbed) (SPGradientSelector *sel);
void (* dragged) (SPGradientSelector *sel);
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index 6c89f6a3b..8474327ca 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -27,7 +27,9 @@
#include "gradient-chemistry.h"
#include "gradient-drag.h"
#include "gradient-toolbar.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "macros.h"
#include "selection.h"
#include "sp-defs.h"
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 5ad89137a..0c5f3cf47 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -63,11 +63,7 @@ enum {
LAST_SIGNAL
};
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_selector_destroy(GtkWidget *object);
-#else
-static void sp_gradient_vector_selector_destroy(GtkObject *object);
-#endif
static void sp_gvs_gradient_release(SPObject *obj, SPGradientVectorSelector *gvs);
static void sp_gvs_defs_release(SPObject *defs, SPGradientVectorSelector *gvs);
@@ -86,11 +82,7 @@ static win_data wd;
static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs
static Glib::ustring const prefs_path = "/dialogs/gradienteditor/";
-#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_VBOX);
-#endif
static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass)
{
@@ -105,20 +97,13 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass
G_TYPE_NONE, 1,
G_TYPE_POINTER);
-#if GTK_CHECK_VERSION(3,0,0)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
widget_class->destroy = sp_gradient_vector_selector_destroy;
-#else
- GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
- object_class->destroy = sp_gradient_vector_selector_destroy;
-#endif
}
static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs)
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(gvs), GTK_ORIENTATION_VERTICAL);
-#endif
gvs->idlabel = TRUE;
@@ -137,11 +122,7 @@ static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs)
}
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_selector_destroy(GtkWidget *object)
-#else
-static void sp_gradient_vector_selector_destroy(GtkObject *object)
-#endif
{
SPGradientVectorSelector *gvs = SP_GRADIENT_VECTOR_SELECTOR(object);
@@ -162,15 +143,9 @@ static void sp_gradient_vector_selector_destroy(GtkObject *object)
gvs->defs_modified_connection.~connection();
gvs->tree_select_connection.~connection();
-#if GTK_CHECK_VERSION(3,0,0)
if ((GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy) {
(GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object);
}
-#else
- if ((GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy) {
- (GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object);
- }
-#endif
}
GtkWidget *sp_gradient_vector_selector_new(SPDocument *doc, SPGradient *gr)
@@ -480,15 +455,8 @@ static GtkWidget *sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *st
static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient);
static gint sp_gradient_vector_dialog_delete(GtkWidget *widget, GdkEvent *event, GtkWidget *dialog);
-
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_dialog_destroy(GtkWidget *object, gpointer data);
static void sp_gradient_vector_widget_destroy(GtkWidget *object, gpointer data);
-#else
-static void sp_gradient_vector_dialog_destroy(GtkObject *object, gpointer data);
-static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer data);
-#endif
-
static void sp_gradient_vector_gradient_release(SPObject *obj, GtkWidget *widget);
static void sp_gradient_vector_gradient_modified(SPObject *obj, guint flags, GtkWidget *widget);
static void sp_gradient_vector_color_dragged(Inkscape::UI::SelectedColor *selected_color, GObject *object);
@@ -841,12 +809,8 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
g_return_val_if_fail(gradient != NULL, NULL);
g_return_val_if_fail(SP_IS_GRADIENT(gradient), NULL);
-#if GTK_CHECK_VERSION(3,0,0)
vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, PAD);
gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
-#else
- vb = gtk_vbox_new(FALSE, PAD);
-#endif
g_signal_connect(G_OBJECT(vb), "destroy", G_CALLBACK(sp_gradient_vector_widget_destroy), NULL);
w = sp_gradient_image_new(gradient);
@@ -879,12 +843,8 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
g_signal_connect(G_OBJECT(combo_box), "changed", G_CALLBACK(sp_grad_edit_combo_box_changed), vb);
/* Add and Remove buttons */
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 1);
-#endif
// TRANSLATORS: "Stop" means: a "phase" of a gradient
GtkWidget *b = gtk_button_new_with_label(_("Add stop"));
gtk_widget_show(b);
@@ -901,21 +861,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
gtk_box_pack_start(GTK_BOX(vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
/* Offset Slider and stuff */
-#if GTK_CHECK_VERSION(3,0,0)
hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- hb = gtk_hbox_new(FALSE, 0);
-#endif
/* Label */
GtkWidget *l = gtk_label_new(C_("Gradient","Offset:"));
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(l, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
-#endif
gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
gtk_widget_show(l);
@@ -933,11 +884,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
gtk_adjustment_set_value(Offset_adj, stop->offset);
/* Slider */
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, Offset_adj);
-#else
- GtkWidget *slider = gtk_hscale_new(Offset_adj);
-#endif
+ auto slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, Offset_adj);
gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE );
gtk_widget_show(slider);
gtk_box_pack_start(GTK_BOX(hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);
@@ -1175,11 +1122,7 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien
blocked = FALSE;
}
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_dialog_destroy(GtkWidget * /*object*/, gpointer /*data*/)
-#else
-static void sp_gradient_vector_dialog_destroy(GtkObject * /*object*/, gpointer /*data*/)
-#endif
{
GObject *obj = G_OBJECT(dlg);
assert(obj != NULL);
@@ -1230,11 +1173,7 @@ static gboolean sp_gradient_vector_dialog_delete(GtkWidget */*widget*/, GdkEvent
}
/* Widget destroy handler */
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_widget_destroy(GtkWidget *object, gpointer /*data*/)
-#else
-static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data*/)
-#endif
{
SPObject *gradient = SP_OBJECT(g_object_get_data(G_OBJECT(object), "gradient"));
diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h
index 5ae90b28f..b51b276b9 100644
--- a/src/widgets/gradient-vector.h
+++ b/src/widgets/gradient-vector.h
@@ -35,11 +35,7 @@ class SPGradient;
class SPStop;
struct SPGradientVectorSelector {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBox vbox;
-#else
- GtkVBox vbox;
-#endif
guint idlabel : 1;
@@ -61,11 +57,7 @@ struct SPGradientVectorSelector {
};
struct SPGradientVectorSelectorClass {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif
void (* vector_set) (SPGradientVectorSelector *gvs, SPGradient *gr);
};
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 515deb565..1efa8f06b 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -61,10 +61,6 @@ struct IconImpl {
static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
static gboolean draw(GtkWidget *widget, cairo_t *cr);
-#if !GTK_CHECK_VERSION(3,0,0)
- static gboolean expose(GtkWidget *widget, GdkEventExpose *event);
-#endif
-
static void screenChanged( GtkWidget *widget, GdkScreen *previous_screen );
static void styleSet( GtkWidget *widget, GtkStyle *previous_style );
static void themeChanged( SPIcon *icon );
@@ -146,14 +142,9 @@ sp_icon_class_init(SPIconClass *klass)
object_class->dispose = IconImpl::dispose;
-#if GTK_CHECK_VERSION(3,0,0)
widget_class->get_preferred_width = IconImpl::getPreferredWidth;
widget_class->get_preferred_height = IconImpl::getPreferredHeight;
widget_class->draw = IconImpl::draw;
-#else
- widget_class->size_request = IconImpl::sizeRequest;
- widget_class->expose_event = IconImpl::expose;
-#endif
widget_class->size_allocate = IconImpl::sizeAllocate;
widget_class->screen_changed = IconImpl::screenChanged;
widget_class->style_set = IconImpl::styleSet;
@@ -241,37 +232,15 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
bool unref_image = false;
/* copied from the expose function of GtkImage */
-#if GTK_CHECK_VERSION(3,0,0)
if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) {
-#else
- if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) {
- std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl;
-#endif
std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl;
-#if GTK_CHECK_VERSION(3,0,0)
- // image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget),
- // source,
- // (GtkIconSize)-1);
-
- // gtk_render_icon_pixbuf deprecated, replaced by:
GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
image = gtk_icon_theme_load_icon (icon_theme,
"gtk-image",
32,
(GtkIconLookupFlags)0,
NULL);
-#else
- GtkIconSource *source = gtk_icon_source_new();
- gtk_icon_source_set_pixbuf(source, icon->pb);
- gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used
- gtk_icon_source_set_size_wildcarded(source, FALSE);
- image = gtk_style_render_icon(gtk_widget_get_style(widget), source,
- gtk_widget_get_direction(widget),
- (GtkStateType) gtk_widget_get_state(widget),
- (GtkIconSize)-1, widget, "gtk-image");
- gtk_icon_source_free(source);
-#endif
unref_image = true;
}
@@ -280,12 +249,7 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
GtkAllocation allocation;
GtkRequisition requisition;
gtk_widget_get_allocation(widget, &allocation);
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_get_preferred_size(widget, &requisition, NULL);
-#else
- gtk_widget_get_requisition(widget, &requisition);
-#endif
int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5));
int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5));
@@ -305,21 +269,6 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
return TRUE;
}
-#if !GTK_CHECK_VERSION(3,0,0)
-gboolean IconImpl::expose(GtkWidget *widget, GdkEventExpose * /*event*/)
-{
- gboolean result = TRUE;
-
- if (gtk_widget_is_drawable(widget)) {
- cairo_t * cr = gdk_cairo_create(gtk_widget_get_window(widget));
- result = draw(widget, cr);
- cairo_destroy(cr);
- }
-
- return result;
-}
-#endif
-
// PUBLIC CALL:
void sp_icon_fetch_pixbuf( SPIcon *icon )
{
diff --git a/src/widgets/ink-action.cpp b/src/widgets/ink-action.cpp
index c0797b236..2f1bf94e4 100644
--- a/src/widgets/ink-action.cpp
+++ b/src/widgets/ink-action.cpp
@@ -1,14 +1,9 @@
+#include "ink-action.h"
#include "widgets/icon.h"
-#include "widgets/ink-action.h"
+#include "widgets/image-menu-item.h"
-#include "widgets/button.h"
-
-#if GTK_CHECK_VERSION(3,0,0)
- // Fork of gtk-imagemenuitem to continue support
- #include "widgets/image-menu-item.h"
-
-#endif
+#include <gtk/gtk.h>
static void ink_action_finalize( GObject* obj );
static void ink_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
@@ -160,12 +155,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action )
if ( act->private_data->iconId ) {
gchar* label = 0;
g_object_get( G_OBJECT(act), "label", &label, NULL );
-
-#if GTK_CHECK_VERSION(3,0,0)
item = image_menu_item_new_with_mnemonic( label );
-#else
- item = gtk_image_menu_item_new_with_mnemonic( label );
-#endif
GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId );
// TODO this work-around is until SPIcon will live properly inside of a popup menu
@@ -180,12 +170,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action )
}
}
gtk_widget_show_all( child );
-
-#if GTK_CHECK_VERSION(3,0,0)
image_menu_item_set_image( IMAGE_MENU_ITEM(item), child );
-#else
- gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child );
-#endif
g_free( label );
label = 0;
@@ -220,454 +205,13 @@ static GtkWidget* ink_action_create_tool_item( GtkAction* action )
return item;
}
-
-
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-
-static void ink_toggle_action_finalize( GObject* obj );
-static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
-static void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
-
-static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action );
-static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action );
-
-static void ink_toggle_action_update_icon( InkToggleAction* action );
-
-struct _InkToggleActionPrivate
-{
- gchar* iconId;
- Inkscape::IconSize iconSize;
-};
-
-#define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) )
-
-G_DEFINE_TYPE(InkToggleAction, ink_toggle_action, GTK_TYPE_TOGGLE_ACTION);
-
-static void ink_toggle_action_class_init( InkToggleActionClass* klass )
-{
- if ( klass ) {
- GObjectClass * objClass = G_OBJECT_CLASS( klass );
-
- objClass->finalize = ink_toggle_action_finalize;
- objClass->get_property = ink_toggle_action_get_property;
- objClass->set_property = ink_toggle_action_set_property;
-
- klass->parent_class.parent_class.create_menu_item = ink_toggle_action_create_menu_item;
- klass->parent_class.parent_class.create_tool_item = ink_toggle_action_create_tool_item;
- /*klass->parent_class.connect_proxy = connect_proxy;*/
- /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/
-
- g_object_class_install_property( objClass,
- PROP_INK_ID,
- g_param_spec_string( "iconId",
- "Icon ID",
- "The id for the icon",
- "",
- (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
-
- g_object_class_install_property( objClass,
- PROP_INK_SIZE,
- g_param_spec_int( "iconSize",
- "Icon Size",
- "The size the icon",
- (int)Inkscape::ICON_SIZE_MENU,
- (int)99,
- (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
- (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
-
- g_type_class_add_private( klass, sizeof(InkToggleActionClass) );
- }
-}
-
-static void ink_toggle_action_init( InkToggleAction* action )
-{
- action->private_data = INK_TOGGLE_ACTION_GET_PRIVATE( action );
- action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
-}
-
-static void ink_toggle_action_finalize( GObject* obj )
-{
- InkToggleAction* action = INK_TOGGLE_ACTION( obj );
-
- g_free( action->private_data->iconId );
- g_free( action->private_data );
-
-}
-
-InkToggleAction* ink_toggle_action_new( const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size,
- SPAttributeEnum attr)
-{
- GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "iconId", inkId,
- "iconSize", Inkscape::getRegisteredIconSize(size),
- //"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below?
- NULL );
-
- g_object_set_data(obj, "SP_ATTR_INKSCAPE", GINT_TO_POINTER(attr));
- InkToggleAction* action = INK_TOGGLE_ACTION( obj );
-
- return action;
-}
-
-static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec )
-{
- InkToggleAction* action = INK_TOGGLE_ACTION( obj );
- (void)action;
- switch ( propId ) {
- case PROP_INK_ID:
- {
- g_value_set_string( value, action->private_data->iconId );
- }
- break;
-
- case PROP_INK_SIZE:
- {
- g_value_set_int( value, action->private_data->iconSize );
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
- }
-}
-
-void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec )
-{
- InkToggleAction* action = INK_TOGGLE_ACTION( obj );
- (void)action;
- switch ( propId ) {
- case PROP_INK_ID:
- {
- gchar* tmp = action->private_data->iconId;
- action->private_data->iconId = g_value_dup_string( value );
- g_free( tmp );
-
- ink_toggle_action_update_icon( action );
- }
- break;
-
- case PROP_INK_SIZE:
- {
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
- }
- break;
-
- default:
- {
- G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
- }
- }
-}
-
-static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action )
-{
- GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_menu_item(action);
-
- return item;
-}
-
-static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
-{
- InkToggleAction* act = INK_TOGGLE_ACTION( action );
-
- GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action);
- if ( GTK_IS_TOOL_BUTTON(item) ) {
- GtkToolButton* button = GTK_TOOL_BUTTON(item);
- if ( act->private_data->iconId ) {
- GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_hexpand(child, FALSE);
- gtk_widget_set_vexpand(child, FALSE);
- gtk_tool_button_set_icon_widget(button, child);
-#else
- GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
- gtk_container_add( GTK_CONTAINER(align), child );
- gtk_tool_button_set_icon_widget( button, align );
-#endif
- } else {
- gchar *label = 0;
- g_object_get( G_OBJECT(action), "short_label", &label, NULL );
- gtk_tool_button_set_label( button, label );
- g_free( label );
- label = 0;
- }
- } else {
- // For now trigger a warning but don't do anything else
- GtkToolButton* button = GTK_TOOL_BUTTON(item);
- (void)button;
- }
- gtk_widget_show_all( item );
-
- return item;
-}
-
-
-static void ink_toggle_action_update_icon( InkToggleAction* action )
-{
- if ( action ) {
- GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
- while ( proxies ) {
- if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
- if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
- GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
-
- GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_hexpand(child, FALSE);
- gtk_widget_set_vexpand(child, FALSE);
- gtk_widget_show_all(child);
- gtk_tool_button_set_icon_widget(button, child);
-#else
- GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
- gtk_container_add( GTK_CONTAINER(align), child );
- gtk_widget_show_all( align );
- gtk_tool_button_set_icon_widget( button, align );
-#endif
- }
- }
-
- proxies = g_slist_next( proxies );
- }
- }
-}
-
-
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-
-static void ink_radio_action_finalize( GObject* obj );
-static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
-static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
-
-static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action );
-static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action );
-
-struct _InkRadioActionPrivate
-{
- gchar* iconId;
- Inkscape::IconSize iconSize;
-};
-
-#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) )
-
-G_DEFINE_TYPE(InkRadioAction, ink_radio_action, GTK_TYPE_RADIO_ACTION);
-
-static void ink_radio_action_class_init( InkRadioActionClass* klass )
-{
- if ( klass ) {
- GObjectClass * objClass = G_OBJECT_CLASS( klass );
-
- objClass->finalize = ink_radio_action_finalize;
- objClass->get_property = ink_radio_action_get_property;
- objClass->set_property = ink_radio_action_set_property;
-
- klass->parent_class.parent_class.parent_class.create_menu_item = ink_radio_action_create_menu_item;
- klass->parent_class.parent_class.parent_class.create_tool_item = ink_radio_action_create_tool_item;
- /*klass->parent_class.connect_proxy = connect_proxy;*/
- /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/
-
- g_object_class_install_property( objClass,
- PROP_INK_ID,
- g_param_spec_string( "iconId",
- "Icon ID",
- "The id for the icon",
- "",
- (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
-
- g_object_class_install_property( objClass,
- PROP_INK_SIZE,
- g_param_spec_int( "iconSize",
- "Icon Size",
- "The size the icon",
- (int)Inkscape::ICON_SIZE_MENU,
- (int)Inkscape::ICON_SIZE_DECORATION,
- (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
- (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
-
- g_type_class_add_private( klass, sizeof(InkRadioActionClass) );
- }
-}
-
-static void ink_radio_action_init( InkRadioAction* action )
-{
- action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action );
- action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
-}
-
-static void ink_radio_action_finalize( GObject* obj )
-{
- InkRadioAction* action = INK_RADIO_ACTION( obj );
-
- g_free( action->private_data->iconId );
- g_free( action->private_data );
-
-}
-
-InkRadioAction* ink_radio_action_new( const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size )
-{
- GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "iconId", inkId,
- "iconSize", Inkscape::getRegisteredIconSize(size),
- NULL );
-
- InkRadioAction* action = INK_RADIO_ACTION( obj );
-
- return action;
-}
-
-static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec )
-{
- InkRadioAction* action = INK_RADIO_ACTION( obj );
- (void)action;
- switch ( propId ) {
- case PROP_INK_ID:
- {
- g_value_set_string( value, action->private_data->iconId );
- }
- break;
-
- case PROP_INK_SIZE:
- {
- g_value_set_int( value, action->private_data->iconSize );
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
- }
-}
-
-void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec )
-{
- InkRadioAction* action = INK_RADIO_ACTION( obj );
- (void)action;
- switch ( propId ) {
- case PROP_INK_ID:
- {
- gchar* tmp = action->private_data->iconId;
- action->private_data->iconId = g_value_dup_string( value );
- g_free( tmp );
- }
- break;
-
- case PROP_INK_SIZE:
- {
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
- }
- break;
-
- default:
- {
- G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
- }
- }
-}
-
-static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action )
-{
- GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_menu_item(action);
-
- return item;
-}
-
-static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
-{
- InkRadioAction* act = INK_RADIO_ACTION( action );
- GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action);
-
- if ( act->private_data->iconId ) {
- if ( GTK_IS_TOOL_BUTTON(item) ) {
- GtkToolButton* button = GTK_TOOL_BUTTON(item);
-
- GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_hexpand(child, FALSE);
- gtk_widget_set_vexpand(child, FALSE);
- gtk_tool_button_set_icon_widget(button, child);
-#else
- GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
- gtk_container_add( GTK_CONTAINER(align), child );
- gtk_tool_button_set_icon_widget( button, align );
-#endif
- } else {
- // For now trigger a warning but don't do anything else
- GtkToolButton* button = GTK_TOOL_BUTTON(item);
- (void)button;
- }
- }
-
- // TODO investigate if needed
- gtk_widget_show_all( item );
-
- return item;
-}
-
-
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215
-
-G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE);
-
-static void
-ink_tool_menu_action_class_init (InkToolMenuActionClass *klass)
-{
- GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
- action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
-}
-
-static void
-ink_tool_menu_action_init (InkToolMenuAction* /*tma*/)
-{
-}
-
-InkToolMenuAction *
-ink_tool_menu_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size )
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "iconId", inkId,
- "iconSize", size,
- NULL );
-
- InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj );
-
- return action;
-}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-action.h b/src/widgets/ink-action.h
index ac5cb9873..738212c61 100644
--- a/src/widgets/ink-action.h
+++ b/src/widgets/ink-action.h
@@ -1,7 +1,6 @@
#ifndef SEEN_INK_ACTION
#define SEEN_INK_ACTION
-
#include <gtk/gtk.h>
#include "icon-size.h"
#include "attributes.h"
@@ -41,119 +40,16 @@ InkAction* ink_action_new( const gchar *name,
Inkscape::IconSize size );
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-
-#define INK_TOGGLE_ACTION_TYPE ( ink_toggle_action_get_type() )
-#define INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleAction) )
-#define INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) )
-#define IS_INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOGGLE_ACTION_TYPE) )
-#define IS_INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOGGLE_ACTION_TYPE) )
-#define INK_TOGGLE_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) )
-
-typedef struct _InkToggleAction InkToggleAction;
-typedef struct _InkToggleActionClass InkToggleActionClass;
-typedef struct _InkToggleActionPrivate InkToggleActionPrivate;
-
-struct _InkToggleAction
-{
- GtkToggleAction action;
- InkToggleActionPrivate *private_data;
-};
-
-struct _InkToggleActionClass
-{
- GtkToggleActionClass parent_class;
-};
-
-GType ink_toggle_action_get_type( void );
-
-InkToggleAction* ink_toggle_action_new( const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size,
- SPAttributeEnum attr = SP_ATTR_INVALID);
-
-
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-
-#define INK_RADIO_ACTION_TYPE ( ink_radio_action_get_type() )
-#define INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_RADIO_ACTION_TYPE, InkRadioAction) )
-#define INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_RADIO_ACTION_TYPE, InkRadioActionClass) )
-#define IS_INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_RADIO_ACTION_TYPE) )
-#define IS_INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_RADIO_ACTION_TYPE) )
-#define INK_RADIO_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_RADIO_ACTION_TYPE, InkRadioActionClass) )
-
-typedef struct _InkRadioAction InkRadioAction;
-typedef struct _InkRadioActionClass InkRadioActionClass;
-typedef struct _InkRadioActionPrivate InkRadioActionPrivate;
-
-struct _InkRadioAction
-{
- GtkRadioAction action;
- InkRadioActionPrivate *private_data;
-};
-
-struct _InkRadioActionClass
-{
- GtkRadioActionClass parent_class;
-};
-
-GType ink_radio_action_get_type( void );
-
-InkRadioAction* ink_radio_action_new( const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size );
-
-
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-/* --------------------------------------------------------------- */
-
-// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215
-
-#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() )
-#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) )
-#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) )
-#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) )
-#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) )
-#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) )
-
-typedef struct _InkToolMenuAction InkToolMenuAction;
-typedef struct _InkToolMenuActionClass InkToolMenuActionClass;
-typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate;
-
-struct _InkToolMenuAction
-{
- InkAction action;
-};
-
-struct _InkToolMenuActionClass
-{
- InkActionClass parent_class;
-};
-
-GType ink_tool_menu_action_get_type( void );
-
-InkToolMenuAction* ink_tool_menu_action_new( const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *inkId,
- Inkscape::IconSize size );
-
-
-
G_END_DECLS
#endif /* SEEN_INK_ACTION */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-comboboxentry-action.cpp b/src/widgets/ink-comboboxentry-action.cpp
index ec5e26cf5..2fecb06a4 100644
--- a/src/widgets/ink-comboboxentry-action.cpp
+++ b/src/widgets/ink-comboboxentry-action.cpp
@@ -371,16 +371,10 @@ GtkWidget* create_tool_item( GtkAction* action )
g_free( combobox_name );
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(comboBoxEntry, GTK_ALIGN_START);
gtk_widget_set_hexpand(comboBoxEntry, FALSE);
gtk_widget_set_vexpand(comboBoxEntry, FALSE);
gtk_container_add(GTK_CONTAINER(item), comboBoxEntry);
-#else
- GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
- gtk_container_add( GTK_CONTAINER(align), comboBoxEntry );
- gtk_container_add( GTK_CONTAINER(item), align );
-#endif
}
ink_comboboxentry_action->combobox = GTK_COMBO_BOX (comboBoxEntry);
@@ -414,11 +408,7 @@ GtkWidget* create_tool_item( GtkAction* action )
// Optionally widen the combobox width... which widens the drop-down list in list mode.
if( ink_comboboxentry_action->extra_width > 0 ) {
GtkRequisition req;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_get_preferred_size(GTK_WIDGET(ink_comboboxentry_action->combobox), &req, NULL);
-#else
- gtk_widget_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), &req );
-#endif
gtk_widget_set_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ),
req.width + ink_comboboxentry_action->extra_width, -1 );
}
@@ -635,11 +625,7 @@ void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action,
// Widget may not have been created....
if( action->combobox ) {
GtkRequisition req;
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_get_preferred_size(GTK_WIDGET(action->combobox), &req, NULL);
-#else
- gtk_widget_size_request( GTK_WIDGET( action->combobox ), &req );
-#endif
gtk_widget_set_size_request( GTK_WIDGET( action->combobox ), req.width + action->extra_width, -1 );
}
}
diff --git a/src/widgets/ink-radio-action.cpp b/src/widgets/ink-radio-action.cpp
new file mode 100644
index 000000000..2113819c3
--- /dev/null
+++ b/src/widgets/ink-radio-action.cpp
@@ -0,0 +1,185 @@
+#include "ink-radio-action.h"
+
+static void ink_radio_action_finalize( GObject* obj );
+static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
+static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
+
+static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action );
+static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action );
+
+struct _InkRadioActionPrivate
+{
+ gchar* iconId;
+ Inkscape::IconSize iconSize;
+};
+
+#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) )
+
+G_DEFINE_TYPE(InkRadioAction, ink_radio_action, GTK_TYPE_RADIO_ACTION);
+
+enum {
+ PROP_INK_ID = 1,
+ PROP_INK_SIZE
+};
+
+static void ink_radio_action_class_init( InkRadioActionClass* klass )
+{
+ if ( klass ) {
+ GObjectClass * objClass = G_OBJECT_CLASS( klass );
+
+ objClass->finalize = ink_radio_action_finalize;
+ objClass->get_property = ink_radio_action_get_property;
+ objClass->set_property = ink_radio_action_set_property;
+
+ klass->parent_class.parent_class.parent_class.create_menu_item = ink_radio_action_create_menu_item;
+ klass->parent_class.parent_class.parent_class.create_tool_item = ink_radio_action_create_tool_item;
+ /*klass->parent_class.connect_proxy = connect_proxy;*/
+ /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/
+
+ g_object_class_install_property( objClass,
+ PROP_INK_ID,
+ g_param_spec_string( "iconId",
+ "Icon ID",
+ "The id for the icon",
+ "",
+ (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
+
+ g_object_class_install_property( objClass,
+ PROP_INK_SIZE,
+ g_param_spec_int( "iconSize",
+ "Icon Size",
+ "The size the icon",
+ (int)Inkscape::ICON_SIZE_MENU,
+ (int)Inkscape::ICON_SIZE_DECORATION,
+ (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
+
+ g_type_class_add_private( klass, sizeof(InkRadioActionClass) );
+ }
+}
+
+static void ink_radio_action_init( InkRadioAction* action )
+{
+ action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action );
+ action->private_data->iconId = 0;
+ action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+}
+
+static void ink_radio_action_finalize( GObject* obj )
+{
+ InkRadioAction* action = INK_RADIO_ACTION( obj );
+
+ g_free( action->private_data->iconId );
+ g_free( action->private_data );
+
+}
+
+InkRadioAction* ink_radio_action_new( const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size )
+{
+ GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "iconId", inkId,
+ "iconSize", Inkscape::getRegisteredIconSize(size),
+ NULL );
+
+ InkRadioAction* action = INK_RADIO_ACTION( obj );
+
+ return action;
+}
+
+static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec )
+{
+ InkRadioAction* action = INK_RADIO_ACTION( obj );
+ (void)action;
+ switch ( propId ) {
+ case PROP_INK_ID:
+ {
+ g_value_set_string( value, action->private_data->iconId );
+ }
+ break;
+
+ case PROP_INK_SIZE:
+ {
+ g_value_set_int( value, action->private_data->iconSize );
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
+ }
+}
+
+void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec )
+{
+ InkRadioAction* action = INK_RADIO_ACTION( obj );
+ (void)action;
+ switch ( propId ) {
+ case PROP_INK_ID:
+ {
+ gchar* tmp = action->private_data->iconId;
+ action->private_data->iconId = g_value_dup_string( value );
+ g_free( tmp );
+ }
+ break;
+
+ case PROP_INK_SIZE:
+ {
+ action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ }
+ break;
+
+ default:
+ {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
+ }
+ }
+}
+
+static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action )
+{
+ GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_menu_item(action);
+
+ return item;
+}
+
+static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
+{
+ InkRadioAction* act = INK_RADIO_ACTION( action );
+ GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action);
+
+ if ( act->private_data->iconId ) {
+ if ( GTK_IS_TOOL_BUTTON(item) ) {
+ GtkToolButton* button = GTK_TOOL_BUTTON(item);
+
+ GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_tool_button_set_icon_widget(button, child);
+ } else {
+ // For now trigger a warning but don't do anything else
+ GtkToolButton* button = GTK_TOOL_BUTTON(item);
+ (void)button;
+ }
+ }
+
+ // TODO investigate if needed
+ gtk_widget_show_all( item );
+
+ return item;
+}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-radio-action.h b/src/widgets/ink-radio-action.h
new file mode 100644
index 000000000..c1f059c4f
--- /dev/null
+++ b/src/widgets/ink-radio-action.h
@@ -0,0 +1,52 @@
+#ifndef INK_RADIO_ACTION_H
+#define INK_RADIO_ACTION_H
+
+#include <gtk/gtk.h>
+
+#include "icon.h"
+
+G_BEGIN_DECLS
+
+#define INK_RADIO_ACTION_TYPE ( ink_radio_action_get_type() )
+#define INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_RADIO_ACTION_TYPE, InkRadioAction) )
+#define INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_RADIO_ACTION_TYPE, InkRadioActionClass) )
+#define IS_INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_RADIO_ACTION_TYPE) )
+#define IS_INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_RADIO_ACTION_TYPE) )
+#define INK_RADIO_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_RADIO_ACTION_TYPE, InkRadioActionClass) )
+
+typedef struct _InkRadioAction InkRadioAction;
+typedef struct _InkRadioActionClass InkRadioActionClass;
+typedef struct _InkRadioActionPrivate InkRadioActionPrivate;
+
+struct _InkRadioAction
+{
+ GtkRadioAction action;
+ InkRadioActionPrivate *private_data;
+};
+
+struct _InkRadioActionClass
+{
+ GtkRadioActionClass parent_class;
+};
+
+GType ink_radio_action_get_type( void );
+
+InkRadioAction* ink_radio_action_new( const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size );
+
+G_END_DECLS
+
+#endif // INK_RADIO_ACTION_H
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-toggle-action.cpp b/src/widgets/ink-toggle-action.cpp
new file mode 100644
index 000000000..3eed974dc
--- /dev/null
+++ b/src/widgets/ink-toggle-action.cpp
@@ -0,0 +1,221 @@
+#include "ink-toggle-action.h"
+#include "icon.h"
+
+static void ink_toggle_action_finalize( GObject* obj );
+static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
+static void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
+
+static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action );
+static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action );
+
+static void ink_toggle_action_update_icon( InkToggleAction* action );
+
+struct _InkToggleActionPrivate
+{
+ gchar* iconId;
+ Inkscape::IconSize iconSize;
+};
+
+#define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) )
+
+G_DEFINE_TYPE(InkToggleAction, ink_toggle_action, GTK_TYPE_TOGGLE_ACTION);
+
+enum {
+ PROP_INK_ID = 1,
+ PROP_INK_SIZE
+};
+
+static void ink_toggle_action_class_init( InkToggleActionClass* klass )
+{
+ if ( klass ) {
+ GObjectClass * objClass = G_OBJECT_CLASS( klass );
+
+ objClass->finalize = ink_toggle_action_finalize;
+ objClass->get_property = ink_toggle_action_get_property;
+ objClass->set_property = ink_toggle_action_set_property;
+
+ klass->parent_class.parent_class.create_menu_item = ink_toggle_action_create_menu_item;
+ klass->parent_class.parent_class.create_tool_item = ink_toggle_action_create_tool_item;
+ /*klass->parent_class.connect_proxy = connect_proxy;*/
+ /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/
+
+ g_object_class_install_property( objClass,
+ PROP_INK_ID,
+ g_param_spec_string( "iconId",
+ "Icon ID",
+ "The id for the icon",
+ "",
+ (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
+
+ g_object_class_install_property( objClass,
+ PROP_INK_SIZE,
+ g_param_spec_int( "iconSize",
+ "Icon Size",
+ "The size the icon",
+ (int)Inkscape::ICON_SIZE_MENU,
+ (int)99,
+ (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
+
+ g_type_class_add_private( klass, sizeof(InkToggleActionClass) );
+ }
+}
+
+static void ink_toggle_action_init( InkToggleAction* action )
+{
+ action->private_data = INK_TOGGLE_ACTION_GET_PRIVATE( action );
+ action->private_data->iconId = 0;
+ action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+}
+
+static void ink_toggle_action_finalize( GObject* obj )
+{
+ InkToggleAction* action = INK_TOGGLE_ACTION( obj );
+
+ g_free( action->private_data->iconId );
+ g_free( action->private_data );
+
+}
+
+InkToggleAction* ink_toggle_action_new( const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size,
+ SPAttributeEnum attr)
+{
+ GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "iconId", inkId,
+ "iconSize", Inkscape::getRegisteredIconSize(size),
+ //"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below?
+ NULL );
+
+ g_object_set_data(obj, "SP_ATTR_INKSCAPE", GINT_TO_POINTER(attr));
+ InkToggleAction* action = INK_TOGGLE_ACTION( obj );
+
+ return action;
+}
+
+static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec )
+{
+ InkToggleAction* action = INK_TOGGLE_ACTION( obj );
+ (void)action;
+ switch ( propId ) {
+ case PROP_INK_ID:
+ {
+ g_value_set_string( value, action->private_data->iconId );
+ }
+ break;
+
+ case PROP_INK_SIZE:
+ {
+ g_value_set_int( value, action->private_data->iconSize );
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
+ }
+}
+
+void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec )
+{
+ InkToggleAction* action = INK_TOGGLE_ACTION( obj );
+ (void)action;
+ switch ( propId ) {
+ case PROP_INK_ID:
+ {
+ gchar* tmp = action->private_data->iconId;
+ action->private_data->iconId = g_value_dup_string( value );
+ g_free( tmp );
+
+ ink_toggle_action_update_icon( action );
+ }
+ break;
+
+ case PROP_INK_SIZE:
+ {
+ action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ }
+ break;
+
+ default:
+ {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
+ }
+ }
+}
+
+static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action )
+{
+ GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_menu_item(action);
+
+ return item;
+}
+
+static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
+{
+ InkToggleAction* act = INK_TOGGLE_ACTION( action );
+
+ GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action);
+ if ( GTK_IS_TOOL_BUTTON(item) ) {
+ GtkToolButton* button = GTK_TOOL_BUTTON(item);
+ if ( act->private_data->iconId ) {
+ GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_tool_button_set_icon_widget(button, child);
+ } else {
+ gchar *label = 0;
+ g_object_get( G_OBJECT(action), "short_label", &label, NULL );
+ gtk_tool_button_set_label( button, label );
+ g_free( label );
+ label = 0;
+ }
+ } else {
+ // For now trigger a warning but don't do anything else
+ GtkToolButton* button = GTK_TOOL_BUTTON(item);
+ (void)button;
+ }
+ gtk_widget_show_all( item );
+
+ return item;
+}
+
+
+static void ink_toggle_action_update_icon( InkToggleAction* action )
+{
+ if ( action ) {
+ GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
+ while ( proxies ) {
+ if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
+ if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
+ GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
+
+ GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_widget_show_all(child);
+ gtk_tool_button_set_icon_widget(button, child);
+ }
+ }
+
+ proxies = g_slist_next( proxies );
+ }
+ }
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-toggle-action.h b/src/widgets/ink-toggle-action.h
new file mode 100644
index 000000000..8e9d5e257
--- /dev/null
+++ b/src/widgets/ink-toggle-action.h
@@ -0,0 +1,53 @@
+#ifndef INK_TOGGLE_ACTION_H
+#define INK_TOGGLE_ACTION_H
+
+#include <gtk/gtk.h>
+
+#include "attributes.h"
+#include "icon-size.h"
+
+G_BEGIN_DECLS
+#define INK_TOGGLE_ACTION_TYPE ( ink_toggle_action_get_type() )
+#define INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleAction) )
+#define INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) )
+#define IS_INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOGGLE_ACTION_TYPE) )
+#define IS_INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOGGLE_ACTION_TYPE) )
+#define INK_TOGGLE_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) )
+
+typedef struct _InkToggleAction InkToggleAction;
+typedef struct _InkToggleActionClass InkToggleActionClass;
+typedef struct _InkToggleActionPrivate InkToggleActionPrivate;
+
+struct _InkToggleAction
+{
+ GtkToggleAction action;
+ InkToggleActionPrivate *private_data;
+};
+
+struct _InkToggleActionClass
+{
+ GtkToggleActionClass parent_class;
+};
+
+GType ink_toggle_action_get_type( void );
+
+InkToggleAction* ink_toggle_action_new( const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size,
+ SPAttributeEnum attr = SP_ATTR_INVALID);
+
+G_END_DECLS
+
+#endif // INK_TOGGLE_ACTION_H
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-tool-menu-action.cpp b/src/widgets/ink-tool-menu-action.cpp
new file mode 100644
index 000000000..29d8dc92f
--- /dev/null
+++ b/src/widgets/ink-tool-menu-action.cpp
@@ -0,0 +1,49 @@
+#include "ink-tool-menu-action.h"
+
+// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215
+
+G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE);
+
+static void
+ink_tool_menu_action_class_init (InkToolMenuActionClass *klass)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+ action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
+}
+
+static void
+ink_tool_menu_action_init (InkToolMenuAction* /*tma*/)
+{
+}
+
+InkToolMenuAction *
+ink_tool_menu_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size )
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "iconId", inkId,
+ "iconSize", size,
+ NULL );
+
+ InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj );
+
+ return action;
+}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-tool-menu-action.h b/src/widgets/ink-tool-menu-action.h
new file mode 100644
index 000000000..be04489d3
--- /dev/null
+++ b/src/widgets/ink-tool-menu-action.h
@@ -0,0 +1,52 @@
+#ifndef INK_TOOL_MENU_ACTION_H
+#define INK_TOOL_MENU_ACTION_H
+
+#include "ink-action.h"
+
+// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215
+
+G_BEGIN_DECLS
+
+#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() )
+#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) )
+#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) )
+#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) )
+#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) )
+#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) )
+
+typedef struct _InkToolMenuAction InkToolMenuAction;
+typedef struct _InkToolMenuActionClass InkToolMenuActionClass;
+typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate;
+
+struct _InkToolMenuAction
+{
+ InkAction action;
+};
+
+struct _InkToolMenuActionClass
+{
+ InkActionClass parent_class;
+};
+
+GType ink_tool_menu_action_get_type( void );
+
+InkToolMenuAction* ink_tool_menu_action_new( const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *inkId,
+ Inkscape::IconSize size );
+
+G_END_DECLS
+
+#endif // INK_TOOL_MENU_ACTION_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index d44983a15..5df5fde70 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -34,7 +34,8 @@
#include "widgets/ege-select-one-action.h"
#include "helper/action-context.h"
#include "helper/action.h"
-#include "widgets/ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "ui/tools-switch.h"
#include "ui/tools/lpe-tool.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 53790cfac..a8c974bbc 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -39,7 +39,8 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "toolbox.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-toggle-action.h"
#include "ui/icon-names.h"
#include "ui/tools/measure-tool.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 381642287..fb540b5f5 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -47,7 +47,9 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index ed3e33acc..31efaa0b4 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -35,7 +35,8 @@
#include "desktop.h"
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
-#include "widgets/ink-action.h"
+#include "ink-toggle-action.h"
+#include "ink-tool-menu-action.h"
#include "inkscape.h"
#include "selection-chemistry.h"
#include "sp-namedview.h"
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index a421ea7d3..01118f337 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -131,11 +131,7 @@ static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel)
return grad;
}
-#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_VBOX);
-#endif
static void
sp_paint_selector_class_init(SPPaintSelectorClass *klass)
@@ -194,19 +190,13 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass)
static void
sp_paint_selector_init(SPPaintSelector *psel)
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(psel), GTK_ORIENTATION_VERTICAL);
-#endif
psel->mode = static_cast<SPPaintSelector::Mode>(-1); // huh? do you mean 0xff? -- I think this means "not in the enum"
/* Paint style button box */
-#if GTK_CHECK_VERSION(3,0,0)
psel->style = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(psel->style), FALSE);
-#else
- psel->style = gtk_hbox_new(FALSE, 0);
-#endif
gtk_widget_show(psel->style);
gtk_container_set_border_width(GTK_CONTAINER(psel->style), 4);
gtk_box_pack_start(GTK_BOX(psel), psel->style, FALSE, FALSE, 0);
@@ -233,12 +223,8 @@ sp_paint_selector_init(SPPaintSelector *psel)
/* Fillrule */
{
-#if GTK_CHECK_VERSION(3,0,0)
- psel->fillrulebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(psel->fillrulebox), FALSE);
-#else
- psel->fillrulebox = gtk_hbox_new(FALSE, 0);
-#endif
+ psel->fillrulebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_set_homogeneous(GTK_BOX(psel->fillrulebox), FALSE);
gtk_box_pack_end(GTK_BOX(psel->style), psel->fillrulebox, FALSE, FALSE, 0);
GtkWidget *w;
@@ -267,22 +253,14 @@ sp_paint_selector_init(SPPaintSelector *psel)
/* Frame */
psel->label = gtk_label_new("");
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *lbbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
+ auto lbbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_set_homogeneous(GTK_BOX(lbbox), FALSE);
-#else
- GtkWidget *lbbox = gtk_hbox_new(FALSE, 4);
-#endif
gtk_widget_show(psel->label);
gtk_box_pack_start(GTK_BOX(lbbox), psel->label, false, false, 4);
gtk_box_pack_start(GTK_BOX(psel), lbbox, false, false, 4);
-#if GTK_CHECK_VERSION(3,0,0)
psel->frame = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(psel->frame), FALSE);
-#else
- psel->frame = gtk_vbox_new(FALSE, 4);
-#endif
gtk_widget_show(psel->frame);
//gtk_container_set_border_width(GTK_CONTAINER(psel->frame), 0);
gtk_box_pack_start(GTK_BOX(psel), psel->frame, TRUE, TRUE, 0);
@@ -697,12 +675,8 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec
sp_paint_selector_clear_frame(psel);
/* Create new color selector */
/* Create vbox */
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
- gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
-#else
- GtkWidget *vb = gtk_vbox_new(FALSE, 4);
-#endif
+ auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
+ gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
gtk_widget_show(vb);
/* Color selector */
@@ -1043,21 +1017,13 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel
sp_paint_selector_clear_frame(psel);
/* Create vbox */
-#if GTK_CHECK_VERSION(3,0,0)
tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(tbl), FALSE);
-#else
- tbl = gtk_vbox_new(FALSE, 4);
-#endif
gtk_widget_show(tbl);
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 1);
-#endif
/**
* Create a combo_box and store with 4 columns,
@@ -1085,13 +1051,9 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel
}
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 0);
-#endif
- GtkWidget *l = gtk_label_new(NULL);
+ auto l = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(l), _("Use the <b>Node tool</b> to adjust position, scale, and rotation of the pattern on canvas. Use <b>Object &gt; Pattern &gt; Objects to Pattern</b> to create a new pattern from selection."));
gtk_label_set_line_wrap(GTK_LABEL(l), true);
gtk_widget_set_size_request(l, 180, -1);
diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h
index 23c2dd456..dde14b6a6 100644
--- a/src/widgets/paint-selector.h
+++ b/src/widgets/paint-selector.h
@@ -40,11 +40,7 @@ class SPStyle;
* Generic paint selector widget.
*/
struct SPPaintSelector {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBox vbox;
-#else
- GtkVBox vbox;
-#endif
enum Mode {
MODE_EMPTY,
@@ -130,11 +126,7 @@ enum {COMBO_COL_LABEL=0, COMBO_COL_STOCK=1, COMBO_COL_PATTERN=2, COMBO_COL_SEP=3
/// The SPPaintSelector vtable
struct SPPaintSelectorClass {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif
void (* mode_changed) (SPPaintSelector *psel, SPPaintSelector::Mode mode);
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index 75d458cd2..582fb66ba 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -35,7 +35,9 @@
#include "desktop.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "toolbox.h"
#include "ui/tools-switch.h"
#include "ui/icon-names.h"
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 5c3e91401..e551c28c3 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -29,7 +29,8 @@
#include "widgets/ege-adjustment-action.h"
#include "helper/action-context.h"
#include "helper/action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-toggle-action.h"
#include "inkscape.h"
#include "message-stack.h"
#include "selection-chemistry.h"
@@ -411,12 +412,8 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
g_object_set_data(G_OBJECT(spw), "dtw", desktop->getCanvas());
// The vb frame holds all other widgets and is used to set sensitivity depending on selection state.
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto vb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
-#else
- GtkWidget *vb = gtk_hbox_new(FALSE, 0);
-#endif
gtk_widget_show(vb);
gtk_container_add(GTK_CONTAINER(spw), vb);
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp
index de44cdbb4..cbff62b23 100644
--- a/src/widgets/sp-attribute-widget.cpp
+++ b/src/widgets/sp-attribute-widget.cpp
@@ -16,12 +16,7 @@
#include <glibmm/i18n.h>
#include <gtkmm/entry.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include "sp-object.h"
#include "xml/repr.h"
@@ -152,11 +147,7 @@ void SPAttributeTable::set_object(SPObject *object,
release_connection = object->connectRelease (sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this));
// Create table
-#if WITH_GTKMM_3_0
table = new Gtk::Grid();
-#else
- table = new Gtk::Table(attributes.size(), 2, false);
-#endif
if (!(parent == NULL))
gtk_container_add(GTK_CONTAINER(parent), (GtkWidget*)table->gobj());
@@ -167,27 +158,17 @@ void SPAttributeTable::set_object(SPObject *object,
Gtk::Label *ll = new Gtk::Label (_(labels[i].c_str()));
ll->show();
ll->set_alignment (1.0, 0.5);
-
-#if WITH_GTKMM_3_0
ll->set_vexpand();
ll->set_margin_left(XPAD);
ll->set_margin_right(XPAD);
ll->set_margin_top(XPAD);
ll->set_margin_bottom(XPAD);
table->attach(*ll, 0, i, 1, 1);
-#else
- table->attach (*ll, 0, 1, i, i + 1,
- Gtk::FILL,
- (Gtk::EXPAND | Gtk::FILL),
- XPAD, YPAD );
-#endif
Gtk::Entry *ee = new Gtk::Entry();
ee->show();
const gchar *val = object->getRepr()->attribute(attributes[i].c_str());
ee->set_text (val ? val : (const gchar *) "");
-
-#if WITH_GTKMM_3_0
ee->set_hexpand();
ee->set_vexpand();
ee->set_margin_left(XPAD);
@@ -195,12 +176,6 @@ void SPAttributeTable::set_object(SPObject *object,
ee->set_margin_top(XPAD);
ee->set_margin_bottom(XPAD);
table->attach(*ee, 1, i, 1, 1);
-#else
- table->attach (*ee, 1, 2, i, i + 1,
- (Gtk::EXPAND | Gtk::FILL),
- (Gtk::EXPAND | Gtk::FILL),
- XPAD, YPAD );
-#endif
_entries.push_back(ee);
g_signal_connect ( ee->gobj(), "changed",
diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h
index d9b972201..161bb706a 100644
--- a/src/widgets/sp-attribute-widget.h
+++ b/src/widgets/sp-attribute-widget.h
@@ -25,12 +25,7 @@
namespace Gtk {
class Entry;
-
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
@@ -138,11 +133,7 @@ private:
/**
* Container widget for the dynamically created child widgets (labels and entry boxes).
*/
-#if WITH_GTKMM_3_0
Gtk::Grid *table;
-#else
- Gtk::Table *table;
-#endif
/**
* List of attributes.
diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp
index 932f074d2..159350012 100644
--- a/src/widgets/sp-color-selector.cpp
+++ b/src/widgets/sp-color-selector.cpp
@@ -32,11 +32,7 @@ static guint csel_signals[LAST_SIGNAL] = {0};
double ColorSelector::_epsilon = 1e-4;
-#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_VBOX);
-#endif
void sp_color_selector_class_init( SPColorSelectorClass *klass )
{
@@ -86,9 +82,7 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass )
void sp_color_selector_init( SPColorSelector *csel )
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(csel), GTK_ORIENTATION_VERTICAL);
-#endif
if ( csel->base )
{
diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h
index 75cb79b00..14a9fccdf 100644
--- a/src/widgets/sp-color-selector.h
+++ b/src/widgets/sp-color-selector.h
@@ -64,21 +64,12 @@ private:
#define SP_COLOR_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass))
struct SPColorSelector {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBox vbox;
-#else
- GtkVBox vbox;
-#endif
-
ColorSelector* base;
};
struct SPColorSelectorClass {
-#if GTK_CHECK_VERSION(3,0,0)
GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif
const gchar **name;
guint submode_count;
diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp
index 180704f59..707e62c12 100644
--- a/src/widgets/sp-widget.cpp
+++ b/src/widgets/sp-widget.cpp
@@ -40,7 +40,6 @@ public:
static void show(GtkWidget *widget);
static void hide(GtkWidget *widget);
-#if GTK_CHECK_VERSION(3,0,0)
static void getPreferredWidth(GtkWidget *widget,
gint *minimal_width,
gint *natural_width);
@@ -49,10 +48,6 @@ public:
gint *minimal_height,
gint *natural_height);
static gboolean draw(GtkWidget *widget, cairo_t *cr);
-#else
- static void sizeRequest(GtkWidget *widget, GtkRequisition *requisition);
- static gboolean expose(GtkWidget *widget, GdkEventExpose *event);
-#endif
static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
static void modifySelectionCB(Selection *selection, guint flags, SPWidget *spw);
@@ -119,14 +114,9 @@ sp_widget_class_init(SPWidgetClass *klass)
widget_class->show = SPWidgetImpl::show;
widget_class->hide = SPWidgetImpl::hide;
-#if GTK_CHECK_VERSION(3,0,0)
widget_class->get_preferred_width = SPWidgetImpl::getPreferredWidth;
widget_class->get_preferred_height = SPWidgetImpl::getPreferredHeight;
widget_class->draw = SPWidgetImpl::draw;
-#else
- widget_class->size_request = SPWidgetImpl::sizeRequest;
- widget_class->expose_event = SPWidgetImpl::expose;
-#endif
widget_class->size_allocate = SPWidgetImpl::sizeAllocate;
}
@@ -206,27 +196,18 @@ void SPWidgetImpl::hide(GtkWidget *widget)
}
}
-#if GTK_CHECK_VERSION(3,0,0)
gboolean SPWidgetImpl::draw(GtkWidget *widget, cairo_t *cr)
-#else
-gboolean SPWidgetImpl::expose(GtkWidget *widget, GdkEventExpose *event)
-#endif
{
GtkBin *bin = GTK_BIN(widget);
GtkWidget *child = gtk_bin_get_child(bin);
if (child) {
-#if GTK_CHECK_VERSION(3,0,0)
gtk_container_propagate_draw(GTK_CONTAINER(widget), child, cr);
-#else
- gtk_container_propagate_expose(GTK_CONTAINER(widget), child, event);
-#endif
}
return FALSE;
}
-#if GTK_CHECK_VERSION(3,0,0)
void SPWidgetImpl::getPreferredWidth(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
GtkBin *bin = GTK_BIN(widget);
@@ -246,17 +227,6 @@ void SPWidgetImpl::getPreferredHeight(GtkWidget *widget, gint *minimal_height, g
gtk_widget_get_preferred_height(child, minimal_height, natural_height);
}
}
-#else
-void SPWidgetImpl::sizeRequest(GtkWidget *widget, GtkRequisition *requisition)
-{
- GtkBin *bin = GTK_BIN(widget);
- GtkWidget *child = gtk_bin_get_child(bin);
-
- if (child) {
- gtk_widget_size_request(child, requisition);
- }
-}
-#endif
void SPWidgetImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
{
diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp
index 45dbae52a..e99605b97 100644
--- a/src/widgets/sp-xmlview-attr-list.cpp
+++ b/src/widgets/sp-xmlview-attr-list.cpp
@@ -20,11 +20,7 @@
#include "../xml/node-event-vector.h"
#include "sp-xmlview-attr-list.h"
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_xmlview_attr_list_destroy(GtkWidget * object);
-#else
-static void sp_xmlview_attr_list_destroy(GtkObject * object);
-#endif
static void event_attr_changed (Inkscape::XML::Node * repr, const gchar * name, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data);
@@ -87,13 +83,8 @@ G_DEFINE_TYPE(SPXMLViewAttrList, sp_xmlview_attr_list, GTK_TYPE_TREE_VIEW);
void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass);
+ auto widget_class = GTK_WIDGET_CLASS(klass);
widget_class->destroy = sp_xmlview_attr_list_destroy;
-#else
- GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass);
- object_class->destroy = sp_xmlview_attr_list_destroy;
-#endif
g_signal_new("row-value-changed",
G_TYPE_FROM_CLASS(klass),
@@ -112,11 +103,7 @@ sp_xmlview_attr_list_init (SPXMLViewAttrList * list)
list->repr = NULL;
}
-#if GTK_CHECK_VERSION(3,0,0)
void sp_xmlview_attr_list_destroy(GtkWidget * object)
-#else
-void sp_xmlview_attr_list_destroy(GtkObject * object)
-#endif
{
SPXMLViewAttrList * list;
@@ -125,11 +112,7 @@ void sp_xmlview_attr_list_destroy(GtkObject * object)
g_object_unref(list->store);
sp_xmlview_attr_list_set_repr (list, NULL);
-#if GTK_CHECK_VERSION(3,0,0)
GTK_WIDGET_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object);
-#else
- GTK_OBJECT_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object);
-#endif
}
void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name)
diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp
index a1d8475ba..6e59ba3cd 100644
--- a/src/widgets/sp-xmlview-content.cpp
+++ b/src/widgets/sp-xmlview-content.cpp
@@ -23,11 +23,7 @@
using Inkscape::DocumentUndo;
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_xmlview_content_destroy(GtkWidget * object);
-#else
-static void sp_xmlview_content_destroy(GtkObject * object);
-#endif
void sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text);
@@ -80,13 +76,8 @@ G_DEFINE_TYPE(SPXMLViewContent, sp_xmlview_content, GTK_TYPE_TEXT_VIEW);
void sp_xmlview_content_class_init(SPXMLViewContentClass * klass)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass);
+ auto widget_class = GTK_WIDGET_CLASS(klass);
widget_class->destroy = sp_xmlview_content_destroy;
-#else
- GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass);
- object_class->destroy = sp_xmlview_content_destroy;
-#endif
}
void
@@ -96,21 +87,13 @@ sp_xmlview_content_init (SPXMLViewContent *text)
text->blocked = FALSE;
}
-#if GTK_CHECK_VERSION(3,0,0)
void sp_xmlview_content_destroy(GtkWidget * object)
-#else
-void sp_xmlview_content_destroy(GtkObject * object)
-#endif
{
SPXMLViewContent * text = SP_XMLVIEW_CONTENT (object);
sp_xmlview_content_set_repr (text, NULL);
-#if GTK_CHECK_VERSION(3,0,0)
GTK_WIDGET_CLASS (sp_xmlview_content_parent_class)->destroy (object);
-#else
- GTK_OBJECT_CLASS (sp_xmlview_content_parent_class)->destroy (object);
-#endif
}
void
diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp
index 5af7c243d..3f8cc6063 100644
--- a/src/widgets/sp-xmlview-tree.cpp
+++ b/src/widgets/sp-xmlview-tree.cpp
@@ -22,11 +22,7 @@ struct NodeData {
enum { STORE_TEXT_COL = 0, STORE_DATA_COL, STORE_REPR_COL, STORE_N_COLS };
-#if GTK_CHECK_VERSION(3,0,0)
static void sp_xmlview_tree_destroy(GtkWidget * object);
-#else
-static void sp_xmlview_tree_destroy(GtkObject * object);
-#endif
static NodeData * node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr);
@@ -120,13 +116,8 @@ G_DEFINE_TYPE(SPXMLViewTree, sp_xmlview_tree, GTK_TYPE_TREE_VIEW);
void sp_xmlview_tree_class_init(SPXMLViewTreeClass * klass)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass);
+ auto widget_class = GTK_WIDGET_CLASS(klass);
widget_class->destroy = sp_xmlview_tree_destroy;
-#else
- GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass);
- object_class->destroy = sp_xmlview_tree_destroy;
-#endif
// Signal for when a tree drag and drop has completed
g_signal_new ( "tree_move",
@@ -147,22 +138,13 @@ sp_xmlview_tree_init (SPXMLViewTree * tree)
tree->dndactive = FALSE;
}
-
-#if GTK_CHECK_VERSION(3,0,0)
void sp_xmlview_tree_destroy(GtkWidget * object)
-#else
-void sp_xmlview_tree_destroy(GtkObject * object)
-#endif
{
SPXMLViewTree * tree = SP_XMLVIEW_TREE (object);
sp_xmlview_tree_set_repr (tree, NULL);
-#if GTK_CHECK_VERSION(3,0,0)
GTK_WIDGET_CLASS(sp_xmlview_tree_parent_class)->destroy (object);
-#else
- GTK_OBJECT_CLASS(sp_xmlview_tree_parent_class)->destroy (object);
-#endif
}
/*
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 43d00c53e..a724637e3 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -36,7 +36,8 @@
#include "inkscape.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "toolbox.h"
#include "ui/dialog/clonetiler.h"
#include "ui/dialog/dialog-manager.h"
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 8bc472601..88a76b1ed 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -19,12 +19,7 @@
#include <gtkmm/box.h>
#include <gtkmm/label.h>
-
-#if GTK_CHECK_VERSION(3,0,0)
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "selection.h"
@@ -34,11 +29,7 @@
* Creates a label widget with the given text, at the given col, row
* position in the table.
*/
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int row, Gtk::Widget* target)
-#else
-Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target)
-#endif
{
Gtk::Label *label_widget = new Gtk::Label();
g_assert(label_widget != NULL);
@@ -54,7 +45,6 @@ Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int
label_widget->set_alignment(1.0, 0.5);
label_widget->show();
-#if GTK_CHECK_VERSION(3,0,0)
label_widget->set_hexpand();
label_widget->set_halign(Gtk::ALIGN_FILL);
label_widget->set_valign(Gtk::ALIGN_CENTER);
@@ -68,9 +58,6 @@ Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int
#endif
table->attach(*label_widget, col, row, 1, 1);
-#else
- table->attach(*label_widget, col, col+1, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 4, 0);
-#endif
return label_widget;
}
@@ -82,16 +69,9 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
label_widget = gtk_label_new (label_text);
g_assert(label_widget != NULL);
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(label_widget, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5);
-#endif
-
gtk_widget_show (label_widget);
-#if GTK_CHECK_VERSION(3,0,0)
#if GTK_CHECK_VERSION(3,12,0)
gtk_widget_set_margin_start(label_widget, 4);
gtk_widget_set_margin_end(label_widget, 4);
@@ -103,10 +83,6 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL);
gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE (table), label_widget, col, col+1, row, row+1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0);
-#endif
return label_widget;
}
@@ -115,25 +91,16 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
* Creates a horizontal layout manager with 4-pixel spacing between children
* and space for 'width' columns.
*/
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row)
-#else
-Gtk::HBox * spw_hbox(Gtk::Table * table, int width, int col, int row)
-#endif
{
/* Create a new hbox with a 4-pixel spacing between children */
Gtk::HBox *hb = new Gtk::HBox(false, 4);
g_assert(hb != NULL);
hb->show();
-
-#if GTK_CHECK_VERSION(3,0,0)
hb->set_hexpand();
hb->set_halign(Gtk::ALIGN_FILL);
hb->set_valign(Gtk::ALIGN_CENTER);
table->attach(*hb, col, row, width, 1);
-#else
- table->attach(*hb, col, col+width, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
-#endif
return hb;
}
@@ -175,37 +142,21 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table,
g_assert(table != NULL);
GtkWidget *l = gtk_label_new (label);
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(l, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
-#endif
-
gtk_widget_show (l);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(l, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(l, TRUE);
gtk_widget_set_valign(l, GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), l, 0, 1, row, row+1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
-#endif
b = gtk_check_button_new ();
gtk_widget_show (b);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(b, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(b, TRUE);
gtk_widget_set_valign(b, GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), b, 1, 2, row, row+1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
-#endif
g_object_set_data (G_OBJECT (b), "key", key);
g_object_set_data (G_OBJECT (dialog), key, b);
@@ -233,16 +184,10 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table,
spw_label_old(table, label_text, 0, row);
gtk_widget_show (selector);
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(selector, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(selector, TRUE);
gtk_widget_set_valign(selector, GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), selector, 1, 2, row, row+1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
-#endif
g_object_set_data (G_OBJECT (dialog), key, selector);
return selector;
@@ -253,8 +198,7 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
guint size = GPOINTER_TO_UINT (font);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkCssProvider *css_provider = gtk_css_provider_new();
+ auto css_provider = gtk_css_provider_new();
const double pt_size = size / static_cast<double>(PANGO_SCALE);
std::ostringstream css_data;
@@ -266,25 +210,16 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
css_data.str().c_str(),
-1, NULL);
- GtkStyleContext *style_context = gtk_widget_get_style_context(w);
+ auto style_context = gtk_widget_get_style_context(w);
gtk_style_context_add_provider(style_context,
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
-#else
- PangoFontDescription* pan = pango_font_description_new ();
- pango_font_description_set_size (pan, size);
- gtk_widget_modify_font (w, pan);
-#endif
if (GTK_IS_CONTAINER(w)) {
gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font);
}
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(css_provider);
-#else
- pango_font_description_free (pan);
-#endif
}
void
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index 31f29e026..71b451631 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -20,25 +20,13 @@
namespace Gtk {
class Label;
-
-#if GTK_CHECK_VERSION(3,0,0)
class Grid;
-#else
- class Table;
-#endif
-
class HBox;
class Widget;
}
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row);
-#else
-Gtk::Label * spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
-Gtk::HBox * spw_hbox(Gtk::Table *table, int width, int col, int row);
-#endif
-
GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row);
GtkWidget *
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 844c678d9..8f667a656 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -37,7 +37,8 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-action.h"
+#include "ink-radio-action.h"
#include "selection.h"
#include "sp-star.h"
#include "toolbox.h"
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 0494deb1b..4a658c5dc 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -152,17 +152,9 @@ StrokeStyle::StrokeStyle() :
Gtk::HBox *f = new Gtk::HBox(false, 0);
f->show();
add(*f);
-
-#if WITH_GTKMM_3_0
table = new Gtk::Grid();
table->set_border_width(4);
table->set_row_spacing(4);
-#else
- table = new Gtk::Table(3, 6, false);
- table->set_border_width(4);
- table->set_row_spacings(4);
-#endif
-
table->show();
f->add(*table);
@@ -178,13 +170,7 @@ StrokeStyle::StrokeStyle() :
// stroke_width_set_unit will be removed (because ScalarUnit takes care of conversions itself), and
// with it, the two remaining calls of stroke_average_width, allowing us to get rid of that
// function in desktop-style.
-
-#if WITH_GTKMM_3_0
widthAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0));
-#else
- widthAdj = new Gtk::Adjustment(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0);
-#endif
-
widthSpin = new Inkscape::UI::Widget::SpinButton(*widthAdj, 0.1, 3);
widthSpin->set_tooltip_text(_("Stroke width"));
widthSpin->show();
@@ -210,12 +196,7 @@ StrokeStyle::StrokeStyle() :
us->show();
hb->pack_start(*us, FALSE, FALSE, 0);
-
-#if WITH_GTKMM_3_0
(*widthAdj)->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::widthChangedCB));
-#else
- widthAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::widthChangedCB));
-#endif
i++;
/* Dash */
@@ -227,16 +208,10 @@ StrokeStyle::StrokeStyle() :
dashSelector = Gtk::manage(new SPDashSelector);
dashSelector->show();
-
-#if WITH_GTKMM_3_0
dashSelector->set_hexpand();
dashSelector->set_halign(Gtk::ALIGN_FILL);
dashSelector->set_valign(Gtk::ALIGN_CENTER);
table->attach(*dashSelector, 1, i, 3, 1);
-#else
- table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
-#endif
-
dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
i++;
@@ -320,28 +295,14 @@ StrokeStyle::StrokeStyle() :
// miter limit is to cut off such spikes (i.e. convert them into bevels)
// when they become too long.
//spw_label(t, _("Miter _limit:"), 0, i);
-
-#if WITH_GTKMM_3_0
miterLimitAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(4.0, 0.0, 100.0, 0.1, 10.0, 0.0));
miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2);
-#else
- miterLimitAdj = new Gtk::Adjustment(4.0, 0.0, 100.0, 0.1, 10.0, 0.0);
- miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2);
-#endif
-
miterLimitSpin->set_tooltip_text(_("Maximum length of the miter (in units of stroke width)"));
miterLimitSpin->show();
sp_dialog_defocus_on_enter_cpp(miterLimitSpin);
hb->pack_start(*miterLimitSpin, false, false, 0);
-
-#if WITH_GTKMM_3_0
(*miterLimitAdj)->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB));
-
-#else
- miterLimitAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB));
-#endif
-
i++;
/* Cap type */
@@ -924,17 +885,9 @@ StrokeStyle::updateLine()
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
double avgwidth = Inkscape::Util::Quantity::convert(query.stroke_width.computed, "px", unit);
-#if WITH_GTKMM_3_0
(*widthAdj)->set_value(avgwidth);
-#else
- widthAdj->set_value(avgwidth);
-#endif
} else {
-#if WITH_GTKMM_3_0
(*widthAdj)->set_value(100);
-#else
- widthAdj->set_value(100);
-#endif
}
// if none of the selected objects has a stroke, than quite some controls should be disabled
@@ -955,11 +908,7 @@ StrokeStyle::updateLine()
}
if (result_ml != QUERY_STYLE_NOTHING)
-#if WITH_GTKMM_3_0
(*miterLimitAdj)->set_value(query.stroke_miterlimit.value); // TODO: reflect averagedness?
-#else
- miterLimitAdj->set_value(query.stroke_miterlimit.value); // TODO: reflect averagedness?
-#endif
if (result_join != QUERY_STYLE_MULTIPLE_DIFFERENT &&
result_join != QUERY_STYLE_NOTHING ) {
@@ -1047,13 +996,8 @@ StrokeStyle::scaleLine()
SPCSSAttr *css = sp_repr_css_attr_new();
if (!items.empty()) {
-#if WITH_GTKMM_3_0
double width_typed = (*widthAdj)->get_value();
double const miterlimit = (*miterLimitAdj)->get_value();
-#else
- double width_typed = widthAdj->get_value();
- double const miterlimit = miterLimitAdj->get_value();
-#endif
Inkscape::Util::Unit const *const unit = unitSelector->getUnit();
@@ -1093,11 +1037,7 @@ StrokeStyle::scaleLine()
if (unit->type != Inkscape::Util::UNIT_TYPE_LINEAR) {
// reset to 100 percent
-#if WITH_GTKMM_3_0
(*widthAdj)->set_value(100.0);
-#else
- widthAdj->set_value(100.0);
-#endif
}
}
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index d83067a4a..76582602d 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -23,12 +23,7 @@
#include "widgets/dash-selector.h"
#include <gtkmm/radiobutton.h>
-
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include <glibmm/i18n.h>
@@ -189,15 +184,9 @@ private:
MarkerComboBox *startMarkerCombo;
MarkerComboBox *midMarkerCombo;
MarkerComboBox *endMarkerCombo;
-#if WITH_GTKMM_3_0
Gtk::Grid *table;
Glib::RefPtr<Gtk::Adjustment> *widthAdj;
Glib::RefPtr<Gtk::Adjustment> *miterLimitAdj;
-#else
- Gtk::Table *table;
- Gtk::Adjustment *widthAdj;
- Gtk::Adjustment *miterLimitAdj;
-#endif
Inkscape::UI::Widget::SpinButton *miterLimitSpin;
Inkscape::UI::Widget::SpinButton *widthSpin;
Inkscape::UI::Widget::UnitMenu *unitSelector;
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index dcac7559b..0160bcac7 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -38,7 +38,8 @@
#include "document.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "widgets/ink-comboboxentry-action.h"
#include "inkscape.h"
#include "selection-chemistry.h"
@@ -1557,8 +1558,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_object_set_data( holder, "TextFontFamilyAction", act );
// Change style of drop-down from menu to list
-#if GTK_CHECK_VERSION(3,0,0)
- GtkCssProvider *css_provider = gtk_css_provider_new();
+ auto css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider,
"#TextFontFamilyAction_combobox {\n"
" -GtkComboBox-appears-as-list: true;\n"
@@ -1569,24 +1569,10 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"}\n",
-1, NULL);
- GdkScreen *screen = gdk_screen_get_default();
+ auto screen = gdk_screen_get_default();
gtk_style_context_add_provider_for_screen(screen,
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
-#else
- gtk_rc_parse_string (
- "style \"dropdown-as-list-style\"\n"
- "{\n"
- " GtkComboBox::appears-as-list = 1\n"
- "}\n"
- "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\""
- "style \"fontfamily-separator-style\"\n"
- "{\n"
- " GtkWidget::wide-separators = 1\n"
- " GtkWidget::separator-height = 6\n"
- "}\n"
- "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\"");
-#endif
}
/* Font size */
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 1e67cca8f..f74be4b15 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -43,6 +43,7 @@
#include "../helper/action.h"
#include "icon.h"
#include "ink-action.h"
+#include "ink-toggle-action.h"
#include "../inkscape.h"
#include "ui/interface.h"
#include "../shortcuts.h"
@@ -1009,26 +1010,18 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType /*h
GtkWidget *ToolboxFactory::createToolToolbox()
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(tb, "ToolToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
-#else
- GtkWidget *tb = gtk_vbox_new(FALSE, 0);
-#endif
return toolboxNewCommon( tb, BAR_TOOL, GTK_POS_TOP );
}
GtkWidget *ToolboxFactory::createAuxToolbox()
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(tb, "AuxToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
-#else
- GtkWidget *tb = gtk_vbox_new(FALSE, 0);
-#endif
return toolboxNewCommon( tb, BAR_AUX, GTK_POS_LEFT );
}
@@ -1039,38 +1032,26 @@ GtkWidget *ToolboxFactory::createAuxToolbox()
GtkWidget *ToolboxFactory::createCommandsToolbox()
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(tb, "CommandsToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
-#else
- GtkWidget *tb = gtk_vbox_new(FALSE, 0);
-#endif
return toolboxNewCommon( tb, BAR_COMMANDS, GTK_POS_LEFT );
}
GtkWidget *ToolboxFactory::createSnapToolbox()
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(tb, "SnapToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
-#else
- GtkWidget *tb = gtk_vbox_new(FALSE, 0);
-#endif
return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT );
}
static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker)
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true);
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits);
-#else
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
-#endif
+ auto adj = Glib::wrap(adjustment, true);
+ auto inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits);
inkSpinner->addUnitTracker(unit_tracker);
inkSpinner = Gtk::manage( inkSpinner );
GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() );
@@ -1432,17 +1413,10 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
if ( aux_toolboxes[i].prep_func ) {
// converted to GtkActions and UIManager
- GtkWidget* kludge = dataHolders[aux_toolboxes[i].type_name];
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget* holder = gtk_grid_new();
+ auto kludge = dataHolders[aux_toolboxes[i].type_name];
+ auto holder = gtk_grid_new();
gtk_widget_set_name( holder, "ToolbarHolder" );
gtk_grid_attach( GTK_GRID(holder), kludge, 2, 0, 1, 1);
-#else
- GtkWidget* holder = gtk_table_new( 1, 3, FALSE );
- gtk_table_attach( GTK_TABLE(holder), kludge, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
-#endif
-
gchar* tmp = g_strdup_printf( "/ui/%s", aux_toolboxes[i].ui_name );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, tmp );
g_free( tmp );
@@ -1454,30 +1428,20 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
-
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(toolBar, TRUE);
gtk_grid_attach( GTK_GRID(holder), toolBar, 0, 0, 1, 1);
-#else
- gtk_table_attach( GTK_TABLE(holder), toolBar, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0 );
-#endif
if ( aux_toolboxes[i].swatch_verb_id != SP_VERB_INVALID ) {
Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch( NULL, _(aux_toolboxes[i].swatch_tip) );
swatch->setDesktop( desktop );
swatch->setClickVerb( aux_toolboxes[i].swatch_verb_id );
swatch->setWatchedTool( aux_toolboxes[i].swatch_tool, true );
- GtkWidget *swatch_ = GTK_WIDGET( swatch->gobj() );
-
-#if GTK_CHECK_VERSION(3,0,0)
+ auto swatch_ = GTK_WIDGET( swatch->gobj() );
gtk_widget_set_margin_left(swatch_, AUX_BETWEEN_BUTTON_GROUPS);
gtk_widget_set_margin_right(swatch_, AUX_BETWEEN_BUTTON_GROUPS);
gtk_widget_set_margin_top(swatch_, AUX_SPACING);
gtk_widget_set_margin_bottom(swatch_, AUX_SPACING);
gtk_grid_attach( GTK_GRID(holder), swatch_, 1, 0, 1, 1);
-#else
- gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, AUX_SPACING );
-#endif
}
if(i==0){
gtk_widget_show_all( holder );
diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp
index 9a021082c..a6b8ba436 100644
--- a/src/widgets/tweak-toolbar.cpp
+++ b/src/widgets/tweak-toolbar.cpp
@@ -36,7 +36,8 @@
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "widgets/ege-select-one-action.h"
-#include "widgets/ink-action.h"
+#include "ink-radio-action.h"
+#include "ink-toggle-action.h"
#include "toolbox.h"
#include "ui/icon-names.h"
#include "ui/tools/tweak-tool.h"