From 279ed42e7b1b8d9d0ae95c67972c7009e504cc92 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 28 Aug 2017 23:42:49 +0200 Subject: Used a GtkStack widget to display the editor status information. --- ChangeLog | 5 +++ src/gtkext/gtkstatusstack.c | 79 +++++++++++++++++---------------------------- 2 files changed, 34 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index be7f7e7..ba76d00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +17-08-28 Cyrille Bagard + + * src/gtkext/gtkstatusstack.c: + Use a GtkStack widget to display the editor status information. + 17-08-27 Cyrille Bagard * src/format/dex/dex-int.c: diff --git a/src/gtkext/gtkstatusstack.c b/src/gtkext/gtkstatusstack.c index 789661e..cf9e525 100644 --- a/src/gtkext/gtkstatusstack.c +++ b/src/gtkext/gtkstatusstack.c @@ -52,20 +52,22 @@ typedef struct _progress_info progress_info; /* Abstration d'une gestion de barre de statut (instance) */ struct _GtkStatusStack { - GtkBin parent; /* A laisser en premier */ + GtkBox parent; /* A laisser en premier */ - GtkWidget *asm_status; /* Barre de status d'assemblage*/ - assembly_info *asm_info; /* Informations courantes */ + GtkStack *main; /* Pile d'informations associée*/ - GtkWidget *prog_status; /* Barre de status d'activité */ - progress_info *prog_info; /* Informations courantes */ + GObject *asm_ref; /* Espace de référencements #1 */ + assembly_info *asm_info; /* Informations courantes #1 */ + + GObject *prog_ref; /* Espace de référencements #2 */ + progress_info *prog_info; /* Informations courantes #2 */ }; /* Abstration d'une gestion de barre de statut (classe) */ struct _GtkStatusStackClass { - GtkBinClass parent; /* A laisser en premier */ + GtkBoxClass parent; /* A laisser en premier */ }; @@ -82,9 +84,6 @@ static void gtk_status_stack_dispose(GtkStatusStack *); /* Procède à la libération totale de la mémoire. */ static void gtk_status_stack_finalize(GtkStatusStack *); -/* S'assure de l'affichage du niveau de pile attendu. */ -static void gtk_status_stack_switch(GtkStatusStack *, GtkWidget *); - /* -------------------- STATUT DES INFORMATIONS DE DESASSEMBLAGE -------------------- */ @@ -178,7 +177,7 @@ static gboolean gtk_status_stack_show_current_activity(GtkStatusStack *); /* Détermine le type de la barre de statut améliorée. */ -G_DEFINE_TYPE(GtkStatusStack, gtk_status_stack, GTK_TYPE_BIN) +G_DEFINE_TYPE(GtkStatusStack, gtk_status_stack, GTK_TYPE_BOX) /****************************************************************************** @@ -219,12 +218,26 @@ static void gtk_status_stack_class_init(GtkStatusStackClass *klass) static void gtk_status_stack_init(GtkStatusStack *stack) { - stack->asm_status = build_assembly_status_stack(stack); + GtkWidget *layer; /* Couche à empiler */ + + gtk_orientable_set_orientation(GTK_ORIENTABLE(stack), GTK_ORIENTATION_HORIZONTAL); + + stack->main = GTK_STACK(gtk_stack_new()); + gtk_widget_show(GTK_WIDGET(stack->main)); + gtk_box_pack_start(GTK_BOX(stack), GTK_WIDGET(stack->main), TRUE, TRUE, 8); + + layer = build_assembly_status_stack(stack); + gtk_stack_add_named(stack->main, layer, "asm_info"); + + stack->asm_ref = G_OBJECT(layer); stack->asm_info = (assembly_info *)calloc(1, sizeof(assembly_info)); reset_assembly_info(stack->asm_info); - stack->prog_status = build_progress_status_stack(stack); + layer = build_progress_status_stack(stack); + gtk_stack_add_named(stack->main, layer, "prog_info"); + + stack->prog_ref = G_OBJECT(layer); stack->prog_info = (progress_info *)calloc(1, sizeof(progress_info)); reset_progress_info(stack->prog_info); @@ -248,8 +261,6 @@ static void gtk_status_stack_init(GtkStatusStack *stack) static void gtk_status_stack_dispose(GtkStatusStack *stack) { - g_object_unref(G_OBJECT(stack->asm_status)); - G_OBJECT_CLASS(gtk_status_stack_parent_class)->dispose(G_OBJECT(stack)); } @@ -299,38 +310,6 @@ GtkWidget *gtk_status_stack_new(void) } -/****************************************************************************** -* * -* Paramètres : stack = pile de statuts à considérer. * -* next = niveau de pile à afficher désormais. * -* * -* Description : S'assure de l'affichage du niveau de pile attendu. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void gtk_status_stack_switch(GtkStatusStack *stack, GtkWidget *next) -{ - GtkWidget *child; /* Support courant */ - - child = gtk_bin_get_child(GTK_BIN(stack)); - - if (child != next) - { - if (child != NULL) - gtk_container_remove(GTK_CONTAINER(stack), child); - - g_object_ref(G_OBJECT(next)); - gtk_container_add(GTK_CONTAINER(stack), next); - - } - -} - - /* ---------------------------------------------------------------------------------- */ /* STATUT DES INFORMATIONS DE DESASSEMBLAGE */ @@ -665,9 +644,9 @@ static gboolean gtk_status_stack_show_current_instruction(GtkStatusStack *stack) char raw_pos[6 + VMPA_MAX_LEN + 1]; /* Formatage final en direct */ char *content; /* Contenu dynamique */ - gtk_status_stack_switch(stack, stack->asm_status); + gtk_stack_set_visible_child_name(stack->main, "asm_info"); - ref = G_OBJECT(stack->asm_status); + ref = stack->asm_ref; info = stack->asm_info; /* Première partie : navigation */ @@ -1139,9 +1118,9 @@ static gboolean gtk_status_stack_show_current_activity(GtkStatusStack *stack) if (!g_source_is_destroyed(g_main_current_source())) { - gtk_status_stack_switch(stack, stack->prog_status); + gtk_stack_set_visible_child_name(stack->main, "prog_info"); - ref = G_OBJECT(stack->prog_status); + ref = stack->prog_ref; info = stack->prog_info; g_mutex_lock(&info->access); -- cgit v0.11.2-87-g4458