summaryrefslogtreecommitdiffstats
path: root/src/widgets/button.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-28 19:18:21 +0000
committerKrzysztof Kosinski <tweenk.pl@gmail.com>2011-08-28 19:18:21 +0000
commitbe7df18d6aef42dd657426b6a9d30834e5f54ca6 (patch)
tree9bc96a469b9cf6595004d1733d1b7104eb764092 /src/widgets/button.cpp
parentRemove last forward declaration of NRPixBlock (diff)
downloadinkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.tar.gz
inkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.zip
Remove nr-object.h and nr-macros.h
(bzr r10582.1.10)
Diffstat (limited to 'src/widgets/button.cpp')
-rw-r--r--src/widgets/button.cpp62
1 files changed, 24 insertions, 38 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(&gtk_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;
}