From 28543f6771463a696d9350b5bab22d817178488d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 19 Nov 2017 17:35:50 -0500 Subject: MqMainMenu: Define and use BTN() macro for main button grid --- (limited to 'src') diff --git a/src/toolbars/navigation/main-menu.c b/src/toolbars/navigation/main-menu.c index bfbfa23..c75caf6 100644 --- a/src/toolbars/navigation/main-menu.c +++ b/src/toolbars/navigation/main-menu.c @@ -293,24 +293,20 @@ create_zoom_buttons(MqMainMenu *main_menu) #define BUTTON_ROWS 3 #define BUTTON_COLS 3 +#define BTN(Y, X) buttons[Y * BUTTON_COLS + X] #define NEW_BTN(Y, X, ID, ICON, TOOLTIP) \ G_STMT_START { \ - buttons[Y * BUTTON_COLS + X] = gtk_button_new_from_icon_name(\ - ICON, GTK_ICON_SIZE_BUTTON); \ - gtk_button_set_relief(GTK_BUTTON(buttons[Y * BUTTON_COLS + X]),\ - GTK_RELIEF_NONE); \ - gtk_button_set_label(GTK_BUTTON(buttons[Y * BUTTON_COLS + X]), \ - TOOLTIP); \ - gtk_button_set_image_position(\ - GTK_BUTTON(buttons[Y * BUTTON_COLS + X]), GTK_POS_TOP);\ - gtk_button_set_always_show_image(\ - GTK_BUTTON(buttons[Y * BUTTON_COLS + X]), TRUE); \ - gtk_widget_set_tooltip_text(buttons[Y * BUTTON_COLS + X], \ - TOOLTIP); \ - g_signal_connect(buttons[Y * BUTTON_COLS + X], "clicked", \ + BTN(Y, X) = gtk_button_new_from_icon_name(ICON, \ + GTK_ICON_SIZE_BUTTON); \ + gtk_button_set_relief(GTK_BUTTON(BTN(Y, X)), GTK_RELIEF_NONE); \ + gtk_button_set_label(GTK_BUTTON(BTN(Y, X)), TOOLTIP); \ + gtk_button_set_image_position(GTK_BUTTON(BTN(Y, X)), \ + GTK_POS_TOP); \ + gtk_button_set_always_show_image(GTK_BUTTON(BTN(Y, X)), TRUE); \ + gtk_widget_set_tooltip_text(BTN(Y, X), TOOLTIP); \ + g_signal_connect(BTN(Y, X), "clicked", \ G_CALLBACK(ID ## _clicked_cb), main_menu); \ - gtk_grid_attach(GTK_GRID(grid), buttons[Y * BUTTON_COLS + X], \ - X, Y, 1, 1); \ + gtk_grid_attach(GTK_GRID(grid), BTN(Y, X), X, Y, 1, 1); \ } G_STMT_END static GtkWidget * @@ -339,16 +335,17 @@ create_main_grid(MqMainMenu *main_menu) NEW_BTN(2, 1, print, "document-print", "Print"); NEW_BTN(2, 2, inspector, "preferences-system", "Inspector"); - gtk_widget_set_sensitive(buttons[1 * BUTTON_COLS + 2], FALSE); + gtk_widget_set_sensitive(BTN(1, 2), FALSE); - gtk_widget_set_sensitive(buttons[2 * BUTTON_COLS + 0], FALSE); - gtk_widget_set_sensitive(buttons[2 * BUTTON_COLS + 1], FALSE); + gtk_widget_set_sensitive(BTN(2, 0), FALSE); + gtk_widget_set_sensitive(BTN(2, 1), FALSE); return grid; } #undef BUTTON_ROWS #undef BUTTON_COLS +#undef BTN #undef NEW_BTN #define NEW_BUTTON(ID, ICON, LABEL, TOOLTIP) \ -- cgit v0.9.1