[easytag/wip/for-2.3.7: 4/11] Convert EtSearchDialog to a template widget



commit 58c17a944041dadcc034c220cdb8c5fa652ab025
Author: David King <amigadave amigadave com>
Date:   Sun May 3 16:58:40 2015 +0100

    Convert EtSearchDialog to a template widget

 data/search_dialog.ui |  591 +++++++++++++++++++++++++------------------------
 src/search_dialog.c   |  118 ++++-------
 2 files changed, 346 insertions(+), 363 deletions(-)
---
diff --git a/data/search_dialog.ui b/data/search_dialog.ui
index ac59f19..ef5f555 100644
--- a/data/search_dialog.ui
+++ b/data/search_dialog.ui
@@ -1,6 +1,6 @@
 <interface domain="easytag">
-    <requires lib="gtk+" version="3.4"/>
-    <object class="GtkListStore" id="search_model">
+    <requires lib="gtk+" version="3.10"/>
+    <object class="GtkListStore" id="search_results_model">
         <columns>
             <column type="gchararray"/>
             <column type="gchararray"/>
@@ -50,331 +50,346 @@
             <column type="gpointer"/>
         </columns>
     </object>
-    <object class="GtkGrid" id="search_grid">
-        <property name="column-spacing">6</property>
-        <property name="row-spacing">6</property>
-        <child>
-            <object class="GtkLabel" id="search_label">
-                <property name="halign">end</property>
-                <property name="label" translatable="yes">Search:</property>
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkComboBox" id="search_combo">
-                <property name="has-entry">True</property>
-                <property name="hexpand">True</property>
-                <property name="entry-text-column">0</property>
-                <property name="tooltip-text" translatable="yes">Type the text to search for in the file 
list, or leave the field empty to display all files</property>
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">0</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkButton" id="search_find_button">
-                <property name="can-default">True</property>
-                <property name="label" translatable="yes">_Find</property>
-                <property name="use-underline">True</property>
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">0</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkLabel" id="search_in_label">
-                <property name="halign">end</property>
-                <property name="label" translatable="yes">In:</property>
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">1</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkBox" id="search_options_box">
+    <template class="EtSearchDialog" parent="GtkDialog">
+        <property name="title" translatable="yes">Find Files</property>
+        <signal name="delete-event" handler="on_delete_event"/>
+        <child internal-child="vbox">
+            <object class="GtkBox" id="search_vbox">
+                <property name="border-width">6</property>
                 <property name="spacing">6</property>
-                <property name="visible">True</property>
-                <child>
-                    <object class="GtkCheckButton" id="search_filename_check">
-                        <property name="label" translatable="yes" comments="This option is for the previous 
'in' option. For instance, translate this as 'Search' 'In:' 'the Filename'.">the Filename</property>
-                        <property name="visible">True</property>
-                    </object>
-                </child>
-                <child>
-                    <object class="GtkCheckButton" id="search_tag_check">
-                        <property name="label" translatable="yes" comments="This option is for the previous 
'in' option. For instance, translate this as 'Search' 'In:' 'the Tag'.">the Tag</property>
-                        <property name="visible">True</property>
-                    </object>
-                </child>
                 <child>
-                    <object class="GtkSeparator" id="search_separator">
-                        <property name="orientation">vertical</property>
-                        <property name="visible">True</property>
-                    </object>
-                </child>
-                <child>
-                    <object class="GtkCheckButton" id="search_case_check">
-                        <property name="label" translatable="yes">Case sensitive</property>
-                        <property name="visible">True</property>
-                    </object>
-                </child>
-            </object>
-            <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkButton" id="search_close_button">
-                <property name="label" translatable="yes">_Close</property>
-                <property name="use-underline">True</property>
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">1</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkScrolledWindow" id="search_scrolled">
-                <property name="min-content-height">300</property>
-                <property name="min-content-width">400</property>
-                <property name="visible">True</property>
-                <child>
-                    <object class="GtkTreeView" id="search_view">
-                        <property name="expand">True</property>
-                        <property name="model">search_model</property>
-                        <property name="sensitive">False</property>
-                        <property name="visible">True</property>
-                        <child internal-child="selection">
-                            <object class="GtkTreeSelection" id="search_selection">
-                                <property name="mode">multiple</property>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="filename_column">
-                                <property name="title" translatable="yes">Filename</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="filename_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">0</attribute>
-                                        <attribute name="weight">15</attribute>
-                                        <attribute name="foreground-rgba">30</attribute>
-                                    </attributes>
-                                </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="title_column">
-                                <property name="title" translatable="yes">Title</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="title_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">1</attribute>
-                                        <attribute name="weight">16</attribute>
-                                        <attribute name="foreground-rgba">31</attribute>
-                                    </attributes>
-                                </child>
-                            </object>
-                        </child>
+                    <object class="GtkGrid" id="search_grid">
+                        <property name="column-spacing">6</property>
+                        <property name="row-spacing">6</property>
                         <child>
