diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-label.c | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/src/tab-label.c b/src/tab-label.c index d783a63..ca6b0e0 100644 --- a/src/tab-label.c +++ b/src/tab-label.c @@ -71,6 +71,20 @@ reload_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqTabLabel *tab_label) } static void +duplicate_clicked_cb(GtkWidget G_GNUC_UNUSED *button, + G_GNUC_UNUSED MqTabLabel *tab_label) +{ + /* TODO */ +} + +static void +move_to_win_clicked_cb(GtkWidget G_GNUC_UNUSED *button, + G_GNUC_UNUSED MqTabLabel *tab_label) +{ + /* TODO */ +} + +static void close_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqTabLabel *tab_label) { /* This callback handles both the close button on the tab label and the @@ -99,21 +113,26 @@ new_window_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqTabLabel *tab_label) gtk_widget_hide(tab_label->popover); } +static void +undo_close_clicked_cb(GtkWidget G_GNUC_UNUSED *button, + G_GNUC_UNUSED MqTabLabel *tab_label) +{ + /* TODO */ +} + #define BUTTON_ROWS 2 #define BUTTON_COLS 4 -#define NEW_BUTTON(Y, X, ICON, TOOLTIP) \ +#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_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); \ + BTN(Y, X) = gtk_button_new_from_icon_name(ICON, \ + GTK_ICON_SIZE_BUTTON); \ + gtk_widget_set_tooltip_text(BTN(Y, X), TOOLTIP); \ + gtk_widget_set_can_focus(BTN(Y, X), FALSE); \ + g_signal_connect(BTN(Y, X), "clicked", \ + G_CALLBACK(ID ## _clicked_cb), tab_label); \ + gtk_grid_attach(GTK_GRID(button_grid), BTN(Y, X), X, Y, 1, 1); \ } G_STMT_END -#define CLICKED_CB(Y, X, CB) \ - g_signal_connect(buttons[Y * BUTTON_COLS + X], "clicked", \ - G_CALLBACK(CB), tab_label) static void create_tab_popover(GtkWidget *widget, MqTabLabel *tab_label) @@ -126,24 +145,21 @@ create_tab_popover(GtkWidget *widget, MqTabLabel *tab_label) 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", _("Move tab to new window")); - NEW_BUTTON(0, 3, "window-close", _("Close tab")); - NEW_BUTTON(1, 0, "tab-new-symbolic", _("New tab")); - NEW_BUTTON(1, 1, "window-new", _("New window")); - NEW_BUTTON(1, 2, "edit-undo", _("Undo close tab")); - - CLICKED_CB(0, 0, reload_tab_clicked_cb); - /* TODO: 0, 1: Duplicate tab */ - gtk_widget_set_sensitive(buttons[0 * BUTTON_COLS + 1], FALSE); - /* TODO: 0, 2: Move tab to new window */ - gtk_widget_set_sensitive(buttons[0 * BUTTON_COLS + 2], FALSE); - CLICKED_CB(0, 3, close_clicked_cb); - CLICKED_CB(1, 0, new_tab_clicked_cb); - CLICKED_CB(1, 1, new_window_clicked_cb); - /* TODO: 1, 2: Undo close tab */ - gtk_widget_set_sensitive(buttons[1 * BUTTON_COLS + 2], FALSE); + /* Y,X,ID, ICON, TOOLTIP */ + NEW_BTN(0,0,reload_tab, "view-refresh", _("Reload tab")); + NEW_BTN(0,1,duplicate, "edit-copy", _("Duplicate tab")); + NEW_BTN(0,2,move_to_win,"window-new", _("Move tab to new window")); + NEW_BTN(0,3,close, "window-close", _("Close tab")); + NEW_BTN(1,0,new_tab, "tab-new-symbolic",_("New tab")); + NEW_BTN(1,1,new_window, "window-new", _("New window")); + NEW_BTN(1,2,undo_close, "edit-undo", _("Undo close tab")); + + /* TODO: Duplicate tab */ + gtk_widget_set_sensitive(BTN(0, 1), FALSE); + /* TODO: Move tab to new window */ + gtk_widget_set_sensitive(BTN(0, 2), FALSE); + /* TODO: Undo close tab */ + gtk_widget_set_sensitive(BTN(1, 2), FALSE); /* Set up the popover. */ tab_label->popover = gtk_popover_new(widget); @@ -155,8 +171,8 @@ create_tab_popover(GtkWidget *widget, MqTabLabel *tab_label) #undef BUTTON_ROWS #undef BUTTON_COLS -#undef NEW_BUTTON -#undef CLICKED_CB +#undef BTN +#undef NEW_BTN static void set_image(MqTabLabel *tab_label, GdkPixbuf *favicon) |