[gnome-photos] embed: Port to template
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] embed: Port to template
- Date: Wed, 29 Mar 2017 08:01:31 +0000 (UTC)
commit 8574718447bbc1e684837470877492b83bd827ce
Author: Alessandro Bono <abono gnome org>
Date: Wed Mar 22 11:45:24 2017 +0100
embed: Port to template
https://bugzilla.gnome.org/show_bug.cgi?id=780424
src/Makefile.am | 1 +
src/photos-embed.c | 30 ++++++++----------------------
src/photos-embed.ui | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/photos.gresource.xml | 1 +
4 files changed, 56 insertions(+), 22 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a8701a..c100eed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -351,6 +351,7 @@ EXTRA_DIST = \
photos-gegl.gresource.xml \
photos-dlna-renderers-dialog.ui \
photos-dropdown.ui \
+ photos-embed.ui \
photos-export-dialog.ui \
photos-help-overlay.ui \
photos-marshalers.list \
diff --git a/src/photos-embed.c b/src/photos-embed.c
index e4c9b63..77ea1a5 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -75,7 +75,6 @@ struct _PhotosEmbed
GtkWidget *overview;
GtkWidget *preview;
GtkWidget *search;
- GtkWidget *selection_toolbar;
GtkWidget *spinner_box;
GtkWidget *stack;
GtkWidget *stack_overlay;
@@ -651,30 +650,16 @@ photos_embed_init (PhotosEmbed *self)
gboolean querying;
const gchar *name;
+ gtk_widget_init_template (GTK_WIDGET (self));
+
app = g_application_get_default ();
state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
self->search_action = g_action_map_lookup_action (G_ACTION_MAP (app), "search");
self->notifications = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
- gtk_widget_show (GTK_WIDGET (self));
-
self->extension_point = g_io_extension_point_lookup (PHOTOS_TRACKER_CONTROLLER_EXTENSION_POINT_NAME);
- self->selection_toolbar = photos_selection_toolbar_new ();
- gtk_box_pack_end (GTK_BOX (self), self->selection_toolbar, FALSE, FALSE, 0);
-
- self->stack_overlay = gtk_overlay_new ();
- gtk_widget_show (self->stack_overlay);
- gtk_box_pack_end (GTK_BOX (self), self->stack_overlay, TRUE, TRUE, 0);
-
- self->stack = gtk_stack_new ();
- gtk_stack_set_homogeneous (GTK_STACK (self->stack), TRUE);
- gtk_stack_set_transition_type (GTK_STACK (self->stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
- gtk_widget_show (self->stack);
- gtk_container_add (GTK_CONTAINER (self->stack_overlay), self->stack);
-
self->toolbar = photos_main_toolbar_new (GTK_OVERLAY (self->stack_overlay));
photos_main_toolbar_set_stack (PHOTOS_MAIN_TOOLBAR (self->toolbar), GTK_STACK (self->stack));
windows = gtk_application_get_windows (GTK_APPLICATION (app));
@@ -703,9 +688,6 @@ photos_embed_init (PhotosEmbed *self)
self->preview = photos_preview_view_new (GTK_OVERLAY (self->stack_overlay));
gtk_stack_add_named (GTK_STACK (self->stack), self->preview, "preview");
- self->spinner_box = photos_spinner_box_new ();
- gtk_overlay_add_overlay (GTK_OVERLAY (self->stack_overlay), self->spinner_box);
-
/* TODO: SearchBar.Dropdown, …
*/
@@ -784,8 +766,6 @@ photos_embed_init (PhotosEmbed *self)
G_CALLBACK (photos_embed_search_changed),
self,
G_CONNECT_SWAPPED);
-
- gtk_widget_show (GTK_WIDGET (self));
}
@@ -793,8 +773,14 @@ static void
photos_embed_class_init (PhotosEmbedClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = photos_embed_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Photos/embed.ui");
+ gtk_widget_class_bind_template_child (widget_class, PhotosEmbed, spinner_box);
+ gtk_widget_class_bind_template_child (widget_class, PhotosEmbed, stack);
+ gtk_widget_class_bind_template_child (widget_class, PhotosEmbed, stack_overlay);
}
diff --git a/src/photos-embed.ui b/src/photos-embed.ui
new file mode 100644
index 0000000..f015e1b
--- /dev/null
+++ b/src/photos-embed.ui
@@ -0,0 +1,46 @@
+<?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="PhotosEmbed" parent="GtkBox">
+ <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkOverlay" id="stack_overlay">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
+ <property name="visible">1</property>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="PhotosSpinnerBox" id="spinner_box"/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="PhotosSelectionToolbar"/>
+ </child>
+ </template>
+</interface>
diff --git a/src/photos.gresource.xml b/src/photos.gresource.xml
index 9a8408a..0acdb03 100644
--- a/src/photos.gresource.xml
+++ b/src/photos.gresource.xml
@@ -24,6 +24,7 @@
<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="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="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]