aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Russell <crussell@canonical.com>2010-03-05 16:04:11 +0000
committerCody Russell <crussell@canonical.com>2010-03-05 16:04:11 +0000
commit6c7fcbe1d5ede0eaa6c6f2c10b0f0597ecdfffbd (patch)
treee65edc7907409cb8dbbd32a3e8efa010331eded8
parent2cffa8580d3f658adce63aa5ff7ced8a14d9c509 (diff)
downloadayatana-ido-6c7fcbe1d5ede0eaa6c6f2c10b0f0597ecdfffbd.tar.gz
ayatana-ido-6c7fcbe1d5ede0eaa6c6f2c10b0f0597ecdfffbd.tar.bz2
ayatana-ido-6c7fcbe1d5ede0eaa6c6f2c10b0f0597ecdfffbd.zip
Add grab/release signals
-rw-r--r--example/menus.c15
-rw-r--r--src/idoscalemenuitem.c32
2 files changed, 47 insertions, 0 deletions
diff --git a/example/menus.c b/example/menus.c
index 7d4b282..133c7c8 100644
--- a/example/menus.c
+++ b/example/menus.c
@@ -3,6 +3,18 @@
#include "idoscalemenuitem.h"
#include "idoentrymenuitem.h"
+static void
+slider_grabbed (GtkWidget *widget, gpointer user_data)
+{
+ g_print ("grabbed\n");
+}
+
+static void
+slider_released (GtkWidget *widget, gpointer user_data)
+{
+ g_print ("released\n");
+}
+
int
main (int argc, char *argv[])
{
@@ -46,6 +58,9 @@ main (int argc, char *argv[])
gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ g_signal_connect (menuitem, "slider-grabbed", G_CALLBACK (slider_grabbed), NULL);
+ g_signal_connect (menuitem, "slider-released", G_CALLBACK (slider_released), NULL);
+
menuitem = ido_entry_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c
index a7ae907..ca1e678 100644
--- a/src/idoscalemenuitem.c
+++ b/src/idoscalemenuitem.c
@@ -70,11 +70,19 @@ struct _IdoScaleMenuItemPrivate {
};
enum {
+ SLIDER_GRABBED,
+ SLIDER_RELEASED,
+ LAST_SIGNAL
+};
+
+enum {
PROP_0,
PROP_ADJUSTMENT,
PROP_REVERSE_SCROLL_EVENTS
};
+static guint signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE (IdoScaleMenuItem, ido_scale_menu_item, GTK_TYPE_MENU_ITEM)
#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_SCALE_MENU_ITEM, IdoScaleMenuItemPrivate))
@@ -190,6 +198,22 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class)
FALSE,
G_PARAM_READWRITE));
+ signals[SLIDER_GRABBED] = g_signal_new ("slider-grabbed",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[SLIDER_RELEASED] = g_signal_new ("slider-released",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (object_class, sizeof (IdoScaleMenuItemPrivate));
}
@@ -389,6 +413,8 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem,
gtk_widget_event (scale,
((GdkEvent *)(void*)(event)));
+ g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0);
+
return TRUE;
}
@@ -415,6 +441,8 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem,
gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj));
}
+ g_signal_emit (menuitem, signals[SLIDER_RELEASED], 0);
+
return TRUE;
}
@@ -432,6 +460,8 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem,
gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
}
+ g_signal_emit (menuitem, signals[SLIDER_RELEASED], 0);
+
return TRUE;
}
@@ -448,6 +478,8 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem,
event->window = tmp;
+ g_signal_emit (menuitem, signals[SLIDER_RELEASED], 0);
+
return TRUE;
}