[gnome-color-manager] Allow the user to flick between different images in the profile viewer



commit 980722ff81b754513500cd315386a0d298a0bf74
Author: Richard Hughes <richard hughsie com>
Date:   Thu Aug 5 13:56:43 2010 +0100

    Allow the user to flick between different images in the profile viewer

 data/figures/Makefile.am |    5 +++-
 data/gcm-viewer.ui       |   49 +++++++++++++++++++++++++++++++++----
 src/gcm-viewer.c         |   60 ++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 105 insertions(+), 9 deletions(-)
---
diff --git a/data/figures/Makefile.am b/data/figures/Makefile.am
index 26013c2..89b9dfb 100644
--- a/data/figures/Makefile.am
+++ b/data/figures/Makefile.am
@@ -1,6 +1,9 @@
 figuresdir = $(datadir)/gnome-color-manager/figures
 figures_DATA = 	 			\
-	viewer-example-00.png
+	viewer-example-00.png		\
+	viewer-example-01.png		\
+	viewer-example-02.png		\
+	viewer-example-03.png
 
 iconsdir = $(datadir)/gnome-color-manager/icons
 icons_DATA = 	 			\
diff --git a/data/gcm-viewer.ui b/data/gcm-viewer.ui
index 1434ddd..d89a4b1 100644
--- a/data/gcm-viewer.ui
+++ b/data/gcm-viewer.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
@@ -55,7 +55,7 @@
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkButton" id="button_profile_import">
-                            <property name="label" translatable="yes">_Add&#x2026;</property>
+                            <property name="label" translatable="yes">_Addâ?¦</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
@@ -200,6 +200,7 @@
                                             <child>
                                               <object class="GtkHBox" id="hbox60">
                                                 <property name="visible">True</property>
+                                                <property name="spacing">3</property>
                                                 <child>
                                                   <object class="GtkVBox" id="vbox_cie_axis">
                                                     <property name="orientation">vertical</property>
@@ -408,13 +409,31 @@
                                                   </packing>
                                                 </child>
                                                 <child>
+                                                  <object class="GtkButton" id="button_image_prev">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">True</property>
+                                                    <property name="use_action_appearance">False</property>
+                                                    <child>
+                                                      <object class="GtkImage" id="image2">
+                                                        <property name="visible">True</property>
+                                                        <property name="stock">gtk-media-previous</property>
+                                                      </object>
+                                                    </child>
+                                                  </object>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">3</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
                                                   <object class="GtkVBox" id="vbox_preview_input">
                                                     <property name="visible">True</property>
                                                     <property name="orientation">vertical</property>
                                                     <property name="spacing">6</property>
                                                     <child>
                                                       <object class="GtkLabel" id="label1">
-                                                        <property name="visible">True</property>
                                                         <property name="label" translatable="yes" comments="This is an example image that is saved in sRGB gamut">sRGB example</property>
                                                       </object>
                                                       <packing>
@@ -426,7 +445,7 @@
                                                   </object>
                                                   <packing>
                                                     <property name="expand">False</property>
-                                                    <property name="position">3</property>
+                                                    <property name="position">4</property>
                                                   </packing>
                                                 </child>
                                                 <child>
@@ -436,7 +455,6 @@
                                                     <property name="spacing">6</property>
                                                     <child>
                                                       <object class="GtkLabel" id="label2">
-                                                        <property name="visible">True</property>
                                                         <property name="label" translatable="yes">sRGB example</property>
                                                       </object>
                                                       <packing>
@@ -448,7 +466,26 @@
                                                   </object>
                                                   <packing>
                                                     <property name="expand">False</property>
