]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwindow.c
Updated Slovenian translation
[~andy/gtk] / gtk / gtkwindow.c
index 1cdad4e04338c9af7ca0ad0afeefe5890c60fbe0..098488667fb2a8b172ccd753520a239feadbab4c 100644 (file)
@@ -98,6 +98,8 @@
  * </refsect2>
  */
 
+#define AUTO_MNEMONICS_DELAY 300 /* ms */
+
 typedef struct _GtkDeviceGrabInfo GtkDeviceGrabInfo;
 
 struct _GtkWindowPrivate
@@ -132,6 +134,8 @@ struct _GtkWindowPrivate
 
   guint16  configure_request_count;
 
+  guint    auto_mnemonics_timeout_id;
+
   /* The following flags are initially TRUE (before a window is mapped).
    * They cause us to compute a configure request that involves
    * default-only parameters. Once mapped, we set them to FALSE.
@@ -471,14 +475,6 @@ static void gtk_window_buildable_custom_finished (GtkBuildable  *buildable,
                                                      const gchar   *tagname,
                                                      gpointer       user_data);
 
-
-static void gtk_window_get_preferred_width    (GtkWidget           *widget,
-                                              gint                *minimum_size,
-                                              gint                *natural_size);
-static void gtk_window_get_preferred_height   (GtkWidget           *widget,
-                                              gint                *minimum_size,
-                                              gint                *natural_size);
-
 static void ensure_state_flag_backdrop (GtkWidget *widget);
 
 G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
@@ -591,8 +587,6 @@ gtk_window_class_init (GtkWindowClass *klass)
   widget_class->focus = gtk_window_focus;
   widget_class->move_focus = gtk_window_move_focus;
   widget_class->draw = gtk_window_draw;
-  widget_class->get_preferred_width = gtk_window_get_preferred_width;
-  widget_class->get_preferred_height = gtk_window_get_preferred_height;
   widget_class->window_state_event = gtk_window_state_event;
   widget_class->direction_changed = gtk_window_direction_changed;
   widget_class->state_changed = gtk_window_state_changed;
@@ -1144,6 +1138,7 @@ gtk_window_class_init (GtkWindowClass *klass)
 static void
 gtk_window_init (GtkWindow *window)
 {
+  GtkStyleContext *context;
   GtkWindowPrivate *priv;
 
   window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window,
@@ -1203,6 +1198,9 @@ gtk_window_init (GtkWindow *window)
                     "notify::gtk-application-prefer-dark-theme",
                     G_CALLBACK (gtk_window_on_theme_variant_changed), window);
 #endif
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (window));
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
 }
 
 static void
@@ -1927,8 +1925,8 @@ _gtk_window_internal_set_focus (GtkWindow *window,
  * unsets the default widget for a #GtkWindow about. When setting
  * (rather than unsetting) the default widget it's generally easier to
  * call gtk_widget_grab_focus() on the widget. Before making a widget
- * the default widget, you must set the #GTK_CAN_DEFAULT flag on the
- * widget you'd like to make the default using GTK_WIDGET_SET_FLAGS().
+ * the default widget, you must call gtk_widget_set_can_default() on the
+ * widget you'd like to make the default.
  **/
 void
 gtk_window_set_default (GtkWindow *window,
@@ -2820,6 +2818,9 @@ gtk_window_set_application (GtkWindow      *window,
           gtk_application_add_window (priv->application, window);
         }
 
+      /* don't use a normal cast: application may be NULL */
+      gtk_widget_insert_action_group (GTK_WIDGET (window), "app", (GActionGroup *) application);
+
       g_object_notify (G_OBJECT (window), "application");
     }
 }
@@ -3401,7 +3402,7 @@ gtk_window_get_decorated (GtkWindow *window)
  * using this function, GTK+ will do its best to convince the window
  * manager not to show a close button. Depending on the system, this
  * function may not have any effect when called on a window that is
- * already visible, so you should call it before calling gtk_window_show().
+ * already visible, so you should call it before calling gtk_widget_show().
  *
  * On Windows, this function always works, since there's no window manager
  * policy involved.
@@ -4780,6 +4781,12 @@ gtk_window_finalize (GObject *object)
 
   g_free (priv->startup_id);
 
