[maemo-commits] [maemo-commits] r10332 - in projects/haf/branches/hildon-libs/hildon-1: . examples src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Mar 2 17:00:46 EET 2007
- Previous message: [maemo-commits] r10331 - projects/haf/trunk/osso-af-startup/services
- Next message: [maemo-commits] r10333 - projects/haf/trunk/libosso/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: mdk Date: 2007-03-02 17:00:42 +0200 (Fri, 02 Mar 2007) New Revision: 10332 Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-scrolled-window-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/examples/hildon-caption-example.c projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.h Log: Adding an example to check scrolled window theming. Adding hildon_caption_set_label_markup to set markup on the caption. Fixes NB#51736. Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-03-02 15:00:42 UTC (rev 10332) @@ -1,3 +1,14 @@ +2007-03-02 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> + + * examples/Makefile.am: + * examples/hildon-caption-example.c: + * examples/hildon-scrolled-window-example.c: Adding an example to + check scrolled window theming. + + * src/hildon-caption.c: + * src/hildon-caption.h: Adding hildon_caption_set_label_markup to set + markup on the caption. Fixes NB#51736. + 2007-03-01 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> * src/hildon-banner.c: Small fix, check for NULL before comparing Modified: projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am 2007-03-02 15:00:42 UTC (rev 10332) @@ -24,7 +24,8 @@ hildon-code-dialog-example \ hildon-hvolumebar-example \ hildon-lookup-example \ - hildon-number-editor-example + hildon-number-editor-example \ + hildon-scrolled-window-example # HIldon window hildon_window_example_LDADD = $(HILDON_OBJ_LIBS) @@ -146,4 +147,9 @@ hildon_number_editor_example_CFLAGS = $(HILDON_OBJ_CFLAGS) hildon_number_editor_example_SOURCES = hildon-number-editor-example.c +# Hildon scrolled window +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 + endif Modified: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c 2007-03-02 15:00:42 UTC (rev 10332) @@ -46,15 +46,18 @@ gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON), 0); GtkWidget *caption4 = hildon_caption_new (size_group, "Check caption", gtk_check_button_new (), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON), 0); + GtkWidget *caption5 = hildon_caption_new (size_group, "", gtk_entry_new (), + NULL, 0); - hildon_caption_set_icon_position (HILDON_CAPTION (caption2), HILDON_CAPTION_POSITION_LEFT); hildon_caption_set_icon_position (HILDON_CAPTION (caption3), HILDON_CAPTION_POSITION_RIGHT); + hildon_caption_set_label_markup (HILDON_CAPTION (caption5), "<b>Bold caption</b>"); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption1, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption3, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption4, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (dialog->vbox), caption5, FALSE, FALSE, 0); gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CLOSE); Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-scrolled-window-example.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-scrolled-window-example.c 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-scrolled-window-example.c 2007-03-02 15:00:42 UTC (rev 10332) @@ -0,0 +1,67 @@ +/* + * 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); + + GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); + GtkWidget *vbox = gtk_vbox_new (6, FALSE); + int i = 0; + + for (i = 0; i < 20; i++) { + gchar *str = g_strdup_printf ("This is one more line of %d", i); + GtkWidget *label = gtk_label_new (str); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + g_free (str); + } + + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), vbox); + + gtk_container_add (GTK_CONTAINER (window), scrolled_window); + + g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); + gtk_widget_show_all (GTK_WIDGET (window)); + + gtk_main (); + return 0; +} + + Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c 2007-03-02 15:00:42 UTC (rev 10332) @@ -118,7 +118,8 @@ GdkEventButton *event); static void -hildon_caption_set_label_text (HildonCaptionPrivate *priv); +hildon_caption_set_label_text (HildonCaptionPrivate *priv, + gboolean markup); static void hildon_caption_set_child_property (GtkContainer *container, @@ -138,6 +139,7 @@ { PROP_0, PROP_LABEL, + PROP_MARKUP, PROP_ICON, PROP_STATUS, PROP_SEPARATOR, @@ -232,6 +234,16 @@ g_param_spec_string ("label", "Current label", "Caption label", NULL, G_PARAM_READABLE | G_PARAM_WRITABLE) ); + + /** + * HildonCaption:markup: + * + * Caption markup. Mutually exclusive with label. + */ + g_object_class_install_property (gobject_class, PROP_MARKUP, + g_param_spec_string ("markup", + "Current markup", "Caption markup", + NULL, G_PARAM_WRITABLE) ); /** * HildonCaption:icon: @@ -408,9 +420,22 @@ /* Update label */ priv->text = g_value_dup_string (value); - hildon_caption_set_label_text (priv); + hildon_caption_set_label_text (priv, FALSE); break; + case PROP_MARKUP: + /* Free old label string */ + if (priv->text) + { + g_free (priv->text); + priv->text = NULL; + } + + /* Update label */ + priv->text = g_value_dup_string (value); + hildon_caption_set_label_text (priv, TRUE); + break; + case PROP_ICON: /* Remove old icon */ if (priv->icon) @@ -453,7 +478,7 @@ } priv->separator = g_value_dup_string (value); - hildon_caption_set_label_text (priv); + hildon_caption_set_label_text (priv, FALSE); break; default: @@ -1036,12 +1061,30 @@ hildon_caption_set_label (HildonCaption *caption, const gchar *label) { - g_return_if_fail (HILDON_IS_CAPTION(caption)); + g_return_if_fail (HILDON_IS_CAPTION (caption)); g_object_set (G_OBJECT(caption), "label", label, NULL); } /** + * hildon_caption_set_label_markup: + * @caption : a #HildonCaption + * @markup : the markup text to use + * + * Sets the label markup text that appears before the control. It acts like + * #hildon_caption_set_label but is using the markup text that allows to specify + * text properties such as bold or italic. + */ +void +hildon_caption_set_label_markup (HildonCaption *caption, + const gchar *markup) +{ + g_return_if_fail (HILDON_IS_CAPTION (caption)); + + g_object_set (G_OBJECT(caption), "markup", markup, NULL); +} + +/** * hildon_caption_get_label: * @caption : a #HildonCaption * @@ -1172,7 +1215,8 @@ } static void -hildon_caption_set_label_text (HildonCaptionPrivate *priv) +hildon_caption_set_label_text (HildonCaptionPrivate *priv, + gboolean markup) { gchar *tmp = NULL; g_assert (priv != NULL); @@ -1184,27 +1228,40 @@ /* Don't duplicate the separator, if the string already contains one */ if (g_str_has_suffix (priv->text, priv->separator)) { - gtk_label_set_text (GTK_LABEL (priv->label), priv->text); + if (markup) + gtk_label_set_markup (GTK_LABEL (priv->label), priv->text); + else + gtk_label_set_text (GTK_LABEL (priv->label), priv->text); } else { /* Append separator and set text */ tmp = g_strconcat( priv->text, priv->separator, NULL ); - gtk_label_set_text (GTK_LABEL( priv->label), tmp); + + if (markup) + gtk_label_set_markup (GTK_LABEL (priv->label), tmp); + else + gtk_label_set_text (GTK_LABEL (priv->label), tmp); + g_free (tmp); } } else { - gtk_label_set_text (GTK_LABEL (priv->label), priv->text); + if (markup) + gtk_label_set_markup (GTK_LABEL (priv->label), priv->text); + else + gtk_label_set_text (GTK_LABEL (priv->label), priv->text); } } else { /* Clear the label */ - gtk_label_set_text (GTK_LABEL (priv->label), "" ); + if (markup) + gtk_label_set_markup (GTK_LABEL (priv->label), ""); + else + gtk_label_set_text (GTK_LABEL (priv->label), "" ); } - } /** Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.h =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.h 2007-03-02 14:40:11 UTC (rev 10331) +++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.h 2007-03-02 15:00:42 UTC (rev 10332) @@ -161,6 +161,10 @@ gboolean hildon_caption_get_child_expand (const HildonCaption *caption); +void +hildon_caption_set_label_markup (HildonCaption *caption, + const gchar *markup); + G_END_DECLS #endif /* __HILDON_CAPTION_H__ */
- Previous message: [maemo-commits] r10331 - projects/haf/trunk/osso-af-startup/services
- Next message: [maemo-commits] r10333 - projects/haf/trunk/libosso/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]