summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-12-24 16:26:51 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-12-24 16:26:51 (GMT)
commit93dfdc30d815629a7e0c9393f0e8f0462844ff56 (patch)
tree8fe59f8c0186871ffd79873ec20905bf39170528 /src/gui
parentc388ad8910dbb1a3c478176d8b1ab3142fdbd9d5 (diff)
Ported the panel update mechanisms to the Python API.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/panels/bintree.c23
-rw-r--r--src/gui/panels/errors.c15
-rw-r--r--src/gui/panels/strings.c19
-rw-r--r--src/gui/panels/symbols.c19
-rw-r--r--src/gui/panels/symbols.ui93
-rw-r--r--src/gui/panels/updating-int.h4
-rw-r--r--src/gui/panels/updating.c56
-rw-r--r--src/gui/panels/updating.h4
8 files changed, 133 insertions, 100 deletions
diff --git a/src/gui/panels/bintree.c b/src/gui/panels/bintree.c
index db5e774..c31bd88 100644
--- a/src/gui/panels/bintree.c
+++ b/src/gui/panels/bintree.c
@@ -190,7 +190,7 @@ struct _bintree_update_data
static bool is_bintree_column_matching(const bintree_update_data *, GBinPortion *, gint, regmatch_t *);
/* Prépare une opération de mise à jour de panneau. */
-static const char *g_bintree_panel_setup(const GBintreePanel *, unsigned int, size_t *, bintree_update_data **);
+static bool g_bintree_panel_setup(const GBintreePanel *, unsigned int, size_t *, bintree_update_data **, char **);
/* Bascule l'affichage d'un panneau avant mise à jour. */
static void g_bintree_panel_introduce(const GBintreePanel *, unsigned int, bintree_update_data *);
@@ -202,7 +202,7 @@ static void g_bintree_panel_process(const GBintreePanel *, unsigned int, GtkStat
static void g_bintree_panel_conclude(GBintreePanel *, unsigned int, bintree_update_data *);
/* Supprime les données dynamiques utilisées à la mise à jour. */
-static void g_bintree_panel_clean_data(GUpdatablePanel *, unsigned int, bintree_update_data *);
+static void g_bintree_panel_clean_data(const GUpdatablePanel *, unsigned int, bintree_update_data *);
@@ -1132,24 +1132,27 @@ static bool is_bintree_column_matching(const bintree_update_data *data, GBinPort
* uid = identifiant de la phase de traitement. *
* count = nombre d'étapes à prévoir dans le traitement. [OUT] *
* data = données sur lesquelles s'appuyer ensuite. [OUT] *
+* msg = description du message d'information. [OUT] *
* *
* Description : Prépare une opération de mise à jour de panneau. *
* *
-* Retour : Description du message d'information. *
+* Retour : Bilan de la préparation. *
* *
* Remarques : - *
* *
******************************************************************************/
-static const char *g_bintree_panel_setup(const GBintreePanel *panel, unsigned int uid, size_t *count, bintree_update_data **data)
+static bool g_bintree_panel_setup(const GBintreePanel *panel, unsigned int uid, size_t *count, bintree_update_data **data, char **msg)
{
- const char *result; /* Message à retourner */
+ bool result; /* Bilan à retourner */
#ifndef NDEBUG
int ret; /* Bilan de mise en place */
#endif
GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeView *treeview; /* Arborescence graphique */
+ result = true;
+
*data = malloc(sizeof(bintree_update_data));
switch (uid)
@@ -1159,7 +1162,7 @@ static const char *g_bintree_panel_setup(const GBintreePanel *panel, unsigned in
*count = 0;
(*data)->count = 0;
- result = _("Loading portions contained in the binary format...");
+ *msg = strdup(_("Loading portions contained in the binary format..."));
break;
@@ -1168,20 +1171,20 @@ static const char *g_bintree_panel_setup(const GBintreePanel *panel, unsigned in
*count = panel->count;
(*data)->count = panel->count;
- result = _("Filtering portions contained in the binary format...");
+ *msg = strdup(_("Filtering portions contained in the binary format..."));
break;
default: /* Pour GCC... */
assert(false);
- result = "";
+ result = false;
break;
}
if (G_PANEL_ITEM(panel)->filter != NULL)
{
- (*data)->filter = (regex_t *)malloc(sizeof(regex_t));
+ (*data)->filter = malloc(sizeof(regex_t));
#ifndef NDEBUG
ret = regcomp((*data)->filter, G_PANEL_ITEM(panel)->filter, REG_EXTENDED | REG_ICASE);
@@ -1375,7 +1378,7 @@ static void g_bintree_panel_conclude(GBintreePanel *panel, unsigned int uid, bin
* *
******************************************************************************/
-static void g_bintree_panel_clean_data(GUpdatablePanel *panel, unsigned int uid, bintree_update_data *data)
+static void g_bintree_panel_clean_data(const GUpdatablePanel *panel, unsigned int uid, bintree_update_data *data)
{
size_t i; /* Boucle de parcours */
diff --git a/src/gui/panels/errors.c b/src/gui/panels/errors.c
index d567511..2b5353f 100644
--- a/src/gui/panels/errors.c
+++ b/src/gui/panels/errors.c
@@ -178,7 +178,7 @@ struct _error_update_data
/* Prépare une opération de mise à jour de panneau. */
-static const char *g_error_panel_setup(const GErrorPanel *, unsigned int, size_t *, error_update_data **);
+static bool g_error_panel_setup(const GErrorPanel *, unsigned int, size_t *, error_update_data **, char **);
/* Bascule l'affichage d'un panneau avant mise à jour. */
static void g_error_panel_introduce(const GErrorPanel *, unsigned int, error_update_data *);
@@ -1046,6 +1046,7 @@ static void on_error_selection_changed(GtkTreeSelection *selection, gpointer unu
* uid = identifiant de la phase de traitement. *
* count = nombre d'étapes à prévoir dans le traitement. [OUT] *
* data = données sur lesquelles s'appuyer ensuite. [OUT] *
+* msg = description du message d'information. [OUT] *
* *
* Description : Prépare une opération de mise à jour de panneau. *
* *
@@ -1055,14 +1056,16 @@ static void on_error_selection_changed(GtkTreeSelection *selection, gpointer unu
* *
******************************************************************************/
-static const char *g_error_panel_setup(const GErrorPanel *panel, unsigned int uid, size_t *count, error_update_data **data)
+static bool g_error_panel_setup(const GErrorPanel *panel, unsigned int uid, size_t *count, error_update_data **data, char **msg)
{
- const char *result; /* Message à retourner */
+ bool result; /* Bilan à retourner */
GBinFormat *format; /* Format du binaire */
size_t fcount; /* Quantité d'erreurs #1 */
GArchProcessor *proc; /* Architecture du binaire */
size_t pcount; /* Quantité d'erreurs #2 */
+ result = true;
+
*data = malloc(sizeof(error_update_data));
switch (uid)
@@ -1087,7 +1090,7 @@ static const char *g_error_panel_setup(const GErrorPanel *panel, unsigned int ui
*count = fcount + pcount;
- result = _("Loading errors occurred during the disassembling process...");
+ *msg = strdup(_("Loading errors occurred during the disassembling process..."));
(*data)->count = *count;
(*data)->kept = 0;
@@ -1098,7 +1101,7 @@ static const char *g_error_panel_setup(const GErrorPanel *panel, unsigned int ui
*count = panel->count;
- result = _("Filtering errors occurred during the disassembling process...");
+ *msg = strdup(_("Filtering errors occurred during the disassembling process..."));
(*data)->count = panel->count;
(*data)->kept = 0;
@@ -1107,7 +1110,7 @@ static const char *g_error_panel_setup(const GErrorPanel *panel, unsigned int ui
default: /* Pour GCC... */
assert(false);
- result = "";
+ result = false;
break;
}
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index 33b715b..f9d6b00 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -211,7 +211,7 @@ static bool is_string_name_matching(const strings_update_data *, GtkTreeModel *,
static bool is_string_value_matching(const strings_update_data *, GtkTreeModel *, GtkTreeIter *, regmatch_t *);
/* Prépare une opération de mise à jour de panneau. */
-static const char *g_strings_panel_setup(const GStringsPanel *, unsigned int, size_t *, strings_update_data **);
+static bool g_strings_panel_setup(const GStringsPanel *, unsigned int, size_t *, strings_update_data **, char **);
/* Bascule l'affichage d'un panneau avant mise à jour. */
static void g_strings_panel_introduce(const GStringsPanel *, unsigned int, strings_update_data *);
@@ -223,7 +223,7 @@ static void g_strings_panel_process(const GStringsPanel *, unsigned int, GtkStat
static void g_strings_panel_conclude(GStringsPanel *, unsigned int, strings_update_data *);
/* Supprime les données dynamiques utilisées à la mise à jour. */
-static void g_strings_panel_clean_data(GUpdatablePanel *, unsigned int, strings_update_data *);
+static void g_strings_panel_clean_data(const GUpdatablePanel *, unsigned int, strings_update_data *);
@@ -1526,6 +1526,7 @@ static bool is_string_value_matching(const strings_update_data *data, GtkTreeMod
* uid = identifiant de la phase de traitement. *
* count = nombre d'étapes à prévoir dans le traitement. [OUT] *
* data = données sur lesquelles s'appuyer ensuite. [OUT] *
+* msg = description du message d'information. [OUT] *
* *
* Description : Prépare une opération de mise à jour de panneau. *
* *
@@ -1535,14 +1536,16 @@ static bool is_string_value_matching(const strings_update_data *data, GtkTreeMod
* *
******************************************************************************/
-static const char *g_strings_panel_setup(const GStringsPanel *panel, unsigned int uid, size_t *count, strings_update_data **data)
+static bool g_strings_panel_setup(const GStringsPanel *panel, unsigned int uid, size_t *count, strings_update_data **data, char **msg)
{
- const char *result; /* Message à retourner */
+ bool result; /* Bilan à retourner */
GBinFormat *format; /* Format du binaire */
#ifndef NDEBUG
int ret; /* Bilan de mise en place */
#endif
+ result = true;
+
*data = malloc(sizeof(strings_update_data));
switch (uid)
@@ -1559,7 +1562,7 @@ static const char *g_strings_panel_setup(const GStringsPanel *panel, unsigned in
(*data)->count = 0;
- result = _("Loading strings available in the binary format...");
+ *msg = strdup(_("Loading strings available in the binary format..."));
break;
@@ -1568,13 +1571,13 @@ static const char *g_strings_panel_setup(const GStringsPanel *panel, unsigned in
*count = panel->count;
(*data)->count = panel->count;
- result = _("Filtering strings available in the binary format...");
+ *msg = strdup(_("Filtering strings available in the binary format..."));
break;
default: /* Pour GCC... */
assert(false);
- result = "";
+ result = false;
break;
}
@@ -1735,7 +1738,7 @@ static void g_strings_panel_conclude(GStringsPanel *panel, unsigned int uid, str
* *
******************************************************************************/
-static void g_strings_panel_clean_data(GUpdatablePanel *panel, unsigned int uid, strings_update_data *data)
+static void g_strings_panel_clean_data(const GUpdatablePanel *panel, unsigned int uid, strings_update_data *data)
{
if (data->filter != NULL)
{
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index 152d705..ab7a414 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -218,7 +218,7 @@ struct _symbols_update_data
static bool is_symbol_matching(const symbols_update_data *, const GBinSymbol *, regmatch_t *);
/* Prépare une opération de mise à jour de panneau. */
-static const char *g_symbols_panel_setup(const GSymbolsPanel *, unsigned int, size_t *, symbols_update_data **);
+static bool g_symbols_panel_setup(const GSymbolsPanel *, unsigned int, size_t *, symbols_update_data **, char **);
/* Bascule l'affichage d'un panneau avant mise à jour. */
static void g_symbols_panel_introduce(const GSymbolsPanel *, unsigned int, symbols_update_data *);
@@ -230,7 +230,7 @@ static void g_symbols_panel_process(const GSymbolsPanel *, unsigned int, GtkStat
static void g_symbols_panel_conclude(GSymbolsPanel *, unsigned int, symbols_update_data *);
/* Supprime les données dynamiques utilisées à la mise à jour. */
-static void g_symbols_panel_clean_data(GUpdatablePanel *, unsigned int, symbols_update_data *);
+static void g_symbols_panel_clean_data(const GUpdatablePanel *, unsigned int, symbols_update_data *);
@@ -1614,6 +1614,7 @@ static bool is_symbol_matching(const symbols_update_data *data, const GBinSymbol
* uid = identifiant de la phase de traitement. *
* count = nombre d'étapes à prévoir dans le traitement. [OUT] *
* data = données sur lesquelles s'appuyer ensuite. [OUT] *
+* msg = description du message d'information. [OUT] *
* *
* Description : Prépare une opération de mise à jour de panneau. *
* *
@@ -1623,9 +1624,9 @@ static bool is_symbol_matching(const symbols_update_data *data, const GBinSymbol
* *
******************************************************************************/
-static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned int uid, size_t *count, symbols_update_data **data)
+static bool g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned int uid, size_t *count, symbols_update_data **data, char **msg)
{
- const char *result; /* Message à retourner */
+ bool result; /* Bilan à retourner */
GBinFormat *format; /* Format du binaire */
#ifndef NDEBUG
int ret; /* Bilan de mise en place */
@@ -1633,6 +1634,8 @@ static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned in
GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeView *treeview; /* Arborescence graphique */
+ result = true;
+
*data = malloc(sizeof(symbols_update_data));
switch (uid)
@@ -1649,7 +1652,7 @@ static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned in
(*data)->count = 0;
- result = _("Loading symbols registered for the binary format...");
+ *msg = strdup(_("Loading symbols registered for the binary format..."));
break;
@@ -1658,13 +1661,13 @@ static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned in
*count = panel->count;
(*data)->count = panel->count;
- result = _("Filtering symbols registered for the binary format...");
+ *msg = strdup(_("Filtering symbols registered for the binary format..."));
break;
default: /* Pour GCC... */
assert(false);
- result = "";
+ result = false;
break;
}
@@ -1873,7 +1876,7 @@ static void g_symbols_panel_conclude(GSymbolsPanel *panel, unsigned int uid, sym
* *
******************************************************************************/
-static void g_symbols_panel_clean_data(GUpdatablePanel *panel, unsigned int uid, symbols_update_data *data)
+static void g_symbols_panel_clean_data(const GUpdatablePanel *panel, unsigned int uid, symbols_update_data *data)
{
size_t i; /* Boucle de parcours */
diff --git a/src/gui/panels/symbols.ui b/src/gui/panels/symbols.ui
index 3c34a29..8e54656 100644
--- a/src/gui/panels/symbols.ui
+++ b/src/gui/panels/symbols.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.21.0 -->
+<!-- Generated with glade 3.37.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkTreeStore" id="store">
@@ -28,51 +28,51 @@
<property name="model">store</property>
</object>
<object class="GtkTreeModelFilter" id="filter">
- <property name="child_model">sorter</property>
+ <property name="child-model">sorter</property>
</object>
<object class="GtkImage" id="symbol_class_classic.png">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="resource">/org/chrysalide/gui/panels/../../../pixmaps/symbol_class_classic.png</property>
</object>
<object class="GtkImage" id="tbutton_collapse.png">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="resource">/org/chrysalide/gui/panels/../../../pixmaps/tbutton_collapse.png</property>
</object>
<object class="GtkImage" id="tbutton_expand.png">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="resource">/org/chrysalide/gui/panels/../../../pixmaps/tbutton_expand.png</property>
</object>
<object class="GtkImage" id="tbutton_list_view.png">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="resource">/org/chrysalide/gui/panels/../../../pixmaps/tbutton_list_view.png</property>
</object>
<object class="GtkImage" id="tbutton_tree_view.png">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="resource">/org/chrysalide/gui/panels/../../../pixmaps/tbutton_tree_view.png</property>
</object>
<object class="GtkOffscreenWindow">
- <property name="can_focus">False</property>
+ <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="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<child>
<object class="GtkRadioToolButton" id="list_display">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Show symbols using a list view</property>
- <property name="use_underline">True</property>
- <property name="icon_widget">tbutton_list_view.png</property>
+ <property name="can-focus">False</property>
+ <property name="tooltip-text" translatable="yes">Show symbols using a list view</property>
+ <property name="use-underline">True</property>
+ <property name="icon-widget">tbutton_list_view.png</property>
<property name="active">True</property>
<property name="group">tree_display</property>
<signal name="toggled" handler="on_symbols_list_display_toggle" swapped="no"/>
@@ -85,10 +85,10 @@
<child>
<object class="GtkRadioToolButton" id="tree_display">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Show symbols using a tree view</property>
- <property name="use_underline">True</property>
- <property name="icon_widget">tbutton_tree_view.png</property>
+ <property name="can-focus">False</property>
+ <property name="tooltip-text" translatable="yes">Show symbols using a tree view</property>
+ <property name="use-underline">True</property>
+ <property name="icon-widget">tbutton_tree_view.png</property>
<signal name="toggled" handler="on_symbols_tree_display_toggle" swapped="no"/>
</object>
<packing>
@@ -99,7 +99,7 @@
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
@@ -109,10 +109,10 @@
<child>
<object class="GtkToolButton" id="collapse">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Collapse all symbol nodes in the tree view</property>
- <property name="use_underline">True</property>
- <property name="icon_widget">tbutton_collapse.png</property>
+ <property name="can-focus">False</property>
+ <property name="tooltip-text" translatable="yes">Collapse all symbol nodes in the tree view</property>
+ <property name="use-underline">True</property>
+ <property name="icon-widget">tbutton_collapse.png</property>
<signal name="clicked" handler="reorganize_symbols_tree_view" swapped="no"/>
</object>
<packing>
@@ -123,10 +123,10 @@
<child>
<object class="GtkToolButton" id="expand">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Expand all symbol nodes in the tree view</property>
- <property name="use_underline">True</property>
- <property name="icon_widget">tbutton_expand.png</property>
+ <property name="can-focus">False</property>
+ <property name="tooltip-text" translatable="yes">Expand all symbol nodes in the tree view</property>
+ <property name="use-underline">True</property>
+ <property name="icon-widget">tbutton_expand.png</property>
<signal name="clicked" handler="reorganize_symbols_tree_view" swapped="no"/>
</object>
<packing>
@@ -137,10 +137,10 @@
<child>
<object class="GtkToolButton" id="classes">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Show all classes in the tree view</property>
- <property name="use_underline">True</property>
- <property name="icon_widget">symbol_class_classic.png</property>
+ <property name="can-focus">False</property>
+ <property name="tooltip-text" translatable="yes">Show all classes in the tree view</property>
+ <property name="use-underline">True</property>
+ <property name="icon-widget">symbol_class_classic.png</property>
<signal name="clicked" handler="reorganize_symbols_tree_view" swapped="no"/>
</object>
<packing>
@@ -151,7 +151,7 @@
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
@@ -161,15 +161,15 @@
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<child>
<object class="GtkSearchEntry">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Filter symbols using POSIX extended regular expressions</property>
- <property name="primary_icon_name">edit-find-symbolic</property>
- <property name="primary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">False</property>
+ <property name="can-focus">True</property>
+ <property name="tooltip-text" translatable="yes">Filter symbols using POSIX extended regular expressions</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_symbols_filter_changed" swapped="no"/>
@@ -191,20 +191,20 @@
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<child>
<object class="GtkScrolledWindow" id="content">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
+ <property name="can-focus">True</property>
+ <property name="shadow-type">in</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="name">treeview</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="can-focus">True</property>
<property name="model">filter</property>
- <property name="headers_visible">False</property>
- <property name="search_column">2</property>
+ <property name="headers-visible">False</property>
+ <property name="search-column">2</property>
<child internal-child="selection">
<object class="GtkTreeSelection">
<signal name="changed" handler="on_symbols_selection_change" swapped="no"/>
@@ -221,7 +221,7 @@
<child>
<object class="GtkSpinner" id="mask">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="active">True</property>
</object>
<packing>
@@ -239,8 +239,5 @@
</child>
</object>
</child>
- <child type="titlebar">
- <placeholder/>
- </child>
</object>
</interface>
diff --git a/src/gui/panels/updating-int.h b/src/gui/panels/updating-int.h
index f8d0760..1b742e8 100644
--- a/src/gui/panels/updating-int.h
+++ b/src/gui/panels/updating-int.h
@@ -30,7 +30,7 @@
/* Prépare une opération de mise à jour de panneau. */
-typedef const char * (* setup_updatable_cb) (const GUpdatablePanel *, unsigned int, size_t *, void **);
+typedef bool (* setup_updatable_cb) (const GUpdatablePanel *, unsigned int, size_t *, void **, char **);
/* Obtient le groupe de travail dédié à une mise à jour. */
typedef wgroup_id_t (* get_updatable_group_cb) (const GUpdatablePanel *);
@@ -45,7 +45,7 @@ typedef void (* process_updatable_cb) (const GUpdatablePanel *, unsigned int, Gt
typedef void (* conclude_updatable_cb) (GUpdatablePanel *, unsigned int, void *);
/* Supprime les données dynamiques utilisées à la mise à jour. */
-typedef void (* clean_updatable_data_cb) (GUpdatablePanel *, unsigned int, void *);
+typedef void (* clean_updatable_data_cb) (const GUpdatablePanel *, unsigned int, void *);
/* Mécanisme de mise à jour d'un panneau (interface) */
diff --git a/src/gui/panels/updating.c b/src/gui/panels/updating.c
index 31f42c3..c5d59e7 100644
--- a/src/gui/panels/updating.c
+++ b/src/gui/panels/updating.c
@@ -55,7 +55,7 @@ struct _GPanelUpdate
size_t max; /* Marge de progression finale */
void *data; /* Données utiles au traitement*/
- const char *msg; /* Description d'activité */
+ char *msg; /* Description d'activité */
};
@@ -120,24 +120,30 @@ static void g_updatable_panel_default_init(GUpdatablePanelInterface *iface)
* uid = identifiant de la phase de traitement. *
* count = nombre d'étapes à prévoir dans le traitement. [OUT] *
* data = données sur lesquelles s'appuyer ensuite. [OUT] *
+* msg = description du message d'information. [OUT] *
* *
* Description : Prépare une opération de mise à jour de panneau. *
* *
-* Retour : Description du message d'information. *
+* Retour : Bilan de la préparation. *
* *
* Remarques : - *
* *
******************************************************************************/
-const char *g_updatable_panel_setup(const GUpdatablePanel *panel, unsigned int uid, size_t *count, void **data)
+bool g_updatable_panel_setup(const GUpdatablePanel *panel, unsigned int uid, size_t *count, void **data, char **msg)
{
+ bool result; /* Bilan à retourner */
GUpdatablePanelIface *iface; /* Interface utilisée */
iface = G_UPDATABLE_PANEL_GET_IFACE(panel);
+ *count = 0;
*data = NULL;
+ *msg = NULL;
- return iface->setup(panel, uid, count, data);
+ result = iface->setup(panel, uid, count, data, msg);
+
+ return result;
}
@@ -148,7 +154,7 @@ const char *g_updatable_panel_setup(const GUpdatablePanel *panel, unsigned int u
* *
* Description : Obtient le groupe de travail dédié à une mise à jour. *
* *
-* Retour : - *
+* Retour : Identifiant de groupe de travail. *
* *
* Remarques : - *
* *
@@ -259,7 +265,7 @@ void g_updatable_panel_conclude(GUpdatablePanel *panel, unsigned int uid, void *
* *
******************************************************************************/
-void g_updatable_panel_clean_data(GUpdatablePanel *panel, unsigned int uid, void *data)
+void g_updatable_panel_clean_data(const GUpdatablePanel *panel, unsigned int uid, void *data)
{
GUpdatablePanelIface *iface; /* Interface utilisée */
@@ -324,6 +330,12 @@ static void g_panel_update_class_init(GPanelUpdateClass *klass)
static void g_panel_update_init(GPanelUpdate *update)
{
+ update->panel = NULL;
+ update->uid = -1;
+
+ update->max = 0;
+ update->data = NULL;
+ update->msg = NULL;
}
@@ -342,7 +354,10 @@ static void g_panel_update_init(GPanelUpdate *update)
static void g_panel_update_dispose(GPanelUpdate *update)
{
- g_object_unref(G_OBJECT(update->panel));
+ if (update->panel != NULL)
+ g_updatable_panel_clean_data(update->panel, update->uid, update->data);
+
+ g_clear_object(&update->panel);
G_OBJECT_CLASS(g_panel_update_parent_class)->dispose(G_OBJECT(update));
@@ -363,11 +378,12 @@ static void g_panel_update_dispose(GPanelUpdate *update)
static void g_panel_update_finalize(GPanelUpdate *update)
{
- g_updatable_panel_clean_data(update->panel, update->uid, update->data);
-
if (update->data != NULL)
free(update->data);
+ if (update->msg != NULL)
+ free(update->msg);
+
G_OBJECT_CLASS(g_panel_update_parent_class)->finalize(G_OBJECT(update));
}
@@ -389,6 +405,7 @@ static void g_panel_update_finalize(GPanelUpdate *update)
GPanelUpdate *g_panel_update_new(GUpdatablePanel *panel, unsigned int uid)
{
GPanelUpdate *result; /* Tâche à retourner */
+ bool status; /* Bilan de la préparation */
result = g_object_new(G_TYPE_PANEL_UPDATE, NULL);
@@ -397,7 +414,10 @@ GPanelUpdate *g_panel_update_new(GUpdatablePanel *panel, unsigned int uid)
result->uid = uid;
- result->msg = g_updatable_panel_setup(panel, uid, &result->max, &result->data);
+ status = g_updatable_panel_setup(panel, uid, &result->max, &result->data, &result->msg);
+
+ if (!status)
+ g_clear_object(&result);
return result;
@@ -477,15 +497,19 @@ void run_panel_update(GUpdatablePanel *panel, unsigned int uid)
update = g_panel_update_new(panel, uid);
- g_signal_connect_to_main(update, "work-completed", G_CALLBACK(conclude_panel_update), panel,
- g_cclosure_marshal_VOID__VOID);
+ if (update != NULL)
+ {
+ g_signal_connect_to_main(update, "work-completed", G_CALLBACK(conclude_panel_update), panel,
+ g_cclosure_marshal_VOID__VOID);
+
+ g_updatable_panel_introduce(panel, uid, update->data);
- g_updatable_panel_introduce(panel, uid, update->data);
+ queue = get_work_queue();
- queue = get_work_queue();
+ gid = g_updatable_panel_get_group(panel);
- gid = g_updatable_panel_get_group(panel);
+ g_work_queue_schedule_work(queue, G_DELAYED_WORK(update), gid);
- g_work_queue_schedule_work(queue, G_DELAYED_WORK(update), gid);
+ }
}
diff --git a/src/gui/panels/updating.h b/src/gui/panels/updating.h
index 8c44795..2293a02 100644
--- a/src/gui/panels/updating.h
+++ b/src/gui/panels/updating.h
@@ -56,7 +56,7 @@ typedef struct _GUpdatablePanelIface GUpdatablePanelIface;
GType g_updatable_panel_get_type(void) G_GNUC_CONST;
/* Prépare une opération de mise à jour de panneau. */
-const char *g_updatable_panel_setup(const GUpdatablePanel *, unsigned int, size_t *, void **);
+bool g_updatable_panel_setup(const GUpdatablePanel *, unsigned int, size_t *, void **, char **);
/* Obtient le groupe de travail dédié à une mise à jour. */
wgroup_id_t g_updatable_panel_get_group(const GUpdatablePanel *);
@@ -71,7 +71,7 @@ void g_updatable_panel_process(const GUpdatablePanel *, unsigned int, GtkStatusS
void g_updatable_panel_conclude(GUpdatablePanel *, unsigned int, void *);
/* Supprime les données dynamiques utilisées à la mise à jour. */
-void g_updatable_panel_clean_data(GUpdatablePanel *, unsigned int, void *);
+void g_updatable_panel_clean_data(const GUpdatablePanel *, unsigned int, void *);