summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tab-chrome.c264
-rw-r--r--src/tab-chrome.h9
-rw-r--r--src/tab.c3
3 files changed, 131 insertions, 145 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index fea7259..40f7ed2 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -463,138 +463,6 @@ menu_button_clicked_cb(GtkToolButton *tool_button,
#undef BUTTON_COLS
#undef NEW_BUTTON
-static GtkWidget *
-navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri)
-{
- GtkToolbar *navigation_toolbar;
- GtkToolItem *back_forward_tool_item;
- GtkWidget *back_forward_event_box;
- GtkToolItem *uri_tool_item;
- GtkToolItem *home_button;
-
- navigation_toolbar = GTK_TOOLBAR(gtk_toolbar_new());
-
- back_forward_tool_item = gtk_tool_item_new();
- chrome->back_forward_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-
- /* Back button */
- chrome->back_button = gtk_button_new_from_icon_name("go-previous",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->back_button),
- "Go back one page");
- g_signal_connect(chrome->back_button, "clicked",
- G_CALLBACK(back_clicked_cb), chrome);
- gtk_box_pack_start(GTK_BOX(chrome->back_forward_box),
- chrome->back_button, FALSE, FALSE, 0);
-
- /* Forward button */
- chrome->forward_button = gtk_button_new_from_icon_name("go-next",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->forward_button),
- "Go forward one page");
- g_signal_connect(chrome->forward_button, "clicked",
- G_CALLBACK(forward_clicked_cb), chrome);
- gtk_box_pack_start(GTK_BOX(chrome->back_forward_box),
- chrome->forward_button, FALSE, FALSE, 0);
-
- gtk_style_context_add_class(
- gtk_widget_get_style_context(chrome->back_forward_box),
- "linked");
- back_forward_event_box = gtk_event_box_new();
- g_signal_connect(back_forward_event_box, "button-press-event",
- G_CALLBACK(back_forward_box_button_press_cb), chrome);
- gtk_container_add(GTK_CONTAINER(back_forward_event_box),
- chrome->back_forward_box);
- gtk_container_add(GTK_CONTAINER(back_forward_tool_item),
- back_forward_event_box);
- gtk_toolbar_insert(navigation_toolbar, back_forward_tool_item, -1);
-
- /* Stop/reload button */
- chrome->stop_icon = gtk_image_new_from_icon_name("process-stop",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- g_object_ref_sink(chrome->stop_icon);
- chrome->reload_icon = gtk_image_new_from_icon_name("view-refresh",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- g_object_ref_sink(chrome->reload_icon);
- chrome->stop_reload_button = gtk_tool_button_new(chrome->stop_icon,
- "Stop");
- gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->stop_reload_button),
- "Stop loading the current page");
- g_signal_connect(chrome->stop_reload_button, "clicked",
- G_CALLBACK(stop_reload_clicked_cb), chrome);
- gtk_toolbar_insert(navigation_toolbar, chrome->stop_reload_button, -1);
-
- /* URI bar */
- uri_tool_item = gtk_tool_item_new();
- chrome->uri_entry = gtk_entry_new();
- if (uri) {
- gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri);
- }
- gtk_entry_set_placeholder_text(GTK_ENTRY(chrome->uri_entry),
- "URI...");
- gtk_entry_set_icon_from_icon_name(GTK_ENTRY(chrome->uri_entry),
- GTK_ENTRY_ICON_PRIMARY, "text-x-generic");
- gtk_entry_set_progress_fraction(GTK_ENTRY(chrome->uri_entry), 0.0);
- g_signal_connect(chrome->uri_entry, "activate",
- G_CALLBACK(uri_activate_cb), chrome);
- gtk_container_add(GTK_CONTAINER(uri_tool_item),
- chrome->uri_entry);
- gtk_tool_item_set_expand(uri_tool_item, TRUE);
- gtk_toolbar_insert(navigation_toolbar, uri_tool_item, -1);
-
- /* URI bar hovered link style */
- chrome->hovered_link_style = pango_attr_list_new();
- 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",
- 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);
- gtk_toolbar_insert(navigation_toolbar, chrome->menu_button, -1);
-
- gtk_widget_set_hexpand(GTK_WIDGET(navigation_toolbar), TRUE);
-
- chrome->load_failed = FALSE;
-
- return GTK_WIDGET(navigation_toolbar);
-}
-
-MqTabChrome *
-mq_tab_chrome_new(MqTab *tab, const gchar *uri)
-{
- MqTabChrome *chrome;
-
- chrome = malloc(sizeof(*chrome));
- chrome->config = mq_application_get_config(mq_tab_get_application(tab));
- chrome->tab = tab;
-
- chrome->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(chrome->container),
- navigation_toolbar_new(chrome, uri), FALSE, FALSE, 0);
-
- return chrome;
-}
-
-GtkWidget *
-mq_tab_chrome_get_container(MqTabChrome *chrome)
-{
- return chrome->container;
-}
-
static void
load_changed_cb(MqWebView *web_view, WebKitLoadEvent load_event,
MqTabChrome *chrome)
@@ -756,9 +624,112 @@ back_forward_list_changed_cb(
WEBKIT_WEB_VIEW(chrome->web_view)));
}
-static void
-connect_web_view(MqTabChrome *chrome)
+static GtkWidget *
+navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri)
{
+ GtkToolbar *navigation_toolbar;
+ GtkToolItem *back_forward_tool_item;
+ GtkWidget *back_forward_event_box;
+ GtkToolItem *uri_tool_item;
+ GtkToolItem *home_button;
+
+ navigation_toolbar = GTK_TOOLBAR(gtk_toolbar_new());
+
+ back_forward_tool_item = gtk_tool_item_new();
+ chrome->back_forward_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+
+ /* Back button */
+ chrome->back_button = gtk_button_new_from_icon_name("go-previous",
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->back_button),
+ "Go back one page");
+ g_signal_connect(chrome->back_button, "clicked",
+ G_CALLBACK(back_clicked_cb), chrome);
+ gtk_box_pack_start(GTK_BOX(chrome->back_forward_box),
+ chrome->back_button, FALSE, FALSE, 0);
+
+ /* Forward button */
+ chrome->forward_button = gtk_button_new_from_icon_name("go-next",
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->forward_button),
+ "Go forward one page");
+ g_signal_connect(chrome->forward_button, "clicked",
+ G_CALLBACK(forward_clicked_cb), chrome);
+ gtk_box_pack_start(GTK_BOX(chrome->back_forward_box),
+ chrome->forward_button, FALSE, FALSE, 0);
+
+ gtk_style_context_add_class(
+ gtk_widget_get_style_context(chrome->back_forward_box),
+ "linked");
+ back_forward_event_box = gtk_event_box_new();
+ g_signal_connect(back_forward_event_box, "button-press-event",
+ G_CALLBACK(back_forward_box_button_press_cb), chrome);
+ gtk_container_add(GTK_CONTAINER(back_forward_event_box),
+ chrome->back_forward_box);
+ gtk_container_add(GTK_CONTAINER(back_forward_tool_item),
+ back_forward_event_box);
+ gtk_toolbar_insert(navigation_toolbar, back_forward_tool_item, -1);
+
+ /* Stop/reload button */
+ chrome->stop_icon = gtk_image_new_from_icon_name("process-stop",
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ g_object_ref_sink(chrome->stop_icon);
+ chrome->reload_icon = gtk_image_new_from_icon_name("view-refresh",
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ g_object_ref_sink(chrome->reload_icon);
+ chrome->stop_reload_button = gtk_tool_button_new(chrome->stop_icon,
+ "Stop");
+ gtk_widget_set_tooltip_text(GTK_WIDGET(chrome->stop_reload_button),
+ "Stop loading the current page");
+ g_signal_connect(chrome->stop_reload_button, "clicked",
+ G_CALLBACK(stop_reload_clicked_cb), chrome);
+ gtk_toolbar_insert(navigation_toolbar, chrome->stop_reload_button, -1);
+
+ /* URI bar */
+ uri_tool_item = gtk_tool_item_new();
+ chrome->uri_entry = gtk_entry_new();
+ if (uri) {
+ gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri);
+ }
+ gtk_entry_set_placeholder_text(GTK_ENTRY(chrome->uri_entry),
+ "URI...");
+ gtk_entry_set_icon_from_icon_name(GTK_ENTRY(chrome->uri_entry),
+ GTK_ENTRY_ICON_PRIMARY, "text-x-generic");
+ gtk_entry_set_progress_fraction(GTK_ENTRY(chrome->uri_entry), 0.0);
+ g_signal_connect(chrome->uri_entry, "activate",
+ G_CALLBACK(uri_activate_cb), chrome);
+ gtk_container_add(GTK_CONTAINER(uri_tool_item),
+ chrome->uri_entry);
+ gtk_tool_item_set_expand(uri_tool_item, TRUE);
+ gtk_toolbar_insert(navigation_toolbar, uri_tool_item, -1);
+
+ /* URI bar hovered link style */
+ chrome->hovered_link_style = pango_attr_list_new();
+ 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",
+ 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);
+ gtk_toolbar_insert(navigation_toolbar, chrome->menu_button, -1);
+
+ gtk_widget_set_hexpand(GTK_WIDGET(navigation_toolbar), TRUE);
+
+ chrome->load_failed = FALSE;
chrome->hovered_link_uri = NULL;
g_signal_connect(chrome->web_view, "load-changed",
@@ -776,14 +747,33 @@ connect_web_view(MqTabChrome *chrome)
g_signal_connect(webkit_web_view_get_back_forward_list(
WEBKIT_WEB_VIEW(chrome->web_view)),
"changed", G_CALLBACK(back_forward_list_changed_cb), chrome);
+
+ return GTK_WIDGET(navigation_toolbar);
}
-void
-mq_tab_chrome_set_web_view(MqTabChrome *chrome, MqWebView *web_view)
+MqTabChrome *
+mq_tab_chrome_new(MqTab *tab, MqWebView *web_view, const gchar *uri)
{
+ MqTabChrome *chrome;
+
+ chrome = malloc(sizeof(*chrome));
+ chrome->config = mq_application_get_config(mq_tab_get_application(tab));
+ chrome->tab = tab;
chrome->web_view = web_view;
+
+ chrome->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_pack_start(GTK_BOX(chrome->container),
+ navigation_toolbar_new(chrome, uri), FALSE, FALSE, 0);
+
chrome->find_toolbar = mq_find_toolbar_new(web_view);
gtk_box_pack_start(GTK_BOX(chrome->container), chrome->find_toolbar,
FALSE, FALSE, 0);
- connect_web_view(chrome);
+
+ return chrome;
+}
+
+GtkWidget *
+mq_tab_chrome_get_container(MqTabChrome *chrome)
+{
+ return chrome->container;
}
diff --git a/src/tab-chrome.h b/src/tab-chrome.h
index 2393650..25ac888 100644
--- a/src/tab-chrome.h
+++ b/src/tab-chrome.h
@@ -42,23 +42,20 @@ struct MqTabChrome {
GtkToolItem *stop_reload_button;
GtkWidget *uri_entry;
PangoAttrList *hovered_link_style;
- gchar *hovered_link_uri;
MqWebView *web_view;
GtkWidget *find_toolbar;
gboolean load_failed;
- GtkWidget *back_forward_popover;
gint back_items;
GtkToolItem *menu_button;
GtkWidget *menu_popover;
+ gchar *hovered_link_uri;
+ GtkWidget *back_forward_popover;
};
MqTabChrome *
-mq_tab_chrome_new(MqTab *tab, const gchar *uri);
+mq_tab_chrome_new(MqTab *tab, MqWebView *web_view, const gchar *uri);
GtkWidget *
mq_tab_chrome_get_container(MqTabChrome *chrome);
-void
-mq_tab_chrome_set_web_view(MqTabChrome *chrome, MqWebView *web_view);
-
#endif
diff --git a/src/tab.c b/src/tab.c
index d1104ab..4d09cab 100644
--- a/src/tab.c
+++ b/src/tab.c
@@ -442,8 +442,7 @@ init_non_root(const gchar *uri, MqTab *source)
g_signal_connect(tab->web_view, "notify::title",
G_CALLBACK(title_cb), tab);
- tab->chrome = mq_tab_chrome_new(tab, uri);
- mq_tab_chrome_set_web_view(tab->chrome, MQ_WEB_VIEW(tab->web_view));
+ tab->chrome = mq_tab_chrome_new(tab, MQ_WEB_VIEW(tab->web_view), uri);
tab->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start(GTK_BOX(tab->container),