diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-08-28 19:18:21 +0000 |
|---|---|---|
| committer | Krzysztof Kosinski <tweenk.pl@gmail.com> | 2011-08-28 19:18:21 +0000 |
| commit | be7df18d6aef42dd657426b6a9d30834e5f54ca6 (patch) | |
| tree | 9bc96a469b9cf6595004d1733d1b7104eb764092 /src/widgets | |
| parent | Remove last forward declaration of NRPixBlock (diff) | |
| download | inkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.tar.gz inkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.zip | |
Remove nr-object.h and nr-macros.h
(bzr r10582.1.10)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/button.cpp | 62 | ||||
| -rw-r--r-- | src/widgets/button.h | 5 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 26 |
3 files changed, 35 insertions, 58 deletions
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index e0b3a0fb9..1360e0a30 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -43,20 +43,10 @@ static gint sp_button_process_event (SPButton *button, GdkEvent *event); static void sp_button_set_action (SPButton *button, SPAction *action); static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action); -static void sp_button_action_set_active (SPAction *action, unsigned int active, void *data); -static void sp_button_action_set_sensitive (SPAction *action, unsigned int sensitive, void *data); -static void sp_button_action_set_shortcut (SPAction *action, unsigned int shortcut, void *data); +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; -SPActionEventVector button_event_vector = { - {NULL}, - NULL, - sp_button_action_set_active, - sp_button_action_set_sensitive, - sp_button_action_set_shortcut, - NULL -}; GType sp_button_get_type(void) { @@ -98,6 +88,8 @@ sp_button_init (SPButton *button) { button->action = NULL; button->doubleclick_action = NULL; + new (&button->c_set_active) sigc::connection(); + new (&button->c_set_sensitive) sigc::connection(); gtk_container_set_border_width (GTK_CONTAINER (button), 0); @@ -111,18 +103,18 @@ sp_button_init (SPButton *button) static void sp_button_destroy (GtkObject *object) { - SPButton *button; - - button = SP_BUTTON (object); + SPButton *button = SP_BUTTON (object); if (button->action) { sp_button_set_action (button, NULL); } - if (button->doubleclick_action) { sp_button_set_doubleclick_action (button, NULL); } + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); + ((GtkObjectClass *) (parent_class))->destroy (object); } @@ -212,12 +204,13 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action) { if (button->doubleclick_action) { - nr_object_unref ((NRObject *) button->doubleclick_action); + g_object_unref (button->doubleclick_action); } button->doubleclick_action = action; if (action) { - button->doubleclick_action = (SPAction *) nr_object_ref ((NRObject *) action); + g_object_ref(action); } + } static void @@ -226,17 +219,25 @@ sp_button_set_action (SPButton *button, SPAction *action) GtkWidget *child; if (button->action) { - nr_active_object_remove_listener_by_data ((NRActiveObject *) button->action, button); - nr_object_unref ((NRObject *) button->action); + button->c_set_active.disconnect(); + button->c_set_sensitive.disconnect(); child = gtk_bin_get_child (GTK_BIN (button)); if (child) { gtk_container_remove (GTK_CONTAINER (button), child); } + g_object_unref(button->action); } button->action = action; if (action) { - button->action = (SPAction *) nr_object_ref ((NRObject *) action); - nr_active_object_add_listener ((NRActiveObject *) action, (NRObjectEventVector *) &button_event_vector, sizeof (SPActionEventVector), button); + g_object_ref(action); + button->c_set_active = action->signal_set_active.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_button_action_set_active), + SP_BUTTON(button))); + button->c_set_sensitive = action->signal_set_sensitive.connect( + sigc::bind<0>( + sigc::ptr_fun(>k_widget_set_sensitive), + GTK_WIDGET(button))); if (action->image) { child = sp_icon_new (button->lsize, action->image); gtk_widget_show (child); @@ -248,10 +249,8 @@ sp_button_set_action (SPButton *button, SPAction *action) } static void -sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *data) +sp_button_action_set_active (SPButton *button, bool active) { - SPButton *button; - button = (SPButton *) data; if (button->type != SP_BUTTON_TYPE_TOGGLE) { return; } @@ -262,19 +261,6 @@ sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *da } } -static void -sp_button_action_set_sensitive (SPAction */*action*/, unsigned int sensitive, void *data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), sensitive); -} - -static void -sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void *data) -{ - SPButton *button=SP_BUTTON (data); - sp_button_set_composed_tooltip (GTK_WIDGET (button), action); -} - static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { @@ -308,7 +294,7 @@ sp_button_new_from_data( Inkscape::IconSize size, GtkWidget *button; SPAction *action=sp_action_new(view, name, name, tip, name, 0); button = sp_button_new (size, type, action, NULL); - nr_object_unref ((NRObject *) action); + g_object_unref(action); return button; } diff --git a/src/widgets/button.h b/src/widgets/button.h index 759096443..41863357d 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -17,7 +17,7 @@ #define SP_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_BUTTON)) #include <gtk/gtk.h> - +#include <sigc++/sigc++.h> #include "helper/action.h" #include "icon-size.h" @@ -38,6 +38,9 @@ struct SPButton { unsigned int psize; SPAction *action; SPAction *doubleclick_action; + + sigc::connection c_set_active; + sigc::connection c_set_sensitive; }; struct SPButtonClass { diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 61c7c8e88..7edc24420 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -863,23 +863,6 @@ static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data ) } } -static void sp_action_action_set_sensitive(SPAction * /*action*/, unsigned int sensitive, void *data) -{ - if ( data ) { - GtkAction* act = GTK_ACTION(data); - gtk_action_set_sensitive( act, sensitive ); - } -} - -static SPActionEventVector action_event_vector = { - {NULL}, - NULL, - NULL, - sp_action_action_set_sensitive, - NULL, - NULL -}; - static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size ) { GtkAction* act = 0; @@ -891,8 +874,13 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction ); - SPAction*rebound = dynamic_cast<SPAction *>( nr_object_ref( dynamic_cast<NRObject *>(targetAction) ) ); - nr_active_object_add_listener( (NRActiveObject *)rebound, (NRObjectEventVector *)&action_event_vector, sizeof(SPActionEventVector), inky ); + // FIXME: memory leak: this is not unrefed anywhere + g_object_ref(G_OBJECT(targetAction)); + g_object_set_data_full(G_OBJECT(inky), "SPAction", (void*) targetAction, (GDestroyNotify) &g_object_unref); + targetAction->signal_set_sensitive.connect( + sigc::bind<0>( + sigc::ptr_fun(>k_action_set_sensitive), + GTK_ACTION(inky))); return act; } |