-                                                    <property name="position">4</property>
+                                                    <property name="position">5</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkButton" id="button_image_next">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">True</property>
+                                                    <property name="use_action_appearance">False</property>
+                                                    <child>
+                                                      <object class="GtkImage" id="image3">
+                                                        <property name="visible">True</property>
+                                                        <property name="stock">gtk-media-next</property>
+                                                      </object>
+                                                    </child>
+                                                  </object>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">6</property>
                                                   </packing>
                                                 </child>
                                               </object>
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index 5774bb1..8496adb 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -50,6 +50,7 @@ typedef struct {
 	GtkWidget	*preview_widget_input;
 	GtkWidget	*preview_widget_output;
 	GSettings	*settings;
+	guint		 example_index;
 } GcmViewerPrivate;
 
 typedef enum {
@@ -80,6 +81,7 @@ enum {
 static void gcm_viewer_profile_store_changed_cb (GcmProfileStore *profile_store, GcmViewerPrivate *viewer);
 
 #define GCM_VIEWER_TREEVIEW_WIDTH		350 /* px */
+#define GCM_VIEWER_MAX_EXAMPLE_IMAGES		4
 
 /**
  * gcm_viewer_error_dialog:
@@ -108,6 +110,44 @@ gcm_viewer_close_cb (GtkWidget *widget, GcmViewerPrivate *viewer)
 }
 
 /**
+ * gcm_viewer_set_example_image:
+ **/
+static void
+gcm_viewer_set_example_image (GcmViewerPrivate *viewer, GtkImage *image)
+{
+	gchar *filename;
+	filename = g_strdup_printf ("%s/figures/viewer-example-%02i.png", GCM_DATA, viewer->example_index);
+	gtk_image_set_from_file (image, filename);
+	g_free (filename);
+}
+
+/**
+ * gcm_viewer_image_next_cb:
+ **/
+static void
+gcm_viewer_image_next_cb (GtkWidget *widget, GcmViewerPrivate *viewer)
+{
+	viewer->example_index++;
+	if (viewer->example_index == GCM_VIEWER_MAX_EXAMPLE_IMAGES)
+		viewer->example_index = 0;
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_input));
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_output));
+}
+
+/**
+ * gcm_viewer_image_prev_cb:
+ **/
+static void
+gcm_viewer_image_prev_cb (GtkWidget *widget, GcmViewerPrivate *viewer)
+{
+	if (viewer->example_index == 0)
+		viewer->example_index = GCM_VIEWER_MAX_EXAMPLE_IMAGES;
+	viewer->example_index--;
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_input));
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_output));
+}
+
+/**
  * gcm_viewer_preferences_cb:
  **/
 static void
@@ -955,6 +995,14 @@ gcm_viewer_graph_combo_changed_cb (GtkWidget *widget, GcmViewerPrivate *viewer)
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_preview_output"));
 	gtk_widget_set_visible (widget, active == GCM_VIEWER_PREVIEW_OUTPUT);
 
+	/* hide or show the buttons */
+	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "button_image_prev"));
+	gtk_widget_set_visible (widget, (active == GCM_VIEWER_PREVIEW_INPUT) ||
+					(active == GCM_VIEWER_PREVIEW_OUTPUT));
+	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "button_image_next"));
+	gtk_widget_set_visible (widget, (active == GCM_VIEWER_PREVIEW_INPUT) ||
+					(active == GCM_VIEWER_PREVIEW_OUTPUT));
+
 	/* save to GSettings */
 	g_settings_set_enum (viewer->settings, GCM_SETTINGS_PROFILE_GRAPH_TYPE, active);
 }
@@ -1096,6 +1144,14 @@ main (int argc, char **argv)
 	g_signal_connect (widget, "clicked",
 			  G_CALLBACK (gcm_viewer_profile_import_cb), viewer);
 
+	/* image next/prev */
+	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "button_image_next"));
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gcm_viewer_image_next_cb), viewer);
+	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "button_image_prev"));
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gcm_viewer_image_prev_cb), viewer);
+
 	/* hidden until a profile is selected */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_graph"));
 	gtk_widget_set_visible (widget, FALSE);
@@ -1131,14 +1187,14 @@ main (int argc, char **argv)
 	viewer->preview_widget_input = GTK_WIDGET (gcm_image_new ());
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_preview_input"));
 	gtk_box_pack_end (GTK_BOX(widget), viewer->preview_widget_input, FALSE, FALSE, 0);
-	gtk_image_set_from_file (GTK_IMAGE (viewer->preview_widget_input), GCM_DATA "/figures/viewer-example-00.png");
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_input));
 	gtk_widget_set_visible (viewer->preview_widget_input, TRUE);
 
 	/* use preview output */
 	viewer->preview_widget_output = GTK_WIDGET (gcm_image_new ());
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_preview_output"));
 	gtk_box_pack_end (GTK_BOX(widget), viewer->preview_widget_output, FALSE, FALSE, 0);
-	gtk_image_set_from_file (GTK_IMAGE (viewer->preview_widget_output), GCM_DATA "/figures/viewer-example-00.png");
+	gcm_viewer_set_example_image (viewer, GTK_IMAGE (viewer->preview_widget_output));
 	gtk_widget_set_visible (viewer->preview_widget_output, TRUE);
 
 	/* do we set a default size to make the window larger? */



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