[maemo-commits] [maemo-commits] r9745 - in projects/haf/branches/hildon-libs/hildon-1: . examples src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Feb 8 14:55:16 EET 2007
- Previous message: [maemo-commits] r9744 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r9746 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gtk tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: mdk Date: 2007-02-08 14:55:14 +0200 (Thu, 08 Feb 2007) New Revision: 9745 Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-cmn-menu-example.c projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-menu-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/src/hildon-program.c projects/haf/branches/hildon-libs/hildon-1/src/hildon-window.c Log: Adding a common menu example and a window menu example. Fixing the problem with menu refcounting in HildonWindow. Adding some documentation to HIldonProgram. Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-02-08 12:55:14 UTC (rev 9745) @@ -1,3 +1,18 @@ +2007-02-08 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> + + * examples/Makefile.am: + * examples/hildon-window-cmn-menu-example.c: + * examples/hildon-window-menu-example.c: Adding a common menu example + and a window menu example. + + * src/hildon-program.c: Adding a note to the documentation about + HildonProgram reffing. Fixes MB#867. + + * src/hildon-window.c: Fixing the menu ref counting problem. Now + applications are NOT supposed to take care about menu destroying since + the HildonWindow handles that. Adding this to the documentation. Fixes + NB#46434. + 2007-02-07 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> * src/hildon-program.c: Modified: projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/examples/Makefile.am 2007-02-08 12:55:14 UTC (rev 9745) @@ -16,7 +16,9 @@ hildon-icon-sizes-example \ hildon-insensitive-example \ hildon-get-password-dialog-example \ - hildon-set-password-dialog-example + hildon-set-password-dialog-example \ + hildon-window-menu-example \ + hildon-window-cmn-menu-example # HIldon window hildon_window_example_LDADD = $(HILDON_OBJ_LIBS) @@ -98,4 +100,14 @@ hildon_set_password_dialog_example_CFLAGS = $(HILDON_OBJ_CFLAGS) hildon_set_password_dialog_example_SOURCES = hildon-set-password-dialog-example.c +# HIldon window menu example +hildon_window_menu_example_LDADD = $(HILDON_OBJ_LIBS) +hildon_window_menu_example_CFLAGS = $(HILDON_OBJ_CFLAGS) +hildon_window_menu__example_SOURCES = hildon-window-menu-example.c + +# HIldon window common menu example +hildon_window_cmn_menu_example_LDADD = $(HILDON_OBJ_LIBS) +hildon_window_cmn_menu_example_CFLAGS = $(HILDON_OBJ_CFLAGS) +hildon_window_cmn_menu_example_SOURCES = hildon-window-cmn-menu-example.c + endif Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-cmn-menu-example.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-cmn-menu-example.c 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-cmn-menu-example.c 2007-02-08 12:55:14 UTC (rev 9745) @@ -0,0 +1,56 @@ +/* + * 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)); + + GtkMenu *menu = GTK_MENU (gtk_menu_new ()); + GtkWidget *menu_item = gtk_menu_item_new_with_label ("Test common item"); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + hildon_program_set_common_menu (program, menu); + + 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; +} + + Added: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-menu-example.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-menu-example.c 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-window-menu-example.c 2007-02-08 12:55:14 UTC (rev 9745) @@ -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 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)); + + GtkMenu *menu = GTK_MENU (gtk_menu_new ()); + GtkWidget *menu_item = gtk_menu_item_new_with_label ("Test item"); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + hildon_window_set_menu (HILDON_WINDOW (window), menu); + + 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-program.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/src/hildon-program.c 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-program.c 2007-02-08 12:55:14 UTC (rev 9745) @@ -381,7 +381,8 @@ * hildon_program_get_instance: * * Return value: Returns the #HildonProgram for the current process. - * The object is created on the first call. + * The object is created on the first call. Note that you're not supposed + * to unref the returned object since it's not reffed in the first place. **/ HildonProgram* hildon_program_get_instance (void) Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-window.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/src/hildon-window.c 2007-02-08 09:59:16 UTC (rev 9744) +++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-window.c 2007-02-08 12:55:14 UTC (rev 9745) @@ -783,7 +783,7 @@ while (menu_list) { - if (GTK_IS_MENU(menu_list->data)) + if (GTK_IS_MENU (menu_list->data)) { if (GTK_WIDGET_VISIBLE (GTK_WIDGET (menu_list->data))) { @@ -791,6 +791,13 @@ gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_list->data)); } gtk_menu_detach (GTK_MENU (menu_list->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)); + } } menu_list = menu_list->next; } @@ -1708,9 +1715,10 @@ * hildon_window_get_menu: * @self : #HildonWindow * - * Gets the #GtMenu assigned to the #HildonAppview. + * Gets the #GtMenu assigned to the #HildonAppview. Note that the + * window is still the owner of the menu. * - * Return value: The #GtkMenu assigned to this application view. + * Return value: The #GtkMenu assigned to this application view. **/ GtkMenu* hildon_window_get_menu (HildonWindow * self) @@ -1731,7 +1739,8 @@ * Sets the menu to be used for this window. This menu overrides * a program-wide menu that may have been set with * hildon_program_set_common_menu. Pass NULL to remove the current - * menu. + * menu. HildonWindow takes ownership of the passed menu and you're + * not supposed to free it yourself anymore. **/ void hildon_window_set_menu (HildonWindow *self,
- Previous message: [maemo-commits] r9744 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r9746 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gtk tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]