*
* Copyright (C) 2006 Nokia Corporation.
*
- * Contact: Luc Pionchon <luc.pionchon@nokia.com>
+ * Contact: 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; either version 2.1 of
- * the License, or (at your option) any later version.
+ * 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
static void
hildon_window_is_topmost_notify (HildonWindow *window);
-static gboolean
-hildon_window_vbox_expose_event (GtkWidget *vbox,
- GdkEventExpose *event,
- gpointer window);
-
static gboolean
hildon_window_toggle_menu (HildonWindow * self);
priv->fullscreen = FALSE;
priv->program = NULL;
-
- /* Handle the drawing of the vbox (add the pixmap borders) */
- g_signal_connect (G_OBJECT (self->priv->vbox), "expose-event",
- G_CALLBACK (hildon_window_vbox_expose_event),
- self);
/* We need to track the root window _MB_CURRENT_APP_WINDOW property */
gdk_window_set_events (gdk_get_default_root_window (),
g_list_foreach (box->children, visible_toolbars,
¤tly_visible_toolbars);
+ paint_toolbar (widget, box,
+ event, priv->fullscreen);
+
if (!HILDON_WINDOW (widget)->priv->fullscreen)
{
}
-
-static gboolean
-hildon_window_vbox_expose_event (GtkWidget *vbox,
- GdkEventExpose *event,
- gpointer window)
-{
- HildonWindowPrivate *priv = HILDON_WINDOW (window)->priv;
-
- hildon_window_get_borders (HILDON_WINDOW(window));
-
- event->area.x -= priv->toolbar_borders->left;
- event->area.y -= priv->toolbar_borders->top;
- event->area.width += (priv->toolbar_borders->left +
- priv->toolbar_borders->right);
- event->area.height += (priv->toolbar_borders->top +
- priv->toolbar_borders->bottom);
-
- paint_toolbar (GTK_WIDGET (window), GTK_BOX (vbox),
- event, priv->fullscreen);
-
- GTK_WIDGET_CLASS (G_TYPE_INSTANCE_GET_CLASS (vbox, GTK_TYPE_VBOX, GtkVBox))
- ->expose_event (vbox, event);
-
- event->area = GTK_WIDGET(window)->allocation;
-
-
- return TRUE;
-}
-
static void
hildon_window_notify (GObject *gobject, GParamSpec *param)
{
hildon_window_toggle_menu (HildonWindow * self)
{
GtkMenu *menu_to_use = NULL;
+ GList *menu_children = NULL;
g_return_val_if_fail (self && HILDON_IS_WINDOW (self), FALSE);
}
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (menu_to_use)))
+ if (GTK_WIDGET_MAPPED (GTK_WIDGET (menu_to_use)))
{
gtk_menu_popdown (menu_to_use);
gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_to_use));
return TRUE;
}
- if (gtk_container_get_children (GTK_CONTAINER (menu_to_use)) != NULL)
+ /* Check if the menu has items */
+ menu_children = gtk_container_get_children (GTK_CONTAINER (menu_to_use));
+
+ if (menu_children)
{
+ g_list_free (menu_children);
+
/* Apply right theming */
gtk_widget_set_name (GTK_WIDGET (menu_to_use),
"menu_force_with_corners");
gtk_get_current_event_time ());
}
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_to_use), TRUE);
+ return TRUE;
}
- return TRUE;
+ return FALSE;
+
}
/*
/* Send fake event, simulation a situation that user
pressed 'x' from the corner */
event = gdk_event_new(GDK_DELETE);
- ((GdkEventAny *)event)->window = GTK_WIDGET(data)->window;
+ ((GdkEventAny *)event)->window = GDK_WINDOW (g_object_ref (GTK_WIDGET(data)->window));
gtk_main_do_event(event);
+
+ /* That unrefs the window, so we're reffing it above */
gdk_event_free(event);
priv->escape_timeout = 0;
*
* 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.
+ * hildon_program_set_common_menu. Pass NULL to remove the current
+ * menu.
**/
void
hildon_window_set_menu (HildonWindow *self, GtkMenu *menu)
{
- g_return_if_fail (self && HILDON_IS_WINDOW (self) &&
- menu && GTK_IS_MENU (menu));
+ g_return_if_fail (HILDON_IS_WINDOW (self));
- if (self->priv->menu)
- {
+ if (self->priv->menu != NULL) {
+ gtk_menu_detach (GTK_MENU (self->priv->menu));
g_object_unref (self->priv->menu);
}
- self->priv->menu = GTK_WIDGET (menu);
- gtk_widget_set_name (GTK_WIDGET (self->priv->menu),
- "menu_force_with_corners");
- gtk_widget_show_all (self->priv->menu);
+ self->priv->menu = (menu != NULL) ? GTK_WIDGET (menu) : NULL;
+ if (self->priv->menu != NULL) {
+ gtk_widget_set_name (self->priv->menu, "menu_force_with_corners");
+ gtk_menu_attach_to_widget (GTK_MENU (self->priv->menu), GTK_WIDGET (self), &detach_menu_func);
+ g_object_ref (GTK_MENU (self->priv->menu));
+ }
- gtk_menu_attach_to_widget (menu, GTK_WIDGET (self), &detach_menu_func);
+ gtk_widget_show_all (GTK_WIDGET (self));
}
/**