[gnome-photos/wip/abono/sidebar: 631/635] WIP title box



commit f02465b44cb5b5b1380e61d06b1392b79cb461ec
Author: Alessandro Bono <abono gnome org>
Date:   Tue Dec 13 16:53:56 2016 +0100

    WIP title box

 src/photos-properties-sidebar.c  |   23 +++++++++++++++++++++++
 src/photos-properties-sidebar.ui |   29 +++++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-properties-sidebar.c b/src/photos-properties-sidebar.c
index 1bf10b5..b0595d3 100644
--- a/src/photos-properties-sidebar.c
+++ b/src/photos-properties-sidebar.c
@@ -19,11 +19,14 @@
  */
 
 #include "photos-base-item.h"
+#include "photos-filterable.h"
 #include "photos-properties-sidebar.h"
+#include "photos-utils.h"
 
 struct _PhotosPropertiesSidebar
 {
   GtkScrolledWindow parent_instance;
+  GtkWidget *title_entry;
   PhotosBaseItem *item;
 };
 
@@ -41,6 +44,17 @@ photos_properties_sidebar_new (void)
 }
 
 static void
+photos_properties_sidebar_name_update (PhotosPropertiesSidebar *self)
+{
+  const gchar *new_title;
+  const gchar *urn;
+
+  urn = photos_filterable_get_id (PHOTOS_FILTERABLE (self->item));
+  new_title = gtk_entry_get_text (GTK_ENTRY (self->title_entry));
+  photos_utils_set_edited_name (urn, new_title);
+}
+
+static void
 photos_properties_sidebar_finalize (GObject *object)
 {
   G_OBJECT_CLASS (photos_properties_sidebar_parent_class)->finalize (object);
@@ -55,6 +69,7 @@ photos_properties_sidebar_class_init (PhotosPropertiesSidebarClass *klass)
   object_class->finalize = photos_properties_sidebar_finalize;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Photos/properties-sidebar.ui");
+  gtk_widget_class_bind_template_child (widget_class, PhotosPropertiesSidebar, title_entry);
 }
 
 static void
@@ -72,6 +87,8 @@ photos_properties_sidebar_clear (PhotosPropertiesSidebar *self)
       g_object_unref (self->item);
       self->item = NULL;
     }
+
+  gtk_entry_set_text (GTK_ENTRY (self->title_entry), "");
 }
 
 void
@@ -80,4 +97,10 @@ photos_properties_sidebar_set_item (PhotosPropertiesSidebar *self, PhotosBaseIte
   photos_properties_sidebar_clear (self);
 
   self->item = g_object_ref (item);
+
+  gtk_entry_set_text (GTK_ENTRY (self->title_entry), photos_base_item_get_name (item));
+  g_signal_connect_swapped (self->title_entry,
+                            "changed",
+                            G_CALLBACK (photos_properties_sidebar_name_update),
+                            self);
 }
diff --git a/src/photos-properties-sidebar.ui b/src/photos-properties-sidebar.ui
index ee0328d..4b61607 100644
--- a/src/photos-properties-sidebar.ui
+++ b/src/photos-properties-sidebar.ui
@@ -24,13 +24,34 @@
             <property name="orientation">vertical</property>
             <property name="row_spacing">12</property>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="hexpand">True</property>
-                <property name="label">Test Sidebar</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="label" translatable="yes">Title</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="title_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
             </child>
           </object>
         </child>


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