diff options
Diffstat (limited to 'src/gui/panels/errors.c')
-rw-r--r-- | src/gui/panels/errors.c | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/src/gui/panels/errors.c b/src/gui/panels/errors.c index f27d0fc..5b996e5 100644 --- a/src/gui/panels/errors.c +++ b/src/gui/panels/errors.c @@ -61,8 +61,6 @@ struct _GErrorPanel { GPanelItem parent; /* A laisser en premier */ - GtkBuilder *builder; /* Constructeur utilisé */ - GLoadedBinary *binary; /* Binaire représenté */ size_t count; /* Nombre de soucis présents */ @@ -263,6 +261,7 @@ static void g_error_panel_init(GErrorPanel *panel) { GEditorItem *base; /* Version basique d'instance */ GPanelItem *pitem; /* Version parente du panneau */ + GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeSortable *store; /* Gestionnaire des données */ GtkTreeModelFilter *filter; /* Filtre pour l'arborescence */ GtkTreeView *treeview; /* Affichage de la liste */ @@ -288,22 +287,18 @@ static void g_error_panel_init(GErrorPanel *panel) /* Représentation graphique */ - panel->builder = gtk_builder_new_from_resource("/org/chrysalide/gui/panels/errors.ui"); + builder = g_panel_item_build(pitem, "errors"); - base->widget = GTK_WIDGET(gtk_builder_get_object(panel->builder, "box")); - g_object_ref(G_OBJECT(base->widget)); - gtk_widget_unparent(base->widget); - - store = GTK_TREE_SORTABLE(gtk_builder_get_object(panel->builder, "store")); + store = GTK_TREE_SORTABLE(gtk_builder_get_object(builder, "store")); gtk_tree_sortable_set_sort_func(store, ETC_ADDR, sort_errors_in_panel, NULL, NULL); gtk_tree_sortable_set_sort_column_id(store, ETC_ADDR, GTK_SORT_ASCENDING); - filter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(panel->builder, "filter")); + filter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(builder, "filter")); gtk_tree_model_filter_set_visible_column(filter, ETC_VISIBLE); /* Liste des erreurs relevées */ - treeview = GTK_TREE_VIEW(gtk_builder_get_object(panel->builder, "treeview")); + treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); column = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, column); @@ -334,14 +329,14 @@ static void g_error_panel_init(GErrorPanel *panel) /* Connexion des signaux */ - gtk_builder_add_callback_symbols(panel->builder, + gtk_builder_add_callback_symbols(builder, "gtk_tree_view_collapse_all", G_CALLBACK(gtk_tree_view_collapse_all), "gtk_tree_view_expand_all", G_CALLBACK(gtk_tree_view_expand_all), "on_error_filter_toggled", G_CALLBACK(on_error_filter_toggled), "on_error_selection_changed", G_CALLBACK(on_error_selection_changed), NULL); - gtk_builder_connect_signals(panel->builder, panel); + gtk_builder_connect_signals(builder, panel); } @@ -382,8 +377,6 @@ static void g_error_panel_interface_init(GUpdatablePanelInterface *iface) static void g_error_panel_dispose(GErrorPanel *panel) { - g_object_unref(G_OBJECT(panel->builder)); - if (panel->binary != NULL) g_object_unref(G_OBJECT(panel->binary)); @@ -483,6 +476,7 @@ static gint sort_errors_in_panel(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIte static void update_panel_with_binary_errors(GErrorPanel *panel, GLoadedBinary *binary) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ /* Réinitialisation */ @@ -495,7 +489,9 @@ static void update_panel_with_binary_errors(GErrorPanel *panel, GLoadedBinary *b if (panel->binary != NULL) g_object_ref(G_OBJECT(panel->binary)); - store = GTK_LIST_STORE(gtk_builder_get_object(panel->builder, "store")); + builder = G_PANEL_ITEM(panel)->builder; + + store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); gtk_list_store_clear(store); @@ -527,6 +523,7 @@ static void update_panel_with_binary_errors(GErrorPanel *panel, GLoadedBinary *b static void update_error_panel(const GErrorPanel *panel, GtkStatusStack *status, activity_id_t id, error_update_data *data) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ GBinFormat *format; /* Format du binaire */ size_t fcount; /* Quantité d'erreurs #1 */ @@ -543,7 +540,9 @@ static void update_error_panel(const GErrorPanel *panel, GtkStatusStack *status, bool ret; /* Bilan d'une récupération */ #endif - store = GTK_LIST_STORE(gtk_builder_get_object(panel->builder, "store")); + builder = G_PANEL_ITEM(panel)->builder; + + store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); /* Recensement initial */ @@ -567,13 +566,13 @@ static void update_error_panel(const GErrorPanel *panel, GtkStatusStack *status, if (panel->binary == NULL || (fcount + pcount) == 0) { - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "format")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "format")); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "disass")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "disass")); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "output")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "output")); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); gtk_list_store_append(store, &iter); @@ -595,15 +594,15 @@ static void update_error_panel(const GErrorPanel *panel, GtkStatusStack *status, else { - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "format")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "format")); gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE); show_format = gtk_toggle_button_get_active(button); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "disass")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "disass")); gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE); show_disass = gtk_toggle_button_get_active(button); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "output")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "output")); gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE); show_output = gtk_toggle_button_get_active(button); @@ -794,6 +793,7 @@ static void on_error_filter_toggled(GtkToggleButton *button, GErrorPanel *panel) static void filter_error_panel(const GErrorPanel *panel, GtkStatusStack *status, activity_id_t id, error_update_data *data) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeModel *store; /* Modèle de gestion */ GtkToggleButton *button; /* Bouton à manipuler */ gboolean show_format; /* Affichages liés au format */ @@ -805,17 +805,19 @@ static void filter_error_panel(const GErrorPanel *panel, GtkStatusStack *status, guint errno; /* Code d'erreur associé */ gboolean state; /* Bilan d'un filtrage */ - store = GTK_TREE_MODEL(gtk_builder_get_object(panel->builder, "store")); + builder = G_PANEL_ITEM(panel)->builder; + + store = GTK_TREE_MODEL(gtk_builder_get_object(builder, "store")); /* Actualisation des données */ - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "format")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "format")); show_format = gtk_toggle_button_get_active(button); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "disass")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "disass")); show_disass = gtk_toggle_button_get_active(button); - button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(panel->builder, "output")); + button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "output")); show_output = gtk_toggle_button_get_active(button); @@ -886,10 +888,13 @@ static void filter_error_panel(const GErrorPanel *panel, GtkStatusStack *status, static void update_error_panel_summary(const GErrorPanel *panel) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkLabel *summary; /* Etiquette à mettre à jour */ char *msg; /* Bilan à faire afficher */ - summary = GTK_LABEL(gtk_builder_get_object(panel->builder, "summary")); + builder = G_PANEL_ITEM(panel)->builder; + + summary = GTK_LABEL(gtk_builder_get_object(builder, "summary")); if (panel->count == 0) gtk_label_set_markup(summary, NULL); @@ -1044,11 +1049,14 @@ static const char *g_error_panel_setup(const GErrorPanel *panel, unsigned int ui static void g_error_panel_introduce(const GErrorPanel *panel, unsigned int uid, error_update_data *data) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeView *treeview; /* Arborescence graphique */ /* Basculement de l'affichage hors ligne */ - treeview = GTK_TREE_VIEW(gtk_builder_get_object(panel->builder, "treeview")); + builder = G_PANEL_ITEM(panel)->builder; + + treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); data->model = gtk_tree_view_get_model(treeview); g_object_ref(G_OBJECT(data->model)); @@ -1107,6 +1115,7 @@ static void g_error_panel_process(const GErrorPanel *panel, unsigned int uid, Gt static void g_error_panel_conclude(GErrorPanel *panel, unsigned int uid, error_update_data *data) { + GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeView *treeview; /* Arborescence graphique */ /* Mise à jour des statistiques */ @@ -1118,7 +1127,9 @@ static void g_error_panel_conclude(GErrorPanel *panel, unsigned int uid, error_u /* Basculement de l'affichage en ligne */ - treeview = GTK_TREE_VIEW(gtk_builder_get_object(panel->builder, "treeview")); + builder = G_PANEL_ITEM(panel)->builder; + + treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); gtk_tree_view_set_model(treeview, data->model); |