summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/window.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/window.c b/src/window.c
index 04ac715..e627d8e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -48,23 +48,24 @@ tab_list_back_button_clicked_cb(GtkButton __attribute__((unused)) *button,
gtk_widget_hide(gtk_stack_get_child_by_name(stack, "tab_list"));
}
-#define NEW_BUTTON(BOX, I, NAME, TOOLTIP) \
+#define BUTTON_ROWS 2
+#define BUTTON_COLS 4
+#define NEW_BUTTON(Y, X, ICON, TOOLTIP) \
do { \
- buttons[I] = gtk_button_new_from_icon_name(NAME, \
- GTK_ICON_SIZE_BUTTON); \
- gtk_widget_set_tooltip_text(buttons[I], TOOLTIP); \
- gtk_widget_set_can_focus(buttons[I], FALSE); \
- gtk_box_pack_start(GTK_BOX(BOX ? all_tabs_button_box : \
- current_tab_button_box), buttons[I], \
- TRUE, FALSE, 0); \
+ buttons[Y * BUTTON_COLS + X] = gtk_button_new_from_icon_name(\
+ ICON, GTK_ICON_SIZE_BUTTON); \
+ gtk_widget_set_tooltip_text(buttons[Y * BUTTON_COLS + X], \
+ TOOLTIP); \
+ gtk_widget_set_can_focus(buttons[Y * BUTTON_COLS + X], FALSE); \
+ gtk_grid_attach(GTK_GRID(button_grid), \
+ buttons[Y * BUTTON_COLS + X], X, Y, 1, 1); \
} while (0)
static gboolean
tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab)
{
- GtkWidget *current_tab_button_box;
- GtkWidget *all_tabs_button_box;
- GtkWidget *buttons[8];
+ GtkWidget *button_grid;
+ GtkWidget *buttons[BUTTON_ROWS * BUTTON_COLS];
GtkWidget *button_rows_box;
GtkWidget *tab_list_box;
GtkWidget *stack;
@@ -75,38 +76,36 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab)
return FALSE;
}
- /* Set up button boxes. */
- current_tab_button_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- all_tabs_button_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_widget_set_halign(current_tab_button_box, GTK_ALIGN_CENTER);
- gtk_widget_set_halign(all_tabs_button_box, GTK_ALIGN_CENTER);
+ /* Set up button grid. */
+ button_grid = gtk_grid_new();
+ gtk_widget_set_halign(button_grid, GTK_ALIGN_CENTER);
/* Set up buttons. */
NEW_BUTTON(0, 0, "view-refresh", "Reload tab");
NEW_BUTTON(0, 1, "edit-copy", "Duplicate tab");
NEW_BUTTON(0, 2, "window-new", "Open tab in new window");
NEW_BUTTON(0, 3, "window-close", "Close tab");
- NEW_BUTTON(1, 4, "tab-new-symbolic", "New tab");
- NEW_BUTTON(1, 5, "edit-undo", "Undo close tab");
- NEW_BUTTON(1, 6, "view-list-symbolic", "Tab list...");
+ NEW_BUTTON(1, 0, "tab-new-symbolic", "New tab");
+ NEW_BUTTON(1, 1, "edit-undo", "Undo close tab");
+ NEW_BUTTON(1, 3, "view-list-symbolic", "Tab list...");
/* Set up the button rows box. */
button_rows_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(button_rows_box), current_tab_button_box,
- TRUE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(button_rows_box), all_tabs_button_box,
+ gtk_box_pack_start(GTK_BOX(button_rows_box), button_grid,
TRUE, FALSE, 0);
/* Set up tab list box. */
tab_list_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
/* Set up tab list back button. */
+ /*
buttons[7] = gtk_button_new_from_icon_name("go-previous-symbolic",
GTK_ICON_SIZE_BUTTON);
gtk_widget_set_tooltip_text(buttons[7], "Back");
gtk_widget_set_can_focus(buttons[7], FALSE);
gtk_widget_set_halign(buttons[7], GTK_ALIGN_START);
gtk_box_pack_start(GTK_BOX(tab_list_box), buttons[7], TRUE, FALSE, 0);
+ */
gtk_box_pack_start(GTK_BOX(tab_list_box), gtk_label_new("Tab list"),
TRUE, FALSE, 0);
@@ -116,10 +115,8 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab)
gtk_stack_add_named(GTK_STACK(stack), button_rows_box, "buttons");
gtk_stack_add_named(GTK_STACK(stack), tab_list_box, "tab_list");
- g_signal_connect(buttons[6], "clicked",
+ g_signal_connect(buttons[1 * BUTTON_COLS + 3], "clicked",
G_CALLBACK(tab_list_button_clicked_cb), GTK_STACK(stack));
- g_signal_connect(buttons[7], "clicked",
- G_CALLBACK(tab_list_back_button_clicked_cb), GTK_STACK(stack));
/* Set up the popover. */
popover = gtk_popover_new(widget);
@@ -132,6 +129,8 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab)
return FALSE;
}
+#undef BUTTON_ROWS
+#undef BUTTON_COLS
#undef NEW_BUTTON
static void