summaryrefslogtreecommitdiff
path: root/src/gui/panels/history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/panels/history.c')
-rw-r--r--src/gui/panels/history.c85
1 files changed, 63 insertions, 22 deletions
diff --git a/src/gui/panels/history.c b/src/gui/panels/history.c
index e0744c6..e1ac123 100644
--- a/src/gui/panels/history.c
+++ b/src/gui/panels/history.c
@@ -36,6 +36,7 @@
#include "../../analysis/binary.h"
#include "../../glibext/chrysamarshal.h"
#include "../../glibext/signal.h"
+#include "../../gtkext/named.h"
@@ -82,6 +83,9 @@ static void g_history_panel_dispose(GHistoryPanel *);
/* Procède à la libération totale de la mémoire. */
static void g_history_panel_finalize(GHistoryPanel *);
+/* Fournit le nom interne attribué à l'élément réactif. */
+static char *g_history_panel_get_key(const GHistoryPanel *);
+
/* Réagit à un changement d'affichage principal de contenu. */
static void change_history_panel_current_content(GHistoryPanel *, GLoadedContent *, GLoadedContent *);
@@ -124,16 +128,18 @@ G_DEFINE_TYPE(GHistoryPanel, g_history_panel, G_TYPE_PANEL_ITEM);
static void g_history_panel_class_init(GHistoryPanelClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
- GEditorItemClass *editem; /* Encore une autre vision... */
+ GEditorItemClass *item; /* Encore une autre vision... */
object = G_OBJECT_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_history_panel_dispose;
object->finalize = (GObjectFinalizeFunc)g_history_panel_finalize;
- editem = G_EDITOR_ITEM_CLASS(klass);
+ item = G_EDITOR_ITEM_CLASS(klass);
+
+ item->get_key = (get_item_key_fc)g_history_panel_get_key;
- editem->change_content = (change_item_content_fc)change_history_panel_current_content;
+ item->change_content = (change_item_content_fc)change_history_panel_current_content;
}
@@ -152,27 +158,26 @@ static void g_history_panel_class_init(GHistoryPanelClass *klass)
static void g_history_panel_init(GHistoryPanel *panel)
{
- GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
GtkBuilder *builder; /* Constructeur utilisé */
GtkListStore *store; /* Modèle de gestion */
/* Eléments de base */
- base = G_EDITOR_ITEM(panel);
-
- base->name = PANEL_HISTORY_ID;
-
pitem = G_PANEL_ITEM(panel);
pitem->personality = PIP_SINGLETON;
- pitem->lname = _("Change history");
+
+ pitem->widget = G_NAMED_WIDGET(gtk_built_named_widget_new_for_panel(_("History"),
+ _("Change history"),
+ PANEL_HISTORY_ID));
+
pitem->dock_at_startup = true;
pitem->path = strdup("MEN");
/* Représentation graphique */
- builder = g_panel_item_build(pitem, "history");
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(pitem->widget));
store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
@@ -189,6 +194,8 @@ static void g_history_panel_init(GHistoryPanel *panel)
gtk_builder_connect_signals(builder, panel);
+ g_object_unref(G_OBJECT(builder));
+
}
@@ -257,6 +264,29 @@ GPanelItem *g_history_panel_new(void)
/******************************************************************************
* *
+* Paramètres : panel = 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_history_panel_get_key(const GHistoryPanel *panel)
+{
+ char *result; /* Description à renvoyer */
+
+ result = strdup(PANEL_HISTORY_ID);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : panel = panneau à mettre à jour. *
* old = ancien contenu chargé analysé. *
* new = nouveau contenu chargé à analyser. *
@@ -312,12 +342,14 @@ static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedCo
if (panel->binary != NULL)
g_object_ref(G_OBJECT(binary));
- builder = G_PANEL_ITEM(panel)->builder;
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget));
store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
gtk_list_store_clear(store);
+ g_object_unref(G_OBJECT(builder));
+
/* Si le panneau actif ne représente pas un binaire... */
if (binary == NULL) return;
@@ -393,7 +425,7 @@ static void on_history_changed(GDbCollection *collec, DBAction action, GDbItem *
char *label; /* Etiquette de représentation */
GtkTreeIter iter; /* Boucle de parcours */
- builder = G_PANEL_ITEM(panel)->builder;
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget));
treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
@@ -503,6 +535,8 @@ static void on_history_changed(GDbCollection *collec, DBAction action, GDbItem *
on_history_selection_change(selection, panel);
+ g_object_unref(G_OBJECT(builder));
+
}
@@ -561,7 +595,7 @@ static void on_history_selection_change(GtkTreeSelection *selection, GHistoryPan
GDbItem *item; /* Elément de collection */
GtkWidget *button; /* Bouton de barre de contrôle */
- builder = G_PANEL_ITEM(panel)->builder;
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
@@ -587,6 +621,8 @@ static void on_history_selection_change(GtkTreeSelection *selection, GHistoryPan
}
+ g_object_unref(G_OBJECT(builder));
+
}
@@ -613,7 +649,7 @@ static void do_history_undo(GtkButton *button, GHistoryPanel *panel)
GDbItem *item; /* Elément de collection */
GHubClient *client; /* Connexion vers la base */
- builder = G_PANEL_ITEM(panel)->builder;
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget));
treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
@@ -621,19 +657,22 @@ static void do_history_undo(GtkButton *button, GHistoryPanel *panel)
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
- if (!gtk_tree_model_iter_previous(model, &iter))
- return;
+ if (gtk_tree_model_iter_previous(model, &iter))
+ {
+ gtk_tree_model_get(model, &iter, HTC_ITEM, &item, -1);
- gtk_tree_model_get(model, &iter, HTC_ITEM, &item, -1);
+ client = g_loaded_binary_get_client(panel->binary, true);
+ g_hub_client_set_last_active(client, g_db_item_get_timestamp(item));
+ g_object_unref(G_OBJECT(client));
- client = g_loaded_binary_get_client(panel->binary, true);
- g_hub_client_set_last_active(client, g_db_item_get_timestamp(item));
- g_object_unref(G_OBJECT(client));
+ g_object_unref(G_OBJECT(item));
- g_object_unref(G_OBJECT(item));
+ }
}
+ g_object_unref(G_OBJECT(builder));
+
}
@@ -660,7 +699,7 @@ static void do_history_redo(GtkButton *button, GHistoryPanel *panel)
GDbItem *item; /* Elément de collection */
GHubClient *client; /* Connexion vers la base */
- builder = G_PANEL_ITEM(panel)->builder;
+ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget));
treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
@@ -678,6 +717,8 @@ static void do_history_redo(GtkButton *button, GHistoryPanel *panel)
}
+ g_object_unref(G_OBJECT(builder));
+
}