summaryrefslogtreecommitdiff
path: root/src/project.c
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/project.c
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/project.c')
-rw-r--r--src/project.c101
1 files changed, 89 insertions, 12 deletions
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 ();