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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Feb 5 17:03:43 EET 2007
Author: mdk
Date: 2007-02-05 17:03:42 +0200 (Mon, 05 Feb 2007)
New Revision: 9645

Modified:
   projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2
   projects/haf/branches/hildon-libs/hildon-1/examples/hildon-controlbar-example.c
   projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner-private.h
   projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner.c
   projects/haf/branches/hildon-libs/hildon-1/src/hildon-controlbar.c
Log:
Fixing the controlbar to behave as if minimal-bars-visible (old 2.6 mod) was equal 1.
Fixing the problem with two information banners being spawned one after another.



Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2	2007-02-05 14:55:09 UTC (rev 9644)
+++ projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2	2007-02-05 15:03:42 UTC (rev 9645)
@@ -1,3 +1,13 @@
+2007-02-05  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
+
+	* examples/hildon-controlbar-example.c:
+	* src/hildon-controlbar.c: Fixing the controlbar to behave as if
+	minimal-bars-visible (old 2.6 mod) was equal 1.
+
+	* src/hildon-banner-private.h:
+	* src/hildon-banner.c: Fixing the problem with two information banners
+	being spawned one after another.
+
 2007-02-04  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
 
 	* src/hildon-find-toolbar.c: Fixing the documentation for the

Modified: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-controlbar-example.c
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-controlbar-example.c	2007-02-05 14:55:09 UTC (rev 9644)
+++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-controlbar-example.c	2007-02-05 15:03:42 UTC (rev 9645)
@@ -28,6 +28,16 @@
 #include                                        <gtk/gtk.h>
 #include                                        "hildon.h"
 
+static gboolean
+on_show_value_clicked                           (GtkWidget *widget, HildonControlbar *bar)
+{
+    g_assert (HILDON_IS_CONTROLBAR (bar));
+
+    g_debug ("Value is: %d", hildon_controlbar_get_value (bar));
+
+    return TRUE;
+}
+
 int
 main                                            (int argc, 
                                                  char **args)
@@ -42,11 +52,18 @@
     gtk_container_set_border_width (GTK_CONTAINER (window), 6);
     
     HildonControlbar *bar = HILDON_CONTROLBAR (hildon_controlbar_new ());
-    hildon_controlbar_set_range (bar, 20, 120);
-    hildon_controlbar_set_value (bar, 100);
+    hildon_controlbar_set_range (bar, 1, 4);
+    hildon_controlbar_set_value (bar, 2);
+    GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
+    GtkButton *button = GTK_BUTTON (gtk_button_new_with_label ("Show value"));
 
     g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (bar));
+    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_show_value_clicked), bar);
+
+    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (bar), FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button), FALSE, FALSE, 0);
+
+    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
     gtk_widget_show_all (GTK_WIDGET (window));
     
     gtk_main ();

Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner-private.h
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner-private.h	2007-02-05 14:55:09 UTC (rev 9644)
+++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner-private.h	2007-02-05 15:03:42 UTC (rev 9645)
@@ -39,7 +39,8 @@
     GtkWidget *label;
     GtkWidget *layout;
     guint timeout_id;
-    gboolean is_timed; 
+    gboolean is_timed;
+    GtkWindow *parent;
 };
 
 /* For internal use of hildon libraries only */

Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner.c
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner.c	2007-02-05 14:55:09 UTC (rev 9644)
+++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-banner.c	2007-02-05 15:03:42 UTC (rev 9645)
@@ -393,6 +393,7 @@
             window = g_value_get_object (value);         
 
             gtk_window_set_transient_for (GTK_WINDOW (object), (GtkWindow *) window);
+            priv->parent = (GtkWindow *) window;
 
             if (window)
                 gtk_window_set_destroy_with_parent (GTK_WINDOW (object), TRUE);
@@ -437,7 +438,7 @@
     g_assert (priv);
 
     HildonBanner *self;
-    GObject *parent_window;
+    GObject *parent_window = (GObject *) priv->parent;
 
     g_assert (HILDON_IS_BANNER (object));
     self = HILDON_BANNER (object);
@@ -449,8 +450,9 @@
     }
 
     /* Remove the data from parent window for timed banners. Those hold reference */
