clean up find in page to operate nicely

This commit is contained in:
Vincent Sanders 2019-09-17 21:18:28 +01:00 committed by Daniel Silverstone
parent a20fe23ce6
commit a013a24d5f
6 changed files with 144 additions and 302 deletions

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="wndBrowser">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
@ -19,156 +23,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="toolbar_style">both</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="searchbar">
<property name="can_focus">False</property>
<property name="toolbar_style">both</property>
<child>
<object class="GtkToolButton" id="closeSearchButton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="stock_id">gtk-close</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="searchLabelItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkLabel" id="searchlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xpad">4</property>
<property name="label" translatable="yes">Match</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="toolSearch">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkEntry" id="searchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="searchBackButton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Search _Back</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-back</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="searchForwardButton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Search _Forward</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-forward</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="checkAllSearchItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkCheckButton" id="checkAllSearch">
<property name="label" translatable="yes">All</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="caseSensItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkCheckButton" id="caseSensButton">
<property name="label" translatable="yes">Case</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>

View File

@ -29,15 +29,109 @@
</packing>
</child>
<child>
<object class="GtkToolbar" id="searchbar">
<object class="GtkToolbar" id="findbar">
<property name="can_focus">False</property>
<property name="toolbar_style">both</property>
<child>
<object class="GtkToolButton" id="closeSearchButton">
<object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">gtk-close</property>
<child>
<object class="GtkEntry" id="Find">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="placeholder_text" translatable="yes">gtkFindPlaceholder</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="FindBack">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">gtkFindBack</property>
<property name="label" translatable="yes">gtkFindBack</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-up</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="FindForward">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">gtkFindForward</property>
<property name="label" translatable="yes">gtkFindForward</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-down</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="FindHightlightAll">
<property name="label" translatable="yes">gtkFindHighlightAll</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="FindMatchCase">
<property name="label" translatable="yes">gtkFindMatchCase</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="FindClose">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">gtkFindClose</property>
<property name="label" translatable="yes">gtkFindClose</property>
<property name="stock_id">gtk-close</property>
</object>
<packing>
@ -45,115 +139,6 @@
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="searchLabelItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="searchlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xpad">4</property>
<property name="label" translatable="yes">Match</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="toolSearch">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="searchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="searchBackButton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Search _Back</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-back</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="searchForwardButton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Search _Forward</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-forward</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="checkAllSearchItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="checkAllSearch">
<property name="label" translatable="yes">All</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="caseSensItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="caseSensButton">
<property name="label" translatable="yes">Case</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@ -1,6 +1,5 @@
/*
* Copyright 2006 Rob Kendrick <rjek@rjek.com>
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
* Copyright 2019 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -18,26 +17,25 @@
*/
#include <gtk/gtk.h>
#include <stdbool.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "utils/nsoption.h"
#include "netsurf/browser_window.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/toolbar_items.h"
#include "gtk/toolbar.h"
#include "gtk/menu.h"
#include "gtk/local_history.h"
#include "gtk/download.h"
#include "gtk/gui.h"
#include "gtk/download.h"
#include "gtk/window.h"
#include "gtk/completion.h"
#include "gtk/warn.h"
#include "gtk/tabs.h"
#include "gtk/resources.h"
#include "gtk/scaffolding.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
* Copyright 2019 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -19,30 +19,24 @@
/**
* \file
* Free text search (front component)
* find in page gtk frontend implementation
*
* \todo this whole thing should be named find rather than search as
* that generally means web search and is confusing.
*/
#include <stdint.h>
#include <ctype.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <stdbool.h>
#include <gtk/gtk.h>
#include "utils/config.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "utils/nsoption.h"
#include "netsurf/search.h"
#include "netsurf/browser_window.h"
#include "desktop/search.h"
#include "desktop/searchweb.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/search.h"
#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/search.h"
/**
* activate search forwards button in gui.
@ -161,12 +155,9 @@ static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
search = (struct gtk_search *)data;
nsgtk_search_set_forward_state(true, search->gw);
nsgtk_search_set_back_state(true, search->gw);
bw = nsgtk_get_browser_window(search->gw);
flags = SEARCH_FLAG_FORWARDS;
flags = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
flags |= SEARCH_FLAG_CASE_SENSITIVE;
@ -241,14 +232,15 @@ nserror nsgtk_search_toggle_visibility(struct gtk_search *search)
{
gboolean vis;
browser_window_search_clear(nsgtk_get_browser_window(search->gw));
g_object_get(G_OBJECT(search->bar), "visible", &vis, NULL);
if (vis) {
browser_window_search_clear(nsgtk_get_browser_window(search->gw));
gtk_widget_hide(GTK_WIDGET(search->bar));
} else {
gtk_widget_show(GTK_WIDGET(search->bar));
gtk_widget_grab_focus(GTK_WIDGET(search->entry));
nsgtk_search_entry_changed(GTK_WIDGET(search->entry), search);
}
return NSERROR_OK;
@ -306,20 +298,18 @@ nsgtk_search_create(GtkBuilder *builder,
search->gw = gw;
search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder,
"searchbar"));
search->entry = GTK_ENTRY(gtk_builder_get_object(builder,
"searchEntry"));
search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder, "findbar"));
search->entry = GTK_ENTRY(gtk_builder_get_object(builder, "Find"));
search->back = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
"searchBackButton"));
"FindBack"));
search->forward = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
"searchForwardButton"));
"FindForward"));
search->close = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
"closeSearchButton"));
"FindClose"));
search->checkAll = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
"checkAllSearch"));
"FindHightlightAll"));
search->caseSens = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
"caseSensButton"));
"FindMatchCase"));
g_signal_connect(search->forward,
"clicked",
@ -356,8 +346,14 @@ nsgtk_search_create(GtkBuilder *builder,
G_CALLBACK(nsgtk_search_entry_changed),
search);
g_signal_connect(search->checkAll,
"toggled",
G_CALLBACK(nsgtk_search_entry_changed),
search);
nsgtk_search_restyle(search);
*search_out = search;
return NSERROR_OK;

View File

@ -889,8 +889,8 @@ gui_window_create(struct browser_window *bw,
}
nsgtk_tab_add(g, g->container, tempback, messages_get("NewTab"), g->icon);
/* \todo move search bar properly */
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(tab_builder, "searchbar")));
/* initialy should not be visible */
nsgtk_search_toggle_visibility(g->search);
/* safe to drop the reference to the tab_builder as the container is
* referenced by the notebook now.

View File

@ -3301,6 +3301,15 @@ nl.gtk.gtkThemeAdd:Thema is succesvol toegevoegd
en.gtk.gtkCustomizeToolbarTitle:Customise Toolbar
en.gtk.gtkCustomizeToolbarInstructions:Drag toolbar items into and out of the toolbar.
# GTK find in page
en.gtk.gtkFindPlaceholder:Find in page
en.gtk.gtkFindBack:Find Previous Occurrence
en.gtk.gtkFindForward:Find _Next Occurrence
en.gtk.gtkFindHighlightAll:Highlight All
en.gtk.gtkFindMatchCase:Match Case
en.gtk.gtkFindClose:Close Find Bar
# GTK preferences dialog
en.gtk.preferencesTitle:Netsurf Preferences