-                            <object class="GtkTreeViewColumn" id="artist_column">
-                                <property name="title" translatable="yes">Artist</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="artist_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">2</attribute>
-                                        <attribute name="weight">17</attribute>
-                                        <attribute name="foreground-rgba">32</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkLabel" id="search_label">
+                                <property name="halign">end</property>
+                                <property name="label" translatable="yes">Search:</property>
+                                <property name="visible">True</property>
                             </object>
+                            <packing>
+                                <property name="left-attach">0</property>
+                                <property name="top-attach">0</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="album_artist_column">
-                                <property name="title" translatable="yes">Album Artist</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="album_artist_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">3</attribute>
-                                        <attribute name="weight">18</attribute>
-                                        <attribute name="foreground-rgba">33</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkComboBox" id="search_string_combo">
+                                <property name="has-entry">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="entry-text-column">0</property>
+                                <property name="tooltip-text" translatable="yes">Type the text to search for 
in the file list, or leave the field empty to display all files</property>
+                                <property name="visible">True</property>
                             </object>
+                            <packing>
+                                <property name="left-attach">1</property>
+                                <property name="top-attach">0</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="album_column">
-                                <property name="title" translatable="yes">Album</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="album_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">4</attribute>
-                                        <attribute name="weight">19</attribute>
-                                        <attribute name="foreground-rgba">34</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkButton" id="search_find_button">
+                                <property name="can-default">True</property>
+                                <property name="label" translatable="yes">_Find</property>
+                                <property name="use-underline">True</property>
+                                <property name="visible">True</property>
+                                <signal name="clicked" handler="Search_File"/>
                             </object>
+                            <packing>
+                                <property name="left-attach">2</property>
+                                <property name="top-attach">0</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="cd_column">
-                                <property name="title" translatable="yes">CD</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="cd_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">5</attribute>
-                                        <attribute name="weight">20</attribute>
-                                        <attribute name="foreground-rgba">35</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkLabel" id="search_in_label">
+                                <property name="halign">end</property>
+                                <property name="label" translatable="yes">In:</property>
+                                <property name="visible">True</property>
                             </object>
+                            <packing>
+                                <property name="left-attach">0</property>
+                                <property name="top-attach">1</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="year_column">
-                                <property name="title" translatable="yes">Year</property>
+                            <object class="GtkBox" id="search_options_box">
+                                <property name="spacing">6</property>
+                                <property name="visible">True</property>
                                 <child>
-                                    <object class="GtkCellRendererText" id="year_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">6</attribute>
-                                        <attribute name="weight">21</attribute>
-                                        <attribute name="foreground-rgba">36</attribute>
-                                    </attributes>
+                                    <object class="GtkCheckButton" id="search_filename_check">
+                                        <property name="label" translatable="yes" comments="This option is 
for the previous 'in' option. For instance, translate this as 'Search' 'In:' 'the Filename'.">the 
Filename</property>
+                                        <property name="visible">True</property>
+                                    </object>
                                 </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="track_column">
-                                <property name="title" translatable="yes">Track</property>
                                 <child>
-                                    <object class="GtkCellRendererText" id="track_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">7</attribute>
-                                        <attribute name="weight">22</attribute>
-                                        <attribute name="foreground-rgba">37</attribute>
-                                    </attributes>
+                                    <object class="GtkCheckButton" id="search_tag_check">
+                                        <property name="label" translatable="yes" comments="This option is 
for the previous 'in' option. For instance, translate this as 'Search' 'In:' 'the Tag'.">the Tag</property>
+                                        <property name="visible">True</property>
+                                    </object>
                                 </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="genre_column">
