diff options
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/gtkdockable.c | 35 | ||||
-rw-r--r-- | src/gtkext/gtkdockable.h | 5 | ||||
-rw-r--r-- | src/gtkext/gtkdockstation.c | 183 | ||||
-rw-r--r-- | src/gtkext/gtkdockstation.h | 9 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 4 |
5 files changed, 140 insertions, 96 deletions
diff --git a/src/gtkext/gtkdockable.c b/src/gtkext/gtkdockable.c index 954b651..98b1a04 100644 --- a/src/gtkext/gtkdockable.c +++ b/src/gtkext/gtkdockable.c @@ -241,7 +241,7 @@ bool gtk_dockable_can_be_closed(const GtkDockable *dockable) * * ******************************************************************************/ -GtkWidget *gtk_dockable_get_widget(GtkDockable *dockable) +GtkWidget *gtk_dockable_build_widget(GtkDockable *dockable) { GtkWidget *result; /* Composant à retourner */ GtkDockableIface *iface; /* Interface utilisée */ @@ -286,6 +286,39 @@ GtkWidget *gtk_dockable_get_widget(GtkDockable *dockable) /****************************************************************************** * * * Paramètres : dockable = instance GTK dont l'interface est à consulter. * +* support = composant à partir duquel décrocher ou NULL. [OUT]* +* * +* Description : Fournit tous les éléments pour un retrait graphique. * +* * +* Retour : Composant graphique à décrocher. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_dockable_decompose(GtkDockable *dockable, GtkWidget **support) +{ + GtkWidget *result; /* Composant à retourner */ + GtkDockableIface *iface; /* Interface utilisée */ + + iface = GTK_DOCKABLE_GET_IFACE(dockable); + + result = iface->get_widget(dockable); + + if (iface->can_search) + result = gtk_widget_get_parent(result); /* GtkBox */ + + if (support != NULL) + *support = gtk_widget_get_parent(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : dockable = instance GTK dont l'interface est à consulter. * * built = composant graphique d'encapsulation mis en place. * * reveal = détermine l'action à mener. * * * diff --git a/src/gtkext/gtkdockable.h b/src/gtkext/gtkdockable.h index e939fad..31a3310 100644 --- a/src/gtkext/gtkdockable.h +++ b/src/gtkext/gtkdockable.h @@ -62,7 +62,10 @@ const char *gtk_dockable_get_name(const GtkDockable *); const char *gtk_dockable_get_desc(const GtkDockable *); /* Fournit le composant graphique intégrable dans un ensemble. */ -GtkWidget *gtk_dockable_get_widget(GtkDockable *); +GtkWidget *gtk_dockable_build_widget(GtkDockable *); + +/* Fournit tous les éléments pour un retrait graphique. */ +GtkWidget *gtk_dockable_decompose(GtkDockable *, GtkWidget **); /* Révèle ou cache la zone de recherches. */ void gtk_dockable_toggle_revealer(GtkDockable *, GtkWidget *, gboolean); diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c index e10e55f..35006ef 100644 --- a/src/gtkext/gtkdockstation.c +++ b/src/gtkext/gtkdockstation.c @@ -57,7 +57,7 @@ static void on_toggle_revealer(GtkToggleButton *, GtkDockStation *); /* Détermine le type du composant d'affichage concentré. */ -G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_BOX) +G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_NOTEBOOK) /****************************************************************************** @@ -115,53 +115,14 @@ static void gtk_dock_station_class_init(GtkDockStationClass *class) static void gtk_dock_station_init(GtkDockStation *station) { - GtkWidget *eventbox; /* Réceptacle actif */ + GtkNotebook *notebook; /* Autre version du composant */ GtkWidget *hbox; /* Division supérieure */ GtkWidget *button; /* Bouton de contrôle */ - GtkWidget *image; /* Image associée */ - gtk_orientable_set_orientation(GTK_ORIENTABLE(station), GTK_ORIENTATION_VERTICAL); + notebook = GTK_NOTEBOOK(station); - eventbox = gtk_event_box_new(); - gtk_widget_show(eventbox); - //gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_widget_show(hbox); - gtk_container_add(GTK_CONTAINER(eventbox), hbox); - - station->title = GTK_LABEL(qck_create_label(NULL, NULL, "<b>titre</b>")); - gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(station->title), TRUE, TRUE, 0); - gtk_label_set_use_markup(station->title, TRUE); - - button = gtk_button_new(); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - - image = gtk_image_new_from_icon_name("gtk-media-play", GTK_ICON_SIZE_MENU); - gtk_widget_show(image); - gtk_container_add(GTK_CONTAINER(button), image); - gtk_widget_set_size_request(image, 10, 10); - - button = gtk_button_new(); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - - image = gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_MENU); - gtk_widget_show(image); - 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_scrollable(station->notebook, TRUE); + gtk_notebook_set_show_border(notebook, FALSE); + gtk_notebook_set_scrollable(notebook, TRUE); /* Définition de la zone de contrôle */ @@ -188,9 +149,9 @@ static void gtk_dock_station_init(GtkDockStation *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); + gtk_notebook_set_action_widget(notebook, hbox, GTK_PACK_END); - g_signal_connect(station->notebook, "switch-page", + g_signal_connect(notebook, "switch-page", G_CALLBACK(gtk_dock_station_switch_panel), station); } @@ -267,10 +228,8 @@ static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *p /****************************************************************************** * * -* Paramètres : station = plateforme GTK à compléter. * -* widget = nouvel élément à intégrer. * -* caption = intitulé court à afficher sur les onglets. * -* desc = intitulé long pour le titre et la description. * +* Paramètres : station = plateforme GTK à compléter. * +* dockable = nouvel élément à intégrer. * * * * Description : Ajoute un paquet d'informations à l'affichage centralisé. * * * @@ -279,7 +238,8 @@ static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *p * Remarques : - * * * ******************************************************************************/ - +#include "gtkviewpanel.h" +#include "../gui/panels/history.h" void gtk_dock_station_add_dockable(GtkDockStation *station, GtkDockable *dockable) { GtkWidget *widget; /* Composant GTK à intégrer */ @@ -288,10 +248,34 @@ void gtk_dock_station_add_dockable(GtkDockStation *station, GtkDockable *dockabl size_t max; /* Taille maximale des titres */ char *str; /* Titre des prochaines fois */ GtkWidget *label; /* Etiquette d'onglet */ + GtkNotebook *notebook; /* Autre version du composant */ /* Récupération des éléments utiles */ - widget = gtk_dockable_get_widget(dockable); + widget = gtk_dockable_build_widget(dockable); + + + if (strcmp(gtk_dockable_get_name(dockable), "History") == 0) + { + GtkRequisition req; + + gtk_widget_get_preferred_size(widget, &req, NULL); + fprintf(stderr, "Histo req :: %d x %d\n", req.width, req.height); + + } + + /* + if (!GTK_IS_SCROLLED_WINDOW(widget) + && ( + strcmp(gtk_dockable_get_name(dockable), "History2") != 0 + ) + ) + widget = gtk_button_new_with_label("123"); + */ + + //widget = gtk_button_new_with_label("123"); + gtk_widget_show(widget); + g_object_set_data(G_OBJECT(widget), "dockable", dockable); @@ -307,24 +291,52 @@ void gtk_dock_station_add_dockable(GtkDockStation *station, GtkDockable *dockabl 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, + notebook = GTK_NOTEBOOK(station); + + if (gtk_notebook_get_n_pages(notebook) > 0) + g_signal_handlers_disconnect_by_func(notebook, G_CALLBACK(gtk_dock_station_switch_panel), station); - gtk_notebook_insert_page(station->notebook, widget, label, -1); + gtk_notebook_insert_page(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", + if (gtk_notebook_get_n_pages(notebook) > 1) + g_signal_connect(notebook, "switch-page", G_CALLBACK(gtk_dock_station_switch_panel), station); /* Lancement des mises à jour */ - if (gtk_notebook_get_n_pages(station->notebook) > 1) - gtk_notebook_set_current_page(station->notebook, -1); + if (gtk_notebook_get_n_pages(notebook) > 1) + gtk_notebook_set_current_page(notebook, -1); + + + // Renéociation des tailles + //gtk_widget_queue_resize(GTK_WIDGET(notebook)); + + + if (false) + { + GtkRequisition req; + + gtk_widget_get_preferred_size(GTK_WIDGET(notebook), &req, NULL); + fprintf(stderr, "=== SUPPORT req :: %d x %d\n", req.width, req.height); + + + gtk_widget_set_size_request(GTK_WIDGET(notebook), req.width, req.height); + + + + } + + - g_signal_emit_by_name(station, "dock-widget", widget); + + + + + + //g_signal_emit_by_name(station, "dock-widget", widget); } @@ -344,32 +356,35 @@ void gtk_dock_station_add_dockable(GtkDockStation *station, GtkDockable *dockabl void gtk_dock_panel_change_active_widget(GtkDockStation *station, GtkWidget *widget) { + GtkNotebook *notebook; /* Autre version du composant */ gint index; /* Indice de l'onglet actif */ GtkWidget *old; /* Ancien composant */ GtkWidget *label; /* Etiquette d'onglet */ char *str; /* Titre des prochaines fois */ - index = gtk_notebook_get_current_page(station->notebook); + notebook = GTK_NOTEBOOK(station); + + index = gtk_notebook_get_current_page(notebook); - g_signal_handlers_disconnect_by_func(station->notebook, + g_signal_handlers_disconnect_by_func(notebook, G_CALLBACK(gtk_dock_station_switch_panel), station); - old = gtk_notebook_get_nth_page(station->notebook, index); - label = gtk_notebook_get_tab_label(station->notebook, old); + old = gtk_notebook_get_nth_page(notebook, index); + label = gtk_notebook_get_tab_label(notebook, old); g_object_ref(G_OBJECT(old)); g_object_ref(G_OBJECT(label)); str = g_object_get_data(G_OBJECT(old), "title"); - gtk_notebook_remove_page(station->notebook, index); - gtk_notebook_insert_page(station->notebook, widget, label, index); + gtk_notebook_remove_page(notebook, index); + gtk_notebook_insert_page(notebook, widget, label, index); g_object_unref(G_OBJECT(label)); g_object_set_data(G_OBJECT(widget), "title", str); - gtk_notebook_set_current_page(station->notebook, index); + gtk_notebook_set_current_page(notebook, index); - g_signal_connect(station->notebook, "switch-page", + g_signal_connect(notebook, "switch-page", G_CALLBACK(gtk_dock_station_switch_panel), station); } @@ -378,7 +393,7 @@ void gtk_dock_panel_change_active_widget(GtkDockStation *station, GtkWidget *wid /****************************************************************************** * * * Paramètres : station = plateforme GTK à compléter. * -* widget = nouvel élément à intégrer. * +* dockable = élément existant à retirer. * * * * Description : Retire un paquet d'informations de l'affichage centralisé. * * * @@ -388,26 +403,19 @@ void gtk_dock_panel_change_active_widget(GtkDockStation *station, GtkWidget *wid * * ******************************************************************************/ -void gtk_dock_panel_remove_widget(GtkDockStation *station, GtkWidget *widget) +void gtk_dock_station_remove_dockable(GtkDockStation *station, GtkDockable *dockable) { + GtkNotebook *notebook; /* Autre version du composant */ + GtkWidget *widget; /* Composant GTK à retirer */ gint index; /* Indice de l'onglet visé */ - gint count; /* Nombre d'onglets en place */ + notebook = GTK_NOTEBOOK(station); - return; + widget = gtk_dockable_decompose(dockable, NULL); + index = gtk_notebook_page_num(notebook, widget); - 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); - - if (count == 0) - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(station))), - GTK_WIDGET(station)); + gtk_notebook_remove_page(notebook, index); } @@ -427,7 +435,7 @@ void gtk_dock_panel_remove_widget(GtkDockStation *station, GtkWidget *widget) GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index) { - return gtk_notebook_get_nth_page(station->notebook, index); + return gtk_notebook_get_nth_page(GTK_NOTEBOOK(station), index); } @@ -447,12 +455,15 @@ GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index) static void on_toggle_revealer(GtkToggleButton *button, GtkDockStation *station) { + GtkNotebook *notebook; /* Autre version du composant */ 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); + notebook = GTK_NOTEBOOK(station); + + index = gtk_notebook_get_current_page(notebook); + widget = gtk_notebook_get_nth_page(notebook, index); dockable = GTK_DOCKABLE(g_object_get_data(G_OBJECT(widget), "dockable")); diff --git a/src/gtkext/gtkdockstation.h b/src/gtkext/gtkdockstation.h index d64a0b8..953ceb8 100644 --- a/src/gtkext/gtkdockstation.h +++ b/src/gtkext/gtkdockstation.h @@ -51,17 +51,14 @@ typedef struct _GtkDockStationClass GtkDockStationClass; /* Station de réception pour concentration d'éléments (instance) */ struct _GtkDockStation { - GtkBox vbox; /* Présence obligatoire en 1er */ - - GtkLabel *title; /* Title du support principal */ - GtkNotebook *notebook; /* Support à onglets */ + GtkNotebook parent; /* A laisser en premier */ }; /* Station de réception pour concentration d'éléments (classe) */ struct _GtkDockStationClass { - GtkBoxClass parent_class; /* Présence obligatoire en 1er */ + GtkNotebookClass parent_class; /* A laisser en premier */ /* Signaux */ @@ -86,7 +83,7 @@ void gtk_dock_station_add_dockable(GtkDockStation *, GtkDockable *); void gtk_dock_panel_change_active_widget(GtkDockStation *, GtkWidget *); /* Retire un paquet d'informations de l'affichage centralisé. */ -void gtk_dock_panel_remove_widget(GtkDockStation *, GtkWidget *); +void gtk_dock_station_remove_dockable(GtkDockStation *, GtkDockable *); /* Renvoie un composant intégré dans l'affichage centralisé. */ GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *, gint); diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index a347ad8..b7829c2 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -121,8 +121,8 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) widget_class->realize = gtk_view_panel_realize; widget_class->size_allocate = gtk_view_panel_size_allocate; widget_class->draw = gtk_view_panel_draw; - widget_class->get_preferred_height = gtk_view_panel_get_preferred_height; - widget_class->get_preferred_width = gtk_view_panel_get_preferred_width; + //widget_class->get_preferred_height = gtk_view_panel_get_preferred_height; + //widget_class->get_preferred_width = gtk_view_panel_get_preferred_width; panel_class->compute_inc = gtk_view_panel_compute_scroll_inc; |