[gnome-photos] dropdown: Port to template



commit a7412974354a83978a5b76790c3e0eff0e941377
Author: Alessandro Bono <abono gnome org>
Date:   Thu Feb 16 22:31:12 2017 +0100

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

 src/Makefile.am          |    1 +
 src/photos-dropdown.c    |   17 ++++++++---------
 src/photos-dropdown.ui   |   31 +++++++++++++++++++++++++++++++
 src/photos.gresource.xml |    1 +
 4 files changed, 41 insertions(+), 9 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index b8e6951..3a8701a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -350,6 +350,7 @@ EXTRA_DIST = \
        photos.gresource.xml \
        photos-gegl.gresource.xml \
        photos-dlna-renderers-dialog.ui \
+       photos-dropdown.ui \
        photos-export-dialog.ui \
        photos-help-overlay.ui \
        photos-marshalers.list \
diff --git a/src/photos-dropdown.c b/src/photos-dropdown.c
index f6f4cbf..e5a362e 100644
--- a/src/photos-dropdown.c
+++ b/src/photos-dropdown.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Alessandro Bono
+ * Copyright © 2015 – 2017 Alessandro Bono
  * Copyright © 2014 – 2017 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
@@ -101,6 +101,8 @@ photos_dropdown_init (PhotosDropdown *self)
   GApplication *app;
   PhotosSearchContextState *state;
 
+  gtk_widget_init_template (GTK_WIDGET (self));
+
   app = g_application_get_default ();
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
@@ -108,16 +110,9 @@ photos_dropdown_init (PhotosDropdown *self)
   self->srch_typ_mngr = g_object_ref (state->srch_typ_mngr);
   self->src_mngr = g_object_ref (state->src_mngr);
 
-  self->grid = gtk_grid_new ();
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (self->grid), GTK_ORIENTATION_HORIZONTAL);
-  gtk_grid_set_row_homogeneous (GTK_GRID (self->grid), TRUE);
-  gtk_container_add (GTK_CONTAINER (self), self->grid);
-
   photos_dropdown_add_manager (self, self->src_mngr);
   photos_dropdown_add_manager (self, self->srch_typ_mngr);
   photos_dropdown_add_manager (self, self->srch_mtch_mngr);
-
-  gtk_widget_show_all (GTK_WIDGET (self->grid));
 }
 
 
@@ -125,13 +120,17 @@ static void
 photos_dropdown_class_init (PhotosDropdownClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
   object_class->dispose = photos_dropdown_dispose;
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Photos/dropdown.ui");
+  gtk_widget_class_bind_template_child (widget_class, PhotosDropdown, grid);
 }
 
 
 GtkWidget *
 photos_dropdown_new (void)
 {
-  return g_object_new (PHOTOS_TYPE_DROPDOWN, "position", GTK_POS_BOTTOM, NULL);
+  return g_object_new (PHOTOS_TYPE_DROPDOWN, NULL);
 }
diff --git a/src/photos-dropdown.ui b/src/photos-dropdown.ui
new file mode 100644
index 0000000..0bc2c35
--- /dev/null
+++ b/src/photos-dropdown.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="PhotosDropdown" parent="GtkPopover">
+    <property name="position">GTK_POS_BOTTOM</property>
+    <child>
+      <object class="GtkGrid" id="grid">
+        <property name="row-homogeneous">1</property>
+        <property name="visible">1</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/photos.gresource.xml b/src/photos.gresource.xml
index 76123fe..9a8408a 100644
--- a/src/photos.gresource.xml
+++ b/src/photos.gresource.xml
@@ -23,6 +23,7 @@
     <file alias="Adwaita.css">../data/Adwaita.css</file>
     <file alias="dlna-renderers-dialog.ui" preprocess="xml-stripblanks" 
compressed="true">photos-dlna-renderers-dialog.ui</file>
     <file alias="dnd-counter.svg" preprocess="to-pixdata">../data/dnd-counter.svg</file>
+    <file alias="dropdown.ui" preprocess="xml-stripblanks" compressed="true">photos-dropdown.ui</file>
     <file alias="export-dialog.ui" preprocess="xml-stripblanks" 
compressed="true">photos-export-dialog.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]