[GTK3] Rename "gtkget" macro "builder_get"

This commit is contained in:
Maximilian Mader 2019-10-03 03:13:53 +02:00
parent 9e7de34e24
commit 286dd4d793
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
3 changed files with 21 additions and 21 deletions

View File

@ -4,7 +4,7 @@
#define str(x) #x
#define xstr(x) str(x)
#define get_object(id) gtk_builder_get_object(builder, id)
#define gtkget(type, id) type(gtk_builder_get_object(builder, id))
#define builder_get(type, id) type(gtk_builder_get_object(builder, id))
#define itoa(val) g_strdup_printf("%i", val)
#endif /* macros_h */

View File

@ -278,7 +278,7 @@ static void setup_menu(GApplication *app) {
case MENUBAR_SHOW_HAMBURGER: {
g_print("Showing hamburger\n");
// Attach a custom title bar
GtkWidget *titlebar = gtkget(GTK_WIDGET, "main_header_bar");
GtkWidget *titlebar = builder_get(GTK_WIDGET, "main_header_bar");
gtk_header_bar_set_title(GTK_HEADER_BAR(titlebar), gtk_window_get_title(GTK_WINDOW(main_window)));
gtk_window_set_titlebar(GTK_WINDOW(main_window), titlebar);
@ -376,8 +376,8 @@ static void startup(GApplication *app, gpointer user_data_gptr) {
g_simple_action_set_enabled(G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(app), "open_gtk_debugger")), false);
// Remove the menubar override
gtk_widget_destroy(gtkget(GTK_WIDGET, "menubar_override_selector_label"));
gtk_widget_destroy(gtkget(GTK_WIDGET, "menubar_override_selector"));
gtk_widget_destroy(builder_get(GTK_WIDGET, "menubar_override_selector_label"));
gtk_widget_destroy(builder_get(GTK_WIDGET, "menubar_override_selector"));
#endif
preferences = GTK_WINDOW(get_object("preferences"));
@ -722,7 +722,7 @@ static gboolean on_draw_vram_viewer_tileset(GtkWidget *widget, cairo_t *cr, gpoi
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_paint(cr);
if (gtk_toggle_button_get_active(gtkget(GTK_TOGGLE_BUTTON, "vram_viewer_tileset_toggle_grid_button"))) {
if (gtk_toggle_button_get_active(builder_get(GTK_TOGGLE_BUTTON, "vram_viewer_tileset_toggle_grid_button"))) {
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.25);
cairo_set_line_width(cr, 1);
@ -773,7 +773,7 @@ static gboolean on_draw_vram_viewer_tilemap(GtkWidget *widget, cairo_t *cr, gpoi
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_paint(cr);
if (gtk_toggle_button_get_active(gtkget(GTK_TOGGLE_BUTTON, "vram_viewer_tilemap_toggle_grid_button"))) {
if (gtk_toggle_button_get_active(builder_get(GTK_TOGGLE_BUTTON, "vram_viewer_tilemap_toggle_grid_button"))) {
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.25);
cairo_set_line_width(cr, 1);
@ -791,7 +791,7 @@ static gboolean on_draw_vram_viewer_tilemap(GtkWidget *widget, cairo_t *cr, gpoi
cairo_stroke(cr);
}
if (gtk_toggle_button_get_active(gtkget(GTK_TOGGLE_BUTTON, "vram_viewer_tilemap_toggle_scrolling_button"))) {
if (gtk_toggle_button_get_active(builder_get(GTK_TOGGLE_BUTTON, "vram_viewer_tilemap_toggle_scrolling_button"))) {
cairo_rectangle(cr, 0, 0, width, height);
for (unsigned x = 0; x < 2; x++) {

View File

@ -98,22 +98,22 @@ void on_preferences_realize(GtkWidget *w, gpointer builder_ptr) {
update_boot_rom_selector(builder);
// Hook up the static preferences
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "rewind_duration_selector"), itoa(config.rewind_duration));
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "dmg_revision_selector"), config.dmg_revision_name);
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "sgb_revision_selector"), config.sgb_revision_name);
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "cgb_revision_selector"), config.cgb_revision_name);
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "shader_selector"), config.shader);
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "color_correction_selector"), config.color_correction_id);
gtk_toggle_button_set_active(gtkget(GTK_TOGGLE_BUTTON, "integer_scaling_toggle"), config.use_integer_scaling);
gtk_toggle_button_set_active(gtkget(GTK_TOGGLE_BUTTON, "aspect_ratio_toggle"), config.keep_aspect_ratio);
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "highpass_filter_selector"), config.high_pass_filter_id);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "rewind_duration_selector"), itoa(config.rewind_duration));
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "dmg_revision_selector"), config.dmg_revision_name);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "sgb_revision_selector"), config.sgb_revision_name);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "cgb_revision_selector"), config.cgb_revision_name);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "shader_selector"), config.shader);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "color_correction_selector"), config.color_correction_id);
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "integer_scaling_toggle"), config.use_integer_scaling);
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "aspect_ratio_toggle"), config.keep_aspect_ratio);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "highpass_filter_selector"), config.high_pass_filter_id);
#if ! NDEBUG
gtk_combo_box_set_active_id(gtkget(GTK_COMBO_BOX, "menubar_override_selector"), config.menubar_override);
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "menubar_override_selector"), config.menubar_override);
#else
if (gtkget(GTK_COMBO_BOX, "menubar_override_selector") != NULL) {
gtk_widget_destroy(GTK_WIDGET(gtkget(GTK_COMBO_BOX, "menubar_override_selector")));
gtk_widget_destroy(GTK_WIDGET(gtkget(GTK_COMBO_BOX, "menubar_override_selector_label")));
if (builder_get(GTK_COMBO_BOX, "menubar_override_selector") != NULL) {
gtk_widget_destroy(GTK_WIDGET(builder_get(GTK_COMBO_BOX, "menubar_override_selector")));
gtk_widget_destroy(GTK_WIDGET(builder_get(GTK_COMBO_BOX, "menubar_override_selector_label")));
}
#endif
}
@ -176,7 +176,7 @@ void free_settings(void) {
}
void update_boot_rom_selector(GtkBuilder *builder) {
GtkComboBoxText *combo_box = gtkget(GTK_COMBO_BOX_TEXT, "boot_rom_selector");
GtkComboBoxText *combo_box = builder_get(GTK_COMBO_BOX_TEXT, "boot_rom_selector");
gtk_combo_box_text_remove_all(combo_box);
gtk_combo_box_text_append(combo_box, "auto", "Use Built-in Boot ROMs");
if (config.boot_rom_path != NULL && !g_str_equal(config.boot_rom_path, "auto") && !g_str_equal(config.boot_rom_path, "other")) {