summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/Makefile_insert110
-rw-r--r--src/ui/widget/addtoicon.cpp33
-rw-r--r--src/ui/widget/addtoicon.h14
-rw-r--r--src/ui/widget/anchor-selector.cpp10
-rw-r--r--src/ui/widget/anchor-selector.h12
-rw-r--r--src/ui/widget/clipmaskicon.cpp33
-rw-r--r--src/ui/widget/clipmaskicon.h13
-rw-r--r--src/ui/widget/color-icc-selector.cpp24
-rw-r--r--src/ui/widget/color-icc-selector.h8
-rw-r--r--src/ui/widget/color-notebook.cpp30
-rw-r--r--src/ui/widget/color-notebook.h9
-rw-r--r--src/ui/widget/color-picker.cpp5
-rw-r--r--src/ui/widget/color-preview.cpp26
-rw-r--r--src/ui/widget/color-preview.h6
-rw-r--r--src/ui/widget/color-scales.cpp28
-rw-r--r--src/ui/widget/color-scales.h8
-rw-r--r--src/ui/widget/color-slider.cpp122
-rw-r--r--src/ui/widget/color-slider.h18
-rw-r--r--src/ui/widget/color-wheel-selector.cpp48
-rw-r--r--src/ui/widget/color-wheel-selector.h12
-rw-r--r--src/ui/widget/dock-item.cpp8
-rw-r--r--src/ui/widget/dock-item.h4
-rw-r--r--src/ui/widget/dock.cpp12
-rw-r--r--src/ui/widget/gimpcolorwheel.c1604
-rw-r--r--src/ui/widget/gimpcolorwheel.h95
-rw-r--r--src/ui/widget/gimpspinscale.c1225
-rw-r--r--src/ui/widget/gimpspinscale.h82
-rw-r--r--src/ui/widget/highlight-picker.cpp33
-rw-r--r--src/ui/widget/highlight-picker.h14
-rw-r--r--src/ui/widget/imagetoggler.cpp33
-rw-r--r--src/ui/widget/imagetoggler.h14
-rw-r--r--src/ui/widget/insertordericon.cpp32
-rw-r--r--src/ui/widget/insertordericon.h13
-rw-r--r--src/ui/widget/layertypeicon.cpp33
-rw-r--r--src/ui/widget/layertypeicon.h14
-rw-r--r--src/ui/widget/licensor.cpp8
-rw-r--r--src/ui/widget/notebook-page.cpp12
-rw-r--r--src/ui/widget/notebook-page.h13
-rw-r--r--src/ui/widget/page-sizer.cpp43
-rw-r--r--src/ui/widget/page-sizer.h26
-rw-r--r--src/ui/widget/panel.cpp6
-rw-r--r--src/ui/widget/panel.h18
-rw-r--r--src/ui/widget/point.cpp4
-rw-r--r--src/ui/widget/point.h4
-rw-r--r--src/ui/widget/preferences-widget.cpp80
-rw-r--r--src/ui/widget/preferences-widget.h25
-rw-r--r--src/ui/widget/random.cpp4
-rw-r--r--src/ui/widget/random.h4
-rw-r--r--src/ui/widget/scalar.cpp10
-rw-r--r--src/ui/widget/scalar.h4
-rw-r--r--src/ui/widget/selected-style.cpp45
-rw-r--r--src/ui/widget/selected-style.h15
-rw-r--r--src/ui/widget/spin-scale.cpp30
-rw-r--r--src/ui/widget/spin-scale.h25
-rw-r--r--src/ui/widget/spin-slider.cpp61
-rw-r--r--src/ui/widget/spin-slider.h18
-rw-r--r--src/ui/widget/spinbutton.h4
-rw-r--r--src/ui/widget/style-swatch.cpp23
-rw-r--r--src/ui/widget/style-swatch.h8
-rw-r--r--src/ui/widget/tolerance-slider.cpp10
-rw-r--r--src/ui/widget/tolerance-slider.h10
61 files changed, 41 insertions, 4254 deletions
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
deleted file mode 100644
index eb98e6872..000000000
--- a/src/ui/widget/Makefile_insert
+++ /dev/null
@@ -1,110 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/widget/anchor-selector.h \
- ui/widget/anchor-selector.cpp \
- ui/widget/attr-widget.h \
- ui/widget/button.h \
- ui/widget/button.cpp \
- ui/widget/color-entry.cpp \
- ui/widget/color-entry.h \
- ui/widget/color-icc-selector.cpp \
- ui/widget/color-icc-selector.h \
- ui/widget/color-notebook.cpp \
- ui/widget/color-notebook.h \
- ui/widget/color-wheel-selector.cpp \
- ui/widget/color-wheel-selector.h \
- ui/widget/color-picker.cpp \
- ui/widget/color-picker.h \
- ui/widget/color-preview.cpp \
- ui/widget/color-preview.h \
- ui/widget/color-slider.cpp \
- ui/widget/color-slider.h \
- ui/widget/color-scales.cpp \
- ui/widget/color-scales.h \
- ui/widget/combo-enums.h \
- ui/widget/dock.h \
- ui/widget/dock.cpp \
- ui/widget/dock-item.h \
- ui/widget/dock-item.cpp \
- ui/widget/entity-entry.cpp \
- ui/widget/entity-entry.h \
- ui/widget/entry.cpp \
- ui/widget/entry.h \
- ui/widget/filter-effect-chooser.h \
- ui/widget/filter-effect-chooser.cpp \
- ui/widget/font-variants.h \
- ui/widget/font-variants.cpp \
- ui/widget/gimpspinscale.c \
- ui/widget/gimpspinscale.h \
- ui/widget/gimpcolorwheel.c \
- ui/widget/gimpcolorwheel.h \
- ui/widget/frame.cpp \
- ui/widget/frame.h \
- ui/widget/imageicon.cpp \
- ui/widget/imageicon.h \
- ui/widget/imagetoggler.cpp \
- ui/widget/imagetoggler.h \
- ui/widget/labelled.cpp \
- ui/widget/labelled.h \
- ui/widget/layer-selector.cpp \
- ui/widget/layer-selector.h \
- ui/widget/licensor.cpp \
- ui/widget/licensor.h \
- ui/widget/notebook-page.cpp \
- ui/widget/notebook-page.h \
- ui/widget/object-composite-settings.cpp \
- ui/widget/object-composite-settings.h \
- ui/widget/page-sizer.cpp \
- ui/widget/page-sizer.h \
- ui/widget/panel.cpp \
- ui/widget/panel.h \
- ui/widget/point.cpp \
- ui/widget/point.h \
- ui/widget/preferences-widget.cpp \
- ui/widget/preferences-widget.h \
- ui/widget/random.cpp \
- ui/widget/random.h \
- ui/widget/registered-widget.cpp \
- ui/widget/registered-widget.h \
- ui/widget/registered-enums.h \
- ui/widget/registry.cpp \
- ui/widget/registry.h \
- ui/widget/rendering-options.cpp \
- ui/widget/rendering-options.h \
- ui/widget/rotateable.h \
- ui/widget/rotateable.cpp \
- ui/widget/scalar-unit.cpp \
- ui/widget/scalar-unit.h \
- ui/widget/scalar.cpp \
- ui/widget/scalar.h \
- ui/widget/selected-style.h \
- ui/widget/selected-style.cpp \
- ui/widget/spinbutton.h \
- ui/widget/spinbutton.cpp \
- ui/widget/spin-scale.h \
- ui/widget/spin-scale.cpp \
- ui/widget/spin-slider.h \
- ui/widget/spin-slider.cpp \
- ui/widget/style-subject.h \
- ui/widget/style-subject.cpp \
- ui/widget/style-swatch.h \
- ui/widget/style-swatch.cpp \
- ui/widget/text.cpp \
- ui/widget/text.h \
- ui/widget/tolerance-slider.cpp \
- ui/widget/tolerance-slider.h \
- ui/widget/unit-menu.cpp \
- ui/widget/unit-menu.h \
- ui/widget/unit-tracker.h \
- ui/widget/unit-tracker.cpp \
- ui/widget/clipmaskicon.cpp \
- ui/widget/clipmaskicon.h \
- ui/widget/highlight-picker.cpp \
- ui/widget/highlight-picker.h \
- ui/widget/layertypeicon.cpp \
- ui/widget/layertypeicon.h \
- ui/widget/insertordericon.cpp \
- ui/widget/insertordericon.h \
- ui/widget/addtoicon.cpp \
- ui/widget/addtoicon.h
diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp
index 465423fc2..70516ed00 100644
--- a/src/ui/widget/addtoicon.cpp
+++ b/src/ui/widget/addtoicon.cpp
@@ -49,8 +49,6 @@ AddToIcon::AddToIcon() :
set_pixbuf();
}
-
-#if WITH_GTKMM_3_0
void AddToIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -80,47 +78,16 @@ void AddToIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void AddToIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void AddToIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void AddToIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
set_pixbuf();
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool AddToIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h
index a8d900d1f..3b2228754 100644
--- a/src/ui/widget/addtoicon.h
+++ b/src/ui/widget/addtoicon.h
@@ -31,8 +31,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -46,18 +44,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp
index acf8aff79..087e7375e 100644
--- a/src/ui/widget/anchor-selector.cpp
+++ b/src/ui/widget/anchor-selector.cpp
@@ -27,11 +27,7 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b
AnchorSelector::AnchorSelector()
: Gtk::Alignment(0.5, 0, 0, 0),
-#if WITH_GTKMM_3_0
_container()
-#else
- _container(3, 3, true)
-#endif
{
setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]);
setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]);
@@ -43,20 +39,14 @@ AnchorSelector::AnchorSelector()
setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]);
setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]);
-#if WITH_GTKMM_3_0
_container.set_row_homogeneous();
_container.set_column_homogeneous(true);
-#endif
for(int i = 0; i < 9; ++i) {
_buttons[i].signal_clicked().connect(
sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i));
-#if WITH_GTKMM_3_0
_container.attach(_buttons[i], i % 3, i / 3, 1, 1);
-#else
- _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL);
-#endif
}
_selection = 4;
_buttons[4].set_active();
diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h
index 0a702d296..96331fae3 100644
--- a/src/ui/widget/anchor-selector.h
+++ b/src/ui/widget/anchor-selector.h
@@ -16,12 +16,7 @@
#include <gtkmm/alignment.h>
#include <gtkmm/togglebutton.h>
-
-#if WITH_GTKMM_3_0
- #include <gtkmm/grid.h>
-#else
- #include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
namespace Inkscape {
namespace UI {
@@ -32,12 +27,7 @@ class AnchorSelector : public Gtk::Alignment
private:
Gtk::ToggleButton _buttons[9];
int _selection;
-
-#if WITH_GTKMM_3_0
Gtk::Grid _container;
-#else
- Gtk::Table _container;
-#endif
sigc::signal<void> _selectionChanged;
diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp
index 8715fdede..4f791042a 100644
--- a/src/ui/widget/clipmaskicon.cpp
+++ b/src/ui/widget/clipmaskicon.cpp
@@ -63,8 +63,6 @@ ClipMaskIcon::ClipMaskIcon() :
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
}
-
-#if WITH_GTKMM_3_0
void ClipMaskIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -94,39 +92,12 @@ void ClipMaskIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void ClipMaskIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void ClipMaskIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
switch (_property_active.get_value())
{
@@ -143,11 +114,7 @@ void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
break;
}
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool ClipMaskIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/clipmaskicon.h b/src/ui/widget/clipmaskicon.h
index eca852a83..0d149edb8 100644
--- a/src/ui/widget/clipmaskicon.h
+++ b/src/ui/widget/clipmaskicon.h
@@ -32,7 +32,6 @@ public:
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -46,18 +45,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp
index 52c6ed2e3..616e9afa8 100644
--- a/src/ui/widget/color-icc-selector.cpp
+++ b/src/ui/widget/color-icc-selector.cpp
@@ -5,7 +5,6 @@
#include <gtkmm/adjustment.h>
#include <glibmm/i18n.h>
-#include <gtk/gtk.h>
#include <set>
#include "ui/dialog-events.h"
@@ -84,7 +83,6 @@ GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs)
void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height,
bool hexpand = false, bool centered = false, guint xpadding = XPAD, guint ypadding = YPAD)
{
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(child, xpadding);
gtk_widget_set_margin_end(child, xpadding);
@@ -103,14 +101,6 @@ void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint
gtk_widget_set_valign(child, GTK_ALIGN_CENTER);
}
gtk_grid_attach(GTK_GRID(parent), child, left, top, width, height);
-#else
- GtkAttachOptions xoptions =
- centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL;
- GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL;
-
- gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding,
- ypadding);
-#endif
}
} // namespace
@@ -428,12 +418,7 @@ void ColorICCSelector::init()
_impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str());
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5);
-#endif
-
gtk_widget_show(_impl->_compUI[i]._label);
gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE);
@@ -492,12 +477,7 @@ void ColorICCSelector::init()
// Label
_impl->_label = gtk_label_new_with_mnemonic(_("_A:"));
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5);
-#endif
-
gtk_widget_show(_impl->_label);
attachToGridOrTable(t, _impl->_label, 0, row, 1, 1);
@@ -724,11 +704,7 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const & /*name*/) {}
void ColorICCSelector::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_colorChanged();
}
diff --git a/src/ui/widget/color-icc-selector.h b/src/ui/widget/color-icc-selector.h
index 1bcb0a540..aaa8372b8 100644
--- a/src/ui/widget/color-icc-selector.h
+++ b/src/ui/widget/color-icc-selector.h
@@ -6,11 +6,7 @@
#endif
#include <gtkmm/widget.h>
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -24,11 +20,7 @@ namespace Widget {
class ColorICCSelectorImpl;
class ColorICCSelector
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *MODE_NAME;
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp
index 6634d8dad..33e22b59d 100644
--- a/src/ui/widget/color-notebook.cpp
+++ b/src/ui/widget/color-notebook.cpp
@@ -52,13 +52,8 @@ namespace Widget {
ColorNotebook::ColorNotebook(SelectedColor &color)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(2, 3, false)
-#endif
, _selected_color(color)
-
{
Page *page;
@@ -106,12 +101,8 @@ void ColorNotebook::_initUI()
notebook->set_show_tabs(false);
_book = GTK_WIDGET(notebook->gobj());
-#if GTK_CHECK_VERSION(3, 0, 0)
_buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE);
-#else
- _buttonbox = gtk_hbox_new(TRUE, 2);
-#endif
gtk_widget_show(_buttonbox);
_buttons = new GtkWidget *[_available_pages.size()];
@@ -122,7 +113,6 @@ void ColorNotebook::_initUI()
sp_set_font_size_smaller(_buttonbox);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_buttonbox, XPAD);
gtk_widget_set_margin_end(_buttonbox, XPAD);
@@ -135,14 +125,9 @@ void ColorNotebook::_initUI()
gtk_widget_set_hexpand(_buttonbox, TRUE);
gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER);
attach(*Glib::wrap(_buttonbox), 0, row, 2, 1);
-#else
- attach(*Glib::wrap(_buttonbox), 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, static_cast<Gtk::AttachOptions>(0),
- XPAD, YPAD);
-#endif
row++;
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_book, XPAD * 2);
gtk_widget_set_margin_end(_book, XPAD * 2);
@@ -155,20 +140,13 @@ void ColorNotebook::_initUI()
gtk_widget_set_hexpand(_book, TRUE);
gtk_widget_set_vexpand(_book, TRUE);
attach(*notebook, 0, row, 2, 1);
-#else
- attach(*notebook, 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD);
-#endif
// restore the last active page
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_setCurrentPage(prefs->getInt("/colorselector/page", 0));
row++;
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- GtkWidget *rgbabox = gtk_hbox_new(FALSE, 0);
-#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/* Create color management icons */
@@ -206,11 +184,7 @@ void ColorNotebook::_initUI()
/* Create RGBA entry and color preview */
_rgbal = gtk_label_new_with_mnemonic(_("RGBA_:"));
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_rgbal, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5);
-#endif
gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2);
ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color));
@@ -226,7 +200,6 @@ void ColorNotebook::_initUI()
gtk_widget_hide(GTK_WIDGET(_box_toomuchink));
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(rgbabox, XPAD);
gtk_widget_set_margin_end(rgbabox, XPAD);
@@ -237,9 +210,6 @@ void ColorNotebook::_initUI()
gtk_widget_set_margin_top(rgbabox, YPAD);
gtk_widget_set_margin_bottom(rgbabox, YPAD);
attach(*Glib::wrap(rgbabox), 0, row, 2, 1);
-#else
- attach(*Glib::wrap(rgbabox), 0, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK, XPAD, YPAD);
-#endif
#ifdef SPCS_PREVIEW
_p = sp_color_preview_new(0xffffffff);
diff --git a/src/ui/widget/color-notebook.h b/src/ui/widget/color-notebook.h
index d28028c72..0948e3d46 100644
--- a/src/ui/widget/color-notebook.h
+++ b/src/ui/widget/color-notebook.h
@@ -19,12 +19,7 @@
#endif
#include <boost/ptr_container/ptr_vector.hpp>
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
-#include <gtk/gtk.h>
#include <glib.h>
#include "color.h"
@@ -35,11 +30,7 @@ namespace UI {
namespace Widget {
class ColorNotebook
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
ColorNotebook(SelectedColor &color);
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index a66fbfc9c..5a62c3c98 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -59,13 +59,8 @@ void ColorPicker::setupDialog(const Glib::ustring &title)
_color_selector = Gtk::manage(new ColorNotebook(_selected_color));
-#if WITH_GTKMM_3_0
_colorSelectorDialog.get_content_area()->pack_start (
*_color_selector, true, true, 0);
-#else
- _colorSelectorDialog.get_vbox()->pack_start (
- *_color_selector, true, true, 0);
-#endif
_color_selector->show();
}
diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp
index 62c7cca1d..c9b6e56d2 100644
--- a/src/ui/widget/color-preview.cpp
+++ b/src/ui/widget/color-preview.cpp
@@ -34,7 +34,6 @@ ColorPreview::on_size_allocate (Gtk::Allocation &all)
queue_draw();
}
-#if WITH_GTKMM_3_0
void
ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
{
@@ -58,31 +57,6 @@ ColorPreview::get_preferred_width_for_height_vfunc(int /* height */, int& minimu
{
minimum_width = natural_width = SPCP_DEFAULT_WIDTH;
}
-#else
-void
-ColorPreview::on_size_request (Gtk::Requisition *req)
-{
- req->width = SPCP_DEFAULT_WIDTH;
- req->height = SPCP_DEFAULT_HEIGHT;
-}
-
-bool
-ColorPreview::on_expose_event (GdkEventExpose *event)
-{
- bool result = true;
-
- if (get_is_drawable())
- {
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- result = on_draw(cr);
- }
-
- return result;
-}
-#endif
void
ColorPreview::setRgba32 (guint32 rgba)
diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h
index caddfb9a2..1276cf42b 100644
--- a/src/ui/widget/color-preview.h
+++ b/src/ui/widget/color-preview.h
@@ -33,16 +33,10 @@ public:
protected:
virtual void on_size_allocate (Gtk::Allocation &all);
-#if WITH_GTKMM_3_0
virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const;
virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const;
virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const;
virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const;
-#else
- virtual void on_size_request (Gtk::Requisition *req);
- virtual bool on_expose_event(GdkEventExpose *event);
-#endif
-
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
guint32 _rgba;
diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp
index 832bc3a62..89913b01b 100644
--- a/src/ui/widget/color-scales.cpp
+++ b/src/ui/widget/color-scales.cpp
@@ -8,7 +8,6 @@
#include <gtkmm/adjustment.h>
#include <glibmm/i18n.h>
-#include <gtk/gtk.h>
#include "ui/dialog-events.h"
#include "ui/widget/color-scales.h"
@@ -44,11 +43,7 @@ static const gchar *sp_color_scales_hue_map();
const gchar *ColorScales::SUBMODE_NAMES[] = { N_("None"), N_("RGB"), N_("HSL"), N_("CMYK") };
ColorScales::ColorScales(SelectedColor &color, SPColorScalesMode mode)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(5, 3, false)
-#endif
, _color(color)
, _rangeLimit(255.0)
, _updating(FALSE)
@@ -91,15 +86,9 @@ void ColorScales::_initUI(SPColorScalesMode mode)
/* Label */
_l[i] = gtk_label_new("");
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_l[i], GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5);
-#endif
-
gtk_widget_show(_l[i]);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_l[i], XPAD);
gtk_widget_set_margin_end(_l[i], XPAD);
@@ -110,9 +99,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_widget_set_margin_top(_l[i], YPAD);
gtk_widget_set_margin_bottom(_l[i], YPAD);
gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _l[i], 0, 1, i, i + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
-#endif
/* Adjustment */
_a[i] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0));
@@ -120,7 +106,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
_s[i] = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_a[i], true)));
_s[i]->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
_s[i]->set_margin_start(XPAD);
_s[i]->set_margin_end(XPAD);
@@ -132,10 +117,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
_s[i]->set_margin_bottom(YPAD);
_s[i]->set_hexpand(true);
gtk_grid_attach(GTK_GRID(t), _s[i]->gobj(), 1, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _s[i]->gobj(), 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- GTK_FILL, XPAD, YPAD);
-#endif
/* Spinbutton */
_b[i] = gtk_spin_button_new(GTK_ADJUSTMENT(_a[i]), 1.0, 0);
@@ -143,7 +124,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_label_set_mnemonic_widget(GTK_LABEL(_l[i]), _b[i]);
gtk_widget_show(_b[i]);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_b[i], XPAD);
gtk_widget_set_margin_end(_b[i], XPAD);
@@ -156,9 +136,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER);
gtk_widget_set_valign(_b[i], GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(t), _b[i], 2, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
-#endif
/* Attach channel value to adjustment */
g_object_set_data(G_OBJECT(_a[i]), "channel", GINT_TO_POINTER(i));
@@ -270,7 +247,6 @@ void ColorScales::_setRangeLimit(gdouble upper)
_rangeLimit = upper;
for (gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) {
gtk_adjustment_set_upper(_a[i], upper);
- gtk_adjustment_changed(_a[i]);
}
}
@@ -284,11 +260,7 @@ void ColorScales::_onColorChanged()
void ColorScales::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_updateDisplay();
}
diff --git a/src/ui/widget/color-scales.h b/src/ui/widget/color-scales.h
index aeacfbcc1..1e86d762d 100644
--- a/src/ui/widget/color-scales.h
+++ b/src/ui/widget/color-scales.h
@@ -5,11 +5,7 @@
#include <config.h>
#endif
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -27,11 +23,7 @@ typedef enum {
} SPColorScalesMode;
class ColorScales
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *SUBMODE_NAMES[];
diff --git a/src/ui/widget/color-slider.cpp b/src/ui/widget/color-slider.cpp
index bf2156628..2e665dbec 100644
--- a/src/ui/widget/color-slider.cpp
+++ b/src/ui/widget/color-slider.cpp
@@ -18,12 +18,7 @@
#include <gdkmm/cursor.h>
#include <gdkmm/general.h>
#include <gtkmm/adjustment.h>
-#if WITH_GTKMM_3_0
#include <gtkmm/stylecontext.h>
-#else
-#include <gtkmm/style.h>
-#endif
-#include <gtk/gtk.h>
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
@@ -42,14 +37,8 @@ namespace Inkscape {
namespace UI {
namespace Widget {
-#if GTK_CHECK_VERSION(3, 0, 0)
ColorSlider::ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment)
: _dragging(false)
-#else
-ColorSlider::ColorSlider(Gtk::Adjustment *adjustment)
- : _dragging(false)
- , _adjustment(NULL)
-#endif
, _value(0.0)
, _oldvalue(0.0)
, _mapsize(0)
@@ -82,12 +71,7 @@ ColorSlider::~ColorSlider()
if (_adjustment) {
_adjustment_changed_connection.disconnect();
_adjustment_value_changed_connection.disconnect();
-#if GTK_CHECK_VERSION(3, 0, 0)
_adjustment.reset();
-#else
- _adjustment->unreference();
- _adjustment = NULL;
-#endif
}
}
@@ -108,26 +92,15 @@ void ColorSlider::on_realize()
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gdk_screen_get_system_visual(gdk_screen_get_default());
-#if !GTK_CHECK_VERSION(3, 0, 0)
- attributes.colormap = gdk_screen_get_system_colormap(gdk_screen_get_default());
-#endif
attributes.event_mask = get_events();
attributes.event_mask |= (Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK |
Gdk::POINTER_MOTION_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK);
-#if GTK_CHECK_VERSION(3, 0, 0)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
-#else
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-#endif
_gdk_window = Gdk::Window::create(get_parent_window(), &attributes, attributes_mask);
set_window(_gdk_window);
_gdk_window->set_user_data(gobj());
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
- style_attach();
-#endif
}
}
@@ -148,8 +121,6 @@ void ColorSlider::on_size_allocate(Gtk::Allocation &allocation)
}
}
-#if GTK_CHECK_VERSION(3, 0, 0)
-
void ColorSlider::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
{
Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
@@ -176,38 +147,12 @@ void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int &minim
get_preferred_height(minimum_height, natural_height);
}
-#else
-
-void ColorSlider::on_size_request(Gtk::Requisition *requisition)
-{
- GtkStyle *style = gtk_widget_get_style(gobj());
- requisition->width = SLIDER_WIDTH + style->xthickness * 2;
- requisition->height = SLIDER_HEIGHT + style->ythickness * 2;
-}
-
-bool ColorSlider::on_expose_event(GdkEventExpose *event)
-{
- bool result = false;
-
- if (get_is_drawable()) {
- Cairo::RefPtr<Cairo::Context> cr = _gdk_window->create_cairo_context();
- result = on_draw(cr);
- }
- return result;
-}
-
-#endif
-
bool ColorSlider::on_button_press_event(GdkEventButton *event)
{
if (event->button == 1) {
Gtk::Allocation allocation = get_allocation();
gint cx, cw;
-#if GTK_CHECK_VERSION(3, 0, 0)
cx = get_style_context()->get_padding(get_state_flags()).get_left();
-#else
- cx = get_style()->get_xthickness();
-#endif
cw = allocation.get_width() - 2 * cx;
signal_grabbed.emit();
_dragging = true;
@@ -215,15 +160,9 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event)
ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0));
signal_dragged.emit();
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_device_grab(
gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)), _gdk_window->gobj(), GDK_OWNERSHIP_NONE, FALSE,
static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, event->time);
-#else
- gdk_pointer_grab(get_window()->gobj(), FALSE,
- static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL,
- event->time);
-#endif
}
return false;
@@ -232,13 +171,8 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event)
bool ColorSlider::on_button_release_event(GdkEventButton *event)
{
if (event->button == 1) {
-
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_device_ungrab(gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)),
gdk_event_get_time(reinterpret_cast<GdkEvent *>(event)));
-#else
- get_window()->pointer_ungrab(event->time);
-#endif
_dragging = false;
signal_released.emit();
@@ -255,11 +189,7 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event)
if (_dragging) {
gint cx, cw;
Gtk::Allocation allocation = get_allocation();
-#if GTK_CHECK_VERSION(3, 0, 0)
cx = get_style_context()->get_padding(get_state_flags()).get_left();
-#else
- cx = get_style()->get_xthickness();
-#endif
cw = allocation.get_width() - 2 * cx;
ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0));
signal_dragged.emit();
@@ -268,19 +198,10 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event)
return false;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
void ColorSlider::setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment)
{
-#else
-void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment)
-{
-#endif
if (!adjustment) {
-#if GTK_CHECK_VERSION(3, 0, 0)
_adjustment = Gtk::Adjustment::create(0.0, 0.0, 1.0, 0.01, 0.0, 0.0);
-#else
- _adjustment = Gtk::manage(new Gtk::Adjustment(0.0, 0.0, 1.0, 0.01, 0.0, 0.0));
-#endif
}
else {
adjustment->set_page_increment(0.0);
@@ -291,9 +212,6 @@ void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment)
if (_adjustment) {
_adjustment_changed_connection.disconnect();
_adjustment_value_changed_connection.disconnect();
-#if !GTK_CHECK_VERSION(3, 0, 0)
- _adjustment->unreference();
-#endif
}
_adjustment = adjustment;
@@ -314,18 +232,11 @@ void ColorSlider::_onAdjustmentValueChanged()
{
if (_value != ColorScales::getScaled(_adjustment->gobj())) {
gint cx, cy, cw, ch;
-#if GTK_CHECK_VERSION(3, 0, 0)
- Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
- Gtk::Allocation allocation = get_allocation();
- Gtk::Border padding = style_context->get_padding(get_state_flags());
+ auto style_context = get_style_context();
+ auto allocation = get_allocation();
+ auto padding = style_context->get_padding(get_state_flags());
cx = padding.get_left();
cy = padding.get_top();
-#else
- Glib::RefPtr<Gtk::Style> style = get_style();
- Gtk::Allocation allocation = get_allocation();
- cx = style->get_xthickness();
- cy = style->get_ythickness();
-#endif
cw = allocation.get_width() - 2 * cx;
ch = allocation.get_height() - 2 * cy;
if ((gint)(ColorScales::getScaled(_adjustment->gobj()) * cw) != (gint)(_value * cw)) {
@@ -389,40 +300,22 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
{
gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false);
- Gtk::Allocation allocation = get_allocation();
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
-#else
- Glib::RefPtr<Gdk::Window> window = get_window();
- Glib::RefPtr<Gtk::Style> style = get_style();
-#endif
+ auto allocation = get_allocation();
+ auto style_context = get_style_context();
// Draw shadow
if (colorsOnTop) {
-#if GTK_CHECK_VERSION(3, 0, 0)
style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height());
-#else
- gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
- "colorslider", 0, 0, allocation.get_width(), allocation.get_height());
-#endif
}
/* Paintable part of color gradient area */
Gdk::Rectangle carea;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Border padding;
padding = style_context->get_padding(get_state_flags());
carea.set_x(padding.get_left());
carea.set_y(padding.get_top());
- ;
-#else
- carea.set_x(style->get_xthickness());
- carea.set_y(style->get_ythickness());
-#endif
carea.set_width(allocation.get_width() - 2 * carea.get_x());
carea.set_height(allocation.get_height() - 2 * carea.get_y());
@@ -490,12 +383,7 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
/* Draw shadow */
if (!colorsOnTop) {
-#if GTK_CHECK_VERSION(3, 0, 0)
style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height());
-#else
- gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
- "colorslider", 0, 0, allocation.get_width(), allocation.get_height());
-#endif
}
/* Draw arrow */
diff --git a/src/ui/widget/color-slider.h b/src/ui/widget/color-slider.h
index 253f3123c..9be6c356a 100644
--- a/src/ui/widget/color-slider.h
+++ b/src/ui/widget/color-slider.h
@@ -24,18 +24,10 @@ namespace Widget {
*/
class ColorSlider : public Gtk::Widget {
public:
-#if GTK_CHECK_VERSION(3, 0, 0)
ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment);
-#else
- ColorSlider(Gtk::Adjustment *adjustment);
-#endif
~ColorSlider();
-#if GTK_CHECK_VERSION(3, 0, 0)
void setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment);
-#else
- void setAdjustment(Gtk::Adjustment *adjustment);
-#endif
void setColors(guint32 start, guint32 mid, guint32 end);
@@ -56,16 +48,10 @@ protected:
bool on_button_release_event(GdkEventButton *event);
bool on_motion_notify_event(GdkEventMotion *event);
bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const;
void get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const;
void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const;
void get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const;
-#else
- void on_size_request(Gtk::Requisition *requisition);
- bool on_expose_event(GdkEventExpose *event);
-#endif
private:
void _onAdjustmentChanged();
@@ -73,11 +59,7 @@ private:
bool _dragging;
-#if GTK_CHECK_VERSION(3, 0, 0)
Glib::RefPtr<Gtk::Adjustment> _adjustment;
-#else
- Gtk::Adjustment *_adjustment;
-#endif
sigc::connection _adjustment_changed_connection;
sigc::connection _adjustment_value_changed_connection;
diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp
index decb02b4f..4f011c6c3 100644
--- a/src/ui/widget/color-wheel-selector.cpp
+++ b/src/ui/widget/color-wheel-selector.cpp
@@ -11,7 +11,7 @@
#include "ui/dialog-events.h"
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
-#include "ui/widget/gimpcolorwheel.h"
+#include "widgets/gimp/gimpcolorwheel.h"
namespace Inkscape {
namespace UI {
@@ -25,16 +25,9 @@ namespace Widget {
const gchar *ColorWheelSelector::MODE_NAME = N_("Wheel");
ColorWheelSelector::ColorWheelSelector(SelectedColor &color)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(5, 3, false)
-#endif
, _color(color)
, _updating(false)
-#if !GTK_CHECK_VERSION(3, 0, 0)
- , _alpha_adjustment(NULL)
-#endif
, _wheel(0)
, _slider(0)
{
@@ -46,9 +39,6 @@ ColorWheelSelector::ColorWheelSelector(SelectedColor &color)
ColorWheelSelector::~ColorWheelSelector()
{
_wheel = 0;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- delete _alpha_adjustment;
-#endif
_color_changed_connection.disconnect();
_color_dragged_connection.disconnect();
@@ -62,16 +52,11 @@ void ColorWheelSelector::_initUI()
_wheel = gimp_color_wheel_new();
gtk_widget_show(_wheel);
-#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_set_halign(_wheel, GTK_ALIGN_FILL);
gtk_widget_set_valign(_wheel, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(_wheel, TRUE);
gtk_widget_set_vexpand(_wheel, TRUE);
gtk_grid_attach(GTK_GRID(gobj()), _wheel, 0, row, 3, 1);
-#else
- gtk_table_attach(GTK_TABLE(gobj()), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
-#endif
row++;
@@ -80,7 +65,6 @@ void ColorWheelSelector::_initUI()
label->set_alignment(1.0, 0.5);
label->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
label->set_margin_start(XPAD);
label->set_margin_end(XPAD);
@@ -93,22 +77,15 @@ void ColorWheelSelector::_initUI()
label->set_halign(Gtk::ALIGN_FILL);
label->set_valign(Gtk::ALIGN_FILL);
attach(*label, 0, row, 1, 1);
-#else
- attach(*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::FILL, XPAD, YPAD);
-#endif
-/* Adjustment */
-#if GTK_CHECK_VERSION(3, 0, 0)
+ /* Adjustment */
_alpha_adjustment = Gtk::Adjustment::create(0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
-#else
- _alpha_adjustment = new Gtk::Adjustment(0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
-#endif
+
/* Slider */
_slider = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(_alpha_adjustment));
_slider->set_tooltip_text(_("Alpha (opacity)"));
_slider->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
_slider->set_margin_start(XPAD);
_slider->set_margin_end(XPAD);
@@ -122,25 +99,17 @@ void ColorWheelSelector::_initUI()
_slider->set_halign(Gtk::ALIGN_FILL);
_slider->set_valign(Gtk::ALIGN_FILL);
attach(*_slider, 1, row, 1, 1);
-#else
- attach(*_slider, 1, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::FILL, XPAD, YPAD);
-#endif
_slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5),
SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 1.0));
-/* Spinbutton */
-#if GTK_CHECK_VERSION(3, 0, 0)
- Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0));
-#else
- Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(*_alpha_adjustment, 1.0, 0));
-#endif
+ /* Spinbutton */
+ auto spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0));
spin_button->set_tooltip_text(_("Alpha (opacity)"));
sp_dialog_defocus_on_enter(GTK_WIDGET(spin_button->gobj()));
label->set_mnemonic_widget(*spin_button);
spin_button->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
spin_button->set_margin_start(XPAD);
spin_button->set_margin_end(XPAD);
@@ -153,9 +122,6 @@ void ColorWheelSelector::_initUI()
spin_button->set_halign(Gtk::ALIGN_CENTER);
spin_button->set_valign(Gtk::ALIGN_CENTER);
attach(*spin_button, 2, row, 1, 1);
-#else
- attach(*spin_button, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, XPAD, YPAD);
-#endif
/* Signals */
_alpha_adjustment->signal_value_changed().connect(sigc::mem_fun(this, &ColorWheelSelector::_adjustmentChanged));
@@ -168,11 +134,7 @@ void ColorWheelSelector::_initUI()
void ColorWheelSelector::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_updateDisplay();
}
diff --git a/src/ui/widget/color-wheel-selector.h b/src/ui/widget/color-wheel-selector.h
index 5711d417c..ee7bd9b83 100644
--- a/src/ui/widget/color-wheel-selector.h
+++ b/src/ui/widget/color-wheel-selector.h
@@ -16,11 +16,7 @@
#include <config.h>
#endif
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -33,11 +29,7 @@ namespace Widget {
class ColorSlider;
class ColorWheelSelector
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *MODE_NAME;
@@ -61,11 +53,7 @@ protected:
SelectedColor &_color;
bool _updating;
-#if GTK_CHECK_VERSION(3, 0, 0)
Glib::RefPtr<Gtk::Adjustment> _alpha_adjustment;
-#else
- Gtk::Adjustment *_alpha_adjustment;
-#endif
GtkWidget *_wheel;
Inkscape::UI::Widget::ColorSlider *_slider;
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp
index 1b3490ffe..979c09d2f 100644
--- a/src/ui/widget/dock-item.cpp
+++ b/src/ui/widget/dock-item.cpp
@@ -57,11 +57,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
Gtk::StockItem item;
Gtk::StockID stockId(icon_name);
if ( Gtk::StockItem::lookup(stockId, item) ) {
-#if WITH_GTKMM_3_0
_icon_pixbuf = _dock.getWidget().render_icon_pixbuf( stockId, Gtk::ICON_SIZE_MENU );
-#else
- _icon_pixbuf = _dock.getWidget().render_icon( stockId, Gtk::ICON_SIZE_MENU );
-#endif
}
}
}
@@ -173,12 +169,8 @@ DockItem::set_size_request(int width, int height)
void DockItem::size_request(Gtk::Requisition& requisition)
{
-#if WITH_GTKMM_3_0
Gtk::Requisition req_natural;
getWidget().get_preferred_size(req_natural, requisition);
-#else
- requisition = getWidget().size_request();
-#endif
}
void
diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h
index 25a69d94c..2df45b207 100644
--- a/src/ui/widget/dock-item.h
+++ b/src/ui/widget/dock-item.h
@@ -19,11 +19,7 @@
#include <gtkmm/frame.h>
#include <gtkmm/window.h>
-#if WITH_EXT_GDL
#include <gdl/gdl.h>
-#else
-#include "libgdl/gdl.h"
-#endif
namespace Gtk {
class HButtonBox;
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index fda647182..7744cb695 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -65,7 +65,6 @@ Dock::Dock(Gtk::Orientation orientation)
static_cast<GtkOrientation>(orientation));
#endif
-#if WITH_GTKMM_3_0
switch(orientation) {
case Gtk::ORIENTATION_VERTICAL:
_dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@@ -75,17 +74,6 @@ Dock::Dock(Gtk::Orientation orientation)
}
_paned = Gtk::manage(new Gtk::Paned(orientation));
-#else
- switch (orientation) {
- case Gtk::ORIENTATION_VERTICAL:
- _dock_box = Gtk::manage(new Gtk::HBox());
- _paned = Gtk::manage(new Gtk::VPaned());
- break;
- case Gtk::ORIENTATION_HORIZONTAL:
- _dock_box = Gtk::manage(new Gtk::VBox());
- _paned = Gtk::manage(new Gtk::HPaned());
- }
-#endif
_scrolled_window->add(*_dock_box);
_scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c
deleted file mode 100644
index d54486505..000000000
--- a/src/ui/widget/gimpcolorwheel.c
+++ /dev/null
@@ -1,1604 +0,0 @@
-/* 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);
-#if GTK_CHECK_VERSION(3,0,0)
-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);
-#else
-static gboolean gimp_color_wheel_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void gimp_color_wheel_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-#endif
-
-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;
-
-#if GTK_CHECK_VERSION(3,0,0)
- 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;
-#else
- widget_class->size_request = gimp_color_wheel_size_request;
- widget_class->expose_event = gimp_color_wheel_expose;
-#endif
-
- 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);
-
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_style_attach (widget);
-#endif
-}
-
-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);
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-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);
-}
-#else
-static void
-gimp_color_wheel_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- requisition->width = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
- requisition->height = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
-}
-#endif
-
-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);
-
-#if GTK_CHECK_VERSION(3,0,0)
- 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);
-#else
- gdk_pointer_grab (priv->window, FALSE,
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_RELEASE_MASK,
- NULL, cursor, time);
- gdk_cursor_unref (cursor);
-#endif
-}
-
-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 ();
-
-#if GTK_CHECK_VERSION(3,0,0)
- gdk_device_ungrab (gtk_get_current_event_device(),
- event->time);
-#else
- gdk_display_pointer_ungrab (gdk_window_get_display (event->window),
- event->time);
-#endif
-
- 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)
-{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *widget = GTK_WIDGET (wheel);
-#else
- GtkAllocation allocation;
-#endif
- 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;
-
-#if GTK_CHECK_VERSION(3,0,0)
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
-#else
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
- width = allocation.width;
- height = allocation.height;
-#endif
-
- 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;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *context;
-
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
-#else
- gchar *detail;
-
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
- width = allocation.width;
- height = allocation.height;
-#endif
-
- /* 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);
-
-#if GTK_CHECK_VERSION(3,0,0)
- context = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (context);
-#endif
-
- if (INTENSITY (r, g, b) > 0.5)
- {
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_add_class (context, "light-area-focus");
-#else
- detail = "colorwheel_light";
-#endif
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- }
- else
- {
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_add_class (context, "dark-area-focus");
-#else
- detail = "colorwheel_dark";
-#endif
- 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);
-
-#if GTK_CHECK_VERSION(3,0,0)
- 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));
-#else
- gtk_widget_get_allocation (widget, &allocation);
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- NULL, widget, detail,
- allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad,
- allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad,
- 2 * (FOCUS_RADIUS + focus_width + focus_pad),
- 2 * (FOCUS_RADIUS + focus_width + focus_pad));
-#endif
- }
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_restore (context);
-#endif
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-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;
-}
-#else
-static gint
-gimp_color_wheel_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
-
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gboolean draw_focus;
- GtkAllocation allocation;
-
- if (! (event->window == gtk_widget_get_window (widget) &&
- gtk_widget_is_drawable (widget)))
- return FALSE;
-
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- gtk_widget_get_allocation (widget, &allocation);
- cairo_translate (cr, allocation.x, allocation.y);
-
- draw_focus = gtk_widget_has_focus (widget);
-
- paint_ring (wheel, cr);
- paint_triangle (wheel, cr, draw_focus);
-
- cairo_destroy (cr);
-
- if (draw_focus && priv->focus_on_ring)
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- &event->area, widget, NULL,
- allocation.x,
- allocation.y,
- allocation.width,
- allocation.height);
-
- return FALSE;
-}
-#endif
-
-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/ui/widget/gimpcolorwheel.h b/src/ui/widget/gimpcolorwheel.h
deleted file mode 100644
index 016fb593f..000000000
--- a/src/ui/widget/gimpcolorwheel.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* 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/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c
deleted file mode 100644
index d99646a64..000000000
--- a/src/ui/widget/gimpspinscale.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/* 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
-#if WITH_GTKMM_3_0
- ,TARGET_NONE
-#endif
-} 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);
-
-#if WITH_GTKMM_3_0
-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);
-#else
-static void gimp_spin_scale_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-
-static gboolean gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event);
-#endif
-
-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;
-#if WITH_GTKMM_3_0
- 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;
-#else
- widget_class->size_request = gimp_spin_scale_size_request;
- widget_class->expose_event = gimp_spin_scale_expose;
-#endif
- 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;
- }
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-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);
-}
-#else
-static void
-gimp_spin_scale_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
- gint height;
-
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
-
- metrics = pango_context_get_metrics (context, style->font_desc,
- pango_context_get_language (context));
-
- height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
-
- if (private->appearanceMode == APPEARANCE_COMPACT) {
- requisition->height += 1;
- } else {
- requisition->height += height;
- }
-
- 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 ellipses */
- requisition->width += char_pixels * 3;
- }
-
- pango_font_metrics_unref (metrics);
-}
-#endif
-
-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
-#if GTK_CHECK_VERSION(3,0,0)
- gimp_spin_scale_draw (GtkWidget *widget,
- cairo_t *cr)
-#else
- gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-#if GTK_CHECK_VERSION(3,0,0)
- 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);
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- cairo_t *cr;
- gint w;
-
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- w = gdk_window_get_width (event->window);
-#endif
-
- cairo_set_line_width (cr, 1.0);
-
-#if GTK_CHECK_VERSION(3,0,0)
- if (private->label)
- {
- GdkRectangle text_area;
- gint minimum_width;
- gint natural_width;
-#else
- if (private->label &&
- gtk_widget_is_drawable (widget) &&
- event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
- {
- GtkRequisition requisition;
- GtkAllocation allocation;
-#endif
- PangoRectangle logical;
- gint layout_offset_x;
- gint layout_offset_y;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStateFlags state;
- GdkRGBA text_color;
- GdkRGBA bar_text_color;
-#else
- GtkStateType state;
- GdkColor text_color;
- GdkColor bar_text_color;
- gint window_width;
- gint window_height;
-#endif
- gdouble progress_fraction;
- gint progress_x;
- gint progress_y;
- gint progress_width;
- gint progress_height;
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
- &minimum_width,
- &natural_width);
-#else
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition);
- gtk_widget_get_allocation (widget, &allocation);
-#endif
-
- 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 *
-#if GTK_CHECK_VERSION(3,0,0)
- (allocation.width - minimum_width));
-#else
- (allocation.width - requisition.width));
-#endif
- 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)
-#if GTK_CHECK_VERSION(3,0,0)
- layout_offset_x = text_area.x + text_area.width - logical.width - 4;
-#else
- layout_offset_x = w - logical.width - 4;
-#endif
- else
- layout_offset_x = 4;
-
- layout_offset_x -= logical.x;
-
-#if GTK_CHECK_VERSION(3,0,0)
- 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);
-#else
- state = GTK_STATE_SELECTED;
- if (! gtk_widget_get_sensitive (widget))
- state = GTK_STATE_INSENSITIVE;
- text_color = style->text[gtk_widget_get_state (widget)];
- bar_text_color = style->fg[state];
-
- window_width = gdk_window_get_width (event->window);
- window_height = gdk_window_get_height (event->window);
-#endif
-
- 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;
-
-#if GTK_CHECK_VERSION(3,0,0)
- progress_x = text_area.width * progress_fraction;
-#else
- progress_x = window_width * progress_fraction;
-#endif
- progress_y = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- progress_width = text_area.width - progress_x;
- progress_height = text_area.height;
-#else
- progress_width = window_width - progress_x;
- progress_height = window_height;
-#endif
- }
- else
- {
- progress_x = 0;
- progress_y = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- progress_width = text_area.width * progress_fraction;
- progress_height = text_area.height;
-#else
- progress_width = window_width * progress_fraction;
- progress_height = window_height;
-#endif
- }
-
- cairo_save (cr);
-
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_rectangle (cr, 0, 0, text_area.width, text_area.height);
-#else
- cairo_rectangle (cr, 0, 0, window_width, window_height);
-#endif
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &text_color);
-#else
- cairo_move_to (cr, layout_offset_x, layout_offset_y-3);
- gdk_cairo_set_source_color (cr, &text_color);
-#endif
- pango_cairo_show_layout (cr, private->layout);
- cairo_restore (cr);
-
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &bar_text_color);
-#else
- cairo_move_to (cr, layout_offset_x, layout_offset_y-3);
- gdk_cairo_set_source_color (cr, &bar_text_color);
-#endif
- pango_cairo_show_layout (cr, private->layout);
- }
-
-#if !GTK_CHECK_VERSION(3,0,0)
- cairo_destroy (cr);
-#endif
-
- return FALSE;
-}
-
-#if WITH_GTKMM_3_0
-/* 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;
-}
-#endif
-
-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);
-
-#if WITH_GTKMM_3_0
- 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;
-#else
- if (x > layout_x && x < layout_x + logical.width &&
- y > layout_y && y < layout_y + logical.height)
- {
- return TARGET_NUMBER;
- }
-
- else if (y > allocation.height / 2)
- {
- return TARGET_LOWER;
- }
- return TARGET_UPPER;
-#endif
-}
-
-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;
-#if WITH_GTKMM_3_0
-#else
-#endif
-#if WITH_GTKMM_3_0
- GdkRectangle text_area;
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
-#else
- GdkWindow *text_window = gtk_entry_get_text_window (GTK_ENTRY (widget));
- gint width;
-
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
-
- width = gdk_window_get_width (text_window);
-#endif
-
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-#if WITH_GTKMM_3_0
- x = text_area.width - x;
-#else
- x = width - x;
-#endif
-
-
- if (private->relative_change)
- {
- gdouble diff;
- gdouble step;
-
-
-#if WITH_GTKMM_3_0
- step = (upper - lower) / text_area.width / 10.0;
-#else
- step = (upper - lower) / width / 10.0;
-#endif
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-
-#if WITH_GTKMM_3_0
- diff = x - (text_area.width - private->start_x);
-#else
- diff = x - (width - private->start_x);
-#endif
- else
- diff = x - private->start_x;
-
- value = (private->start_value + diff * step);
- }
- else
- {
- gdouble fraction;
-
-
-#if WITH_GTKMM_3_0
- fraction = x / (gdouble) text_area.width;
-#else
- fraction = x / (gdouble) width;
-#endif
- 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;
-
-#if WITH_GTKMM_3_0
- 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;
- }
-#else
- if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
- {
- switch (gimp_spin_scale_get_target (widget, event->x, event->y))
- {
- case TARGET_UPPER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- gimp_spin_scale_change_value (widget, event->x);
-
- return TRUE;
-
- case TARGET_LOWER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- private->relative_change = TRUE;
- private->start_x = event->x;
- private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
-
- return TRUE;
-
- default:
- break;
- }
- }
-#endif
-
- 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);
-#if WITH_GTKMM_3_0
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-#endif
-
- if (private->changing_value)
- {
- private->changing_value = FALSE;
-#if WITH_GTKMM_3_0
- gimp_spin_scale_change_value (widget, x);
-#else
- gimp_spin_scale_change_value (widget, event->x);
-#endif
- 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);
-
-#if WITH_GTKMM_3_0
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-#endif
-
- if (private->changing_value)
- {
-#if WITH_GTKMM_3_0
- gimp_spin_scale_change_value (widget, x);
-#else
- gimp_spin_scale_change_value (widget, event->x);
-#endif
-
- return TRUE;
- }
-
- GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
-
- if (! (event->state &
- (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))
-#if WITH_GTKMM_3_0
-#else
- && event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))
-#endif
- )
- {
- GdkDisplay *display = gtk_widget_get_display (widget);
- GdkCursor *cursor = NULL;
-
-#if WITH_GTKMM_3_0
- switch (gimp_spin_scale_get_target (widget, x, y))
-#else
- switch (gimp_spin_scale_get_target (widget, event->x, event->y))
-#endif
- {
- 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 WITH_GTKMM_3_0
- if (cursor)
- {
- gdk_window_set_cursor (event->window, cursor);
- g_object_unref (cursor);
- }
-#else
- gdk_window_set_cursor (event->window, cursor);
- gdk_cursor_unref (cursor);
-#endif
- }
-
- 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/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h
deleted file mode 100644
index b42a0faf8..000000000
--- a/src/ui/widget/gimpspinscale.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* 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/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp
index c1068c9b2..561c1332a 100644
--- a/src/ui/widget/highlight-picker.cpp
+++ b/src/ui/widget/highlight-picker.cpp
@@ -32,8 +32,6 @@ HighlightPicker::~HighlightPicker()
{
}
-
-#if WITH_GTKMM_3_0
void HighlightPicker::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -63,39 +61,12 @@ void HighlightPicker::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void HighlightPicker::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = 10;//+= (*width) >> 1;
- }
- if ( height ) {
- *height = 20; //cell_area ? cell_area->get_height() / 2 : 50; //+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void HighlightPicker::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
GdkRectangle carea;
@@ -137,11 +108,7 @@ void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
convert_pixbuf_argb32_to_normal(pixbuf);
property_pixbuf() = Glib::wrap(pixbuf);
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool HighlightPicker::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/highlight-picker.h b/src/ui/widget/highlight-picker.h
index c5fe4c02c..c459b0dcd 100644
--- a/src/ui/widget/highlight-picker.h
+++ b/src/ui/widget/highlight-picker.h
@@ -29,8 +29,6 @@ public:
Glib::PropertyProxy<guint32> property_active() { return _property_active.get_proxy(); }
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -44,18 +42,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp
index 29907f4c9..987cc67bb 100644
--- a/src/ui/widget/imagetoggler.cpp
+++ b/src/ui/widget/imagetoggler.cpp
@@ -53,8 +53,6 @@ ImageToggler::ImageToggler( char const* on, char const* off) :
property_pixbuf() = _property_pixbuf_off.get_value();
}
-
-#if WITH_GTKMM_3_0
void ImageToggler::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -84,46 +82,15 @@ void ImageToggler::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void ImageToggler::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width += (*width) >> 1;
- }
- if ( height ) {
- *height += (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void ImageToggler::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void ImageToggler::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off;
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool
diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h
index 7b02fa4dc..d4f27cf11 100644
--- a/src/ui/widget/imagetoggler.h
+++ b/src/ui/widget/imagetoggler.h
@@ -36,8 +36,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -51,18 +49,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp
index 9aec7d135..7ed1ed2e2 100644
--- a/src/ui/widget/insertordericon.cpp
+++ b/src/ui/widget/insertordericon.cpp
@@ -52,7 +52,6 @@ InsertOrderIcon::InsertOrderIcon() :
}
-#if WITH_GTKMM_3_0
void InsertOrderIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -82,39 +81,12 @@ void InsertOrderIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void InsertOrderIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void InsertOrderIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
switch (_property_active.get_value())
{
@@ -128,11 +100,7 @@ void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
break;
}
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool InsertOrderIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/insertordericon.h b/src/ui/widget/insertordericon.h
index bf8ac4fa7..43188fa5b 100644
--- a/src/ui/widget/insertordericon.h
+++ b/src/ui/widget/insertordericon.h
@@ -33,7 +33,6 @@ public:
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -47,18 +46,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp
index e281d982a..df85f271a 100644
--- a/src/ui/widget/layertypeicon.cpp
+++ b/src/ui/widget/layertypeicon.cpp
@@ -63,8 +63,6 @@ LayerTypeIcon::LayerTypeIcon() :
property_pixbuf() = _property_pixbuf_path.get_value();
}
-
-#if WITH_GTKMM_3_0
void LayerTypeIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -94,46 +92,15 @@ void LayerTypeIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void LayerTypeIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width += (*width) >> 1;
- }
- if ( height ) {
- *height += (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void LayerTypeIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void LayerTypeIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
property_pixbuf() = _property_active.get_value() == 1 ? _property_pixbuf_group : (_property_active.get_value() == 2 ? _property_pixbuf_layer : _property_pixbuf_path);
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool
diff --git a/src/ui/widget/layertypeicon.h b/src/ui/widget/layertypeicon.h
index 6c71ce361..f12029c12 100644
--- a/src/ui/widget/layertypeicon.h
+++ b/src/ui/widget/layertypeicon.h
@@ -35,8 +35,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -50,18 +48,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp
index 09f3fac8d..1e9ee361d 100644
--- a/src/ui/widget/licensor.cpp
+++ b/src/ui/widget/licensor.cpp
@@ -134,18 +134,10 @@ void Licensor::update (SPDocument *doc)
for (i=0; rdf_licenses[i].name; i++)
if (license == &rdf_licenses[i])
break;
-#if WITH_GTKMM_3_0
static_cast<LicenseItem*>(get_children()[i+1])->set_active();
-#else
- static_cast<LicenseItem*>(children()[i+1].get_widget())->set_active();
-#endif
}
else {
-#if WITH_GTKMM_3_0
static_cast<LicenseItem*>(get_children()[0])->set_active();
-#else
- static_cast<LicenseItem*>(children()[0].get_widget())->set_active();
-#endif
}
/* update the URI */
diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp
index 2f03ed23b..6d8ff1d75 100644
--- a/src/ui/widget/notebook-page.cpp
+++ b/src/ui/widget/notebook-page.cpp
@@ -11,31 +11,19 @@
#include "notebook-page.h"
-#if WITH_GTKMM_3_0
# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
namespace Inkscape {
namespace UI {
namespace Widget {
NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding)
-#if WITH_GTKMM_3_0
:_table(Gtk::manage(new Gtk::Grid()))
-#else
- :_table(Gtk::manage(new Gtk::Table(n_rows, n_columns)))
-#endif
{
set_border_width(2);
-#if WITH_GTKMM_3_0
_table->set_row_spacing(2);
_table->set_column_spacing(2);
-#else
- _table->set_spacings(2);
-#endif
pack_start(*_table, expand, fill, padding);
}
diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h
index c11de1b5b..6eb23907c 100644
--- a/src/ui/widget/notebook-page.h
+++ b/src/ui/widget/notebook-page.h
@@ -17,11 +17,7 @@
#include <gtkmm/box.h>
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
@@ -42,19 +38,10 @@ public:
*/
NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0);
-#if WITH_GTKMM_3_0
Gtk::Grid& table() { return *_table; }
-#else
- Gtk::Table& table() { return *_table; }
-#endif
protected:
-
-#if WITH_GTKMM_3_0
Gtk::Grid *_table;
-#else
- Gtk::Table *_table;
-#endif
};
} // namespace Widget
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 4a1fe9ac6..578b6855a 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -336,7 +336,6 @@ PageSizer::PageSizer(Registry & _wr)
_customDimTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_customDimTable.set_row_spacing(4);
_customDimTable.set_column_spacing(4);
@@ -355,15 +354,6 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageMarginExpander.set_hexpand();
_fitPageMarginExpander.set_vexpand();
_customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1);
-#else
- _customDimTable.resize(3, 2);
- _customDimTable.set_row_spacings(4);
- _customDimTable.set_col_spacings(4);
- _customDimTable.attach(_dimensionWidth, 0,1, 0,1);
- _customDimTable.attach(_dimensionUnits, 1,2, 0,1);
- _customDimTable.attach(_dimensionHeight, 0,1, 1,2);
- _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3);
-#endif
_dimTabOrderGList = NULL;
_dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj());
@@ -381,7 +371,6 @@ PageSizer::PageSizer(Registry & _wr)
//## Set up margin settings
_marginTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_marginTable.set_row_spacing(4);
_marginTable.set_column_spacing(4);
@@ -404,16 +393,6 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageButtonAlign.set_hexpand();
_fitPageButtonAlign.set_vexpand();
_marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1);
-#else
- _marginTable.set_border_width(4);
- _marginTable.set_row_spacings(4);
- _marginTable.set_col_spacings(4);
- _marginTable.attach(_marginTopAlign, 0,2, 0,1);
- _marginTable.attach(_marginLeftAlign, 0,1, 1,2);
- _marginTable.attach(_marginRightAlign, 1,2, 1,2);
- _marginTable.attach(_marginBottomAlign, 0,2, 2,3);
- _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4);
-#endif
_marginTopAlign.set(0.5, 0.5, 0.0, 1.0);
_marginTopAlign.add(_marginTop);
@@ -436,7 +415,6 @@ PageSizer::PageSizer(Registry & _wr)
_scaleTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_scaleTable.set_row_spacing(4);
_scaleTable.set_column_spacing(4);
@@ -448,16 +426,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxExpander.set_hexpand();
_viewboxExpander.set_vexpand();
_scaleTable.attach(_viewboxExpander, 0, 2, 2, 1);
-#else
- _scaleTable.resize(3, 2);
- _scaleTable.set_row_spacings(4);
- _scaleTable.set_col_spacings(4);
- _scaleTable.attach(_scaleX, 0,1, 0,1);
- _scaleTable.attach(_scaleY, 1,2, 0,1);
- _scaleTable.attach(_scaleLabel, 2,3, 0,1);
- _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL);
- _scaleTable.attach(_viewboxExpander, 0,3, 2,3);
-#endif
_scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly."));
_scaleWarning.set_line_wrap( true );
@@ -466,7 +434,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxExpander.set_label(_("_Viewbox..."));
_viewboxExpander.add(_viewboxTable);
-#if WITH_GTKMM_3_0
_viewboxTable.set_row_spacing(2);
_viewboxTable.set_column_spacing(2);
@@ -486,16 +453,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxH.set_vexpand();
_viewboxTable.attach(_viewboxH, 1, 1, 1, 1);
-#else
- _viewboxTable.set_border_width(4);
- _viewboxTable.set_row_spacings(2);
- _viewboxTable.set_col_spacings(2);
- _viewboxTable.attach(_viewboxX, 0,1, 0,1);
- _viewboxTable.attach(_viewboxY, 1,2, 0,1);
- _viewboxTable.attach(_viewboxW, 0,1, 1,2);
- _viewboxTable.attach(_viewboxH, 1,2, 1,2);
-#endif
-
_wr.setUpdating (true);
updateScaleUI();
_wr.setUpdating (false);
diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h
index 0eea28e61..f1966f848 100644
--- a/src/ui/widget/page-sizer.h
+++ b/src/ui/widget/page-sizer.h
@@ -23,15 +23,9 @@
#include <gtkmm/alignment.h>
#include <gtkmm/expander.h>
#include <gtkmm/frame.h>
+#include <gtkmm/grid.h>
#include <gtkmm/liststore.h>
#include <gtkmm/scrolledwindow.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
#include <gtkmm/radiobutton.h>
namespace Inkscape {
@@ -222,12 +216,7 @@ protected:
//### Custom size frame
Gtk::Frame _customFrame;
-
-#if WITH_GTKMM_3_0
Gtk::Grid _customDimTable;
-#else
- Gtk::Table _customDimTable;
-#endif
RegisteredUnitMenu _dimensionUnits;
RegisteredScalarUnit _dimensionWidth;
@@ -237,12 +226,7 @@ protected:
//### Fit Page options
Gtk::Expander _fitPageMarginExpander;
-#if WITH_GTKMM_3_0
Gtk::Grid _marginTable;
-#else
- Gtk::Table _marginTable;
-#endif
-
Gtk::Alignment _marginTopAlign;
Gtk::Alignment _marginLeftAlign;
Gtk::Alignment _marginRightAlign;
@@ -257,11 +241,7 @@ protected:
// Document scale
Gtk::Frame _scaleFrame;
-#if WITH_GTKMM_3_0
Gtk::Grid _scaleTable;
-#else
- Gtk::Table _scaleTable;
-#endif
Gtk::Label _scaleLabel;
Gtk::Label _scaleWarning;
@@ -271,11 +251,7 @@ protected:
// Viewbox
Gtk::Expander _viewboxExpander;
-#if WITH_GTKMM_3_0
Gtk::Grid _viewboxTable;
-#else
- Gtk::Table _viewboxTable;
-#endif
RegisteredScalar _viewboxX;
RegisteredScalar _viewboxY;
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index 98d9d41f3..6e6e6c527 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -72,9 +72,7 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path,
_fillable(0)
{
set_name( "InkscapePanel" );
-#if WITH_GTKMM_3_0
set_orientation( Gtk::ORIENTATION_VERTICAL );
-#endif
_init();
}
@@ -596,13 +594,9 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_s
{
// Create a button box for the response buttons if it's the first button to be added
if (!_action_area) {
-#if WITH_GTKMM_3_0
_action_area = new Gtk::ButtonBox();
_action_area->set_layout(Gtk::BUTTONBOX_END);
_action_area->set_spacing(6);
-#else
- _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
-#endif
_action_area->set_border_width(4);
pack_end(*_action_area, Gtk::PACK_SHRINK, 0);
}
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 7b2836fe8..370779586 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -31,13 +31,7 @@ class SPDocument;
namespace Gtk {
class CheckMenuItem;
-
-#if WITH_GTKMM_3_0
class ButtonBox;
-#else
- class HButtonBox;
-#endif
-
class MenuItem;
}
@@ -64,12 +58,7 @@ namespace Widget {
* @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications.
* @see UI::Dialog::DialogManager manages the dialogs within inkscape.
*/
-#if WITH_GTKMM_3_0
class Panel : public Gtk::Box {
-#else
-class Panel : public Gtk::VBox {
-#endif
-
public:
static void prep();
@@ -172,12 +161,7 @@ private:
Gtk::EventBox _menu_popper;
Gtk::Button _close_button;
Gtk::Menu *_menu;
-
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *_action_area; //< stores response buttons
-#else
- Gtk::HButtonBox *_action_area; //< stores response buttons
-#endif
+ Gtk::ButtonBox *_action_area; //< stores response buttons
std::vector<Gtk::Widget *> _non_horizontal;
std::vector<Gtk::Widget *> _non_vertical;
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
index 2c2eb5e8a..6b31b1856 100644
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
@@ -50,11 +50,7 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 17078df8f..71bfd8473 100644
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
@@ -82,11 +82,7 @@ public:
*/
Point( Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index e0eba3934..1205cd012 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -51,14 +51,9 @@ DialogPage::DialogPage()
{
set_border_width(12);
-#if WITH_GTKMM_3_0
set_orientation(Gtk::ORIENTATION_VERTICAL);
set_column_spacing(12);
set_row_spacing(6);
-#else
- set_col_spacings(12);
- set_row_spacings(6);
-#endif
}
/**
@@ -97,12 +92,7 @@ void DialogPage::add_line(bool indent,
// be indented if desired
Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment());
w_alignment->add(*hb);
-
-#if WITH_GTKMM_3_0
w_alignment->set_valign(Gtk::ALIGN_CENTER);
-#else
- guint row = property_n_rows();
-#endif
// Add a label in the first column if provided
if (label != "")
@@ -118,17 +108,12 @@ void DialogPage::add_line(bool indent,
if (indent)
label_alignment->set_padding(0, 0, 12, 0);
-#if WITH_GTKMM_3_0
label_alignment->set_valign(Gtk::ALIGN_CENTER);
add(*label_alignment);
attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1);
-#else
- attach(*label_alignment, 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
-#endif
}
// Now add the widget to the bottom of the dialog
-#if WITH_GTKMM_3_0
if (label == "")
{
if (indent)
@@ -141,17 +126,6 @@ void DialogPage::add_line(bool indent,
g_value_set_int(&width, 2);
gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width);
}
-#else
- // The widget should span two columns if there is no label
- int w_col_span = 1;
- if (label == "")
- w_col_span = 2;
-
- attach(*w_alignment, 2 - w_col_span, 2, row, row + 1,
- Gtk::FILL | Gtk::EXPAND,
- Gtk::AttachOptions(),
- 0, 0);
-#endif
// Add a label on the right of the widget if desired
if (suffix != "")
@@ -170,18 +144,8 @@ void DialogPage::add_group_header(Glib::ustring name)
Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true));
label_widget->set_use_markup(true);
-
-#if WITH_GTKMM_3_0
label_widget->set_valign(Gtk::ALIGN_CENTER);
add(*label_widget);
-// if (row != 1)
- // set_row_spacing(row - 1, 18);
-#else
- int row = property_n_rows();
- attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
- if (row != 1)
- set_row_spacing(row - 1, 18);
-#endif
}
}
@@ -423,24 +387,6 @@ ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int maj
}
}
-#if !WITH_GTKMM_3_0
-bool
-ZoomCorrRuler::on_expose_event(GdkEventExpose *event) {
- bool result = false;
-
- if(get_is_drawable())
- {
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- result = on_draw(cr);
- }
-
- return result;
-}
-#endif
-
bool
ZoomCorrRuler::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
Glib::RefPtr<Gdk::Window> window = get_window();
@@ -544,11 +490,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
_ruler.set_size(ruler_width, ruler_height);
-#if WITH_GTKMM_3_0
_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- _slider = Gtk::manage(new Gtk::HScale());
-#endif
_slider->set_size_request(_ruler.width(), -1);
_slider->set_range (lower, upper);
@@ -575,21 +517,13 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
alignment1->add(_sb);
alignment2->add(_unit);
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = Gtk::manage(new Gtk::Grid());
+ auto table = Gtk::manage(new Gtk::Grid());
table->attach(*_slider, 0, 0, 1, 1);
alignment1->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment1, 1, 0, 1, 1);
table->attach(_ruler, 0, 1, 1, 1);
alignment2->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment2, 1, 1, 1, 1);
-#else
- Gtk::Table *table = Gtk::manage(new Gtk::Table());
- table->attach(*_slider, 0, 1, 0, 1);
- table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
- table->attach(_ruler, 0, 1, 1, 2);
- table->attach(*alignment2, 1, 2, 1, 2, static_cast<Gtk::AttachOptions>(0));
-#endif
pack_start(*table, Gtk::PACK_SHRINK);
}
@@ -636,11 +570,7 @@ PrefSlider::init(Glib::ustring const &prefs_path,
freeze = false;
-#if WITH_GTKMM_3_0
_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- _slider = Gtk::manage(new Gtk::HScale());
-#endif
_slider->set_range (lower, upper);
_slider->set_increments (step_increment, page_increment);
@@ -657,17 +587,11 @@ PrefSlider::init(Glib::ustring const &prefs_path,
Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
alignment1->add(_sb);
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = Gtk::manage(new Gtk::Grid());
+ auto table = Gtk::manage(new Gtk::Grid());
_slider->set_hexpand();
table->attach(*_slider, 0, 0, 1, 1);
alignment1->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment1, 1, 0, 1, 1);
-#else
- Gtk::Table *table = Gtk::manage(new Gtk::Table());
- table->attach(*_slider, 0, 1, 0, 1);
- table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
-#endif
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index 1d2d77699..142793509 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -30,12 +30,7 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
-
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/widget/color-picker.h"
#include "ui/widget/unit-menu.h"
@@ -43,11 +38,7 @@
#include "ui/widget/scalar-unit.h"
namespace Gtk {
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
namespace Inkscape {
@@ -126,10 +117,6 @@ public:
static const double textpadding;
private:
-#if !WITH_GTKMM_3_0
- bool on_expose_event(GdkEventExpose *event);
-#endif
-
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval);
@@ -155,11 +142,7 @@ private:
Inkscape::UI::Widget::SpinButton _sb;
UnitMenu _unit;
-#if WITH_GTKMM_3_0
Gtk::Scale* _slider;
-#else
- Gtk::HScale* _slider;
-#endif
ZoomCorrRuler _ruler;
bool freeze; // used to block recursive updates of slider and spinbutton
};
@@ -178,11 +161,7 @@ private:
Glib::ustring _prefs_path;
Inkscape::UI::Widget::SpinButton _sb;
-#if WITH_GTKMM_3_0
Gtk::Scale* _slider;
-#else
- Gtk::HScale* _slider;
-#endif
bool freeze; // used to block recursive updates of slider and spinbutton
};
@@ -279,11 +258,7 @@ protected:
void on_changed();
};
-#if WITH_GTKMM_3_0
class DialogPage : public Gtk::Grid
-#else
-class DialogPage : public Gtk::Table
-#endif
{
public:
DialogPage();
diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp
index b6ea16b89..ba3b025ba 100644
--- a/src/ui/widget/random.cpp
+++ b/src/ui/widget/random.cpp
@@ -47,11 +47,7 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h
index dc2b457c2..d86ab6246 100644
--- a/src/ui/widget/random.h
+++ b/src/ui/widget/random.h
@@ -75,11 +75,7 @@ public:
*/
Random(Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp
index fca8a7974..434c2c0bb 100644
--- a/src/ui/widget/scalar.cpp
+++ b/src/ui/widget/scalar.cpp
@@ -43,11 +43,7 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
@@ -141,11 +137,7 @@ void Scalar::update()
void Scalar::addSlider()
{
-#if WITH_GTKMM_3_0
- Gtk::Scale *scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment());
-#else
- Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() );
-#endif
+ auto scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment());
scale->set_draw_value(false);
add (*manage (scale));
}
diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h
index 86d7aee28..847790b96 100644
--- a/src/ui/widget/scalar.h
+++ b/src/ui/widget/scalar.h
@@ -73,11 +73,7 @@ public:
*/
Scalar(Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index 7bbfa08db..fd83a62c9 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -118,11 +118,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
current_stroke_width(0),
_desktop (NULL),
-#if WITH_GTKMM_3_0
_table(),
-#else
- _table(2, 6),
-#endif
_fill_label (_("Fill:")),
_stroke_label (_("Stroke:")),
_opacity_label (_("O:")),
@@ -134,11 +130,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_stroke_flag_place (),
_opacity_place (),
-#if WITH_GTKMM_3_0
_opacity_adjustment(Gtk::Adjustment::create(100, 0.0, 100, 1.0, 10.0)),
-#else
- _opacity_adjustment (100, 0.0, 100, 1.0, 10.0),
-#endif
_opacity_sb (0.02, 0),
_stroke (),
@@ -161,13 +153,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_opacity_label.set_alignment(0.0, 0.5);
_opacity_label.set_padding(0, 0);
-#if WITH_GTKMM_3_0
_table.set_column_spacing(2);
_table.set_row_spacing(0);
-#else
- _table.set_col_spacings (2);
- _table.set_row_spacings (0);
-#endif
for (int i = SS_FILL; i <= SS_STROKE; i++) {
@@ -374,7 +361,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1);
_opacity_sb.set_sensitive (false);
-#if WITH_GTKMM_3_0
_table.attach(_fill_label, 0, 0, 1, 1);
_table.attach(_stroke_label, 0, 1, 1, 1);
@@ -383,26 +369,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_table.attach(_fill_place, 2, 0, 1, 1);
_table.attach(_stroke, 2, 1, 1, 1);
-#else
- _table.attach(_fill_label, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK);
- _table.attach(_stroke_label, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK);
-
- _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK);
- _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK);
-
- _table.attach(_fill_place, 2,3, 0,1);
- _table.attach(_stroke, 2,3, 1,2);
-#endif
_opacity_place.add(_opacity_label);
-#if WITH_GTKMM_3_0
_table.attach(_opacity_place, 4, 0, 1, 2);
_table.attach(_opacity_sb, 5, 0, 1, 2);
-#else
- _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK);
- _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
pack_start(_table, true, true, 2);
@@ -1115,11 +1086,7 @@ SelectedStyle::update()
if (_opacity_blocked) break;
_opacity_blocked = true;
_opacity_sb.set_sensitive(true);
-#if WITH_GTKMM_3_0
_opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
-#else
- _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
-#endif
_opacity_blocked = false;
break;
}
@@ -1219,11 +1186,7 @@ void SelectedStyle::on_opacity_changed ()
_opacity_blocked = true;
SPCSSAttr *css = sp_repr_css_attr_new ();
Inkscape::CSSOStringStream os;
-#if WITH_GTKMM_3_0
os << CLAMP ((_opacity_adjustment->get_value() / 100), 0.0, 1.0);
-#else
- os << CLAMP ((_opacity_adjustment.get_value() / 100), 0.0, 1.0);
-#endif
sp_repr_css_set_property (css, "opacity", os.str().c_str());
// FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK
// sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop
@@ -1352,11 +1315,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
g_object_unref(pixbuf);
gdk_window_set_cursor(gtk_widget_get_window(w), cr);
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cr);
-#else
- gdk_cursor_unref(cr);
-#endif
cr = NULL;
cr_set = true;
}
@@ -1420,11 +1379,7 @@ RotateableSwatch::do_release(double by, guint modifier) {
GtkWidget *w = GTK_WIDGET(gobj());
gdk_window_set_cursor(gtk_widget_get_window(w), NULL);
if (cr) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cr);
-#else
- gdk_cursor_unref (cr);
-#endif
cr = NULL;
}
cr_set = false;
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index 804a6fef6..efac29f73 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -16,12 +16,7 @@
#endif
#include <gtkmm/box.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>
@@ -140,11 +135,7 @@ public:
protected:
SPDesktop *_desktop;
-#if WITH_GTKMM_3_0
Gtk::Grid _table;
-#else
- Gtk::Table _table;
-#endif
Gtk::Label _fill_label;
Gtk::Label _stroke_label;
@@ -157,11 +148,7 @@ protected:
Gtk::EventBox _stroke_flag_place;
Gtk::EventBox _opacity_place;
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment;
-#else
- Gtk::Adjustment _opacity_adjustment;
-#endif
Inkscape::UI::Widget::SpinButton _opacity_sb;
Gtk::Label _na[2];
diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp
index d6b34a5b4..f74626d9b 100644
--- a/src/ui/widget/spin-scale.cpp
+++ b/src/ui/widget/spin-scale.cpp
@@ -11,7 +11,7 @@
#include <glibmm/i18n.h>
#include <glibmm/stringutils.h>
-#include "ui/widget/gimpspinscale.h"
+#include "widgets/gimp/gimpspinscale.h"
namespace Inkscape {
namespace UI {
@@ -21,13 +21,8 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper
double /*climb_rate*/, int digits, const SPAttributeEnum a, const char* tip_text)
: AttrWidget(a, value)
{
-#if WITH_GTKMM_3_0
_adjustment = Gtk::Adjustment::create(value, lower, upper, step_inc);
_spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits);
-#else
- _adjustment = new Gtk::Adjustment(value, lower, upper, step_inc);
- _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits);
-#endif
signal_value_changed().connect(signal_attr_changed().make_slot());
@@ -41,12 +36,10 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper
}
SpinScale::SpinScale(const char* label,
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj,
-#else
- Gtk::Adjustment *adj,
-#endif
- int digits, const SPAttributeEnum a, const char* tip_text)
+ Glib::RefPtr<Gtk::Adjustment> adj,
+ int digits,
+ const SPAttributeEnum a,
+ const char* tip_text)
: AttrWidget(a, 0.0),
_adjustment(adj)
@@ -110,19 +103,12 @@ void SpinScale::set_appearance(const gchar* appearance)
gimp_spin_scale_set_appearance(_spinscale, appearance);
}
-#if WITH_GTKMM_3_0
-const Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment() const
-#else
-const Gtk::Adjustment *SpinScale::get_adjustment() const
-#endif
+const decltype(SpinScale::_adjustment) SpinScale::get_adjustment() const
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
-Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment()
-#else
-Gtk::Adjustment *SpinScale::get_adjustment()
-#endif
+
+decltype(SpinScale::_adjustment) SpinScale::get_adjustment()
{
return _adjustment;
}
diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h
index 50e4fc953..d7030bed3 100644
--- a/src/ui/widget/spin-scale.h
+++ b/src/ui/widget/spin-scale.h
@@ -36,12 +36,8 @@ public:
int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
SpinScale(const char* label,
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj,
-#else
- Gtk::Adjustment *adj,
-#endif
- int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
+ Glib::RefPtr<Gtk::Adjustment> adj,
+ int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
virtual Glib::ustring get_as_attribute() const;
virtual void set_from_attribute(SPObject*);
@@ -52,23 +48,14 @@ public:
void set_value(const double);
void set_focuswidget(GtkWidget *widget);
void set_appearance(const gchar* appearance);
-
-#if WITH_GTKMM_3_0
- const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const;
- Glib::RefPtr<Gtk::Adjustment> get_adjustment();
-#else
- const Gtk::Adjustment *get_adjustment() const;
- Gtk::Adjustment *get_adjustment();
-#endif
private:
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _adjustment;
-#else
- Gtk::Adjustment *_adjustment;
-#endif
-
GtkWidget *_spinscale;
+
+public:
+ const decltype(_adjustment) get_adjustment() const;
+ decltype(_adjustment) get_adjustment();
};
diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp
index 9b361ae78..f17b9b26c 100644
--- a/src/ui/widget/spin-slider.cpp
+++ b/src/ui/widget/spin-slider.cpp
@@ -20,11 +20,7 @@ namespace Widget {
SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc,
double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text)
: AttrWidget(a, value),
-#if WITH_GTKMM_3_0
_adjustment(Gtk::Adjustment::create(value, lower, upper, step_inc)),
-#else
- _adjustment(value, lower, upper, step_inc),
-#endif
_scale(_adjustment), _spin(_adjustment, climb_rate, digits)
{
signal_value_changed().connect(signal_attr_changed().make_slot());
@@ -43,11 +39,7 @@ SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc
Glib::ustring SpinSlider::get_as_attribute() const
{
-#if WITH_GTKMM_3_0
- const double val = _adjustment->get_value();
-#else
- const double val = _adjustment.get_value();
-#endif
+ const auto val = _adjustment->get_value();
if(_spin.get_digits() == 0)
return Glib::Ascii::dtostr((int)val);
@@ -58,77 +50,43 @@ Glib::ustring SpinSlider::get_as_attribute() const
void SpinSlider::set_from_attribute(SPObject* o)
{
const gchar* val = attribute_value(o);
-#if WITH_GTKMM_3_0
if(val)
_adjustment->set_value(Glib::Ascii::strtod(val));
else
_adjustment->set_value(get_default()->as_double());
-#else
- if(val)
- _adjustment.set_value(Glib::Ascii::strtod(val));
- else
- _adjustment.set_value(get_default()->as_double());
-#endif
}
Glib::SignalProxy0<void> SpinSlider::signal_value_changed()
{
-#if WITH_GTKMM_3_0
return _adjustment->signal_value_changed();
-#else
- return _adjustment.signal_value_changed();
-#endif
}
double SpinSlider::get_value() const
{
-#if WITH_GTKMM_3_0
return _adjustment->get_value();
-#else
- return _adjustment.get_value();
-#endif
}
void SpinSlider::set_value(const double val)
{
-#if WITH_GTKMM_3_0
_adjustment->set_value(val);
-#else
- _adjustment.set_value(val);
-#endif
}
-#if WITH_GTKMM_3_0
-const Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment() const
-#else
-const Gtk::Adjustment& SpinSlider::get_adjustment() const
-#endif
+const decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() const
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
-Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment()
-#else
-Gtk::Adjustment& SpinSlider::get_adjustment()
-#endif
+
+decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment()
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
const Gtk::Scale& SpinSlider::get_scale() const
-#else
-const Gtk::HScale& SpinSlider::get_scale() const
-#endif
{
return _scale;
}
-#if WITH_GTKMM_3_0
Gtk::Scale& SpinSlider::get_scale()
-#else
-Gtk::HScale& SpinSlider::get_scale()
-#endif
{
return _scale;
}
@@ -157,15 +115,9 @@ DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double
{
signal_value_changed().connect(signal_attr_changed().make_slot());
-#if WITH_GTKMM_3_0
_s1.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot());
_s2.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot());
_s1.get_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked));
-#else
- _s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
- _s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
- _s1.get_adjustment().signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked));
-#endif
_link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinSlider::link_toggled));
Gtk::VBox* vb = Gtk::manage(new Gtk::VBox);
@@ -202,13 +154,8 @@ void DualSpinSlider::set_from_attribute(SPObject* o)
_link.set_active(toks[1] == 0);
-#if WITH_GTKMM_3_0
_s1.get_adjustment()->set_value(v1);
_s2.get_adjustment()->set_value(v2);
-#else
- _s1.get_adjustment().set_value(v1);
- _s2.get_adjustment().set_value(v2);
-#endif
g_strfreev(toks);
}
diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h
index a5999f14f..5a29c1b67 100644
--- a/src/ui/widget/spin-slider.h
+++ b/src/ui/widget/spin-slider.h
@@ -42,17 +42,8 @@ public:
double get_value() const;
void set_value(const double);
-#if WITH_GTKMM_3_0
- const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const;
- Glib::RefPtr<Gtk::Adjustment> get_adjustment();
const Gtk::Scale& get_scale() const;
Gtk::Scale& get_scale();
-#else
- const Gtk::Adjustment& get_adjustment() const;
- Gtk::Adjustment& get_adjustment();
- const Gtk::HScale& get_scale() const;
- Gtk::HScale& get_scale();
-#endif
const Inkscape::UI::Widget::SpinButton& get_spin_button() const;
Inkscape::UI::Widget::SpinButton& get_spin_button();
@@ -60,14 +51,13 @@ public:
// Change the SpinSlider into a SpinButton with AttrWidget support)
void remove_scale();
private:
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _adjustment;
Gtk::Scale _scale;
-#else
- Gtk::Adjustment _adjustment;
- Gtk::HScale _scale;
-#endif
Inkscape::UI::Widget::SpinButton _spin;
+
+public:
+ const decltype(_adjustment) get_adjustment() const;
+ decltype(_adjustment) get_adjustment();
};
/**
diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h
index 30ffc7d77..ae571994b 100644
--- a/src/ui/widget/spinbutton.h
+++ b/src/ui/widget/spinbutton.h
@@ -36,11 +36,7 @@ public:
{
connect_signals();
};
-#if GTK_CHECK_VERSION(3,0,0)
explicit SpinButton(Glib::RefPtr<Gtk::Adjustment>& adjustment, double climb_rate = 0.0, guint digits = 0)
-#else
- explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0)
-#endif
: Gtk::SpinButton(adjustment, climb_rate, digits),
_unit_menu(NULL),
_unit_tracker(NULL),
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index 2952a3f97..f8eac1c78 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -28,11 +28,7 @@
#include "verbs.h"
#include <glibmm/i18n.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
enum {
SS_FILL,
@@ -111,11 +107,7 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_css(NULL),
_tool_obs(NULL),
_style_obs(NULL),
-#if WITH_GTKMM_3_0
_table(Gtk::manage(new Gtk::Grid())),
-#else
- _table(Gtk::manage(new Gtk::Table(2, 6))),
-#endif
_sw_unit(NULL)
{
set_name("StyleSwatch");
@@ -133,13 +125,8 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_opacity_value.set_alignment(0.0, 0.5);
_opacity_value.set_padding(0, 0);
-#if WITH_GTKMM_3_0
_table->set_column_spacing(2);
_table->set_row_spacing(0);
-#else
- _table->set_col_spacings(2);
- _table->set_row_spacings(0);
-#endif
_stroke.pack_start(_place[SS_STROKE]);
_stroke_width_place.add(_stroke_width);
@@ -147,19 +134,11 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_opacity_place.add(_opacity_value);
-#if WITH_GTKMM_3_0
_table->attach(_label[SS_FILL], 0, 0, 1, 1);
_table->attach(_label[SS_STROKE], 0, 1, 1, 1);
_table->attach(_place[SS_FILL], 1, 0, 1, 1);
_table->attach(_stroke, 1, 1, 1, 1);
_table->attach(_opacity_place, 2, 0, 1, 2);
-#else
- _table->attach(_label[SS_FILL], 0,1, 0,1, Gtk::FILL, Gtk::SHRINK);
- _table->attach(_label[SS_STROKE], 0,1, 1,2, Gtk::FILL, Gtk::SHRINK);
- _table->attach(_place[SS_FILL], 1,2, 0,1);
- _table->attach(_stroke, 1,2, 1,2);
- _table->attach(_opacity_place, 2,3, 0,2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_swatch.add(*_table);
pack_start(_swatch, true, true, 0);
diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h
index 0016e0256..81a907d16 100644
--- a/src/ui/widget/style-swatch.h
+++ b/src/ui/widget/style-swatch.h
@@ -29,11 +29,7 @@ class SPStyle;
class SPCSSAttr;
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
@@ -75,11 +71,7 @@ private:
Gtk::EventBox _swatch;
-#if WITH_GTKMM_3_0
Gtk::Grid *_table;
-#else
- Gtk::Table *_table;
-#endif
Gtk::Label _label[2];
Gtk::EventBox _place[2];
diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp
index e904666cc..dea14585d 100644
--- a/src/ui/widget/tolerance-slider.cpp
+++ b/src/ui/widget/tolerance-slider.cpp
@@ -76,12 +76,8 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la
// align the label with the checkbox text above by indenting 22 px.
_hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22);
-#if WITH_GTKMM_3_0
_hscale = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
_hscale->set_range(1.0, 51.0);
-#else
- _hscale = Gtk::manage (new Gtk::HScale (1.0, 51, 1.0));
-#endif
theLabel1->set_mnemonic_widget (*_hscale);
_hscale->set_draw_value (true);
@@ -121,11 +117,7 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la
void ToleranceSlider::setValue (double val)
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = _hscale->get_adjustment();
-#else
- Gtk::Adjustment *adj = _hscale->get_adjustment();
-#endif
+ auto adj = _hscale->get_adjustment();
adj->set_lower (1.0);
adj->set_upper (51.0);
diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h
index 7ae8e4712..3d2548ebe 100644
--- a/src/ui/widget/tolerance-slider.h
+++ b/src/ui/widget/tolerance-slider.h
@@ -14,11 +14,7 @@
namespace Gtk {
class RadioButton;
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
namespace Inkscape {
@@ -60,13 +56,7 @@ protected:
void on_toggled();
void update (double val);
Gtk::HBox *_hbox;
-
-#if WITH_GTKMM_3_0
Gtk::Scale *_hscale;
-#else
- Gtk::HScale *_hscale;
-#endif
-
Gtk::RadioButtonGroup _radio_button_group;
Gtk::RadioButton *_button1;
Gtk::RadioButton *_button2;