summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-12-25 23:46:18 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-12-25 23:46:18 +0000
commit60efec48f2861fba5e02ca4fff61bfdcef33f56f (patch)
tree2dbcec0c9c8d1453c422c10a53d691203f18e965 /src/widgets
parentFix start anchors (diff)
parentMerge about-box Gtkmm changes (diff)
downloadinkscape-60efec48f2861fba5e02ca4fff61bfdcef33f56f.tar.gz
inkscape-60efec48f2861fba5e02ca4fff61bfdcef33f56f.zip
Merge branch 'master' into powerpencilII
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/ege-adjustment-action.cpp10
-rw-r--r--src/widgets/gimp/CMakeLists.txt2
-rw-r--r--src/widgets/gimp/gimpspinscale.c969
-rw-r--r--src/widgets/gimp/gimpspinscale.h82
-rw-r--r--src/widgets/sp-attribute-widget.cpp4
-rw-r--r--src/widgets/spray-toolbar.cpp93
-rw-r--r--src/widgets/toolbox.h2
7 files changed, 55 insertions, 1107 deletions
diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp
index 3d46fd81d..0f0d205e2 100644
--- a/src/widgets/ege-adjustment-action.cpp
+++ b/src/widgets/ege-adjustment-action.cpp
@@ -46,12 +46,12 @@
#include <gtkmm/container.h>
#include <gtkmm/radiomenuitem.h>
+#include <gtkmm/adjustment.h>
#include <gdk/gdkkeysyms.h>
#include "widgets/ege-adjustment-action.h"
-#include "gimp/gimpspinscale.h"
#include "ui/icon-names.h"
-
+#include "ui/widget/ink-spinscale.h"
static void ege_adjustment_action_finalize( GObject* object );
static void ege_adjustment_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
@@ -820,7 +820,11 @@ static GtkWidget* create_tool_item( GtkAction* action )
if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
/* Slider */
- spinbutton = gimp_spin_scale_new (act->private_data->adj, g_value_get_string( &value ), 0);
+ InkSpinScale* inkspinscale =
+ new InkSpinScale(Glib::wrap(act->private_data->adj));
+ inkspinscale->set_label( g_value_get_string( &value ));
+ inkspinscale->set_digits(0);
+ spinbutton = (GtkWidget*)inkspinscale->gobj();
gtk_widget_set_size_request(spinbutton, 100, -1);
} else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) {
diff --git a/src/widgets/gimp/CMakeLists.txt b/src/widgets/gimp/CMakeLists.txt
index 7b3e834e3..aa886cc67 100644
--- a/src/widgets/gimp/CMakeLists.txt
+++ b/src/widgets/gimp/CMakeLists.txt
@@ -1,12 +1,10 @@
set(gimpwidgets_SRC
gimpcolorwheel.c
- gimpspinscale.c
ruler.cpp
# -------
# Headers
gimpcolorwheel.h
- gimpspinscale.h
ruler.h
)
diff --git a/src/widgets/gimp/gimpspinscale.c b/src/widgets/gimp/gimpspinscale.c
deleted file mode 100644
index 8d8c6c935..000000000
--- a/src/widgets/gimp/gimpspinscale.c
+++ /dev/null
@@ -1,969 +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,
- TARGET_NONE
-} SpinScaleTarget;
-
-typedef enum
-{
- APPEARANCE_FULL = 1, /* Full size suitable for tablets */
- APPEARANCE_COMPACT, /* Compact, suitable for desktops with mouse control */
-} SpinScaleAppearance;
-
-typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate;
-
-struct _GimpSpinScalePrivate
-{
- gchar *label;
-
- gboolean scale_limits_set;
- gdouble scale_lower;
- gdouble scale_upper;
- gdouble gamma;
-
- PangoLayout *layout;
- gboolean changing_value;
- gboolean relative_change;
- gdouble start_x;
- gdouble start_value;
-
- GtkWidget* focusWidget;
- gboolean transferFocus;
- SpinScaleAppearance appearanceMode;
-};
-
-#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- GIMP_TYPE_SPIN_SCALE, \
- GimpSpinScalePrivate))
-
-
-static void gimp_spin_scale_dispose (GObject *object);
-static void gimp_spin_scale_finalize (GObject *object);
-static void gimp_spin_scale_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_spin_scale_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gimp_spin_scale_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-
-static void gimp_spin_scale_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static void gimp_spin_scale_get_preferred_height (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static gboolean gimp_spin_scale_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static gboolean gimp_spin_scale_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_spin_scale_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_spin_scale_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static gboolean gimp_spin_scale_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event);
-static gboolean gimp_spin_scale_keypress( GtkWidget *widget,
- GdkEventKey *event);
-
-static void gimp_spin_scale_defocus( GtkSpinButton *spin_button );
-
-static void gimp_spin_scale_value_changed (GtkSpinButton *spin_button);
-
-
-G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GTK_TYPE_SPIN_BUTTON);
-
-#define parent_class gimp_spin_scale_parent_class
-
-
-static void
-gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass);
-
- object_class->dispose = gimp_spin_scale_dispose;
- object_class->finalize = gimp_spin_scale_finalize;
- object_class->set_property = gimp_spin_scale_set_property;
- object_class->get_property = gimp_spin_scale_get_property;
-
- widget_class->style_set = gimp_spin_scale_style_set;
- widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width;
- widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height;
- widget_class->draw = gimp_spin_scale_draw;
- widget_class->button_press_event = gimp_spin_scale_button_press;
- widget_class->button_release_event = gimp_spin_scale_button_release;
- widget_class->motion_notify_event = gimp_spin_scale_motion_notify;
- widget_class->leave_notify_event = gimp_spin_scale_leave_notify;
- widget_class->key_press_event = gimp_spin_scale_keypress;
-
- spin_button_class->value_changed = gimp_spin_scale_value_changed;
-
- g_object_class_install_property (object_class, PROP_LABEL,
- g_param_spec_string ("label", NULL, NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (klass, sizeof (GimpSpinScalePrivate));
-}
-
-static void
-gimp_spin_scale_init (GimpSpinScale *scale)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- gtk_widget_add_events (GTK_WIDGET (scale),
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_LEAVE_NOTIFY_MASK);
-
- gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE);
-
- private->gamma = 1.0;
- private->focusWidget = NULL;
- private->transferFocus = FALSE;
- private->appearanceMode = APPEARANCE_COMPACT;
-}
-
-static void
-gimp_spin_scale_dispose (GObject *object)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-gimp_spin_scale_finalize (GObject *object)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
-
- if (private->label)
- {
- g_free (private->label);
- private->label = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gimp_spin_scale_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
- GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
-
- switch (property_id)
- {
- case PROP_LABEL:
- gimp_spin_scale_set_label (scale, g_value_get_string (value));
- break;
-
- case PROP_FOCUS_WIDGET:
- {
- /* TODO unhook prior */
- private->focusWidget = GTK_WIDGET (g_value_get_pointer (value));
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gimp_spin_scale_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
- GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
-
- switch (property_id)
- {
- case PROP_LABEL:
- g_value_set_string (value, gimp_spin_scale_get_label (scale));
- break;
-
- case PROP_FOCUS_WIDGET:
- g_value_set_pointer (value, private->focusWidget);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-void
-gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget )
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- /* TODO unhook prior */
-
- private->focusWidget = widget;
-}
-
-void
-gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- if ( strcmp("full", appearance) == 0 ) {
- private->appearanceMode = APPEARANCE_FULL;
- } else if ( strcmp("compact", appearance) == 0 ) {
- private->appearanceMode = APPEARANCE_COMPACT;
- }
-}
-
-static void
-gimp_spin_scale_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
- minimum_width,
- natural_width);
-
- metrics = pango_context_get_metrics (context,
- pango_context_get_font_description (context),
- pango_context_get_language (context));
-
- if (private->label)
- {
- gint char_width;
- gint digit_width;
- gint char_pixels;
-
- char_width = pango_font_metrics_get_approximate_char_width (metrics);
- digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
- char_pixels = PANGO_PIXELS (MAX (char_width, digit_width));
-
- /* ~3 chars for the ellipse */
- *minimum_width += char_pixels * 3;
- *natural_width += char_pixels * 3;
- }
-
- pango_font_metrics_unref (metrics);
-}
-
-static void
-gimp_spin_scale_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
- //gint height;
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget,
- minimum_height,
- natural_height);
-
- metrics = pango_context_get_metrics (context,
- pango_context_get_font_description (context),
- pango_context_get_language (context));
-
- //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- // pango_font_metrics_get_descent (metrics));
-
- *minimum_height += 1;
- *natural_height += 1;
-
- pango_font_metrics_unref (metrics);
-}
-
-static void
-gimp_spin_scale_style_set (GtkWidget *widget,
- GtkStyle *prev_style)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-}
-
-
-static gboolean
- gimp_spin_scale_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- GtkStyleContext *style = gtk_widget_get_style_context(widget);
- GtkAllocation allocation;
- GdkRGBA color;
-
- cairo_save (cr);
- GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- cairo_restore (cr);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- cairo_set_line_width (cr, 1.0);
-
- if (private->label)
- {
- GdkRectangle text_area;
- gint minimum_width;
- gint natural_width;
- PangoRectangle logical;
- gint layout_offset_x;
- gint layout_offset_y;
- GtkStateFlags state;
- GdkRGBA text_color;
- GdkRGBA bar_text_color;
- gdouble progress_fraction;
- gint progress_x;
- gint progress_y;
- gint progress_width;
- gint progress_height;
-
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
- &minimum_width,
- &natural_width);
-
- if (! private->layout)
- {
- private->layout = gtk_widget_create_pango_layout (widget,
- private->label);
- pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END);
- }
-
- pango_layout_set_width (private->layout,
- PANGO_SCALE *
- (allocation.width - minimum_width));
- pango_layout_get_pixel_extents (private->layout, NULL, &logical);
-
- gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- layout_offset_x = text_area.x + text_area.width - logical.width - 4;
- else
- layout_offset_x = 4;
-
- layout_offset_x -= logical.x;
-
- state = gtk_widget_get_state_flags (widget);
-
- gtk_style_context_get_color (style, state, &text_color);
-
- gtk_style_context_save (style);
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR);
- gtk_style_context_get_color (style, state, &bar_text_color);
- gtk_style_context_restore (style);
-
- progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget));
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- {
- progress_fraction = 1.0 - progress_fraction;
-
- progress_x = text_area.width * progress_fraction;
- progress_y = 0;
- progress_width = text_area.width - progress_x;
- progress_height = text_area.height;
- }
- else
- {
- progress_x = 0;
- progress_y = 0;
- progress_width = text_area.width * progress_fraction;
- progress_height = text_area.height;
- }
-
- cairo_save (cr);
-
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_rectangle (cr, 0, 0, text_area.width, text_area.height);
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &text_color);
- pango_cairo_show_layout (cr, private->layout);
- cairo_restore (cr);
-
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
-
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &bar_text_color);
- pango_cairo_show_layout (cr, private->layout);
- }
-
- return FALSE;
-}
-
-/* Returns TRUE if a translation should be done */
-static gboolean
-gtk_widget_get_translation_to_window (GtkWidget *widget,
- GdkWindow *window,
- int *x,
- int *y)
-{
- GdkWindow *w, *widget_window;
-
- if (!gtk_widget_get_has_window (widget))
- {
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- *x = -allocation.x;
- *y = -allocation.y;
- }
- else
- {
- *x = 0;
- *y = 0;
- }
-
- widget_window = gtk_widget_get_window (widget);
-
- for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
- {
- int wx, wy;
- gdk_window_get_position (w, &wx, &wy);
- *x += wx;
- *y += wy;
- }
-
- if (w == NULL)
- {
- *x = 0;
- *y = 0;
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-gimp_spin_scale_event_to_widget_coords (GtkWidget *widget,
- GdkWindow *window,
- gdouble event_x,
- gdouble event_y,
- gint *widget_x,
- gint *widget_y)
-{
- gint tx, ty;
-
- if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty))
- {
- event_x += tx;
- event_y += ty;
- }
-
- *widget_x = event_x;
- *widget_y = event_y;
-}
-
-static SpinScaleTarget
-gimp_spin_scale_get_target (GtkWidget *widget,
- gdouble x,
- gdouble y)
-{
- GtkAllocation allocation;
- PangoRectangle logical;
- gint layout_x;
- gint layout_y;
-
- gtk_widget_get_allocation (widget, &allocation);
- gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y);
- pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)),
- NULL, &logical);
-
- GdkRectangle text_area;
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- if (x >= text_area.x && x < text_area.width &&
- y >= text_area.y && y < text_area.height)
- {
- x -= text_area.x;
- y -= text_area.y;
-
- if (x > layout_x && x < layout_x + logical.width &&
- y > layout_y && y < layout_y + logical.height)
- {
- return TARGET_NUMBER;
- }
- else if (y > text_area.height / 2)
- {
- return TARGET_LOWER;
- }
-
- return TARGET_UPPER;
- }
-
- return TARGET_NONE;
-}
-
-static void
-gimp_spin_scale_get_limits (GimpSpinScale *scale,
- gdouble *lower,
- gdouble *upper)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- if (private->scale_limits_set)
- {
- *lower = private->scale_lower;
- *upper = private->scale_upper;
- }
- else
- {
- GtkSpinButton *spin_button = GTK_SPIN_BUTTON (scale);
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
-
- *lower = gtk_adjustment_get_lower (adjustment);
- *upper = gtk_adjustment_get_upper (adjustment);
- }
-}
-
-static void
-gimp_spin_scale_change_value (GtkWidget *widget,
- gdouble x)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
- gdouble lower;
- gdouble upper;
- gdouble value;
- GdkRectangle text_area;
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- x = text_area.width - x;
-
- if (private->relative_change)
- {
- gdouble diff;
- gdouble step;
-
- step = (upper - lower) / text_area.width / 10.0;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- diff = x - (text_area.width - private->start_x);
- else
- diff = x - private->start_x;
-
- value = (private->start_value + diff * step);
- }
- else
- {
- gdouble fraction;
-
- fraction = x / (gdouble) text_area.width;
- if (fraction > 0.0)
- fraction = pow (fraction, private->gamma);
-
- value = fraction * (upper - lower) + lower;
- }
-
- gtk_adjustment_set_value (adjustment, value);
-}
-
-static gboolean
-gimp_spin_scale_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- private->changing_value = FALSE;
- private->relative_change = FALSE;
-
- gint x, y;
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
- switch (gimp_spin_scale_get_target (widget, x, y))
- {
- case TARGET_UPPER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- gimp_spin_scale_change_value (widget, x);
-
- return TRUE;
-
- case TARGET_LOWER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- private->relative_change = TRUE;
- private->start_x = x;
- private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
-
- return TRUE;
-
- default:
- break;
- }
-
- return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
-}
-
-static gboolean
-gimp_spin_scale_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-
- if (private->changing_value)
- {
- private->changing_value = FALSE;
- gimp_spin_scale_change_value (widget, x);
- return TRUE;
- }
-
- return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
-}
-
-static gboolean
-gimp_spin_scale_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- gdk_event_request_motions (event);
-
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-
- if (private->changing_value)
- {
- gimp_spin_scale_change_value (widget, x);
-
- return TRUE;
- }
-
- GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
-
- if (! (event->state &
- (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))
- )
- {
- GdkDisplay *display = gtk_widget_get_display (widget);
- GdkCursor *cursor = NULL;
-
- switch (gimp_spin_scale_get_target (widget, x, y))
- {
- case TARGET_NUMBER:
- cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
- break;
-
- case TARGET_UPPER:
- cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW);
- break;
-
- case TARGET_LOWER:
- cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW);
- break;
-
- default:
- break;
- }
-
- if (cursor)
- {
- gdk_window_set_cursor (event->window, cursor);
- g_object_unref (cursor);
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-gimp_spin_scale_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event)
-{
- gdk_window_set_cursor (event->window, NULL);
-
- return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
-}
-
-gboolean gimp_spin_scale_keypress( GtkWidget *widget, GdkEventKey *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- guint key = 0;
- gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display( gdk_display_get_default() ),
- event->hardware_keycode, (GdkModifierType)event->state,
- 0, &key, 0, 0, 0 );
-
- switch ( key ) {
-
- case GDK_KEY_Escape:
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- {
- private->transferFocus = TRUE;
- gimp_spin_scale_defocus( GTK_SPIN_BUTTON(widget) );
- }
- break;
-
- }
-
- return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
-}
-
-static void
-gimp_spin_scale_defocus( GtkSpinButton *spin_button )
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
-
- if ( private->transferFocus ) {
- if ( private->focusWidget ) {
- gtk_widget_grab_focus( private->focusWidget );
- }
- }
-}
-
-static void
-gimp_spin_scale_value_changed (GtkSpinButton *spin_button)
-{
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
- GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
- gdouble lower;
- gdouble upper;
- gdouble value;
-
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper);
-
- value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper);
-
- gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button),
- pow ((value - lower) / (upper - lower),
- 1.0 / private->gamma));
-
- // TODO - Allow scrollwheel to change value then return focus,
- // but clicks/keypress should keep focus in the control
- //if ( gtk_widget_has_focus( GTK_WIDGET(spin_button) ) ) {
- // gimp_spin_scale_defocus( spin_button );
- //}
-}
-
-
-/* public functions */
-
-GtkWidget *
-gimp_spin_scale_new (GtkAdjustment *adjustment,
- const gchar *label,
- gint digits)
-{
- g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
-
- return g_object_new (GIMP_TYPE_SPIN_SCALE,
- "adjustment", adjustment,
- "label", label,
- "digits", digits,
- NULL);
-}
-
-void
-gimp_spin_scale_set_label (GimpSpinScale *scale,
- const gchar *label)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- if (label == private->label)
- return;
-
- g_free (private->label);
- private->label = g_strdup (label);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-
- gtk_widget_queue_resize (GTK_WIDGET (scale));
-
- g_object_notify (G_OBJECT (scale), "label");
-}
-
-const gchar *
-gimp_spin_scale_get_label (GimpSpinScale *scale)
-{
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL);
-
- return GET_PRIVATE (scale)->label;
-}
-
-void
-gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
- gdouble lower,
- gdouble upper)
-{
- GimpSpinScalePrivate *private;
- GtkSpinButton *spin_button;
- GtkAdjustment *adjustment;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
- spin_button = GTK_SPIN_BUTTON (scale);
- adjustment = gtk_spin_button_get_adjustment (spin_button);
-
- g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment));
- g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment));
-
- private->scale_limits_set = TRUE;
- private->scale_lower = lower;
- private->scale_upper = upper;
- private->gamma = 1.0;
-
- gimp_spin_scale_value_changed (spin_button);
-}
-
-void
-gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- private->scale_limits_set = FALSE;
- private->scale_lower = 0.0;
- private->scale_upper = 0.0;
-
- gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
-}
-
-gboolean
-gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
- gdouble *lower,
- gdouble *upper)
-{
- GimpSpinScalePrivate *private;
-
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE);
-
- private = GET_PRIVATE (scale);
-
- if (lower)
- *lower = private->scale_lower;
-
- if (upper)
- *upper = private->scale_upper;
-
- return private->scale_limits_set;
-}
-
-void
-gimp_spin_scale_set_gamma (GimpSpinScale *scale,
- gdouble gamma)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- private->gamma = gamma;
-
- gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
-}
-
-gdouble
-gimp_spin_scale_get_gamma (GimpSpinScale *scale)
-{
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
-
- return GET_PRIVATE(scale)->gamma;
-}
diff --git a/src/widgets/gimp/gimpspinscale.h b/src/widgets/gimp/gimpspinscale.h
deleted file mode 100644
index b42a0faf8..000000000
--- a/src/widgets/gimp/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/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp
index 89ce191ee..6116d3be5 100644
--- a/src/widgets/sp-attribute-widget.cpp
+++ b/src/widgets/sp-attribute-widget.cpp
@@ -160,7 +160,7 @@ void SPAttributeTable::set_object(SPObject *object,
ll->set_halign(Gtk::ALIGN_END);
ll->set_valign(Gtk::ALIGN_CENTER);
ll->set_vexpand();
-#if WITH_GTKMM_3_12
+#if GTKMM_CHECK_VERSION(3,12,0)
ll->set_margin_start(XPAD);
ll->set_margin_end(XPAD);
#else
@@ -177,7 +177,7 @@ void SPAttributeTable::set_object(SPObject *object,
ee->set_text (val ? val : (const gchar *) "");
ee->set_hexpand();
ee->set_vexpand();
-#if WITH_GTKMM_3_12
+#if GTKMM_CHECK_VERSION(3,12,0)
ee->set_margin_start(XPAD);
ee->set_margin_end(XPAD);
#else
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 2a56d81cb..140c60ef6 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -35,13 +35,13 @@
#include "desktop.h"
#include "inkscape.h"
#include "widgets/ege-adjustment-action.h"
-#include "widgets/ege-select-one-action.h"
#include "ink-radio-action.h"
#include "ink-toggle-action.h"
#include "toolbox.h"
#include "ui/dialog/clonetiler.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/panel-dialog.h"
+#include "ui/widget/ink-select-one-action.h"
#include "ui/icon-names.h"
#include <glibmm/i18n.h>
@@ -101,6 +101,7 @@ static void sp_stb_update_widgets( GObject *tbl )
static void sp_spray_init( GObject *tbl){
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int mode = prefs->getInt("/tools/spray/mode", 0);
+
bool show = true;
if(mode == 3 || mode == 2){
show = false;
@@ -161,9 +162,8 @@ static void sp_spray_standard_deviation_value_changed( GtkAdjustment *adj, GObje
gtk_adjustment_get_value(adj));
}
-static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject * tbl )
+static void sp_spray_mode_changed( GObject * tbl, int mode )
{
- int mode = ege_select_one_action_get_active( act );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/spray/mode", mode);
sp_spray_init(tbl);
@@ -352,56 +352,53 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
/* Mode */
{
- GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
-
- GtkTreeIter iter;
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Spray with copies"),
- 1, _("Spray copies of the initial selection"),
- 2, INKSCAPE_ICON("spray-mode-copy"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Spray with clones"),
- 1, _("Spray clones of the initial selection"),
- 2, INKSCAPE_ICON("spray-mode-clone"),
- -1 );
-
+ InkSelectOneActionColumns columns;
+
+ Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+
+ Gtk::TreeModel::Row row;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Spray with copies");
+ row[columns.col_tooltip ] = _("Spray copies of the initial selection");
+ row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-copy");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Spray with clones");
+ row[columns.col_tooltip ] = _("Spray clones of the initial selection");
+ row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-clone");
+ row[columns.col_sensitive] = true;
+
#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Spray single path"),
- 1, _("Spray objects in a single path"),
- 2, INKSCAPE_ICON("spray-mode-union"),
- -1 );
+ row = *(store->append());
+ row[columns.col_label ] = _("Spray single path");
+ row[columns.col_tooltip ] = _("Spray objects in a single path");
+ row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-union");
+ row[columns.col_sensitive] = true;
#endif
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Delete sprayed items"),
- 1, _("Delete sprayed items from selection"),
- 2, INKSCAPE_ICON("draw-eraser"),
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) );
- g_object_set( act, "short_label", _("Mode:"), NULL );
- gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
- g_object_set_data( holder, "mode_action", act );
-
- ege_select_one_action_set_appearance( act, "full" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
- ege_select_one_action_set_icon_column( act, 2 );
- ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
+ row = *(store->append());
+ row[columns.col_label ] = _("Delete sprayed items");
+ row[columns.col_tooltip ] = _("Delete sprayed items from selection");
+ row[columns.col_icon ] = INKSCAPE_ICON("draw-eraser");
+ row[columns.col_sensitive] = true;
+
+ InkSelectOneAction* act =
+ InkSelectOneAction::create( "SprayModeAction", // Name
+ _("Mode"), // Label
+ _(""), // Tooltip
+ "Not Used", // Icon
+ store ); // Tree store
+
+ act->use_radio( true );
+ act->use_group_label( true );
gint mode = prefs->getInt("/tools/spray/mode", 1);
- ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_spray_mode_changed), holder );
+ act->set_active( mode );
+
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() ));
- g_object_set_data( G_OBJECT(holder), "spray_tool_mode", act);
+ act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_spray_mode_changed), holder));
}
{ /* Population */
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index afa382e5b..ab1dcdfbd 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -17,7 +17,7 @@
#include "preferences.h"
-#define TOOLBAR_SLIDER_HINT "full"
+#define TOOLBAR_SLIDER_HINT "compact"
typedef struct _EgeAdjustmentAction EgeAdjustmentAction;