From 5f55377ff6c014d513f13b76ec5faf56c31da478 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 6 Aug 2017 17:43:20 +0200 Subject: Created a new task to update panel contents. --- ChangeLog | 7 ++ src/gui/panels/panel-int.h | 29 ++++++++ src/gui/panels/panel.c | 182 +++++++++++++++++++++++++++++++++++++++++++++ src/gui/panels/panel.h | 34 +++++++++ 4 files changed, 252 insertions(+) diff --git a/ChangeLog b/ChangeLog index b28ef4f..f33c247 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +17-08-06 Cyrille Bagard + + * src/gui/panels/panel-int.h: + * src/gui/panels/panel.c: + * src/gui/panels/panel.h: + Create a new task to update panel contents. + 17-08-05 Cyrille Bagard * src/analysis/disass/area.c: diff --git a/src/gui/panels/panel-int.h b/src/gui/panels/panel-int.h index 33b0746..d95485c 100644 --- a/src/gui/panels/panel-int.h +++ b/src/gui/panels/panel-int.h @@ -34,9 +34,13 @@ #include "../editem-int.h" #include "../../common/dllist.h" +#include "../../glibext/delayed-int.h" +/* ------------------------- BASE D'UN PANNEAU POUR EDITEUR ------------------------- */ + + /* Place un panneau dans l'ensemble affiché. */ typedef void (* ack_dock_process_fc) (GPanelItem *item); @@ -86,4 +90,29 @@ struct _GPanelItemClass +/* ---------------------------- AIDE POUR LA MISE A JOUR ---------------------------- */ + + +/* Procédure de mise à jour de panneau graphique (instance) */ +struct _GPanelUpdate +{ + GDelayedWork parent; /* A laisser en premier */ + + GPanelItem *panel; /* Panneau à manipuler */ + pu_fallback_cb internal; /* Traitement sous-traité */ + + const char *msg; /* Description de l'opération */ + size_t max; /* Nombre d'éléments à traiter */ + +}; + +/* Procédure de mise à jour de panneau graphique (classe) */ +struct _GPanelUpdateClass +{ + GDelayedWorkClass parent; /* A laisser en premier */ + +}; + + + #endif /* _GUI_PANELS_PANEL_INT_H */ diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c index e70d57b..c9d5ecf 100644 --- a/src/gui/panels/panel.c +++ b/src/gui/panels/panel.c @@ -59,6 +59,31 @@ static char *gtk_panel_item_build_configuration_key(const GPanelItem *, const ch +/* ---------------------------- AIDE POUR LA MISE A JOUR ---------------------------- */ + + +/* Initialise la classe des tâches des mises à jour de panneaux. */ +static void g_panel_update_class_init(GPanelUpdateClass *); + +/* Initialise une tâche d'étude de routines. */ +static void g_panel_update_init(GPanelUpdate *); + +/* Supprime toutes les références externes. */ +static void g_panel_update_dispose(GPanelUpdate *); + +/* Procède à la libération totale de la mémoire. */ +static void g_panel_update_finalize(GPanelUpdate *); + +/* Assure la mise à jour d'un panneau en différé. */ +static void g_panel_update_process(GPanelUpdate *, GtkStatusStack *); + + + +/* ---------------------------------------------------------------------------------- */ +/* BASE D'UN PANNEAU POUR EDITEUR */ +/* ---------------------------------------------------------------------------------- */ + + /* Indique le type défini pour un élément destiné à un panneau. */ G_DEFINE_TYPE_WITH_CODE(GPanelItem, g_panel_item, G_TYPE_EDITOR_ITEM, G_IMPLEMENT_INTERFACE(GTK_TYPE_DOCKABLE, g_panel_item_dockable_interface_init)) @@ -550,3 +575,160 @@ void g_panel_item_undock(GPanelItem *item) G_PANEL_ITEM_GET_CLASS(item)->ack_undock(item); } + + + +/* ---------------------------------------------------------------------------------- */ +/* AIDE POUR LA MISE A JOUR */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour les tâches d'étude de routines. */ +G_DEFINE_TYPE(GPanelUpdate, g_panel_update, G_TYPE_DELAYED_WORK); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des tâches des mises à jour de panneaux.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_update_class_init(GPanelUpdateClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GDelayedWorkClass *work; /* Version en classe parente */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_panel_update_dispose; + object->finalize = (GObjectFinalizeFunc)g_panel_update_finalize; + + work = G_DELAYED_WORK_CLASS(klass); + + work->run = (run_task_fc)g_panel_update_process; + +} + + +/****************************************************************************** +* * +* Paramètres : update = instance à initialiser. * +* * +* Description : Initialise une tâche d'étude de routines. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_update_init(GPanelUpdate *update) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : update = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_update_dispose(GPanelUpdate *update) +{ + g_object_unref(G_OBJECT(update->panel)); + + G_OBJECT_CLASS(g_panel_update_parent_class)->dispose(G_OBJECT(update)); + +} + + +/****************************************************************************** +* * +* Paramètres : update = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_update_finalize(GPanelUpdate *update) +{ + G_OBJECT_CLASS(g_panel_update_parent_class)->finalize(G_OBJECT(update)); + +} + + +/****************************************************************************** +* * +* Paramètres : panel = panneau graphique devant être actualisé. * +* msg = description de l'activité à présenter. * +* max = marge de progression à attendre. * +* internal = procédure de sous-traitance à appeler. * +* * +* Description : Crée une tâche de mise à jour non bloquante. * +* * +* Retour : Tâche créée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GPanelUpdate *g_panel_update_new(GPanelItem *panel, const char *msg, size_t max, pu_fallback_cb internal) +{ + GPanelUpdate *result; /* Tâche à retourner */ + + result = g_object_new(G_TYPE_PANEL_UPDATE, NULL); + + g_object_ref(G_OBJECT(panel)); + result->panel = panel; + + result->internal = internal; + + result->msg = msg; + result->max = max; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : update = étude de routines à mener. * +* status = barre de statut à tenir informée. * +* * +* Description : Assure la mise à jour d'un panneau en différé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_update_process(GPanelUpdate *update, GtkStatusStack *status) +{ + activity_id_t id; /* Identifiant de progression */ + + id = gtk_status_stack_add_activity(status, update->msg, update->max); + + update->internal(update->panel, status, id); + + gtk_status_stack_remove_activity(status, id); + +} diff --git a/src/gui/panels/panel.h b/src/gui/panels/panel.h index bdeffcc..b293fd3 100644 --- a/src/gui/panels/panel.h +++ b/src/gui/panels/panel.h @@ -31,9 +31,13 @@ #include "../editem.h" #include "../../glibext/configuration.h" +#include "../../gtkext/gtkstatusstack.h" +/* ------------------------- BASE D'UN PANNEAU POUR EDITEUR ------------------------- */ + + #define G_TYPE_PANEL_ITEM g_panel_item_get_type() #define G_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_panel_item_get_type(), GPanelItem)) #define G_IS_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_panel_item_get_type())) @@ -101,4 +105,34 @@ void g_panel_item_undock(GPanelItem *); +/* ---------------------------- AIDE POUR LA MISE A JOUR ---------------------------- */ + + +#define G_TYPE_PANEL_UPDATE g_panel_update_get_type() +#define G_PANEL_UPDATE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_PANEL_UPDATE, GRoutinesStudy)) +#define G_IS_PANEL_UPDATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_PANEL_UPDATE)) +#define G_PANEL_UPDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_PANEL_UPDATE, GRoutinesStudyClass)) +#define G_IS_PANEL_UPDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_PANEL_UPDATE)) +#define G_PANEL_UPDATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PANEL_UPDATE, GRoutinesStudyClass)) + + +/* Procédure de mise à jour de panneau graphique (instance) */ +typedef struct _GPanelUpdate GPanelUpdate; + +/* Procédure de mise à jour de panneau graphique (classe) */ +typedef struct _GPanelUpdateClass GPanelUpdateClass; + + +/* Assure l'étude des routines en différé. */ +typedef void (* pu_fallback_cb) (GPanelItem *, GtkStatusStack *, activity_id_t); + + +/* Indique le type défini pour les tâches d'étude de routines. */ +GType g_panel_update_get_type(void); + +/* Crée une tâche de mise à jour non bloquante. */ +GPanelUpdate *g_panel_update_new(GPanelItem *, const char *, size_t, pu_fallback_cb); + + + #endif /* _GUI_PANELS_PANEL_H */ -- cgit v0.11.2-87-g4458