summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-03-11 23:55:50 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-03-11 23:55:50 (GMT)
commit491e9837f33831f94747a6063f709ba2c5d2703e (patch)
tree5878c875e308307849d75e85140ef1e71c94b7d4 /src/gui
parentdc8a2b19dbb32bfe49b1ff6640cc609238b392ca (diff)
Handled user actions on the dock station buttons.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/editor.c292
-rw-r--r--src/gui/panels/panel.c39
-rw-r--r--src/gui/panels/panel.h3
3 files changed, 248 insertions, 86 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c
index fdf253f..e5ec4d7 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -27,6 +27,8 @@
#include <assert.h>
#include <ctype.h>
+#include <malloc.h>
+#include <string.h>
#include <i18n.h>
@@ -35,6 +37,7 @@
#include "status.h"
#include "menus/menubar.h"
#include "core/core.h"
+#include "core/panels.h"
#include "panels/panel.h"
#include "tb/portions.h"
#include "tb/source.h"
@@ -50,6 +53,13 @@
+
+
+/* Gestion des raccourcis clavier */
+static GtkAccelGroup *_accgroup = NULL;
+
+
+
/* Met en place la liste des icônes de l'éditeur. */
static GList *build_editor_icons_list(void);
@@ -68,10 +78,6 @@ static void on_destroy_editor(GtkWidget *, gpointer);
-/* Réagit au changement d'onglet d'un panneau quelconque. */
-static void on_dock_item_switch(GtkDockStation *, GtkWidget *, GObject *);
-
-
@@ -172,6 +178,17 @@ void on_panel_item_dock_request(GPanelItem *, void *);
/* Réagit à une demande de suppression d'un panneau d'affichage. */
void on_panel_item_undock_request(GPanelItem *, void *);
+/* Réagit au changement d'onglet d'un panneau quelconque. */
+static void on_dock_item_switch(GtkDockStation *, GtkWidget *, GObject *);
+
+/* Réagit à une demande de menu pour rajouter des panneaux. */
+static void on_dock_menu_request(GtkDockStation *, GtkWidget *, GObject *);
+
+/* Réagit à une demande de fermeture du panneau courant. */
+static void on_dock_close_request(GtkDockStation *, GtkWidget *, GObject *);
+
+
+
@@ -239,8 +256,6 @@ GtkWidget *create_editor(void)
GtkWidget *vbox1;
- GtkAccelGroup *accgroup;
-
GtkWidget *widget; /* Composant à intégrer */
@@ -268,8 +283,8 @@ GtkWidget *create_editor(void)
ref = G_OBJECT(result);
- accgroup = gtk_accel_group_new();
- gtk_window_add_accel_group(GTK_WINDOW(result), accgroup);
+ _accgroup = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(result), _accgroup);
@@ -280,7 +295,7 @@ GtkWidget *create_editor(void)
/* Intégration des menus */
- editem = g_menu_bar_new(ref, accgroup);
+ editem = g_menu_bar_new(ref, _accgroup);
register_editor_item(editem);
menuboard = g_editor_item_get_widget(editem);
@@ -436,83 +451,6 @@ static void on_destroy_editor(GtkWidget *widget, gpointer data)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : station = panneau de support des éléments concerné. *
-* item = nouvel élément présenté à l'affichage. *
-* ref = adresse de l'espace de référencement global. *
-* *
-* Description : Réagit au changement d'onglet d'un panneau quelconque. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, GObject *ref)
-{
- GLoadedBinary *old_binary; /* Ancien binaire édité */
- GLoadedBinary *binary; /* Binaire en cours d'édition */
-
- if (GTK_IS_SCROLLED_WINDOW(widget))
- widget = gtk_bin_get_child(GTK_BIN(widget));
-
- if (GTK_IS_VIEWPORT(widget))
- widget = gtk_bin_get_child(GTK_BIN(widget));
-
- if (GTK_IS_VIEW_PANEL(widget))
- {
- /* Changement de binaire ? */
-
- old_binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary"));
- binary = gtk_view_panel_get_binary(GTK_VIEW_PANEL(widget));
-
- if (old_binary != binary)
- {
- //notify_panels_of_binary_change(binary);
- change_editor_items_current_binary(ref, binary);
- }
-
- change_editor_items_current_view(ref, GTK_VIEW_PANEL(widget));
-
- //notify_panels_of_view_change(GTK_VIEW_PANEL(widget), false);
-
- }
-
-}
-
-
-
-
-
-
-
-
-
-
/* ---------------------------------------------------------------------------------- */
/* INTEGRATION DE LA BARRE D'OUTILS */
/* ---------------------------------------------------------------------------------- */
@@ -595,6 +533,8 @@ static panel_node *create_simple_panel_node_for_item(GPanelItem *item, const cha
station = gtk_dock_station_new();
g_signal_connect(station, "switch-widget", G_CALLBACK(on_dock_item_switch), _global_ref);
+ g_signal_connect(station, "menu-requested", G_CALLBACK(on_dock_menu_request), _global_ref);
+ g_signal_connect(station, "close-requested", G_CALLBACK(on_dock_close_request), _global_ref);
gtk_widget_show(station);
gtk_dock_station_add_dockable(GTK_DOCK_STATION(station), GTK_DOCKABLE(item));
@@ -1220,3 +1160,183 @@ void on_panel_item_undock_request(GPanelItem *item, void *unused)
g_panel_item_set_dock_status(item, false);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : station = panneau de support des éléments concerné. *
+* item = nouvel élément présenté à l'affichage. *
+* ref = adresse de l'espace de référencement global. *
+* *
+* Description : Réagit au changement d'onglet d'un panneau quelconque. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, GObject *ref)
+{
+ GLoadedBinary *old_binary; /* Ancien binaire édité */
+ GLoadedBinary *binary; /* Binaire en cours d'édition */
+
+ if (GTK_IS_SCROLLED_WINDOW(widget))
+ widget = gtk_bin_get_child(GTK_BIN(widget));
+
+ if (GTK_IS_VIEWPORT(widget))
+ widget = gtk_bin_get_child(GTK_BIN(widget));
+
+ if (GTK_IS_VIEW_PANEL(widget))
+ {
+ /* Changement de binaire ? */
+
+ old_binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary"));
+ binary = gtk_view_panel_get_binary(GTK_VIEW_PANEL(widget));
+
+ if (old_binary != binary)
+ {
+ //notify_panels_of_binary_change(binary);
+ change_editor_items_current_binary(ref, binary);
+ }
+
+ change_editor_items_current_view(ref, GTK_VIEW_PANEL(widget));
+
+ //notify_panels_of_view_change(GTK_VIEW_PANEL(widget), false);
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : station = panneau de support des éléments concerné. *
+* button = bouton à l'origine de la procédure. *
+* ref = adresse de l'espace de référencement global. *
+* *
+* Description : Réagit à une demande de menu pour rajouter des panneaux. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void on_dock_menu_request(GtkDockStation *station, GtkWidget *button, GObject *ref)
+{
+ GtkWidget *active; /* Composant actif modèle */
+ GPanelItem *model; /* Panneau encapsulé */
+ GtkContainer *menu; /* Support à retourner */
+ GList *children; /* Composants mis en place */
+ GtkWidget *nopanel; /* Sous-élément de menu */
+
+ menu = GTK_CONTAINER(gtk_menu_new());
+
+ active = gtk_notebook_get_nth_page(GTK_NOTEBOOK(station), 0);
+
+ model = G_PANEL_ITEM(g_object_get_data(G_OBJECT(active), "dockable"));
+
+ g_object_set_data_full(G_OBJECT(menu), "path", strdup(gtk_panel_item_get_path(model)), free);
+
+ /* Ajout des panneaux uniques */
+
+ void dock_panel_into_current_station(GtkCheckMenuItem *menuitem, GPanelItem *item)
+ {
+ GtkWidget *parent; /* Menu parent avec chemin */
+ const char *new_path; /* Nouveau chemin à appliquer */
+
+ parent = gtk_widget_get_parent(GTK_WIDGET(menuitem));
+
+ new_path = g_object_get_data(G_OBJECT(parent), "path");
+
+ gtk_panel_item_set_path(item, new_path);
+
+ g_panel_item_dock(item);
+
+ }
+
+ bool add_side_panel_to_menu(GPanelItem *panel, GtkContainer *support)
+ {
+ const char *name; /* Désignation de l'entrée */
+ GtkWidget *submenuitem; /* Sous-élément de menu */
+ const char *bindings; /* Raccourcis clavier bruts */
+
+ /* Profil qui ne cadre pas ? */
+
+ if (gtk_panel_item_get_personality(panel) != PIP_SINGLETON)
+ goto aptm_exit;
+
+ if (g_panel_item_is_docked(panel))
+ goto aptm_exit;
+
+ /* Elément de menu */
+
+ name = g_editor_item_get_name(G_EDITOR_ITEM(panel));
+
+ submenuitem = qck_create_menu_item(NULL, NULL, name,
+ G_CALLBACK(dock_panel_into_current_station), panel);
+
+ bindings = gtk_panel_item_get_key_bindings(panel);
+
+ if (bindings != NULL)
+ add_accelerator_to_menu_item(submenuitem, bindings, _accgroup);
+
+ gtk_container_add(support, submenuitem);
+
+ aptm_exit:
+
+ return true;
+
+ }
+
+ browse_all_item_panels((handle_panel_item_fc)add_side_panel_to_menu, menu);
+
+ /* Avertissement en cas d'indisponibilité */
+
+ children = gtk_container_get_children(GTK_CONTAINER(menu));
+
+ if (children == NULL)
+ {
+ nopanel = qck_create_menu_item(NULL, NULL, "No available free panel", NULL, NULL);
+ gtk_widget_set_sensitive(nopanel, FALSE);
+ gtk_container_add(GTK_CONTAINER(menu), nopanel);
+ }
+ else
+ g_list_free(children);
+
+ /* Affichage du menu */
+
+ gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
+ (GtkMenuPositionFunc)attach_popup_menu_to_widget, button,
+ 0, gtk_get_current_event_time());
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : station = panneau de support des éléments concerné. *
+* button = bouton à l'origine de la procédure. *
+* ref = adresse de l'espace de référencement global. *
+* *
+* Description : Réagit à une demande de fermeture du panneau courant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void on_dock_close_request(GtkDockStation *station, GtkWidget *button, GObject *ref)
+{
+ GtkWidget *active; /* Composant actif modèle */
+ GPanelItem *panel; /* Panneau encapsulé */
+
+ active = gtk_notebook_get_nth_page(GTK_NOTEBOOK(station), 0);
+
+ panel = G_PANEL_ITEM(g_object_get_data(G_OBJECT(active), "dockable"));
+
+ g_panel_item_undock(panel);
+
+}
diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c
index 71fa155..ee0c102 100644
--- a/src/gui/panels/panel.c
+++ b/src/gui/panels/panel.c
@@ -31,6 +31,7 @@
#include "panel-int.h"
#include "../../common/extstr.h"
+#include "../../core/params.h"
#include "../../gtkext/gtkdockable-int.h"
@@ -406,6 +407,35 @@ const char *gtk_panel_item_get_path(const GPanelItem *item)
}
+/******************************************************************************
+* *
+* Paramètres : item = instance GTK à consulter. *
+* path = nouvelle emplacement d'inclusion. *
+* *
+* Description : Définit le chemin d'accès à utiliser pour les encapsulations.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_panel_item_set_path(GPanelItem *item, const char *path)
+{
+ char *key; /* Clef d'accès à un paramètre */
+
+ free(item->path);
+
+ item->path = strdup(path);
+
+ key = gtk_panel_item_build_configuration_key(item, "path");
+
+ g_generic_config_set_value(get_main_configuration(), key, item->path);
+
+ free(key);
+
+}
+
/******************************************************************************
* *
@@ -462,7 +492,16 @@ void g_panel_item_dock(GPanelItem *item)
void g_panel_item_set_dock_status(GPanelItem *item, bool status)
{
+ char *key; /* Clef d'accès à un paramètre */
+
item->docked = status;
+ item->dock_at_startup = status;
+
+ key = gtk_panel_item_build_configuration_key(item, "dock_at_startup");
+
+ g_generic_config_set_value(get_main_configuration(), key, item->dock_at_startup);
+
+ free(key);
}
diff --git a/src/gui/panels/panel.h b/src/gui/panels/panel.h
index cbe9030..cb716f8 100644
--- a/src/gui/panels/panel.h
+++ b/src/gui/panels/panel.h
@@ -81,6 +81,9 @@ PanelItemPersonality gtk_panel_item_get_personality(const GPanelItem *);
/* Fournit le chemin d'accès à utiliser pour les encapsulations. */
const char *gtk_panel_item_get_path(const GPanelItem *);
+/* Définit le chemin d'accès à utiliser pour les encapsulations. */
+void gtk_panel_item_set_path(GPanelItem *, const char *);
+
/* Indique la définition d'un éventuel raccourci clavier. */
const char *gtk_panel_item_get_key_bindings(const GPanelItem *);