[glide] Populate the theme box with theme previews



commit 43d8577c755d82bda552c476fcf88087e1e378e2
Author: Robert Carr <racarr Valentine localdomain>
Date:   Sat Jun 5 17:50:07 2010 -0400

    Populate the theme box with theme previews

 libglide/glide-theme-chooser.c |   49 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/libglide/glide-theme-chooser.c b/libglide/glide-theme-chooser.c
index 15e62a2..bf8fe51 100644
--- a/libglide/glide-theme-chooser.c
+++ b/libglide/glide-theme-chooser.c
@@ -98,7 +98,7 @@ glide_theme_chooser_make_layout (GlideThemeChooser *chooser)
   // TODO: What is the deal with references on these?
   ClutterLayoutManager *layout = clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL);
   
-  clutter_flow_layout_set_homogenous (CLUTTER_FLOW_LAYOUT (layout),
+  clutter_flow_layout_set_homogeneous (CLUTTER_FLOW_LAYOUT (layout),
 				      TRUE);
   clutter_flow_layout_set_column_spacing (CLUTTER_FLOW_LAYOUT (layout), 10);
   clutter_flow_layout_set_row_spacing (CLUTTER_FLOW_LAYOUT (layout),
@@ -109,6 +109,23 @@ glide_theme_chooser_make_layout (GlideThemeChooser *chooser)
   return layout;
 }
 
+static void
+glide_theme_chooser_populate_theme_box (GlideThemeChooser *chooser)
+{
+  GList *t;
+  
+  for (t = chooser->priv->themes; t; t = t->next)
+    {
+      GlideTheme *theme = (GlideTheme *)t->data;
+      ClutterActor *preview = glide_theme_preview_actor_new ();
+      
+      glide_theme_preview_actor_set_theme (GLIDE_THEME_PREVIEW_ACTOR (preview),
+					   theme);
+      
+      clutter_box_pack (CLUTTER_BOX (chooser->priv->theme_box), preview, NULL);
+    }
+}
+
 static ClutterActor *
 glide_theme_chooser_make_theme_box (GlideThemeChooser *chooser)
 {
@@ -116,18 +133,37 @@ glide_theme_chooser_make_theme_box (GlideThemeChooser *chooser)
   ClutterLayoutManager *layout = glide_theme_chooser_make_layout (chooser);
   
   box = clutter_box_new (layout);
+  clutter_actor_set_size (CLUTTER_ACTOR (box), 600, 400);
   
   chooser->priv->theme_box = box;
   
+  glide_theme_chooser_populate_theme_box (chooser);
+  
   return box;  
 }
 
 static void
+glide_theme_chooser_stage_allocation_changed (ClutterActor *stage,
+					      const ClutterActorBox *allocation,
+					      ClutterAllocationFlags flags,
+					      ClutterActor *box)
+{
+  gfloat width, height;
+  
+  clutter_actor_box_get_size (allocation, &width, &height);
+  clutter_actor_set_size (box, width, height);
+}
+
+static void
 glide_theme_chooser_populate_stage (GlideThemeChooser *chooser)
 {
   ClutterActor *box = glide_theme_chooser_make_theme_box (chooser);
   
   clutter_container_add_actor (CLUTTER_CONTAINER (chooser->priv->stage), box);
+  
+  g_signal_connect (chooser->priv->stage, "allocation-changed",
+		    G_CALLBACK (glide_theme_chooser_stage_allocation_changed),
+		    box);
 }
 
 static void
@@ -142,6 +178,8 @@ glide_theme_chooser_setup_stage (GlideThemeChooser *chooser)
   clutter_actor_show_all (stage);
   
   chooser->priv->stage = stage;
+  
+  glide_theme_chooser_populate_stage (chooser);
 }
 
 static GtkWidget *
@@ -152,7 +190,7 @@ glide_theme_chooser_make_clutter_embed (GlideThemeChooser *chooser)
   chooser->priv->embed = embed;
   glide_theme_chooser_setup_stage (chooser);
   
-  gtk_widget_set_size_request (embed, 600, 400);
+  gtk_widget_set_size_request (embed, 100, 400);
   
   return embed;
 }
@@ -163,7 +201,7 @@ glide_theme_chooser_make_top_hbox (GlideThemeChooser *chooser)
   GtkWidget *ret = gtk_hbox_new (FALSE, 0);
   GtkWidget *embed = glide_theme_chooser_make_clutter_embed (chooser);
   
-  gtk_box_pack_start (GTK_BOX (ret), embed, FALSE, 0, 0);
+  gtk_box_pack_start (GTK_BOX (ret), embed, TRUE, TRUE, 0);
   
   return ret;  
 }
@@ -192,7 +230,7 @@ glide_theme_chooser_make_main_vbox (GlideThemeChooser *chooser)
   top = glide_theme_chooser_make_top_hbox (chooser);
   bottom = glide_theme_chooser_make_bottom_hbox (chooser);
   
-  gtk_box_pack_start (GTK_BOX (ret), top, FALSE, 0, 0);
+  gtk_box_pack_start (GTK_BOX (ret), top, TRUE, 0, 0);
   gtk_box_pack_start (GTK_BOX (ret), bottom, FALSE, 0, 0);
   
   return ret;  
@@ -217,6 +255,9 @@ glide_theme_chooser_init (GlideThemeChooser *chooser)
   chooser->priv->themes = glide_theme_manager_get_themes ();
   
   glide_theme_chooser_setup_ui (chooser);
+  
+  gtk_window_set_default_size (GTK_WINDOW (chooser), 650, 450);
+
 }
 
 static void



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