-    if (priv->is_timed && (parent_window = (GObject *) gtk_window_get_transient_for (GTK_WINDOW (object))) != NULL)
+    if (priv->is_timed && parent_window != NULL) {
         g_object_set_qdata (parent_window, hildon_banner_timed_quark (), NULL);
+    }
 
     (void) hildon_banner_clear_timeout (self);
 
@@ -463,12 +465,11 @@
 hildon_banner_real_get_instance                 (GObject *window, 
                                                  gboolean timed)
 {
-    g_assert (GTK_IS_WINDOW (window));
-
     if (timed) {
         /* If we have a parent window, the previous instance is stored there */
-        if (window) 
+        if (window) {
             return g_object_get_qdata(window, hildon_banner_timed_quark ());
+        }
 
         /* System notification instance is stored into global pointer */
         return (GObject *) global_timed_banner;
@@ -679,8 +680,10 @@
 hildon_banner_init                              (HildonBanner *self)
 {
     HildonBannerPrivate *priv = HILDON_BANNER_GET_PRIVATE (self);
-    g_assert (self);
+    g_assert (priv);
 
+    priv->parent = NULL;
+
     /* Initialize the common layout inside banner */
     priv->layout = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
 
@@ -709,7 +712,6 @@
     va_list args;
     HildonBannerPrivate *priv = HILDON_BANNER_GET_PRIVATE (self);
 
-    g_assert (HILDON_IS_BANNER (self));
     g_assert (priv);
 
     widget = priv->main_item;
@@ -725,7 +727,7 @@
         /* We have to abandon old content widget */
         if (widget)
             gtk_container_remove (GTK_CONTAINER (priv->layout), widget);
-
+        
         /* Use user provided widget or create a new one */
         priv->main_item = widget = user_widget ? 
             user_widget : GTK_WIDGET (g_object_new_valist(type, first_property, args));
@@ -745,7 +747,6 @@
 {
     GtkWidget *window;
 
-    g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
     window = widget ? gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) : NULL;
     return g_object_new (HILDON_TYPE_BANNER, "parent-window", window, "is-timed", timed, NULL);
 }

Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-controlbar.c
===================================================================
--- projects/haf/branches/hildon-libs/hildon-1/src/hildon-controlbar.c	2007-02-05 14:55:09 UTC (rev 9644)
+++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-controlbar.c	2007-02-05 15:03:42 UTC (rev 9645)
@@ -282,7 +282,7 @@
             DEFAULT_HEIGHT);
 
     g_signal_connect (range, "change-value",
-            G_CALLBACK (hildon_controlbar_change_value), NULL );
+            G_CALLBACK (hildon_controlbar_change_value), NULL);
 }
 
 static GObject*
@@ -648,6 +648,8 @@
 {
     HildonControlbarPrivate *priv;
     GtkAdjustment *adj = range->adjustment;
+    gdouble vv = adj->upper - adj->lower;
+    gint calc = ((new_value - adj->lower) / vv) * (vv + 1.0) + adj->lower;
 
     priv = HILDON_CONTROLBAR_GET_PRIVATE(range);
     g_assert (priv);
@@ -672,7 +674,10 @@
         default:
             break;
     }
-    return FALSE;
+
+    GTK_RANGE_CLASS (parent_class)->change_value (range, scroll, calc);
+
+    return TRUE;
 }
 
 /*
@@ -796,13 +801,12 @@
             "stepper-spacing", &stepper_spacing,
             "inner_border_width", &inner_border_width, NULL);
 
-    g_object_get (G_OBJECT (self), "minimum_visible_bars", &block_min, NULL);
-
     block_area = (w - 2 * stepper_size - 2 * stepper_spacing - 2 * inner_border_width);
 
     if (block_area <= 0)
         return;
 
+    block_min = 1;
     block_max = ctrlbar->upper - ctrlbar->lower + block_min; 
     block_act = priv->old_value - GTK_RANGE (self)->adjustment->lower + block_min;
 
@@ -844,6 +848,8 @@
 
     block_count = ctrlbar->value - ctrlbar->lower +  block_min;
 
+    if (block_count == 0)
+            block_count = 1;
     /* Without this there is vertical block corruption when block_height = 
        1. This should work from 0 up to whatever */
 


More information about the maemo-commits mailing list