[gnome-photos] main-toolbar: Port to template



commit fa0756e6edf68c5796759d6b3a6f09216ec4f8b1
Author: Alessandro Bono <abono gnome org>
Date:   Thu Feb 16 23:08:08 2017 +0100

    main-toolbar: Port to template
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780424

 src/photos-main-toolbar.c  |   13 ++++++-------
 src/photos-main-toolbar.ui |   31 +++++++++++++++++++++++++++++++
 src/photos.gresource.xml   |    1 +
 3 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 1c67a45..e555c9e 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -748,16 +748,11 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
   GtkBuilder *builder;
   PhotosSearchContextState *state;
 
+  gtk_widget_init_template (GTK_WIDGET (self));
+
   app = g_application_get_default ();
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
-  gtk_widget_show (GTK_WIDGET (self));
-
-  self->header_bar = photos_header_bar_new ();
-  gtk_container_add (GTK_CONTAINER (self), self->header_bar);
-  gtk_widget_show (self->header_bar);
-
   self->gear_menu = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (app), "gear-menu"));
   self->search = g_action_map_lookup_action (G_ACTION_MAP (app), "search");
 
@@ -809,6 +804,7 @@ static void
 photos_main_toolbar_class_init (PhotosMainToolbarClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
   object_class->constructed = photos_main_toolbar_constructed;
   object_class->dispose = photos_main_toolbar_dispose;
@@ -821,6 +817,9 @@ photos_main_toolbar_class_init (PhotosMainToolbarClass *class)
                                                         "The stack overlay widget",
                                                         GTK_TYPE_OVERLAY,
                                                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Photos/main-toolbar.ui");
+  gtk_widget_class_bind_template_child (widget_class, PhotosMainToolbar, header_bar);
 }
 
 
diff --git a/src/photos-main-toolbar.ui b/src/photos-main-toolbar.ui
new file mode 100644
index 0000000..0650159
--- /dev/null
+++ b/src/photos-main-toolbar.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Photos - access, organize and share your photos on GNOME
+ Copyright © 2017 Alessandro Bono
+
+ 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 2
+ 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+-->
+<interface>
+  <template class="PhotosMainToolbar" parent="GtkBox">
+    <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+    <property name="visible">1</property>
+    <child>
+      <object class="PhotosHeaderBar" id="header_bar">
+        <property name="visible">1</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/photos.gresource.xml b/src/photos.gresource.xml
index 3669c1a..8c56159 100644
--- a/src/photos.gresource.xml
+++ b/src/photos.gresource.xml
@@ -26,6 +26,7 @@
     <file alias="dropdown.ui" preprocess="xml-stripblanks" compressed="true">photos-dropdown.ui</file>
     <file alias="embed.ui" preprocess="xml-stripblanks" compressed="true">photos-embed.ui</file>
     <file alias="export-dialog.ui" preprocess="xml-stripblanks" 
compressed="true">photos-export-dialog.ui</file>
+    <file alias="main-toolbar.ui" preprocess="xml-stripblanks" 
compressed="true">photos-main-toolbar.ui</file>
     <file alias="main-window.ui" preprocess="xml-stripblanks" compressed="true">photos-main-window.ui</file>
     <file alias="preview-menu.ui" preprocess="xml-stripblanks" 
compressed="true">photos-preview-menu.ui</file>
     <file alias="selection-menu.ui" preprocess="xml-stripblanks" 
compressed="true">photos-selection-menu.ui</file>


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