+  if (priv->auto_mnemonics_timeout_id)
+    {
+      g_source_remove (priv->auto_mnemonics_timeout_id);
+      priv->auto_mnemonics_timeout_id = 0;
+    }
+
 #ifdef GDK_WINDOWING_X11
   g_signal_handlers_disconnect_by_func (gtk_settings_get_default (),
                                         gtk_window_on_theme_variant_changed,
@@ -4795,6 +4802,7 @@ gtk_window_show (GtkWidget *widget)
   GtkWindow *window = GTK_WINDOW (widget);
   GtkWindowPrivate *priv = window->priv;
   GtkContainer *container = GTK_CONTAINER (window);
+  GtkBitmask *empty;
   gboolean need_resize;
   gboolean is_plug;
 
@@ -4808,9 +4816,12 @@ gtk_window_show (GtkWidget *widget)
 
   need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
 
+  empty = _gtk_bitmask_new ();
   _gtk_style_context_validate (gtk_widget_get_style_context (widget),
                                g_get_monotonic_time (),
-                               0);
+                               0,
+                               empty);
+  _gtk_bitmask_free (empty);
 
   if (need_resize)
     {
@@ -5017,8 +5028,6 @@ gtk_window_map (GtkWidget *widget)
     gtk_window_set_focus_visible (window, gtk_window_get_focus_visible (priv->transient_parent));
   else
     gtk_window_set_focus_visible (window, visible_focus == GTK_POLICY_ALWAYS);
-
-  ensure_state_flag_backdrop (widget);
 }
 
 static gboolean