-                                <property name="title" translatable="yes">Genre</property>
                                 <child>
-                                    <object class="GtkCellRendererText" id="genre_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">8</attribute>
-                                        <attribute name="weight">23</attribute>
-                                        <attribute name="foreground-rgba">38</attribute>
-                                    </attributes>
+                                    <object class="GtkSeparator" id="search_separator">
+                                        <property name="orientation">vertical</property>
+                                        <property name="visible">True</property>
+                                    </object>
                                 </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="comment_column">
-                                <property name="title" translatable="yes">Comment</property>
                                 <child>
-                                    <object class="GtkCellRendererText" id="comment_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">9</attribute>
-                                        <attribute name="weight">24</attribute>
-                                        <attribute name="foreground-rgba">39</attribute>
-                                    </attributes>
+                                    <object class="GtkCheckButton" id="search_case_check">
+                                        <property name="label" translatable="yes">Case sensitive</property>
+                                        <property name="visible">True</property>
+                                    </object>
                                 </child>
                             </object>
+                            <packing>
+                                <property name="left-attach">1</property>
+                                <property name="top-attach">1</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="composer_column">
-                                <property name="title" translatable="yes">Composer</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="composer_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">10</attribute>
-                                        <attribute name="weight">25</attribute>
-                                        <attribute name="foreground-rgba">40</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkButton" id="search_close_button">
+                                <property name="label" translatable="yes">_Close</property>
+                                <property name="use-underline">True</property>
+                                <property name="visible">True</property>
+                                <signal name="clicked" handler="on_close_clicked"/>
                             </object>
+                            <packing>
+                                <property name="left-attach">2</property>
+                                <property name="top-attach">1</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="orig_artist_column">
-                                <property name="title" translatable="yes">Original Artist</property>
+                            <object class="GtkScrolledWindow" id="search_scrolled">
+                                <property name="min-content-height">300</property>
+                                <property name="min-content-width">400</property>
+                                <property name="visible">True</property>
                                 <child>
-                                    <object class="GtkCellRendererText" id="orig_artist_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">11</attribute>
-                                        <attribute name="weight">26</attribute>
-                                        <attribute name="foreground-rgba">41</attribute>
-                                    </attributes>
+                                    <object class="GtkTreeView" id="search_results_view">
+                                        <property name="expand">True</property>
+                                        <property name="model">search_results_model</property>
+                                        <property name="sensitive">False</property>
+                                        <property name="visible">True</property>
+                                        <child internal-child="selection">
+                                            <object class="GtkTreeSelection" id="search_selection">
+                                                <property name="mode">multiple</property>
+                                                <signal name="changed" 
handler="Search_Result_List_Row_Selected"/>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="filename_column">
+                                                <property name="title" translatable="yes">Filename</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="filename_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">0</attribute>
+                                                        <attribute name="weight">15</attribute>
+                                                        <attribute name="foreground-rgba">30</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="title_column">
+                                                <property name="title" translatable="yes">Title</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="title_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">1</attribute>
+                                                        <attribute name="weight">16</attribute>
+                                                        <attribute name="foreground-rgba">31</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="artist_column">
+                                                <property name="title" translatable="yes">Artist</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="artist_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">2</attribute>
+                                                        <attribute name="weight">17</attribute>
+                                                        <attribute name="foreground-rgba">32</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="album_artist_column">
+                                                <property name="title" translatable="yes">Album 
Artist</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="album_artist_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">3</attribute>
+                                                        <attribute name="weight">18</attribute>
+                                                        <attribute name="foreground-rgba">33</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="album_column">
+                                                <property name="title" translatable="yes">Album</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="album_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">4</attribute>
+                                                        <attribute name="weight">19</attribute>
+                                                        <attribute name="foreground-rgba">34</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="cd_column">
+                                                <property name="title" translatable="yes">CD</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="cd_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">5</attribute>
+                                                        <attribute name="weight">20</attribute>
+                                                        <attribute name="foreground-rgba">35</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="year_column">
+                                                <property name="title" translatable="yes">Year</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="year_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">6</attribute>
+                                                        <attribute name="weight">21</attribute>
+                                                        <attribute name="foreground-rgba">36</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="track_column">
+                                                <property name="title" translatable="yes">Track</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="track_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">7</attribute>
+                                                        <attribute name="weight">22</attribute>
+                                                        <attribute name="foreground-rgba">37</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="genre_column">
+                                                <property name="title" translatable="yes">Genre</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="genre_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">8</attribute>
+                                                        <attribute name="weight">23</attribute>
+                                                        <attribute name="foreground-rgba">38</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="comment_column">
+                                                <property name="title" translatable="yes">Comment</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="comment_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">9</attribute>
+                                                        <attribute name="weight">24</attribute>
+                                                        <attribute name="foreground-rgba">39</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="composer_column">
+                                                <property name="title" translatable="yes">Composer</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="composer_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">10</attribute>
+                                                        <attribute name="weight">25</attribute>
+                                                        <attribute name="foreground-rgba">40</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="orig_artist_column">
+                                                <property name="title" translatable="yes">Original 
Artist</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="orig_artist_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">11</attribute>
+                                                        <attribute name="weight">26</attribute>
+                                                        <attribute name="foreground-rgba">41</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="copyright_column">
+                                                <property name="title" 
translatable="yes">Copyright</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="copyright_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">12</attribute>
+                                                        <attribute name="weight">27</attribute>
+                                                        <attribute name="foreground-rgba">42</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="url_column">
+                                                <property name="title" translatable="yes">URL</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" id="url_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">13</attribute>
+                                                        <attribute name="weight">28</attribute>
+                                                        <attribute name="foreground-rgba">43</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                        <child>
+                                            <object class="GtkTreeViewColumn" id="encoded_by_column">
+                                                <property name="title" translatable="yes">Encoded 
By</property>
+                                                <child>
+                                                    <object class="GtkCellRendererText" 
id="encoced_by_renderer"/>
+                                                    <attributes>
+                                                        <attribute name="text">14</attribute>
+                                                        <attribute name="weight">29</attribute>
+                                                        <attribute name="foreground-rgba">44</attribute>
+                                                    </attributes>
+                                                </child>
+                                            </object>
+                                        </child>
+                                    </object>
                                 </child>
                             </object>
