[maemo-commits] [maemo-commits] r10773 - in projects/haf/branches/hildon-libs/hildon-1: . examples src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Mar 27 11:37:47 EEST 2007
Author: mdk
Date: 2007-03-27 11:37:46 +0300 (Tue, 27 Mar 2007)
New Revision: 10773

Added:
   projects/haf/branches/hildon-libs/hildon-1/examples/hildon-thumb-scrollbar-example.c
Modified:
   projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2
   projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am
   projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.c
   projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.h
Log:
Adding a hildon_helper_set_thumb_scrollbar function to enable/disable a thumb scrollbar on a GtkScrolledWindow.
Adding an example that demoes the thumb scrollbar functionality.


Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2	2007-03-27 06:34:45 UTC (rev 10772)
+++ projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2	2007-03-27 08:37:46 UTC (rev 10773)
@@ -1,3 +1,14 @@
+2007-03-27  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
+
+	* src/hildon-helper.c:
+	* src/hildon-helper.h: Adding a hildon_helper_set_thumb_scrollbar
+	function to enable/disable a thumb scrollbar on a GtkScrolledWindow.
+	Note: requires a 'hildon-thumb-scrollbar' style defined in the theme.
+
+	* examples/Makefile.am:
+	* examples/hildon-thumb-scrollbar-example.c: Example that demoes the
+	thumb scrollbar functionality.
+
 2007-03-26  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
 
 	* src/Makefile.am: Actually take the libtool versioning into account.

Modified: projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am	2007-03-27 06:34:45 UTC (rev 10772)
+++ projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am	2007-03-27 08:37:46 UTC (rev 10773)
@@ -26,7 +26,8 @@
 					  hildon-lookup-example			\
 					  hildon-number-editor-example		\
 					  hildon-scrolled-window-example	\
-					  hildon-color-pop-example
+					  hildon-color-pop-example		\
+					  hildon-thumb-scrollbar-example
 
 # HIldon window
 hildon_window_example_LDADD		= $(HILDON_OBJ_LIBS)
@@ -158,4 +159,9 @@
 hildon_scrolled_window_example_CFLAGS	= $(HILDON_OBJ_CFLAGS)
 hildon_scrolled_window_example_SOURCES	= hildon-scrolled-window-example.c
 
+# Hildon thumb scrollbar example
+hildon_thumb_scrollbar_example_LDADD	= $(HILDON_OBJ_LIBS)
+hildon_thumb_scrollbar_example_CFLAGS	= $(HILDON_OBJ_CFLAGS)
+hildon_thumb_scrollbar_example_SOURCES	= hildon-thumb-scrollbar-example.c
+
 endif

Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-thumb-scrollbar-example.c
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-thumb-scrollbar-example.c	2007-03-27 06:34:45 UTC (rev 10772)
+++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-thumb-scrollbar-example.c	2007-03-27 08:37:46 UTC (rev 10773)
@@ -0,0 +1,69 @@
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ *
+ * Author: Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include                                        <stdio.h>
+#include                                        <stdlib.h>
+#include                                        <glib.h>
+#include                                        <gtk/gtk.h>
+#include                                        "hildon.h"
+
+int
+main                                            (int argc, 
+                                                 char **args)
+{
+    gtk_init (&argc, &args);
+    
+    HildonProgram *program = hildon_program_get_instance ();
+
+    GtkWidget *window = hildon_window_new ();
+    hildon_program_add_window (program, HILDON_WINDOW (window));    
+
+    gtk_container_set_border_width (GTK_CONTAINER (window), 6);
+    
+    GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
+    gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+    hildon_helper_set_thumb_scrollbar (scrolled, TRUE);
+
+    GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
+    int i;
+
+    for (i = 0; i < 30; i++) {
+            GtkLabel *label = GTK_LABEL (gtk_label_new (""));
+            gchar *content = g_strdup_printf ("<big><big><big>Content %d</big></big></big>", i);
+            gtk_label_set_markup (label, content);
+            g_free (content);
+            gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (label), TRUE, TRUE, 0);
+    }
+
+    gtk_scrolled_window_add_with_viewport (scrolled, GTK_WIDGET (vbox));
+
+    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (scrolled));
+    gtk_widget_show_all (GTK_WIDGET (window));
+    
+    gtk_main ();
+    return 0;
+}
+
+

Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.c
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.c	2007-03-27 06:34:45 UTC (rev 10772)
+++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.c	2007-03-27 08:37:46 UTC (rev 10773)
@@ -379,3 +379,30 @@
 }
 
 
+/**
+ *
+ * hildon_helper_set_thumb_scrollbar
+ * @win: A @GtkScrolledWindow to use as target
+ * @thumb: TRUE to enable the thumb scrollbar, FALSE to disable
+ *
+ * This function enables a thumb scrollbar on a given scrolled window. It'll convert the
+ * existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus. 
+ * As fingerable list rows are fairly high, consider using the whole available vertical space 
+ * of your application for the content in order to have as many rows as possible 
+ * visible on the screen at once. 
+ *
+ * Finger-Sized scrollbar should always be used together with finger-sized content.
+ **/
+void
+hildon_helper_set_thumb_scrollbar               (GtkScrolledWindow *win, 
+                                                 gboolean thumb)
+{
+        g_return_if_fail (GTK_IS_SCROLLED_WINDOW (win));
+
+        if (win->vscrollbar) 
+                gtk_widget_set_name (win->vscrollbar, (thumb) ? "hildon-thumb-scrollbar" : NULL);
+}
+
+
+
+

Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.h
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.h	2007-03-27 06:34:45 UTC (rev 10772)
+++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-helper.h	2007-03-27 08:37:46 UTC (rev 10773)
@@ -53,6 +53,10 @@
 						 const gchar *format,
 						 ...);
 
+void
+hildon_helper_set_thumb_scrollbar               (GtkScrolledWindow *win, 
+                                                 gboolean thumb);
+
 G_END_DECLS
 
 #endif                                          /* HILDON_HELPER_H */


More information about the maemo-commits mailing list