aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.210
-rw-r--r--examples/hildon-controlbar-example.c23
-rw-r--r--src/hildon-banner-private.h3
-rw-r--r--src/hildon-banner.c19
-rw-r--r--src/hildon-controlbar.c14
5 files changed, 52 insertions, 17 deletions
diff --git a/ChangeLog.2 b/ChangeLog.2
index 3e718da..c105209 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -1,3 +1,13 @@
+2007-02-05 Michael Dominic Kostrzewa <michael.kostrzewa@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@nokia.com>
* src/hildon-find-toolbar.c: Fixing the documentation for the
diff --git a/examples/hildon-controlbar-example.c b/examples/hildon-controlbar-example.c
index 1b6a378..157e799 100644
--- a/examples/hildon-controlbar-example.c
+++ b/examples/hildon-controlbar-example.c
@@ -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 @@ main (int argc,
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 ();
diff --git a/src/hildon-banner-private.h b/src/hildon-banner-private.h
index 1134ba4..84f41a4 100644
--- a/src/hildon-banner-private.h
+++ b/src/hildon-banner-private.h
@@ -39,7 +39,8 @@ struct _HildonBannerPrivate
GtkWidget *label;
GtkWidget *layout;
guint timeout_id;
- gboolean is_timed;
+ gboolean is_timed;
+ GtkWindow *parent;
};
/* For internal use of hildon libraries only */
diff --git a/src/hildon-banner.c b/src/hildon-banner.c
index 5d347b0..5a906dd 100644
--- a/src/hildon-banner.c
+++ b/src/hildon-banner.c
@@ -393,6 +393,7 @@ hildon_banner_set_property (GObject *object,
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 @@ hildon_banner_destroy (GtkObject *object)
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 @@ hildon_banner_destroy (GtkObject *object)
}
/* 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 @@ static GObject*
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,7 +680,9 @@ static void
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 @@ hildon_banner_ensure_child (HildonBanner *self,
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 @@ hildon_banner_ensure_child (HildonBanner *self,
/* 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 @@ hildon_banner_get_instance_for_widget (GtkWidget *widget,
{
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);
}
diff --git a/src/hildon-controlbar.c b/src/hildon-controlbar.c
index cc703eb..1584cc0 100644
--- a/src/hildon-controlbar.c
+++ b/src/hildon-controlbar.c
@@ -282,7 +282,7 @@ hildon_controlbar_init (HildonControlbar *controlbar)
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 @@ hildon_controlbar_change_value (GtkRange *range,
{
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 @@ hildon_controlbar_change_value (GtkRange *range,
default:
break;
}
- return FALSE;
+
+ GTK_RANGE_CLASS (parent_class)->change_value (range, scroll, calc);
+
+ return TRUE;
}
/*
@@ -796,13 +801,12 @@ hildon_controlbar_paint (HildonControlbar *self,
"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 @@ hildon_controlbar_paint (HildonControlbar *self,
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 */