summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorSoeren Sandmann <sandmann@daimi.au.dk>2004-03-12 22:41:32 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2004-03-12 22:41:32 +0000
commit543b1c2f78010616b963d0dad0211ecd8e1d29a9 (patch)
tree197a1c019c70fe1d7cb6886aa073e60e03d2bfcd /gtk
parent1c188e7c2bfd8f2f735d26336c08559277f90fce (diff)
downloadgdk-pixbuf-543b1c2f78010616b963d0dad0211ecd8e1d29a9.tar.gz
Clamp the new size to the screen. Part of bug 129020.
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.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkfilechooserdialog.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 24ea732b6..4f61abe96 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -212,6 +212,29 @@ file_chooser_widget_update_hints (GtkFileChooserDialog *dialog)
}
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. */