libgnt/libgnt

Single clicking a menuitem should activate it.
v2.4.0
2008-02-17, Sadrul Habib Chowdhury
829a17d71c05
Parents af04f4cae6bb
Children 41b5f3b28a2b
Single clicking a menuitem should activate it.
  • +13 -0
    gntmenu.c
  • --- a/gntmenu.c Sun Feb 17 17:14:29 2008 +0000
    +++ b/gntmenu.c Sun Feb 17 17:26:37 2008 +0000
    @@ -46,6 +46,7 @@
    static void (*org_map)(GntWidget *wid);
    static void (*org_size_request)(GntWidget *wid);
    static gboolean (*org_key_pressed)(GntWidget *w, const char *t);
    +static gboolean (*org_clicked)(GntWidget *w, GntMouseEvent event, int x, int y);
    static void menuitem_activate(GntMenu *menu, GntMenuItem *item);
    @@ -390,6 +391,16 @@
    menu->parentmenu->submenu = NULL;
    }
    +static gboolean
    +gnt_menu_clicked(GntWidget *widget, GntMouseEvent event, int x, int y)
    +{
    + if (!org_clicked || !org_clicked(widget, event, x, y) ||
    + !GNT_MENU(widget)->type == GNT_MENU_TOPLEVEL)
    + return FALSE;
    + gnt_widget_activate(widget);
    + return TRUE;
    +}
    +
    static void
    gnt_menu_class_init(GntMenuClass *klass)
    {
    @@ -401,6 +412,7 @@
    org_draw = wid_class->draw;
    org_key_pressed = wid_class->key_pressed;
    org_size_request = wid_class->size_request;
    + org_clicked = wid_class->clicked;
    wid_class->destroy = gnt_menu_destroy;
    wid_class->draw = gnt_menu_draw;
    @@ -409,6 +421,7 @@
    wid_class->key_pressed = gnt_menu_key_pressed;
    wid_class->activate = gnt_menu_activate;
    wid_class->hide = gnt_menu_hide;
    + wid_class->clicked = gnt_menu_clicked;
    parent_class->toggled = gnt_menu_toggled;