summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-09-24 22:15:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-09-24 22:15:43 (GMT)
commit8271ddd8f450f1ae9629f5d39e786bc323eba31c (patch)
tree726db1b41738003f1d15512dfc210505fce0344a /src
parentf7c1c34cb54b239586bf431b1749759baee9493e (diff)
Managed properly projects (close, reload, aso.).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@118 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/editor.c42
-rw-r--r--src/gtkext/gtkdockitem.c106
-rw-r--r--src/gtkext/gtkdockitem.h46
-rw-r--r--src/gtkext/gtkdockpanel.c62
-rw-r--r--src/gtkext/gtkdockpanel.h8
-rw-r--r--src/panels/panel.c4
-rw-r--r--src/panels/registers.c3
-rw-r--r--src/project.c101
-rw-r--r--src/project.h4
9 files changed, 270 insertions, 106 deletions
diff --git a/src/editor.c b/src/editor.c
index 942e6f4..5cdd4df 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -86,7 +86,7 @@ void mcb_file_save_project_as(GtkMenuItem *, gpointer);
/* Charge un projet récent et met à jour la liste. */
-void mcb_open_recent_project(GtkMenuItem *, gpointer);
+void mcb_open_recent_project(GtkMenuItem *, GObject *);
/* Réagit avec le menu "Affichage -> Vue xxx". */
void mcb_view_change_support(GtkRadioMenuItem *, GObject *);
@@ -137,7 +137,7 @@ void update_debug_menu_items(GObject *, gboolean);
/* Réagit au changement d'onglet d'un panneau quelconque. */
-static void on_dock_item_switch(GtkDockPanel *, GtkDockItem *, GObject *);
+static void on_dock_item_switch(GtkDockPanel *, GDockItem *, GObject *);
/* Met en concordance les menus avec l'édition courante. */
static void refresh_editor_menus(GObject *, GOpenidaBinary *, GtkBinView *);
@@ -192,7 +192,7 @@ GtkWidget *create_editor(void)
GtkWidget *dpanel; /* Support de panneaux */
- GtkDockItem *ditem; /* Panneau avec ses infos. */
+ GDockItem *ditem; /* Panneau avec ses infos. */
#if 0
@@ -400,7 +400,7 @@ GtkWidget *create_editor(void)
//gtk_paned_pack1 (GTK_PANED (hpaned1), scrolledwindow2, FALSE, TRUE);
- ditem = gtk_dock_item_new(_("Binary code"), scrolledwindow2);
+ ditem = g_dock_item_new(_("Binary code"), scrolledwindow2);
gtk_dock_panel_add_item(dpanel, ditem);
@@ -455,7 +455,7 @@ GtkWidget *create_editor(void)
place_all_panels_in_editor(dpanel);
- ditem = gtk_dock_item_new(_("Registers"), get_panel(PNT_REGISTERS));
+ ditem = g_dock_item_new(_("Registers"), get_panel(PNT_REGISTERS));
gtk_dock_panel_add_item(dpanel, ditem);
@@ -472,17 +472,17 @@ GtkWidget *create_editor(void)
gtk_paned_pack2(GTK_PANED(vpaned1), dpanel, FALSE, FALSE);
- ditem = gtk_dock_item_new(_("Messages"), get_panel(PNT_LOG));
+ ditem = g_dock_item_new(_("Messages"), get_panel(PNT_LOG));
gtk_dock_panel_add_item(dpanel, ditem);
- ditem = gtk_dock_item_new(_("Strings"), get_panel(PNT_STRINGS));
+ ditem = g_dock_item_new(_("Strings"), get_panel(PNT_STRINGS));
gtk_dock_panel_add_item(dpanel, ditem);
panel = build_shell_panel(G_OBJECT(result));
- ditem = gtk_dock_item_new(_("Shell"), panel);
+ ditem = g_dock_item_new(_("Shell"), panel);
gtk_dock_panel_add_item(dpanel, ditem);
@@ -555,6 +555,8 @@ GtkWidget *create_editor(void)
void destroy_editor(GtkWidget *widget, gpointer data)
{
+ close_openida_project(get_current_openida_project());
+
gtk_main_quit();
}
@@ -716,7 +718,7 @@ void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer data)
/******************************************************************************
* *
* Paramètres : menuitem = élément de menu sélectionné. *
-* data = adresse de l'espace de référencement global. *
+* ref = adresse de l'espace de référencement global. *
* *
* Description : Charge un projet récent et met à jour la liste. *
* *
@@ -726,17 +728,20 @@ void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer data)
* *
******************************************************************************/
-void mcb_open_recent_project(GtkMenuItem *menuitem, gpointer data)
+void mcb_open_recent_project(GtkMenuItem *menuitem, GObject *ref)
{
const gchar *caption; /* Etiquette du menu */
openida_project *project; /* Nouveau projet chargé */
caption = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))));
- project = NULL/*load_openida_project_from_xml(caption)*/;
+ project = g_openida_project_new_from_xml(ref, caption);
if (project != NULL)
{
+ push_openida_project_into_recent_list(project);
+ load_recent_openida_projects_list(ref, G_CALLBACK(mcb_open_recent_project));
+
set_current_openida_project(project);
/* TODO ... */
@@ -767,9 +772,7 @@ void mcb_view_change_support(GtkRadioMenuItem *menuitem, GObject *ref)
GOpenidaBinary *binary; /* Edition courante */
GtkBinView *binview; /* Afficheur effectif de code */
GtkWidget *panel; /* Nouveau support à utiliser */
- GtkDockPanel *dpanel; /* Support de panneaux */
- char *title; /* Titre associé au binaire */
- GtkDockItem *ditem; /* Panneau avec ses infos. */
+ GDockItem *ditem; /* Panneau avec ses infos. */
/* On ne traite qu'une seule fois ! */
if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return;
@@ -787,12 +790,9 @@ void mcb_view_change_support(GtkRadioMenuItem *menuitem, GObject *ref)
g_object_set_data(ref, "binview", binview);
- dpanel = GTK_DOCK_PANEL(g_object_get_data(ref, "binpanel"));
-
- title = g_openida_binary_to_string(binary);
- ditem = gtk_dock_panel_item_from_name(dpanel, strrchr(title, '/') + 1);
+ ditem = gtk_dock_panel_get_item_from_binary(get_current_openida_project(), binary);
- gtk_dock_item_set_panel(ditem, panel);
+ g_dock_item_set_panel(ditem, panel);
notify_panels_of_view_change(binview, true);
@@ -1255,12 +1255,12 @@ void update_debug_menu_items(GObject *ref, gboolean stopped)
* *
******************************************************************************/
-static void on_dock_item_switch(GtkDockPanel *panel, GtkDockItem *item, GObject *ref)
+static void on_dock_item_switch(GtkDockPanel *panel, GDockItem *item, GObject *ref)
{
GtkWidget *widget; /* Support réel à traiter */
GOpenidaBinary *binary; /* Binaire en cours d'édition */
- widget = gtk_dock_item_get_panel(item);
+ widget = g_dock_item_get_panel(item);
if (GTK_IS_SCROLLED_WINDOW(widget))
widget = gtk_bin_get_child(GTK_BIN(widget));
diff --git a/src/gtkext/gtkdockitem.c b/src/gtkext/gtkdockitem.c
index 89d606c..51d1cc7 100644
--- a/src/gtkext/gtkdockitem.c
+++ b/src/gtkext/gtkdockitem.c
@@ -28,14 +28,24 @@
-/* Détermine le type d'un panneau dockable. */
-G_DEFINE_TYPE(GtkDockItem, gtk_dock_item, GTK_TYPE_OBJECT)
+/* Procède à l'initialisation d'un panneau dockable. */
+static void g_dock_item_class_init(GDockItemClass *);
+
+/* Supprime toutes les références externes. */
+static void g_dock_item_class_dispose(GDockItem *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_dock_item_class_finalize(GDockItem *);
+/* Détermine le type d'un panneau dockable. */
+G_DEFINE_TYPE(GDockItem, g_dock_item, G_TYPE_OBJECT)
+
+
/******************************************************************************
* *
-* Paramètres : class = classe GTK à initialiser. *
+* Paramètres : klass = classe GTK à initialiser. *
* *
* Description : Procède à l'initialisation d'un panneau dockable. *
* *
@@ -45,12 +55,19 @@ G_DEFINE_TYPE(GtkDockItem, gtk_dock_item, GTK_TYPE_OBJECT)
* *
******************************************************************************/
-static void gtk_dock_item_class_init(GtkDockItemClass *class)
+static void g_dock_item_class_init(GDockItemClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = g_dock_item_class_dispose;
+ object->finalize = g_dock_item_class_finalize;
+
g_signal_new("content-changed",
- GTK_TYPE_DOCK_ITEM,
+ G_TYPE_DOCK_ITEM,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GtkDockItemClass, content_changed),
+ G_STRUCT_OFFSET(GDockItemClass, content_changed),
NULL, NULL,
g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, GTK_TYPE_WIDGET, GTK_TYPE_WIDGET);
@@ -60,6 +77,57 @@ static void gtk_dock_item_class_init(GtkDockItemClass *class)
/******************************************************************************
* *
+* Paramètres : ditem = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dock_item_class_dispose(GDockItem *ditem)
+{
+ gpointer obj_class; /* Classe parente */
+
+ gtk_widget_unref(ditem->panel);
+
+ obj_class = g_type_class_peek_parent(G_DOCK_ITEM_GET_CLASS(ditem));
+
+ G_OBJECT_CLASS(obj_class)->dispose(G_OBJECT(ditem));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : ditem = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dock_item_class_finalize(GDockItem *ditem)
+{
+ gpointer obj_class; /* Classe parente */
+
+ g_free(ditem->name);
+ g_free(ditem->desc);
+
+ obj_class = g_type_class_peek_parent(G_DOCK_ITEM_GET_CLASS(ditem));
+
+ G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(ditem));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : ditem = composant GTK à initialiser. *
* *
* Description : Procède à l'initialisation d'un panneau dockable. *
@@ -70,7 +138,7 @@ static void gtk_dock_item_class_init(GtkDockItemClass *class)
* *
******************************************************************************/
-static void gtk_dock_item_init(GtkDockItem *ditem)
+static void g_dock_item_init(GDockItem *ditem)
{
ditem->name = NULL;
@@ -92,14 +160,14 @@ static void gtk_dock_item_init(GtkDockItem *ditem)
* *
******************************************************************************/
-GtkDockItem *gtk_dock_item_new(const gchar *name, GtkWidget *panel)
+GDockItem *g_dock_item_new(const gchar *name, GtkWidget *panel)
{
- GtkDockItem *result; /* Composant à retourner */
+ GDockItem *result; /* Composant à retourner */
- result = g_object_new(GTK_TYPE_DOCK_ITEM, NULL);
+ result = g_object_new(G_TYPE_DOCK_ITEM, NULL);
- gtk_dock_item_set_name(result, name);
- gtk_dock_item_set_panel(result, panel);
+ g_dock_item_set_name(result, name);
+ g_dock_item_set_panel(result, panel);
return result;
@@ -119,7 +187,7 @@ GtkDockItem *gtk_dock_item_new(const gchar *name, GtkWidget *panel)
* *
******************************************************************************/
-void gtk_dock_item_set_name(GtkDockItem *ditem, const gchar *name)
+void g_dock_item_set_name(GDockItem *ditem, const gchar *name)
{
if (ditem->name != NULL)
g_free(ditem->name);
@@ -141,7 +209,7 @@ void gtk_dock_item_set_name(GtkDockItem *ditem, const gchar *name)
* *
******************************************************************************/
-const gchar *gtk_dock_item_get_name(GtkDockItem *ditem)
+const gchar *g_dock_item_get_name(GDockItem *ditem)
{
return ditem->name;
@@ -161,7 +229,7 @@ const gchar *gtk_dock_item_get_name(GtkDockItem *ditem)
* *
******************************************************************************/
-void gtk_dock_item_set_desc(GtkDockItem *ditem, const gchar *desc)
+void g_dock_item_set_desc(GDockItem *ditem, const gchar *desc)
{
if (ditem->desc != NULL)
g_free(ditem->desc);
@@ -183,14 +251,14 @@ void gtk_dock_item_set_desc(GtkDockItem *ditem, const gchar *desc)
* *
******************************************************************************/
-const gchar *gtk_dock_item_get_desc(GtkDockItem *ditem)
+const gchar *g_dock_item_get_desc(GDockItem *ditem)
{
const char *result; /* CHaîne à renvoyer */
result = ditem->desc;
if (result == NULL)
- result = gtk_dock_item_get_name(ditem);
+ result = g_dock_item_get_name(ditem);
return result;
@@ -210,7 +278,7 @@ const gchar *gtk_dock_item_get_desc(GtkDockItem *ditem)
* *
******************************************************************************/
-void gtk_dock_item_set_panel(GtkDockItem *ditem, GtkWidget *panel)
+void g_dock_item_set_panel(GDockItem *ditem, GtkWidget *panel)
{
GtkWidget *old; /* Ancien panneau remplacé */
@@ -240,7 +308,7 @@ void gtk_dock_item_set_panel(GtkDockItem *ditem, GtkWidget *panel)
* *
******************************************************************************/
-GtkWidget *gtk_dock_item_get_panel(GtkDockItem *ditem)
+GtkWidget *g_dock_item_get_panel(GDockItem *ditem)
{
return ditem->panel;
diff --git a/src/gtkext/gtkdockitem.h b/src/gtkext/gtkdockitem.h
index 851d8de..4e9d1ee 100644
--- a/src/gtkext/gtkdockitem.h
+++ b/src/gtkext/gtkdockitem.h
@@ -31,21 +31,29 @@
G_BEGIN_DECLS
-#define GTK_TYPE_DOCK_ITEM (gtk_dock_item_get_type())
-#define GTK_DOCK_ITEM(obj) GTK_CHECK_CAST(obj, gtk_dock_item_get_type (), GtkDockItem)
-#define GTK_DOCK_ITEM_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_dock_item_get_type(), GtkDockItemClass)
-#define GTK_IS_DOCK_ITEM(obj) GTK_CHECK_TYPE(obj, gtk_dock_item_get_type())
+#define G_TYPE_DOCK_ITEM g_dock_item_get_type()
+#define G_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dock_item_get_type(), GDockItem))
+#define G_IS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dock_item_get_type()))
+#define G_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DOCK_ITEM, GDockItemClass))
+#define G_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DOCK_ITEM))
+#define G_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DOCK_ITEM, GDockItemClass))
-typedef struct _GtkDockItem GtkDockItem;
-typedef struct _GtkDockItemClass GtkDockItemClass;
-struct _GtkDockItem
+
+
+typedef struct _GDockItem GDockItem;
+typedef struct _GDockItemClass GDockItemClass;
+
+
+
+
+struct _GDockItem
{
- GtkObject object; /* Présence obligatoire en 1er */
+ GObject parent; /* A laisser en premier */
gchar *name; /* Nom court pour titre */
gchar *desc; /* Nom long pour onglet */
@@ -54,40 +62,40 @@ struct _GtkDockItem
};
-struct _GtkDockItemClass
+struct _GDockItemClass
{
- GtkVBoxClass parent_class; /* Présence obligatoire en 1er */
+ GObjectClass parent; /* A laisser en premier */
/* Signaux */
- void (* content_changed) (GtkDockItem *, GtkWidget *, GtkWidget *);
+ void (* content_changed) (GDockItem *, GtkWidget *, GtkWidget *);
};
/* Détermine le type d'un panneau dockable. */
-GtkType gtk_dock_item_get_type(void);
+GtkType g_dock_item_get_type(void);
/* Crée une nouvelle mémorisation de panneau dockable. */
-GtkDockItem *gtk_dock_item_new(const gchar *, GtkWidget *);
+GDockItem *g_dock_item_new(const gchar *, GtkWidget *);
/* Change le nom du panneau dockable pour son onglet. */
-void gtk_dock_item_set_name(GtkDockItem *, const gchar *);
+void g_dock_item_set_name(GDockItem *, const gchar *);
/* Fournit le nom du panneau dockable pour son onglet. */
-const gchar *gtk_dock_item_get_name(GtkDockItem *);
+const gchar *g_dock_item_get_name(GDockItem *);
/* Change la description du panneau dockable pour son titre. */
-void gtk_dock_item_set_desc(GtkDockItem *, const gchar *);
+void g_dock_item_set_desc(GDockItem *, const gchar *);
/* Fournit la description du panneau dockable pour son titre. */
-const gchar *gtk_dock_item_get_desc(GtkDockItem *);
+const gchar *g_dock_item_get_desc(GDockItem *);
/* Change le panneau dockable associé à l'élément. */
-void gtk_dock_item_set_panel(GtkDockItem *, GtkWidget *);
+void g_dock_item_set_panel(GDockItem *, GtkWidget *);
/* Fournit le panneau dockable associé à l'élément. */
-GtkWidget *gtk_dock_item_get_panel(GtkDockItem *);
+GtkWidget *g_dock_item_get_panel(GDockItem *);
diff --git a/src/gtkext/gtkdockpanel.c b/src/gtkext/gtkdockpanel.c
index 1d9548f..3b74fbb 100644
--- a/src/gtkext/gtkdockpanel.c
+++ b/src/gtkext/gtkdockpanel.c
@@ -58,13 +58,13 @@ static void gtk_dock_panel_drag_end_cb(GtkDockPanel *, GdkDragContext *, gpointe
//static void gtk_dock_panel_drag_data_delete_cb(GtkDockPanel *, GdkDragContext *, gpointer);
/* Ajoute un paquet d'informations à la station dockable. */
-static void _gtk_dock_panel_add_item(GtkDockPanel *, GtkDockItem *, gint);
+static void _gtk_dock_panel_add_item(GtkDockPanel *, GDockItem *, gint);
/* Remplace le panneau d'un membre actuellement affiché. */
-static void on_dock_item_content_changed(GtkDockItem *, GtkWidget *, GtkWidget *, GtkDockPanel *);
+static void on_dock_item_content_changed(GDockItem *, GtkWidget *, GtkWidget *, GtkDockPanel *);
/* Supprime un paquet d'informations à la station dockable. */
-static void _gtk_dock_panel_remove_item(GtkDockPanel *, GtkDockItem *, GtkWidget *);
+static void _gtk_dock_panel_remove_item(GtkDockPanel *, GDockItem *, GtkWidget *);
/* Met à jour le titre du support de panneaux dockables. */
static gboolean gtk_dock_panel_update_title(GtkNotebook *, GtkNotebookPage *, guint, gpointer);
@@ -130,7 +130,7 @@ static void gtk_dock_panel_class_init(GtkDockPanelClass *class)
G_STRUCT_OFFSET(GtkDockPanelClass, switch_item),
NULL, NULL,
g_cclosure_user_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GTK_TYPE_DOCK_ITEM);
+ G_TYPE_NONE, 1, G_TYPE_DOCK_ITEM);
}
@@ -338,7 +338,7 @@ static gboolean gtk_dock_panel_drag_drop_cb(GtkDockPanel *dpanel, GdkDragContext
static void gtk_dock_panel_drag_data_received_cb(GtkDockPanel *dpanel, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint target, guint time, gpointer data)
{
- GtkDockItem *ditem; /* Elément transféré */
+ GDockItem *ditem; /* Elément transféré */
gboolean success; /* Bilan de l'opération */
success = FALSE;
@@ -347,7 +347,7 @@ static void gtk_dock_panel_drag_data_received_cb(GtkDockPanel *dpanel, GdkDragCo
switch (target)
{
case TARGET_DOCKITEM:
- success = (selection->length == sizeof(GtkDockItem *));
+ success = (selection->length == sizeof(GDockItem *));
printf(" ## DRAG DATA RCV ## %p\n", dpanel);
@@ -356,9 +356,9 @@ static void gtk_dock_panel_drag_data_received_cb(GtkDockPanel *dpanel, GdkDragCo
if (success)
{
- ditem = GTK_DOCK_ITEM(*((GtkDockItem **)selection->data));
+ ditem = G_DOCK_ITEM(*((GDockItem **)selection->data));
- printf(" :: get ? %p - %d\n", ditem, GTK_IS_DOCK_ITEM(ditem));
+ printf(" :: get ? %p - %d\n", ditem, G_IS_DOCK_ITEM(ditem));
gtk_dock_panel_remove_item(gtk_drag_get_source_widget(context), ditem);
gtk_dock_panel_add_item(dpanel, ditem);
@@ -480,7 +480,7 @@ static void gtk_dock_panel_drag_begin_cb(GtkDockPanel *dpanel, GdkDragContext *c
static void gtk_dock_panel_drag_data_get_cb(GtkDockPanel *dpanel, GdkDragContext *context, GtkSelectionData *selection, guint target, guint time, gpointer data)
{
gint current; /* Indice de l'onglet courant */
- GtkDockItem *ditem; /* Elément à transférer */
+ GDockItem *ditem; /* Elément à transférer */
switch (target)
{
@@ -490,14 +490,14 @@ static void gtk_dock_panel_drag_data_get_cb(GtkDockPanel *dpanel, GdkDragContext
current = gtk_notebook_get_current_page(dpanel->notebook);
- ditem = GTK_DOCK_ITEM(g_list_nth_data(dpanel->ditems, current));
+ ditem = G_DOCK_ITEM(g_list_nth_data(dpanel->ditems, current));
printf(" %d nth item is %p\n", current, ditem);
- printf(" :: set ? %p - %d\n", ditem, GTK_IS_DOCK_ITEM(ditem));
+ printf(" :: set ? %p - %d\n", ditem, G_IS_DOCK_ITEM(ditem));
gtk_selection_data_set(selection, selection->target,
- 32, (guchar *)&ditem, sizeof(GtkDockItem *));
+ 32, (guchar *)&ditem, sizeof(GDockItem *));
break;
@@ -540,9 +540,9 @@ static void gtk_dock_panel_drag_end_cb(GtkDockPanel *dpanel, GdkDragContext *con
* *
******************************************************************************/
-GtkDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *dpanel, const char *name)
+GDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *dpanel, const char *name)
{
- GtkDockItem *result; /* Trouvaille à remonter */
+ GDockItem *result; /* Trouvaille à remonter */
GList *iter; /* Boucle de parcours */
const char *tmp; /* Autre nom à consulter */
@@ -550,10 +550,10 @@ GtkDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *dpanel, const char *nam
for (iter = dpanel->ditems; iter != NULL && result == NULL; iter = g_list_next(iter))
{
- tmp = gtk_dock_item_get_name(GTK_DOCK_ITEM(iter->data));
+ tmp = g_dock_item_get_name(G_DOCK_ITEM(iter->data));
if (strcmp(name, tmp) == 0)
- result = GTK_DOCK_ITEM(iter->data);
+ result = G_DOCK_ITEM(iter->data);
}
@@ -575,7 +575,7 @@ GtkDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *dpanel, const char *nam
* *
******************************************************************************/
-void gtk_dock_panel_add_item(GtkDockPanel *dpanel, GtkDockItem *ditem)
+void gtk_dock_panel_add_item(GtkDockPanel *dpanel, GDockItem *ditem)
{
_gtk_dock_panel_add_item(dpanel, ditem, -1);
@@ -596,7 +596,7 @@ void gtk_dock_panel_add_item(GtkDockPanel *dpanel, GtkDockItem *ditem)
* *
******************************************************************************/
-static void _gtk_dock_panel_add_item(GtkDockPanel *dpanel, GtkDockItem *ditem, gint position)
+static void _gtk_dock_panel_add_item(GtkDockPanel *dpanel, GDockItem *ditem, gint position)
{
GtkWidget *label; /* Etiquette d'onglet */
@@ -604,10 +604,10 @@ static void _gtk_dock_panel_add_item(GtkDockPanel *dpanel, GtkDockItem *ditem, g
printf("[add %p to %p] list len :: %u\n", ditem, dpanel, g_list_length(dpanel->ditems));
- label = gtk_label_new(gtk_dock_item_get_name(ditem));
+ label = gtk_label_new(g_dock_item_get_name(ditem));
gtk_widget_show(label);
- gtk_notebook_insert_page(dpanel->notebook, gtk_dock_item_get_panel(ditem), label, position);
+ gtk_notebook_insert_page(dpanel->notebook, g_dock_item_get_panel(ditem), label, position);
gtk_notebook_set_show_tabs(dpanel->notebook, g_list_length(dpanel->ditems) > 1);
@@ -631,7 +631,7 @@ static void _gtk_dock_panel_add_item(GtkDockPanel *dpanel, GtkDockItem *ditem, g
* *
******************************************************************************/
-static void on_dock_item_content_changed(GtkDockItem *ditem, GtkWidget *old, GtkWidget *new, GtkDockPanel *dpanel)
+static void on_dock_item_content_changed(GDockItem *ditem, GtkWidget *old, GtkWidget *new, GtkDockPanel *dpanel)
{
gint position; /* Position de l'onglet à maj */
@@ -639,9 +639,13 @@ static void on_dock_item_content_changed(GtkDockItem *ditem, GtkWidget *old, Gtk
g_signal_handlers_disconnect_by_func(dpanel->notebook, G_CALLBACK(gtk_dock_panel_update_title), dpanel);
+ //g_object_ref(G_OBJECT(ditem));
+
_gtk_dock_panel_remove_item(dpanel, ditem, old);
_gtk_dock_panel_add_item(dpanel, ditem, position);
+ //g_object_unref(G_OBJECT(ditem));
+
gtk_notebook_set_current_page(dpanel->notebook, position);
g_signal_connect(dpanel->notebook, "switch-page", G_CALLBACK(gtk_dock_panel_update_title), dpanel);
@@ -663,7 +667,7 @@ static void on_dock_item_content_changed(GtkDockItem *ditem, GtkWidget *old, Gtk
* *
******************************************************************************/
-void gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GtkDockItem *ditem)
+void gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GDockItem *ditem)
{
gint pos; /* Position de l'élément visé */
@@ -675,11 +679,13 @@ void gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GtkDockItem *ditem)
printf("[rem %p from %p] list len :: %u\n", ditem, dpanel, g_list_length(dpanel->ditems));
- gtk_widget_ref(gtk_dock_item_get_panel(ditem));
- gtk_container_remove(GTK_CONTAINER(dpanel->notebook), gtk_dock_item_get_panel(ditem));
+ gtk_widget_ref(g_dock_item_get_panel(ditem));
+ gtk_container_remove(GTK_CONTAINER(dpanel->notebook), g_dock_item_get_panel(ditem));
//gtk_notebook_remove_page(dpanel->notebook, pos);
+ g_object_unref(G_OBJECT(ditem));
+
gtk_notebook_set_show_tabs(dpanel->notebook, g_list_length(dpanel->ditems) > 1);
}
@@ -699,7 +705,7 @@ void gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GtkDockItem *ditem)
* *
******************************************************************************/
-static void _gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GtkDockItem *ditem, GtkWidget *panel)
+static void _gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GDockItem *ditem, GtkWidget *panel)
{
gint pos; /* Position de l'élément visé */
@@ -738,7 +744,7 @@ static void _gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GtkDockItem *ditem
static gboolean gtk_dock_panel_update_title(GtkNotebook *notebook, GtkNotebookPage *page, guint index, gpointer data)
{
- GtkDockItem *ditem; /* Elément nouvellement actif */
+ GDockItem *ditem; /* Elément nouvellement actif */
const gchar *desc; /* Description à afficher */
char *str; /* Valeur finale reconstituée */
@@ -751,9 +757,9 @@ static gboolean gtk_dock_panel_update_title(GtkNotebook *notebook, GtkNotebookPa
//printf(" >> index :: %u vs %d\n", index, gtk_notebook_get_current_page(GTK_DOCK_PANEL(data)->notebook));
- ditem = GTK_DOCK_ITEM(g_list_nth_data(GTK_DOCK_PANEL(data)->ditems, index));
+ ditem = G_DOCK_ITEM(g_list_nth_data(GTK_DOCK_PANEL(data)->ditems, index));
- desc = gtk_dock_item_get_desc(ditem);
+ desc = g_dock_item_get_desc(ditem);
str = calloc(strlen("<b>") + strlen(desc) + strlen("</b>") + 1, sizeof(char));
diff --git a/src/gtkext/gtkdockpanel.h b/src/gtkext/gtkdockpanel.h
index 2c0cda9..250d6bf 100644
--- a/src/gtkext/gtkdockpanel.h
+++ b/src/gtkext/gtkdockpanel.h
@@ -68,7 +68,7 @@ struct _GtkDockPanelClass
/* Signaux */
- void (* switch_item) (GtkDockPanel *, GtkDockItem *);
+ void (* switch_item) (GtkDockPanel *, GDockItem *);
};
@@ -80,13 +80,13 @@ GtkType gtk_dock_panel_get_type(void);
GtkWidget *gtk_dock_panel_new(void);
/* Retrouve un membre du panneau d'après son nom. */
-GtkDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *, const char *);
+GDockItem *gtk_dock_panel_item_from_name(GtkDockPanel *, const char *);
/* Ajoute un paquet d'informations à la station dockable. */
-void gtk_dock_panel_add_item(GtkDockPanel *, GtkDockItem *);
+void gtk_dock_panel_add_item(GtkDockPanel *, GDockItem *);
/* Supprime un paquet d'informations à la station dockable. */
-void gtk_dock_panel_remove_item(GtkDockPanel *, GtkDockItem *);
+void gtk_dock_panel_remove_item(GtkDockPanel *, GDockItem *);
diff --git a/src/panels/panel.c b/src/panels/panel.c
index 6258de8..9cf3f98 100644
--- a/src/panels/panel.c
+++ b/src/panels/panel.c
@@ -167,11 +167,11 @@ void init_internal_panels(void)
void place_all_panels_in_editor(GtkWidget *top)
{
GEditorPanel *iter; /* Boucle de parcours */
- GtkDockItem *ditem; /* Panneau avec ses infos. */
+ GDockItem *ditem; /* Panneau avec ses infos. */
panels_list_for_each(iter, panels_list)
{
- ditem = gtk_dock_item_new(iter->name, iter->widget);
+ ditem = g_dock_item_new(iter->name, iter->widget);
gtk_dock_panel_add_item(GTK_DOCK_PANEL(top), ditem);
}
diff --git a/src/panels/registers.c b/src/panels/registers.c
index 1f9c8e5..6480404 100644
--- a/src/panels/registers.c
+++ b/src/panels/registers.c
@@ -95,7 +95,8 @@ GtkWidget *build_registers_panel(void)
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
- gtk_container_add (GTK_CONTAINER (result), vbox1);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(result), vbox1);
+
label1 = gtk_label_new (_("Registers:"));
gtk_widget_show (label1);
diff --git a/src/project.c b/src/project.c
index 14261f3..6403b18 100644
--- a/src/project.c
+++ b/src/project.c
@@ -69,7 +69,7 @@ GtkWidget *get_loaded_binary_view(const loaded_binary *, BinaryView);
/* Propriétés d'un ensemble de fichiers ouverts */
struct openida_project
{
- GObject* ref; /* Espace de référencement */
+ GObject *ref; /* Espace de référencement */
char *filename; /* Lieu d'enregistrement */
@@ -319,6 +319,8 @@ openida_project *g_openida_project_new_from_xml(GObject *ref, const char *filena
result = create_empty_openida_project(ref);
+ result->filename = strdup(filename);
+
/* Chargement des éléments binaires attachés */
xobject = get_node_xpath_object(context, "/OpenIDAProject/Binaries/Binary");
@@ -430,8 +432,16 @@ bool g_openida_project_save(openida_project *project, const char *filename)
void close_openida_project(openida_project *project)
{
+ size_t max; /* Nombre de binaires chargés */
+ size_t i; /* Boucle de parcours */
+
+ max = project->binaries_count;
+
+ for (i = 0; i < max; i++)
+ detach_binary_to_openida_project(project, project->binaries[0]->binary);
+ /* ... */
free(project);
@@ -509,21 +519,63 @@ size_t attach_binary_to_openida_project(openida_project *project, GOpenidaBinary
void detach_binary_to_openida_project(openida_project *project, GOpenidaBinary *binary)
{
-#if 0
+ GtkDockPanel *dpanel; /* Support de panneaux */
+ GDockItem *ditem; /* Support d'affichage utilisé */
size_t i; /* Boucle de parcours */
+ dpanel = GTK_DOCK_PANEL(g_object_get_data(project->ref, "binpanel"));
+ ditem = gtk_dock_panel_get_item_from_binary(project, binary);
+
+ gtk_dock_panel_remove_item(dpanel, ditem);
+
for (i = 0; i < project->binaries_count; i++)
- if (project->binaries[i] == binary) break;
+ if (project->binaries[i]->binary == binary) break;
if ((i + 1) < project->binaries_count)
- memmove(&project->binaries[i], &project->binaries[i + 1], (project->binaries_count - i - 1) * sizeof(GOpenidaBinary *));
+ memmove(&project->binaries[i], &project->binaries[i + 1], (project->binaries_count - i - 1) * sizeof(loaded_binary *));
+
+ project->binaries = (loaded_binary **)realloc(project->binaries,
+ --project->binaries_count * sizeof(loaded_binary *));
+
+}
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : project = projet à consulter. *
+* binary = binaire chargé et encadré. *
+* *
+* Description : Fournit le support d'affichage principal d'un binaire chargé.*
+* *
+* Retour : Composant GLib dédié à l'affichage principal. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDockItem *gtk_dock_panel_get_item_from_binary(const openida_project *project, GOpenidaBinary *binary)
+{
+ GDockItem *result; /* Panneau avec ses infos. */
+ GtkDockPanel *dpanel; /* Support de panneaux */
+ const char *title; /* Titre associé au binaire */
+
+ dpanel = GTK_DOCK_PANEL(g_object_get_data(project->ref, "binpanel"));
+
+ title = g_openida_binary_to_string(binary);
+ result = gtk_dock_panel_item_from_name(dpanel, strrchr(title, '/') + 1);
+
+ return result;
- project->binaries = (GOpenidaBinary **)realloc(project->binaries,
- --project->binaries_count * sizeof(GOpenidaBinary *));
-#endif
}
+
+
/******************************************************************************
* *
* Paramètres : project = projet à consulter. *
@@ -638,9 +690,32 @@ void push_openida_project_into_recent_list(const openida_project *project)
void pop_openida_project_from_recent_list(const openida_project *project)
{
+ configuration *config; /* Configuration principale */
+ unsigned int i; /* Boucle de parcours #1 */
+ const char *filename; /* Chemin d'un projet donné */
+ unsigned int k; /* Boucle de parcours #2 */
+ if (project->filename == NULL) return;
+ config = get_main_configuration();
+ for (i = MPT_RECENT_PROJECT_1; i <= MPT_RECENT_PROJECT_7; i++)
+ {
+ filename = get_string_config_value(config, i);
+
+ if (filename == NULL || strcmp(filename, project->filename) == 0)
+ {
+ for (k = i; k <= MPT_RECENT_PROJECT_6; k++)
+ {
+ filename = get_string_config_value(config, k + 1);
+ set_string_config_value(config, k, filename);
+ }
+
+ set_string_config_value(config, k, NULL);
+
+ }
+
+ }
}
@@ -673,6 +748,8 @@ void load_recent_openida_projects_list(GObject *ref, GCallback func)
menuitem = GTK_WIDGET(g_object_get_data(ref, "menu_recent_prjs"));
menubar = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
+ gtk_container_foreach(GTK_CONTAINER(menubar), G_CALLBACK(gtk_widget_destroy), NULL);
+
config = get_main_configuration();
for (i = MPT_RECENT_PROJECT_1; i <= MPT_RECENT_PROJECT_7; i++)
@@ -714,7 +791,7 @@ void display_openida_project(const openida_project *project, GObject *ref)
size_t i; /* Boucle de parcours */
GOpenidaBinary *binary;
GtkWidget *view; /* Affichage du code binaire */
- GtkDockItem *ditem; /* Panneau avec ses infos. */
+ GDockItem *ditem; /* Panneau avec ses infos. */
GtkBinView *binview; /* Affichage à faire défiler */
dpanel = GTK_DOCK_PANEL(g_object_get_data(ref, "binpanel"));
@@ -725,7 +802,7 @@ void display_openida_project(const openida_project *project, GObject *ref)
view = get_loaded_binary_view(project->binaries[i], BVW_BLOCK);
- ditem = gtk_dock_item_new(g_openida_binary_to_string(binary), view);
+ ditem = g_dock_item_new(g_openida_binary_to_string(binary), view);
gtk_dock_panel_add_item(dpanel, ditem);
}
@@ -752,7 +829,7 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje
GtkDockPanel *dpanel; /* Support de panneaux */
GtkWidget *view; /* Affichage du code binaire */
char *title; /* Titre associé au binaire */
- GtkDockItem *ditem; /* Panneau avec ses infos. */
+ GDockItem *ditem; /* Panneau avec ses infos. */
GtkBinView *binview; /* Affichage à faire défiler */
index = attach_binary_to_openida_project(project, binary);
@@ -765,8 +842,8 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje
gdk_threads_enter();
- ditem = gtk_dock_item_new(strrchr(title, '/') + 1, view);
- gtk_dock_item_set_desc(ditem, title);
+ ditem = g_dock_item_new(strrchr(title, '/') + 1, view);
+ g_dock_item_set_desc(ditem, title);
gtk_dock_panel_add_item(dpanel, ditem);
gdk_flush ();
diff --git a/src/project.h b/src/project.h
index cf4c9e2..da05aeb 100644
--- a/src/project.h
+++ b/src/project.h
@@ -30,6 +30,7 @@
#include "analysis/binary.h"
#include "gtkext/gtkbinview.h"
+#include "gtkext/gtkdockitem.h"
@@ -81,6 +82,9 @@ size_t attach_binary_to_openida_project(openida_project *, GOpenidaBinary *);
/* Détache un fichier donné à un projet donné. */
void detach_binary_to_openida_project(openida_project *, GOpenidaBinary *);
+/* Fournit le support d'affichage principal d'un binaire chargé. */
+GDockItem *gtk_dock_panel_get_item_from_binary(const openida_project *, GOpenidaBinary *);
+
/* Fournit un support d'affichage donné pour un binaire chargé. */
GtkWidget *get_view_for_openida_project_binary(const openida_project *, const GOpenidaBinary *, BinaryView, GtkBinView **);