aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}