diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-08-06 15:43:20 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-08-06 15:43:20 (GMT) |
commit | 5f55377ff6c014d513f13b76ec5faf56c31da478 (patch) | |
tree | fb063c28541635b0cd6039084b74f24083f1b82f /src/gui/panels/panel.c | |
parent | 121d24042c60fe9f3587c626f0b092c399cdc2a9 (diff) |
Created a new task to update panel contents.
Diffstat (limited to 'src/gui/panels/panel.c')
-rw-r--r-- | src/gui/panels/panel.c | 182 |
1 files changed, 182 insertions, 0 deletions
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); + +} |