From 927c4ea37ca967e61831164bb4b7ea33e28e0d9d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 08 Oct 2017 03:57:10 -0400 Subject: MqTabChrome: Add a home button to the navigation bar --- diff --git a/src/tab-chrome.c b/src/tab-chrome.c index 39efff7..3a57f4b 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -312,6 +312,24 @@ uri_activate_cb(GtkEntry *entry, MqTabChrome *chrome) } static void +home_clicked_cb(GtkToolButton G_GNUC_UNUSED *toolbutton, + MqTabChrome *chrome) +{ + const gchar *uri; + gchar *rw_uri; + + uri = mq_config_get_string(chrome->config, "tabs.home"); + + if (g_str_has_prefix(uri, "about:")) { + rw_uri = g_strconcat("mq-about:", uri + strlen("about:"), NULL); + webkit_web_view_load_uri(chrome->web_view, rw_uri); + g_free(rw_uri); + } else { + webkit_web_view_load_uri(chrome->web_view, uri); + } +} + +static void zoom_out_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome) { webkit_web_view_set_zoom_level(chrome->web_view, @@ -463,6 +481,7 @@ navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri) GtkToolItem *back_forward_tool_item; GtkWidget *back_forward_event_box; GtkToolItem *uri_tool_item; + GtkToolItem *home_button; navigation_toolbar = GTK_TOOLBAR(gtk_toolbar_new()); @@ -539,6 +558,15 @@ navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri) pango_attr_list_insert(chrome->hovered_link_style, pango_attr_style_new(PANGO_STYLE_ITALIC)); + /* Home button */ + home_button = gtk_tool_button_new(gtk_image_new_from_icon_name( + "go-home", GTK_ICON_SIZE_SMALL_TOOLBAR), "Home"); + gtk_widget_set_tooltip_text(GTK_WIDGET(home_button), + "Load the home page"); + g_signal_connect(home_button, "clicked", + G_CALLBACK(home_clicked_cb), chrome); + 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", -- cgit v0.9.1