[gnome-photos] embed: Derive from GtkClutterEmbed instead of ClutterBox



commit 9e105ef2503cf6bcf2c018781424f6396dc3fe90
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 9 14:33:36 2012 +0200

    embed: Derive from GtkClutterEmbed instead of ClutterBox
    
    There is a reason it is called Embed after all. This removes the code
    to create the GtkClutterEmbed from MainWindow.
    
    Based on the following patches from Cosimo Cecchi for gnome-documents:
    + f1a1ad5f31d1e1c02ecbbfe5d5cf831db845a623
    + d0d8a2d5fb9daa74c3ee4f1dc7fe25ed474e92fa

 src/photos-embed.c       |   56 +++++++++++++++++++++++-----------------------
 src/photos-embed.h       |    8 +++---
 src/photos-main-window.c |   27 ++-------------------
 3 files changed, 35 insertions(+), 56 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 931dae1..100fa39 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -21,7 +21,7 @@
 
 #include "config.h"
 
-#include <clutter-gtk/clutter-gtk.h>
+#include <clutter/clutter.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
 
@@ -62,7 +62,7 @@ struct _PhotosEmbedPrivate
 };
 
 
-G_DEFINE_TYPE (PhotosEmbed, photos_embed, CLUTTER_TYPE_BOX);
+G_DEFINE_TYPE (PhotosEmbed, photos_embed, GTK_CLUTTER_TYPE_EMBED);
 
 
 static void
@@ -322,15 +322,31 @@ static void
 photos_embed_init (PhotosEmbed *self)
 {
   PhotosEmbedPrivate *priv;
+  ClutterActor *actor;
+  ClutterActor *stage;
   ClutterActor *toolbar_actor;
+  ClutterBinLayout *overlay_layout;
   ClutterColor color = {255, 255, 255, 255};
+  ClutterConstraint *constraint;
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, PHOTOS_TYPE_EMBED, PhotosEmbedPrivate);
   priv = self->priv;
 
+  overlay_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER);
+  actor = clutter_box_new (CLUTTER_LAYOUT_MANAGER (overlay_layout));
+
+  stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (self));
+  constraint = clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0);
+  clutter_actor_add_constraint (actor, constraint);
+  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
+
   priv->contents_layout = clutter_box_layout_new ();
   clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (priv->contents_layout), TRUE);
   priv->contents_actor = clutter_box_new (priv->contents_layout);
+  clutter_bin_layout_add (overlay_layout,
+                          priv->contents_actor,
+                          CLUTTER_BIN_ALIGNMENT_FILL,
+                          CLUTTER_BIN_ALIGNMENT_FILL);
 
   priv->toolbar = photos_main_toolbar_new ();
   toolbar_actor = photos_main_toolbar_get_actor (priv->toolbar);
@@ -375,6 +391,11 @@ photos_embed_init (PhotosEmbed *self)
    */
 
   priv->selection_toolbar = photos_selection_toolbar_new (priv->contents_actor);
+  toolbar_actor = photos_selection_toolbar_get_actor (priv->selection_toolbar);
+  clutter_bin_layout_add (overlay_layout,
+                          toolbar_actor,
+                          CLUTTER_BIN_ALIGNMENT_FIXED,
+                          CLUTTER_BIN_ALIGNMENT_FIXED);
 
   priv->mode_cntrlr = photos_mode_controller_new ();
   g_signal_connect (priv->mode_cntrlr,
@@ -394,6 +415,8 @@ photos_embed_init (PhotosEmbed *self)
 
   priv->item_mngr = photos_item_manager_new ();
   g_signal_connect (priv->item_mngr, "active-changed", G_CALLBACK (photos_embed_active_changed), self);
+
+  gtk_widget_show (GTK_WIDGET (self));
 }
 
 
@@ -408,31 +431,8 @@ photos_embed_class_init (PhotosEmbedClass *class)
 }
 
 
