diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
commit | 932ea7c83c07d3982fee605c6dd9895fd2753874 (patch) | |
tree | 766ad53bab9e3e3005334c30e823493de8e84168 /src/gui/menus | |
parent | 1b5d39bfbc48c33a0ea0924b60e48448c8b45dd4 (diff) |
Rewritten the line buffers using generators and on-demand building to save memory.
Diffstat (limited to 'src/gui/menus')
-rw-r--r-- | src/gui/menus/edition.c | 1 | ||||
-rw-r--r-- | src/gui/menus/view.c | 75 |
2 files changed, 55 insertions, 21 deletions
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c index 89b5fe9..d5ef541 100644 --- a/src/gui/menus/edition.c +++ b/src/gui/menus/edition.c @@ -37,7 +37,6 @@ #include "../../analysis/db/items/switcher.h" #include "../../arch/target.h" #include "../../gtkext/easygtk.h" -#include "../../gtkext/gtkbufferview.h" diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index 9447724..2b3f37e 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -25,6 +25,9 @@ #include "view.h" +#include <assert.h> + + #include <i18n.h> @@ -32,6 +35,8 @@ #include "../core/panels.h" #include "../../analysis/project.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkblockdisplay.h" +#include "../../gtkext/gtkgraphdisplay.h" @@ -100,6 +105,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) G_CALLBACK(mcb_view_change_support), bar); add_accelerator_to_menu_item(submenuitem, "F3", accgroup); g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_BLOCK)); + g_object_set_data(G_OBJECT(submenuitem), "kind_of_display", GSIZE_TO_POINTER(GTK_TYPE_BLOCK_DISPLAY)); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); rgroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(submenuitem)); @@ -108,14 +114,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) G_CALLBACK(mcb_view_change_support), bar); add_accelerator_to_menu_item(submenuitem, "F4", accgroup); g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_GRAPH)); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - rgroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(submenuitem)); - - submenuitem = qck_create_radio_menu_item(ref, "mnu_view_switch_sourceview", rgroup, _("Source code"), - G_CALLBACK(mcb_view_change_support), bar); - add_accelerator_to_menu_item(submenuitem, "F5", accgroup); - g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_SOURCE)); + g_object_set_data(G_OBJECT(submenuitem), "kind_of_display", GSIZE_TO_POINTER(GTK_TYPE_GRAPH_DISPLAY)); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); /* - */ @@ -174,6 +173,9 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuBar *bar) { GObject *ref; /* Espace de référencements */ + GtkRadioMenuItem *item; /* Elément de menu arbitraire */ + GSList *radios; /* Liste des menus d'affichage */ + GSList *found; /* Elément de menu à activer */ GLoadedBinary *binary; /* Binaire courant */ BinaryView content; /* Type de vue active */ const bool *display; /* Règles d'affichage courantes*/ @@ -182,6 +184,49 @@ void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuB ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar)); + /* Types de panneau de code */ + + item = GTK_RADIO_MENU_ITEM(g_object_get_data(ref, "mnu_view_switch_graphview")); + + radios = gtk_radio_menu_item_get_group(item); + + void disconnect_display_radio(GtkWidget *wgt, gpointer unused) + { + g_signal_handlers_disconnect_by_func(wgt, G_CALLBACK(mcb_view_change_support), bar); + + } + + g_slist_foreach(radios, (GFunc)disconnect_display_radio, NULL); + + gint find_suitable_display_radio(GObject *rdo, GObject *pnl) + { + GType rdo_type; /* Type d'affichage supporté */ + GType pnl_type; /* Type du panneau affiché */ + + rdo_type = GPOINTER_TO_SIZE(g_object_get_data(rdo, "kind_of_display")); + + pnl_type = G_OBJECT_TYPE(pnl); + + return (rdo_type == pnl_type ? 0 : -1); + + } + + found = g_slist_find_custom(radios, G_OBJECT(panel), (GCompareFunc)find_suitable_display_radio); + + assert(found != NULL); + + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(found->data), TRUE); + + void reconnect_display_radio(GtkWidget *wgt, gpointer unused) + { + g_signal_connect(wgt, "toggled", G_CALLBACK(mcb_view_change_support), bar); + + } + + g_slist_foreach(radios, (GFunc)reconnect_display_radio, NULL); + + /* - */ + binary = g_editor_item_get_current_binary(G_EDITOR_ITEM(bar)); content = gtk_display_panel_describe_content(panel); @@ -246,17 +291,6 @@ void update_access_in_menu_view(GObject *ref, GtkDisplayPanel *panel) access = (panel != NULL); - /* Types de panneau de code */ - - item = GTK_WIDGET(g_object_get_data(ref, "mnu_view_switch_textview")); - gtk_widget_set_sensitive(item, access); - - item = GTK_WIDGET(g_object_get_data(ref, "mnu_view_switch_graphview")); - gtk_widget_set_sensitive(item, access); - - item = GTK_WIDGET(g_object_get_data(ref, "mnu_view_switch_sourceview")); - gtk_widget_set_sensitive(item, access); - /* Affichage des données */ item = GTK_WIDGET(g_object_get_data(ref, "mnu_view_display_off")); @@ -450,7 +484,8 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, GMenuBar *bar) station = get_dock_station_for_view_panel(panel); /* En vue du retrait de la station d'accueil... */ - g_object_ref(G_OBJECT(panel)); + scroll = get_scroll_window_for_view_panel(panel); + g_object_ref(G_OBJECT(scroll)); panel = get_alt_view_for_view_panel(panel, wanted); scroll = get_scroll_window_for_view_panel(panel); |