[gtranslator] Find and replace to the main menu



commit f3d778d9d93cdc3f8564aa8da821e186609033df
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Tue Oct 2 10:08:33 2018 +0200

    Find and replace to the main menu
    
    I've added two new entries to the main menu to show the find dialog and
    the find and replace dialog.
    
    In the future we should remove these dialogs and use a GtkRevealer in
    the top with the search info and controls and maybe we can unify these
    two dialogs in one with an advanced button.
    
    Fix #23

 src/gtr-application.c | 26 ++++++++++++++++++++++++++
 src/gtr-notebook.ui   | 45 +++++++++++++++++++++++++++++++++++++--------
 2 files changed, 63 insertions(+), 8 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 02e2ecd5..fe352431 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -227,6 +227,28 @@ new_window_activated (GSimpleAction *action,
   gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
 }
 
+static void
+find_activated (GSimpleAction *action,
+                GVariant      *parameter,
+                gpointer       user_data)
+{
+  GtrApplication *app = GTR_APPLICATION (user_data);
+  GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+
+  _gtr_actions_search_find (GTK_ACTION (action), priv->active_window);
+}
+
+static void
+find_and_replace_activated (GSimpleAction *action,
+                            GVariant      *parameter,
+                            gpointer       user_data)
+{
+  GtrApplication *app = GTR_APPLICATION (user_data);
+  GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+
+  _gtr_actions_search_replace (GTK_ACTION (action), priv->active_window);
+}
+
 static void
 preferences_activated (GSimpleAction *action,
                        GVariant      *parameter,
@@ -461,6 +483,8 @@ static GActionEntry app_entries[] = {
   { "tm_8", tm_activated, NULL, NULL, NULL },
   { "tm_9", tm_activated, NULL, NULL, NULL },
 
+  { "find_and_replace", find_and_replace_activated, NULL, NULL, NULL },
+  { "find", find_activated, NULL, NULL, NULL },
   { "new_window", new_window_activated, NULL, NULL, NULL },
   { "preferences", preferences_activated, NULL, NULL, NULL },
   { "shortcuts", shortcuts_activated, NULL, NULL, NULL },
@@ -510,6 +534,8 @@ gtr_application_startup (GApplication *application)
   set_kb (application, "app.next_no", "<Alt>Page_Down");
 
   set_kb (application, "app.fuzzy", "<Ctrl>u");
+  set_kb (application, "app.find", "<Ctrl>f");
+  set_kb (application, "app.find_and_replace", "<Ctrl>h");
 
   set_kb (application, "app.build_tm", "<Ctrl>plus");
   set_kb (application, "app.tm_1", "<Ctrl>1");
diff --git a/src/gtr-notebook.ui b/src/gtr-notebook.ui
index 36359735..ecde1580 100644
--- a/src/gtr-notebook.ui
+++ b/src/gtr-notebook.ui
@@ -17,6 +17,34 @@
         <property name="margin_top">6</property>
         <property name="margin_bottom">6</property>
         <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkModelButton" id="find">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="action_name">app.find</property>
+            <property name="text" translatable="yes">Find</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="find_and_replace">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="action_name">app.find_and_replace</property>
+            <property name="text" translatable="yes">Find and replace</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkModelButton" id="translation_memory">
             <property name="visible">True</property>
@@ -28,7 +56,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">0</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child>
@@ -41,7 +69,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="position">3</property>
           </packing>
         </child>
         <child>
@@ -55,7 +83,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">4</property>
           </packing>
         </child>
         <child>
@@ -69,7 +97,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">3</property>
+            <property name="position">5</property>
           </packing>
         </child>
         <child>
@@ -82,7 +110,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">4</property>
+            <property name="position">6</property>
           </packing>
         </child>
         <child>
@@ -96,7 +124,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">5</property>
+            <property name="position">7</property>
           </packing>
         </child>
         <child>
@@ -110,7 +138,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">6</property>
+            <property name="position">8</property>
           </packing>
         </child>
         <child>
@@ -124,7 +152,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">7</property>
+            <property name="position">9</property>
           </packing>
         </child>
       </object>
@@ -553,3 +581,4 @@
   </object>
 </interface>
 
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]