+2007-02-08 Michael Dominic Kostrzewa <michael.kostrzewa@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@nokia.com>
* src/hildon-program.c:
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)
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
--- /dev/null
+/*
+ * 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);
+
+ 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;
+}
+
+
--- /dev/null
+/*
+ * 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);
+
+ 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;
+}
* 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)
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)))
{
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;
}
* 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)
* 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,