2 * This file is a part of hildon
4 * Copyright (C) 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * SECTION:hildon-window
27 * @short_description: Widget representing a top-level window in the Hildon framework.
29 * The HildonWindow is a GTK widget which represents a top-level
30 * window in the Hildon framework. It is derived from the GtkWindow
31 * and provides additional commodities specific to the Hildon
34 * Among these windows in the Hildon framework can have a single menu
35 * attached, which is toggled with a hardware key or by tapping
36 * a custom button in the window frame. This menu can be set
37 * by providing a GtkMenu to the hildon_window_set_menu() method.
39 * Similarly a window in the Hildon framework can have several toolbars
40 * attached. These can be added to the HildonWindow with
41 * hildon_window_add_toolbar()..
44 * <title>Creating a HildonWindow</title>
46 * HildonWindow *window;
47 * GtkToolbar *toolbar;
49 * GdkPixbuf *icon_pixbuf;
51 * window = HILDON_WINDOW (hildon_window_new());
53 * toolbar = create_toolbar();
55 * menu = create_menu();
57 * icon_pixbuf = create_icon();
59 * hildon_window_set_menu (window, menu);
61 * hildon_window_add_toolbar (window, toolbar);
63 * // Can be used to set the window fullscreen
64 * gtk_window_fullscreen (GTK_WINDOW (window));
66 * // Used to trigger the blinking of the window's icon in the task navigator
67 * gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);
69 * // Change the window's icon in the task navigator
70 * gtk_window_set_icon (GTK_WINDOW (window), icon_pixbuf);
76 #include "hildon-window.h"
81 #include "hildon-program.h"
82 #include "hildon-window-private.h"
83 #include "hildon-find-toolbar.h"
85 #include <gtk/gtkmenu.h>
86 #include <gtk/gtkimcontext.h>
87 #include <gtk/gtkmenuitem.h>
88 #include <gtk/gtkcheckmenuitem.h>
89 #include <gtk/gtkmenushell.h>
90 #include <gtk/gtkwindow.h>
91 #include <gtk/gtkwidget.h>
92 #include <gtk/gtkvbox.h>
93 #include <gtk/gtklabel.h>
94 #include <gtk/gtkentry.h>
95 #include <gtk/gtktextview.h>
96 #include <gtk/gtkscrolledwindow.h>
97 #include <gtk/gtkmain.h>
98 #include <gdk/gdkkeysyms.h>
100 #include <gtk/gtkprivate.h>
102 #include <X11/Xlib.h>
103 #include <X11/Xatom.h>
106 #define _(String) gettext(String)
108 #define TOOLBAR_HEIGHT 40
110 #define TOOLBAR_MIDDLE 10
113 #define CAN_HIBERNATE "CANKILL"
115 #define CAN_HIBERNATE_LENGTH 7
117 #define CAN_HIBERNATE_PROPERTY "_HILDON_ABLE_TO_HIBERNATE"
119 #define TITLE_SEPARATOR " - "
121 static GtkWindowClass *parent_class;
123 typedef void (*HildonWindowSignal) (HildonWindow *, gint, gpointer);
126 hildon_window_init (HildonWindow * self);
129 hildon_window_class_init (HildonWindowClass * window_class);
132 hildon_window_menu_popup_func (GtkMenu *menu,
138 hildon_window_menu_popup_func_full (GtkMenu *menu,
144 hildon_window_expose (GtkWidget *widget,
145 GdkEventExpose *event);
147 hildon_window_forall (GtkContainer *container,
148 gboolean include_internals,
149 GtkCallback callback,
150 gpointer callback_data);
152 hildon_window_show_all (GtkWidget *widget);
155 hildon_window_size_allocate (GtkWidget * widget,
156 GtkAllocation *allocation);
158 hildon_window_size_request (GtkWidget * widget,
159 GtkRequisition *requisition);
161 hildon_window_finalize (GObject *obj_self);
164 hildon_window_get_property (GObject *object,
170 hildon_window_destroy (GtkObject *obj);
173 hildon_window_realize (GtkWidget *widget);
176 hildon_window_unrealize (GtkWidget *widget);
179 hildon_window_key_press_event (GtkWidget *widget,
183 hildon_window_key_release_event (GtkWidget *widget,
186 hildon_window_window_state_event (GtkWidget *widget,
187 GdkEventWindowState *event);
189 hildon_window_focus_out_event (GtkWidget *widget,
190 GdkEventFocus *event);
193 hildon_window_notify (GObject *gobject,
197 hildon_window_is_topmost_notify (HildonWindow *window);
200 hildon_window_toggle_menu (HildonWindow * self,
205 hildon_window_escape_timeout (gpointer data);
207 static GdkFilterReturn
208 hildon_window_event_filter (GdkXEvent *xevent,
212 static GdkFilterReturn
213 hildon_window_root_window_event_filter (GdkXEvent *xevent,
218 hildon_window_get_borders (HildonWindow *window);
221 visible_toolbar (gpointer data,
225 paint_toolbar (GtkWidget *widget,
227 GdkEventExpose * event,
228 gboolean fullscreen);
244 * hildon_window_get_type:
246 * Initializes and returns the type of a hildon window.
248 * @Returns: GType of #HildonWindow
251 hildon_window_get_type (void)
253 static GType window_type = 0;
256 static const GTypeInfo window_info = {
257 sizeof(HildonWindowClass),
258 NULL, /* base_init */
259 NULL, /* base_finalize */
260 (GClassInitFunc) hildon_window_class_init,
261 NULL, /* class_finalize */
262 NULL, /* class_data */
263 sizeof(HildonWindow),
265 (GInstanceInitFunc) hildon_window_init,
267 window_type = g_type_register_static(GTK_TYPE_WINDOW,
275 hildon_window_class_init (HildonWindowClass * window_class)
277 /* Get convenience variables */
278 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (window_class);
279 GObjectClass *object_class = G_OBJECT_CLASS (window_class);
280 GtkContainerClass *container_class = GTK_CONTAINER_CLASS (window_class);
282 /* Set the global parent_class here */
283 parent_class = g_type_class_peek_parent (window_class);
285 object_class->get_property = hildon_window_get_property;
286 object_class->notify = hildon_window_notify;
287 widget_class->size_allocate = hildon_window_size_allocate;
288 widget_class->size_request = hildon_window_size_request;
289 widget_class->expose_event = hildon_window_expose;
290 widget_class->show_all = hildon_window_show_all;
291 widget_class->realize = hildon_window_realize;
292 widget_class->unrealize = hildon_window_unrealize;
293 widget_class->key_press_event = hildon_window_key_press_event;
294 widget_class->key_release_event = hildon_window_key_release_event;
295 widget_class->window_state_event = hildon_window_window_state_event;
296 widget_class->focus_out_event = hildon_window_focus_out_event;
298 /* now the object stuff */
299 object_class->finalize = hildon_window_finalize;
301 /* To the container */
302 container_class->forall = hildon_window_forall;
305 GTK_OBJECT_CLASS (window_class)->destroy = hildon_window_destroy;
307 g_type_class_add_private (window_class,
308 sizeof (struct _HildonWindowPrivate));
310 /* Install properties */
313 * HildonWindow:is-topmost:
315 * Whether the window is currently activated by the window manager.
317 g_object_class_install_property (object_class, PROP_IS_TOPMOST,
318 g_param_spec_boolean ("is-topmost",
320 "Whether the window is currently activated by the window "
325 gtk_widget_class_install_style_property (widget_class,
326 g_param_spec_boxed ("borders",
328 "Size of graphical window borders",
332 gtk_widget_class_install_style_property (widget_class,
333 g_param_spec_boxed ("toolbar-borders",
334 "Graphical toolbar borders",
335 "Size of graphical toolbar borders",
339 /* opera hack, install clip operation signal */
340 g_signal_new ("clipboard_operation",
341 G_OBJECT_CLASS_TYPE (object_class),
343 G_STRUCT_OFFSET (HildonWindowClass, clipboard_operation),
345 g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1,
350 hildon_window_init (HildonWindow *self)
352 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
353 g_assert (priv != NULL);
355 priv->vbox = gtk_vbox_new (TRUE, TOOLBAR_MIDDLE);
356 gtk_widget_set_parent (priv->vbox, GTK_WIDGET(self));
358 priv->visible_toolbars = 0;
359 priv->is_topmost = FALSE;
360 priv->borders = NULL;
361 priv->toolbar_borders = NULL;
362 priv->escape_timeout = 0;
364 priv->fullscreen = FALSE;
366 priv->program = NULL;
368 /* We need to track the root window _MB_CURRENT_APP_WINDOW property */
369 gdk_window_set_events (gdk_get_default_root_window (),
370 gdk_window_get_events (gdk_get_default_root_window ()) | GDK_PROPERTY_CHANGE_MASK);
372 gdk_window_add_filter (gdk_get_default_root_window (),
373 hildon_window_root_window_event_filter, self);
377 hildon_window_finalize (GObject * obj_self)
380 HildonWindowPrivate *priv;
382 g_return_if_fail (HILDON_WINDOW (obj_self));
384 priv = HILDON_WINDOW_GET_PRIVATE (obj_self);
385 g_assert (priv != NULL);
387 self = HILDON_WINDOW (obj_self);
389 if (priv->escape_timeout) {
390 g_source_remove (priv->escape_timeout);
391 priv->escape_timeout = 0;
394 g_free (priv->borders);
395 g_free (priv->toolbar_borders);
397 if (G_OBJECT_CLASS (parent_class)->finalize)
398 G_OBJECT_CLASS (parent_class)->finalize (obj_self);
403 hildon_window_realize (GtkWidget *widget)
405 Atom *old_atoms, *new_atoms;
409 Window active_window;
410 HildonWindowPrivate *priv;
412 GTK_WIDGET_CLASS (parent_class)->realize (widget);
414 priv = HILDON_WINDOW_GET_PRIVATE (widget);
415 g_assert (priv != NULL);
417 gtk_widget_realize (GTK_WIDGET (priv->vbox));
419 /* catch the custom button signal from mb to display the menu */
420 gdk_window_add_filter (widget->window, hildon_window_event_filter, widget);
422 window = GDK_WINDOW_XID (widget->window);
423 disp = GDK_WINDOW_XDISPLAY (widget->window);
425 /* Enable custom button that is used for menu */
426 XGetWMProtocols (disp, window, &old_atoms, &atom_count);
427 new_atoms = g_new (Atom, atom_count + 1);
429 memcpy (new_atoms, old_atoms, sizeof(Atom) * atom_count);
431 new_atoms[atom_count++] =
432 XInternAtom (disp, "_NET_WM_CONTEXT_CUSTOM", False);
434 XSetWMProtocols (disp, window, new_atoms, atom_count);
439 /* rely on GDK to set the window group to its default */
440 gdk_window_set_group (widget->window, NULL);
443 gboolean can_hibernate = hildon_program_get_can_hibernate (priv->program);
445 hildon_window_set_can_hibernate_property (HILDON_WINDOW (widget),
449 /* Update the topmost status */
450 active_window = hildon_window_get_active_window();
451 hildon_window_update_topmost (HILDON_WINDOW (widget), active_window);
453 /* Update the window title */
454 hildon_window_update_title(HILDON_WINDOW (widget));
458 hildon_window_unrealize (GtkWidget *widget)
460 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
461 g_assert (priv != NULL);
463 gdk_window_remove_filter (widget->window, hildon_window_event_filter,
466 gtk_widget_unrealize (GTK_WIDGET (priv->vbox));
467 GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
471 hildon_window_get_property (GObject *object,
476 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (object);
477 g_assert (priv != NULL);
479 switch (property_id) {
481 case PROP_IS_TOPMOST:
482 g_value_set_boolean (value, priv->is_topmost);
486 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
492 * Retrieve the graphical borders size used by the themes
495 hildon_window_get_borders (HildonWindow *window)
497 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (window);
500 g_free (priv->borders);
501 g_free (priv->toolbar_borders);
503 gtk_widget_style_get (GTK_WIDGET (window), "borders",&priv->borders,
504 "toolbar-borders", &priv->toolbar_borders,
508 priv->borders = (GtkBorder *) g_malloc0 (sizeof (GtkBorder));
510 if (! priv->toolbar_borders)
511 priv->toolbar_borders = (GtkBorder *) g_malloc0 (sizeof (GtkBorder));
515 visible_toolbars (gpointer data,
518 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (((GtkBoxChild *)data)->widget)))
519 (*((gint *)user_data)) ++;
523 hildon_window_expose (GtkWidget *widget,
524 GdkEventExpose * event)
526 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
529 GtkWidget *bx = priv->vbox;
530 GtkBox *box = GTK_BOX(bx);
531 GtkBorder *b = priv->borders;
532 GtkBorder *tb = priv->toolbar_borders;
534 gint currently_visible_toolbars = 0;
536 if (! priv->borders) {
537 hildon_window_get_borders (HILDON_WINDOW (widget));
539 tb = priv->toolbar_borders;
542 tb_height = bx->allocation.height + tb->top + tb->bottom;
544 g_list_foreach (box->children, visible_toolbars,
545 ¤tly_visible_toolbars);
547 paint_toolbar (widget, box,
548 event, priv->fullscreen);
550 if (! priv->fullscreen) {
552 /* Draw the left and right window border */
553 gint side_borders_height = widget->allocation.height - b->top;
555 if (currently_visible_toolbars)
556 side_borders_height -= tb_height;
558 side_borders_height -= b->bottom;
562 gtk_paint_box (widget->style, widget->window,
563 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
564 &event->area, widget, "left-border",
565 widget->allocation.x, widget->allocation.y +
566 b->top, b->left, side_borders_height);
571 gtk_paint_box (widget->style, widget->window,
572 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
573 &event->area, widget, "right-border",
574 widget->allocation.x + widget->allocation.width -
575 b->right, widget->allocation.y + b->top,
576 b->right, side_borders_height);
579 /* If no toolbar, draw the bottom window border */
580 if (!currently_visible_toolbars && b->bottom > 0)
582 gtk_paint_box (widget->style, widget->window,
583 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
584 &event->area, widget, "bottom-border",
585 widget->allocation.x, widget->allocation.y +
586 (widget->allocation.height - b->bottom),
587 widget->allocation.width, b->bottom);
590 /* Draw the top border */
593 gtk_paint_box (widget->style, widget->window,
594 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
595 &event->area, widget, "top-border",
596 widget->allocation.x, widget->allocation.y,
597 widget->allocation.width, b->top);
603 /* don't draw the window stuff as it overwrites our borders with a blank
604 * rectangle. Instead start with the drawing of the GtkBin */
605 GTK_WIDGET_CLASS (g_type_class_peek_parent (parent_class))->expose_event (widget, event);
607 /* FIXME Not sure why this is commented out
608 * GTK_WIDGET_CLASS (parent_class))->
609 * expose_event (widget, event);
616 hildon_window_size_request (GtkWidget *widget,
617 GtkRequisition *requisition)
619 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
622 GtkWidget *child = GTK_BIN (widget)->child;
624 gint border_width = GTK_CONTAINER(widget)->border_width;
628 hildon_window_get_borders (HILDON_WINDOW (widget));
632 gtk_widget_size_request (child, requisition);
634 if (priv->vbox != NULL)
635 gtk_widget_size_request (priv->vbox, &req2);
637 requisition->height += req2.height;
638 requisition->width = (requisition->width < req2.width) ?
639 req2.width : requisition->width;
641 requisition->width += 2 * border_width;
642 requisition->height += 2 * border_width;
644 if (! priv->fullscreen)
646 requisition->height += priv->borders->top;
647 if (req2.height == 0)
648 requisition->height += priv->borders->bottom;
649 requisition->width += priv->borders->left + priv->borders->right;
654 hildon_window_size_allocate (GtkWidget *widget,
655 GtkAllocation *allocation)
657 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
660 GtkAllocation box_alloc;
661 GtkAllocation alloc = *allocation;
663 gint border_width = GTK_CONTAINER(widget)->border_width;
665 GtkWidget *box = priv->vbox;
666 GtkBin *bin = GTK_BIN(widget);
667 GtkBorder *b = priv->borders;
668 GtkBorder *tb = priv->toolbar_borders;
672 hildon_window_get_borders (HILDON_WINDOW (widget));
674 tb = priv->toolbar_borders;
677 widget->allocation = *allocation;
679 gtk_widget_get_child_requisition (box, &req);
681 box_alloc.width = allocation->width - tb->left - tb->right;
682 box_alloc.height = ( (req.height < allocation->height) ?
683 req.height : allocation->height );
684 box_alloc.x = allocation->x + tb->left;
685 box_alloc.y = allocation->y + allocation->height - box_alloc.height - tb->bottom;
687 if (bin->child != NULL && GTK_IS_WIDGET (bin->child)
688 && GTK_WIDGET_VISIBLE (bin->child))
690 alloc.x += border_width;
691 alloc.y += border_width;
692 alloc.width -= (border_width * 2);
693 alloc.height -= (border_width * 2) + box_alloc.height;
695 if (! priv->fullscreen)
698 alloc.width -= (b->left + b->right);
701 alloc.height -= b->top;
703 if (box_alloc.height <= 0)
704 alloc.height -= b->bottom;
706 alloc.height -= (tb->top + tb->bottom);
710 if (!(box_alloc.height <= 0))
711 alloc.height -= (tb->top + tb->bottom);
714 gtk_widget_size_allocate (bin->child, &alloc);
717 gtk_widget_size_allocate (box, &box_alloc);
719 if (priv->previous_vbox_y != box_alloc.y)
721 /* The size of the VBox has changed, we need to redraw part
722 * of the window borders */
723 gint draw_from_y = priv->previous_vbox_y < box_alloc.y?
724 priv->previous_vbox_y - tb->top:
725 box_alloc.y - tb->top;
727 gtk_widget_queue_draw_area (widget, 0, draw_from_y,
728 widget->allocation.width,
729 widget->allocation.height - draw_from_y);
731 priv->previous_vbox_y = box_alloc.y;
737 hildon_window_forall (GtkContainer *container,
738 gboolean include_internals,
739 GtkCallback callback,
740 gpointer callback_data)
742 HildonWindow *self = HILDON_WINDOW (container);
743 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
745 g_return_if_fail (callback != NULL);
748 GTK_CONTAINER_CLASS (parent_class)->forall (container, include_internals,
749 callback, callback_data);
750 if (include_internals && priv->vbox != NULL)
751 (* callback)(GTK_WIDGET (priv->vbox), callback_data);
755 hildon_window_show_all (GtkWidget *widget)
757 HildonWindow *self = HILDON_WINDOW (widget);
758 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
760 g_assert (priv != NULL);
762 GTK_WIDGET_CLASS (parent_class)->show_all (widget);
763 gtk_widget_show_all (priv->vbox);
767 hildon_window_destroy (GtkObject *obj)
769 HildonWindow *self = HILDON_WINDOW (obj);
770 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (obj);
771 GList *menu_list = NULL;
772 GList *menu_node = NULL;
774 gtk_widget_hide ((GtkWidget *) self);
775 while (gtk_events_pending ())
776 gtk_main_iteration ();
778 g_assert (priv != NULL);
780 if (priv->vbox != NULL)
784 GtkWidget * common_toolbar =
785 GTK_WIDGET (hildon_program_get_common_toolbar (priv->program));
786 if (common_toolbar && common_toolbar->parent == priv->vbox)
788 gtk_container_remove (GTK_CONTAINER (priv->vbox),
793 gtk_widget_unparent (priv->vbox);
798 menu_list = g_list_copy (gtk_menu_get_for_attach_widget (GTK_WIDGET (obj)));
799 menu_node = menu_list;
803 if (GTK_IS_MENU (menu_node->data))
805 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (menu_node->data)))
807 gtk_menu_popdown (GTK_MENU (menu_node->data));
808 gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_node->data));
810 gtk_menu_detach (GTK_MENU (menu_node->data));
812 /* Destroy it, but only if it's not a common menu */
814 hildon_program_get_common_menu (priv->program) != menu_node->data) {
815 gtk_object_destroy (GTK_OBJECT (menu_node->data));
816 g_object_unref (menu_node->data);
819 menu_node = menu_node->next;
822 g_list_free (menu_list);
827 hildon_program_remove_window (priv->program, self);
830 gdk_window_remove_filter (gdk_get_default_root_window(),
831 hildon_window_root_window_event_filter,
834 gtk_widget_set_events (GTK_WIDGET(obj), 0);
836 GTK_OBJECT_CLASS (parent_class)->destroy (obj);
840 hildon_window_notify (GObject *gobject,
843 HildonWindow *window = HILDON_WINDOW (gobject);
845 if (g_str_equal (param->name, "title"))
848 hildon_window_update_title (window);
850 else if (g_str_equal (param->name, "is-topmost"))
852 hildon_window_is_topmost_notify (window);
855 if (G_OBJECT_CLASS(parent_class)->notify)
856 G_OBJECT_CLASS(parent_class)->notify (gobject, param);
861 visible_toolbar (gpointer data,
864 if (GTK_WIDGET_VISIBLE (((GtkBoxChild *)data)->widget))
865 (*((gint *)user_data))++;
869 find_findtoolbar_index (gpointer data,
872 gint *pass_bundle = (gint *)user_data;
874 if(((GtkBoxChild *)data)->widget->allocation.y < pass_bundle[0]
875 && GTK_WIDGET_VISIBLE (((GtkBoxChild *)data)->widget))
880 find_findtoolbar (gpointer data,
883 if(HILDON_IS_FIND_TOOLBAR (((GtkBoxChild *)data)->widget)
884 && GTK_WIDGET_VISIBLE (((GtkBoxChild *)data)->widget))
885 (*((GtkWidget **)user_data)) = ((GtkBoxChild *)data)->widget;
889 paint_toolbar (GtkWidget *widget,
891 GdkEventExpose * event,
894 gint toolbar_num = 0;
897 GtkWidget *findtoolbar = NULL;
898 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
899 gchar toolbar_mode[40];
900 GtkBorder *tb = priv->toolbar_borders;
902 g_assert (priv != NULL);
904 /* collect info to help on painting the boxes */
905 g_list_foreach (box->children, visible_toolbar,
906 (gpointer) &toolbar_num);
911 g_list_foreach (box->children, find_findtoolbar, (gpointer) &findtoolbar);
913 if (findtoolbar != NULL)
915 gint pass_bundle[2];/* an array for convient data passing
916 the first member contains the y allocation
917 of the find toolbar, and the second allocation
918 contains the index(how many toolbars are above
920 pass_bundle[0] = findtoolbar->allocation.y;
921 pass_bundle[1] = ftb_index;
922 g_list_foreach(box->children, find_findtoolbar_index,
923 (gpointer) pass_bundle);
924 ftb_index = pass_bundle[1];
928 sprintf (toolbar_mode, "toolbar%sframe-top",
929 fullscreen ? "-fullscreen-" : "-");
930 gtk_paint_box (widget->style, widget->window,
931 GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
932 &event->area, widget, toolbar_mode,
933 widget->allocation.x,
934 GTK_WIDGET (box)->allocation.y - tb->top,
935 widget->allocation.width, tb->top);
937 /*top most toolbar painting*/
938 if (findtoolbar != NULL && ftb_index == 0 )
940 sprintf (toolbar_mode, "findtoolbar%s",
941 fullscreen ? "-fullscreen" : "");
943 gtk_paint_box (widget->style, widget->window,
944 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
945 &event->area, widget, toolbar_mode,
946 widget->allocation.x,
947 GTK_WIDGET(box)->allocation.y,
948 widget->allocation.width,
953 sprintf (toolbar_mode, "toolbar%s",
954 fullscreen ? "-fullscreen" : "");
956 gtk_paint_box (widget->style, widget->window,
957 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
958 &event->area, widget, toolbar_mode,
959 widget->allocation.x,
960 GTK_WIDGET(box)->allocation.y,
961 widget->allocation.width,
964 /*multi toolbar painting*/
965 for (count = 0; count < toolbar_num - 1; count++)
967 sprintf (toolbar_mode, "toolbar%sframe-middle",
968 fullscreen ? "-fullscreen-" : "-");
970 gtk_paint_box (widget->style, widget->window,
971 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
972 &event->area, widget, toolbar_mode,
973 widget->allocation.x,
974 GTK_WIDGET(box)->allocation.y +
975 (1 + count) * TOOLBAR_HEIGHT +
976 count * TOOLBAR_MIDDLE,
977 widget->allocation.width,
980 if (findtoolbar != NULL && count + 1 == ftb_index)
983 sprintf (toolbar_mode, "findtoolbar%s",
984 fullscreen ? "-fullscreen" : "");
986 gtk_paint_box (widget->style, widget->window,
987 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
988 &event->area, widget, toolbar_mode,
989 widget->allocation.x,
990 GTK_WIDGET(box)->allocation.y +
991 (1 + count) * (TOOLBAR_HEIGHT + TOOLBAR_MIDDLE),
992 widget->allocation.width,
997 sprintf (toolbar_mode, "toolbar%s",
998 fullscreen ? "-fullscreen" : "");
1000 gtk_paint_box (widget->style, widget->window,
1001 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
1002 &event->area, widget, toolbar_mode,
1003 widget->allocation.x,
1004 GTK_WIDGET(box)->allocation.y +
1005 (1 + count) * (TOOLBAR_HEIGHT + TOOLBAR_MIDDLE),
1006 widget->allocation.width,
1010 sprintf (toolbar_mode, "toolbar%sframe-bottom",
1011 fullscreen ? "-fullscreen-" : "-");
1013 gtk_paint_box (widget->style, widget->window,
1014 GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
1015 &event->area, widget, toolbar_mode,
1016 widget->allocation.x,
1017 GTK_WIDGET(box)->allocation.y +
1018 GTK_WIDGET(box)->allocation.height,
1019 widget->allocation.width, tb->bottom);
1023 * Checks the root window to know which is the topped window
1026 hildon_window_get_active_window (void)
1034 unsigned long extra;
1038 unsigned char *char_pointer;
1040 Atom active_app_atom =
1041 XInternAtom (GDK_DISPLAY (), "_MB_CURRENT_APP_WINDOW", False);
1045 gdk_error_trap_push ();
1046 status = XGetWindowProperty (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
1047 active_app_atom, 0L, 16L,
1048 0, XA_WINDOW, &realtype, &format,
1049 &n, &extra, &win.char_pointer);
1050 xerror = gdk_error_trap_pop ();
1051 if (xerror || !(status == Success && realtype == XA_WINDOW && format == 32
1052 && n == 1 && win.win != NULL))
1054 if (win.win != NULL)
1055 XFree (win.char_pointer);
1061 if (win.win != NULL)
1062 XFree(win.char_pointer);
1068 xclient_message_type_check (XClientMessageEvent *cm,
1071 return cm->message_type == XInternAtom(GDK_DISPLAY(), name, FALSE);
1075 * Handle the window border custom button, which toggles the menu,
1076 * and the Hildon input method copy paste messages
1078 static GdkFilterReturn
1079 hildon_window_event_filter (GdkXEvent *xevent,
1083 XAnyEvent *eventti = xevent;
1085 if (eventti->type == ClientMessage)
1087 XClientMessageEvent *cm = xevent;
1089 if (xclient_message_type_check (cm, "_MB_GRAB_TRANSFER"))
1091 hildon_window_toggle_menu (HILDON_WINDOW ( data ), cm->data.l[2], cm->data.l[0]);
1092 return GDK_FILTER_REMOVE;
1094 /* opera hack clipboard client message */
1095 else if (xclient_message_type_check (cm, "_HILDON_IM_CLIPBOARD_COPY"))
1097 g_signal_emit_by_name(G_OBJECT(data), "clipboard_operation",
1098 HILDON_WINDOW_CO_COPY);
1099 return GDK_FILTER_REMOVE;
1101 else if (xclient_message_type_check(cm, "_HILDON_IM_CLIPBOARD_CUT"))
1103 g_signal_emit_by_name(G_OBJECT(data), "clipboard_operation",
1104 HILDON_WINDOW_CO_CUT);
1105 return GDK_FILTER_REMOVE;
1107 else if (xclient_message_type_check(cm, "_HILDON_IM_CLIPBOARD_PASTE"))
1109 g_signal_emit_by_name(G_OBJECT(data), "clipboard_operation",
1110 HILDON_WINDOW_CO_PASTE);
1111 return GDK_FILTER_REMOVE;
1115 return GDK_FILTER_CONTINUE;
1119 * Here we keep track of changes in the _MB_CURRENT_APP_WINDOW,
1120 * to know when we acquire/lose topmost status
1122 static GdkFilterReturn
1123 hildon_window_root_window_event_filter (GdkXEvent *xevent,
1127 XAnyEvent *eventti = xevent;
1128 HildonWindow *hwindow = HILDON_WINDOW (data);
1130 if (eventti->type == PropertyNotify)
1132 XPropertyEvent *pevent = xevent;
1133 Atom active_app_atom =
1134 XInternAtom (GDK_DISPLAY (), "_MB_CURRENT_APP_WINDOW", False);
1136 if (pevent->atom == active_app_atom)
1138 Window active_window = hildon_window_get_active_window();
1140 hildon_window_update_topmost (hwindow, active_window);
1144 return GDK_FILTER_CONTINUE;
1148 * Handle the menu hardware key here
1151 hildon_window_key_press_event (GtkWidget *widget,
1154 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
1156 g_return_val_if_fail (HILDON_IS_WINDOW (widget),FALSE);
1159 switch (event->keyval)
1161 case HILDON_HARDKEY_MENU:
1162 if (hildon_window_toggle_menu (HILDON_WINDOW (widget), 0, GDK_CURRENT_TIME))
1165 case HILDON_HARDKEY_ESC:
1166 if (!priv->escape_timeout)
1168 priv->escape_timeout = g_timeout_add
1169 (HILDON_WINDOW_LONG_PRESS_TIME,
1170 hildon_window_escape_timeout, widget);
1175 return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
1179 hildon_window_key_release_event (GtkWidget *widget,
1182 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
1184 g_return_val_if_fail (HILDON_IS_WINDOW (widget), FALSE);
1187 switch (event->keyval)
1189 case HILDON_HARDKEY_ESC:
1190 if (priv->escape_timeout)
1192 g_source_remove (priv->escape_timeout);
1193 priv->escape_timeout = 0;
1198 return GTK_WIDGET_CLASS (parent_class)->key_release_event (widget, event);
1203 * We keep track of the window state changes, because the drawing
1204 * (borders) differs whether we are in fullscreen mode or not
1207 hildon_window_window_state_event (GtkWidget *widget,
1208 GdkEventWindowState *event)
1210 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
1211 g_assert (priv != NULL);
1213 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
1214 priv->fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
1216 if (GTK_WIDGET_CLASS (parent_class)->window_state_event)
1218 return GTK_WIDGET_CLASS (parent_class)->window_state_event (
1229 * If the window lost focus while the user started to press the ESC key, we
1230 * won't get the release event. We need to stop the timeout.
1233 hildon_window_focus_out_event (GtkWidget *widget,
1234 GdkEventFocus *event)
1236 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
1238 if (priv->escape_timeout)
1240 g_source_remove (priv->escape_timeout);
1241 priv->escape_timeout = 0;
1244 return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
1248 * The menu popuping needs a menu popup-function
1251 hildon_window_menu_popup_func (GtkMenu *menu,
1259 GdkWindow *window = GTK_WIDGET(widget)->window;
1263 gdk_window_get_origin (window, &window_x, &window_y);
1266 gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
1267 "vertical-offset", y, NULL);
1275 hildon_window_menu_popup_func_full (GtkMenu *menu,
1281 gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
1282 "vertical-offset", y, NULL);
1290 * Takes the common toolbar when we acquire the top-most status
1293 hildon_window_is_topmost_notify (HildonWindow *window)
1295 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (window);
1299 if (priv->is_topmost)
1301 hildon_window_take_common_toolbar (window);
1306 * Sets the program to which the window belongs. This should only be called
1307 * by hildon_program_add_window
1309 void G_GNUC_INTERNAL
1310 hildon_window_set_program (HildonWindow *self,
1313 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1315 g_return_if_fail (HILDON_IS_WINDOW (self));
1316 g_assert (priv != NULL);
1320 g_object_unref (priv->program);
1323 /* Now that we are bound to a program, we can rely on it to track the
1325 gdk_window_remove_filter (gdk_get_default_root_window(),
1326 hildon_window_root_window_event_filter,
1329 priv->program = HILDON_PROGRAM (program);
1330 g_object_ref (program);
1334 * Unsets the program to which the window belongs. This should only be called
1335 * by hildon_program_add_window
1337 void G_GNUC_INTERNAL
1338 hildon_window_unset_program (HildonWindow *self)
1340 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1342 g_return_if_fail(HILDON_IS_WINDOW (self));
1343 g_assert (priv != NULL);
1347 g_object_unref (priv->program);
1348 priv->program = NULL;
1350 /* We need to start tacking the root window again */
1351 gdk_window_set_events (gdk_get_default_root_window (),
1352 gdk_window_get_events (gdk_get_default_root_window ())
1353 | GDK_PROPERTY_CHANGE_MASK);
1355 gdk_window_add_filter (gdk_get_default_root_window (),
1356 hildon_window_root_window_event_filter, self );
1359 priv->program = NULL;
1363 * Sets whether or not the program to which this window belongs is
1364 * killable. This is used by the HildonProgram to signify to the
1365 * Task Navigator whether or not it can hibernate in memory-low situations
1367 void G_GNUC_INTERNAL
1368 hildon_window_set_can_hibernate_property (HildonWindow *self,
1369 gpointer _can_hibernate)
1371 GdkAtom killable_atom;
1372 gboolean can_hibernate;
1374 g_return_if_fail(self && HILDON_IS_WINDOW (self));
1376 if (!GTK_WIDGET_REALIZED ((GTK_WIDGET (self))))
1381 can_hibernate = * ((gboolean *)_can_hibernate);
1383 killable_atom = gdk_atom_intern (CAN_HIBERNATE_PROPERTY, FALSE);
1387 gdk_property_change (GTK_WIDGET (self)->window, killable_atom,
1388 (GdkAtom)31/* XA_STRING */, 8,
1389 GDK_PROP_MODE_REPLACE, (const guchar *)CAN_HIBERNATE,
1390 CAN_HIBERNATE_LENGTH);
1394 gdk_property_delete (GTK_WIDGET (self)->window, killable_atom);
1400 * If a common toolbar was set to the program, reparent it to
1403 void G_GNUC_INTERNAL
1404 hildon_window_take_common_toolbar (HildonWindow *self)
1406 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1408 g_return_if_fail(HILDON_IS_WINDOW (self));
1413 GtkWidget *common_toolbar =
1414 GTK_WIDGET (hildon_program_get_common_toolbar (priv->program));
1416 if (common_toolbar && common_toolbar->parent != priv->vbox)
1418 g_object_ref (common_toolbar);
1419 if (common_toolbar->parent)
1421 gtk_container_remove (GTK_CONTAINER (common_toolbar->parent),
1425 gtk_box_pack_end (GTK_BOX(priv->vbox), common_toolbar,
1427 g_object_unref (common_toolbar);
1429 gtk_widget_set_size_request (common_toolbar, -1, TOOLBAR_HEIGHT);
1431 gtk_widget_show (priv->vbox);
1438 * Compare the window that was last topped, and act consequently
1441 hildon_window_update_topmost (HildonWindow *self,
1444 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1448 g_return_if_fail (HILDON_IS_WINDOW (self));
1451 my_window = GDK_WINDOW_XID (GTK_WIDGET (self)->window);
1453 if (window_id == my_window)
1455 if (! priv->is_topmost)
1457 priv->is_topmost = TRUE;
1458 hildon_window_is_topmost_notify (self);
1459 g_object_notify (G_OBJECT (self), "is-topmost");
1462 else if (priv->is_topmost)
1464 /* Should this go in the signal handler? */
1465 GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (self));
1467 if (GTK_IS_ENTRY (focus))
1468 gtk_im_context_focus_out (GTK_ENTRY (focus)->im_context);
1469 if (GTK_IS_TEXT_VIEW (focus))
1470 gtk_im_context_focus_out (GTK_TEXT_VIEW (focus)->im_context);
1472 priv->is_topmost = FALSE;
1473 hildon_window_is_topmost_notify (self);
1474 g_object_notify (G_OBJECT (self), "is-topmost");
1479 * If the application
1480 * was given a name (with g_set_application_name(), set
1481 * "ProgramName - WindowTitle" as the displayed
1484 void G_GNUC_INTERNAL
1485 hildon_window_update_title (HildonWindow *window)
1487 const gchar * application_name;
1489 g_return_if_fail (HILDON_IS_WINDOW (window));
1491 if (!GTK_WIDGET_REALIZED (window))
1496 application_name = g_get_application_name ();
1498 if (application_name && application_name[0])
1500 const gchar *old_title = gtk_window_get_title (GTK_WINDOW (window));
1504 gchar *title = NULL;
1506 if (strlen (old_title) == 0)
1507 title = g_strdup (application_name);
1509 title = g_strjoin (TITLE_SEPARATOR, application_name,
1512 gdk_window_set_title (GTK_WIDGET (window)->window, title);
1521 detach_menu_func (GtkWidget *attach_widget,
1524 /* FIXME Why is this even needed here? */
1528 * Toggles the display of the HildonWindow menu.
1529 * Returns whether or not something was done (whether or not we had a menu
1533 hildon_window_toggle_menu (HildonWindow * self,
1537 GtkMenu *menu_to_use = NULL;
1538 GList *menu_children = NULL;
1539 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1541 g_return_val_if_fail (HILDON_IS_WINDOW (self), FALSE);
1542 g_assert (priv != NULL);
1544 /* Select which menu to use, Window specific has highest priority,
1545 * then program specific */
1548 menu_to_use = GTK_MENU (priv->menu);
1550 else if (priv->program)
1552 menu_to_use = hildon_program_get_common_menu (priv->program);
1553 if (menu_to_use && gtk_menu_get_attach_widget (menu_to_use) !=
1556 g_object_ref (menu_to_use);
1557 if (gtk_menu_get_attach_widget (menu_to_use))
1559 gtk_menu_detach (menu_to_use);
1562 gtk_menu_attach_to_widget (menu_to_use, GTK_WIDGET (self),
1564 g_object_unref (menu_to_use);
1574 if (GTK_WIDGET_MAPPED (GTK_WIDGET (menu_to_use)))
1576 gtk_menu_popdown (menu_to_use);
1577 gtk_menu_shell_deactivate (GTK_MENU_SHELL (menu_to_use));
1581 /* Check if the menu has items */
1582 menu_children = gtk_container_get_children (GTK_CONTAINER (menu_to_use));
1586 g_list_free (menu_children);
1588 /* Apply right theming */
1589 gtk_widget_set_name (GTK_WIDGET (menu_to_use),
1590 "menu_force_with_corners");
1592 if (priv->fullscreen)
1594 gtk_menu_popup (menu_to_use, NULL, NULL,
1595 (GtkMenuPositionFunc)
1596 hildon_window_menu_popup_func_full,
1597 self, button, time);
1601 gtk_menu_popup (menu_to_use, NULL, NULL,
1602 (GtkMenuPositionFunc)
1603 hildon_window_menu_popup_func,
1604 self, button, time);
1606 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_to_use), TRUE);
1614 * If the ESC key was not released when the timeout expires,
1618 hildon_window_escape_timeout (gpointer data)
1620 HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (data);
1625 GDK_THREADS_ENTER ();
1627 /* Send fake event, simulation a situation that user
1628 pressed 'x' from the corner */
1629 event = gdk_event_new(GDK_DELETE);
1630 ((GdkEventAny *)event)->window = GDK_WINDOW (g_object_ref (GTK_WIDGET(data)->window));
1631 gtk_main_do_event(event);
1633 /* That unrefs the window, so we're reffing it above */
1634 gdk_event_free(event);
1636 priv->escape_timeout = 0;
1638 GDK_THREADS_LEAVE ();
1644 * hildon_window_new:
1646 * Creates a new HildonWindow.
1648 * Return value: A @HildonWindow.
1651 hildon_window_new (void)
1653 HildonWindow *newwindow = g_object_new (HILDON_TYPE_WINDOW, NULL);
1655 return GTK_WIDGET (newwindow);
1659 * hildon_window_add_with_scrollbar
1660 * @self : A @HildonWindow
1661 * @child : A @GtkWidget
1663 * Adds the @child to the HildonWindow and creates a scrollbar
1664 * for it. Similar as adding first a @GtkScrolledWindow and then the
1668 hildon_window_add_with_scrollbar (HildonWindow *self,
1671 GtkScrolledWindow *scrolledw;
1673 g_return_if_fail (HILDON_IS_WINDOW (self));
1674 g_return_if_fail (GTK_IS_WIDGET (child));
1675 g_return_if_fail (child->parent == NULL);
1677 scrolledw = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
1678 gtk_scrolled_window_set_policy (scrolledw, GTK_POLICY_NEVER,
1679 GTK_POLICY_AUTOMATIC);
1680 gtk_scrolled_window_set_shadow_type (scrolledw, GTK_SHADOW_NONE);
1682 if (GTK_IS_VIEWPORT (child))
1683 gtk_container_add (GTK_CONTAINER (scrolledw), child);
1686 if (GTK_IS_CONTAINER (child) )
1687 gtk_container_set_focus_vadjustment (GTK_CONTAINER(child),
1688 gtk_scrolled_window_get_vadjustment (scrolledw) );
1689 gtk_scrolled_window_add_with_viewport (scrolledw, child);
1692 gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (scrolledw));
1696 * hildon_window_add_toolbar:
1697 * @self: A @HildonWindow
1698 * @toolbar: A #GtkToolbar to add to the HildonWindow
1700 * Adds a toolbar to the window. Note that the toolbar is not automatically
1701 * shown. You need to call #gtk_widget_show_all on it to make it visible.
1702 * It's also possible to hide the toolbar (without removing it) by calling
1703 * #gtk_widget_hide_all.
1706 hildon_window_add_toolbar (HildonWindow *self,
1707 GtkToolbar *toolbar)
1710 HildonWindowPrivate *priv;
1712 g_return_if_fail (HILDON_IS_WINDOW (self));
1713 g_return_if_fail (toolbar && GTK_IS_TOOLBAR (toolbar));
1715 priv = HILDON_WINDOW_GET_PRIVATE (self);
1717 vbox = GTK_BOX (priv->vbox);
1719 gtk_box_pack_start (vbox, GTK_WIDGET (toolbar), TRUE, TRUE, 0);
1720 gtk_box_reorder_child (vbox, GTK_WIDGET (toolbar), 0);
1721 gtk_widget_set_size_request (GTK_WIDGET (toolbar), -1, TOOLBAR_HEIGHT);
1723 gtk_widget_queue_resize (GTK_WIDGET (self));
1727 * hildon_window_remove_toolbar:
1728 * @self: A @HildonWindow
1729 * @toolbar: A #GtkToolbar to remove from the HildonWindow
1731 * Removes a toolbar from the window. Note that this decreases the refference
1732 * count on the widget. If you want to keep the toolbar alive call #g_object_ref
1733 * before calling this function.
1736 hildon_window_remove_toolbar (HildonWindow *self,
1737 GtkToolbar *toolbar)
1739 HildonWindowPrivate *priv;
1741 g_return_if_fail (HILDON_IS_WINDOW (self));
1743 priv = HILDON_WINDOW_GET_PRIVATE (self);
1745 gtk_container_remove (GTK_CONTAINER (priv->vbox), GTK_WIDGET (toolbar));
1749 * hildon_window_get_menu:
1750 * @self : #HildonWindow
1752 * Gets the #GtMenu assigned to the #HildonAppview. Note that the
1753 * window is still the owner of the menu.
1755 * Return value: The #GtkMenu assigned to this application view.
1758 hildon_window_get_menu (HildonWindow * self)
1760 HildonWindowPrivate *priv;
1762 g_return_val_if_fail (HILDON_IS_WINDOW (self), NULL);
1764 priv = HILDON_WINDOW_GET_PRIVATE (self);
1766 return GTK_MENU (priv->menu);
1770 * hildon_window_set_menu:
1771 * @self: A #HildonWindow
1772 * @menu: The #GtkMenu to be used for this #HildonWindow
1774 * Sets the menu to be used for this window. This menu overrides
1775 * a program-wide menu that may have been set with
1776 * hildon_program_set_common_menu. Pass NULL to remove the current
1777 * menu. HildonWindow takes ownership of the passed menu and you're
1778 * not supposed to free it yourself anymore.
1781 hildon_window_set_menu (HildonWindow *self,
1784 HildonWindowPrivate *priv;
1786 g_return_if_fail (HILDON_IS_WINDOW (self));
1788 priv = HILDON_WINDOW_GET_PRIVATE (self);
1790 if (priv->menu != NULL)
1792 gtk_menu_detach (GTK_MENU (priv->menu));
1793 g_object_unref (priv->menu);
1796 priv->menu = (menu != NULL) ? GTK_WIDGET (menu) : NULL;
1797 if (priv->menu != NULL)
1799 gtk_widget_set_name (priv->menu, "menu_force_with_corners");
1800 gtk_menu_attach_to_widget (GTK_MENU (priv->menu), GTK_WIDGET (self), &detach_menu_func);
1801 g_object_ref (GTK_MENU (priv->menu));
1802 gtk_widget_show_all (GTK_WIDGET (priv->menu));
1807 * hildon_window_get_is_topmost:
1808 * @self: A #HildonWindow
1810 * Return value: Whether or not the #HildonWindow is currenltly activated
1811 * by the window manager.
1814 hildon_window_get_is_topmost (HildonWindow *self)
1816 HildonWindowPrivate *priv;
1818 g_return_val_if_fail (HILDON_IS_WINDOW (self), FALSE);
1820 priv = HILDON_WINDOW_GET_PRIVATE (self);
1821 return priv->is_topmost;