diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-01-11 02:20:30 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-01-11 02:20:30 (GMT) |
commit | 486f0bf0a27ffed3e9fde2f183974ae029b45c54 (patch) | |
tree | 8840eaab0629f83e7501506b91101ce4f2d42a5d /src/gtkext | |
parent | 6ebdbfbca9e7bc34fe0f280e4a6a65c24c5003e9 (diff) |
Defined new panel definitions for the editor GUI.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@223 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/Makefile.am | 1 | ||||
-rw-r--r-- | src/gtkext/gtkbufferview.c | 16 | ||||
-rw-r--r-- | src/gtkext/gtkdockstation.c | 285 | ||||
-rw-r--r-- | src/gtkext/gtkdockstation.h | 94 |
4 files changed, 384 insertions, 12 deletions
diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index 47d4e41..bcaa730 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -13,6 +13,7 @@ libgtkext_la_SOURCES = \ gtkbufferview.h gtkbufferview.c \ gtkdockitem.h gtkdockitem.c \ gtkdockpanel.h gtkdockpanel.c \ + gtkdockstation.h gtkdockstation.c \ gtkdropwindow.h gtkdropwindow.c \ gtkgraphview.h gtkgraphview.c \ gtklinkrenderer.h gtklinkrenderer.c \ diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index bad88fc..796a001 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkbufferview.c - affichage de tampons de lignes * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -175,16 +175,8 @@ static void gtk_buffer_view_compute_real_coord(GtkBufferView *view, gint *x, gin static void gtk_buffer_view_size_request(GtkWidget *widget, GtkRequisition *requisition) { if (GTK_BUFFER_VIEW(widget)->buffer_view != NULL) - { - - g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, - &requisition->width, &requisition->height); - - printf(" === size req :: (%d ; %d)\n", - requisition->width, requisition->height); - - } - else printf(" === size req :: ??\n"); + g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, + &requisition->width, &requisition->height); } @@ -394,7 +386,7 @@ void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer) width += -view->left_text + 1; height += 1; - gtk_widget_set_size_request(GTK_WIDGET(view), width, height); + //gtk_widget_set_size_request(GTK_WIDGET(view), width, height); gtk_widget_queue_draw(GTK_WIDGET(view)); diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c new file mode 100644 index 0000000..afea11d --- /dev/null +++ b/src/gtkext/gtkdockstation.c @@ -0,0 +1,285 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtkdockstation.c - manipulation et l'affichage de composants rassemblés + * + * Copyright (C) 2012 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "gtkdockstation.h" + + +#include <malloc.h> +#include <string.h> + + +#include "easygtk.h" + + + +/* Procède à l'initialisation de l'afficheur concentré. */ +static void gtk_dock_station_class_init(GtkDockStationClass *); + +/* Procède à l'initialisation du support d'affichage concentré. */ +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 *, GtkNotebookPage *, guint, gpointer); + + + +/* Détermine le type du composant d'affichage concentré. */ +G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_VBOX) + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Procède à l'initialisation de l'afficheur concentré. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_dock_station_class_init(GtkDockStationClass *class) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : station = composant GTK à initialiser. * +* * +* Description : Procède à l'initialisation du support d'affichage concentré. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_dock_station_init(GtkDockStation *station) +{ + GtkWidget *eventbox; /* Réceptacle actif */ + GtkWidget *hbox; /* Division supérieure */ + GtkWidget *button; /* Bouton de contrôle */ + GtkWidget *image; /* Image associée */ + + eventbox = gtk_event_box_new(); + gtk_widget_show(eventbox); + gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(hbox); + gtk_container_add(GTK_CONTAINER(eventbox), hbox); + + station->title = GTK_LABEL(gtk_label_new(("<b>titre</b>"))); + gtk_widget_show(GTK_WIDGET(station->title)); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(station->title), TRUE, TRUE, 0); + gtk_label_set_use_markup(GTK_LABEL(station->title), TRUE); + gtk_misc_set_alignment(GTK_MISC(station->title), 0, 0.5); + + 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_stock("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_stock("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_tab_pos(station->notebook, GTK_POS_BOTTOM); + gtk_notebook_set_scrollable(station->notebook, TRUE); + + g_signal_connect(station->notebook, "switch-page", + G_CALLBACK(gtk_dock_station_switch_panel), station); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un nouveau composant pour support d'affichage concentré.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_dock_station_new(void) +{ + return g_object_new(GTK_TYPE_DOCK_STATION, NULL); + +} + + +/****************************************************************************** +* * +* 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. * +* * +* Description : Met à jour le titre du support de panneaux concentrés. * +* * +* Retour : TRUE ? * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, GtkNotebookPage *page, guint index, gpointer data) +{ + GtkWidget *widget; /* Panneau concerné */ + char *caption; /* Texte à redonner */ + + widget = gtk_notebook_get_nth_page(notebook, index); + caption = g_object_get_data(G_OBJECT(widget), "title"); + + gtk_dock_panel_update_title(GTK_DOCK_STATION(data), widget, caption); + + //g_signal_emit_by_name(GTK_DOCK_PANEL(data), "switch-item", ditem); + + return TRUE; + +} + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à compléter. * +* widget = nouvel élément à intégrer. * +* caption = intitulé court à afficher sur les onglets. * +* * +* Description : Ajoute un paquet d'informations à l'affichage centralisé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_dock_panel_add_widget(GtkDockStation *station, GtkWidget *widget, const char *caption) +{ + GtkWidget *label; /* Etiquette d'onglet */ + + label = qck_create_label(NULL, NULL, caption); + + 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); + + 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); + + gtk_dock_panel_update_title(station, widget, caption); + +} + + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à compléter. * +* widget = nouvel élément à intégrer. * +* caption = intitulé court à afficher sur les onglets. * +* * +* Description : Met à jour, si besoin est, le titre de l'affichage concentré.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_dock_panel_update_title(GtkDockStation *station, GtkWidget *widget, const char *caption) +{ + char *str; /* Valeur finale reconstituée */ + gint index; /* Indice de l'onglet actif */ + + /* Sauvegarde pour une prochaine fois */ + + str = g_object_get_data(G_OBJECT(widget), "title"); + if (str != NULL) free(str); + + g_object_set_data(G_OBJECT(widget), "title", strdup(caption)); + + /* Mise à jour de l'affichage */ + + index = gtk_notebook_get_current_page(station->notebook); + + if (index == gtk_notebook_page_num(station->notebook, widget)) + { + 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); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à consulter. * +* index = indice de l'onglet visé. * +* * +* Description : Renvoie un composant intégré dans l'affichage centralisé. * +* * +* Retour : Composant associé à l'indice donné. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index) +{ + return gtk_notebook_get_nth_page(station->notebook, index); + +} diff --git a/src/gtkext/gtkdockstation.h b/src/gtkext/gtkdockstation.h new file mode 100644 index 0000000..c92f43d --- /dev/null +++ b/src/gtkext/gtkdockstation.h @@ -0,0 +1,94 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtkdockstation.h - prototypes pour la manipulation et l'affichage de composants rassemblés + * + * Copyright (C) 2012 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GTKEXT_GTKDOCKSTATION_H +#define _GTKEXT_GTKDOCKSTATION_H + + +#include <gtk/gtk.h> + + +G_BEGIN_DECLS + + +#define GTK_TYPE_DOCK_STATION (gtk_dock_station_get_type()) +#define GTK_DOCK_STATION(obj) GTK_CHECK_CAST(obj, gtk_dock_station_get_type (), GtkDockStation) +#define GTK_DOCK_STATION_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_dock_station_get_type(), GtkDockStationClass) +#define GTK_IS_DOCK_STATION(obj) GTK_CHECK_TYPE(obj, gtk_dock_station_get_type()) + + +/* Station de réception pour concentration d'éléments (instance) */ +typedef struct _GtkDockStation GtkDockStation; + +/* Station de réception pour concentration d'éléments (classe) */ +typedef struct _GtkDockStationClass GtkDockStationClass; + + +/* Station de réception pour concentration d'éléments (instance) */ +struct _GtkDockStation +{ + GtkVBox vbox; /* Présence obligatoire en 1er */ + + GtkLabel *title; /* Title du support principal */ + GtkNotebook *notebook; /* Support à onglets */ + +}; + +/* Station de réception pour concentration d'éléments (classe) */ +struct _GtkDockStationClass +{ + GtkVBoxClass parent_class; /* Présence obligatoire en 1er */ + +}; + + +/* Détermine le type du composant d'affichage concentré. */ +GtkType gtk_dock_station_get_type(void); + +/* Crée un nouveau composant pour support d'affichage concentré. */ +GtkWidget *gtk_dock_station_new(void); + +/* Ajoute un paquet d'informations à l'affichage centralisé. */ +void gtk_dock_panel_add_widget(GtkDockStation *, GtkWidget *, const char *); + +/* Met à jour, si besoin est, le titre de l'affichage concentré. */ +void gtk_dock_panel_update_title(GtkDockStation *, GtkWidget *, const char *); + +/* Renvoie un composant intégré dans l'affichage centralisé. */ +GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *, gint); + + + +/* Ajoute un nouveau composant à l'ensemble. */ +//void gtk_dock_station_add_item(GtkDockStation *, GDockItem *); + +/* Supprime un composant à l'ensemble. */ +//void gtk_dock_station_remove_item(GtkDockStation *, GDockItem *); + + + +G_END_DECLS + + + +#endif /* _GTKEXT_GTKDOCKSTATION_H */ |