aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-08-21 15:19:12 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-08-21 15:19:12 -0500
commitfbd76f40c44dd02acaa73ebaf843189b96da3357 (patch)
tree6f460cf8f3e7b202bd38c1eccec1bb33e1924f8b
parentfb4b30683744b22f3eae819a100ad3184b454fc8 (diff)
downloadayatana-ido-fbd76f40c44dd02acaa73ebaf843189b96da3357.tar.gz
ayatana-ido-fbd76f40c44dd02acaa73ebaf843189b96da3357.tar.bz2
ayatana-ido-fbd76f40c44dd02acaa73ebaf843189b96da3357.zip
when the mouse is over the GtkSwitch widget, the menuitem should delegate the mouse down and motion events to it.
-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
***/