]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwindow.c
Some fixes for modal hint setting based on a patch from Arvind Samptur
[~andy/gtk] / gtk / gtkwindow.c
index bee766c3b3693fabc0dd6dcf52ffec735364e930..1d3dfea02395aa8a6caa6f1cfae7e200fd77622a 100644 (file)
@@ -1487,6 +1487,14 @@ gtk_window_set_position (GtkWindow         *window,
   g_object_notify (G_OBJECT (window), "window_position");
 }
 
+/**
+ * gtk_window_activate_focus:
+ * @window: a #GtkWindow
+ * 
+ * Activates the current focused widget within the window.
+ * 
+ * Return value: %TRUE if a widget got activated.
+ **/
 gboolean 
 gtk_window_activate_focus (GtkWindow *window)
 {
@@ -1522,6 +1530,17 @@ gtk_window_get_focus (GtkWindow *window)
   return window->focus_widget;
 }
 
+/**
+ * gtk_window_activate_default:
+ * @window: a #GtkWindow
+ * 
+ * Activates the default widget for the window, unless the current 
+ * focused widget has been configured to receive the default action 
+ * (see #GTK_RECEIVES_DEFAULT in #GtkWidgetFlags), in which case the
+ * focused widget is activated. 
+ * 
+ * Return value: %TRUE if a widget got activated.
+ **/
 gboolean
 gtk_window_activate_default (GtkWindow *window)
 {
@@ -1563,13 +1582,30 @@ gtk_window_set_modal (GtkWindow *window,
 {
   g_return_if_fail (GTK_IS_WINDOW (window));
 
-  window->modal = modal != FALSE;
+  modal = modal != FALSE;
+  if (window->modal == modal)
+    return;
+  
+  window->modal = modal;
   
   /* adjust desired modality state */
-  if (GTK_WIDGET_VISIBLE (window) && window->modal)
-    gtk_grab_add (GTK_WIDGET (window));
-  else
-    gtk_grab_remove (GTK_WIDGET (window));
+  if (GTK_WIDGET_REALIZED (window))
+    {
+      GtkWidget *widget = GTK_WIDGET (window);
+      
+      if (window->modal)
+       gdk_window_set_modal_hint (widget->window, TRUE);
+      else
+       gdk_window_set_modal_hint (widget->window, FALSE);
+    }
+
+  if (GTK_WIDGET_VISIBLE (window))
+    {
+      if (window->modal)
+       gtk_grab_add (GTK_WIDGET (window));
+      else
+       gtk_grab_remove (GTK_WIDGET (window));
+    }
 
   g_object_notify (G_OBJECT (window), "modal");
 }
@@ -1894,6 +1930,7 @@ gtk_window_get_type_hint (GtkWindow *window)
  * Windows may set a hint asking the desktop environment not to display
  * the window in the task bar. This function toggles this hint.
  * 
+ * Since: 2.2
  **/
 void
 gtk_window_set_skip_taskbar_hint (GtkWindow *window,
@@ -1924,6 +1961,8 @@ gtk_window_set_skip_taskbar_hint (GtkWindow *window,
  * Gets the value set by gtk_window_set_skip_taskbar_hint()
  * 
  * Return value: %TRUE if window shouldn't be in taskbar
+ * 
+ * Since: 2.2
  **/
 gboolean
 gtk_window_get_skip_taskbar_hint (GtkWindow *window)
@@ -1948,6 +1987,7 @@ gtk_window_get_skip_taskbar_hint (GtkWindow *window)
  * switcher that displays a thumbnail representation of the windows
  * on the screen.)
  * 
+ * Since: 2.2
  **/
 void
 gtk_window_set_skip_pager_hint (GtkWindow *window,
@@ -1978,6 +2018,8 @@ gtk_window_set_skip_pager_hint (GtkWindow *window,
  * Gets the value set by gtk_window_set_skip_pager_hint().
  * 
  * Return value: %TRUE if window shouldn't be in pager
+ * 
+ * Since: 2.2
  **/
 gboolean
 gtk_window_get_skip_pager_hint (GtkWindow *window)
@@ -2649,6 +2691,8 @@ load_pixbuf_verbosely (const char *filename,
  * with a pixbuf created by loading the image from @filename.
  *
  * Returns: %TRUE if setting the icon succeeded.
+ *
+ * Since: 2.2
  **/
 gboolean
 gtk_window_set_icon_from_file (GtkWindow   *window,
@@ -2732,6 +2776,8 @@ gtk_window_set_default_icon_list (GList *list)
  * on disk. Warns on failure if @err is %NULL.
  *
  * Returns: %TRUE if setting the icon succeeded.
+ *
+ * Since: 2.2
  **/
 gboolean
 gtk_window_set_default_icon_from_file (const gchar *filename,
@@ -3733,8 +3779,7 @@ gtk_window_realize (GtkWidget *widget)
   if (gtk_window_get_skip_taskbar_hint (window))
     gdk_window_set_skip_taskbar_hint (widget->window, TRUE);
   
-  /* transient_for must be set to allow the modal hint */
-  if (window->transient_parent && window->modal)
+  if (window->modal)
     gdk_window_set_modal_hint (widget->window, TRUE);
   else
     gdk_window_set_modal_hint (widget->window, FALSE);
@@ -5057,10 +5102,9 @@ gtk_window_move_resize (GtkWindow *window)
                                  new_request.width, new_request.height);
            }
          else
-           if (widget->window)
-             gdk_window_move_resize (widget->window,
-                                     new_request.x, new_request.y,
-                                     new_request.width, new_request.height);
+           gdk_window_move_resize (widget->window,
+                                   new_request.x, new_request.y,
+                                   new_request.width, new_request.height);
        }
       else  /* only size changed */
        {
@@ -5068,9 +5112,8 @@ gtk_window_move_resize (GtkWindow *window)
            gdk_window_resize (window->frame,
                               new_request.width + window->frame_left + window->frame_right,
                               new_request.height + window->frame_top + window->frame_bottom);
-         if (widget->window)
-           gdk_window_resize (widget->window,
-                              new_request.width, new_request.height);
+         gdk_window_resize (widget->window,
+                            new_request.width, new_request.height);
        }
       
       /* Increment the number of have-not-yet-received-notify requests */
@@ -5743,6 +5786,7 @@ gtk_window_unmaximize (GtkWindow *window)
  * You can track the fullscreen state via the "window_state_event" signal
  * on #GtkWidget.
  * 
+ * Since: 2.2
  **/
 void
 gtk_window_fullscreen (GtkWindow *window)
@@ -5782,6 +5826,7 @@ gtk_window_fullscreen (GtkWindow *window)
  * You can track the fullscreen state via the "window_state_event" signal
  * on #GtkWidget.
  * 
+ * Since: 2.2
  **/
 void
 gtk_window_unfullscreen (GtkWindow *window)
@@ -6021,6 +6066,8 @@ gtk_window_begin_move_drag  (GtkWindow *window,
  * Sets the #GdkScreen where the @window is displayed; if
  * the window is already mapped, it will be unmapped, and
  * then remapped on the new screen.
+ *
+ * Since: 2.2
  */
 void
 gtk_window_set_screen (GtkWindow *window,
@@ -6077,6 +6124,8 @@ gtk_window_check_screen (GtkWindow *window)
  * Returns the #GdkScreen associated with @window.
  *
  * Return value: a #GdkScreen.
+ *
+ * Since: 2.2
  */
 GdkScreen*
 gtk_window_get_screen (GtkWindow *window)
@@ -6801,6 +6850,7 @@ _gtk_window_set_has_toplevel_focus (GtkWindow *window,
  * temporarily, show your splash screen, then re-enable it so that
  * showing the main window would automatically result in notification.
  * 
+ * Since: 2.2
  **/
 void
 gtk_window_set_auto_startup_notification (gboolean setting)