@@ -5657,7 +5666,6 @@ gtk_window_configure_event (GtkWidget         *widget,
 
   /*
    * If we do need to resize, we do that by:
-   *   - filling in widget->allocation with the new size
    *   - setting configure_notify_received to TRUE
    *     for use in gtk_window_move_resize()
    *   - queueing a resize, leading to invocation of
@@ -5667,10 +5675,6 @@ gtk_window_configure_event (GtkWidget         *widget,
   
   priv->configure_notify_received = TRUE;
 
-  allocation.width = event->width;
-  allocation.height = event->height;
-  gtk_widget_set_allocation (widget, &allocation);
-
   gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE); // XXX - What was this for again?
 
   _gtk_container_queue_resize (GTK_CONTAINER (widget));
@@ -5726,7 +5730,6 @@ gtk_window_style_updated (GtkWidget *widget)
                               rect.width, rect.height);
 
       set_grip_shape (window);
-      gtk_widget_queue_resize (widget);
     }
 }
 
@@ -6229,7 +6232,7 @@ maybe_set_mnemonics_visible (GtkWindow *window)
                                 NULL, &mask);
           if (window->priv->mnemonic_modifier == (mask & gtk_accelerator_get_default_mod_mask ()))
             {
-              gtk_window_set_mnemonics_visible (window, TRUE);
+              _gtk_window_set_auto_mnemonics_visible (window);
               break;
             }
         }
@@ -6471,60 +6474,6 @@ gtk_window_real_set_focus (GtkWindow *window,
     }
 }
 
-
-static void 
-gtk_window_get_preferred_width (GtkWidget *widget,
-                                gint      *minimum_size,
-                                gint      *natural_size)
-{
-  GtkWindow *window;
-  GtkWidget *child;
-  guint border_width;
-
-  window = GTK_WINDOW (widget);
-  child  = gtk_bin_get_child (GTK_BIN (window));
-
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
-  *minimum_size = border_width * 2;
-  *natural_size = border_width * 2;
-
-  if (child && gtk_widget_get_visible (child))
-    {
-      gint child_min, child_nat;
-      gtk_widget_get_preferred_width (child, &child_min, &child_nat);
-
-      *minimum_size += child_min;
-      *natural_size += child_nat;
-    }
-}
-
-static void 
-gtk_window_get_preferred_height (GtkWidget *widget,
-                                 gint      *minimum_size,
-                                 gint      *natural_size)
-{
-  GtkWindow *window;
-  GtkWidget *child;
-  guint border_width;
-
-  window = GTK_WINDOW (widget);
-  child  = gtk_bin_get_child (GTK_BIN (window));
-
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
-  *minimum_size = border_width * 2;
-  *natural_size = border_width * 2;
-
-  if (child && gtk_widget_get_visible (child))
-    {
-      gint child_min, child_nat;
-      gtk_widget_get_preferred_height (child, &child_min, &child_nat);
-
-      *minimum_size += child_min;
-      *natural_size += child_nat;
-    }
-}
-
-
 /**
  * _gtk_window_unset_focus_and_default:
  * @window: a #GtkWindow
@@ -7222,7 +7171,10 @@ gtk_window_move_resize (GtkWindow *window)
                                   &new_geometry,
                                   new_flags);
 
-  gtk_widget_get_allocation (widget, &allocation);
+  allocation.x = 0;
+  allocation.y = 0;
+  allocation.width = gdk_window_get_width (gdk_window);
+  allocation.height = gdk_window_get_height (gdk_window);
 
   /* handle resizing/moving and widget tree allocation
    */
@@ -7660,14 +7612,9 @@ gtk_window_draw (GtkWidget *widget,
   if (!gtk_widget_get_app_paintable (widget) &&
       gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
     {
-      gtk_style_context_save (context);
-
-      gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
       gtk_render_background (context, cr, 0, 0,
                             gtk_widget_get_allocated_width (widget),
                             gtk_widget_get_allocated_height (widget));
-
-      gtk_style_context_restore (context);
     }
 
   if (GTK_WIDGET_CLASS (gtk_window_parent_class)->draw)
@@ -7684,6 +7631,7 @@ gtk_window_draw (GtkWidget *widget,
       gtk_cairo_transform_to_window (cr, widget, priv->grip_window);
       gtk_window_get_resize_grip_area (GTK_WINDOW (widget), &rect);
 
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BACKGROUND);
       gtk_style_context_add_class (context, GTK_STYLE_CLASS_GRIP);
       gtk_style_context_set_junction_sides (context, get_grip_junction (widget));
       gtk_render_handle (context, cr, 0, 0, rect.width, rect.height);
@@ -8200,7 +8148,7 @@ gtk_window_set_resizable (GtkWindow *window,
 
   if (priv->resizable != resizable)
     {
-      priv->resizable = (resizable != FALSE);
+      priv->resizable = resizable;
 
       update_grip_visibility (window);
 
@@ -9574,8 +9522,8 @@ _gtk_window_set_is_active (GtkWindow *window,
  * in-process, parented GtkPlug)
  *
  * Internal function used by #GtkPlug when it gets parented/unparented by a
- * #GtkSocket.  This keeps the @window's #GTK_TOPLEVEL flag in sync with the
- * global list of toplevel windows.
+ * #GtkSocket.  This keeps the @window's #GTK_WINDOW_TOPLEVEL flag in sync
+ * with the global list of toplevel windows.
  */
 void
 _gtk_window_set_is_toplevel (GtkWindow *window,
@@ -9753,9 +9701,39 @@ gtk_window_set_mnemonics_visible (GtkWindow *window,
       g_object_notify (G_OBJECT (window), "mnemonics-visible");
     }
 
+  if (priv->auto_mnemonics_timeout_id)
+    {
+      g_source_remove (priv->auto_mnemonics_timeout_id);
+      priv->auto_mnemonics_timeout_id = 0;
+    }
+
   priv->mnemonics_visible_set = TRUE;
 }
 
+static gboolean
+set_auto_mnemonics_visible_cb (gpointer data)
+{
+  GtkWindow *window = data;
+
+  gtk_window_set_mnemonics_visible (window, TRUE);
+
+  window->priv->auto_mnemonics_timeout_id = 0;
+
+  return FALSE;
+}
+
+void
+_gtk_window_set_auto_mnemonics_visible (GtkWindow *window)
+{
+  g_return_if_fail (GTK_IS_WINDOW (window));
+
+  if (window->priv->auto_mnemonics_timeout_id)
+    return;
+
+  window->priv->auto_mnemonics_timeout_id =
+    gdk_threads_add_timeout (AUTO_MNEMONICS_DELAY, set_auto_mnemonics_visible_cb, window);
+}
+
 /**
  * gtk_window_get_focus_visible:
  * @window: a #GtkWindow
@@ -9820,7 +9798,7 @@ _gtk_window_get_wmclass (GtkWindow  *window,
  * @setting: the new value
  *
  * Tells GTK+ whether to drop its extra reference to the window
- * when gtk_window_destroy() is called.
+ * when gtk_widget_destroy() is called.
  *
  * This function is only exported for the benefit of language
  * bindings which may need to keep the window alive until their