diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-08-18 22:39:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-08-18 22:39:43 (GMT) |
commit | 81c1646a1eb96a6291b18a5a37f87bf6805b6794 (patch) | |
tree | c5093a7f5d535b3169bcce8d3f07c071541366cc /src | |
parent | 3e9d5cedf701fd8957024f7ddf65238aea9a1eba (diff) |
Centralized the macro used to provide callbacks to GtkBuilder easily.
Diffstat (limited to 'src')
-rw-r--r-- | src/gtkext/easygtk.h | 9 | ||||
-rw-r--r-- | src/gui/agroup.c | 10 | ||||
-rw-r--r-- | src/gui/dialogs/about.c | 6 | ||||
-rw-r--r-- | src/gui/editor.c | 10 | ||||
-rw-r--r-- | src/gui/menus/binary.c | 16 | ||||
-rw-r--r-- | src/gui/menus/debug.c | 28 | ||||
-rw-r--r-- | src/gui/menus/edition.c | 25 | ||||
-rw-r--r-- | src/gui/menus/file.c | 14 | ||||
-rw-r--r-- | src/gui/menus/help.c | 12 | ||||
-rw-r--r-- | src/gui/menus/options.c | 8 | ||||
-rw-r--r-- | src/gui/menus/project.c | 4 | ||||
-rw-r--r-- | src/gui/menus/view.c | 12 |
12 files changed, 70 insertions, 84 deletions
diff --git a/src/gtkext/easygtk.h b/src/gtkext/easygtk.h index f8335ac..f8c2212 100644 --- a/src/gtkext/easygtk.h +++ b/src/gtkext/easygtk.h @@ -21,8 +21,8 @@ */ -#ifndef _EASYGTK_H -#define _EASYGTK_H +#ifndef _GTKEXT_EASYGTK_H +#define _GTKEXT_EASYGTK_H #include <gtk/gtk.h> @@ -34,6 +34,9 @@ /* Transition vers GTK-3.x claire */ #define HAS_H_ORIENTATION(wid) gtk_orientable_get_orientation(GTK_ORIENTABLE(wid)) == GTK_ORIENTATION_HORIZONTAL +/* Enregistrement des fonctions pour GtkBuilder */ +#define BUILDER_CALLBACK(cb) #cb, G_CALLBACK(cb) + /* Définit des bordures extérieures à appliquer à un composant. */ void qck_set_margins(GtkWidget *, guint, guint, guint, guint); @@ -103,4 +106,4 @@ void scroll_to_treeview_iter(GtkTreeView *, GtkTreeModel *, GtkTreeIter *); -#endif /* _EASYGTK_H */ +#endif /* _GTKEXT_EASYGTK_H */ diff --git a/src/gui/agroup.c b/src/gui/agroup.c index 435f005..98952f0 100644 --- a/src/gui/agroup.c +++ b/src/gui/agroup.c @@ -28,6 +28,9 @@ #include <stdbool.h> +#include "../gtkext/easygtk.h" + + /* Détermine si un élément graphique peut être actionné. */ static gboolean enable_accel_all_the_time(GtkWidget *, guint, gpointer); @@ -55,12 +58,9 @@ static bool _entry_focused = false; void setup_accel_group_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(enable_accel_all_the_time), - DEFINE_CALLBACK(enable_accel_with_care), + BUILDER_CALLBACK(enable_accel_all_the_time), + BUILDER_CALLBACK(enable_accel_with_care), NULL); } diff --git a/src/gui/dialogs/about.c b/src/gui/dialogs/about.c index e2836e5..574c7f2 100644 --- a/src/gui/dialogs/about.c +++ b/src/gui/dialogs/about.c @@ -101,11 +101,9 @@ GtkWidget *create_about_dialog(GtkWindow *parent, GtkBuilder **outb) /* Connexion des signaux */ -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(close_about_window_on_escape), - DEFINE_CALLBACK(draw_black_background), + BUILDER_CALLBACK(close_about_window_on_escape), + BUILDER_CALLBACK(draw_black_background), NULL); gtk_builder_connect_signals(builder, builder); diff --git a/src/gui/editor.c b/src/gui/editor.c index be8dfa5..1d4190f 100644 --- a/src/gui/editor.c +++ b/src/gui/editor.c @@ -231,13 +231,11 @@ GtkWidget *create_editor(void) gtk_window_set_icon_list(GTK_WINDOW(result), icons); g_list_free_full(icons, (GDestroyNotify)g_object_unref); -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(on_delete_editor), - DEFINE_CALLBACK(on_destroy_editor), - DEFINE_CALLBACK(on_window_state_changed), - DEFINE_CALLBACK(on_key_event), + BUILDER_CALLBACK(on_delete_editor), + BUILDER_CALLBACK(on_destroy_editor), + BUILDER_CALLBACK(on_window_state_changed), + BUILDER_CALLBACK(on_key_event), NULL); setup_accel_group_callbacks(builder); diff --git a/src/gui/menus/binary.c b/src/gui/menus/binary.c index 4ec866b..87558a0 100644 --- a/src/gui/menus/binary.c +++ b/src/gui/menus/binary.c @@ -36,6 +36,7 @@ #include "../dialogs/gotox.h" #include "../dialogs/snapshots.h" #include "../dialogs/storage.h" +#include "../../gtkext/easygtk.h" #include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/gtkgraphdisplay.h" @@ -75,16 +76,13 @@ static void mcb_binary_export_graph(GtkMenuItem *, gpointer); void setup_menu_binary_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_binary_entry_points), - DEFINE_CALLBACK(mcb_binary_attach_debugger), - DEFINE_CALLBACK(mcb_binary_storage), - DEFINE_CALLBACK(mcb_binary_snapshots), - DEFINE_CALLBACK(mcb_binary_export_disass), - DEFINE_CALLBACK(mcb_binary_export_graph), + BUILDER_CALLBACK(mcb_binary_entry_points), + BUILDER_CALLBACK(mcb_binary_attach_debugger), + BUILDER_CALLBACK(mcb_binary_storage), + BUILDER_CALLBACK(mcb_binary_snapshots), + BUILDER_CALLBACK(mcb_binary_export_disass), + BUILDER_CALLBACK(mcb_binary_export_graph), NULL); } diff --git a/src/gui/menus/debug.c b/src/gui/menus/debug.c index c1a3d2d..925198c 100644 --- a/src/gui/menus/debug.c +++ b/src/gui/menus/debug.c @@ -31,6 +31,9 @@ #include <i18n.h> +#include "../../gtkext/easygtk.h" + + /* Réagit avec le menu "Débogage -> Continuer". */ static void mcb_debug_continue(GtkMenuItem *, GObject *); @@ -81,21 +84,18 @@ static void mcb_debug_options(GtkMenuItem *, GObject *); void setup_menu_debug_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_debug_continue), - DEFINE_CALLBACK(mcb_debug_continue_to), - DEFINE_CALLBACK(mcb_debug_pause), - DEFINE_CALLBACK(mcb_debug_restart), - DEFINE_CALLBACK(mcb_debug_close), - DEFINE_CALLBACK(mcb_debug_step_into), - DEFINE_CALLBACK(mcb_debug_step_over), - DEFINE_CALLBACK(mcb_debug_visit_blocks_into), - DEFINE_CALLBACK(mcb_debug_visit_blocks_over), - DEFINE_CALLBACK(mcb_debug_return), - DEFINE_CALLBACK(mcb_debug_options), + BUILDER_CALLBACK(mcb_debug_continue), + BUILDER_CALLBACK(mcb_debug_continue_to), + BUILDER_CALLBACK(mcb_debug_pause), + BUILDER_CALLBACK(mcb_debug_restart), + BUILDER_CALLBACK(mcb_debug_close), + BUILDER_CALLBACK(mcb_debug_step_into), + BUILDER_CALLBACK(mcb_debug_step_over), + BUILDER_CALLBACK(mcb_debug_visit_blocks_into), + BUILDER_CALLBACK(mcb_debug_visit_blocks_over), + BUILDER_CALLBACK(mcb_debug_return), + BUILDER_CALLBACK(mcb_debug_options), NULL); } diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c index e11a3b9..b78c084 100644 --- a/src/gui/menus/edition.c +++ b/src/gui/menus/edition.c @@ -40,6 +40,7 @@ #include "../../analysis/db/items/switcher.h" #include "../../arch/operands/targetable.h" #include "../../glibext/gbinarycursor.h" +#include "../../gtkext/easygtk.h" #include "../../gtkext/gtkblockdisplay.h" #include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/gtkgraphdisplay.h" @@ -98,20 +99,18 @@ void setup_menu_edition_callbacks(GtkBuilder *builder) { GObject *item; /* Elément à compléter */ -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_edition_goto), - DEFINE_CALLBACK(mcb_edition_switch_numeric_operand), - DEFINE_CALLBACK(mcb_edition_go_back), - DEFINE_CALLBACK(mcb_edition_follow_ref), - DEFINE_CALLBACK(mcb_edition_list_xrefs), - DEFINE_CALLBACK(mcb_edition_bookmarks_toggle), - DEFINE_CALLBACK(mcb_edition_bookmarks_delete_all), - DEFINE_CALLBACK(mcb_edition_comment_enter), - DEFINE_CALLBACK(mcb_edition_comment_enter_repeatable), - DEFINE_CALLBACK(mcb_edition_comment_enter_previous), - DEFINE_CALLBACK(mcb_edition_comment_enter_next), + BUILDER_CALLBACK(mcb_edition_goto), + BUILDER_CALLBACK(mcb_edition_switch_numeric_operand), + BUILDER_CALLBACK(mcb_edition_go_back), + BUILDER_CALLBACK(mcb_edition_follow_ref), + BUILDER_CALLBACK(mcb_edition_list_xrefs), + BUILDER_CALLBACK(mcb_edition_bookmarks_toggle), + BUILDER_CALLBACK(mcb_edition_bookmarks_delete_all), + BUILDER_CALLBACK(mcb_edition_comment_enter), + BUILDER_CALLBACK(mcb_edition_comment_enter_repeatable), + BUILDER_CALLBACK(mcb_edition_comment_enter_previous), + BUILDER_CALLBACK(mcb_edition_comment_enter_next), NULL); /* Bascule des opérandes numériques */ diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c index 07acd16..b7edbd2 100644 --- a/src/gui/menus/file.c +++ b/src/gui/menus/file.c @@ -31,6 +31,7 @@ #include "../core/global.h" #include "../../analysis/project.h" #include "../../core/global.h" +#include "../../gtkext/easygtk.h" @@ -62,15 +63,12 @@ static void mcb_file_quit(GtkMenuItem *, gpointer); void setup_menu_file_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_file_new_project), - DEFINE_CALLBACK(mcb_file_open_project), - DEFINE_CALLBACK(mcb_file_save_project), - DEFINE_CALLBACK(mcb_file_save_project_as), - DEFINE_CALLBACK(mcb_file_quit), + BUILDER_CALLBACK(mcb_file_new_project), + BUILDER_CALLBACK(mcb_file_open_project), + BUILDER_CALLBACK(mcb_file_save_project), + BUILDER_CALLBACK(mcb_file_save_project_as), + BUILDER_CALLBACK(mcb_file_quit), NULL); diff --git a/src/gui/menus/help.c b/src/gui/menus/help.c index db19758..78c1072 100644 --- a/src/gui/menus/help.c +++ b/src/gui/menus/help.c @@ -30,6 +30,7 @@ #include "../core/global.h" #include "../dialogs/about.h" +#include "../../gtkext/easygtk.h" @@ -61,14 +62,11 @@ static void mcb_help_about(GtkMenuItem *, gpointer); void setup_menu_help_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_help_website), - DEFINE_CALLBACK(mcb_help_python_api_documentation), - DEFINE_CALLBACK(mcb_help_bug_report), - DEFINE_CALLBACK(mcb_help_about), + BUILDER_CALLBACK(mcb_help_website), + BUILDER_CALLBACK(mcb_help_python_api_documentation), + BUILDER_CALLBACK(mcb_help_bug_report), + BUILDER_CALLBACK(mcb_help_about), NULL); } diff --git a/src/gui/menus/options.c b/src/gui/menus/options.c index 0f5d1a2..acb275c 100644 --- a/src/gui/menus/options.c +++ b/src/gui/menus/options.c @@ -33,6 +33,7 @@ #include "../core/global.h" #include "../dialogs/identity.h" #include "../dialogs/preferences.h" +#include "../../gtkext/easygtk.h" @@ -58,12 +59,9 @@ static void mcb_options_identity(GtkMenuItem *, gpointer); void setup_menu_options_callbacks(GtkBuilder *builder) { - -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_options_preferences), - DEFINE_CALLBACK(mcb_options_identity), + BUILDER_CALLBACK(mcb_options_preferences), + BUILDER_CALLBACK(mcb_options_identity), NULL); } diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index e9e690c..293af3d 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -65,10 +65,8 @@ void setup_menu_project_callbacks(GtkBuilder *builder) { GObject *item; /* Elément à compléter */ -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_project_add_binary_file), + BUILDER_CALLBACK(mcb_project_add_binary_file), NULL); /* Projet -> Retirer un binaire */ diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index b778f8c..d41df92 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -93,14 +93,12 @@ void setup_menu_view_callbacks(GtkBuilder *builder) { GObject *item; /* Elément à compléter */ -#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) - gtk_builder_add_callback_symbols(builder, - DEFINE_CALLBACK(mcb_view_update_side_panels_list), - DEFINE_CALLBACK(mcb_view_switch_to_next_support), - DEFINE_CALLBACK(mcb_view_switch_to_prev_support), - DEFINE_CALLBACK(mcb_view_zoom), - DEFINE_CALLBACK(mcb_view_show_full_screen), + BUILDER_CALLBACK(mcb_view_update_side_panels_list), + BUILDER_CALLBACK(mcb_view_switch_to_next_support), + BUILDER_CALLBACK(mcb_view_switch_to_prev_support), + BUILDER_CALLBACK(mcb_view_zoom), + BUILDER_CALLBACK(mcb_view_show_full_screen), NULL); /* Affichage -> Panneaux latéraux */ |