Adding a hildon_helper_set_thumb_scrollbar function to enable/disable a thumb scrollb...
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Tue, 27 Mar 2007 08:37:46 +0000 (08:37 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Tue, 27 Mar 2007 08:37:46 +0000 (08:37 +0000)
ChangeLog.2
examples/Makefile.am
examples/hildon-thumb-scrollbar-example.c [new file with mode: 0644]
src/hildon-helper.c
src/hildon-helper.h

index cf4f9b2..aad39ef 100644 (file)
@@ -1,3 +1,14 @@
+2007-03-27  Michael Dominic Kostrzewa  <michael.kostrzewa@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@nokia.com> 
 
        * src/Makefile.am: Actually take the libtool versioning into account.
index fcaff4b..0b7c18b 100644 (file)
@@ -26,7 +26,8 @@ noinst_PROGRAMS                               = hildon-window-example                 \
                                          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_LDADD        = $(HILDON_OBJ_LIBS)
 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
diff --git a/examples/hildon-thumb-scrollbar-example.c b/examples/hildon-thumb-scrollbar-example.c
new file mode 100644 (file)
index 0000000..4ae4c75
--- /dev/null
@@ -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@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;
+}
+
+
index d1f0647..2e40e43 100644 (file)
@@ -379,3 +379,30 @@ hildon_helper_set_logical_color                 (GtkWidget *widget,
 }
 
 
+/**
+ *
+ * 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);
+}
+
+
+
+
index 44e1c8f..5efa986 100644 (file)
@@ -53,6 +53,10 @@ hildon_helper_set_insensitive_messagef          (GtkWidget *widget,
                                                 const gchar *format,
                                                 ...);
 
+void
+hildon_helper_set_thumb_scrollbar               (GtkScrolledWindow *win, 
+                                                 gboolean thumb);
+
 G_END_DECLS
 
 #endif                                          /* HILDON_HELPER_H */