[glide] Hook the slide buttons up to something



commit c878c5f7cb7b1974702c9aaac2a87107f1c3f765
Author: Robert Carr <racarr Valentine localdomain>
Date:   Thu Apr 29 03:43:39 2010 -0400

    Hook the slide buttons up to something

 src/glide-slide-box.c    |    8 ++++++++
 src/glide-slide-button.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/glide-slide-box.c b/src/glide-slide-box.c
index 2a67e91..a9f85cd 100644
--- a/src/glide-slide-box.c
+++ b/src/glide-slide-box.c
@@ -19,6 +19,8 @@
 #include "glide-slide-box.h"
 #include "glide-slide-box-priv.h"
 
+#include "glide-slide-button.h"
+
 #define GLIDE_SLIDE_BOX_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GLIDE_TYPE_SLIDE_BOX, GlideSlideBoxPrivate))
 
 G_DEFINE_TYPE(GlideSlideBox, glide_slide_box, GTK_TYPE_VBOX);
@@ -34,6 +36,12 @@ glide_slide_box_document_slide_added (GlideDocument *document,
 				      gpointer data)
 {
   GlideSlideBox *box = (GlideSlideBox *)data;
+  GtkWidget *b = glide_slide_button_new ();
+  
+  gtk_box_pack_start (GTK_BOX (box), b, FALSE, FALSE, 0);
+  gtk_widget_show (b);  
+  
+  glide_slide_button_set_slide (GLIDE_SLIDE_BUTTON (b), slide);
   
   g_message ("Box %p slide added", box);
 }
diff --git a/src/glide-slide-button.c b/src/glide-slide-button.c
index 9c44f9a..6bd2b1e 100644
--- a/src/glide-slide-button.c
+++ b/src/glide-slide-button.c
@@ -29,6 +29,25 @@ enum {
 };
 
 static void
+glide_slide_button_update_label (GlideSlideButton *b)
+{
+  gchar *label = g_strdup_printf("%u", glide_slide_get_index (b->priv->slide));
+  
+  gtk_button_set_label (GTK_BUTTON (b), label);
+  g_free (label);
+}
+
+static void
+glide_slide_button_slide_index_changed_cb (GObject *object,
+					   GParamSpec *pspec,
+					   gpointer user_data)
+{
+  GlideSlideButton *b = (GlideSlideButton *)user_data;
+
+  glide_slide_button_update_label (b);
+}
+
+static void
 glide_slide_button_get_property (GObject *object,
 			      guint prop_id,
 			      GValue *value,
@@ -74,9 +93,19 @@ glide_slide_button_finalize (GObject *object)
 }
 
 static void
+glide_slide_button_clicked (GlideSlideButton *button, gpointer user_data)
+{
+  GlideStageManager *m = glide_actor_get_stage_manager (GLIDE_ACTOR (button->priv->slide));
+  
+  glide_stage_manager_set_current_slide (m, glide_slide_get_index (button->priv->slide));
+}
+
+static void
 glide_slide_button_init (GlideSlideButton *button)
 {
   button->priv = GLIDE_SLIDE_BUTTON_GET_PRIVATE (button);
+  
+  g_signal_connect (button, "clicked", G_CALLBACK (glide_slide_button_clicked), NULL);
 }
 
 static void
@@ -118,4 +147,9 @@ glide_slide_button_set_slide (GlideSlideButton *button,
 {
   button->priv->slide = slide;
   g_object_notify (G_OBJECT (button), "slide");
+  
+  glide_slide_button_update_label (button);
+  g_signal_connect (slide, "notify::index",
+		    G_CALLBACK (glide_slide_button_slide_index_changed_cb),
+		    button);
 }



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