+                            <packing>
+                                <property name="left-attach">0</property>
+                                <property name="top-attach">2</property>
+                                <property name="width">3</property>
+                            </packing>
                         </child>
                         <child>
-                            <object class="GtkTreeViewColumn" id="copyright_column">
-                                <property name="title" translatable="yes">Copyright</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="copyright_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">12</attribute>
-                                        <attribute name="weight">27</attribute>
-                                        <attribute name="foreground-rgba">42</attribute>
-                                    </attributes>
-                                </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="url_column">
-                                <property name="title" translatable="yes">URL</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="url_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">13</attribute>
-                                        <attribute name="weight">28</attribute>
-                                        <attribute name="foreground-rgba">43</attribute>
-                                    </attributes>
-                                </child>
-                            </object>
-                        </child>
-                        <child>
-                            <object class="GtkTreeViewColumn" id="encoded_by_column">
-                                <property name="title" translatable="yes">Encoded By</property>
-                                <child>
-                                    <object class="GtkCellRendererText" id="encoced_by_renderer"/>
-                                    <attributes>
-                                        <attribute name="text">14</attribute>
-                                        <attribute name="weight">29</attribute>
-                                        <attribute name="foreground-rgba">44</attribute>
-                                    </attributes>
-                                </child>
+                            <object class="GtkStatusbar" id="status_bar">
+                                <property name="visible">True</property>
                             </object>
+                            <packing>
+                                <property name="left-attach">0</property>
+                                <property name="top-attach">3</property>
+                                <property name="width">3</property>
+                            </packing>
                         </child>
                     </object>
                 </child>
             </object>
-            <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">2</property>
-                <property name="width">3</property>
-            </packing>
-        </child>
-        <child>
-            <object class="GtkStatusbar" id="search_status">
-                <property name="visible">True</property>
-            </object>
-            <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">3</property>
-                <property name="width">3</property>
-            </packing>
         </child>
-    </object>
+    </template>
 </interface>
 
