diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-03-08 21:44:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-03-08 21:46:19 (GMT) |
commit | 235b34006d734d55333a182ffd8bbe7fbf8f54bc (patch) | |
tree | f1c8f75391537c8c187aea46c16b3d2642c92107 /src/gui/menus | |
parent | 02e978d601cdcf2ea9bb39ae21207c3b97d16e22 (diff) |
Loaded a dynamic list of dockable panels in the View menu.
Diffstat (limited to 'src/gui/menus')
-rw-r--r-- | src/gui/menus/menubar.c | 2 | ||||
-rw-r--r-- | src/gui/menus/project.c | 2 | ||||
-rw-r--r-- | src/gui/menus/view.c | 168 |
3 files changed, 170 insertions, 2 deletions
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c index db1905c..e2ad155 100644 --- a/src/gui/menus/menubar.c +++ b/src/gui/menus/menubar.c @@ -208,6 +208,8 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup) result = g_object_new(G_TYPE_MENU_BAR, NULL); + g_object_set_data(G_OBJECT(result), "accgroup", accgroup); + /* Initialisation générique */ item = G_EDITOR_ITEM(result); diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index f4f6233..9e43616 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -66,7 +66,7 @@ static void mcb_project_remove_binary(GtkMenuItem *, GStudyProject *); GtkWidget *build_menu_project(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) { GtkWidget *result; /* Support à retourner */ - GtkWidget *menubar; /* Support pour éléments */ + GtkWidget *menubar; /* Support pour éléments #1 */ GtkWidget *submenuitem; /* Sous-élément de menu #1 */ GtkWidget *deepmenubar; /* Support pour éléments #2 */ GtkWidget *deepmenuitem; /* Sous-élément de menu #2 */ diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index cbfa9bf..e80077a 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -29,12 +29,19 @@ #include "../editem-int.h" +#include "../panels/panel.h" #include "../../analysis/project.h" #include "../../gtkext/easygtk.h" #include "../../gtkext/gtkdockstation.h" +/* Réagit avec le menu "Affichage -> Panneaux latéraux". */ +static void mcb_view_update_side_panels_list(GtkMenuItem *, GMenuBar *); + +/* Réagit avec le menu "Affichage -> Panneaux latéraux -> ...". */ +static void mcb_view_change_panel_docking(GtkCheckMenuItem *, GPanelItem *); + /* Réagit avec le menu "Affichage -> Vue xxx". */ static void mcb_view_change_support(GtkRadioMenuItem *, GMenuBar *); @@ -63,8 +70,9 @@ static void mcb_view_show_full_screen(GtkCheckMenuItem *, GMenuBar *); GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) { GtkWidget *result; /* Support à retourner */ - GtkWidget *menubar; /* Support pour éléments */ + GtkWidget *menubar; /* Support pour éléments #1 */ GtkWidget *submenuitem; /* Sous-élément de menu */ + GtkWidget *deepmenubar; /* Support pour éléments #2 */ GSList *rgroup; /* Groupe des boutons radio */ result = gtk_menu_item_new_with_mnemonic(_("_View")); @@ -73,6 +81,20 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) menubar = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar); + /* Affichage -> Panneaux latéraux */ + + submenuitem = qck_create_menu_item(NULL, NULL, _("Side panels"), NULL, NULL); + g_signal_connect(submenuitem, "select", G_CALLBACK(mcb_view_update_side_panels_list), bar); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + + deepmenubar = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), deepmenubar); + + /* - */ + + submenuitem = qck_create_menu_separator(); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + submenuitem = qck_create_radio_menu_item(ref, "textview", NULL, _("Text view"), G_CALLBACK(mcb_view_change_support), bar); add_accelerator_to_menu_item(submenuitem, "F2", accgroup); @@ -113,6 +135,8 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) g_object_set_data(G_OBJECT(submenuitem), "kind_of_col", GUINT_TO_POINTER(BLC_BINARY)); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + /* - */ + submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -194,6 +218,148 @@ void update_menu_view_for_view(GtkWidget *widget, GtkViewPanel *view, GMenuBar * /****************************************************************************** * * +* Paramètres : menuitem = élément de menu sélectionné. * +* bar = barre de menu parente. * +* * +* Description : Réagit avec le menu "Affichage -> Panneaux latéraux". * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void mcb_view_update_side_panels_list(GtkMenuItem *menuitem, GMenuBar *bar) +{ + GtkWidget *menubar; /* Support pour éléments */ + GtkAccelGroup *accgroup; /* Groupe de raccourcis */ + + typedef struct _panels_loading_filter + { + GtkContainer *support; /* Support pour éléments */ + GtkAccelGroup *accel; /* Groupe de raccourcis */ + + PanelItemPersonality personality; /* Nature des éléments attendus*/ + bool first; /* Premier ajout ? */ + + } panels_loading_filter; + + panels_loading_filter pfilter; + + + menubar = gtk_menu_item_get_submenu(menuitem); + + /* Réinitialisation */ + + void remove_panel_menu_item(GtkWidget *widget, GtkContainer *container) + { + gtk_container_remove(container, widget); + + } + + gtk_container_foreach(GTK_CONTAINER(menubar), (GtkCallback)remove_panel_menu_item, menubar); + + /* Ajout des panneaux uniques */ + + bool add_side_panel_to_list(GPanelItem *panel, panels_loading_filter *filter) + { + const char *name; /* Désignation de l'entrée */ + GtkWidget *submenuitem; /* Sous-élément de menu */ + const char *bindings; /* Raccourcis clavier bruts */ + + if (gtk_panel_item_get_personality(panel) != filter->personality) + goto aptl_exit; + + /* Séparation */ + + if (filter->first) + { + filter->first = false; + + submenuitem = qck_create_menu_separator(); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + + } + + /* Elément de menu */ + + name = g_editor_item_get_name(G_EDITOR_ITEM(panel)); + + submenuitem = qck_create_check_menu_item(NULL, NULL, name, + G_CALLBACK(mcb_view_change_panel_docking), panel); + + bindings = gtk_panel_item_get_key_bindings(panel); + + if (bindings != NULL) + add_accelerator_to_menu_item(submenuitem, bindings, filter->accel); + + gtk_container_add(filter->support, submenuitem); + + /* Statut de la coche */ + + if (g_panel_item_is_docked(panel)) + { + g_signal_handlers_disconnect_by_func(submenuitem, G_CALLBACK(mcb_view_change_panel_docking), panel); + + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(submenuitem), TRUE); + + g_signal_connect(submenuitem, "toggled", G_CALLBACK(mcb_view_change_panel_docking), panel); + + } + + aptl_exit: + + return true; + + } + + accgroup = GTK_ACCEL_GROUP(g_object_get_data(G_OBJECT(bar), "accgroup")); + + pfilter.support = GTK_CONTAINER(menubar); + pfilter.accel = accgroup; + + pfilter.personality = PIP_SINGLETON; + pfilter.first = false; + + browse_all_item_panels((handle_panel_item_fc)add_side_panel_to_list, &pfilter); + + pfilter.personality = PIP_OTHER; + pfilter.first = true; + + browse_all_item_panels((handle_panel_item_fc)add_side_panel_to_list, &pfilter); + +} + + +/****************************************************************************** +* * +* Paramètres : menuitem = élément de menu ayant basculé. * +* bar = barre de menu parente. * +* * +* Description : Réagit avec le menu "Affichage -> Panneaux latéraux -> ...". * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void mcb_view_change_panel_docking(GtkCheckMenuItem *menuitem, GPanelItem *item) +{ + gboolean active; /* Etat de sélection du menu */ + + active = gtk_check_menu_item_get_active(menuitem); + + if (active) + g_panel_item_dock(item); + else + g_panel_item_undock(item); + +} + + +/****************************************************************************** +* * * Paramètres : menuitem = élément de menu ayant basculé. * * bar = barre de menu parente. * * * |