From 9f5232732784a299f5586fb7b275210ca8473388 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 27 Sep 2017 21:30:05 -0400 Subject: MqTab: Refactor popover creation into more functions --- (limited to 'src/tab.c') diff --git a/src/tab.c b/src/tab.c index 6f3a539..f1ef600 100644 --- a/src/tab.c +++ b/src/tab.c @@ -167,8 +167,14 @@ tab_list_button_toggled_cb(GtkToggleButton *toggle_button, GtkWidget *tab_list) #define CLICKED_CB(Y, X, CB) \ g_signal_connect(buttons[Y * BUTTON_COLS + X], "clicked", CB, tab) -static gboolean -tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab) +static GtkWidget * +create_tab_list(void) +{ + return gtk_label_new("Tab list"); +} + +static void +create_tab_popover(GtkWidget *widget, MqTab *tab) { GtkWidget *button_grid; GtkWidget *buttons[BUTTON_ROWS * BUTTON_COLS]; @@ -176,11 +182,6 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab) GtkWidget *tab_list_scrolled_window; GtkWidget *box; - /* 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); @@ -200,7 +201,7 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab) CLICKED_CB(1, 1, G_CALLBACK(new_window_clicked_cb)); /* Set up the tab list. */ - tab_list = gtk_label_new("Tab list"); + tab_list = create_tab_list(); /* Set up the tab list scrolled window. * @@ -235,6 +236,17 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab) /* NB: gtk_popover_popup() is new in GTK+ 3.22. */ gtk_widget_show_all(tab->popover); gtk_widget_hide(tab_list_scrolled_window); +} + +static gboolean +tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab) +{ + /* Make sure this is a right mouse button press event. */ + if (event->type != GDK_BUTTON_PRESS || event->button.button != 3) { + return FALSE; + } + + create_tab_popover(widget, tab); return FALSE; } -- cgit v0.9.1