aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/idoswitchmenuitem.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c
index 3831336..2ff60a3 100644
--- a/src/idoswitchmenuitem.c
+++ b/src/idoswitchmenuitem.c
@@ -24,6 +24,10 @@
static gboolean ido_switch_menu_button_release_event (GtkWidget * widget,
GdkEventButton * event);
+static gboolean ido_switch_menu_button_press_event (GtkWidget * widget,
+ GdkEventButton * event);
+static gboolean ido_switch_menu_item_motion_notify_event (GtkWidget *menuitem,
+ GdkEventMotion *event);
struct _IdoSwitchMenuItemPrivate
@@ -50,7 +54,9 @@ ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass)
g_type_class_add_private (gobject_class, sizeof (IdoSwitchMenuItemPrivate));
widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->button_press_event = ido_switch_menu_button_press_event;
widget_class->button_release_event = ido_switch_menu_button_release_event;
+ widget_class->motion_notify_event = ido_switch_menu_item_motion_notify_event;
check_class = GTK_CHECK_MENU_ITEM_CLASS (klass);
check_class->draw_indicator = NULL;
@@ -102,6 +108,51 @@ ido_switch_menu_button_release_event (GtkWidget * widget, GdkEventButton * event
}
/***
+****
+****
+***/
+
+static gboolean
+ido_switch_menu_button_press_event (GtkWidget * w, GdkEventButton * e)
+{
+ gboolean delegated = FALSE;
+ IdoSwitchMenuItemPrivate * p = IDO_SWITCH_MENU_ITEM(w)->priv;
+
+ GtkAllocation a;
+ gtk_widget_get_allocation (p->switch_w, &a);
+
+ if ((a.x <= e->x) && (e->x < a.x + a.width))
+ {
+ e->x -= a.x;
+ e->x_root -= a.x;
+ gtk_widget_event (p->switch_w, (GdkEvent*)e);
+ delegated = TRUE;
+ }
+
+ return delegated;
+}
+
+static gboolean
+ido_switch_menu_item_motion_notify_event (GtkWidget * w, GdkEventMotion * e)
+{
+ gboolean delegated = FALSE;
+ IdoSwitchMenuItemPrivate * p = IDO_SWITCH_MENU_ITEM(w)->priv;
+
+ GtkAllocation a;
+ gtk_widget_get_allocation (p->switch_w, &a);
+
+ if ((a.x <= e->x) && (e->x < a.x + a.width))
+ {
+ e->x -= a.x;
+ e->x_root -= a.x;
+ gtk_widget_event (p->switch_w, (GdkEvent*)e);
+ delegated = TRUE;
+ }
+
+ return delegated;
+}
+
+/***
**** Public API
***/