diff --git a/src/search_dialog.c b/src/search_dialog.c
index d32719c..2611e17 100644
--- a/src/search_dialog.c
+++ b/src/search_dialog.c
@@ -1,5 +1,5 @@
 /* EasyTAG - tag editor for audio files
- * Copyright (C) 2013-2014  David King <amigadave amigadave com>
+ * Copyright (C) 2013-2015  David King <amigadave amigadave 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
@@ -34,11 +34,12 @@
 
 typedef struct
 {
+    GtkWidget *search_find_button;
     GtkWidget *search_string_combo;
     GtkListStore *search_string_model;
-    GtkWidget *search_in_filename;
-    GtkWidget *search_in_tag;
-    GtkWidget *search_case_sensitive;
+    GtkWidget *search_filename_check;
+    GtkWidget *search_tag_check;
+    GtkWidget *search_case_check;
     GtkWidget *search_results_view;
     GtkListStore *search_results_model;
     GtkWidget *status_bar;
@@ -47,8 +48,6 @@ typedef struct
 
 G_DEFINE_TYPE_WITH_PRIVATE (EtSearchDialog, et_search_dialog, GTK_TYPE_DIALOG)
 
-static const guint BOX_SPACING = 6;
-
 enum
 {
     // Columns for titles
@@ -183,7 +182,7 @@ Add_Row_To_Search_Result_List (EtSearchDialog *self,
     if (!ETFile || !string_to_search)
         return;
 
-    case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_sensitive));
+    case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_check));
 
     // Filename
     SearchResultList_Text[SEARCH_RESULT_FILENAME]    = g_path_get_basename( ((File_Name 
*)ETFile->FileNameNew->data)->value_utf8 );
@@ -393,7 +392,7 @@ Search_File (GtkWidget *search_button, gpointer user_data)
     self = ET_SEARCH_DIALOG (user_data);
     priv = et_search_dialog_get_instance_private (self);
 
-    if (!priv->search_string_combo || !priv->search_in_filename || !priv->search_in_tag || 
!priv->search_results_view)
+    if (!priv->search_string_combo || !priv->search_filename_check || !priv->search_tag_check || 
!priv->search_results_view)
         return;
 
     string_to_search = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->search_string_combo))));
@@ -411,13 +410,13 @@ Search_File (GtkWidget *search_button, gpointer user_data)
         ETFile = (ET_File *)l->data;
 
         // Search in the filename
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->search_in_filename)))
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->search_filename_check)))
         {
             gchar *filename_utf8 = ((File_Name *)ETFile->FileNameNew->data)->value_utf8;
             gchar *basename_utf8;
 
             // To search without case sensivity
-            if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_sensitive)))
+            if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_check)))
             {
                 temp = g_path_get_basename(filename_utf8);
                 basename_utf8 = g_utf8_casefold(temp, -1);
@@ -442,12 +441,12 @@ Search_File (GtkWidget *search_button, gpointer user_data)
         }
 
         // Search in the tag
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->search_in_tag)))
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->search_tag_check)))
         {
             File_Tag *FileTag   = (File_Tag *)ETFile->FileTag->data;
 
             // To search with or without case sensivity
-            if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_sensitive)))
+            if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_case_check)))
             {
                 // To search without case sensivity...
                 // Duplicate and convert the strings into UTF-8 in loxer case
@@ -583,42 +582,12 @@ static void
 create_search_dialog (EtSearchDialog *self)
 {
     EtSearchDialogPrivate *priv;
-    GtkWidget *content_area;
-    GtkBuilder *builder;
-    GError *error = NULL;
-    GtkWidget *grid;
-    GtkWidget *button;
 
     priv = et_search_dialog_get_instance_private (self);
 
-    gtk_window_set_title (GTK_WINDOW (self), _("Find Files"));
-    g_signal_connect (self, "delete-event", G_CALLBACK (on_delete_event),
-                      NULL);
-
-    content_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
-    gtk_box_set_spacing (GTK_BOX (content_area), BOX_SPACING);
-    gtk_container_set_border_width (GTK_CONTAINER (self),
-                                    BOX_SPACING);
-
-    builder = gtk_builder_new ();
-    gtk_builder_add_from_resource (builder,
-                                   "/org/gnome/EasyTAG/search_dialog.ui",
-                                   &error);
-
-    if (error != NULL)
-    {
-        g_error ("Unable to get search dialog from resource: %s",
-                 error->message);
-    }
-
-    grid = GTK_WIDGET (gtk_builder_get_object (builder, "search_grid"));
-    gtk_container_add (GTK_CONTAINER (content_area), grid);
-
     /* Words to search. */
     priv->search_string_model = gtk_list_store_new (MISC_COMBO_COUNT,
                                                     G_TYPE_STRING);
