]> Pileus Git - ~andy/gtk/commitdiff
Clamp the new size to the screen. Part of bug 129020.
authorSoeren Sandmann <sandmann@daimi.au.dk>
Fri, 12 Mar 2004 22:41:32 +0000 (22:41 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Fri, 12 Mar 2004 22:41:32 +0000 (22:41 +0000)
Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

* gtk/gtkfilechooserdialog.c
(file_chooser_widget_default_realized_size_changed): Clamp the
new size to the screen. Part of bug 129020.

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

index 7b2da00649f72ec58db42a80a959caf7af0e8bcd..f070f86c295a80d8c5b2eab2e772d26736ff3f05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkfilechooserdialog.c
+       (file_chooser_widget_default_realized_size_changed): Clamp the
+       new size to the screen.
+
 Fri Mar 12 15:06:44 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkexpander.c (gtk_expander_realize): Create the
index 7b2da00649f72ec58db42a80a959caf7af0e8bcd..f070f86c295a80d8c5b2eab2e772d26736ff3f05 100644 (file)
@@ -1,3 +1,9 @@
+Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkfilechooserdialog.c
+       (file_chooser_widget_default_realized_size_changed): Clamp the
+       new size to the screen.
+
 Fri Mar 12 15:06:44 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkexpander.c (gtk_expander_realize): Create the
index 7b2da00649f72ec58db42a80a959caf7af0e8bcd..f070f86c295a80d8c5b2eab2e772d26736ff3f05 100644 (file)
@@ -1,3 +1,9 @@
+Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkfilechooserdialog.c
+       (file_chooser_widget_default_realized_size_changed): Clamp the
+       new size to the screen.
+
 Fri Mar 12 15:06:44 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkexpander.c (gtk_expander_realize): Create the
index 7b2da00649f72ec58db42a80a959caf7af0e8bcd..f070f86c295a80d8c5b2eab2e772d26736ff3f05 100644 (file)
@@ -1,3 +1,9 @@
+Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkfilechooserdialog.c
+       (file_chooser_widget_default_realized_size_changed): Clamp the
+       new size to the screen.
+
 Fri Mar 12 15:06:44 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkexpander.c (gtk_expander_realize): Create the
index 7b2da00649f72ec58db42a80a959caf7af0e8bcd..f070f86c295a80d8c5b2eab2e772d26736ff3f05 100644 (file)
@@ -1,3 +1,9 @@
+Fri Mar 12 23:37:15 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkfilechooserdialog.c
+       (file_chooser_widget_default_realized_size_changed): Clamp the
+       new size to the screen.
+
 Fri Mar 12 15:06:44 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkexpander.c (gtk_expander_realize): Create the
index 24ea732b6ed0b94a077fe91056ac17be82545e60..4f61abe967c67430a244df434f8d47473b9320c7 100644 (file)
@@ -211,6 +211,29 @@ file_chooser_widget_update_hints (GtkFileChooserDialog *dialog)
                                 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
 }
 
+static void
+clamp_to_screen (GtkWidget *widget,
+                gint      *width,
+                gint      *height)
+{
+  GdkScreen *screen;
+  int monitor_num;
+  GdkRectangle monitor;
+
+  g_return_if_fail (GTK_WIDGET_REALIZED (widget));
+  
+  screen = gtk_widget_get_screen (widget);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+
+  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+  if (width)
+    *width = MIN (*width, (monitor.width * 3) / 4);
+
+  if (height)
+    *height = MIN (*height, (monitor.height * 3) / 4);
+}
+
 static void
 file_chooser_widget_default_realized_size_changed (GtkWidget            *widget,
                                                   GtkFileChooserDialog *dialog)
@@ -289,12 +312,14 @@ file_chooser_widget_default_realized_size_changed (GtkWidget            *widget,
   priv->resize_horizontally = resize_horizontally;
   priv->resize_vertically = resize_vertically;
 
-  /* FIXME: We should make sure that we arent' bigger than the current screen */
   if (dx != 0 || dy != 0)
     {
-      gtk_window_resize (GTK_WINDOW (dialog),
-                        cur_width + dx,
-                        cur_height + dy);
+      gint new_width = cur_width + dx;
+      gint new_height = cur_height + dy;
+
+      clamp_to_screen (GTK_WIDGET (dialog), &new_width, &new_height);
+      
+      gtk_window_resize (GTK_WINDOW (dialog), new_width, new_height);
     }
 
   /* Only store the size if we can resize in that direction. */