summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-12 23:51:39 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-12 23:51:39 (EDT)
commit9740cb4f644bb49f4cd8f10d2d76e7a4ff7ce9a3 (patch)
treeabd3995fbdee3053a32b535deb2c70b338a2c4ad /src
parent3962132f9f079897cafa444d9fde5d9eca4dacdf (diff)
downloadmarquee-9740cb4f644bb49f4cd8f10d2d76e7a4ff7ce9a3.zip
marquee-9740cb4f644bb49f4cd8f10d2d76e7a4ff7ce9a3.tar.gz
marquee-9740cb4f644bb49f4cd8f10d2d76e7a4ff7ce9a3.tar.bz2
MqTabChrome: Use MqMainMenu
Diffstat (limited to 'src')
-rw-r--r--src/tab-chrome.c149
-rw-r--r--src/tab-chrome.h1
2 files changed, 2 insertions, 148 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index 285b42f..9cc6619 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -63,146 +63,6 @@ home_clicked_cb(GtkToolButton G_GNUC_UNUSED *toolbutton,
}
static void
-zoom_out_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- mq_web_view_zoom_out(chrome->web_view);
-}
-
-static void
-zoom_reset_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- mq_web_view_zoom_reset(chrome->web_view);
-}
-
-static void
-zoom_in_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- mq_web_view_zoom_in(chrome->web_view);
-}
-
-static void
-find_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- gtk_widget_hide(chrome->menu_popover);
- mq_find_toolbar_reveal(chrome->find_toolbar);
-}
-
-static void
-fullscreen_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- gtk_widget_hide(chrome->menu_popover);
- mq_window_toggle_fullscreen(mq_tab_get_window(chrome->tab));
-}
-
-static void
-developer_tools_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- gtk_widget_hide(chrome->menu_popover);
- webkit_web_inspector_show(webkit_web_view_get_inspector(
- WEBKIT_WEB_VIEW(chrome->web_view)));
-}
-
-static void
-preferences_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- gtk_widget_hide(chrome->menu_popover);
- mq_tab_new("about:preferences", chrome->tab);
- /* TODO: Hack: */
- gtk_notebook_next_page(GTK_NOTEBOOK(chrome->tab->window->notebook));
-}
-
-static void
-about_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- gtk_widget_hide(chrome->menu_popover);
- mq_tab_new("about:", chrome->tab);
- /* TODO: Hack: */
- gtk_notebook_next_page(GTK_NOTEBOOK(chrome->tab->window->notebook));
-}
-
-static void
-quit_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
-{
- /* mq_tab_quit() just calls mq_window_quit(), which just calls
- * mq_application_quit(), which is asynchronous. So close the menu. */
- gtk_widget_hide(chrome->menu_popover);
- mq_tab_quit(chrome->tab);
-}
-
-#define BUTTON_ROWS 6
-#define BUTTON_COLS 3
-#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_grid_attach(GTK_GRID(grid), buttons[Y * BUTTON_COLS + X], \
- X, Y, 1, 1); \
- } while (0)
-#define CLICKED_CB(Y, X, CB) \
- g_signal_connect(buttons[Y * BUTTON_COLS + X], "clicked", \
- G_CALLBACK(CB), chrome)
-
-static void
-menu_button_clicked_cb(GtkToolButton *tool_button,
- MqTabChrome G_GNUC_UNUSED *chrome)
-{
- GtkWidget *grid;
- GtkWidget *buttons[BUTTON_ROWS * BUTTON_COLS];
-
- /* Set up the grid. */
- grid = gtk_grid_new();
-
- NEW_BUTTON(0, 0, "zoom-out", "Zoom out");
- NEW_BUTTON(0, 1, "zoom-original", "Reset zoom");
- NEW_BUTTON(0, 2, "zoom-in", "Zoom in");
- NEW_BUTTON(1, 0, "document-open", "Open file");
- NEW_BUTTON(1, 1, "document-save-as", "Save page");
- NEW_BUTTON(1, 2, "mail-message-new", "E-mail link");
- NEW_BUTTON(2, 0, "edit-find", "Find");
- NEW_BUTTON(2, 1, "document-print-preview", "Print preview");
- NEW_BUTTON(2, 2, "document-print", "Print");
- NEW_BUTTON(3, 0, "bookmark-new", "Bookmarks");
- NEW_BUTTON(3, 1, "document-open-recent", "History");
- NEW_BUTTON(3, 2, "document-save", "Downloads");
- NEW_BUTTON(4, 0, "view-fullscreen", "Full screen");
- NEW_BUTTON(4, 1, "document-properties", "Developer tools");
- NEW_BUTTON(4, 2, "system-run", "Preferences");
- NEW_BUTTON(5, 0, "help-about", "About Marquee");
- NEW_BUTTON(5, 2, "application-exit", "Quit");
-
- CLICKED_CB(0, 0, zoom_out_clicked_cb);
- CLICKED_CB(0, 1, zoom_reset_clicked_cb);
- CLICKED_CB(0, 2, zoom_in_clicked_cb);
- /* TODO: 1, 0: Open file */
- /* TODO: 1, 1: Save page */
- /* TODO: 1, 2: E-mail link */
- CLICKED_CB(2, 0, find_clicked_cb);
- /* TODO: 2, 1: Print preview */
- /* TODO: 2, 2: Print */
- /* TODO: 3, 0: Bookmarks */
- /* TODO: 3, 1: History */
- /* TODO: 3, 2: Downloads */
- CLICKED_CB(4, 0, fullscreen_clicked_cb);
- CLICKED_CB(4, 1, developer_tools_clicked_cb);
- CLICKED_CB(4, 2, preferences_clicked_cb);
- CLICKED_CB(5, 0, about_clicked_cb);
- CLICKED_CB(5, 2, quit_clicked_cb);
-
- /* Set up the popover. */
- chrome->menu_popover = gtk_popover_new(GTK_WIDGET(tool_button));
- gtk_container_add(GTK_CONTAINER(chrome->menu_popover), grid);
-
- /* NB: gtk_popover_popup() is new in GTK+ 3.22. */
- gtk_widget_show_all(chrome->menu_popover);
-}
-
-#undef BUTTON_ROWS
-#undef BUTTON_COLS
-#undef NEW_BUTTON
-
-static void
load_changed_cb(MqWebView *web_view, WebKitLoadEvent load_event,
MqTabChrome *chrome)
{
@@ -416,13 +276,8 @@ navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri)
gtk_toolbar_insert(navigation_toolbar, home_button, -1);
/* Menu button */
- chrome->menu_button = gtk_tool_button_new(
- gtk_image_new_from_icon_name("open-menu-symbolic",
- GTK_ICON_SIZE_SMALL_TOOLBAR), "Menu");
- gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->menu_button),
- "Open menu");
- g_signal_connect(chrome->menu_button, "clicked",
- G_CALLBACK(menu_button_clicked_cb), chrome);
+ chrome->menu_button = mq_main_menu_new(chrome->tab,
+ chrome->find_toolbar, chrome->web_view);
gtk_toolbar_insert(navigation_toolbar, chrome->menu_button, -1);
gtk_widget_set_hexpand(GTK_WIDGET(navigation_toolbar), TRUE);
diff --git a/src/tab-chrome.h b/src/tab-chrome.h
index 54cd3c8..cc897f4 100644
--- a/src/tab-chrome.h
+++ b/src/tab-chrome.h
@@ -45,7 +45,6 @@ struct MqTabChrome {
MqWebView *web_view;
gboolean load_failed;
GtkToolItem *menu_button;
- GtkWidget *menu_popover;
gchar *hovered_link_uri;
};