[gedit-plugins] Move more code to the ui file



commit da911c812a495f9b4a0ce87d65da06f0f0999c70
Author: Paolo Borelli <pborelli gnome org>
Date:   Wed Apr 22 22:09:16 2015 +0200

    Move more code to the ui file

 plugins/findinfiles/dialog.ui   |   52 +++++++++++++++++++++++++++-----------
 plugins/findinfiles/dialog.vala |   41 ++++++------------------------
 2 files changed, 46 insertions(+), 47 deletions(-)
---
diff --git a/plugins/findinfiles/dialog.ui b/plugins/findinfiles/dialog.ui
index 5376634..bf9f6de 100644
--- a/plugins/findinfiles/dialog.ui
+++ b/plugins/findinfiles/dialog.ui
@@ -69,30 +69,54 @@
               <object class="GtkLabel" id="search_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">1</property>
                 <property name="label" translatable="yes" context="label on the left of the GtkEntry 
containing text to search">F_ind </property>
                 <property name="use_underline">True</property>
+                <property name="mnemonic_widget">search_entry</property>
+                <property name="xalign">1</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="search_entry">
+                <property name="width_request">300</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="activates_default">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
               <object class="GtkLabel" id="folder_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">1</property>
                 <property name="label" translatable="yes">_In </property>
                 <property name="use_underline">True</property>
+                <property name="mnemonic_widget">sel_folder</property>
+                <property name="xalign">1</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFileChooserButton" id="sel_folder">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="action">select-folder</property>
+                <property name="title" translatable="yes">Select a _folder</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
               </packing>
             </child>
             <child>
@@ -109,13 +133,12 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">0.5</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -126,13 +149,12 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">0.5</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -143,23 +165,23 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">0.5</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="top_attach">2</property>
               </packing>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/plugins/findinfiles/dialog.vala b/plugins/findinfiles/dialog.vala
index ff189a5..c38acc4 100644
--- a/plugins/findinfiles/dialog.vala
+++ b/plugins/findinfiles/dialog.vala
@@ -21,7 +21,9 @@ namespace FindInFilesPlugin {
 
 [GtkTemplate (ui = "/org/gnome/gedit/plugins/findinfiles/ui/dialog.ui")]
 class FindDialog : Gtk.Dialog {
+    [GtkChild]
     public Gtk.Entry search_entry;
+    [GtkChild]
     public Gtk.FileChooserButton sel_folder;
     [GtkChild]
     public Gtk.CheckButton match_case_checkbutton;
@@ -31,39 +33,16 @@ class FindDialog : Gtk.Dialog {
     public Gtk.CheckButton regex_checkbutton;
     [GtkChild]
     public Gtk.Widget find_button;
-    [GtkChild]
-    Gtk.Grid grid;
-    [GtkChild]
-    Gtk.Label search_label;
-    [GtkChild]
-    Gtk.Label folder_label;
 
     public FindDialog (File? root) {
-        build_layout ();
-        setup_signals ();
-
-        try {
-            if (root != null)
-                sel_folder.set_current_folder_file (root);
+        if (root != null) {
+            try {
+                    sel_folder.set_current_folder_file (root);
+            }
+            catch (Error err) {
+                warning (err.message);
+            }
         }
-        catch (Error err) {
-            warning (err.message);
-        }
-    }
-
-    private void build_layout () {
-        search_entry = new Gtk.Entry ();
-        search_entry.set_size_request (300, -1);
-        search_entry.set_hexpand (true);
-        search_entry.set_activates_default (true);
-        grid.attach_next_to (search_entry, search_label, Gtk.PositionType.RIGHT, 1, 1);
-
-        sel_folder = new Gtk.FileChooserButton (_("Select a _folder"), Gtk.FileChooserAction.SELECT_FOLDER);
-        sel_folder.set_hexpand (true);
-        grid.attach_next_to (sel_folder, folder_label, Gtk.PositionType.RIGHT, 1, 1);
-
-        search_label.set_mnemonic_widget (search_entry);
-        folder_label.set_mnemonic_widget (sel_folder);
 
         set_default_response (Gtk.ResponseType.OK);
         set_response_sensitive (Gtk.ResponseType.OK, false);
@@ -78,9 +57,7 @@ class FindDialog : Gtk.Dialog {
         } else {
             add_button (_("_Close"), Gtk.ResponseType.CLOSE);
         }
-    }
 
-    private void setup_signals () {
         search_entry.changed.connect (() => {
             find_button.sensitive = (search_entry.text != "");
         });


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