summaryrefslogtreecommitdiff
path: root/src/gui/editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/editor.c')
-rw-r--r--src/gui/editor.c109
1 files changed, 84 insertions, 25 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 926201a..3723bd8 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -39,6 +39,7 @@
#include "core/core.h"
#include "core/panels.h"
#include "panels/panel.h"
+#include "panels/welcome.h"
#include "tb/portions.h"
#include "tb/source.h"
#include "../analysis/project.h"
@@ -158,7 +159,7 @@ static void update_path_of_paned_nodes(panel_node *, const char *, const char *)
static size_t compute_path_common_length(const panel_node *, const char *);
/* Place au bon endroit un panneau donné. */
-static void insert_item_as_panel_node(GPanelItem *, panel_node *, const char *, size_t);
+static panel_node *insert_item_as_panel_node(GPanelItem *, panel_node *, const char *, size_t);
/* Tente de mettre la main sur une station d'accueil. */
static panel_node *find_node_for_station(panel_node *, GtkWidget *);
@@ -788,18 +789,18 @@ static size_t compute_path_common_length(const panel_node *node, const char *tar
* *
* Description : Place au bon endroit un panneau donné. *
* *
-* Retour : - *
+* Retour : Noeud final inséré dans la liste. *
* *
* Remarques : - *
* *
******************************************************************************/
-static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const char *path, size_t consumed)
+static panel_node *insert_item_as_panel_node(GPanelItem *item, panel_node *node, const char *path, size_t consumed)
{
+ panel_node *result; /* Noeud ultime à renvoyer */
char div; /* Division demandée */
bool horiz; /* Traduction en composant */
bool first; /* Point d'insertion */
- panel_node *new; /* Nouveau noeud créé */
size_t common1; /* Tron common avec le côté #1 */
size_t common2; /* Tron common avec le côté #2 */
@@ -813,7 +814,10 @@ static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const
{
/* Le parcours s'arrête ici ! */
if (strcmp(node->path, path) == 0)
+ {
gtk_dock_station_add_dockable(GTK_DOCK_STATION(node->station), GTK_DOCKABLE(item));
+ result = node;
+ }
/* On ne peut aller plus loin, on doit diviser... */
else
@@ -828,9 +832,9 @@ static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const
switch_panel_node_into_paned(node, horiz, !first);
- new = create_simple_panel_node_for_item(item, path);
+ result = create_simple_panel_node_for_item(item, path);
- attach_panel_node_to_paned(node, new, first);
+ attach_panel_node_to_paned(node, result, first);
fprintf(stderr, "1# [%p] widget = %p --- split :: %p // %p\n",
@@ -857,10 +861,10 @@ static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const
if (common1 > 0 || common2 > 0)
{
if (common1 > common2)
- insert_item_as_panel_node(item, node->first, path, common1);
+ result = insert_item_as_panel_node(item, node->first, path, common1);
else
- insert_item_as_panel_node(item, node->second, path, common2);
+ result = insert_item_as_panel_node(item, node->second, path, common2);
}
@@ -875,9 +879,9 @@ static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const
switch_panel_node_into_paned(node, horiz, !first);
- new = create_simple_panel_node_for_item(item, path);
+ result = create_simple_panel_node_for_item(item, path);
- attach_panel_node_to_paned(node, new, first);
+ attach_panel_node_to_paned(node, result, first);
fprintf(stderr, "2# [%p] split :: %p-%p // %p-%p\n", node,
@@ -888,6 +892,8 @@ static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const
}
+ return result;
+
}
@@ -1047,7 +1053,7 @@ static void delete_panel_node(panel_node *node)
/******************************************************************************
* *
-* Paramètres : item = composant à retirer de l'affichage. *
+* Paramètres : panel = composant à placer dans l'affichage. *
* unused = adresse non utilisée ici. *
* *
* Description : Réagit à une demande de placement d'un panneau d'affichage. *
@@ -1058,28 +1064,53 @@ static void delete_panel_node(panel_node *node)
* *
******************************************************************************/
-void on_panel_item_dock_request(GPanelItem *item, void *unused)
+void on_panel_item_dock_request(GPanelItem *panel, void *unused)
{
const char *path; /* Chemin d'accès */
+ panel_node *node; /* Noeud à supprimer */
+ const char *name; /* Nom du dernier panneau */
+ GPanelItem *welcome; /* Panneau d'accueil */
- path = gtk_panel_item_get_path(item);
+ path = gtk_panel_item_get_path(panel);
/* Tout est à faire... */
if (_nodes == NULL)
{
- _nodes = create_simple_panel_node_for_item(item, path);
+ _nodes = create_simple_panel_node_for_item(panel, path);
gtk_container_add(GTK_CONTAINER(_support), _nodes->widget);
}
- else insert_item_as_panel_node(item, _nodes, path, 0);
+ else
+ {
+ node = insert_item_as_panel_node(panel, _nodes, path, 0);
+
+ if (strncmp(node->path, "N", 1) == 0)
+ {
+ name = g_editor_item_get_name(G_EDITOR_ITEM(panel));
+
+ if (strcmp(name, PANEL_WELCOME_ID) != 0)
+ {
+ welcome = get_panel_item_by_name(PANEL_WELCOME_ID);
+
+ if (!g_welcome_panel_get_user_origin(G_WELCOME_PANEL(welcome)))
+ {
+ /* Equivalent d'un appel "g_panel_item_undock(welcome)", avec effet immédiat */
+ on_panel_item_undock_request(welcome, NULL);
+ }
+
+ }
+
+ }
+
+ }
- g_panel_item_set_dock_status(item, true);
+ g_panel_item_set_dock_status(panel, true);
}
/******************************************************************************
* *
-* Paramètres : item = composant à retirer de l'affichage. *
+* Paramètres : panel = composant à retirer de l'affichage. *
* unused = adresse non utilisée ici. *
* *
* Description : Réagit à une demande de suppression d'un panneau d'affichage.*
@@ -1090,25 +1121,53 @@ void on_panel_item_dock_request(GPanelItem *item, void *unused)
* *
******************************************************************************/
-void on_panel_item_undock_request(GPanelItem *item, void *unused)
+void on_panel_item_undock_request(GPanelItem *panel, void *unused)
{
GtkWidget *station; /* Support courant */
+ GtkNotebook *notebook; /* Version parente de station */
panel_node *node; /* Noeud à supprimer */
+ bool allowed; /* Fermture permise ? */
+ const char *name; /* Nom du dernier panneau */
+ GPanelItem *welcome; /* Panneau d'accueil */
+
+ gtk_dockable_decompose(GTK_DOCKABLE(panel), &station);
+
+ notebook = GTK_NOTEBOOK(station);
- gtk_dockable_decompose(GTK_DOCKABLE(item), &station);
+ node = find_node_for_station(_nodes, station);
+ assert(node != NULL);
- gtk_dock_station_remove_dockable(GTK_DOCK_STATION(station), GTK_DOCKABLE(item));
+ allowed = true;
- if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(station)) == 0)
+ if (strcmp(node->path, "N") == 0 && gtk_notebook_get_n_pages(notebook) == 1)
{
- node = find_node_for_station(_nodes, station);
- assert(node != NULL);
+ name = g_editor_item_get_name(G_EDITOR_ITEM(panel));
+
+ if (strcmp(name, PANEL_WELCOME_ID) == 0)
+ allowed = false;
+
+ else
+ {
+ welcome = get_panel_item_by_name(PANEL_WELCOME_ID);
+ g_welcome_panel_set_user_origin(G_WELCOME_PANEL(welcome), false);
+
+ /* Equivalent d'un appel "g_panel_item_dock(welcome)", avec effet immédiat */
+ on_panel_item_dock_request(welcome, NULL);
- delete_panel_node(node);
+ }
}
- g_panel_item_set_dock_status(item, false);
+ if (allowed)
+ {
+ gtk_dock_station_remove_dockable(GTK_DOCK_STATION(station), GTK_DOCKABLE(panel));
+
+ if (gtk_notebook_get_n_pages(notebook) == 0)
+ delete_panel_node(node);
+
+ g_panel_item_set_dock_status(panel, false);
+
+ }
}