-ClutterActor *
-photos_embed_new (ClutterBinLayout *layout)
+GtkWidget *
+photos_embed_new (void)
 {
-  PhotosEmbed *self;
-  PhotosEmbedPrivate *priv;
-  ClutterActor *toolbar_actor;
-  ClutterLayoutManager *overlay_layout;
-
-  g_return_val_if_fail (CLUTTER_IS_BIN_LAYOUT (layout), NULL);
-  self = g_object_new (PHOTOS_TYPE_EMBED, "layout-manager", CLUTTER_LAYOUT_MANAGER (layout), NULL);
-  priv = self->priv;
-
-  /* "layout-manager" being a non-construct property we can not use
-   * it from the constructed method :-(
-   */
-  overlay_layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (self));
-  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (overlay_layout),
-                          priv->contents_actor,
-                          CLUTTER_BIN_ALIGNMENT_FILL,
-                          CLUTTER_BIN_ALIGNMENT_FILL);
-  toolbar_actor = photos_selection_toolbar_get_actor (priv->selection_toolbar);
-  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (overlay_layout),
-                          toolbar_actor,
-                          CLUTTER_BIN_ALIGNMENT_FIXED,
-                          CLUTTER_BIN_ALIGNMENT_FIXED);
-
-  return CLUTTER_ACTOR (self);
+  return g_object_new (PHOTOS_TYPE_EMBED, NULL);
 }
diff --git a/src/photos-embed.h b/src/photos-embed.h
index 2915bc6..efdc4a7 100644
--- a/src/photos-embed.h
+++ b/src/photos-embed.h
@@ -21,7 +21,7 @@
 #ifndef PHOTOS_EMBED_H
 #define PHOTOS_EMBED_H
 
-#include <clutter/clutter.h>
+#include <clutter-gtk/clutter-gtk.h>
 
 G_BEGIN_DECLS
 
@@ -53,18 +53,18 @@ typedef struct _PhotosEmbedPrivate PhotosEmbedPrivate;
 
 struct _PhotosEmbed
 {
-  ClutterBox parent_instance;
+  GtkClutterEmbed parent_instance;
   PhotosEmbedPrivate *priv;
 };
 
 struct _PhotosEmbedClass
 {
-  ClutterBoxClass parent_class;
+  GtkClutterEmbedClass parent_class;
 };
 
 GType                  photos_embed_get_type               (void) G_GNUC_CONST;
 
-ClutterActor          *photos_embed_new                    (ClutterBinLayout *layout);
+GtkWidget             *photos_embed_new                    (void);
 
 G_END_DECLS
 
diff --git a/src/photos-main-window.c b/src/photos-main-window.c
index ea8631c..93f21ba 100644
--- a/src/photos-main-window.c
+++ b/src/photos-main-window.c
@@ -34,9 +34,7 @@
 
 struct _PhotosMainWindowPrivate
 {
-  ClutterActor *box;
-  ClutterActor *embed;
-  ClutterLayoutManager *box_layout;
+  GtkWidget *embed;
   GSettings *settings;
   GtkWidget *clutter_embed;
   PhotosModeController *controller;
@@ -254,7 +252,6 @@ photos_main_window_init (PhotosMainWindow *self)
   PhotosMainWindowPrivate *priv;
   ClutterActor *stage;
   ClutterConstraint *constraint;
-  ClutterLayoutManager *overlay_layout;
   GVariant *variant;
   gboolean maximized;
   const gint32 *position;
@@ -264,10 +261,6 @@ photos_main_window_init (PhotosMainWindow *self)
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, PHOTOS_TYPE_MAIN_WINDOW, PhotosMainWindowPrivate);
   priv = self->priv;
 
-  priv->clutter_embed = gtk_clutter_embed_new ();
-  gtk_container_add (GTK_CONTAINER (self), priv->clutter_embed);
-  gtk_widget_show (priv->clutter_embed);
-
   priv->settings = photos_settings_new ();
 
   variant = g_settings_get_value (priv->settings, "window-size");
@@ -292,22 +285,8 @@ photos_main_window_init (PhotosMainWindow *self)
                     G_CALLBACK (photos_main_window_fullscreen_changed),
                     self);
 
-  stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutter_embed));
-
-  priv->box_layout = clutter_box_layout_new ();
-  clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (priv->box_layout), TRUE);
-
-  priv->box = clutter_box_new (priv->box_layout);
-  constraint = clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0);
-  clutter_actor_add_constraint (priv->box, constraint);
-
-  clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->box);
-
-  overlay_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER);
-  priv->embed = photos_embed_new (CLUTTER_BIN_LAYOUT (overlay_layout));
-  clutter_container_add_actor (CLUTTER_CONTAINER (priv->box), priv->embed);
-  clutter_box_layout_set_expand (CLUTTER_BOX_LAYOUT (priv->box_layout), priv->embed, TRUE);
-  clutter_box_layout_set_fill (CLUTTER_BOX_LAYOUT (priv->box_layout), priv->embed, TRUE, TRUE);
+  priv->embed = photos_embed_new ();
+  gtk_container_add (GTK_CONTAINER (self), priv->embed);
 }
 
 



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