[gtranslator: 1/2] Add public function declaration for new re-written function from the gtr-search-bar.c in src/gtr-sea
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator: 1/2] Add public function declaration for new re-written function from the gtr-search-bar.c in src/gtr-sea
- Date: Thu, 12 Mar 2020 10:07:31 +0000 (UTC)
commit d4cfb9c8b150c8d12b436c8703b08dfd59d11b42
Author: Priyanka Saggu <priyankasaggu11929 gmail com>
Date: Thu Mar 12 10:07:08 2020 +0000
Add public function declaration for new re-written function from the gtr-search-bar.c in
src/gtr-search-bar.h
build-aux/flatpak/org.gnome.Gtranslator.json | 18 +
meson.build | 1 +
src/gtr-actions-search.c | 349 +++--------
src/gtr-actions.h | 69 ++-
src/gtr-application.c | 68 ++-
src/gtr-notebook.c | 12 +
src/gtr-notebook.h | 2 +
src/gtr-notebook.ui | 38 ++
src/gtr-search-bar.c | 833 +++++++++++++++++++++++++++
src/gtr-search-bar.h | 98 ++++
src/gtr-search-bar.ui | 286 +++++++++
src/gtr-search-dialog.c | 775 -------------------------
src/gtr-search-dialog.h | 150 -----
src/gtr-search-dialog.ui | 325 -----------
src/gtr-tab.c | 97 +++-
src/gtr-tab.h | 6 +
src/gtr-tab.ui | 584 ++++++++++---------
src/gtr-window.c | 25 +
src/gtr-window.h | 3 +
src/gtranslator.gresource.xml | 2 +-
src/help-overlay.ui | 21 +
src/meson.build | 7 +-
src/styles.css | 51 ++
23 files changed, 1999 insertions(+), 1821 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Gtranslator.json b/build-aux/flatpak/org.gnome.Gtranslator.json
index 2cdb069c..d3b91442 100644
--- a/build-aux/flatpak/org.gnome.Gtranslator.json
+++ b/build-aux/flatpak/org.gnome.Gtranslator.json
@@ -31,6 +31,24 @@
"*.a"
],
"modules" : [
+ {
+ "name" : "libdazzle",
+ "config-opts" : [
+ "--libdir=/app/lib",
+ "--buildtype=debugoptimized"
+ ],
+ "buildsystem" : "meson",
+ "builddir" : true,
+ "cleanup" : [
+ "/bin"
+ ],
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://gitlab.gnome.org/GNOME/libdazzle.git"
+ }
+ ]
+ },
{
"name" : "gspell",
"config-opts" : [
diff --git a/meson.build b/meson.build
index d98ba735..b71c1528 100644
--- a/meson.build
+++ b/meson.build
@@ -107,6 +107,7 @@ gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.20')
gtr_deps = [
glib_dep,
gtk_dep,
+ dependency('libdazzle-1.0', version: '>= 3.33.90'),
dependency('libgda-5.0'),
dependency('gio-2.0', version: '>= 2.36.0'),
dependency('gsettings-desktop-schemas'),
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index 446aa07f..16c84efe 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -38,99 +38,84 @@
#include "gtr-utils.h"
#include "gtr-view.h"
#include "gtr-window.h"
-#include "gtr-search-dialog.h"
+#include "gtr-search-bar.h"
-#define GTR_SEARCH_DIALOG_KEY "gtr-search-dialog-key"
#define GTR_LAST_SEARCH_DATA_KEY "gtr-last-search-data-key"
/* data stored in the document
* to persist the last searched
* words and options
*/
-typedef struct _LastSearchData LastSearchData;
-struct _LastSearchData
-{
- gchar *find_text;
- gchar *replace_text;
-
- gint original_text:1;
- gint translated_text:1;
- gint fuzzy_messages:1;
- gint match_case:1;
- gint entire_word:1;
- gint backwards:1;
- gint wrap_around:1;
-};
static void
-last_search_data_free (LastSearchData * data)
+last_search_data_free (LastSearchData *data)
{
g_free (data->find_text);
g_free (data->replace_text);
g_free (data);
}
-static void
-last_search_data_set (LastSearchData * data, GtrSearchDialog * dialog)
+void
+last_search_data_set (LastSearchData * data, GtrSearchBar * dialog)
{
const gchar *str;
- str = gtr_search_dialog_get_search_text (dialog);
+ str = gtr_search_bar_get_search_text (dialog);
if (str != NULL && *str != '\0')
{
g_free (data->find_text);
data->find_text = gtr_utils_unescape_search_text (str);
}
- str = gtr_search_dialog_get_replace_text (dialog);
+ str = gtr_search_bar_get_replace_text (dialog);
if (str != NULL && *str != '\0')
{
g_free (data->replace_text);
data->replace_text = gtr_utils_unescape_search_text (str);
}
- data->original_text = gtr_search_dialog_get_original_text (dialog);
- data->translated_text = gtr_search_dialog_get_translated_text (dialog);
- data->match_case = gtr_search_dialog_get_match_case (dialog);
- data->entire_word = gtr_search_dialog_get_entire_word (dialog);
- data->backwards = gtr_search_dialog_get_backwards (dialog);
- data->wrap_around = gtr_search_dialog_get_wrap_around (dialog);
+ data->original_text = gtr_search_bar_get_original_text (dialog);
+ data->translated_text = gtr_search_bar_get_translated_text (dialog);
+ data->match_case = gtr_search_bar_get_match_case (dialog);
+ data->entire_word = gtr_search_bar_get_entire_word (dialog);
+ data->backwards = gtr_search_bar_get_backwards (dialog);
+ data->wrap_around = gtr_search_bar_get_wrap_around (dialog);
}
-static void
-search_dialog_set_last_find_text (GtrSearchDialog * dialog,
+void
+search_bar_set_last_find_text (GtrSearchBar * dialog,
LastSearchData * data)
{
if (data->find_text)
- gtr_search_dialog_set_search_text (dialog, data->find_text);
+ gtr_search_bar_set_search_text (dialog, data->find_text);
}
-static void
-search_dialog_set_last_replace_text (GtrSearchDialog * dialog,
- LastSearchData * data)
+void
+search_bar_set_last_replace_text (GtrSearchBar * dialog,
+ LastSearchData * data)
{
if (data->replace_text)
- gtr_search_dialog_set_replace_text (dialog, data->replace_text);
+ gtr_search_bar_set_replace_text (dialog, data->replace_text);
}
-static void
-search_dialog_set_last_options (GtrSearchDialog * dialog,
- LastSearchData * data)
+void
+search_bar_set_last_options (GtrSearchBar * dialog,
+ LastSearchData * data)
{
- gtr_search_dialog_set_original_text (dialog, data->original_text);
- gtr_search_dialog_set_translated_text (dialog, data->translated_text);
- gtr_search_dialog_set_match_case (dialog, data->match_case);
- gtr_search_dialog_set_entire_word (dialog, data->entire_word);
- gtr_search_dialog_set_backwards (dialog, data->backwards);
- gtr_search_dialog_set_wrap_around (dialog, data->wrap_around);
+ gtr_search_bar_set_original_text (dialog, data->original_text);
+ gtr_search_bar_set_translated_text (dialog, data->translated_text);
+ gtr_search_bar_set_match_case (dialog, data->match_case);
+ gtr_search_bar_set_entire_word (dialog, data->entire_word);
+ gtr_search_bar_set_backwards (dialog, data->backwards);
+ gtr_search_bar_set_wrap_around (dialog, data->wrap_around);
}
/*
* Used to get the old search data and store the new values.
*/
static void
-restore_last_searched_data (GtrSearchDialog * dialog, GtrTab * tab)
+restore_last_searched_data (GtrSearchBar * dialog, GtrTab * tab)
{
LastSearchData *data;
@@ -152,29 +137,7 @@ restore_last_searched_data (GtrSearchDialog * dialog, GtrTab * tab)
}
}
-/* Use occurences only for Replace All */
-static void
-phrase_found (GtrSearchDialog * dialog,
- gint occurrences)
-{
- g_autofree char *message = NULL;
-
- message = g_strdup_printf (
- ngettext ("Found and replaced one occurrence",
- "Found and replaced %d occurrences",
- occurrences), occurrences);
-
- gtr_search_dialog_show_message (dialog, message, GTR_SEARCH_DIALOG_MSG_INFO);
-}
-
-static void
-phrase_not_found (GtrSearchDialog * dialog)
-{
- gtr_search_dialog_show_message (dialog, _("Phrase not found"),
- GTR_SEARCH_DIALOG_MSG_ERROR);
-}
-
-static gboolean
+gboolean
run_search (GtrView * view, gboolean follow)
{
GtkSourceBuffer *doc;
@@ -213,10 +176,11 @@ run_search (GtrView * view, gboolean follow)
return found;
}
-static gboolean
+gboolean
find_in_list (GtrWindow * window,
GList * views,
- gboolean wrap_around, gboolean search_backwards)
+ gboolean wrap_around,
+ gboolean search_backwards)
{
GtrTab *tab = gtr_window_get_active_tab (window);
GtrPo *po = gtr_tab_get_po (tab);
@@ -279,11 +243,11 @@ find_in_list (GtrWindow * window,
return FALSE;
}
-static void
-do_find (GtrSearchDialog * dialog, GtrWindow * window)
+void
+do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
{
GtrTab *tab;
- GList *views, *list;
+ GList *views, *list, *current_msg;
gchar *search_text;
const gchar *entry_text;
gboolean original_text;
@@ -291,7 +255,6 @@ do_find (GtrSearchDialog * dialog, GtrWindow * window)
gboolean match_case;
gboolean entire_word;
gboolean wrap_around;
- gboolean search_backwards;
guint flags = 0;
guint old_flags = 0;
gboolean found;
@@ -299,17 +262,16 @@ do_find (GtrSearchDialog * dialog, GtrWindow * window)
/* Used to store search options */
tab = gtr_window_get_active_tab (window);
- entry_text = gtr_search_dialog_get_search_text (dialog);
+ entry_text = gtr_search_bar_get_search_text (dialog);
/* Views where find */
- original_text = gtr_search_dialog_get_original_text (dialog);
- translated_text = gtr_search_dialog_get_translated_text (dialog);
+ original_text = gtr_search_bar_get_original_text (dialog);
+ translated_text = gtr_search_bar_get_translated_text (dialog);
/* Flags */
- match_case = gtr_search_dialog_get_match_case (dialog);
- entire_word = gtr_search_dialog_get_entire_word (dialog);
- search_backwards = gtr_search_dialog_get_backwards (dialog);
- wrap_around = gtr_search_dialog_get_wrap_around (dialog);
+ match_case = gtr_search_bar_get_match_case (dialog);
+ entire_word = gtr_search_bar_get_entire_word (dialog);
+ wrap_around = gtr_search_bar_get_wrap_around (dialog);
if (!original_text && !translated_text)
return;
@@ -339,18 +301,12 @@ do_find (GtrSearchDialog * dialog, GtrWindow * window)
list = list->next;
}
+ current_msg = gtr_po_get_current_message (gtr_tab_get_po (tab));
found = find_in_list (window, views, wrap_around, search_backwards);
-
- if (found)
- phrase_found (dialog, 0);
- else
- phrase_not_found (dialog);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- found);
-
restore_last_searched_data (dialog, tab);
+
+ if (!found && current_msg)
+ gtr_tab_message_go_to (tab, current_msg->data, FALSE, GTR_TAB_MOVE_NONE);
}
static void
@@ -369,8 +325,8 @@ replace_selected_text (GtkTextBuffer * buffer, const gchar * replace)
gtk_text_buffer_end_user_action (buffer);
}
-static void
-do_replace (GtrSearchDialog * dialog, GtrWindow * window)
+void
+do_replace (GtrSearchBar * dialog, GtrWindow * window)
{
GtrView *view;
const gchar *search_entry_text;
@@ -388,19 +344,19 @@ do_replace (GtrSearchDialog * dialog, GtrWindow * window)
tab = gtr_window_get_active_tab (window);
gtr_tab_find_replace (tab, TRUE);
- search_entry_text = gtr_search_dialog_get_search_text (dialog);
+ search_entry_text = gtr_search_bar_get_search_text (dialog);
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete */
- replace_entry_text = gtr_search_dialog_get_replace_text (dialog);
+ replace_entry_text = gtr_search_bar_get_replace_text (dialog);
g_return_if_fail ((replace_entry_text) != NULL);
unescaped_search_text = gtr_utils_unescape_search_text (search_entry_text);
gtr_view_get_selected_text (view, &selected_text, NULL);
- match_case = gtr_search_dialog_get_match_case (dialog);
+ match_case = gtr_search_bar_get_match_case (dialog);
if ((selected_text == NULL) ||
(match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
@@ -410,7 +366,7 @@ do_replace (GtrSearchDialog * dialog, GtrWindow * window)
strlen (unescaped_search_text))
!= 0))
{
- do_find (dialog, window);
+ do_find (dialog, window, FALSE);
g_free (unescaped_search_text);
g_free (selected_text);
gtr_tab_find_replace (tab, FALSE);
@@ -427,12 +383,12 @@ do_replace (GtrSearchDialog * dialog, GtrWindow * window)
g_free (selected_text);
g_free (unescaped_replace_text);
- do_find (dialog, window);
+ do_find (dialog, window, FALSE);
gtr_tab_find_replace (tab, FALSE);
}
-static void
-do_replace_all (GtrSearchDialog * dialog, GtrWindow * window)
+void
+do_replace_all (GtrSearchBar *searchbar, GtrWindow * window)
{
GtrTab *tab;
GList *views, *l;
@@ -458,16 +414,16 @@ do_replace_all (GtrSearchDialog * dialog, GtrWindow * window)
l = views;
aux = current_msg;
- search_entry_text = gtr_search_dialog_get_search_text (dialog);
+ search_entry_text = gtr_search_bar_get_search_text (searchbar);
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete all occurrencies */
- replace_entry_text = gtr_search_dialog_get_replace_text (dialog);
+ replace_entry_text = gtr_search_bar_get_replace_text (searchbar);
g_return_if_fail ((replace_entry_text) != NULL);
- match_case = gtr_search_dialog_get_match_case (dialog);
- entire_word = gtr_search_dialog_get_entire_word (dialog);
+ match_case = gtr_search_bar_get_match_case (searchbar);
+ entire_word = gtr_search_bar_get_entire_word (searchbar);
GTR_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
GTR_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
@@ -495,196 +451,27 @@ do_replace_all (GtrSearchDialog * dialog, GtrWindow * window)
gtr_tab_message_go_to (tab, aux->data, FALSE, GTR_TAB_MOVE_NONE);
- if (count > 0)
- {
- phrase_found (dialog, count);
- }
- else
- {
- phrase_not_found (dialog);
- }
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- FALSE);
-
- restore_last_searched_data (dialog, tab);
+ restore_last_searched_data (searchbar, tab);
gtr_tab_find_replace (tab, FALSE);
}
-static void
-search_dialog_response_cb (GtrSearchDialog * dialog,
- gint response_id, GtrWindow * window)
+void
+search_bar_response_cb (GtrSearchBar *dialog,
+ gint response_id,
+ GtrWindow *window)
{
switch (response_id)
{
- case GTR_SEARCH_DIALOG_FIND_RESPONSE:
- do_find (dialog, window);
+ case GTR_SEARCH_BAR_FIND_RESPONSE:
+ do_find (dialog, window, FALSE);
break;
- case GTR_SEARCH_DIALOG_REPLACE_RESPONSE:
+ case GTR_SEARCH_BAR_REPLACE_RESPONSE:
do_replace (dialog, window);
break;
- case GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
+ case GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE:
do_replace_all (dialog, window);
break;
default:
gtk_widget_destroy (GTK_WIDGET (dialog));
}
}
-
-static void
-search_dialog_destroyed (GtrWindow * window, GtrSearchDialog * dialog)
-{
- g_object_set_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY, NULL);
-}
-
-void
-_gtr_actions_search_find (GtkAction * action, GtrWindow * window)
-{
- gpointer data;
- GtkWidget *search_dialog;
- GtrTab *tab;
- GtrView *view;
- gboolean selection_exists;
- gchar *find_text = NULL;
- gint sel_len;
- LastSearchData *last_search_data;
-
- data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
-
- if (data != NULL)
- {
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
-
- /* note that we rise a search&replace dialog if
- * it is already open
- */
-
- gtr_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
- GDK_CURRENT_TIME);
-
- return;
- }
-
- search_dialog = gtr_search_dialog_new (GTK_WINDOW (window), FALSE);
-
- g_object_set_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY, search_dialog);
-
- g_object_weak_ref (G_OBJECT (search_dialog),
- (GWeakNotify) search_dialog_destroyed, window);
-
- tab = gtr_window_get_active_tab (window);
- view = gtr_window_get_active_view (window);
- g_return_if_fail (tab != NULL);
- g_return_if_fail (view != NULL);
-
- last_search_data = g_object_get_data (G_OBJECT (tab),
- GTR_LAST_SEARCH_DATA_KEY);
-
- selection_exists = gtr_view_get_selected_text (view, &find_text, &sel_len);
-
- if (selection_exists && find_text != NULL && sel_len < 80)
- {
- gtr_search_dialog_set_search_text (GTR_SEARCH_DIALOG
- (search_dialog), find_text);
- g_free (find_text);
- }
- else
- {
- g_free (find_text);
-
- if (last_search_data != NULL)
- search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
- }
-
- if (last_search_data != NULL)
- search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
-
- if (last_search_data != NULL)
- search_dialog_set_last_options (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
-
- g_signal_connect (search_dialog,
- "response",
- G_CALLBACK (search_dialog_response_cb), window);
-
- gtk_widget_show (search_dialog);
-}
-
-void
-_gtr_actions_search_replace (GtkAction * action, GtrWindow * window)
-{
- gpointer data;
- GtkWidget *replace_dialog;
- GtrTab *tab;
- GtrView *view;
- gboolean selection_exists;
- gchar *find_text = NULL;
- gint sel_len;
- LastSearchData *last_search_data;
-
- data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
-
- if (data != NULL)
- {
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
-
- /* turn the dialog into a replace dialog if needed */
- if (!gtr_search_dialog_get_show_replace (GTR_SEARCH_DIALOG (data)))
- gtr_search_dialog_set_show_replace (GTR_SEARCH_DIALOG (data), TRUE);
-
- gtr_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
- GDK_CURRENT_TIME);
-
- return;
- }
-
- replace_dialog = gtr_search_dialog_new (GTK_WINDOW (window), TRUE);
-
- g_object_set_data (G_OBJECT (window),
- GTR_SEARCH_DIALOG_KEY, replace_dialog);
-
- g_object_weak_ref (G_OBJECT (replace_dialog),
- (GWeakNotify) search_dialog_destroyed, window);
-
- tab = gtr_window_get_active_tab (window);
- view = gtr_window_get_active_view (window);
- g_return_if_fail (tab != NULL);
-
- last_search_data = g_object_get_data (G_OBJECT (tab),
- GTR_LAST_SEARCH_DATA_KEY);
-
-
- selection_exists = gtr_view_get_selected_text (view, &find_text, &sel_len);
-
- if (selection_exists && find_text != NULL && sel_len < 80)
- {
- gtr_search_dialog_set_search_text (GTR_SEARCH_DIALOG
- (replace_dialog), find_text);
- g_free (find_text);
- }
- else
- {
- g_free (find_text);
-
- if (last_search_data != NULL)
- search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
- }
-
- if (last_search_data != NULL)
- search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
-
- if (last_search_data != NULL)
- search_dialog_set_last_options (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
-
- g_signal_connect (replace_dialog,
- "response",
- G_CALLBACK (search_dialog_response_cb), window);
-
- gtk_widget_show (replace_dialog);
-}
diff --git a/src/gtr-actions.h b/src/gtr-actions.h
index 7a635efc..bd4de361 100644
--- a/src/gtr-actions.h
+++ b/src/gtr-actions.h
@@ -23,9 +23,27 @@
#include <gio/gio.h>
#include "gtr-window.h"
+#include "gtr-search-bar.h"
G_BEGIN_DECLS
/*File*/
+
+typedef struct _LastSearchData LastSearchData;
+struct _LastSearchData
+{
+ gchar *find_text;
+ gchar *replace_text;
+
+ gint original_text:1;
+ gint translated_text:1;
+ gint fuzzy_messages:1;
+ gint match_case:1;
+ gint entire_word:1;
+ gint backwards:1;
+ gint wrap_around:1;
+};
+
+
void gtr_open_file_dialog (GtkAction * action, GtrWindow * window);
void gtr_save_current_file_dialog (GtkWidget * widget, GtrWindow * window);
@@ -94,12 +112,57 @@ void gtr_message_go_to_next_fuzzy_or_untranslated
void gtr_message_go_to_prev_fuzzy_or_untranslated
(GtkAction * action, GtrWindow * window);
-void gtr_message_jump (GtkAction * action, GtrWindow * window);
+void gtr_message_jump (GtkAction * action,
+ GtrWindow * window);
/*Search*/
-void _gtr_actions_search_find (GtkAction * action, GtrWindow * window);
+void _gtr_actions_search_find (GtkAction * action,
+ GtrWindow * window);
+
+void _gtr_actions_search_replace (GtkAction * action,
+ GtrWindow * window);
+
+void gtr_page_stop_search (GtrTab * tab,
+ GtrSearchBar * search_bar);
+
+void gtr_page_notify_child_revealed (GtrTab * tab,
+ GParamSpec * pspec,
+ GtkRevealer * revealer);
+
+void last_search_data_set (LastSearchData * data,
+ GtrSearchBar * dialog);
+
+void search_bar_set_last_find_text (GtrSearchBar * dialog,
+ LastSearchData * data);
+
+void search_bar_set_last_replace_text (GtrSearchBar * dialog,
+ LastSearchData * data);
+
+void search_bar_set_last_options (GtrSearchBar * dialog,
+ LastSearchData * data);
+
+gboolean run_search (GtrView * view,
+ gboolean follow);
+
+gboolean find_in_list (GtrWindow * window,
+ GList * views,
+ gboolean wrap_around,
+ gboolean search_backwards);
+
+
+void do_find (GtrSearchBar * dialog,
+ GtrWindow * window,
+ gboolean search_backwards);
+
+void do_replace (GtrSearchBar * dialog,
+ GtrWindow * window);
+
+void do_replace_all (GtrSearchBar * dialog,
+ GtrWindow * window);
-void _gtr_actions_search_replace (GtkAction * action, GtrWindow * window);
+void search_bar_response_cb (GtrSearchBar * dialog,
+ gint response_id,
+ GtrWindow * window);
/*Documents*/
void gtr_actions_documents_next_document
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 4ad84cf8..da459fb6 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -34,6 +34,8 @@
#include "gtr-utils.h"
#include "gtr-window.h"
#include "gtr-preferences-dialog.h"
+#include "gtr-search-bar.h"
+#include "gtr-tab.h"
#include <glib.h>
#include <glib-object.h>
@@ -221,6 +223,17 @@ new_window_activated (GSimpleAction *action,
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
}
+static void
+find_toggle_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+ GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+
+ gtr_window_toggle_search_bar (priv->active_window);
+}
+
static void
find_activated (GSimpleAction *action,
GVariant *parameter,
@@ -229,7 +242,49 @@ find_activated (GSimpleAction *action,
GtrApplication *app = GTR_APPLICATION (user_data);
GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
- _gtr_actions_search_find (NULL, priv->active_window);
+ GtrTab *active_tab = gtr_window_get_active_tab (priv->active_window);
+ g_return_if_fail (active_tab != NULL);
+ gtr_window_show_search_bar (priv->active_window, TRUE);
+ gtr_tab_find_set_replace (active_tab, FALSE);
+}
+
+static void
+find_next_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+ GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+
+ GtrTab *active_tab = gtr_window_get_active_tab (priv->active_window);
+ g_return_if_fail (active_tab != NULL);
+ gtr_window_show_search_bar (priv->active_window, TRUE);
+ gtr_tab_find_next (active_tab);
+}
+
+static void
+find_prev_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+ GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+
+ GtrTab *active_tab = gtr_window_get_active_tab (priv->active_window);
+ g_return_if_fail (active_tab != NULL);
+ gtr_window_show_search_bar (priv->active_window, TRUE);
+ gtr_tab_find_prev (active_tab);
+}
+
+static void
+find_unactivated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtrApplication *app = GTR_APPLICATION (user_data);
+
+ GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+ gtr_window_show_search_bar (priv->active_window, FALSE);
}
static void
@@ -240,7 +295,9 @@ find_and_replace_activated (GSimpleAction *action,
GtrApplication *app = GTR_APPLICATION (user_data);
GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
- _gtr_actions_search_replace (NULL, priv->active_window);
+ GtrTab *active_tab = gtr_window_get_active_tab (priv->active_window);
+ gtr_window_show_search_bar (priv->active_window, TRUE);
+ gtr_tab_find_set_replace (active_tab, TRUE);
}
static void
@@ -567,7 +624,11 @@ static GActionEntry app_entries[] = {
{ "copy_text", copy_text_activated, NULL, NULL, NULL },
{ "find_and_replace", find_and_replace_activated, NULL, NULL, NULL },
+ { "findtoggle", find_toggle_activated, NULL, NULL, NULL },
{ "find", find_activated, NULL, NULL, NULL },
+ { "find-off", find_unactivated, NULL, NULL, NULL},
+ { "find-next", find_next_activated, NULL, NULL, NULL },
+ { "find-prev", find_prev_activated, NULL, NULL, NULL },
{ "new_window", new_window_activated, NULL, NULL, NULL },
{ "preferences", preferences_activated, NULL, NULL, NULL },
{ "edit_header", edit_header_activated, NULL, NULL, NULL },
@@ -628,7 +689,10 @@ gtr_application_startup (GApplication *application)
set_kb (application, "app.fuzzy", "<Ctrl>u");
set_kb (application, "app.find", "<Ctrl>f");
+ set_kb (application, "app.find-off", "Escape");
set_kb (application, "app.find_and_replace", "<Ctrl>h");
+ set_kb (application, "app.find-next", "<Ctrl>g");
+ set_kb (application, "app.find-prev", "<Ctrl><Shift>g");
set_kb (application, "app.copy_text", "<Ctrl>space");
diff --git a/src/gtr-notebook.c b/src/gtr-notebook.c
index f84d9640..5da45877 100644
--- a/src/gtr-notebook.c
+++ b/src/gtr-notebook.c
@@ -36,6 +36,7 @@ typedef struct
GtkWidget *save;
GtkWidget *sort_id;
GtkWidget *order_menu_popover;
+ GtkWidget *search;
GtkWidget *undo;
GtkWidget *redo;
@@ -143,6 +144,7 @@ gtr_notebook_class_init (GtrNotebookClass * klass)
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, titlebar);
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, sort_id);
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, order_menu_popover);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, search);
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, undo);
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, redo);
gtk_widget_class_bind_template_child_private (widget_class, GtrNotebook, save);
@@ -300,3 +302,13 @@ gtr_notebook_hide_sort_menu (GtrNotebook *notebook)
if (priv->sort_id)
gtk_popover_popdown (GTK_POPOVER (priv->order_menu_popover));
}
+
+void
+gtr_notebook_enable_find_button (GtrNotebook *notebook,
+ gboolean enable)
+{
+ GtrNotebookPrivate *priv = gtr_notebook_get_instance_private (notebook);
+
+ if (priv->search)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search), enable);
+}
diff --git a/src/gtr-notebook.h b/src/gtr-notebook.h
index 2835eb83..af579ca8 100644
--- a/src/gtr-notebook.h
+++ b/src/gtr-notebook.h
@@ -83,5 +83,7 @@ void gtr_notebook_reset_sort (GtrNotebook *notebook);
void gtr_notebook_hide_sort_menu (GtrNotebook *notebook);
+void gtr_notebook_enable_find_button (GtrNotebook *notebook, gboolean enable);
+
G_END_DECLS
#endif /* __NOTEBOOK_H__ */
diff --git a/src/gtr-notebook.ui b/src/gtr-notebook.ui
index 3a2b5de3..0b8a8732 100644
--- a/src/gtr-notebook.ui
+++ b/src/gtr-notebook.ui
@@ -577,6 +577,43 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkToggleButton" id="search">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Find (<Ctrl><f>)</property>
+ <property name="action_name">app.findtoggle</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-find-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
+ <property name="non_homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
@@ -643,3 +680,4 @@
+
diff --git a/src/gtr-search-bar.c b/src/gtr-search-bar.c
new file mode 100644
index 00000000..aa6a0a42
--- /dev/null
+++ b/src/gtr-search-bar.c
@@ -0,0 +1,833 @@
+/*
+ * Copyright (C) 2020 Priyanka Saggu <priyankasaggu11929 gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define G_LOG_DOMAIN "gtr-search-bar"
+
+#include "config.h"
+
+#include <dazzle.h>
+#include <glib/gi18n.h>
+
+#include "gtr-search-bar.h"
+#include "gtr-actions.h"
+#include "gtr-tab.h"
+#include "gtr-window.h"
+#include "gtr-history-entry.h"
+#include "gtr-utils.h"
+
+struct _GtrSearchBar
+{
+ DzlBin parent_instance;
+
+ DzlSignalGroup *search_signals;
+ DzlBindingGroup *search_bindings;
+ GtkSearchEntry *search;
+
+ GObject *search_entry_tag;
+
+ GtkCheckButton *case_sensitive;
+ GtkButton *replace_all_button;
+ GtkButton *replace_button;
+ GtkButton *previous_button;
+ GtkButton *next_button;
+ GtrHistoryEntry *replace_entry;
+ GtkEntry *search_entry;
+ GtkGrid *search_options;
+ GtkCheckButton *whole_word;
+ GtkCheckButton *wrap_around_button;
+ GtkCheckButton *original_text_checkbutton;
+ GtkCheckButton *translated_text_checkbutton;
+ GtkLabel *search_text_error;
+ GtkWidget *search_text_entry;
+ GtkWidget *replace_text_entry;
+
+ GtrWindow *active_window;
+
+ guint match_source;
+
+ guint show_options : 1;
+ guint replace_mode : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_REPLACE_MODE,
+ PROP_SHOW_OPTIONS,
+ N_PROPS
+};
+
+enum {
+ STOP_SEARCH,
+ N_SIGNALS
+};
+
+G_DEFINE_TYPE (GtrSearchBar, gtr_search_bar, DZL_TYPE_BIN)
+
+static GParamSpec *properties [N_PROPS];
+static guint signals [N_SIGNALS];
+
+/*----------------------------------------NEW RE-WRITTEN METHODS--------------------------------------*/
+
+void
+gtr_search_bar_set_search_text (GtrSearchBar *dialog,
+ const gchar *text)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+ g_return_if_fail (text != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), text);
+}
+
+/*
+ * The text must be unescaped before searching.
+ */
+const gchar*
+gtr_search_bar_get_search_text (GtrSearchBar *dialog)
+{
+ //g_assert (GTR_IS_SEARCH_BAR (dialog));
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (dialog->search_entry));
+}
+
+void
+gtr_search_bar_set_replace_text (GtrSearchBar *dialog,
+ const gchar *text)
+{
+ //g_assert (GTR_IS_SEARCH_BAR (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+ g_return_if_fail (text != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->replace_entry), text);
+}
+
+const gchar *
+gtr_search_bar_get_replace_text (GtrSearchBar *dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry));
+}
+
+void
+gtr_search_bar_set_original_text (GtrSearchBar *dialog,
+ gboolean match_case)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->original_text_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_bar_get_original_text (GtrSearchBar *dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->original_text_checkbutton));
+}
+
+void
+gtr_search_bar_set_translated_text (GtrSearchBar *dialog,
+ gboolean match_case)
+{
+
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->translated_text_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_bar_get_translated_text (GtrSearchBar *dialog)
+{
+
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->translated_text_checkbutton));
+}
+
+void
+gtr_search_bar_set_match_case (GtrSearchBar *dialog,
+ gboolean match_case)
+{
+
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->case_sensitive),
+ match_case);
+}
+
+gboolean
+gtr_search_bar_get_match_case (GtrSearchBar *dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->case_sensitive));
+}
+
+void
+gtr_search_bar_set_entire_word (GtrSearchBar *dialog,
+ gboolean entire_word)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->whole_word),
+ entire_word);
+}
+
+gboolean
+gtr_search_bar_get_entire_word (GtrSearchBar *dialog)
+{
+
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->whole_word));
+}
+
+void
+gtr_search_bar_set_backwards (GtrSearchBar *dialog, gboolean backwards)
+{
+
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->previous_button),
+ backwards);
+}
+
+gboolean
+gtr_search_bar_get_backwards (GtrSearchBar *dialog)
+{
+
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->previous_button));
+}
+
+void
+gtr_search_bar_set_wrap_around (GtrSearchBar *dialog,
+ gboolean wrap_around)
+{
+
+ g_return_if_fail (GTR_IS_SEARCH_BAR (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->wrap_around_button),
+ wrap_around);
+}
+
+gboolean
+gtr_search_bar_get_wrap_around (GtrSearchBar *dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->wrap_around_button));
+}
+
+void
+gtr_hide_bar (GtrSearchBar *self)
+{
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+
+ GtrTab *active_tab = gtr_window_get_active_tab (GTR_WINDOW (window));
+
+ return gtr_tab_show_hide_search_bar (active_tab, FALSE);
+}
+
+void
+gtr_search_bar_find_next (GtrSearchBar *self)
+{
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ do_find (self, GTR_WINDOW (window), FALSE);
+}
+
+void
+gtr_search_bar_find_prev (GtrSearchBar *self)
+{
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ do_find (self, GTR_WINDOW (window), TRUE);
+}
+
+void
+gtr_do_replace (GtrSearchBar *self)
+{
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ do_replace (self, GTR_WINDOW (window));
+}
+
+void
+gtr_do_replace_all (GtrSearchBar *self)
+{
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ do_replace_all (self, GTR_WINDOW (window));
+}
+
+static void
+insert_text_handler (GtkEditable * editable,
+ const gchar * text,
+ gint length, gint * position, gpointer data)
+{
+ static gboolean insert_text = FALSE;
+ gchar *escaped_text;
+ gint new_len;
+
+ /* To avoid recursive behavior */
+ if (insert_text)
+ return;
+
+ escaped_text = gtr_utils_escape_search_text (text);
+
+ new_len = strlen (escaped_text);
+
+ if (new_len == length)
+ {
+ g_free (escaped_text);
+ return;
+ }
+
+ insert_text = TRUE;
+
+ g_signal_stop_emission_by_name (editable, "insert_text");
+
+ gtk_editable_insert_text (editable, escaped_text, new_len, position);
+
+ insert_text = FALSE;
+
+ g_free (escaped_text);
+}
+
+/*
+ * Functions to make sure either translated or original checkbutton
+ * is selected at any time. Anything else does not make any sense.
+ */
+static void
+translated_checkbutton_toggled (GtkToggleButton * button,
+ GtrSearchBar * dialog)
+{
+ gboolean original_text;
+ gboolean translated_text;
+
+ original_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->original_text_checkbutton));
+ translated_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (
+ dialog->translated_text_checkbutton));
+
+ if (!original_text && !translated_text)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->original_text_checkbutton),
+ TRUE);
+ }
+}
+
+static void
+original_checkbutton_toggled (GtkToggleButton * button,
+ GtrSearchBar * dialog)
+{
+ gboolean original_text;
+ gboolean translated_text;
+
+ original_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->original_text_checkbutton));
+ translated_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (
+ dialog->translated_text_checkbutton));
+
+ if (!original_text && !translated_text)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->translated_text_checkbutton),
+ TRUE);
+ }
+}
+
+/*-----------------------------END OF NEW RE_WRITTEN METHODS-----------------*/
+
+gboolean
+gtr_search_bar_get_replace_mode (GtrSearchBar *self)
+{
+ g_return_val_if_fail (GTK_IS_SEARCH_BAR (self), FALSE);
+
+ return self->replace_mode;
+}
+
+void
+gtr_search_bar_set_replace_mode (GtrSearchBar *self,
+ gboolean replace_mode)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (self));
+
+ replace_mode = !!replace_mode;
+
+ if (replace_mode != self->replace_mode)
+ {
+ self->replace_mode = replace_mode;
+ gtk_widget_set_visible (GTK_WIDGET (self->replace_entry), replace_mode);
+ gtk_widget_set_visible (GTK_WIDGET (self->replace_button), replace_mode);
+ gtk_widget_set_visible (GTK_WIDGET (self->replace_all_button), replace_mode);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_REPLACE_MODE]);
+ }
+}
+
+static gboolean
+maybe_escape_regex (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ GtrSearchBar *self = user_data;
+ const gchar *entry_text;
+
+ g_assert (GTR_IS_SEARCH_BAR (self));
+ g_assert (from_value != NULL);
+ g_assert (to_value != NULL);
+
+ entry_text = g_value_get_string (from_value);
+
+ if (entry_text == NULL)
+ {
+ g_value_set_static_string (to_value, "");
+ }
+ else
+ {
+ g_autofree gchar *unescaped = NULL;
+
+ if (self->search != NULL)
+ entry_text = unescaped = gtk_source_utils_unescape_search_text (entry_text);
+
+ g_value_set_string (to_value, entry_text);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+pacify_null_text (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ g_assert (from_value != NULL);
+ g_assert (to_value != NULL);
+ g_assert (G_VALUE_HOLDS_STRING (from_value));
+ g_assert (G_VALUE_HOLDS_STRING (to_value));
+
+ if (g_value_get_string (from_value) == NULL)
+ g_value_set_static_string (to_value, "");
+ else
+ g_value_copy (from_value, to_value);
+
+ return TRUE;
+}
+
+static void
+gtr_search_bar_grab_focus (GtkWidget *widget)
+{
+ GtrSearchBar *self = (GtrSearchBar *)widget;
+
+ g_assert (GTR_IS_SEARCH_BAR (self));
+
+ gtk_widget_grab_focus (GTK_WIDGET (self->search_entry));
+}
+
+static void
+search_entry_populate_popup (GtrSearchBar *self,
+ GtkWidget *widget,
+ GtkEntry *entry)
+{
+ g_assert (GTR_IS_SEARCH_BAR (self));
+ g_assert (GTK_IS_MENU (widget));
+ g_assert (GTK_IS_ENTRY (entry));
+
+ if (GTK_IS_MENU (widget))
+ {
+ g_autoptr(DzlPropertiesGroup) group = NULL;
+
+ GtkWidget *item;
+ GtkWidget *sep;
+ guint pos = 0;
+
+ item = gtk_check_menu_item_new_with_label (_("Case sensitive"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "search-settings.case-sensitive");
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), item, pos++);
+ gtk_widget_show (item);
+
+ item = gtk_check_menu_item_new_with_label (_("Match whole word only"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "search-settings.at-word-boundaries");
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), item, pos++);
+ gtk_widget_show (item);
+
+ item = gtk_check_menu_item_new_with_label (_("Wrap around"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "search-settings.wrap-around");
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), item, pos++);
+ gtk_widget_show (item);
+
+ item = gtk_check_menu_item_new_with_label (_("Original text"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "search-settings.at-original-text");
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), item, pos++);
+ gtk_widget_show (item);
+
+ item = gtk_check_menu_item_new_with_label (_("Translated text"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "search-settings.at-translated-text");
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), item, pos++);
+ gtk_widget_show (item);
+
+ sep = gtk_separator_menu_item_new ();
+ gtk_menu_shell_insert (GTK_MENU_SHELL (widget), sep, pos++);
+ gtk_widget_show (sep);
+
+ if (self->search != NULL)
+ {
+ group = dzl_properties_group_new (G_OBJECT (self->search));
+ dzl_properties_group_add_all_properties (group);
+ }
+
+ gtk_widget_insert_action_group (widget, "search-settings", G_ACTION_GROUP (group));
+ }
+}
+
+static void
+gtr_search_bar_real_stop_search (GtrSearchBar *self)
+{
+ g_assert (GTR_IS_SEARCH_BAR (self));
+}
+
+static void
+search_entry_stop_search (GtrSearchBar *self,
+ GtkSearchEntry *entry)
+{
+ g_assert (GTR_IS_SEARCH_BAR (self));
+ g_assert (GTK_IS_SEARCH_ENTRY (entry));
+
+ g_signal_emit (self, signals [STOP_SEARCH], 0);
+}
+
+static void
+search_entry_changed (GtrSearchBar *dialog,
+ GtkEntry *entry)
+{
+ const gchar *search_string;
+
+ search_string = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_return_if_fail (search_string != NULL);
+}
+
+static void
+gtr_search_bar_destroy (GtkWidget *widget)
+{
+ GtrSearchBar *self = (GtrSearchBar *)widget;
+
+ dzl_clear_source (&self->match_source);
+
+ g_clear_object (&self->search_signals);
+ g_clear_object (&self->search_bindings);
+ g_clear_object (&self->search);
+ g_clear_object (&self->search_entry_tag);
+
+ GTK_WIDGET_CLASS (gtr_search_bar_parent_class)->destroy (widget);
+}
+
+gboolean
+gtr_search_bar_get_show_options (GtrSearchBar *self)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (self), FALSE);
+
+ return self->show_options;
+}
+
+void
+gtr_search_bar_set_show_options (GtrSearchBar *self,
+ gboolean show_options)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (self));
+
+ show_options = !!show_options;
+
+ if (self->show_options != show_options)
+ {
+ self->show_options = show_options;
+ gtk_widget_set_visible (GTK_WIDGET (self->search_options), show_options);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SHOW_OPTIONS]);
+ }
+}
+
+static void
+gtr_search_bar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtrSearchBar *self = GTR_SEARCH_BAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_REPLACE_MODE:
+ g_value_set_boolean (value, gtr_search_bar_get_replace_mode (self));
+ break;
+
+ case PROP_SHOW_OPTIONS:
+ g_value_set_boolean (value, gtr_search_bar_get_show_options (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gtr_search_bar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtrSearchBar *self = GTR_SEARCH_BAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_REPLACE_MODE:
+ gtr_search_bar_set_replace_mode (self, g_value_get_boolean (value));
+ break;
+
+ case PROP_SHOW_OPTIONS:
+ gtr_search_bar_set_show_options (self, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gtr_search_bar_class_init (GtrSearchBarClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = gtr_search_bar_get_property;
+ object_class->set_property = gtr_search_bar_set_property;
+
+ widget_class->destroy = gtr_search_bar_destroy;
+ widget_class->grab_focus = gtr_search_bar_grab_focus;
+
+ properties [PROP_REPLACE_MODE] =
+ g_param_spec_boolean ("replace-mode", NULL, NULL, FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ properties [PROP_SHOW_OPTIONS] =
+ g_param_spec_boolean ("show-options", NULL, NULL, FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
+ signals [STOP_SEARCH] =
+ g_signal_new_class_handler ("stop-search",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_CALLBACK (gtr_search_bar_real_stop_search),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/translator/gtr-search-bar.ui");
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, case_sensitive);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, replace_all_button);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, replace_button);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, replace_entry);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, search_entry);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, previous_button);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, next_button);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, search_options);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, search_text_error);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, whole_word);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, wrap_around_button );
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, original_text_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, translated_text_checkbutton);
+
+ gtk_widget_class_set_css_name (widget_class, "gtrsearchbar");
+}
+
+static void
+gtr_search_bar_init (GtrSearchBar *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY (self->search_entry),
+ (GtrHistoryEntryEscapeFunc) gtr_utils_escape_search_text);
+
+ self->search_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (self->search_entry));
+
+ gtk_entry_set_activates_default (GTK_ENTRY (self->search_text_entry), TRUE);
+
+ // Sets the Original-text and Translated-text checkbutton toggled by default.
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (self->original_text_checkbutton),
+ TRUE);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (self->translated_text_checkbutton),
+ TRUE);
+
+ gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY
+ (self->replace_entry),
+ (GtrHistoryEntryEscapeFunc)
+ gtr_utils_escape_search_text);
+
+ self->replace_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (self->replace_entry));
+
+ gtk_entry_set_activates_default (GTK_ENTRY (self->replace_text_entry), TRUE);
+
+
+ self->search_signals = dzl_signal_group_new (GTK_TYPE_SEARCH_ENTRY);
+
+ g_object_set (G_OBJECT (self->next_button), "can-default", TRUE, NULL);
+
+ self->search_bindings = dzl_binding_group_new ();
+
+ dzl_binding_group_bind_full (self->search_bindings, "search-text",
+ self->search_entry, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL,
+ maybe_escape_regex, pacify_null_text, self, NULL);
+
+ dzl_binding_group_bind_full (self->search_bindings, "replacement-text",
+ self->replace_entry, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL,
+ pacify_null_text, pacify_null_text, NULL, NULL);
+
+ dzl_binding_group_bind (self->search_bindings, "case-sensitive",
+ self->case_sensitive, "active",
+ G_BINDING_SYNC_CREATE |
+ G_BINDING_BIDIRECTIONAL);
+
+ dzl_binding_group_bind (self->search_bindings, "at-word-boundaries",
+ self->whole_word, "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ dzl_binding_group_bind (self->search_bindings, "wrap-around",
+ self->whole_word, "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ dzl_binding_group_bind (self->search_bindings, "at-original-text",
+ self->whole_word, "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ dzl_binding_group_bind (self->search_bindings, "at-translated-text",
+ self->whole_word, "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_signal_connect (self->search_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+
+ g_signal_connect (self->replace_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+
+
+ g_signal_connect (self->original_text_checkbutton,
+ "toggled",
+ G_CALLBACK (original_checkbutton_toggled),
+ self);
+
+ g_signal_connect (self->translated_text_checkbutton,
+ "toggled",
+ G_CALLBACK (translated_checkbutton_toggled),
+ self);
+
+ g_signal_connect_swapped (self->search_entry,
+ "activate",
+ G_CALLBACK (gtr_search_bar_find_next),
+ self);
+
+ g_signal_connect_data (self->search_entry,
+ "changed",
+ G_CALLBACK (search_entry_changed),
+ self, NULL,
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+
+ g_signal_connect_swapped (self->search_entry,
+ "populate-popup",
+ G_CALLBACK (search_entry_populate_popup),
+ self);
+
+ g_signal_connect_swapped (self->next_button,
+ "clicked",
+ G_CALLBACK (gtr_search_bar_find_next),
+ self);
+
+ g_signal_connect_swapped (self->previous_button,
+ "clicked",
+ G_CALLBACK (gtr_search_bar_find_prev),
+ self);
+
+ g_signal_connect_swapped (self->replace_button,
+ "clicked",
+ G_CALLBACK (gtr_do_replace),
+ self);
+
+ g_signal_connect_swapped (self->replace_all_button,
+ "clicked",
+ G_CALLBACK (gtr_do_replace_all),
+ self);
+
+ g_signal_connect_swapped (self->search_entry,
+ "stop-search",
+ G_CALLBACK (search_entry_stop_search),
+ self);
+}
+
+GtkSearchEntry *
+gtr_search_bar_get_search (GtrSearchBar *self)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_BAR (self), NULL);
+
+ return self->search;
+}
+
+void
+gtr_search_bar_set_search (GtrSearchBar *self,
+ GtkSearchEntry *search)
+{
+ g_return_if_fail (GTR_IS_SEARCH_BAR (self));
+
+ if (g_set_object (&self->search, search))
+ {
+ dzl_signal_group_set_target (self->search_signals, search);
+ dzl_binding_group_set_source (self->search_bindings, search);
+ }
+}
+
+
+
diff --git a/src/gtr-search-bar.h b/src/gtr-search-bar.h
new file mode 100644
index 00000000..32d3d26e
--- /dev/null
+++ b/src/gtr-search-bar.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2020 Priyanka Saggu <priyankasaggu11929 gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#pragma once
+
+#include <dazzle.h>
+#include <gtksourceview/gtksource.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_SEARCH_BAR (gtr_search_bar_get_type())
+
+G_DECLARE_FINAL_TYPE (GtrSearchBar, gtr_search_bar, GTR, SEARCH_BAR, DzlBin)
+
+enum
+{
+ GTR_SEARCH_BAR_FIND_RESPONSE = 100,
+ GTR_SEARCH_BAR_REPLACE_RESPONSE,
+ GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE
+};
+
+typedef enum
+{
+ GTR_SEARCH_BAR_MSG_INFO,
+ GTR_SEARCH_BAR_MSG_ERROR
+} GtrSearchBarMsg;
+
+
+GtkSearchEntry *gtr_search_bar_get_search (GtrSearchBar *self);
+void gtr_search_bar_set_search (GtrSearchBar *self,
+ GtkSearchEntry *search);
+gboolean gtr_search_bar_get_show_options (GtrSearchBar *self);
+void gtr_search_bar_set_show_options (GtrSearchBar *self,
+ gboolean show_options);
+gboolean gtr_search_bar_get_replace_mode (GtrSearchBar *self);
+void gtr_search_bar_set_replace_mode (GtrSearchBar *self,
+ gboolean replace_mode);
+const gchar *gtr_search_bar_get_search_text (GtrSearchBar *dialog);
+void gtr_search_bar_set_search_text (GtrSearchBar *dialog,
+ const gchar *text);
+
+
+const gchar *gtr_search_bar_get_replace_text (GtrSearchBar *dialog);
+void gtr_search_bar_set_replace_text (GtrSearchBar *dialog,
+ const gchar *text);
+
+gboolean gtr_search_bar_get_original_text (GtrSearchBar *dialog);
+void gtr_search_bar_set_original_text (GtrSearchBar *dialog,
+ gboolean match_case);
+
+gboolean gtr_search_bar_get_translated_text (GtrSearchBar *dialog);
+void gtr_search_bar_set_translated_text (GtrSearchBar *dialog,
+ gboolean match_case);
+
+gboolean gtr_search_bar_get_match_case (GtrSearchBar *dialog);
+void gtr_search_bar_set_match_case (GtrSearchBar *dialog,
+ gboolean match_case);
+
+gboolean gtr_search_bar_get_entire_word (GtrSearchBar * dialog);
+void gtr_search_bar_set_entire_word (GtrSearchBar *dialog,
+ gboolean entire_word);
+
+gboolean gtr_search_bar_get_backwards (GtrSearchBar *dialog);
+void gtr_search_bar_set_backwards (GtrSearchBar *dialog,
+ gboolean backwards);
+
+gboolean gtr_search_bar_get_wrap_around (GtrSearchBar *dialog);
+void gtr_search_bar_set_wrap_around (GtrSearchBar *dialog,
+ gboolean wrap_around);
+
+void gtr_search_bar_show_message (GtrSearchBar *dialog,
+ char *message,
+ GtrSearchBarMsg info_type);
+
+void gtr_search_bar_present_with_time (GtrSearchBar * dialog,
+ guint32 timestamp);
+
+void gtr_search_bar_find_next (GtrSearchBar *self);
+void gtr_search_bar_find_prev (GtrSearchBar *self);
+
+G_END_DECLS
+
diff --git a/src/gtr-search-bar.ui b/src/gtr-search-bar.ui
new file mode 100644
index 00000000..bc9fbf1d
--- /dev/null
+++ b/src/gtr-search-bar.ui
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtrSearchBar" parent="DzlBin">
+ <style>
+ <class name="search-frame"/>
+ </style>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">true</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">7</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="row_spacing">8</property>
+ <property name="column_spacing">8</property>
+ <child>
+ <object class="GtkEntry" id="search_entry">
+ <property name="visible">true</property>
+ <property name="can-focus">true</property>
+ <property name="hexpand">true</property>
+ <property name="primary_icon_name">edit-find-symbolic</property>
+ <property name="primary_icon_activatable">false</property>
+ <property name="primary_icon_sensitive">false</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="search_text_error">
+ <property name="visible">false</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ <attributes>
+ <attribute name="scale" value="0.8333"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="width">3</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSearchEntry" id="replace_entry">
+ <property name="visible">false</property>
+ <property name="can-focus">true</property>
+ <property name="width-chars">20</property>
+ <property name="max-width-chars">30</property>
+ <property name="primary_icon_name">edit-find-replace-symbolic</property>
+ <property name="primary_icon_activatable">false</property>
+ <property name="primary_icon_sensitive">false</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="homogeneous">true</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="previous_button">
+ <!-- <property name="action-name">editor-search.move-previous</property> -->
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="icon_name">go-up-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="next_button">
+ <!-- <property name="action-name">editor-search.move-next</property> -->
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="icon_name">go-down-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="replace_button">
+ <property name="label" translatable="yes">Replace</property>
+ <!-- <property name="action-name">editor-search.replace</property> -->
+ <property name="visible">false</property>
+ <property name="can-focus">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="replace_all_button">
+ <property name="label" translatable="yes">Replace All</property>
+ <!-- <property name="action-name">editor-search.replace-all</property> -->
+ <property name="visible">false</property>
+ <property name="can-focus">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="homogeneous">true</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="valign">center</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkToggleButton">
+ <property name="active" bind-source="GtrSearchBar" bind-property="replace-mode"
bind-flags="sync-create|bidirectional"/>
+ <property name="tooltip-text" translatable="yes">Switch between Search and
Search-and-Replace</property>
+ <property name="visible">true</property>
+ <property name="can-focus">true</property>
+ <property name="image_position">right</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="icon_name">edit-find-replace-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="show_options">
+ <property name="tooltip-text" translatable="yes">Show or hide search options such as
case sensitivity</property>
+ <property name="focus-on-click">false</property>
+ <property name="visible">true</property>
+ <property name="can-focus">true</property>
+ <property name="active" bind-source="GtrSearchBar" bind-property="show-options"
bind-flags="sync-create|bidirectional"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="icon_name">emblem-system-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="search_options">
+ <property name="visible">false</property>
+ <property name="can-focus">false</property>
+ <property name="column_spacing">8</property>
+ <child>
+ <object class="GtkCheckButton" id="case_sensitive">
+ <property name="label" translatable="yes">Case sensitive</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="xalign">0</property>
+ <property name="draw-indicator">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="whole_word">
+ <property name="label" translatable="yes">Match whole word only</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="xalign">0</property>
+ <property name="draw-indicator">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wrap_around_button">
+ <property name="label" translatable="yes">Wrap Around</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="xalign">1</property>
+ <property name="draw-indicator">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="original_text_checkbutton">
+ <property name="label" translatable="yes">Original-text</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="xalign">1</property>
+ <property name="draw-indicator">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="translated_text_checkbutton">
+ <property name="label" translatable="yes">Translated-text</property>
+ <property name="visible">true</property>
+ <property name="can-focus">false</property>
+ <property name="xalign">1</property>
+ <property name="draw-indicator">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">false</property>
+ <property name="fill">true</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
+
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 94b65249..2f864e6b 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -46,6 +46,7 @@
#include "gtr-debug.h"
#include "gtr-window.h"
#include "gtr-progress.h"
+#include "gtr-actions.h"
#include <glib.h>
#include <glib-object.h>
@@ -107,12 +108,17 @@ typedef struct
gint autosave_interval;
guint autosave_timeout;
guint autosave : 1;
-
/*Blocking movement */
guint blocking : 1;
guint tab_realized : 1;
guint dispose_has_run : 1;
+
+ /*Search Bar*/
+ GtkOverlay *overlay;
+ GtkRevealer *search_revealer;
+ GtrSearchBar *search_bar;
+ GtkSearchEntry *search;
} GtrTabPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GtrTab, gtr_tab, GTK_TYPE_BOX)
@@ -138,6 +144,89 @@ static guint signals[LAST_SIGNAL];
static gboolean gtr_tab_autosave (GtrTab * tab);
+//---------------------------Search Bar Revealer------------------//
+
+void
+gtr_page_stop_search (GtrTab *tab,
+ GtrSearchBar *search_bar)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_assert (GTR_IS_TAB (tab));
+ g_assert (GTR_IS_SEARCH_BAR (priv->search_bar));
+
+ gtk_revealer_set_reveal_child (priv->search_revealer, FALSE);
+
+}
+
+void
+gtr_tab_show_hide_search_bar (GtrTab *tab, gboolean show)
+{
+ GtrTabPrivate *priv;
+
+ g_assert (GTR_IS_TAB (tab));
+ priv = gtr_tab_get_instance_private (tab);
+
+ gtk_revealer_set_reveal_child (priv->search_revealer, show);
+}
+
+void
+gtr_tab_find_set_replace (GtrTab *tab,
+ gboolean replace)
+{
+ GtrTabPrivate *priv;
+
+ g_assert (GTR_IS_TAB (tab));
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_set_replace_mode (priv->search_bar, replace);
+}
+
+void
+gtr_tab_find_next (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_find_next (priv->search_bar);
+}
+
+void
+gtr_tab_find_prev (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_find_prev (priv->search_bar);
+}
+
+void
+gtr_page_notify_child_revealed (GtrTab *tab,
+ GParamSpec *pspec,
+ GtkRevealer *revealer)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_assert (GTR_IS_TAB (tab));
+ g_assert (GTK_IS_REVEALER (revealer));
+
+ if (gtk_revealer_get_child_revealed (revealer))
+ {
+ GtkWidget *toplevel = gtk_widget_get_ancestor (GTK_WIDGET (revealer), GTK_TYPE_WINDOW);
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
+
+ /* Only focus the search bar if it doesn't already have focus,
+ * as it can reselect the search text.
+ */
+ if (focus == NULL || !gtk_widget_is_ancestor (focus, GTK_WIDGET (revealer)))
+ gtk_widget_grab_focus (GTK_WIDGET (priv->search_bar));
+ }
+}
+
+//----------------------------------------------------------------//
+
+
static gboolean
show_hide_revealer (GtkWidget *widget, GdkEvent *ev, GtrTab *tab)
{
@@ -867,10 +956,16 @@ gtr_tab_class_init (GtrTabClass * klass)
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_fuzzy);
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_untrans);
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_percentage);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, overlay);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_bar);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_revealer);
+ gtk_widget_class_bind_template_callback (widget_class, gtr_page_notify_child_revealed);
+ gtk_widget_class_bind_template_callback (widget_class, gtr_page_stop_search);
g_type_ensure (gtr_view_get_type ());
g_type_ensure (gtr_context_panel_get_type ());
g_type_ensure (gtr_message_table_get_type ());
+ g_type_ensure (gtr_search_bar_get_type ());
}
/***************************** Public funcs ***********************************/
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index a08ab5ec..aa17b148 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -32,6 +32,7 @@
#include "gtr-po.h"
#include "gtr-view.h"
#include "gtr-message-table-model.h"
+#include "gtr-search-bar.h"
G_BEGIN_DECLS
/*
@@ -159,6 +160,11 @@ void gtr_tab_sort_by (GtrTab *tab, GtrMessageTableSortBy sort);
void gtr_tab_find_replace (GtrTab *tab, gboolean set);
+void gtr_tab_show_hide_search_bar (GtrTab * tab, gboolean show);
+void gtr_tab_find_next (GtrTab * tab);
+void gtr_tab_find_prev (GtrTab * tab);
+void gtr_tab_find_set_replace (GtrTab * tab, gboolean replace);
+
/* Semi-public methods */
gchar *_gtr_tab_get_name (GtrTab * tab);
diff --git a/src/gtr-tab.ui b/src/gtr-tab.ui
index b40ba37c..49a144c9 100644
--- a/src/gtr-tab.ui
+++ b/src/gtr-tab.ui
@@ -1,301 +1,325 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.15.3 on Wed Sep 4 22:17:30 2013 -->
<interface>
- <!-- interface-requires gtk+ 3.10 -->
- <template class="GtrTab" parent="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
-
- <child>
- <object class="GtkEventBox" id="progress_eventbox">
- <property name="visible">True</property>
- <child>
- <object class="GtkBox" id="progress_box">
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GtrTab" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
-
- <object class="GtkRevealer" id="progress_revealer">
- <property name="visible">True</property>
- <property name="reveal_child">True</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">6</property>
- <property name="margin_right">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="orientation">horizontal</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="progress_percentage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">translated: 0.00%</property>
- <property name="xalign">0.5</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="progress_trans">
+ <property name="expand">True</property>
+ <child type="overlay">
+ <object class="GtkRevealer" id="search_revealer">
+ <property name="width-request">525</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="margin-right">12</property>
+ <property name="reveal-child">false</property>
+ <property name="visible">True</property>
+ <signal name="notify::child-revealed" handler="gtr_page_notify_child_revealed"
swapped="true" object="GtrTab"/>
+ <child>
+ <object class="GtrSearchBar" id="search_bar">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">Translated: 0</property>
- <property name="xalign">0.5</property>
- <style>
- <class name="progress_trans"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="progress_fuzzy">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">fuzzy: 0</property>
- <property name="xalign">0.5</property>
- <style>
- <class name="progress_fuzzy"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="progress_untrans">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">untranslated: 0</property>
- <property name="xalign">0.5</property>
- <style>
- <class name="progress_untranslated"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">false</property>
- <property name="position">1</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkPaned" id="hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="wide_handle">True</property>
- <child>
- <object class="GtkPaned" id="vertical_box">
+ <signal name="stop-search" handler="gtr_page_stop_search" swapped="true"
object="GtrTab"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkPaned" id="hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="width_request">450</property>
<property name="wide_handle">True</property>
<child>
- <object class="GtrMessageTable" id="message_table">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tab">GtrTab</property>
- <property name="height_request">350</property>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="translation_box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox" id="text_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox" id="text_hbox">
+ <object class="GtkPaned" id="vertical_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="width_request">450</property>
+ <property name="wide_handle">True</property>
+ <child>
+ <object class="GtrMessageTable" id="message_table">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
- <child>
- <object class="GtkLabel" id="msgid_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="ypad">5</property>
- <property name="label" translatable="yes">_Original Message</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="tab">GtrTab</property>
+ <property name="height_request">350</property>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="translation_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkLabel" id="msgid_ctxt">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="no"></property>
- <property name="use_underline">True</property>
- <property name="ellipsize">end</property>
- <style>
- <class name="msgcontext"/>
- </style>
- </object>
+ <object class="GtkBox" id="text_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="text_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel" id="msgid_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes">_Original
Message</property>
+ <property name="use_underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="msgid_ctxt">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="no"></property>
+ <property name="use_underline">True</property>
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="msgcontext"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="msgid_tags">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label"></property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ <style>
+ <class name="msgtags"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="text_msgid_scroll">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtrView" id="text_msgid">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="text_plural_scroll">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtrView" id="text_msgid_plural">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
<child>
- <object class="GtkLabel" id="msgid_tags">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label"></property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- <style>
- <class name="msgtags"/>
- </style>
- </object>
+ <object class="GtkLabel" id="msgstr_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes">Translate_d Text</property>
+ <property name="use_underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="text_msgid_scroll">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtrView" id="text_msgid">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- </object>
+ <object class="GtkNotebook" id="trans_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_border">False</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="text_plural_scroll">
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtrContextPanel" id="context">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tab">GtrTab</property>
+ <property name="width_request">150</property>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child >
+ <object class="GtkEventBox" id="progress_eventbox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox" id="progress_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkRevealer" id="progress_revealer">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
+ <property name="reveal_child">True</property>
<child>
- <object class="GtrView" id="text_msgid_plural">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- </object>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">horizontal</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="progress_percentage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">translated: 0.00%</property>
+ <property name="xalign">0.5</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_trans">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Translated: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_trans"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_fuzzy">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">fuzzy: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_fuzzy"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_untrans">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">untranslated: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_untranslated"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
</child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="msgstr_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="ypad">5</property>
- <property name="label" translatable="yes">Translate_d Text</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkNotebook" id="trans_notebook">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="show_border">False</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">False</property>
- </packing>
+ </object>
+ </child>
+ </object>
</child>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">False</property>
- </packing>
- </child>
- <child>
- <object class="GtrContextPanel" id="context">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tab">GtrTab</property>
- <property name="width_request">150</property>
- </object>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </template>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </template>
</interface>
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 19175f06..2e3aceb9 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -93,6 +93,8 @@ typedef struct
GtrProfileManager *prof_manager;
GtkWidget *profile_combo;
+ gboolean search_bar_shown;
+
guint dispose_has_run : 1;
} GtrWindowPrivate;
@@ -700,6 +702,7 @@ gtr_window_init (GtrWindow *window)
GtkTargetList *tl;
GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ priv->search_bar_shown = FALSE;
priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
gtk_widget_init_template (GTK_WIDGET (window));
@@ -1305,3 +1308,25 @@ gtr_window_hide_sort_menu (GtrWindow *window)
gtr_notebook_hide_sort_menu (GTR_NOTEBOOK (priv->notebook));
}
+
+void
+gtr_window_show_search_bar (GtrWindow *window,
+ gboolean show)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ GtrNotebook *notebook = GTR_NOTEBOOK (priv->notebook);
+ GtrTab *tab = gtr_window_get_active_tab (window);
+
+ gtr_tab_show_hide_search_bar (tab, show);
+ gtr_notebook_enable_find_button(notebook, show);
+
+ priv->search_bar_shown = show;
+}
+
+void
+gtr_window_toggle_search_bar (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+
+ gtr_window_show_search_bar(window, !priv->search_bar_shown);
+}
diff --git a/src/gtr-window.h b/src/gtr-window.h
index 7db93909..444f18f5 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -90,6 +90,9 @@ void gtr_window_tm_keybind (GtrWindow *window, GSimpleAction *action);
void gtr_window_hide_sort_menu (GtrWindow *window);
+void gtr_window_show_search_bar (GtrWindow *window, gboolean show);
+void gtr_window_toggle_search_bar (GtrWindow *window);
+
/** stack app states **/
void gtr_window_show_projects (GtrWindow *window);
void gtr_window_show_poeditor (GtrWindow *window);
diff --git a/src/gtranslator.gresource.xml b/src/gtranslator.gresource.xml
index 04d6c0db..75b7706d 100644
--- a/src/gtranslator.gresource.xml
+++ b/src/gtranslator.gresource.xml
@@ -12,7 +12,6 @@
<file preprocess="xml-stripblanks">gtr-notebook.ui</file>
<file preprocess="xml-stripblanks">gtr-preferences-dialog.ui</file>
<file preprocess="xml-stripblanks">gtr-profile-dialog.ui</file>
- <file preprocess="xml-stripblanks">gtr-search-dialog.ui</file>
<file preprocess="xml-stripblanks">gtr-statusbar.ui</file>
<file preprocess="xml-stripblanks">gtr-tab.ui</file>
<file preprocess="xml-stripblanks">gtr-window.ui</file>
@@ -20,5 +19,6 @@
<file preprocess="xml-stripblanks">gtr-dl-teams.ui</file>
<file preprocess="xml-stripblanks">gtr-filter-selection.ui</file>
<file preprocess="xml-stripblanks">help-overlay.ui</file>
+ <file preprocess="xml-stripblanks">gtr-search-bar.ui</file>
</gresource>
</gresources>
diff --git a/src/help-overlay.ui b/src/help-overlay.ui
index c2181961..b145593d 100644
--- a/src/help-overlay.ui
+++ b/src/help-overlay.ui
@@ -167,6 +167,27 @@
<property name="accelerator"><Primary>h</property>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Forward-search</property>
+ <property name="accelerator"><Primary>g</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut
window">Backward-search</property>
+ <property name="accelerator"><Primary><Shift>g</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Hide find & replace
bar</property>
+ <property name="accelerator">Escape</property>
+ </object>
+ </child>
</object>
</child>
diff --git a/src/meson.build b/src/meson.build
index be64e2d0..ded2794d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,6 +20,7 @@ enum_headers = files(
'gtr-view.h',
'gtr-window-activatable.h',
'gtr-window.h',
+ 'gtr-search-bar.h',
)
sources = files(
@@ -54,7 +55,6 @@ sources = files(
'gtr-profile.c',
'gtr-profile-dialog.c',
'gtr-profile-manager.c',
- 'gtr-search-dialog.c',
'gtr-settings.c',
'gtr-statusbar.c',
'gtr-status-combo-box.c',
@@ -68,6 +68,7 @@ sources = files(
'gtr-lang-button.c',
'gtr-progress.c',
'gtr-window.c',
+ 'gtr-search-bar.c',
)
marshal = 'gtr-marshal'
@@ -104,10 +105,10 @@ resource_data = files(
'gtr-notebook.ui',
'gtr-preferences-dialog.ui',
'gtr-profile-dialog.ui',
- 'gtr-search-dialog.ui',
'gtr-statusbar.ui',
'gtr-tab.ui',
- 'gtr-window.ui'
+ 'gtr-window.ui',
+ 'gtr-search-bar.ui',
)
sources += gnome.compile_resources(
diff --git a/src/styles.css b/src/styles.css
index 8a0a0d4d..5440ea21 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -27,3 +27,54 @@
#info_label.info {
color: @theme_fg_color;
}
+
+/* This file contains styling for various search widgets */
+.search-frame {
+ background-image: linear-gradient(shade(@theme_bg_color,1.05), @theme_bg_color);
+ padding: 6px;
+ border-style: solid;
+ border-color: @borders;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-bottom-left-radius: 5px;
+ border-bottom-right-radius: 5px;
+ box-shadow: 0px 0 3px @borders;
+ margin: 0 10px 20px 10px;
+}
+frame.search-frame border {
+ border: none;
+}
+.search-frame > box > grid:first-child > button.close:disabled,
+.search-frame > box > grid:first-child > button.close {
+ background: none;
+ border: none;
+ box-shadow: none;
+ padding-left: 4px;
+ padding-right: 4px;
+}
+.search-frame > box > grid:first-child > button.close image {
+ color: @theme_fg_color;
+ opacity: 0.3;
+ margin: 2px;
+ border: 1px solid transparent;
+ border-radius: 3px;
+}
+.search-frame > box > grid:first-child > button.close:hover image {
+ opacity: 0.75;
+ transition-duration: 250ms;
+ border: 1px solid @borders;
+}
+.search-frame > box > grid:first-child > button.close:active image {
+ opacity: 0.8;
+ background-image: linear-gradient(shade(@theme_bg_color, 0.9), @theme_bg_color);
+}
+.search-frame > box > grid:first-child > button.close:backdrop image {
+ opacity: 0.1;
+}
+.search-occurrences-tag {
+ color: shade (@theme_unfocused_fg_color, 0.8);
+ border: 0px;
+ margin: 2px;
+ padding: 2px;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]