[gtranslator] notebook: toggle fuzzy button in headerbar



commit b1c0c83ed0f2ee17978acf62cc03178388611fe7
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Thu Sep 13 15:06:09 2018 +0200

    notebook: toggle fuzzy button in headerbar

 src/gtr-application.c | 15 +++++++++++
 src/gtr-notebook.ui   | 73 +++++++++++++++++++++++++++++++++++----------------
 2 files changed, 65 insertions(+), 23 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 14d48b44..7f075820 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -377,6 +377,17 @@ build_tm_activated (GSimpleAction *action,
   gtr_window_show_tm_dialog (w);
 }
 
+static void
+toggle_fuzzy_activated (GSimpleAction *action,
+                        GVariant      *parameter,
+                        gpointer       user_data)
+{
+  GtrApplication *app = GTR_APPLICATION (user_data);
+  GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
+  GtrWindow *w = GTR_WINDOW (priv->active_window);
+  gtr_message_status_toggle_fuzzy (NULL, w);
+}
+
 static GActionEntry app_entries[] = {
   { "save", save_activated, NULL, NULL, NULL },
   { "saveas", saveas_activated, NULL, NULL, NULL },
@@ -391,6 +402,8 @@ static GActionEntry app_entries[] = {
   { "prev_no", prev_no_activated, NULL, NULL, NULL },
   { "next_no", next_no_activated, NULL, NULL, NULL },
 
+  { "fuzzy", toggle_fuzzy_activated, NULL, NULL, NULL },
+
   { "build_tm", build_tm_activated, NULL, NULL, NULL },
   { "new_window", new_window_activated, NULL, NULL, NULL },
   { "preferences", preferences_activated, NULL, NULL, NULL },
@@ -437,6 +450,8 @@ gtr_application_startup (GApplication *application)
   set_kb (application, "app.prev_no", "<Alt>Page_Up");
   set_kb (application, "app.next_no", "<Alt>Page_Down");
 
+  set_kb (application, "app.fuzzy", "<Alt>f");
+
   builder = gtk_builder_new ();
   gtk_builder_add_from_resource (builder, "/org/gnome/translator/gtranslator-menu.ui", NULL);
   gtk_application_set_app_menu (GTK_APPLICATION (application),
diff --git a/src/gtr-notebook.ui b/src/gtr-notebook.ui
index 18ade05e..f3bdc849 100644
--- a/src/gtr-notebook.ui
+++ b/src/gtr-notebook.ui
@@ -130,16 +130,16 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="progress_untrans">
+          <object class="GtkLabel" id="progress_trans">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label">fuzzy: 0</property>
+            <property name="label">Translated: 0</property>
             <property name="xalign">0</property>
           </object>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">4</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child>
@@ -156,16 +156,16 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="progress_trans">
+          <object class="GtkLabel" id="progress_untrans">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label">Translated: 0</property>
+            <property name="label">fuzzy: 0</property>
             <property name="xalign">0</property>
           </object>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">4</property>
           </packing>
         </child>
       </object>
@@ -382,47 +382,55 @@
       </packing>
     </child>
     <child>
-      <object class="GtkMenuButton" id="main_menu">
+      <object class="GtkSeparator">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+      <packing>
+        <property name="position">9</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkButton">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="receives_default">True</property>
-        <property name="popover">main_menu_popover</property>
+        <property name="tooltip_text" translatable="yes">Toggle fuzzy state (&lt;Alt&gt;+f)</property>
+        <property name="action_name">app.fuzzy</property>
         <child>
           <object class="GtkImage">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="icon_name">open-menu-symbolic</property>
-          </object>
-        </child>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="main_menu-atkobject">
-            <property name="AtkObject::accessible-name" translatable="yes">Main Menu</property>
+            <property name="icon_name">weather-fog-symbolic</property>
           </object>
         </child>
       </object>
       <packing>
-        <property name="pack_type">end</property>
-        <property name="position">1</property>
+        <property name="position">10</property>
       </packing>
     </child>
     <child>
-      <object class="GtkMenuButton" id="progress_button">
+      <object class="GtkMenuButton" id="main_menu">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="receives_default">True</property>
-        <property name="popover">progress_popover</property>
+        <property name="popover">main_menu_popover</property>
         <child>
-          <placeholder/>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="icon_name">open-menu-symbolic</property>
+          </object>
         </child>
         <child internal-child="accessible">
-          <object class="AtkObject" id="progress_button-atkobject">
-            <property name="AtkObject::accessible-name" translatable="yes">Progress button</property>
+          <object class="AtkObject" id="main_menu-atkobject">
+            <property name="AtkObject::accessible-name" translatable="yes">Main Menu</property>
           </object>
         </child>
       </object>
       <packing>
         <property name="pack_type">end</property>
-        <property name="position">6</property>
+        <property name="position">1</property>
       </packing>
     </child>
     <child>
@@ -478,9 +486,28 @@
         <property name="position">6</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkMenuButton" id="progress_button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">True</property>
+        <property name="popover">progress_popover</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="progress_button-atkobject">
+            <property name="AtkObject::accessible-name" translatable="yes">Progress button</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack_type">end</property>
+        <property name="position">6</property>
+      </packing>
+    </child>
     <style>
       <class name="titlebar"/>
     </style>
   </object>
 </interface>
-


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