summaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-22 01:39:21 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-22 01:39:21 (EDT)
commit4d5308723024a5eaaee42f60c79fb0862b072052 (patch)
tree4702e3d0be32074014b353103075b0a994746dfd /src/window.c
parentc5ec2c6c37ca5a9548957312d08edc493d512411 (diff)
downloadmarquee-4d5308723024a5eaaee42f60c79fb0862b072052.zip
marquee-4d5308723024a5eaaee42f60c79fb0862b072052.tar.gz
marquee-4d5308723024a5eaaee42f60c79fb0862b072052.tar.bz2
Move tab context menu code from MqWindow to MqTab
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c102
1 files changed, 1 insertions, 101 deletions
diff --git a/src/window.c b/src/window.c
index 013ed80..bd64e1e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -27,116 +27,16 @@
#include "tab.h"
static void
-tab_list_button_toggled_cb(GtkToggleButton *toggle_button, GtkWidget *tab_list)
-{
- if (gtk_toggle_button_get_active(toggle_button)) {
- gtk_widget_show(tab_list);
- } else {
- gtk_widget_hide(tab_list);
- }
-}
-
-#define BUTTON_ROWS 2
-#define BUTTON_COLS 4
-#define NEW_BUTTON(Y, X, ICON, TOOLTIP) \
- do { \
- 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)
-#define NEW_TOGGLE(Y, X, ICON, TOOLTIP) \
- do { \
- buttons[Y * BUTTON_COLS + X] = gtk_toggle_button_new(); \
- gtk_button_set_image(GTK_BUTTON(buttons[Y * BUTTON_COLS + X]), \
- gtk_image_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 *button_grid;
- GtkWidget *buttons[BUTTON_ROWS * BUTTON_COLS];
- GtkWidget *box;
- GtkWidget *tab_list;
- GtkWidget *popover; /* TODO: Add to MqWindow */
-
- /* Make sure this is a right mouse button press event. */
- if (event->type != GDK_BUTTON_PRESS || event->button.button != 3) {
- return FALSE;
- }
-
- /* 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, 0, "tab-new-symbolic", "New tab");
- NEW_BUTTON(1, 1, "edit-undo", "Undo close tab");
- NEW_TOGGLE(1, 3, "view-list-symbolic", "Tab list...");
-
- /* Set up the button rows box. */
- box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(box), button_grid,
- TRUE, FALSE, 0);
-
- /* Set up the tab list. */
- tab_list = gtk_label_new("Tab list");
- gtk_box_pack_start(GTK_BOX(box), tab_list,
- TRUE, FALSE, 0);
-
- g_signal_connect(buttons[1 * BUTTON_COLS + 3], "toggled",
- G_CALLBACK(tab_list_button_toggled_cb), tab_list);
-
- /* Set up the popover. */
- popover = gtk_popover_new(widget);
- gtk_container_add(GTK_CONTAINER(popover), box);
-
- /* NB: gtk_popover_popup() is new in GTK+ 3.22. */
- gtk_widget_show_all(popover);
- gtk_widget_hide(tab_list);
-
- return FALSE;
-}
-
-#undef BUTTON_ROWS
-#undef BUTTON_COLS
-#undef NEW_BUTTON
-#undef NEW_TOGGLE
-
-static void
add_tab(MqWindow *window, gchar *uri, gint position)
{
MqTab *tab;
- GtkWidget *tab_label_event_box;
GtkWidget *tab_widget;
tab = mq_tab_new(uri);
- tab_label_event_box = gtk_event_box_new();
- g_signal_connect(tab_label_event_box, "button-press-event",
- G_CALLBACK(tab_label_button_press_cb), tab);
- gtk_event_box_set_visible_window(GTK_EVENT_BOX(tab_label_event_box),
- FALSE);
- gtk_container_add(GTK_CONTAINER(tab_label_event_box),
- mq_tab_get_tab(tab));
-
tab_widget = mq_tab_get_container(tab);
position = gtk_notebook_insert_page(GTK_NOTEBOOK(window->notebook),
- tab_widget, tab_label_event_box, position);
+ tab_widget, mq_tab_get_tab(tab), position);
gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(window->notebook),
tab_widget, TRUE);
gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(window->notebook),