Don't clamp the restored size of the file chooser dialog
* gtk/gtkfilechooserdialog.c (file_chooser_widget_default_size_changed): Simply resize the dialog to the default size without any fancy clamping. Also, leave in place ifdef-ed out code to restore the file chooser's position in addition to its size. The code to restore the position doesn't quite work yet, but we'll leave it in as a reference. Signed-off-by: Federico Mena Quintero <federico@novell.com> svn path=/trunk/; revision=22118
This commit is contained in:

committed by
Federico Mena Quintero

parent
1d4694ec79
commit
d133ab3ac0
@ -28,6 +28,14 @@
|
|||||||
if the widget is not mapped, to avoid resizing the dialog while it
|
if the widget is not mapped, to avoid resizing the dialog while it
|
||||||
is visible.
|
is visible.
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdialog.c
|
||||||
|
(file_chooser_widget_default_size_changed): Simply resize the
|
||||||
|
dialog to the default size without any fancy clamping. Also,
|
||||||
|
leave in place ifdef-ed out code to restore the file chooser's
|
||||||
|
position in addition to its size. The code to restore the
|
||||||
|
position doesn't quite work yet, but we'll leave it in as a
|
||||||
|
reference.
|
||||||
|
|
||||||
2009-01-13 Matthias Clasen <mclasen@redhat.com>
|
2009-01-13 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
Bug 450716 – New API to change global IM
|
Bug 450716 – New API to change global IM
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "gtkfilechooserwidget.h"
|
#include "gtkfilechooserwidget.h"
|
||||||
#include "gtkfilechooserutils.h"
|
#include "gtkfilechooserutils.h"
|
||||||
#include "gtkfilechooserembed.h"
|
#include "gtkfilechooserembed.h"
|
||||||
|
#include "gtkfilechoosersettings.h"
|
||||||
#include "gtkfilesystem.h"
|
#include "gtkfilesystem.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
@ -154,37 +155,33 @@ file_chooser_widget_file_activated (GtkFileChooser *chooser,
|
|||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* FIXME: to see why this function is ifdef-ed out, see the comment below in
|
||||||
|
* file_chooser_widget_default_size_changed().
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
clamp_to_screen (GtkWidget *widget,
|
load_position (int *out_xpos, int *out_ypos)
|
||||||
gint *width,
|
|
||||||
gint *height)
|
|
||||||
{
|
{
|
||||||
GdkScreen *screen;
|
GtkFileChooserSettings *settings;
|
||||||
int monitor_num;
|
int x, y, width, height;
|
||||||
GdkRectangle monitor;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
|
settings = _gtk_file_chooser_settings_new ();
|
||||||
|
_gtk_file_chooser_settings_get_geometry (settings, &x, &y, &width, &height);
|
||||||
|
g_object_unref (settings);
|
||||||
|
|
||||||
screen = gtk_widget_get_screen (widget);
|
*out_xpos = x;
|
||||||
monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
|
*out_ypos = y;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_chooser_widget_default_size_changed (GtkWidget *widget,
|
file_chooser_widget_default_size_changed (GtkWidget *widget,
|
||||||
GtkFileChooserDialog *dialog)
|
GtkFileChooserDialog *dialog)
|
||||||
{
|
{
|
||||||
GtkFileChooserDialogPrivate *priv;
|
GtkFileChooserDialogPrivate *priv;
|
||||||
gint width, height;
|
|
||||||
gint default_width, default_height;
|
gint default_width, default_height;
|
||||||
GtkRequisition req, widget_req;
|
GtkRequisition req, widget_req;
|
||||||
|
int xpos, ypos;
|
||||||
|
|
||||||
priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
|
priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
|
||||||
|
|
||||||
@ -197,27 +194,29 @@ file_chooser_widget_default_size_changed (GtkWidget *widget,
|
|||||||
* that widget->requisition is meaningful. */
|
* that widget->requisition is meaningful. */
|
||||||
gtk_widget_size_request (GTK_WIDGET (dialog), &req);
|
gtk_widget_size_request (GTK_WIDGET (dialog), &req);
|
||||||
gtk_widget_size_request (widget, &widget_req);
|
gtk_widget_size_request (widget, &widget_req);
|
||||||
|
|
||||||
width = req.width - widget_req.width;
|
|
||||||
height = req.height - widget_req.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
width = GTK_WIDGET (dialog)->allocation.width - widget->allocation.width;
|
|
||||||
height = GTK_WIDGET (dialog)->allocation.height - widget->allocation.height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_gtk_file_chooser_embed_get_default_size (GTK_FILE_CHOOSER_EMBED (priv->widget),
|
_gtk_file_chooser_embed_get_default_size (GTK_FILE_CHOOSER_EMBED (priv->widget),
|
||||||
&default_width, &default_height);
|
&default_width, &default_height);
|
||||||
|
|
||||||
/* Ideal target size plus any extra size */
|
gtk_window_resize (GTK_WINDOW (dialog), default_width, default_height);
|
||||||
width = default_width + width + (2 * GTK_CONTAINER (dialog)->border_width);
|
|
||||||
height = default_height + height + (2 * GTK_CONTAINER (dialog)->border_width);
|
|
||||||
|
|
||||||
if (GTK_WIDGET_REALIZED (dialog))
|
if (!GTK_WIDGET_MAPPED (dialog))
|
||||||
clamp_to_screen (GTK_WIDGET (dialog), &width, &height);
|
{
|
||||||
|
#if 0
|
||||||
gtk_window_resize (GTK_WINDOW (dialog), width, height);
|
/* FIXME: the code to restore the position does not work yet. It is not
|
||||||
|
* clear whether it is actually desirable --- if enabled, applications
|
||||||
|
* would not be able to say "center the file chooser on top of my toplevel
|
||||||
|
* window". So, we don't use this code at all.
|
||||||
|
*/
|
||||||
|
load_position (&xpos, &ypos);
|
||||||
|
if (xpos >= 0 && ypos >= 0)
|
||||||
|
{
|
||||||
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_NONE);
|
||||||
|
gtk_window_move (GTK_WINDOW (dialog), xpos, ypos);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user