From a346136fcaa86c845dd9883674449eebdc39a065 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 18 May 2012 09:29:44 +0100 Subject: Gtk+ 3 fixes for button widget (bzr r11381) --- src/widgets/button.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 0071fc56e..42dac2ef3 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,9 +25,13 @@ #include "button.h" +#if !GTK_CHECK_VERSION(2,22,0) +#include "compat-key-syms.h" +#endif + static void sp_button_class_init (SPButtonClass *klass); static void sp_button_init (SPButton *button); -static void sp_button_destroy (GtkObject *object); +static void sp_button_dispose(GObject *object); static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition); @@ -76,13 +80,13 @@ GType sp_button_get_type(void) static void sp_button_class_init (SPButtonClass *klass) { - GtkObjectClass *object_class=(GtkObjectClass *)klass; + GObjectClass *object_class=(GObjectClass *)klass; GtkWidgetClass *widget_class=(GtkWidgetClass *)klass; GtkButtonClass *button_class=(GtkButtonClass *)klass; parent_class = (GtkToggleButtonClass *)g_type_class_peek_parent (klass); - object_class->destroy = sp_button_destroy; + object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_button_get_preferred_width; widget_class->get_preferred_height = sp_button_get_preferred_height; @@ -109,8 +113,7 @@ sp_button_init (SPButton *button) g_signal_connect_after (G_OBJECT (button), "event", G_CALLBACK (sp_button_process_event), NULL); } -static void -sp_button_destroy (GtkObject *object) +static void sp_button_dispose(GObject *object) { SPButton *button = SP_BUTTON (object); @@ -124,7 +127,7 @@ sp_button_destroy (GtkObject *object) button->c_set_active.~connection(); button->c_set_sensitive.~connection(); - ((GtkObjectClass *) (parent_class))->destroy (object); + ((GObjectClass *) (parent_class))->dispose(object); } static void @@ -291,7 +294,7 @@ static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { unsigned int shortcut = sp_shortcut_get_primary (action->verb); - if (shortcut != GDK_VoidSymbol) { + if (shortcut != GDK_KEY_VoidSymbol) { // there's both action and shortcut gchar *key = sp_shortcut_get_label(shortcut); -- cgit v1.2.3 From 9abd33133650d77714fccf09d0c9ff27c9b75a78 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 5 Jul 2012 22:39:08 +0100 Subject: Drop GTK+ 2.20 support. Fixed bugs: - https://launchpad.net/bugs/1020494 (bzr r11529) --- src/widgets/button.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 42dac2ef3..4b152f914 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,10 +25,6 @@ #include "button.h" -#if !GTK_CHECK_VERSION(2,22,0) -#include "compat-key-syms.h" -#endif - static void sp_button_class_init (SPButtonClass *klass); static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); -- cgit v1.2.3 From 1c78495f3dd05febf84085cb665fc83d338ec2c3 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 23 Jul 2012 17:19:50 +0100 Subject: Drop use of size-request in button and sp-widget (GTK3) (bzr r11564) --- src/widgets/button.cpp | 61 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 4b152f914..45356601b 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -29,8 +29,6 @@ static void sp_button_class_init (SPButtonClass *klass); static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); -static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition); - #if GTK_CHECK_VERSION(3,0,0) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, @@ -39,6 +37,8 @@ static void sp_button_get_preferred_width(GtkWidget *widget, static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); +#else +static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition); #endif static void sp_button_clicked (GtkButton *button); @@ -126,13 +126,47 @@ static void sp_button_dispose(GObject *object) ((GObjectClass *) (parent_class))->dispose(object); } -static void -sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition) + + +#if GTK_CHECK_VERSION(3,0,0) +static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { - GtkWidget *child; + GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); + } else { + *minimal_width = 0; + *natural_width = 0; + } + + *minimal_width += 2 + 2 * MAX(2, style->xthickness); + *natural_width += 2 + 2 * MAX(2, style->xthickness); +} + +static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) +{ + GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); + } else { + *minimal_height = 0; + *natural_height = 0; + } + + *minimal_height += 2 + 2 * MAX(2, style->ythickness); + *natural_height += 2 + 2 * MAX(2, style->ythickness); + +} +#else +static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) +{ + GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); GtkStyle *style = gtk_widget_get_style (widget); - child = gtk_bin_get_child (GTK_BIN (widget)); if (child) { gtk_widget_size_request (GTK_WIDGET (child), requisition); } else { @@ -143,21 +177,6 @@ sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition) requisition->width += 2 + 2 * MAX (2, style->xthickness); requisition->height += 2 + 2 * MAX (2, style->ythickness); } - -#if GTK_CHECK_VERSION(3,0,0) -static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) -{ - GtkRequisition requisition; - sp_button_size_request(widget, &requisition); - *minimal_width = *natural_width = requisition.width; -} - -static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) -{ - GtkRequisition requisition; - sp_button_size_request(widget, &requisition); - *minimal_height = *natural_height = requisition.height; -} #endif static void -- cgit v1.2.3 From 5da5121b9afaa8b2d1f0308dffc7d1e1b225b142 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 12:46:25 +0000 Subject: Replace remaining C-style pointer casts for src/widgets (bzr r11868) --- src/widgets/button.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 45356601b..1ac083276 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -218,9 +218,7 @@ sp_button_perform_action (SPButton *button, gpointer /*data*/) GtkWidget * sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action ) { - SPButton *button; - - button = (SPButton *)g_object_new (SP_TYPE_BUTTON, NULL); + SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); button->type = type; button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); -- cgit v1.2.3 From 8ee9827502fadcae0b02fec434799e94ee115357 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 25 Dec 2012 22:50:08 +0000 Subject: Convert a load more C-style pointer casts to GObject or C++ casts (merry christmas\!) (bzr r11986) --- src/widgets/button.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 1ac083276..d7be6c9f0 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -76,11 +76,11 @@ GType sp_button_get_type(void) static void sp_button_class_init (SPButtonClass *klass) { - GObjectClass *object_class=(GObjectClass *)klass; - GtkWidgetClass *widget_class=(GtkWidgetClass *)klass; - GtkButtonClass *button_class=(GtkButtonClass *)klass; + GObjectClass *object_class=G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); + GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - parent_class = (GtkToggleButtonClass *)g_type_class_peek_parent (klass); + parent_class = GTK_TOGGLE_BUTTON_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) @@ -123,7 +123,7 @@ static void sp_button_dispose(GObject *object) button->c_set_active.~connection(); button->c_set_sensitive.~connection(); - ((GObjectClass *) (parent_class))->dispose(object); + (G_OBJECT_CLASS(parent_class))->dispose(object); } @@ -185,7 +185,7 @@ sp_button_clicked (GtkButton *button) SPButton *sp_button=SP_BUTTON (button); if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - ((GtkButtonClass *) (parent_class))->clicked (button); + (GTK_BUTTON_CLASS(parent_class))->clicked (button); } } @@ -230,7 +230,7 @@ sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPA // The Inkscape style is no-relief buttons gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - return (GtkWidget *) button; + return GTK_WIDGET(button); } void @@ -287,7 +287,7 @@ sp_button_set_action (SPButton *button, SPAction *action) } } - sp_button_set_composed_tooltip ((GtkWidget *) button, action); + sp_button_set_composed_tooltip(GTK_WIDGET(button), action); } static void -- cgit v1.2.3 From 1615436543169f305d1df4d830ed8f5ec5dc75ed Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 19:33:04 +0000 Subject: More GObject boilerplate reduction (bzr r12065) --- src/widgets/button.cpp | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index d7be6c9f0..467f0d70e 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,8 +25,6 @@ #include "button.h" -static void sp_button_class_init (SPButtonClass *klass); -static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); #if GTK_CHECK_VERSION(3,0,0) @@ -50,28 +48,7 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action static void sp_button_action_set_active (SPButton *button, bool active); static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); -static GtkToggleButtonClass *parent_class; - -GType sp_button_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPButtonClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_button_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPButton), - 0, // n_preallocs - (GInstanceInitFunc)sp_button_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TOGGLE_BUTTON, "SPButton", &info, static_cast(0)); - } - return type; -} +G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); static void sp_button_class_init (SPButtonClass *klass) @@ -80,8 +57,6 @@ sp_button_class_init (SPButtonClass *klass) GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - parent_class = GTK_TOGGLE_BUTTON_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_button_get_preferred_width; @@ -120,10 +95,10 @@ static void sp_button_dispose(GObject *object) sp_button_set_doubleclick_action (button, NULL); } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } @@ -185,7 +160,7 @@ sp_button_clicked (GtkButton *button) SPButton *sp_button=SP_BUTTON (button); if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(parent_class))->clicked (button); + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); } } @@ -340,3 +315,13 @@ sp_button_new_from_data( Inkscape::IconSize size, return button; } +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: Factored layer model out into new Inkscape::LayerModel class. This allows Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1) --- src/widgets/button.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 467f0d70e..a1bd9b792 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -20,6 +20,7 @@ #include "icon.h" #include "shortcuts.h" #include "interface.h" +#include "helper/action-context.h" #include @@ -309,7 +310,7 @@ sp_button_new_from_data( Inkscape::IconSize size, const gchar *tip ) { GtkWidget *button; - SPAction *action=sp_action_new(view, name, name, tip, name, 0); + SPAction *action=sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); button = sp_button_new (size, type, action, NULL); g_object_unref(action); return button; -- cgit v1.2.3