summaryrefslogtreecommitdiff
path: root/src/gui/tb
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-08-08 21:37:21 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-08-08 21:37:21 (GMT)
commit4370d2d77d623f560c7df94a3bc15b1395e4878b (patch)
tree57cc6268f504c19aaac3b1adda4295ed3b1ddc7f /src/gui/tb
parent34d28c7418342d3c67be4747b13cdcb124edda32 (diff)
Updated all the code relative to GUI items.
Diffstat (limited to 'src/gui/tb')
-rw-r--r--src/gui/tb/portions.c99
-rw-r--r--src/gui/tb/portions.h5
-rw-r--r--src/gui/tb/tbitem-int.h4
-rw-r--r--src/gui/tb/tbitem.c17
-rw-r--r--src/gui/tb/tbitem.h2
5 files changed, 91 insertions, 36 deletions
diff --git a/src/gui/tb/portions.c b/src/gui/tb/portions.c
index 1823bda..f8b2b92 100644
--- a/src/gui/tb/portions.c
+++ b/src/gui/tb/portions.c
@@ -43,6 +43,8 @@ struct _GPortionsTbItem
{
GToolbarItem parent; /* A laisser en premier */
+ GtkWidget *support; /* Composant GTK de support */
+
};
@@ -67,8 +69,14 @@ static void g_portions_tbitem_dispose(GPortionsTbItem *);
/* Procède à la libération totale de la mémoire. */
static void g_portions_tbitem_finalize(GPortionsTbItem *);
+/* Fournit le nom interne attribué à l'élément réactif. */
+static char *g_portions_tbitem_get_key(const GPortionsTbItem *);
+
+/* Fournit le composant GTK associé à l'élément réactif. */
+static GtkWidget *g_portions_tbitem_get_widget(const GPortionsTbItem *);
+
/* Réagit à un changement du binaire courant. */
-static void change_portions_tbitem_current_content(GEditorItem *, GLoadedContent *, GLoadedContent *);
+static void change_portions_tbitem_current_content(GPortionsTbItem *, GLoadedContent *, GLoadedContent *);
/* Fait suivre un changement d'adresse dans la barre. */
static void track_address_on_binary_strip(GtkBinaryStrip *, GEditorItem *);
@@ -97,12 +105,16 @@ static void g_portions_tbitem_class_init(GPortionsTbItemClass *klass)
GEditorItemClass *item; /* Encore une autre vision */
object = G_OBJECT_CLASS(klass);
- item = G_EDITOR_ITEM_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_portions_tbitem_dispose;
object->finalize = (GObjectFinalizeFunc)g_portions_tbitem_finalize;
- item->change_content = change_portions_tbitem_current_content;
+ item = G_EDITOR_ITEM_CLASS(klass);
+
+ item->get_key = (get_item_key_fc)g_portions_tbitem_get_key;
+ item->get_widget = (get_item_widget_fc)g_portions_tbitem_get_widget;
+
+ item->change_content = (change_item_content_fc)change_portions_tbitem_current_content;
}
@@ -121,20 +133,18 @@ static void g_portions_tbitem_class_init(GPortionsTbItemClass *klass)
static void g_portions_tbitem_init(GPortionsTbItem *item)
{
- GtkWidget *widget; /* Composant principal */
GtkWidget *strip; /* Bande pour binaire */
- widget = GTK_WIDGET(gtk_tool_item_new());
- gtk_tool_item_set_expand(GTK_TOOL_ITEM(widget), TRUE);
- gtk_widget_show(widget);
+ item->support = GTK_WIDGET(gtk_tool_item_new());
- G_EDITOR_ITEM(item)->widget = widget;
+ gtk_tool_item_set_expand(GTK_TOOL_ITEM(item->support), TRUE);
+ gtk_widget_show(item->support);
strip = gtk_binary_strip_new();
gtk_widget_show(strip);
- gtk_container_add(GTK_CONTAINER(widget), strip);
+ gtk_container_add(GTK_CONTAINER(item->support), strip);
- g_object_set_data(G_OBJECT(widget), "strip", strip);
+ g_object_set_data(G_OBJECT(item->support), "strip", strip);
g_signal_connect(strip, "select-address",
G_CALLBACK(track_address_on_binary_strip),
@@ -157,6 +167,8 @@ static void g_portions_tbitem_init(GPortionsTbItem *item)
static void g_portions_tbitem_dispose(GPortionsTbItem *item)
{
+ g_clear_object(&item->support);
+
G_OBJECT_CLASS(g_portions_tbitem_parent_class)->dispose(G_OBJECT(item));
}
@@ -193,13 +205,63 @@ static void g_portions_tbitem_finalize(GPortionsTbItem *item)
* *
******************************************************************************/
-GEditorItem *create_portions_tb_item(GObject *ref)
+GEditorItem *g_portions_tbitem_new(GObject *ref)
{
GPortionsTbItem *result; /* Structure à retourner */
result = g_object_new(G_TYPE_PORTIONS_TBITEM, NULL);
- return g_toolbar_item_setup(G_TOOLBAR_ITEM(result), ref, "portions", _("Portions"));
+ g_toolbar_item_setup(G_TOOLBAR_ITEM(result), ref);
+
+ return G_EDITOR_ITEM(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : item = instance à consulter. *
+* *
+* Description : Fournit le nom interne attribué à l'élément réactif. *
+* *
+* Retour : Désignation (courte) de l'élément de l'éditeur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_portions_tbitem_get_key(const GPortionsTbItem *item)
+{
+ char *result; /* Description à renvoyer */
+
+ result = strdup(PORTIONS_TBITEM_ID);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : item = instance à consulter. *
+* *
+* Description : Fournit le composant GTK associé à l'élément réactif. *
+* *
+* Retour : Instance de composant graphique chargé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GtkWidget *g_portions_tbitem_get_widget(const GPortionsTbItem *item)
+{
+ GtkWidget *result; /* Composant à retourner */
+
+ result = item->support;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
}
@@ -218,10 +280,9 @@ GEditorItem *create_portions_tb_item(GObject *ref)
* *
******************************************************************************/
-static void change_portions_tbitem_current_content(GEditorItem *item, GLoadedContent *old, GLoadedContent *new)
+static void change_portions_tbitem_current_content(GPortionsTbItem *item, GLoadedContent *old, GLoadedContent *new)
{
GLoadedBinary *binary; /* Autre version de l'instance */
- GtkWidget *widget; /* Elément graphique principal */
GtkBinaryStrip *strip; /* Bande pour binaire */
if (G_IS_LOADED_BINARY(new))
@@ -229,19 +290,15 @@ static void change_portions_tbitem_current_content(GEditorItem *item, GLoadedCon
else
binary = NULL;
- widget = g_editor_item_get_widget(item);
-
- strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(widget), "strip"));
+ strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(item->support), "strip"));
if (binary != NULL)
{
gtk_binary_strip_attach(strip, binary);
- gtk_widget_show(GTK_WIDGET(widget));
+ gtk_widget_show(item->support);
}
else
- gtk_widget_hide(GTK_WIDGET(widget));
-
- g_object_unref(G_OBJECT(widget));
+ gtk_widget_hide(item->support);
}
diff --git a/src/gui/tb/portions.h b/src/gui/tb/portions.h
index db1d4b4..b7457e7 100644
--- a/src/gui/tb/portions.h
+++ b/src/gui/tb/portions.h
@@ -30,6 +30,9 @@
+#define PORTIONS_TBITEM_ID "portions"
+
+
#define G_TYPE_PORTIONS_TBITEM g_portions_tbitem_get_type()
#define G_PORTIONS_TBITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_portions_tbitem_get_type(), GToolbarItem))
#define G_IS_PORTIONS_TBITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_portions_tbitem_get_type()))
@@ -49,7 +52,7 @@ typedef struct _GPortionsTbItemClass GPortionsTbItemClass;
GType g_portions_tbitem_get_type(void);
/* Crée une sélection de fichier réactive pour barre d'outils. */
-GEditorItem *create_portions_tb_item(GObject *ref);
+GEditorItem *g_portions_tbitem_new(GObject *ref);
diff --git a/src/gui/tb/tbitem-int.h b/src/gui/tb/tbitem-int.h
index 4d519f2..4cc4778 100644
--- a/src/gui/tb/tbitem-int.h
+++ b/src/gui/tb/tbitem-int.h
@@ -26,7 +26,7 @@
#define _GUI_TBITEM_INT_H
-#include "../editem-int.h"
+#include "../item-int.h"
@@ -48,7 +48,7 @@ struct _GToolbarItemClass
/* Termine la préparation d'un élément de barre d'outils. */
-GEditorItem *g_toolbar_item_setup(GToolbarItem *, GObject *, const char *, const char *);
+void g_toolbar_item_setup(GToolbarItem *, GObject *);
diff --git a/src/gui/tb/tbitem.c b/src/gui/tb/tbitem.c
index f7f3ec8..e46702e 100644
--- a/src/gui/tb/tbitem.c
+++ b/src/gui/tb/tbitem.c
@@ -84,31 +84,26 @@ static void g_toolbar_item_init(GToolbarItem *item)
* *
* Paramètres : tbitem = élément de barre d'outils à finaliser. *
* ref = espace de référencement global. *
-* name = nom associé à l'élément. *
-* label = étiquette destinée au menu. *
* *
* Description : Termine la préparation d'un élément de barre d'outils. *
* *
-* Retour : Adresse de la structure mise en place. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GEditorItem *g_toolbar_item_setup(GToolbarItem *tbitem, GObject *ref, const char *name, const char *label)
+void g_toolbar_item_setup(GToolbarItem *tbitem, GObject *ref)
{
- GEditorItem *result; /* Structure à retourner */
GtkContainer *toolbar; /* Barre d'outils visée */
-
- result = G_EDITOR_ITEM(tbitem);
-
- result->name = name;
+ GtkWidget *widget; /* Composant GTK à intégrer */
/* Intégration dans la barre */
toolbar = GTK_CONTAINER(g_object_get_data(ref, "toolbar"));
- gtk_container_add(toolbar, result->widget);
- return result;
+ widget = g_editor_item_get_widget(G_EDITOR_ITEM(tbitem));
+
+ gtk_container_add(toolbar, widget);
}
diff --git a/src/gui/tb/tbitem.h b/src/gui/tb/tbitem.h
index 2a9c61a..260bfc3 100644
--- a/src/gui/tb/tbitem.h
+++ b/src/gui/tb/tbitem.h
@@ -26,7 +26,7 @@
#define _GUI_TBITEM_H
-#include "../editem.h"
+#include "../item.h"