summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
commit2c28d59fb3671c0fdd1987784076d4968c58b651 (patch)
treea301f6cd9c1fd9f92191fba7fe7b59a7e3a01b5a /src/gui
parent67b4887317b7394d63b543aa48cb368406374103 (diff)
Created the GLoadedContent interface to load all kinds of content.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/editor.c90
-rw-r--r--src/gui/menus/project.c41
-rw-r--r--src/gui/menus/view.c66
3 files changed, 147 insertions, 50 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 6785753..d1f90d5 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -47,6 +47,7 @@
#include "../core/global.h"
#include "../core/params.h"
#include "../gtkext/easygtk.h"
+#include "../gtkext/gtkdisplaypanel.h"
#include "../gtkext/gtkdockable.h"
#include "../gtkext/gtkdockstation.h"
#include "../gtkext/support.h"
@@ -214,6 +215,11 @@ static void notify_paned_handle_position_change(GObject *, GParamSpec *, gpointe
/* Réagit à un changement du projet principal. */
static void notify_editor_project_change(GStudyProject *, bool);
+/* Assure un positionnement initial idéal. */
+static gboolean scroll_for_the_first_time(GtkWidget *, GdkEvent *, GLoadedContent *);
+
+/* Affiche le contenu qui vient de rejoindre un projet donné. */
+void on_editor_loaded_content_added(GStudyProject *, GLoadedContent *, void *);
@@ -1612,7 +1618,12 @@ static void notify_editor_project_change(GStudyProject *project, bool new)
if (new)
{
- /* ... */
+
+ g_signal_connect(project, "content-added", G_CALLBACK(on_editor_loaded_content_added), NULL);
+
+
+
+ /* TODO : show_all()... */
}
@@ -1623,9 +1634,86 @@ static void notify_editor_project_change(GStudyProject *project, bool new)
g_study_project_hide(project);
+ g_signal_handlers_disconnect_by_func(project, G_CALLBACK(on_editor_loaded_content_added), NULL);
+
}
}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = project impliqué dans l'opération. *
+* content = nouveau contenu à présenter dans l'éditeur. *
+* unused = adresse non utilisée ici. *
+* *
+* Description : Affiche le contenu qui vient de rejoindre un projet donné. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void on_editor_loaded_content_added(GStudyProject *project, GLoadedContent *content, void *unused)
+{
+ GtkWidget *selected; /* Interface de prédilection */
+ const char *name; /* Titre associé au binaire */
+ const char *lname; /* Description du binaire */
+ GPanelItem *panel; /* Nouveau panneau à integrer */
+
+ selected = g_loaded_content_build_view(content, 0);
+
+ name = g_loaded_content_describe(content, false);
+ lname = g_loaded_content_describe(content, true);
+
+ panel = g_panel_item_new(PIP_BINARY_VIEW, name, lname, selected, true, "N");
+ register_panel_item(panel, get_main_configuration());
+
+ g_signal_connect(selected, "size-allocate", G_CALLBACK(scroll_for_the_first_time), content);
+
+ g_panel_item_dock(panel);
+
+ update_project_area(project);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant d'affichage nouvellement porté à l'écran.*
+* event = informations liées à l'événement. *
+* content = contenu chargé associé au composant d'affichage. *
+* *
+* Description : Assure un positionnement initial idéal. *
+* *
+* Retour : FALSE. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean scroll_for_the_first_time(GtkWidget *widget, GdkEvent *event, GLoadedContent *content)
+{
+ GExeFormat *format; /* Format associé au binaire */
+ vmpa2t target; /* Position initiale à viser */
+
+ g_signal_handlers_disconnect_by_func(widget, G_CALLBACK(scroll_for_the_first_time), content);
+
+ if (G_IS_LOADED_BINARY(content))
+ {
+ format = g_loaded_binary_get_format(G_LOADED_BINARY(content));
+
+ if (g_exe_format_get_main_address(format, &target))
+ gtk_display_panel_request_move(GTK_DISPLAY_PANEL(widget), &target);
+
+ g_object_unref(G_OBJECT(format));
+
+ }
+
+ return FALSE;
+
+}
diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c
index c46c017..5d027a0 100644
--- a/src/gui/menus/project.c
+++ b/src/gui/menus/project.c
@@ -46,8 +46,8 @@ static void mcb_project_add_shellcode(GtkMenuItem *, GMenuBar *);
/* Affiche la boîte d'ajout d'un binaire au projet courant. */
static void mcb_project_add_binary_file(GtkMenuItem *, GMenuBar *);
-/* Retire un binaire du projet indiqué. */
-static void mcb_project_remove_binary(GtkMenuItem *, GStudyProject *);
+/* Retire un contenu du projet indiqué. */
+static void mcb_project_remove_content(GtkMenuItem *, GStudyProject *);
@@ -122,8 +122,8 @@ void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project,
GtkWidget *menubar; /* Support pour éléments */
GList *list; /* Liste des éléments en place */
GList *iter; /* Boucle de parcours #1 */
- size_t count; /* Nombre de binaires attachés */
- GLoadedBinary **binaries; /* Liste de ces binaires */
+ size_t count; /* Nombre de contenus attachés */
+ GLoadedContent **contents; /* Liste de ces contenus */
size_t i; /* Boucle de parcours #2 */
const char *desc; /* Description à afficher */
GtkWidget *submenuitem; /* Sous-menu à ajouter */
@@ -142,23 +142,26 @@ void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project,
/* Ajout des entrées */
- binaries = g_study_project_get_binaries(project, &count);
+ contents = g_study_project_get_contents(project, &count);
for (i = 0; i < count; i++)
{
- desc = g_loaded_binary_get_name(binaries[i], true);
+ desc = g_loaded_content_describe(contents[i], true);
submenuitem = qck_create_menu_item(NULL, NULL, desc,
- G_CALLBACK(mcb_project_remove_binary), project);
- g_object_set_data(G_OBJECT(submenuitem), "binary", binaries[i]);
+ G_CALLBACK(mcb_project_remove_content), project);
+ g_object_set_data_full(G_OBJECT(submenuitem), "content", contents[i], g_object_unref);
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
- g_object_unref(G_OBJECT(binaries[i]));
+ /**
+ * Note : l'appel à g_object_unref() est réalisé lorsque la référence
+ * est retirée du menu.
+ */
}
- if (binaries != NULL)
- free(binaries);
+ if (contents != NULL)
+ free(contents);
gtk_widget_set_sensitive(menuitem, count > 0);
@@ -304,7 +307,7 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar)
* Paramètres : menuitem = élément de menu sélectionné. *
* project = projet d'appartenance du binaire à traiter. *
* *
-* Description : Retire un binaire du projet indiqué. *
+* Description : Retire un contenu du projet indiqué. *
* *
* Retour : - *
* *
@@ -312,13 +315,17 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar)
* *
******************************************************************************/
-static void mcb_project_remove_binary(GtkMenuItem *menuitem, GStudyProject *project)
+static void mcb_project_remove_content(GtkMenuItem *menuitem, GStudyProject *project)
{
- GLoadedBinary *binary; /* Binaire à retirer */
+ GObject *ref; /* Espace de référencement */
+ GLoadedContent *content; /* Contenu à retirer */
- binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(menuitem), "binary"));
+ ref = G_OBJECT(menuitem);
- g_study_project_detach_binary(project, binary);
- g_object_unref(G_OBJECT(binary));
+ content = G_LOADED_CONTENT(g_object_get_data(ref, "content"));
+
+ g_study_project_detach_content(project, content);
+
+ g_object_set_data(ref, "content", NULL);
}
diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c
index 4298805..81b06d6 100644
--- a/src/gui/menus/view.c
+++ b/src/gui/menus/view.c
@@ -35,7 +35,7 @@
#include "../core/global.h"
#include "../core/items.h"
#include "../core/panels.h"
-#include "../../analysis/project.h"
+#include "../../analysis/loaded.h"
#include "../../gtkext/easygtk.h"
#include "../../gtkext/gtkblockdisplay.h"
#include "../../gtkext/gtkgraphdisplay.h"
@@ -125,17 +125,17 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar)
submenuitem = qck_create_check_menu_item(ref, "mnu_view_display_off", _("Physical offset"),
G_CALLBACK(mcb_view_display_column), NULL);
- g_object_set_data(G_OBJECT(submenuitem), "kind_of_col", GUINT_TO_POINTER(BLC_PHYSICAL));
+ g_object_set_data(G_OBJECT(submenuitem), "kind_of_opt", GUINT_TO_POINTER(BLC_PHYSICAL));
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
submenuitem = qck_create_check_menu_item(ref, "mnu_view_display_addr", _("Virtual address"),
G_CALLBACK(mcb_view_display_column), NULL);
- g_object_set_data(G_OBJECT(submenuitem), "kind_of_col", GUINT_TO_POINTER(BLC_VIRTUAL));
+ g_object_set_data(G_OBJECT(submenuitem), "kind_of_opt", GUINT_TO_POINTER(BLC_VIRTUAL));
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
submenuitem = qck_create_check_menu_item(ref, "mnu_view_display_code", _("Binary code"),
G_CALLBACK(mcb_view_display_column), NULL);
- g_object_set_data(G_OBJECT(submenuitem), "kind_of_col", GUINT_TO_POINTER(BLC_BINARY));
+ g_object_set_data(G_OBJECT(submenuitem), "kind_of_opt", GUINT_TO_POINTER(BLC_BINARY));
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
/* - */
@@ -175,8 +175,8 @@ void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuB
GtkRadioMenuItem *item; /* Elément de menu arbitraire */
GSList *radios; /* Liste des menus d'affichage */
GSList *found; /* Elément de menu à activer */
- BinaryView content; /* Type de vue active */
- GLoadedBinary *binary; /* Binaire courant */
+ GLoadedContent *content; /* Contenu global représenté */
+ unsigned int view_index; /* Indice de représentation */
const bool *display; /* Règles d'affichage courantes*/
GtkWidget *submenuitem; /* Sous-élément de menu */
bool status; /* Consigne d'affichage */
@@ -226,13 +226,13 @@ void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuB
/* - */
- content = gtk_display_panel_describe_content(panel);
+ content = g_loaded_panel_get_content(G_LOADED_PANEL(panel));
- binary = get_current_binary();
+ view_index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
- display = g_loaded_binary_get_column_display(binary, content);
+ display = g_loaded_content_get_all_display_options(content, view_index);
- g_object_unref(G_OBJECT(binary));
+ g_object_unref(G_OBJECT(content));
/* Positions physiques */
@@ -465,11 +465,12 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, gpointer unused)
{
GSList *group; /* Liste de menus radio */
GSList *iter; /* Boucle de parcours */
- BinaryView wanted; /* Nouvelle vue à présenter */
- GtkDisplayPanel *panel; /* Afficheur effectif de code */
+ unsigned int wanted; /* Nouvelle vue à présenter */
+ GLoadedPanel *panel; /* Afficheur effectif de code */
GtkDockStation *station; /* Base du remplacement */
- GtkWidget *scroll; /* Nouveau support à utiliser */
- GtkDisplayPanel *new; /* Nouvel afficheur de code */
+ GLoadedContent *content; /* Contenu représenté */
+ GtkWidget *support; /* Nouvel afficheur généraliste*/
+ GtkWidget *new; /* Panneau encapsulé */
/* On ne traite qu'une seule fois ! */
if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return;
@@ -483,16 +484,17 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, gpointer unused)
wanted = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(iter->data), "kind_of_view"));
panel = get_current_view();
- station = get_dock_station_for_view_panel(panel);
+ station = get_dock_station_for_view_panel(GTK_WIDGET(panel));
- /* En vue du retrait de la station d'accueil... */
- scroll = get_scroll_window_for_view_panel(panel);
- g_object_ref(G_OBJECT(scroll));
+ content = g_loaded_panel_get_content(panel);
- new = get_alt_view_for_view_panel(panel, wanted);
- scroll = get_scroll_window_for_view_panel(new);
+ support = g_loaded_content_build_view(content, wanted);
- gtk_dock_panel_change_active_widget(station, scroll);
+ g_object_unref(G_OBJECT(content));
+
+ gtk_dock_panel_change_active_widget(station, support);
+
+ new = get_loaded_panel_from_built_view(support);
change_editor_items_current_view(G_LOADED_PANEL(new));
@@ -518,25 +520,25 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, gpointer unused)
static void mcb_view_display_column(GtkCheckMenuItem *menuitem, gpointer unused)
{
- BufferLineColumn col; /* Colonne à traiter */
- GLoadedBinary *binary; /* Binaire courant */
- GtkDisplayPanel *panel; /* Affichage courant */
- BinaryView view; /* Type de vue représentée */
+ unsigned int option; /* Paramètre à traiter */
gboolean active; /* Etat de sélection du menu */
+ GLoadedPanel *panel; /* Afficheur effectif de code */
+ GLoadedContent *content; /* Contenu représenté */
+ unsigned int index; /* Indice de la vue courante */
- col = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuitem), "kind_of_col"));
+ option = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuitem), "kind_of_opt"));
- binary = get_current_binary();
+ active = gtk_check_menu_item_get_active(menuitem);
panel = get_current_view();
- view = gtk_display_panel_describe_content(panel);
- g_object_unref(G_OBJECT(panel));
+ content = g_loaded_panel_get_content(panel);
- active = gtk_check_menu_item_get_active(menuitem);
+ index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
- g_loaded_binary_set_column_display(binary, view, col, active);
+ g_loaded_content_set_display_option(content, index, option, active);
- g_object_unref(G_OBJECT(binary));
+ g_object_unref(G_OBJECT(content));
+ g_object_unref(G_OBJECT(panel));
}