Adding number editor example. Free the list used to detach menus. Fixes the MB#1065.
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Wed, 28 Feb 2007 12:25:38 +0000 (12:25 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Wed, 28 Feb 2007 12:25:38 +0000 (12:25 +0000)
ChangeLog.2
examples/Makefile.am
examples/hildon-color-button-example.c
examples/hildon-number-editor-example.c [new file with mode: 0644]
src/hildon-color-chooser-dialog.c
src/hildon-window.c

index 820ca08..3ef2eb6 100644 (file)
@@ -1,3 +1,13 @@
+2007-02-28  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
+       * examples/Makefile.am:
+       * examples/hildon-color-button-example.c:
+       * examples/hildon-number-editor-example.c: Adding number editor
+       example.
+
+       * src/hildon-window.c: Free the list used to detach menus. Fixes the
+       MB#1065.
+
 2007-02-19  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * doc/hildon.types:
index 40f6606..049e741 100644 (file)
@@ -23,7 +23,8 @@ noinst_PROGRAMS                               = hildon-window-example                 \
                                          hildon-toolbar-example                \
                                          hildon-code-dialog-example            \
                                          hildon-hvolumebar-example             \
-                                         hildon-lookup-example
+                                         hildon-lookup-example                 \
+                                         hildon-number-editor-example
 
 # HIldon window
 hildon_window_example_LDADD            = $(HILDON_OBJ_LIBS)
@@ -140,4 +141,9 @@ hildon_lookup_example_LDADD         = $(HILDON_OBJ_LIBS)
 hildon_lookup_example_CFLAGS           = $(HILDON_OBJ_CFLAGS)
 hildon_lookup_example_SOURCES          = hildon-lookup-example.c
 
+# Hildon number editor
+hildon_number_editor_example_LDADD     = $(HILDON_OBJ_LIBS)
+hildon_number_editor_example_CFLAGS    = $(HILDON_OBJ_CFLAGS)
+hildon_number_editor_example_SOURCES   = hildon-number-editor-example.c
+
 endif
index e534934..f455fa9 100644 (file)
@@ -47,6 +47,11 @@ main                                            (int argc,
 
     gtk_widget_show_all (GTK_WIDGET (dialog));
     gtk_dialog_run (dialog);
+
+    GdkColor *color;
+    g_object_get (G_OBJECT (button), "color", &color, NULL);
+
+    g_debug ("Color is: %d %d %d", color->red, color->green, color->blue);
     
     return 0;
 }
diff --git a/examples/hildon-number-editor-example.c b/examples/hildon-number-editor-example.c
new file mode 100644 (file)
index 0000000..78952ce
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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);
+    
+    GtkDialog *dialog = GTK_DIALOG (gtk_dialog_new ());
+    GtkWidget *editor = hildon_number_editor_new (2, 5);
+    GtkWidget *label = gtk_label_new ("Enter number:");
+    GtkWidget *hbox = gtk_hbox_new (FALSE, 12);
+
+    gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), editor, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, TRUE, TRUE, 0);
+
+    gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CLOSE);
+
+    gtk_widget_show_all (GTK_WIDGET (dialog));
+    gtk_dialog_run (dialog);
+
+    return 0;
+}
+
+
index 39618b8..69b2a37 100644 (file)
@@ -295,7 +295,6 @@ hildon_color_chooser_dialog_class_init          (HildonColorChooserDialogClass *
                 GTK_TYPE_BORDER,
                 G_PARAM_READABLE));
 
-
     gtk_widget_class_install_style_property (widget_klass,
             g_param_spec_boxed ("default_color", "Default color",
                 "Default color for nonpainted custom colors",
index e9970f4..d396d20 100644 (file)
@@ -757,7 +757,8 @@ hildon_window_destroy                           (GtkObject *obj)
 {
     HildonWindow *self = HILDON_WINDOW (obj);
     HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (obj);
-    GList *menu_list;
+    GList *menu_list = NULL;
+    GList *menu_node = NULL;
     
     g_assert (priv != NULL);
 
@@ -780,29 +781,31 @@ hildon_window_destroy                           (GtkObject *obj)
     }
 
     menu_list = g_list_copy (gtk_menu_get_for_attach_widget (GTK_WIDGET (obj)));
+    menu_node = menu_list;
 
-    while (menu_list)
+    while (menu_node)
     {
-        if (GTK_IS_MENU (menu_list->data))
+        if (GTK_IS_MENU (menu_node->data))
         {
-            if (GTK_WIDGET_VISIBLE (GTK_WIDGET (menu_list->data)))
+            if (GTK_WIDGET_VISIBLE (GTK_WIDGET (menu_node->data)))
             {
-                gtk_menu_popdown (GTK_MENU (menu_list->data));
-                gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_list->data));
+                gtk_menu_popdown (GTK_MENU (menu_node->data));
+                gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_node->data));
             }
-            gtk_menu_detach (GTK_MENU (menu_list->data));
+            gtk_menu_detach (GTK_MENU (menu_node->data));
 
             /* Destroy it, but only if it's not a common menu */
             if (priv->program && 
-                hildon_program_get_common_menu (priv->program) != menu_list->data) {
-                    g_object_unref (menu_list->data);
-                    gtk_object_destroy (GTK_OBJECT (menu_list->data));
+                hildon_program_get_common_menu (priv->program) != menu_node->data) {
+                    gtk_object_destroy (GTK_OBJECT (menu_node->data));
+                    g_object_unref (menu_node->data);
             }
         }
-        menu_list = menu_list->next;
+        menu_node = menu_node->next;
     }
 
     g_list_free (menu_list);
+    menu_list = NULL;
 
     if (priv->program)
     {