summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkdockstation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/gtkdockstation.c')
-rw-r--r--src/gtkext/gtkdockstation.c157
1 files changed, 112 insertions, 45 deletions
diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c
index 2737557..e10e55f 100644
--- a/src/gtkext/gtkdockstation.c
+++ b/src/gtkext/gtkdockstation.c
@@ -42,7 +42,17 @@ static void gtk_dock_station_class_init(GtkDockStationClass *);
static void gtk_dock_station_init(GtkDockStation *);
/* Met à jour le titre du support de panneaux concentrés. */
-static gboolean gtk_dock_station_switch_panel(GtkNotebook *, gpointer *, guint, gpointer);
+static gboolean gtk_dock_station_switch_panel(GtkNotebook *, gpointer *, guint, GtkDockStation *);
+
+
+
+
+/* Révèle ou cache la zone de recherches. */
+static void on_toggle_revealer(GtkToggleButton *, GtkDockStation *);
+
+
+
+
@@ -114,7 +124,7 @@ static void gtk_dock_station_init(GtkDockStation *station)
eventbox = gtk_event_box_new();
gtk_widget_show(eventbox);
- gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0);
+ //gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show(hbox);
@@ -144,13 +154,42 @@ static void gtk_dock_station_init(GtkDockStation *station)
gtk_container_add(GTK_CONTAINER(button), image);
gtk_widget_set_size_request(image, 10, 10);
+
+
+
station->notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_widget_show(GTK_WIDGET(station->notebook));
gtk_box_pack_start(GTK_BOX(station), GTK_WIDGET(station->notebook), TRUE, TRUE, 0);
gtk_notebook_set_show_border(station->notebook, FALSE);
- gtk_notebook_set_tab_pos(station->notebook, GTK_POS_BOTTOM);
gtk_notebook_set_scrollable(station->notebook, TRUE);
+ /* Définition de la zone de contrôle */
+
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_valign(hbox, GTK_ALIGN_CENTER);
+ gtk_widget_set_margin_end(hbox, 8);
+ gtk_widget_show(hbox);
+
+ button = qck_create_toggle_button_with_named_img(G_OBJECT(station), "search",
+ "edit-find-symbolic", GTK_ICON_SIZE_MENU, NULL,
+ G_CALLBACK(on_toggle_revealer), station);
+ gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ button = qck_create_button_with_named_img(G_OBJECT(station), "menu",
+ "go-down-symbolic", GTK_ICON_SIZE_MENU, NULL,
+ G_CALLBACK(NULL), station);
+ gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ button = qck_create_button_with_named_img(G_OBJECT(station), "close",
+ "window-close-symbolic", GTK_ICON_SIZE_MENU, NULL,
+ G_CALLBACK(NULL), station);
+ gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ gtk_notebook_set_action_widget(station->notebook, hbox, GTK_PACK_END);
+
g_signal_connect(station->notebook, "switch-page",
G_CALLBACK(gtk_dock_station_switch_panel), station);
@@ -181,7 +220,7 @@ GtkWidget *gtk_dock_station_new(void)
* Paramètres : notebook = support à l'origine de la mise à jour. *
* page = onglet mis en avant. *
* index = indice de l'onglet actuellement actif. *
-* data = adresse du conteneur supérieur. *
+* station = conteneur de gestion supérieur. *
* *
* Description : Met à jour le titre du support de panneaux concentrés. *
* *
@@ -191,17 +230,35 @@ GtkWidget *gtk_dock_station_new(void)
* *
******************************************************************************/
-static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *page, guint index, gpointer data)
+static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *page, guint index, GtkDockStation *station)
{
GtkWidget *widget; /* Panneau concerné */
- char *str; /* Texte à redonner */
+ GtkDockable *dockable; /* Elément encapsulé */
+ GtkWidget *button; /* Bouton de contrôle */
widget = gtk_notebook_get_nth_page(notebook, index);
- str = g_object_get_data(G_OBJECT(widget), "title");
- gtk_dock_panel_update_title(GTK_DOCK_STATION(data), widget, str);
+ dockable = GTK_DOCKABLE(g_object_get_data(G_OBJECT(widget), "dockable"));
+
+ /* Mise à jour des boutons utilisables */
- g_signal_emit_by_name(GTK_DOCK_STATION(data), "switch-widget", widget);
+ button = GTK_WIDGET(g_object_get_data(G_OBJECT(station), "search"));
+
+ if (gtk_dockable_can_search(dockable))
+ gtk_widget_show(button);
+ else
+ gtk_widget_hide(button);
+
+ button = GTK_WIDGET(g_object_get_data(G_OBJECT(station), "close"));
+
+ if (gtk_dockable_can_be_closed(dockable))
+ gtk_widget_show(button);
+ else
+ gtk_widget_hide(button);
+
+ /* Remontée du changement d'onglet */
+
+ g_signal_emit_by_name(station, "switch-widget", widget);
return TRUE;
@@ -223,12 +280,26 @@ static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *p
* *
******************************************************************************/
-void gtk_dock_panel_add_widget(GtkDockStation *station, GtkWidget *widget, const char *caption, const char *desc)
+void gtk_dock_station_add_dockable(GtkDockStation *station, GtkDockable *dockable)
{
+ GtkWidget *widget; /* Composant GTK à intégrer */
+ const char *caption; /* Nom à donner à l'onglet */
+ const char *desc; /* Description à y associer */
size_t max; /* Taille maximale des titres */
char *str; /* Titre des prochaines fois */
GtkWidget *label; /* Etiquette d'onglet */
+ /* Récupération des éléments utiles */
+
+ widget = gtk_dockable_get_widget(dockable);
+
+ g_object_set_data(G_OBJECT(widget), "dockable", dockable);
+
+ caption = gtk_dockable_get_name(dockable);
+ desc = gtk_dockable_get_desc(dockable);
+
+ /* Mise en place de la page */
+
if (!g_generic_config_get_value(get_main_configuration(), MPK_ELLIPSIS_TAB, &max))
max = -1;
@@ -236,28 +307,22 @@ void gtk_dock_panel_add_widget(GtkDockStation *station, GtkWidget *widget, const
label = qck_create_label(NULL, NULL, str);
free(str);
+ if (gtk_notebook_get_n_pages(station->notebook) > 0)
g_signal_handlers_disconnect_by_func(station->notebook,
G_CALLBACK(gtk_dock_station_switch_panel), station);
gtk_notebook_insert_page(station->notebook, widget, label, -1);
gtk_widget_set_tooltip_text(label, desc);
+ if (gtk_notebook_get_n_pages(station->notebook) > 1)
g_signal_connect(station->notebook, "switch-page",
G_CALLBACK(gtk_dock_station_switch_panel), station);
- gtk_notebook_set_show_tabs(station->notebook, gtk_notebook_get_n_pages(station->notebook) > 1);
-
- str = g_object_get_data(G_OBJECT(widget), "title");
- if (str != NULL) free(str);
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_ELLIPSIS_HEADER, &max))
- max = -1;
-
- g_object_set_data(G_OBJECT(widget), "title", ellipsis(strdup(desc), max));
+ /* Lancement des mises à jour */
- gtk_dock_panel_update_title(station, widget, desc);
+ if (gtk_notebook_get_n_pages(station->notebook) > 1)
+ gtk_notebook_set_current_page(station->notebook, -1);
- gtk_notebook_set_current_page(station->notebook, -1);
g_signal_emit_by_name(station, "dock-widget", widget);
@@ -328,13 +393,17 @@ void gtk_dock_panel_remove_widget(GtkDockStation *station, GtkWidget *widget)
gint index; /* Indice de l'onglet visé */
gint count; /* Nombre d'onglets en place */
+
+ return;
+
+
index = gtk_notebook_page_num(station->notebook, widget);
gtk_notebook_remove_page(station->notebook, index);
count = gtk_notebook_get_n_pages(station->notebook);
- gtk_notebook_set_show_tabs(station->notebook, count > 1);
+ //gtk_notebook_set_show_tabs(station->notebook, count > 1);
if (count == 0)
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(station))),
@@ -345,50 +414,48 @@ void gtk_dock_panel_remove_widget(GtkDockStation *station, GtkWidget *widget)
/******************************************************************************
* *
-* Paramètres : station = plateforme GTK à compléter. *
-* widget = nouvel élément à intégrer. *
-* caption = intitulé court à afficher sur les onglets. *
+* Paramètres : station = plateforme GTK à consulter. *
+* index = indice de l'onglet visé. *
* *
-* Description : Met à jour, si besoin est, le titre de l'affichage concentré.*
+* Description : Renvoie un composant intégré dans l'affichage centralisé. *
* *
-* Retour : - *
+* Retour : Composant associé à l'indice donné. *
* *
* Remarques : - *
* *
******************************************************************************/
-void gtk_dock_panel_update_title(GtkDockStation *station, GtkWidget *widget, const char *caption)
+GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index)
{
- char *str; /* Valeur finale reconstituée */
-
- str = calloc(strlen("<b>") + strlen(caption) + strlen("</b>") + 1, sizeof(char));
-
- strcpy(str, "<b>");
- strcat(str, caption);
- strcat(str, "</b>");
-
- gtk_label_set_markup(station->title, str);
-
- free(str);
+ return gtk_notebook_get_nth_page(station->notebook, index);
}
/******************************************************************************
* *
-* Paramètres : station = plateforme GTK à consulter. *
-* index = indice de l'onglet visé. *
+* Paramètres : button = bouton à l'origine de la procédure. *
+* station = station d'accueil pour différents composants. *
* *
-* Description : Renvoie un composant intégré dans l'affichage centralisé. *
+* Description : Révèle ou cache la zone de recherches. *
* *
-* Retour : Composant associé à l'indice donné. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index)
+static void on_toggle_revealer(GtkToggleButton *button, GtkDockStation *station)
{
- return gtk_notebook_get_nth_page(station->notebook, index);
+ gint index; /* Indice de l'onglet courant */
+ GtkWidget *widget; /* Panneau concerné */
+ GtkDockable *dockable; /* Elément encapsulé */
+
+ index = gtk_notebook_get_current_page(station->notebook);
+ widget = gtk_notebook_get_nth_page(station->notebook, index);
+
+ dockable = GTK_DOCKABLE(g_object_get_data(G_OBJECT(widget), "dockable"));
+
+ gtk_dockable_toggle_revealer(dockable, widget, gtk_toggle_button_get_active(button));
}