Add HildonAppMenu::changed signal
[hildon] / hildon / hildon-window.c
index b68820a..990a2bd 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.
@@ -95,6 +95,7 @@
 #include                                        "hildon-app-menu-private.h"
 #include                                        "hildon-find-toolbar.h"
 #include                                        "hildon-defines.h"
+#include                                        "hildon-private.h"
 
 #define                                         _(String) gettext(String)
 
@@ -1165,7 +1166,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);
             }
@@ -1694,8 +1695,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);
@@ -1707,8 +1706,6 @@ hildon_window_escape_timeout                    (gpointer data)
 
     priv->escape_timeout = 0;
 
-    GDK_THREADS_LEAVE ();
-
     return FALSE;
 }
 
@@ -1962,6 +1959,25 @@ hildon_window_add_accel_group (HildonWindow *self,
     gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
 }
 
+static void
+do_set_has_menu (GtkWindow *window,
+                 gpointer   boolptr)
+{
+    gboolean has_menu = GPOINTER_TO_INT (boolptr);
+    hildon_gtk_window_set_clear_window_flag (window, "_HILDON_WM_WINDOW_MENU_INDICATOR",
+                                             XA_INTEGER, has_menu);
+    g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_FUNC,
+                                          0, 0, NULL, do_set_has_menu, NULL);
+}
+
+void
+hildon_window_set_menu_flag (HildonWindow *window,
+                             gboolean   has_menu)
+{
+    hildon_gtk_window_set_flag (GTK_WINDOW (window), (HildonFlagFunc) do_set_has_menu,
+                                GUINT_TO_POINTER (has_menu));
+}
+
 /**
  * hildon_window_set_main_menu:
  * @self: A #HildonWindow
@@ -1987,6 +2003,8 @@ hildon_window_set_main_menu (HildonWindow* self,
 
     priv = HILDON_WINDOW_GET_PRIVATE (self);
 
+    hildon_window_set_menu_flag (self, menu != NULL);
+
     if (priv->menu != NULL)
     {
        accel_group = gtk_menu_get_accel_group (priv->menu);
@@ -2092,6 +2110,8 @@ hildon_window_set_app_menu                      (HildonWindow  *self,
 
     old_menu = priv->app_menu;
 
+    hildon_window_set_menu_flag (self, menu != NULL);
+
     /* Add new menu */
     priv->app_menu = menu;
     if (menu)