[gnome-photos] view-embed: Create the SelectionToolbar



commit c9875bda80b8229e6af649d3c210a747f4999326
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Apr 27 21:51:53 2012 +0200

    view-embed: Create the SelectionToolbar

 src/photos-view-embed.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-view-embed.c b/src/photos-view-embed.c
index b04e699..6573326 100644
--- a/src/photos-view-embed.c
+++ b/src/photos-view-embed.c
@@ -26,6 +26,7 @@
 
 #include "photos-main-toolbar.h"
 #include "photos-mode-controller.h"
+#include "photos-selection-toolbar.h"
 #include "photos-view-embed.h"
 
 
@@ -35,10 +36,12 @@ struct _PhotosViewEmbedPrivate
   ClutterActor *contents_actor;
   ClutterActor *notebook_actor;
   ClutterActor *view_actor;
+  ClutterConstraint *width_constraint;
   ClutterLayoutManager *contents_layout;
   ClutterLayoutManager *view_layout;
   GtkWidget *notebook;
   PhotosMainToolbar *toolbar;
+  PhotosSelectionToolbar *selection_toolbar;
   PhotosModeController *mode_cntrlr;
 };
 
@@ -62,6 +65,24 @@ photos_view_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
 
 
 static void
+photos_view_embed_selection_toolbar_notify_width (GObject *object, GParamSpec *pspec, gpointer user_data)
+{
+  PhotosViewEmbed *self = PHOTOS_VIEW_EMBED (user_data);
+  PhotosViewEmbedPrivate *priv = self->priv;
+  gfloat offset = 300.0;
+  gfloat width;
+
+  width = clutter_actor_get_width (priv->contents_actor);
+  if (width > 1000)
+    offset += (width - 1000);
+  else if (width < 600)
+    offset -= (600 - width);
+
+  clutter_bind_constraint_set_offset (CLUTTER_BIND_CONSTRAINT (priv->width_constraint), -1 * offset);
+}
+
+
+static void
 photos_view_embed_dispose (GObject *object)
 {
   PhotosViewEmbed *self = PHOTOS_VIEW_EMBED (object);
@@ -83,6 +104,7 @@ photos_view_embed_init (PhotosViewEmbed *self)
   PhotosViewEmbedPrivate *priv;
   ClutterActor *toolbar_actor;
   ClutterColor color = {255, 255, 255, 255};
+  ClutterConstraint *constraint;
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, PHOTOS_TYPE_VIEW_EMBED, PhotosViewEmbedPrivate);
   priv = self->priv;
@@ -123,10 +145,25 @@ photos_view_embed_init (PhotosViewEmbed *self)
   clutter_actor_lower_bottom (priv->background);
 
   /* TODO: SearchBar.Dropdown,
-   *       SelectionToolbar,
    *       ...
    */
 
+  priv->selection_toolbar = photos_selection_toolbar_new();
+  toolbar_actor = photos_selection_toolbar_get_actor (priv->selection_toolbar);
+
+  priv->width_constraint = clutter_bind_constraint_new (priv->contents_actor, CLUTTER_BIND_WIDTH, -300.0);
+  clutter_actor_add_constraint (toolbar_actor, priv->width_constraint);
+  g_signal_connect (toolbar_actor,
+                    "notify::width",
+                    G_CALLBACK (photos_view_embed_selection_toolbar_notify_width),
+                    self);
+
+  constraint = clutter_align_constraint_new (priv->contents_actor, CLUTTER_ALIGN_X_AXIS, 0.50);
+  clutter_actor_add_constraint (toolbar_actor, constraint);
+
+  constraint = clutter_align_constraint_new (priv->contents_actor, CLUTTER_ALIGN_Y_AXIS, 0.95);
+  clutter_actor_add_constraint (toolbar_actor, constraint);
+
   priv->mode_cntrlr = photos_mode_controller_new ();
   g_signal_connect (priv->mode_cntrlr,
                     "window-mode-changed",



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