summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tab-chrome.c101
-rw-r--r--src/tab-chrome.h2
2 files changed, 102 insertions, 1 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index 976597a..f09eb25 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -333,6 +333,15 @@ zoom_in_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
}
static void
+find_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
+{
+ gtk_revealer_set_reveal_child(GTK_REVEALER(chrome->find_revealer),
+ TRUE);
+ gtk_widget_grab_focus(chrome->find_search_entry);
+ gtk_widget_hide(chrome->menu_popover);
+}
+
+static void
fullscreen_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
{
mq_window_toggle_fullscreen(mq_tab_get_window(chrome->tab));
@@ -423,7 +432,7 @@ menu_button_clicked_cb(GtkToolButton *tool_button,
/* TODO: 1, 0: Open file */
/* TODO: 1, 1: Save page */
/* TODO: 1, 2: E-mail link */
- /* TODO: 2, 0: Find */
+ CLICKED_CB(2, 0, find_clicked_cb);
/* TODO: 2, 1: Print preview */
/* TODO: 2, 2: Print */
/* TODO: 3, 0: Bookmarks */
@@ -547,6 +556,94 @@ navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri)
return GTK_WIDGET(navigation_toolbar);
}
+static void
+find_prev_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
+{
+ /* FIXME: Unimplemented */
+}
+
+static void
+find_next_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
+{
+ /* FIXME: Unimplemented */
+}
+
+static void
+find_match_case_toggled_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
+{
+ /* FIXME: Unimplemented */
+}
+
+static void
+find_close_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome)
+{
+ gtk_revealer_set_reveal_child(GTK_REVEALER(chrome->find_revealer),
+ FALSE);
+}
+
+static GtkWidget *
+find_toolbar_new(MqTabChrome *chrome)
+{
+ GtkWidget *close_button;
+ GtkWidget *prev_button;
+ GtkWidget *next_button;
+ GtkWidget *match_case_button;
+ GtkWidget *box;
+
+ /* Search entry */
+ chrome->find_search_entry = gtk_search_entry_new();
+
+ /* Previous button */
+ prev_button = gtk_button_new_from_icon_name("go-up",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_tooltip_text(prev_button, "Find previous occurrence");
+ gtk_widget_set_can_focus(prev_button, FALSE);
+ g_signal_connect(prev_button, "clicked",
+ G_CALLBACK(find_prev_clicked_cb), chrome);
+
+ /* Next button */
+ next_button = gtk_button_new_from_icon_name("go-down",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_tooltip_text(next_button, "Find next occurrence");
+ gtk_widget_set_can_focus(next_button, FALSE);
+ g_signal_connect(next_button, "clicked",
+ G_CALLBACK(find_next_clicked_cb), chrome);
+
+ /* Case sensitivity button */
+ match_case_button = gtk_toggle_button_new_with_label("Match case");
+ gtk_widget_set_tooltip_text(match_case_button,
+ "Search with case sensitivity");
+ gtk_widget_set_can_focus(match_case_button, FALSE);
+ g_signal_connect(match_case_button, "toggled",
+ G_CALLBACK(find_match_case_toggled_cb), chrome);
+
+ /* Close button */
+ close_button = gtk_button_new_from_icon_name("window-close",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text(close_button, "Close find bar");
+ gtk_widget_set_can_focus(close_button, FALSE);
+ g_signal_connect(close_button, "clicked",
+ G_CALLBACK(find_close_clicked_cb), chrome);
+
+ /* Box */
+ box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start(GTK_BOX(box), chrome->find_search_entry,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), prev_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), next_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), match_case_button, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(box), close_button, FALSE, FALSE, 0);
+
+ /* Revealer */
+ chrome->find_revealer = gtk_revealer_new();
+ gtk_revealer_set_transition_type(GTK_REVEALER(chrome->find_revealer),
+ GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+ gtk_container_add(GTK_CONTAINER(chrome->find_revealer), box);
+
+ return chrome->find_revealer;
+}
+
MqTabChrome *
mq_tab_chrome_new(MqTab *tab, const gchar *uri)
{
@@ -559,6 +656,8 @@ mq_tab_chrome_new(MqTab *tab, const gchar *uri)
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);
+ gtk_box_pack_start(GTK_BOX(chrome->container),
+ find_toolbar_new(chrome), FALSE, FALSE, 0);
return chrome;
}
diff --git a/src/tab-chrome.h b/src/tab-chrome.h
index 850a783..658351b 100644
--- a/src/tab-chrome.h
+++ b/src/tab-chrome.h
@@ -42,6 +42,8 @@ struct MqTabChrome {
GtkWidget *uri_entry;
PangoAttrList *hovered_link_style;
gchar *hovered_link_uri;
+ GtkWidget *find_revealer;
+ GtkWidget *find_search_entry;
WebKitWebView *web_view;
gboolean load_failed;
GtkWidget *back_forward_popover;