]> Pileus Git - ~andy/gtk/commitdiff
Monitor the screen of the attach widget continually, rather than only
authorOwen Taylor <otaylor@redhat.com>
Thu, 14 Nov 2002 05:46:34 +0000 (05:46 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 14 Nov 2002 05:46:34 +0000 (05:46 +0000)
Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
        the screen of the attach widget continually, rather than only
        setting the screen only on popup (#85710)

        * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
        go back to getting the screen from the attach widget.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmenu.c

index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 0211d9333c32063c980e9eefd6f1e1a094346ac7..b229fb226ab581531097dc8ef2a428c24aa26d6a 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov 14 00:33:26 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (attach_widget_screen_changed): Monitor
+       the screen of the attach widget continually, rather than only 
+       setting the screen only on popup (#85710)
+
+       * gtk/gtkmenu.c (gtk_menu_set_screen): Allow %NULL to
+       go back to getting the screen from the attach widget.
+
 Wed Nov 13 17:03:19 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c: Change so that updates of selection
index 80667b52ba2dfb633800d915ed2afbc7e4fedd5a..8de77793ea0ee22553705ef34d99b55c7758b4d9 100644 (file)
@@ -529,6 +529,19 @@ gtk_menu_finalize (GObject *object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static void
+attach_widget_screen_changed (GtkWidget *attach_widget,
+                             GdkScreen *previous_screen,
+                             GtkMenu   *menu)
+{
+  if (gtk_widget_has_screen (attach_widget) &&
+      !g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
+    {
+      gtk_window_set_screen (GTK_WINDOW (menu->toplevel),
+                            gtk_widget_get_screen (attach_widget));
+    }
+}
+
 void
 gtk_menu_attach_to_widget (GtkMenu            *menu,
                           GtkWidget           *attach_widget,
@@ -548,7 +561,7 @@ gtk_menu_attach_to_widget (GtkMenu         *menu,
     {
       g_warning ("gtk_menu_attach_to_widget(): menu already attached to %s",
                 g_type_name (G_TYPE_FROM_INSTANCE (data->attach_widget)));
-      return;
+     return;
     }
   
   g_object_ref (menu);
@@ -556,6 +569,11 @@ gtk_menu_attach_to_widget (GtkMenu        *menu,
   
   data = g_new (GtkMenuAttachData, 1);
   data->attach_widget = attach_widget;
+  
+  g_signal_connect (attach_widget, "screen_changed",
+                   G_CALLBACK (attach_widget_screen_changed), menu);
+  attach_widget_screen_changed (attach_widget, NULL, menu);
+  
   data->detacher = detacher;
   g_object_set_data (G_OBJECT (menu), attach_data_key, data);
   
@@ -600,6 +618,10 @@ gtk_menu_detach (GtkMenu *menu)
     }
   g_object_set_data (G_OBJECT (menu), attach_data_key, NULL);
   
+  g_signal_handlers_disconnect_by_func (data->attach_widget,
+                                       (gpointer) attach_widget_screen_changed,
+                                       menu);
+
   data->detacher (data->attach_widget, menu);
   
   if (GTK_WIDGET_REALIZED (menu))
@@ -758,7 +780,6 @@ gtk_menu_popup (GtkMenu                 *menu,
   GtkWidget *parent;
   GdkEvent *current_event;
   GtkMenuShell *menu_shell;
-  GtkMenuAttachData *attach_data;
 
   g_return_if_fail (GTK_IS_MENU (menu));
   
@@ -767,21 +788,6 @@ gtk_menu_popup (GtkMenu                *menu,
   
   menu_shell->parent_menu_shell = parent_menu_shell;
   
-  if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
-    {
-      /* The screen was not set explicitly, if the menu is
-       * attached to a widget, try to get screen from its 
-       * toplevel window else go with the default
-       */
-      attach_data = g_object_get_data (G_OBJECT (menu), attach_data_key);
-      if (attach_data)
-       {
-         if (!GTK_WIDGET_REALIZED (menu))
-         gtk_window_set_screen (GTK_WINDOW (menu->toplevel),
-                                gtk_widget_get_screen (attach_data->attach_widget));
-       }
-    }
-
   /* Find the last viewable ancestor, and make an X grab on it
    */
   parent = GTK_WIDGET (menu);
@@ -2947,19 +2953,30 @@ gtk_menu_hide_all (GtkWidget *widget)
 /**
  * gtk_menu_set_screen:
  * @menu: a #GtkMenu.
- * @screen: a #GtkScreen.
+ * @screen: a #GtkScreen, or %NULL if the screen should be
+ *          determined by the widget the menu is attached to.
  *
  * Sets the #GtkScreen on which the GtkMenu will be displayed.
- * This function can only be called before @menu is realized.
  **/
 void
-gtk_menu_set_screen (GtkMenu *menu, 
+gtk_menu_set_screen (GtkMenu   *menu, 
                     GdkScreen *screen)
 {
   g_return_if_fail (GTK_IS_MENU (menu));
-  gtk_window_set_screen (GTK_WINDOW (menu->toplevel), 
-                        screen);
+  g_return_if_fail (!screen || GDK_IS_SCREEN (screen));
+
   g_object_set_data (G_OBJECT (menu), "gtk-menu-explicit-screen", screen);
+
+  if (screen)
+    {
+      gtk_window_set_screen (GTK_WINDOW (menu->toplevel), screen);
+    }
+  else
+    {
+      GtkWidget *attach_widget = gtk_menu_get_attach_widget (menu);
+      if (attach_widget)
+       attach_widget_screen_changed (attach_widget, NULL, menu);
+    }
 }