summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/panels/Makefile.am5
-rw-r--r--src/gui/panels/bookmarks.c156
-rw-r--r--src/gui/panels/bookmarks.ui89
-rw-r--r--src/gui/panels/glance.c30
-rw-r--r--src/gui/panels/glance.ui28
-rw-r--r--src/gui/panels/gresource.xml5
-rw-r--r--src/gui/panels/history.c160
-rw-r--r--src/gui/panels/history.ui141
-rw-r--r--src/gui/panels/log.c71
-rw-r--r--src/gui/panels/log.ui59
-rw-r--r--src/gui/panels/panel.c3
-rw-r--r--src/gui/panels/regedit.c181
-rw-r--r--src/gui/panels/regedit.ui144
13 files changed, 687 insertions, 385 deletions
diff --git a/src/gui/panels/Makefile.am b/src/gui/panels/Makefile.am
index b273f82..8b63b24 100644
--- a/src/gui/panels/Makefile.am
+++ b/src/gui/panels/Makefile.am
@@ -5,7 +5,12 @@ noinst_LTLIBRARIES = libguipanels.la
UI_FILES = \
bintree.ui \
+ bookmarks.ui \
errors.ui \
+ glance.ui \
+ history.ui \
+ log.ui \
+ regedit.ui \
strings.ui \
symbols.ui \
welcome.ui
diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c
index 071ae75..91301bc 100644
--- a/src/gui/panels/bookmarks.c
+++ b/src/gui/panels/bookmarks.c
@@ -59,7 +59,6 @@ struct _GBookmarksPanel
{
GPanelItem parent; /* A laisser en premier */
- GtkTreeView *treeview; /* Composant d'affichage */
const regex_t *filter; /* Filtre appliqué ou NULL */
GtkMenu *menu; /* Menu contextuel pour param. */
@@ -129,7 +128,7 @@ static void on_bookmarks_selection_change(GtkTreeSelection *, gpointer);
static void on_config_param_modified(GCfgParam *, GBookmarksPanel *);
/* Actualise la valeur affichée d'un paramètre de configuration. */
-static void update_config_param_value(GtkTreeStore *, GtkTreeIter *);
+static void update_config_param_value(GtkListStore *, GtkTreeIter *);
/* Etablit une comparaison entre deux lignes de paramètres. */
static gint compare_bookmarks_list_columns(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gpointer);
@@ -248,13 +247,8 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel)
{
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
- GObject *ref; /* Espace de référencement */
- GtkTreeStore *store; /* Modèle de gestion */
- GtkWidget *treeview; /* Affichage de la liste */
- GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
- GtkTreeViewColumn *column; /* Colonne de la liste */
+ GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeSortable *sortable; /* Autre vision de la liste */
- GtkTreeSelection *select; /* Sélection dans la liste */
/* Eléments de base */
@@ -271,67 +265,11 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel)
/* Représentation graphique */
- base->widget = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show(base->widget);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(base->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(base->widget), GTK_SHADOW_IN);
-
- ref = G_OBJECT(base->widget);
- g_object_set_data(ref, "panel", panel);
-
- /* Partie signets */
-
- store = gtk_tree_store_new(BMC_COUNT, G_TYPE_OBJECT,
- CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- panel->treeview = GTK_TREE_VIEW(treeview);
-
- g_signal_connect(G_OBJECT(treeview), "button-press-event",
- G_CALLBACK(on_button_press_over_bookmarks), panel);
- g_signal_connect(G_OBJECT(treeview), "key-press-event",
- G_CALLBACK(on_key_pressed_over_params), panel);
-
- gtk_widget_show(treeview);
- gtk_container_add(GTK_CONTAINER(base->widget), treeview);
-
- g_object_unref(G_OBJECT(store));
-
- /* Cellules d'affichage */
-
- renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes("", renderer,
- "surface", BMC_PICTURE,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Physical address"), renderer,
- "text", BMC_PHYSICAL,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, BMC_PHYSICAL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Virtual address"), renderer,
- "text", BMC_VIRTUAL,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, BMC_VIRTUAL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
- ///g_signal_connect(renderer, "edited", G_CALLBACK(on_param_value_edited), store);
- column = gtk_tree_view_column_new_with_attributes(_("Comment"), renderer,
- "text", BMC_COMMENT,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, BMC_COMMENT);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ builder = g_panel_item_build(pitem, "bookmarks");
/* Tri de la liste */
- sortable = GTK_TREE_SORTABLE(store);
+ sortable = GTK_TREE_SORTABLE(gtk_builder_get_object(builder, "store"));
gtk_tree_sortable_set_sort_func(sortable, BMC_PHYSICAL, compare_bookmarks_list_columns,
GINT_TO_POINTER(BMC_PHYSICAL), NULL);
@@ -344,16 +282,20 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel)
gtk_tree_sortable_set_sort_column_id(sortable, BMC_COMMENT, GTK_SORT_ASCENDING);
- /* Prise en compte de la sélection */
-
- select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
- g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_bookmarks_selection_change), NULL);
-
/* Préparation du menu contextuel */
panel->menu = build_bookmarks_panel_menu(panel);
+ /* Connexion des signaux */
+
+ gtk_builder_add_callback_symbols(builder,
+ "on_button_press_over_bookmarks", G_CALLBACK(on_button_press_over_bookmarks),
+ "on_key_pressed_over_params", G_CALLBACK(on_key_pressed_over_params),
+ "on_bookmarks_selection_change", G_CALLBACK(on_bookmarks_selection_change),
+ NULL);
+
+ gtk_builder_connect_signals(builder, panel);
+
}
@@ -371,8 +313,7 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel)
static void g_bookmarks_panel_dispose(GBookmarksPanel *panel)
{
- if (panel->binary != NULL)
- g_object_unref(G_OBJECT(panel->binary));
+ g_clear_object(&panel->binary);
G_OBJECT_CLASS(g_bookmarks_panel_parent_class)->dispose(G_OBJECT(panel));
@@ -479,7 +420,8 @@ static void change_bookmarks_panel_current_content(GBookmarksPanel *panel, GLoad
static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary *binary)
{
GDbCollection *collec; /* Collection à lister ici */
- GtkTreeStore *store; /* Modèle de gestion */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GArchProcessor *proc; /* Architecture du binaire */
MemoryDataSize msize; /* Taille par défaut */
GList *items; /* Liste des éléments groupés */
@@ -514,8 +456,11 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary
}
- store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
- gtk_tree_store_clear(store);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+
+ gtk_list_store_clear(store);
/* Si le panneau actif ne représente pas un binaire... */
@@ -546,8 +491,8 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary
if (is_bookmark_filtered(panel, phys, virt, comment))
continue;
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
BMC_BOOKMARK, bookmark,
BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img,
BMC_PHYSICAL, phys,
@@ -579,8 +524,8 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary
static void on_collection_content_changed(GDbCollection *collec, DBAction action, GDbBookmark *bookmark, GBookmarksPanel *panel)
{
-
- GtkTreeStore *store; /* Modèle de gestion */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GArchProcessor *proc; /* Architecture du binaire */
@@ -595,10 +540,12 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
GDbBookmark *displayed; /* Elément de collection */
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+
if (action == DBA_ADD_ITEM || (action == DBA_CHANGE_STATE && g_db_item_is_active(G_DB_ITEM(bookmark))))
{
- store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
-
proc = g_loaded_binary_get_processor(panel->binary);
msize = g_arch_processor_get_memory_size(proc);
g_object_unref(G_OBJECT(proc));
@@ -608,8 +555,8 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
vmpa2_phys_to_string(addr, msize, phys, NULL);
vmpa2_virt_to_string(addr, msize, virt, NULL);
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
BMC_BOOKMARK, bookmark,
BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img,
BMC_PHYSICAL, phys,
@@ -624,8 +571,6 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
else /*if (action == DBA_CHANGE_STATE && g_db_item_is_active(G_DB_ITEM(bookmark)))*/
{
-
- store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
model = GTK_TREE_MODEL(store);
@@ -636,7 +581,7 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
if (bookmark == displayed)
{
- gtk_tree_store_remove(store, &iter);
+ gtk_list_store_remove(store, &iter);
break;
}
@@ -709,14 +654,17 @@ static void on_bookmarks_selection_change(GtkTreeSelection *selection, gpointer
static void on_config_param_modified(GCfgParam *param, GBookmarksPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeModel *model; /* Gestionnaire de données */
GtkTreeIter iter; /* Point de recherche */
gboolean looping; /* Autorisation de bouclage */
GCfgParam *item; /* Elément de la liste */
- model = gtk_tree_view_get_model(panel->treeview);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ model = GTK_TREE_MODEL(gtk_builder_get_object(builder, "store"));
- for (looping = gtk_tree_model_get_iter_first (model, &iter);
+ for (looping = gtk_tree_model_get_iter_first(model, &iter);
looping;
looping = gtk_tree_model_iter_next(model, &iter))
{
@@ -724,7 +672,7 @@ static void on_config_param_modified(GCfgParam *param, GBookmarksPanel *panel)
if (item == param)
{
- update_config_param_value(GTK_TREE_STORE(model), &iter);
+ update_config_param_value(GTK_LIST_STORE(model), &iter);
break;
}
@@ -747,7 +695,7 @@ static void on_config_param_modified(GCfgParam *param, GBookmarksPanel *panel)
* *
******************************************************************************/
-static void update_config_param_value(GtkTreeStore *store, GtkTreeIter *iter)
+static void update_config_param_value(GtkListStore *store, GtkTreeIter *iter)
{
GCfgParam *param; /* Paramètre à consulter */
ConfigParamState state; /* Etat du paramètre */
@@ -800,7 +748,7 @@ static void update_config_param_value(GtkTreeStore *store, GtkTreeIter *iter)
}
/*
- gtk_tree_store_set(store, iter,
+ gtk_list_store_set(store, iter,
CPC_BOLD, state & CPS_DEFAULT ? 400 : 800,
CPC_STATUS, state_desc,
CPC_VALUE, desc, -1);
@@ -1182,19 +1130,25 @@ static GDbBookmark *get_selected_panel_bookmark(GtkTreeView *treeview, GtkTreeIt
static void mcb_bookmarks_panel_edit(GtkMenuItem *menuitem, GBookmarksPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Arborescence manipulée */
GtkTreeIter iter; /* Point de la sélection */
GDbBookmark *mark; /* Signet sélectionné */
GtkTreeModel *model; /* Gestionnaire de données */
GtkTreePath *path; /* Chemin d'accès à ce point */
- mark = get_selected_panel_bookmark(panel->treeview, &iter);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ mark = get_selected_panel_bookmark(treeview, &iter);
if (mark == NULL) return;
- model = gtk_tree_view_get_model(panel->treeview);
+ model = gtk_tree_view_get_model(treeview);
path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_view_set_cursor(panel->treeview, path,
- gtk_tree_view_get_column(panel->treeview, BMC_COMMENT - BMC_PHYSICAL),
+ gtk_tree_view_set_cursor(treeview, path,
+ gtk_tree_view_get_column(treeview, BMC_COMMENT - BMC_PHYSICAL),
TRUE);
gtk_tree_path_free(path);
@@ -1219,9 +1173,15 @@ static void mcb_bookmarks_panel_edit(GtkMenuItem *menuitem, GBookmarksPanel *pan
static void mcb_bookmarks_panel_delete(GtkMenuItem *menuitem, GBookmarksPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Affichage de la liste */
GDbBookmark *mark; /* Signet sélectionné */
- mark = get_selected_panel_bookmark(panel->treeview, NULL);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ mark = get_selected_panel_bookmark(treeview, NULL);
if (mark == NULL) return;
g_loaded_binary_remove_from_collection(panel->binary, DBF_BOOKMARKS, G_DB_ITEM(mark));
diff --git a/src/gui/panels/bookmarks.ui b/src/gui/panels/bookmarks.ui
new file mode 100644
index 0000000..8ba6211
--- /dev/null
+++ b/src/gui/panels/bookmarks.ui
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="store">
+ <columns>
+ <!-- column-name bookmark -->
+ <column type="GObject"/>
+ <!-- column-name picture -->
+ <column type="CairoSurface"/>
+ <!-- column-name physical -->
+ <column type="gchararray"/>
+ <!-- column-name virtual -->
+ <column type="gchararray"/>
+ <!-- column-name comment -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkOffscreenWindow">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">store</property>
+ <signal name="button-press-event" handler="on_button_press_over_bookmarks" swapped="no"/>
+ <signal name="key-press-event" handler="on_key_pressed_over_params" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection">
+ <signal name="changed" handler="on_bookmarks_selection_change" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <child>
+ <object class="GtkCellRendererPixbuf"/>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Physical address</property>
+ <property name="sort_column_id">2</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Virtual address</property>
+ <property name="sort_column_id">3</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Comment</property>
+ <property name="sort_column_id">4</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">4</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c
index 00fe1ab..9b2c088 100644
--- a/src/gui/panels/glance.c
+++ b/src/gui/panels/glance.c
@@ -175,7 +175,7 @@ static void g_glance_panel_init(GGlancePanel *panel)
{
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
- GtkWidget *area; /* Surface de dessin réelle */
+ GtkBuilder *builder; /* Constructeur utilisé */
/* Eléments de base */
@@ -190,27 +190,21 @@ static void g_glance_panel_init(GGlancePanel *panel)
pitem->dock_at_startup = true;
pitem->path = strdup("MEs");
- /* Support de dessin */
+ /* Représentation graphique */
- base->widget = gtk_event_box_new();
+ builder = g_panel_item_build(pitem, "glance");
- area = gtk_drawing_area_new();
- gtk_widget_show(area);
+ /* Connexion des signaux */
- gtk_container_add(GTK_CONTAINER(base->widget), area);
- gtk_widget_show(base->widget);
+ gtk_builder_add_callback_symbols(builder,
+ "redraw_glance_area", G_CALLBACK(redraw_glance_area),
+ "on_glance_resize", G_CALLBACK(on_glance_resize),
+ "on_button_press_over_glance", G_CALLBACK(on_button_press_over_glance),
+ "on_button_release_over_glance", G_CALLBACK(on_button_release_over_glance),
+ "on_mouse_motion_over_glance", G_CALLBACK(on_mouse_motion_over_glance),
+ NULL);
- g_signal_connect(G_OBJECT(area), "draw",
- G_CALLBACK(redraw_glance_area), panel);
- g_signal_connect(G_OBJECT(area), "size-allocate",
- G_CALLBACK(on_glance_resize), panel);
-
- g_signal_connect(G_OBJECT(base->widget), "button-press-event",
- G_CALLBACK(on_button_press_over_glance), panel);
- g_signal_connect(G_OBJECT(base->widget), "button-release-event",
- G_CALLBACK(on_button_release_over_glance), panel);
- g_signal_connect(G_OBJECT(base->widget), "motion-notify-event",
- G_CALLBACK(on_mouse_motion_over_glance), panel);
+ gtk_builder_connect_signals(builder, panel);
}
diff --git a/src/gui/panels/glance.ui b/src/gui/panels/glance.ui
new file mode 100644
index 0000000..7430e85
--- /dev/null
+++ b/src/gui/panels/glance.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkOffscreenWindow">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkEventBox" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="button-press-event" handler="on_button_press_over_glance" swapped="no"/>
+ <signal name="button-release-event" handler="on_button_release_over_glance" swapped="no"/>
+ <signal name="motion-notify-event" handler="on_mouse_motion_over_glance" swapped="no"/>
+ <child>
+ <object class="GtkDrawingArea">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="draw" handler="redraw_glance_area" swapped="no"/>
+ <signal name="size-allocate" handler="on_glance_resize" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/src/gui/panels/gresource.xml b/src/gui/panels/gresource.xml
index b6f6cf9..d996ef1 100644
--- a/src/gui/panels/gresource.xml
+++ b/src/gui/panels/gresource.xml
@@ -7,7 +7,12 @@
<file compressed="true">../../../pixmaps/tbutton_expand.png</file>
<file compressed="true">../../../pixmaps/symbol_class_classic.png</file>
<file compressed="true">bintree.ui</file>
+ <file compressed="true">bookmarks.ui</file>
<file compressed="true">errors.ui</file>
+ <file compressed="true">glance.ui</file>
+ <file compressed="true">history.ui</file>
+ <file compressed="true">log.ui</file>
+ <file compressed="true">regedit.ui</file>
<file compressed="true">strings.ui</file>
<file compressed="true">symbols.ui</file>
<file compressed="true">welcome.ui</file>
diff --git a/src/gui/panels/history.c b/src/gui/panels/history.c
index 247c1a1..a1aa36b 100644
--- a/src/gui/panels/history.c
+++ b/src/gui/panels/history.c
@@ -36,7 +36,6 @@
#include "../../analysis/binary.h"
#include "../../glibext/chrysamarshal.h"
#include "../../glibext/signal.h"
-#include "../../gtkext/easygtk.h"
@@ -45,9 +44,6 @@ struct _GHistoryPanel
{
GPanelItem parent; /* A laisser en premier */
- GtkTreeView *treeview; /* Composant d'affichage */
- GtkTreeStore *store; /* Modèle de gestion */
-
GLoadedBinary *binary; /* Binaire à prendre en compte */
};
@@ -158,14 +154,8 @@ static void g_history_panel_init(GHistoryPanel *panel)
{
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
- GObject *ref; /* Espace de référencement */
- GtkWidget *scrollwnd; /* Support défilant */
- GtkWidget *treeview; /* Affichage de la liste */
- GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
- GtkTreeViewColumn *column; /* Colonne de la liste */
- GtkWidget *box; /* Séparation horizontale */
- GtkWidget *button; /* Bouton de cette même barre */
- GtkTreeSelection *select; /* Sélection dans la liste */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
/* Eléments de base */
@@ -182,80 +172,22 @@ static void g_history_panel_init(GHistoryPanel *panel)
/* Représentation graphique */
- base->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
- gtk_container_set_border_width(GTK_CONTAINER(base->widget), 8);
- gtk_widget_show(base->widget);
-
- ref = G_OBJECT(panel);
-
- /* Liste des éléments d'évolution */
-
- scrollwnd = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show(scrollwnd);
- gtk_box_pack_start(GTK_BOX(base->widget), scrollwnd, TRUE, TRUE, 0);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwnd), GTK_SHADOW_IN);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwnd), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwnd), GTK_SHADOW_IN);
-
- panel->store = gtk_tree_store_new(HTC_COUNT, G_TYPE_OBJECT, CAIRO_GOBJECT_TYPE_SURFACE,
- G_TYPE_STRING, G_TYPE_STRING);
-
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(panel->store));
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
- gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(treeview), TRUE);
-
- panel->treeview = GTK_TREE_VIEW(treeview);
-
- gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(panel->store), sort_history_lines, NULL, NULL);
-
- gtk_widget_show(treeview);
- gtk_container_add(GTK_CONTAINER(scrollwnd), treeview);
-
- g_object_unref(G_OBJECT(panel->store));
-
- /* Cellules d'affichage */
-
- renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes("", renderer,
- "surface", HTC_PICTURE,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer,
- "foreground", HTC_FOREGROUND,
- "text", HTC_LABEL,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ builder = g_panel_item_build(pitem, "history");
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(panel->store),
- GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
- /* Eléments de contrôle inférieurs */
+ gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), sort_history_lines, NULL, NULL);
- box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
- gtk_widget_set_halign(box, GTK_ALIGN_CENTER);
- gtk_widget_show(box);
- gtk_box_pack_start(GTK_BOX(base->widget), box, FALSE, TRUE, 0);
+ /* Connexion des signaux */
- button = qck_create_button_with_css_img(ref, "undo", "img-undo", _("Undo"),
- G_CALLBACK(do_history_undo), panel);
- gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
+ gtk_builder_add_callback_symbols(builder,
+ "on_history_selection_change", G_CALLBACK(on_history_selection_change),
+ "do_history_undo", G_CALLBACK(do_history_undo),
+ "do_history_redo", G_CALLBACK(do_history_redo),
+ "do_history_clean", G_CALLBACK(do_history_clean),
+ NULL);
- button = qck_create_button_with_css_img(ref, "redo", "img-redo", _("Redo"),
- G_CALLBACK(do_history_redo), panel);
- gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
-
- button = qck_create_button_with_css_img(NULL, NULL, "img-clean", _("Clean"),
- G_CALLBACK(do_history_clean), panel);
- gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
-
- /* Prise en compte de la sélection */
-
- select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- gtk_tree_selection_set_mode(select, GTK_SELECTION_BROWSE);
- g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_history_selection_change), panel);
+ gtk_builder_connect_signals(builder, panel);
}
@@ -274,8 +206,7 @@ static void g_history_panel_init(GHistoryPanel *panel)
static void g_history_panel_dispose(GHistoryPanel *panel)
{
- if (panel->binary != NULL)
- g_object_unref(G_OBJECT(panel->binary));
+ g_clear_object(&panel->binary);
G_OBJECT_CLASS(g_history_panel_parent_class)->dispose(G_OBJECT(panel));
@@ -344,7 +275,8 @@ static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedCo
GList *collections; /* Ensemble de collections */
GList *c; /* Boucle de parcours #1 */
GDbCollection *collec; /* Collection visée manipulée */
- GtkTreeStore *store; /* Modèle de gestion */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GList *items; /* Liste des éléments groupés */
GList *i; /* Boucle de parcours #2 */
GDbItem *item; /* Elément à intégrer */
@@ -380,8 +312,11 @@ static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedCo
if (panel->binary != NULL)
g_object_ref(G_OBJECT(binary));
- store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
- gtk_tree_store_clear(store);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+
+ gtk_list_store_clear(store);
/* Si le panneau actif ne représente pas un binaire... */
@@ -402,8 +337,8 @@ static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedCo
{
item = G_DB_ITEM(i->data);
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
HTC_ITEM, item,
//HTC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img,
HTC_FOREGROUND, g_db_item_is_active(item) ? NULL : "grey",
@@ -442,13 +377,21 @@ static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedCo
static void on_history_changed(GDbCollection *collec, DBAction action, GDbItem *item, GHistoryPanel *panel)
{
- GtkTreeModel *model; /* Modèle de gestion courant */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Arborescence manipulée */
+ GtkListStore *store; /* Modèle de gestion courant */
+ GtkTreeModel *model; /* Modèle de gestion générique */
GtkTreeSelection *selection; /* Nouvelle sélection à établir*/
GtkTreeIter iter; /* Boucle de parcours */
- model = GTK_TREE_MODEL(panel->store);
+ builder = G_PANEL_ITEM(panel)->builder;
- selection = gtk_tree_view_get_selection(panel->treeview);
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+ model = GTK_TREE_MODEL(store);
+
+ selection = gtk_tree_view_get_selection(treeview);
/* Mise à jour de la liste affichée */
@@ -484,8 +427,8 @@ static void on_history_changed(GDbCollection *collec, DBAction action, GDbItem *
{
case DBA_ADD_ITEM:
- gtk_tree_store_append(panel->store, &iter, NULL);
- gtk_tree_store_set(panel->store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
HTC_ITEM, item,
//HTC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img,
HTC_FOREGROUND, g_db_item_is_active(item) ? NULL : "grey",
@@ -497,14 +440,14 @@ static void on_history_changed(GDbCollection *collec, DBAction action, GDbItem *
case DBA_REM_ITEM:
if (find_changed_item(model, item, &iter))
- gtk_tree_store_remove(panel->store, &iter);
+ gtk_list_store_remove(store, &iter);
break;
case DBA_CHANGE_STATE:
if (find_changed_item(model, item, &iter))
- gtk_tree_store_set(panel->store, &iter,
+ gtk_list_store_set(store, &iter,
HTC_FOREGROUND, g_db_item_is_active(item) ? NULL : "grey",
-1);
break;
@@ -599,19 +542,22 @@ static gint sort_history_lines(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter
static void on_history_selection_change(GtkTreeSelection *selection, GHistoryPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeIter iter; /* Point de sélection */
GtkTreeModel *model; /* Modèle de gestion */
GDbItem *item; /* Elément de collection */
GtkWidget *button; /* Bouton de barre de contrôle */
+ builder = G_PANEL_ITEM(panel)->builder;
+
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
gtk_tree_model_get(model, &iter, HTC_ITEM, &item, -1);
- button = GTK_WIDGET(g_object_get_data(G_OBJECT(panel), "undo"));
+ button = GTK_WIDGET(gtk_builder_get_object(builder, "undo"));
gtk_widget_set_sensitive(button, g_db_item_is_active(item));
- button = GTK_WIDGET(g_object_get_data(G_OBJECT(panel), "redo"));
+ button = GTK_WIDGET(gtk_builder_get_object(builder, "redo"));
gtk_widget_set_sensitive(button, !g_db_item_is_active(item));
g_object_unref(G_OBJECT(item));
@@ -620,10 +566,10 @@ static void on_history_selection_change(GtkTreeSelection *selection, GHistoryPan
else
{
- button = GTK_WIDGET(g_object_get_data(G_OBJECT(panel), "undo"));
+ button = GTK_WIDGET(gtk_builder_get_object(builder, "undo"));
gtk_widget_set_sensitive(button, FALSE);
- button = GTK_WIDGET(g_object_get_data(G_OBJECT(panel), "redo"));
+ button = GTK_WIDGET(gtk_builder_get_object(builder, "redo"));
gtk_widget_set_sensitive(button, FALSE);
}
@@ -646,13 +592,19 @@ static void on_history_selection_change(GtkTreeSelection *selection, GHistoryPan
static void do_history_undo(GtkButton *button, GHistoryPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Arborescence manipulée */
GtkTreeSelection *selection; /* Sélection courante */
GtkTreeModel *model; /* Modèle de gestion de données*/
GtkTreeIter iter; /* Pointeur vers la ligne visée*/
GDbItem *item; /* Elément de collection */
GDbClient *client; /* Connexion vers la base */
- selection = gtk_tree_view_get_selection(panel->treeview);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ selection = gtk_tree_view_get_selection(treeview);
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
@@ -687,13 +639,19 @@ static void do_history_undo(GtkButton *button, GHistoryPanel *panel)
static void do_history_redo(GtkButton *button, GHistoryPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Arborescence manipulée */
GtkTreeSelection *selection; /* Sélection courante */
GtkTreeModel *model; /* Modèle de gestion de données*/
GtkTreeIter iter; /* Pointeur vers la ligne visée*/
GDbItem *item; /* Elément de collection */
GDbClient *client; /* Connexion vers la base */
- selection = gtk_tree_view_get_selection(panel->treeview);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ selection = gtk_tree_view_get_selection(treeview);
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
diff --git a/src/gui/panels/history.ui b/src/gui/panels/history.ui
new file mode 100644
index 0000000..d62216a
--- /dev/null
+++ b/src/gui/panels/history.ui
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="store">
+ <columns>
+ <!-- column-name item -->
+ <column type="GObject"/>
+ <!-- column-name picture -->
+ <column type="CairoSurface"/>
+ <!-- column-name foreground -->
+ <column type="gchararray"/>
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkOffscreenWindow">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">8</property>
+ <property name="margin_right">8</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">store</property>
+ <property name="headers_visible">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection">
+ <signal name="changed" handler="on_history_selection_change" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">picture</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"/>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">label</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="foreground">2</attribute>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkButton" id="undo">
+ <property name="label">gtk-undo</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <property name="always_show_image">True</property>
+ <signal name="clicked" handler="do_history_undo" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="redo">
+ <property name="label">gtk-redo</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <property name="always_show_image">True</property>
+ <signal name="clicked" handler="do_history_redo" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="label">gtk-clear</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <property name="always_show_image">True</property>
+ <signal name="clicked" handler="do_history_clean" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/src/gui/panels/log.c b/src/gui/panels/log.c
index 9c109d4..f0252e9 100644
--- a/src/gui/panels/log.c
+++ b/src/gui/panels/log.c
@@ -142,11 +142,6 @@ static void g_log_panel_init(GLogPanel *panel)
{
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
- GtkWidget *scrolled; /* Fenêtre avec défilements */
- GtkTreeStore *store; /* Modèle de gestion */
- GtkWidget *treeview; /* Affichage de la liste */
- GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
- GtkTreeViewColumn *column; /* Colonne de la liste */
/* Eléments de base */
@@ -163,43 +158,7 @@ static void g_log_panel_init(GLogPanel *panel)
/* Représentation graphique */
- scrolled = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show(scrolled);
-
- base->widget = scrolled;
-
- /* Construction graphique */
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
-
- store = gtk_tree_store_new(LGC_COUNT, G_TYPE_STRING, G_TYPE_STRING);
- g_object_set_data(G_OBJECT(scrolled), "store", store);
-
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- g_object_set_data(G_OBJECT(scrolled), "treeview", treeview);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
- gtk_widget_show(treeview);
- gtk_container_add(GTK_CONTAINER(scrolled), treeview);
-
- g_object_unref(G_OBJECT(store));
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_visible(column, FALSE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column);
-
- column = gtk_tree_view_column_new();
-
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_add_attribute(column, renderer, "stock-id", LGC_PICTURE);
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_add_attribute(column, renderer, "markup", LGC_STRING);
-
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ g_panel_item_build(pitem, "log");
}
@@ -283,7 +242,7 @@ void g_log_panel_add_message(GLogPanel *panel, LogMessageType type, const char *
{
log_data *data; /* Paramètres à joindre */
- data = (log_data *)calloc(1, sizeof(log_data));
+ data = calloc(1, sizeof(log_data));
data->item = G_PANEL_ITEM(panel);
data->type = type;
@@ -311,58 +270,58 @@ void g_log_panel_add_message(GLogPanel *panel, LogMessageType type, const char *
static gboolean log_message(log_data *data)
{
- GtkWidget *panel; /* Panneau à traiter */
- GtkTreeStore *store; /* Modèle de gestion */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GtkTreeIter iter; /* Point d'insertion */
GtkTreeView *treeview; /* Affichage de la liste */
- /* Mise en place du message */
+ builder = G_PANEL_ITEM(data->item)->builder;
- panel = g_editor_item_get_widget(G_EDITOR_ITEM(data->item));
+ /* Mise en place du message */
- store = g_object_get_data(G_OBJECT(panel), "store");
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
- gtk_tree_store_append(store, &iter, NULL);
+ gtk_list_store_append(store, &iter);
switch (data->type)
{
case LMT_INFO:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_PICTURE, "gtk-info",
LGC_STRING, data->msg,
-1);
break;
case LMT_BAD_BINARY:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_PICTURE, "gtk-dialog-warning",
LGC_STRING, data->msg,
-1);
break;
case LMT_PROCESS:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_PICTURE, "gtk-execute",
LGC_STRING, data->msg,
-1);
break;
case LMT_ERROR:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_PICTURE, "gtk-dialog-error",
LGC_STRING, data->msg,
-1);
break;
case LMT_WARNING:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_PICTURE, "gtk-dialog-warning",
LGC_STRING, data->msg,
-1);
break;
default:
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
LGC_STRING, data->msg,
-1);
break;
@@ -371,7 +330,7 @@ static gboolean log_message(log_data *data)
/* Défilement pour pointer à l'affichage */
- treeview = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(panel), "treeview"));
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
scroll_to_treeview_iter(treeview, GTK_TREE_MODEL(store), &iter);
diff --git a/src/gui/panels/log.ui b/src/gui/panels/log.ui
new file mode 100644
index 0000000..4ffe96c
--- /dev/null
+++ b/src/gui/panels/log.ui
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="store">
+ <columns>
+ <!-- column-name picture -->
+ <column type="gchararray"/>
+ <!-- column-name string -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkOffscreenWindow">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">store</property>
+ <property name="headers_visible">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">picture</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"/>
+ <attributes>
+ <attribute name="stock-id">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">string</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="markup">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c
index c21e1b2..164fca7 100644
--- a/src/gui/panels/panel.c
+++ b/src/gui/panels/panel.c
@@ -201,8 +201,7 @@ static void g_panel_item_dockable_interface_init(GtkDockableInterface *iface)
static void g_panel_item_dispose(GPanelItem *item)
{
- if (item->builder != NULL) // REMME
- g_object_unref(G_OBJECT(item->builder));
+ g_clear_object(&item->builder);
G_OBJECT_CLASS(g_panel_item_parent_class)->dispose(G_OBJECT(item));
diff --git a/src/gui/panels/regedit.c b/src/gui/panels/regedit.c
index 7ec05c0..8ecc99b 100644
--- a/src/gui/panels/regedit.c
+++ b/src/gui/panels/regedit.c
@@ -52,7 +52,6 @@ struct _GRegeditPanel
{
GPanelItem parent; /* A laisser en premier */
- GtkTreeView *treeview; /* Composant d'affichage */
regex_t *filter; /* Filtre appliqué ou NULL */
GtkMenu *menu; /* Menu contextuel pour param. */
@@ -109,7 +108,7 @@ static void reload_config_into_treeview(GRegeditPanel *, GGenConfig *);
static void on_config_param_modified(GCfgParam *, GRegeditPanel *);
/* Actualise la valeur affichée d'un paramètre de configuration. */
-static void update_config_param_value(GtkTreeStore *, GtkTreeIter *);
+static void update_config_param_value(GtkListStore *, GtkTreeIter *);
/* Etablit une comparaison entre deux lignes de paramètres. */
static gint compare_config_list_columns(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gpointer);
@@ -118,7 +117,7 @@ static gint compare_config_list_columns(GtkTreeModel *, GtkTreeIter *, GtkTreeIt
static gboolean on_key_pressed_over_params(GtkTreeView *, GdkEventKey *, GRegeditPanel *);
/* Réagit à une édition de la valeur d'un paramètre. */
-static void on_param_value_edited(GtkCellRendererText *, gchar *, gchar *, GtkTreeStore *);
+static void on_param_value_edited(GtkCellRendererText *, gchar *, gchar *, GRegeditPanel *);
@@ -206,14 +205,8 @@ static void g_regedit_panel_init(GRegeditPanel *panel)
{
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
- GObject *ref; /* Espace de référencement */
- GtkWidget *label; /* Etiquette à utiliser */
- GtkWidget *search; /* Zone de recherche */
- GtkWidget *scrolled; /* Fenêtre défilante */
- GtkTreeStore *store; /* Modèle de gestion */
- GtkWidget *treeview; /* Affichage de la liste */
- GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
- GtkTreeViewColumn *column; /* Colonne de la liste */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GObject *vrenderer; /* Moteur de rendu de colonne */
GtkTreeSortable *sortable; /* Autre vision de la liste */
/* Eléments de base */
@@ -231,93 +224,15 @@ static void g_regedit_panel_init(GRegeditPanel *panel)
/* Représentation graphique */
- base->widget = gtk_grid_new();
- gtk_widget_show(base->widget);
-
- gtk_grid_set_row_spacing(GTK_GRID(base->widget), 8);
-
- ref = G_OBJECT(base->widget);
- g_object_set_data(ref, "panel", panel);
-
- /* Partie recherche */
-
- label = qck_create_label(NULL, NULL, _("Look for:"));
- g_object_set(label, "margin", 8, NULL);
- gtk_grid_attach(GTK_GRID(base->widget), label, 0, 0, 1, 1);
-
- search = gtk_search_entry_new();
- g_signal_connect(search, "search-changed", G_CALLBACK(on_param_search_changed), panel);
- g_signal_connect(search, "focus-in-event", G_CALLBACK(track_focus_change_in_text_area), NULL);
- g_signal_connect(search, "focus-out-event", G_CALLBACK(track_focus_change_in_text_area), NULL);
- gtk_widget_show(search);
- gtk_widget_set_hexpand(search, TRUE);
- gtk_grid_attach_next_to(GTK_GRID(base->widget), search, label, GTK_POS_RIGHT, 1, 1);
-
- /* Partie paramètres */
-
- scrolled = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show(scrolled);
- gtk_widget_set_vexpand(scrolled, TRUE);
- gtk_grid_attach_next_to(GTK_GRID(base->widget), scrolled, label, GTK_POS_BOTTOM, 2, 1);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
-
- store = gtk_tree_store_new(LGC_COUNT, G_TYPE_OBJECT, G_TYPE_INT,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- panel->treeview = GTK_TREE_VIEW(treeview);
-
- g_signal_connect(G_OBJECT(treeview), "button-press-event",
- G_CALLBACK(on_button_press_over_params), panel);
- g_signal_connect(G_OBJECT(treeview), "key-press-event",
- G_CALLBACK(on_key_pressed_over_params), panel);
-
- gtk_widget_show(treeview);
- gtk_container_add(GTK_CONTAINER(scrolled), treeview);
-
- g_object_unref(G_OBJECT(store));
-
- /* Cellules d'affichage */
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Access path"), renderer,
- "text", CPC_PATH,
- "weight", CPC_BOLD,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, CPC_PATH);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Status"), renderer,
- "text", CPC_STATUS,
- "weight", CPC_BOLD,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, CPC_STATUS);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Type"), renderer,
- "text", CPC_TYPE,
- "weight", CPC_BOLD,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, CPC_TYPE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- renderer = gtk_cell_renderer_text_new();
- g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
- g_signal_connect(renderer, "edited", G_CALLBACK(on_param_value_edited), store);
- column = gtk_tree_view_column_new_with_attributes(_("Value"), renderer,
- "text", CPC_VALUE,
- "weight", CPC_BOLD,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, CPC_VALUE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ builder = g_panel_item_build(pitem, "regedit");
+
+ vrenderer = G_OBJECT(gtk_builder_get_object(builder, "vrenderer"));
+
+ g_object_set(vrenderer, "editable", TRUE, NULL);
/* Tri de la liste */
- sortable = GTK_TREE_SORTABLE(store);
+ sortable = GTK_TREE_SORTABLE(gtk_builder_get_object(builder, "store"));
gtk_tree_sortable_set_sort_func(sortable, CPC_PATH, compare_config_list_columns,
GINT_TO_POINTER(CPC_PATH), NULL);
@@ -337,6 +252,18 @@ static void g_regedit_panel_init(GRegeditPanel *panel)
panel->menu = build_param_panel_menu(panel);
+ /* Connexion des signaux */
+
+ gtk_builder_add_callback_symbols(builder,
+ "on_param_search_changed", G_CALLBACK(on_param_search_changed),
+ "track_focus_change_in_text_area", G_CALLBACK(track_focus_change_in_text_area),
+ "on_button_press_over_params", G_CALLBACK(on_button_press_over_params),
+ "on_key_pressed_over_params", G_CALLBACK(on_key_pressed_over_params),
+ "on_param_value_edited", G_CALLBACK(on_param_value_edited),
+ NULL);
+
+ gtk_builder_connect_signals(builder, panel);
+
}
@@ -430,15 +357,19 @@ GPanelItem *g_regedit_panel_new(void)
static void reload_config_into_treeview(GRegeditPanel *panel, GGenConfig *config)
{
- GtkTreeStore *store; /* Modèle de gestion */
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GList *params; /* Paramètres de configuration */
GCfgParam *param; /* Paramètre en cours d'étude */
GList *p; /* Boucle de parcours */
char *type_desc; /* Type de paramètre */
GtkTreeIter iter; /* Point d'insertion */
- store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
- gtk_tree_store_clear(store);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+
+ gtk_list_store_clear(store);
g_generic_config_rlock(config);
@@ -475,8 +406,8 @@ static void reload_config_into_treeview(GRegeditPanel *panel, GGenConfig *config
}
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
CPC_PARAM, param,
CPC_PATH, g_config_param_get_path(param),
CPC_TYPE, type_desc,
@@ -508,14 +439,20 @@ static void reload_config_into_treeview(GRegeditPanel *panel, GGenConfig *config
static void on_config_param_modified(GCfgParam *param, GRegeditPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Affichage de la liste */
GtkTreeModel *model; /* Gestionnaire de données */
GtkTreeIter iter; /* Point de recherche */
gboolean looping; /* Autorisation de bouclage */
GCfgParam *item; /* Elément de la liste */
- model = gtk_tree_view_get_model(panel->treeview);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ model = gtk_tree_view_get_model(treeview);
- for (looping = gtk_tree_model_get_iter_first (model, &iter);
+ for (looping = gtk_tree_model_get_iter_first(model, &iter);
looping;
looping = gtk_tree_model_iter_next(model, &iter))
{
@@ -523,7 +460,7 @@ static void on_config_param_modified(GCfgParam *param, GRegeditPanel *panel)
if (item == param)
{
- update_config_param_value(GTK_TREE_STORE(model), &iter);
+ update_config_param_value(GTK_LIST_STORE(model), &iter);
break;
}
@@ -546,7 +483,7 @@ static void on_config_param_modified(GCfgParam *param, GRegeditPanel *panel)
* *
******************************************************************************/
-static void update_config_param_value(GtkTreeStore *store, GtkTreeIter *iter)
+static void update_config_param_value(GtkListStore *store, GtkTreeIter *iter)
{
GCfgParam *param; /* Paramètre à consulter */
ConfigParamState state; /* Etat du paramètre */
@@ -606,7 +543,7 @@ static void update_config_param_value(GtkTreeStore *store, GtkTreeIter *iter)
}
- gtk_tree_store_set(store, iter,
+ gtk_list_store_set(store, iter,
CPC_BOLD, state & CPS_DEFAULT ? 400 : 800,
CPC_STATUS, state_desc,
CPC_VALUE, desc, -1);
@@ -718,7 +655,7 @@ static gboolean on_key_pressed_over_params(GtkTreeView *treeview, GdkEventKey *e
* Paramètres : renderer = moteur de rendu pour la cellule. *
* path = chemin d'accès vers la cellule éditée. *
* new = nouvelle valeur sous forme de texte à valider. *
-* store = gestionnaire des données de la liste affichée. *
+* panel = panneau d'affichage sur lequel s'appuyer. *
* *
* Description : Réagit à une édition de la valeur d'un paramètre. *
* *
@@ -728,8 +665,10 @@ static gboolean on_key_pressed_over_params(GtkTreeView *treeview, GdkEventKey *e
* *
******************************************************************************/
-static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gchar *new, GtkTreeStore *store)
+static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gchar *new, GRegeditPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkListStore *store; /* Modèle de gestion */
GtkTreePath *tree_path; /* Chemin d'accès natif */
GtkTreeIter iter; /* Point de la modification */
GCfgParam *param; /* Paramètre à actualiser */
@@ -738,6 +677,10 @@ static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gc
int ulong; /* Valeur entière positive */
char *end; /* Pointeur vers '\0' final ? */
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store"));
+
tree_path = gtk_tree_path_new_from_string(path);
if (tree_path == NULL) return;
@@ -1004,12 +947,18 @@ static GCfgParam *get_selected_panel_param(GtkTreeView *treeview, GtkTreeIter *s
static void mcb_param_panel_copy(GtkMenuItem *menuitem, GRegeditPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Affichage de la liste */
GCfgParam *param; /* Paramètre sélectionné */
const char *content; /* Prochain contenu à diffuser */
gint clen; /* Taille de ce contenu */
GtkClipboard *clipboard; /* Presse-papiers à remplir */
- param = get_selected_panel_param(panel->treeview, NULL);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ param = get_selected_panel_param(treeview, NULL);
if (param == NULL) return;
content = g_config_param_get_path(param);
@@ -1041,9 +990,15 @@ static void mcb_param_panel_copy(GtkMenuItem *menuitem, GRegeditPanel *panel)
static void mcb_param_panel_empty(GtkMenuItem *menuitem, GRegeditPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Affichage de la liste */
GCfgParam *param; /* Paramètre sélectionné */
- param = get_selected_panel_param(panel->treeview, NULL);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ param = get_selected_panel_param(treeview, NULL);
if (param == NULL) return;
g_config_param_make_empty(param);
@@ -1068,9 +1023,15 @@ static void mcb_param_panel_empty(GtkMenuItem *menuitem, GRegeditPanel *panel)
static void mcb_param_panel_reset(GtkMenuItem *menuitem, GRegeditPanel *panel)
{
+ GtkBuilder *builder; /* Constructeur utilisé */
+ GtkTreeView *treeview; /* Affichage de la liste */
GCfgParam *param; /* Paramètre sélectionné */
- param = get_selected_panel_param(panel->treeview, NULL);
+ builder = G_PANEL_ITEM(panel)->builder;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
+
+ param = get_selected_panel_param(treeview, NULL);
if (param == NULL) return;
g_config_param_reset(param);
diff --git a/src/gui/panels/regedit.ui b/src/gui/panels/regedit.ui
new file mode 100644
index 0000000..7bfd016
--- /dev/null
+++ b/src/gui/panels/regedit.ui
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="store">
+ <columns>
+ <!-- column-name param -->
+ <column type="GObject"/>
+ <!-- column-name bold -->
+ <column type="gint"/>
+ <!-- column-name path -->
+ <column type="gchararray"/>
+ <!-- column-name status -->
+ <column type="gchararray"/>
+ <!-- column-name type -->
+ <column type="gchararray"/>
+ <!-- column-name value -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkOffscreenWindow">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkGrid" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">8</property>
+ <property name="column_spacing">8</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Look for:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSearchEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="primary_icon_name">edit-find-symbolic</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">False</property>
+ <signal name="focus-in-event" handler="track_focus_change_in_text_area" swapped="no"/>
+ <signal name="focus-out-event" handler="track_focus_change_in_text_area" swapped="no"/>
+ <signal name="search-changed" handler="on_param_search_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">store</property>
+ <signal name="button-press-event" handler="on_button_press_over_params" swapped="no"/>
+ <signal name="key-press-event" handler="on_key_pressed_over_params" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Access path</property>
+ <property name="sort_column_id">2</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ <attribute name="weight">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Status</property>
+ <property name="sort_column_id">3</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ <attribute name="weight">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Type</property>
+ <property name="sort_column_id">4</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">4</attribute>
+ <attribute name="weight">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Value</property>
+ <property name="sort_column_id">5</property>
+ <child>
+ <object class="GtkCellRendererText" id="vrenderer">
+ <signal name="edited" handler="on_param_value_edited" swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="text">5</attribute>
+ <attribute name="weight">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>