summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/editor.c96
-rw-r--r--src/gui/menus/file.c3
2 files changed, 85 insertions, 14 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 39fd13b..16b7a59 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -132,6 +132,8 @@ static gboolean scroll_for_the_first_time(GtkWidget *, GdkEvent *, GLoadedConten
/* Affiche le contenu qui vient de rejoindre un projet donné. */
void on_editor_loaded_content_added(GStudyProject *, GLoadedContent *, void *);
+/* Recherche et retirer de l'affichage un contenu chargé. */
+static void remove_loaded_content_from_editor(GtkWidget *, GLoadedContent *);
@@ -893,32 +895,39 @@ static void on_dock_close_request(GtkDockStation *station, GtkWidget *button, gp
static void notify_editor_project_change(GStudyProject *project, bool new)
{
+ GLoadedContent **contents; /* Contenus chargés à traiter */
+ size_t count; /* Quantité de ces contenus */
+ size_t i; /* Boucle de parcours */
+ GtkContainer *root; /* Racine des panneaux */
- if (new)
- {
+ g_study_project_lock_contents(project);
+ contents = _g_study_project_get_contents(project, &count);
+ if (new)
g_signal_connect_to_main(project, "content-added", G_CALLBACK(on_editor_loaded_content_added), NULL,
- g_cclosure_marshal_VOID__OBJECT);
-
-
-
+ g_cclosure_marshal_VOID__OBJECT);
- /* TODO : show_all()... */
+ g_study_project_unlock_contents(project);
+ if (new)
+ {
+ for (i = 0; i < count; i++)
+ on_editor_loaded_content_added(project, contents[i], NULL);
}
else
{
+ root = GTK_CONTAINER(get_tiled_grid());
- g_study_project_hide(project);
-
-
+ for (i = 0; i < count; i++)
+ gtk_container_foreach(root, (GtkCallback)remove_loaded_content_from_editor, contents[i]);
}
-
+ if (contents != NULL)
+ free(contents);
}
@@ -1000,3 +1009,68 @@ static gboolean scroll_for_the_first_time(GtkWidget *widget, GdkEvent *event, GL
return FALSE;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant d'affichage nouvellement porté à l'écran.*
+* content = contenu chargé associé à un composant d'affichage. *
+* *
+* Description : Recherche et retirer de l'affichage un contenu chargé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void remove_loaded_content_from_editor(GtkWidget *widget, GLoadedContent *content)
+{
+ GtkNotebook *notebook; /* Série d'onglets à considérer*/
+ gint count; /* Quantité de ces onglets */
+ gint i; /* Boucle de parcours */
+ GtkWidget *tab; /* Composant d'un onglet */
+ GPanelItem *panel; /* Panneau encapsulé */
+ GLoadedContent *loaded; /* Contenu chargé à comparer */
+ GtkWidget *built; /* Composant construit */
+
+ if (GTK_IS_DOCK_STATION(widget))
+ {
+ /**
+ * On considère qu'on est le seul à s'exécuter dans le thread d'affichage,
+ * et que donc aucun ajout ne peut venir modifier la constitution des
+ * onglets en cours de parcours !
+ */
+
+ notebook = GTK_NOTEBOOK(widget);
+
+ count = gtk_notebook_get_n_pages(notebook);
+
+ for (i = 0; i < count; i++)
+ {
+ tab = gtk_notebook_get_nth_page(notebook, i);
+
+ panel = G_PANEL_ITEM(g_object_get_data(G_OBJECT(tab), "dockable"));
+
+ if (gtk_panel_item_get_personality(panel) != PIP_BINARY_VIEW)
+ continue;
+
+ built = get_loaded_panel_from_built_view(tab);
+
+ assert(G_IS_LOADED_PANEL(built));
+
+ loaded = g_loaded_panel_get_content(G_LOADED_PANEL(built));
+
+ if (loaded == content)
+ g_panel_item_undock(panel);
+
+ g_object_unref(G_OBJECT(loaded));
+
+ }
+
+ }
+
+ else if (GTK_IS_CONTAINER(widget))
+ gtk_container_foreach(GTK_CONTAINER(widget), (GtkCallback)remove_loaded_content_from_editor, content);
+
+}
diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c
index 41b17e1..d9232db 100644
--- a/src/gui/menus/file.c
+++ b/src/gui/menus/file.c
@@ -146,8 +146,6 @@ static void mcb_file_new_project(GtkMenuItem *menuitem, gpointer unused)
set_current_project(project);
- g_study_project_display(project);
-
}
@@ -193,7 +191,6 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, gpointer unused)
if (project != NULL)
{
set_current_project(project);
- g_study_project_display(project);
push_project_into_recent_list(project);
}