Documentation updates
[hildon] / hildon / hildon-window.c
index 531e8a2..e61c920 100644 (file)
 
 /**
  * SECTION:hildon-window
- * @short_description: Widget representing a top-level window in the Hildon framework.
+ * @short_description: Top-level window in the Hildon framework.
  * @see_also: #HildonProgram, #HildonStackableWindow
  *
- * #HildonWindow is a GTK widget which represents a top-level
+ * #HildonWindow is a top-level
  * window in the Hildon framework. It is derived from #GtkWindow
  * and provides additional commodities specific to the Hildon
  * framework.
 
 #define                                         CAN_HIBERNATE_PROPERTY "_HILDON_ABLE_TO_HIBERNATE"
 
+#define                                         LEGACY_MENU_PROPERTY_NAME  "_HILDON_WM_WINDOW_TYPE"
+#define                                         LEGACY_MENU_PROPERTY_VALUE "_HILDON_WM_WINDOW_TYPE_LEGACY_MENU"
+
 #define TITLE_SEPARATOR                         " - "
 
 typedef void                                    (*HildonWindowSignal) (HildonWindow *, gint, gpointer);
@@ -1162,7 +1165,7 @@ hildon_window_key_press_event                   (GtkWidget *widget,
         case HILDON_HARDKEY_ESC:
             if (!priv->escape_timeout)
             {
-                priv->escape_timeout = g_timeout_add 
+                priv->escape_timeout = gdk_threads_add_timeout
                     (HILDON_WINDOW_LONG_PRESS_TIME,
                      hildon_window_escape_timeout, widget);
             }
@@ -1241,6 +1244,36 @@ hildon_window_focus_out_event                   (GtkWidget *widget,
   return GTK_WIDGET_CLASS (hildon_window_parent_class)->focus_out_event (widget, event);
 }
 
+static void
+set_legacy_menu_type                            (GtkMenu  *menu,
+                                                 gboolean  set)
+{
+    GdkWindow *gdkwin = GTK_WIDGET (menu->toplevel)->window;
+    GdkAtom property = gdk_atom_intern_static_string (LEGACY_MENU_PROPERTY_NAME);
+    if (set) {
+        GdkAtom type = gdk_x11_xatom_to_atom (XA_ATOM);
+        GdkAtom value = gdk_atom_intern_static_string (LEGACY_MENU_PROPERTY_VALUE);
+        gdk_property_change (gdkwin, property, type, 32,
+                             GDK_PROP_MODE_REPLACE, (const guchar *) &value, 1);
+    } else {
+        gdk_property_delete (gdkwin, property);
+    }
+}
+
+static void
+legacy_menu_realized                            (GtkMenu *menu)
+{
+    set_legacy_menu_type (menu, TRUE);
+    g_signal_handlers_disconnect_by_func (menu, legacy_menu_realized, NULL);
+}
+
+static void
+legacy_menu_unmapped                            (GtkMenu *menu)
+{
+    set_legacy_menu_type (menu, FALSE);
+    g_signal_handlers_disconnect_by_func (menu, legacy_menu_unmapped, NULL);
+}
+
 /*
  * The menu popuping needs a menu popup-function
  */
@@ -1545,6 +1578,18 @@ hildon_window_toggle_gtk_menu                   (HildonWindow *self,
             HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
             g_list_free (menu_children);
 
+            /* Set the 'legacy app menu' property when the widget is realized */
+            if (GTK_WIDGET_REALIZED (menu)) {
+                set_legacy_menu_type (menu, TRUE);
+            } else {
+                g_signal_connect (menu, "realize",
+                                  G_CALLBACK (legacy_menu_realized), NULL);
+            }
+
+            /* Remove it when it's unmapped */
+            g_signal_connect (menu, "unmap",
+                              G_CALLBACK (legacy_menu_unmapped), NULL);
+
             /* Apply right theming */
             gtk_widget_set_name (GTK_WIDGET (menu), "menu_force_with_corners");
 
@@ -1649,8 +1694,6 @@ hildon_window_escape_timeout                    (gpointer data)
 
     g_assert (priv);
 
-    GDK_THREADS_ENTER ();
-
     /* Send fake event, simulation a situation that user
        pressed 'x' from the corner */
     event = gdk_event_new(GDK_DELETE);
@@ -1662,8 +1705,6 @@ hildon_window_escape_timeout                    (gpointer data)
 
     priv->escape_timeout = 0;
 
-    GDK_THREADS_LEAVE ();
-
     return FALSE;
 }
 
@@ -1860,7 +1901,7 @@ hildon_window_set_edit_toolbar                  (HildonWindow      *self,
  * hildon_window_get_main_menu:
  * @self: a #HildonWindow
  *
- * Gets the #GtkMenu assigned to the #HildonAppview. Note that the
+ * Gets the #GtkMenu assigned to the #HildonWindow. Note that the
  * window is still the owner of the menu.
  *
  * Note that if you're using a #HildonAppMenu rather than a #GtkMenu
@@ -1886,6 +1927,8 @@ hildon_window_get_main_menu                     (HildonWindow * self)
  * hildon_window_get_menu:
  * @self: a #HildonWindow
  *
+ * Gets the #GtkMenu assigned to @self
+ *
  * Return value: a #GtkMenu
  *
  * Deprecated: In Hildon 2.2 this function has been renamed to