summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/Makefile.am3
-rw-r--r--src/gui/status.c266
-rw-r--r--src/gui/status.h56
3 files changed, 324 insertions, 1 deletions
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index c0a03f0..2e2bc1c 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -3,7 +3,8 @@ noinst_LTLIBRARIES = libgui.la
libgui_la_SOURCES = \
editem-int.h \
- editem.h editem.c
+ editem.h editem.c \
+ status.h status.c
libgui_la_LIBADD = \
menus/libguimenus.la \
diff --git a/src/gui/status.c b/src/gui/status.c
new file mode 100644
index 0000000..16a3ff8
--- /dev/null
+++ b/src/gui/status.c
@@ -0,0 +1,266 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * status.c - affichage d'informations de statut dans la fenêtre principale
+ *
+ * Copyright (C) 2013 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "status.h"
+
+
+#include <string.h>
+
+
+#include <i18n.h>
+
+
+#include "editem-int.h"
+#include "../common/extstr.h"
+#include "../gtkext/gtkbufferview.h"
+#include "../gtkext/gtkblockview.h"
+#include "../gtkext/gtkextstatusbar.h"
+
+
+
+/* Barre de statut de la fenêtre principale (instance) */
+struct _GStatusInfo
+{
+ GEditorItem parent; /* A laisser en premier */
+
+ GObject *caret_instance; /* Dernier émetteur de signaux */
+ guint msg_id; /* Identifiant du dernier msg. */
+
+};
+
+
+/* Barre de statut de la fenêtre principale (classe) */
+struct _GStatusInfoClass
+{
+ GEditorItemClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe de la barre de statut de l'éditeur. */
+static void g_status_info_class_init(GStatusInfoClass *);
+
+/* Initialise une instance de la barre de statut pour l'éditeur. */
+static void g_status_info_init(GStatusInfo *);
+
+/* Lance une actualisation du fait d'un changement de vue. */
+static void update_status_info_for_view(GStatusInfo *, GtkViewPanel *);
+
+/* Imprime la position du parcours courant dans le statut. */
+static void track_caret_address_on_buffer_views(GtkBufferView *, vmpa_t, GStatusInfo *);
+
+
+
+
+/* Indique le type défini pour la barre de statut de la fenêtre principale. */
+G_DEFINE_TYPE(GStatusInfo, g_status_info, G_TYPE_EDITOR_ITEM);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe de la barre de statut de l'éditeur. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_status_info_class_init(GStatusInfoClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : bar = instance à initialiser. *
+* *
+* Description : Initialise une instance de la barre de statut pour l'éditeur.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_status_info_init(GStatusInfo *bar)
+{
+ GEditorItem *item; /* Autre version de l'élément */
+
+ item = G_EDITOR_ITEM(bar);
+
+ item->name = "status";
+
+ item->widget = gtk_extended_status_bar_new();
+ gtk_widget_show(item->widget);
+
+ item->update_view = (update_item_view_fc)update_status_info_for_view;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* *
+* Description : Compose la barre de statut principale. *
+* *
+* Retour : Adresse de la structure mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GEditorItem *g_status_info_new(GObject *ref)
+{
+ GStatusInfo *result; /* Structure à retourner */
+ GEditorItem *item; /* Autre version de l'élément */
+
+ result = g_object_new(G_TYPE_STATUS_INFO, NULL);
+
+ item = G_EDITOR_ITEM(result);
+
+ g_object_ref(ref);
+ item->ref = ref;
+
+ g_object_set_data(ref, "statusbar", item->widget);
+
+ return G_EDITOR_ITEM(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = barre de statut à actualiser. *
+* view = nouveau panneau d'affichage actif. *
+* *
+* Description : Lance une actualisation du fait d'un changement de vue. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void update_status_info_for_view(GStatusInfo *info, GtkViewPanel *view)
+{
+ printf("new view :: %p\n", view);
+
+ //track_caret_address_on_buffer_views
+
+ if (info->caret_instance != NULL)
+ {
+ g_signal_handlers_disconnect_by_func(info->caret_instance,
+ G_CALLBACK(track_caret_address_on_buffer_views),
+ info);
+ g_object_unref(info->caret_instance);
+ }
+
+ if (GTK_IS_BLOCK_VIEW(view))
+ g_signal_connect(view, "caret-moved",
+ G_CALLBACK(track_caret_address_on_buffer_views),
+ info);
+
+ else
+ return;
+
+ info->caret_instance = G_OBJECT(view);
+ g_object_ref(info->caret_instance);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = composant d'affichage parcouru. *
+* addr = nouvelle adresse du curseur courant. *
+* info = barre de statut présentant les informations. *
+* *
+* Description : Imprime la position du parcours courant dans le statut. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void track_caret_address_on_buffer_views(GtkBufferView *view, vmpa_t addr, GStatusInfo *info)
+{
+ GEditorItem *item; /* Autre version de l'élément */
+ char *msg; /* Message à transmettre */
+ char tmp[VMPA_MAX_SIZE]; /* Zone de conversion */
+ GLoadedBinary *binary; /* Binaire courant */
+ GExeFormat *format; /* Format associé au binaire */
+ vmpa_t rel; /* Adresse relative à un symb. */
+ const char *label; /* Désignation d'un symbole */
+
+ item = G_EDITOR_ITEM(info);
+
+ /* Adresse brute */
+
+ msg = strdup(_("Address "));
+
+ snprintf(tmp, VMPA_MAX_SIZE, VMPA_FMT_LONG, addr);
+ msg = stradd(msg, tmp);
+
+ /* Relation avec les symboles */
+
+ binary = G_LOADED_BINARY(g_object_get_data(item->ref, "current_binary"));
+ format = g_loaded_binary_get_format(binary);
+
+ rel = addr;
+
+ if (g_binary_format_resolve_relative_routine(G_BIN_FORMAT(format), &label, &rel))
+ {
+ msg = stradd(msg, _(" at "));
+ msg = stradd(msg, label);
+ msg = stradd(msg, _("+"));
+
+ snprintf(tmp, VMPA_MAX_SIZE, VMPA_FMT, rel);
+ msg = stradd(msg, tmp);
+
+ }
+
+ /* Impression */
+
+ if (info->msg_id > 0)
+ gtk_extended_status_bar_remove(GTK_EXT_STATUS_BAR(item->widget), info->msg_id);
+
+ info->msg_id = gtk_extended_status_bar_push(GTK_EXT_STATUS_BAR(item->widget), msg, FALSE);
+
+
+ printf("---- moved to 0x%08llx\n", addr);
+
+ printf(" MSG '%s'\n", msg);
+
+ //update_menu_project_for_project(bar->project, project, bar);
+
+
+ free(msg);
+
+}
diff --git a/src/gui/status.h b/src/gui/status.h
new file mode 100644
index 0000000..277df4c
--- /dev/null
+++ b/src/gui/status.h
@@ -0,0 +1,56 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * status.h - prototypes pour l'affichage d'informations de statut dans la fenêtre principale
+ *
+ * Copyright (C) 2013 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _GUI_STATUS_H
+#define _GUI_STATUS_H
+
+
+#include "editem.h"
+
+
+
+#define G_TYPE_STATUS_INFO g_status_info_get_type()
+#define G_STATUS_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_status_info_get_type(), GStatusInfo))
+#define G_IS_STATUS_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_status_info_get_type()))
+#define G_STATUS_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_STATUS_INFO, GStatusInfoClass))
+#define G_IS_STATUS_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_STATUS_INFO))
+#define G_STATUS_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_STATUS_INFO, GStatusInfoClass))
+
+
+/* Barre de statut de la fenêtre principale (instance) */
+typedef struct _GStatusInfo GStatusInfo;
+
+/* Barre de statut de la fenêtre principale (classe) */
+typedef struct _GStatusInfoClass GStatusInfoClass;
+
+
+/* Indique le type défini pour la barre de statut de la fenêtre principale. */
+GType g_status_info_get_type(void);
+
+/* Compose la barre de statut principale. */
+GEditorItem *g_status_info_new(GObject *);
+
+
+
+#endif /* _GUI_MENUS_MENUBAR_H */