-    priv->search_string_combo = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                                    "search_combo"));
     gtk_combo_box_set_model (GTK_COMBO_BOX (priv->search_string_combo),
                              GTK_TREE_MODEL (priv->search_string_model));
     g_object_unref (priv->search_string_model);
@@ -630,54 +599,27 @@ create_search_dialog (EtSearchDialog *self)
     /* Set content of the clipboard if available. */
     gtk_editable_paste_clipboard (GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (priv->search_string_combo))));
 
-    priv->search_in_filename = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                                   "search_filename_check"));
-    priv->search_in_tag = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                              "search_tag_check"));
-    g_settings_bind (MainSettings, "search-filename", priv->search_in_filename,
-                     "active", G_SETTINGS_BIND_DEFAULT);
-    g_settings_bind (MainSettings, "search-tag", priv->search_in_tag,
+    g_settings_bind (MainSettings, "search-filename",
+                     priv->search_filename_check, "active",
+                     G_SETTINGS_BIND_DEFAULT);
+    g_settings_bind (MainSettings, "search-tag", priv->search_tag_check,
                      "active", G_SETTINGS_BIND_DEFAULT);
 
     /* Property of the search. */
-    priv->search_case_sensitive = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                                      "search_case_check"));
     g_settings_bind (MainSettings, "search-case-sensitive",
-                     priv->search_case_sensitive, "active",
+                     priv->search_case_check, "active",
                      G_SETTINGS_BIND_DEFAULT);
 
-    /* Results list. */
-    priv->search_results_model = GTK_LIST_STORE (gtk_builder_get_object (builder,
-                                                                         "search_model"));
-    priv->search_results_view = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                                    "search_view"));
-
-    g_signal_connect (gtk_builder_get_object (builder, "search_selection"),
-                      "changed", G_CALLBACK (Search_Result_List_Row_Selected),
-                      self);
-
     /* Button to run the search. */
-    button = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                 "search_find_button"));
-    gtk_widget_grab_default (button);
-    g_signal_connect (button, "clicked", G_CALLBACK (Search_File), self);
+    gtk_widget_grab_default (priv->search_find_button);
     g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->search_string_combo)),
                       "activate", G_CALLBACK (Search_File), self);
 
-    /* Button to cancel. */
-    button = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                 "search_close_button"));
-    g_signal_connect (button, "clicked", G_CALLBACK (on_close_clicked), self);
-
     /* Status bar. */
-    priv->status_bar = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                           "search_status"));
     priv->status_bar_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->status_bar),
                                                              "Messages");
     gtk_statusbar_push (GTK_STATUSBAR (priv->status_bar),
                         priv->status_bar_context, _("Ready to search…"));
-
-    g_object_unref (builder);
 }
 
 /*
@@ -698,12 +640,38 @@ et_search_dialog_apply_changes (EtSearchDialog *self)
 static void
 et_search_dialog_init (EtSearchDialog *self)
 {
+    gtk_widget_init_template (GTK_WIDGET (self));
     create_search_dialog (self);
 }
 
 static void
 et_search_dialog_class_init (EtSearchDialogClass *klass)
 {
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+    gtk_widget_class_set_template_from_resource (widget_class,
+                                                 "/org/gnome/EasyTAG/search_dialog.ui");
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_find_button);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_string_combo);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_filename_check);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_tag_check);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_case_check);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_results_model);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  search_results_view);
+    gtk_widget_class_bind_template_child_private (widget_class, EtSearchDialog,
+                                                  status_bar);
+    gtk_widget_class_bind_template_callback (widget_class, on_close_clicked);
+    gtk_widget_class_bind_template_callback (widget_class, on_delete_event);
+    gtk_widget_class_bind_template_callback (widget_class, Search_File);
+    gtk_widget_class_bind_template_callback (widget_class,
+                                             Search_Result_List_Row_Selected);
 }
 
 /*


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