diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-01-27 22:51:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-01-27 22:51:43 (GMT) |
commit | 7640b28691817aea89fc5a5dd5e74fd0b40c516f (patch) | |
tree | 5b8dc6b6746575fb4bbfcefff36fc9af5f6a2c17 /src/gtkext | |
parent | 56b84c3624c59c8a1796bf411b7ba950d12ddfc5 (diff) |
Made the menu bar appear and disappear in the same way Firefox does.
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/easygtk.c | 57 | ||||
-rw-r--r-- | src/gtkext/easygtk.h | 3 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/gtkext/easygtk.c b/src/gtkext/easygtk.c index 706505b..b931ff0 100644 --- a/src/gtkext/easygtk.c +++ b/src/gtkext/easygtk.c @@ -819,6 +819,56 @@ GtkWidget *qck_create_combobox_with_entry(GObject *object, const char *name, GCa /****************************************************************************** * * +* Paramètres : item = élément de menu devant recevoir un sous-menu. * +* * +* Description : Met en place un support de menu 'GtkMenu'. * +* * +* Retour : Rceptacle pour sous-éléments de menu. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *qck_create_menu(GtkMenuItem *item) +{ + GtkWidget *result; /* Composant à retourner */ + + result = gtk_menu_new(); + + if (item != NULL) + { + gtk_menu_item_set_submenu(item, result); + + gboolean handle_escape_on_menu(GtkWidget *menu, GdkEventKey *event, GtkMenuItem *item) + { + if (event->keyval == GDK_KEY_Escape) + { + gtk_widget_hide(menu); + gtk_menu_item_deselect(item); + } + + return FALSE; + + } + + g_signal_connect(result, "key-press-event", G_CALLBACK(handle_escape_on_menu), item); + + void show_parent_selection(GtkWidget *widget, GtkMenuItem *item) + { + gtk_menu_item_select(item); + } + + g_signal_connect(result, "show", G_CALLBACK(show_parent_selection), item); + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : object = espace dédié à l'inscription de références. * * name = nom à donner au nouveau composant. * * caption = intitulé du menu à créer. * @@ -953,6 +1003,13 @@ void add_accelerator_to_menu_item(GtkWidget *item, const char *accelerator, GtkA gtk_accelerator_parse(accelerator, &key, &mods); + gboolean enable_accel_all_the_time(GtkWidget *widget, guint signal_id, gpointer unused) + { + return gtk_widget_is_sensitive(widget); + } + + g_signal_connect(item, "can-activate-accel", G_CALLBACK(enable_accel_all_the_time), NULL); + gtk_widget_add_accelerator(item, "activate", group, key, mods, GTK_ACCEL_VISIBLE); diff --git a/src/gtkext/easygtk.h b/src/gtkext/easygtk.h index 1beb536..fb6ad5a 100644 --- a/src/gtkext/easygtk.h +++ b/src/gtkext/easygtk.h @@ -92,6 +92,9 @@ GtkWidget *qck_create_combobox2(GObject *, const char *, GCallback, gpointer); /* Crée et enregistre un composant 'GtkComboBox'. */ GtkWidget *qck_create_combobox_with_entry(GObject *, const char *, GCallback, gpointer); +/* Met en place un support de menu 'GtkMenu'. */ +GtkWidget *qck_create_menu(GtkMenuItem *); + /* Crée et enregistre un composant 'GtkMenuItem'. */ GtkWidget *qck_create_menu_item(GObject *, const char *, const char *, GCallback, gpointer); |