diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-04-01 11:44:00 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-04-01 11:44:00 (GMT) |
commit | c989181c56ff97d2c4918c0e9028762a1ed46623 (patch) | |
tree | 24a413f71c65d90994e435bf86f5c85ab732a244 /src/project.c | |
parent | a174ee784f5d9e554ed09181b8e6d8c0205f8ef5 (diff) |
Moved all the File menu entries in the GUI menu.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@242 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/project.c')
-rw-r--r-- | src/project.c | 103 |
1 files changed, 57 insertions, 46 deletions
diff --git a/src/project.c b/src/project.c index 47bbe3e..245bac4 100644 --- a/src/project.c +++ b/src/project.c @@ -49,6 +49,8 @@ typedef struct _loaded_binary GtkViewPanel *views[BVW_COUNT]; /* Composants pour l'affichage */ GtkWidget *scrollwindows[BVW_COUNT]; /* Supports pour l'affichage */ + GEditorItem *item; /* Support d'affichage final */ + } loaded_binary; @@ -80,6 +82,9 @@ static void g_study_project_class_init(GStudyProjectClass *); /*Initialise une instance de projet d'étude. */ static void g_study_project_init(GStudyProject *); +/* Supprime de l'écran un projet en place. */ +static void g_study_project_hide(const GStudyProject *); + /* ---------------------------------------------------------------------------------- */ @@ -313,20 +318,10 @@ const char *g_study_project_get_filename(const GStudyProject *project) void g_study_project_add_loaded_binary(GOpenidaBinary *binary, GStudyProject *project) { size_t index; /* Indice du nouveau binaire */ - GtkWidget *view; /* Affichage du code binaire */ - const char *title; /* Titre associé au binaire */ - GEditorItem *item; /* Panneau avec ses infos. */ index = g_study_project_attach_binary(project, binary); - view = project->binaries[index]->scrollwindows[BVW_BLOCK]; - - title = g_openida_binary_to_string(binary); - - //gdk_threads_enter(); - - item = g_panel_item_new(strrchr(title, G_DIR_SEPARATOR) + 1, title, view, "M"); - g_panel_item_dock(G_PANEL_ITEM(item)); + g_panel_item_dock(G_PANEL_ITEM(project->binaries[index]->item)); //gdk_flush (); //gdk_threads_leave(); @@ -353,7 +348,8 @@ size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *bin loaded_binary *loaded; /* Structure à renvoyer */ BinaryView i; /* Boucle de parcours */ GtkWidget *view; /* Affichage du binaire */ - GtkWidget *scrolledwindow; /* Surface d'exposition */ + GtkWidget *scroll; /* Surface d'exposition */ + const char *title; /* Titre associé au binaire */ loaded = (loaded_binary *)calloc(1, sizeof(loaded_binary)); @@ -395,13 +391,20 @@ size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *bin //gdk_threads_enter(); - scrolledwindow = qck_create_scrolled_window(NULL, NULL); - gtk_container_add(GTK_CONTAINER(scrolledwindow), view); + scroll = qck_create_scrolled_window(NULL, NULL); + gtk_container_add(GTK_CONTAINER(scroll), view); - loaded->scrollwindows[i] = scrolledwindow; + loaded->scrollwindows[i] = scroll; } + /* Support graphique final */ + + scroll = loaded->scrollwindows[BVW_BLOCK]; + title = g_openida_binary_to_string(binary); + + loaded->item = g_panel_item_new(strrchr(title, G_DIR_SEPARATOR) + 1, title, scroll, "M"); + /* Enregistrement dans le projet */ g_mutex_lock(project->mutex); @@ -511,22 +514,31 @@ GtkWidget *g_study_project_get_view_for_binary(const GStudyProject *project, con void g_study_project_display(const GStudyProject *project) { size_t i; /* Boucle de parcours */ - GOpenidaBinary *binary; /* Binaire chargé */ - GtkWidget *scroll; /* Affichage du code binaire */ - const char *title; /* Titre associé au binaire */ - GEditorItem *item; /* Panneau avec ses infos. */ for (i = 0; i < project->binaries_count; i++) - { - binary = project->binaries[i]->binary; + g_panel_item_dock(G_PANEL_ITEM(project->binaries[i]->item)); - scroll = project->binaries[i]->scrollwindows[BVW_BLOCK]; - title = g_openida_binary_to_string(binary); +} - item = g_panel_item_new(strrchr(title, G_DIR_SEPARATOR) + 1, title, scroll, "M"); - g_panel_item_dock(G_PANEL_ITEM(item)); - } +/****************************************************************************** +* * +* Paramètres : project = projet dont le contenu est à cacher. * +* * +* Description : Supprime de l'écran un projet en place. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_study_project_hide(const GStudyProject *project) +{ + size_t i; /* Boucle de parcours */ + + for (i = 0; i < project->binaries_count; i++) + g_panel_item_undock(G_PANEL_ITEM(project->binaries[i]->item)); } @@ -586,8 +598,14 @@ GStudyProject *_get_current_study_project(GStudyProject *project) if (project != NULL) { - if (result != NULL) g_object_unref(G_OBJECT(result)); + if (result != NULL) + { + g_study_project_hide(result); + g_object_unref(G_OBJECT(result)); + } + result = project; + } return result; @@ -613,7 +631,7 @@ GtkRecentManager *get_projects_manager(void) if (result == NULL) { - result = gtk_recent_manager_new(); + result = gtk_recent_manager_get_default(); //gtk_recent_manager_purge_items(result, NULL); } @@ -637,34 +655,27 @@ GtkRecentManager *get_projects_manager(void) void push_project_into_recent_list(const GStudyProject *project) { GtkRecentManager *manager; /* Gestionnaire global */ - GtkRecentData *recent; /* Données complètes */ - - - + char *qualified; /* Chemin avec 'file://' */ + GtkRecentData recent; /* Données complètes */ if (project->filename == NULL) return; manager = get_projects_manager(); - /* Recherche un éventuel vestige à remplacer */ - - - - - + qualified = (char *)calloc(strlen("file://") + strlen(project->filename) + 1, sizeof(char)); + strcpy(qualified, "file://"); + strcat(qualified, project->filename); - /* Inscrit le projet dans l'actualité */ + memset(&recent, 0, sizeof(GtkRecentData)); - recent = g_slice_new0(GtkRecentData); + recent.mime_type = "application/chrysalide.project"; + recent.app_name = "Chrysalide"; + recent.app_exec = "chrysalide %f"; - recent->display_name = project->filename; - recent->mime_type = "application/chrysalide.project"; - recent->mime_type = "plain/text"; - recent->app_name = "chrysalide"; - recent->app_exec = "chrysalide %s"; + gtk_recent_manager_add_full(manager, qualified, &recent); - gtk_recent_manager_add_full(manager, project->filename, recent); + free(qualified); } |