Commit d3a43f73 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Fix to properly take the default window into account by setting a flag and

Sun Mar  3 18:47:13 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
        to properly take the default window into account by
        setting a flag and in gtk_window_compute_configure_request_size ()
        multiplying by the increments and adding in the base
        size. (#72393)

        * tests/testgtk.c (create_gridded_geometry): Add a
        test for gridded geometry and for gtk_window_parse_geometry().
parent 86dec809
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
Sun Mar 3 18:47:13 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_parse_geometry): Fix
to properly take the default window into account by
setting a flag and in gtk_window_compute_configure_request_size ()
multiplying by the increments and adding in the base
size. (#72393)
* tests/testgtk.c (create_gridded_geometry): Add a
test for gridded geometry and for gtk_window_parse_geometry().
2002-03-04 Hans Breuer <hans@breuer.org>
* gtk/makefile.msc.in : don't build gtk.defs anymore
......
......@@ -118,6 +118,12 @@ struct _GtkWindowGeometryInfo
* we sent the last configure request.
*/
guint position_constraints_changed : 1;
/* if true, default_width, height come from gtk_window_parse_geometry,
* and thus should be multiplied by the increments and affect the
* geometry widget only
*/
guint default_is_geometry : 1;
GtkWindowLastGeometryInfo last;
};
......@@ -220,7 +226,8 @@ static void gtk_window_set_default_size_internal (GtkWindow *window,
gboolean change_width,
gint width,
gboolean change_height,
gint height);
gint height,
gboolean is_geometry);
static void gtk_window_realize_icon (GtkWindow *window);
static void gtk_window_unrealize_icon (GtkWindow *window);
......@@ -675,12 +682,12 @@ gtk_window_set_property (GObject *object,
case PROP_DEFAULT_WIDTH:
gtk_window_set_default_size_internal (window,
TRUE, g_value_get_int (value),
FALSE, -1);
FALSE, -1, FALSE);
break;
case PROP_DEFAULT_HEIGHT:
gtk_window_set_default_size_internal (window,
FALSE, -1,
TRUE, g_value_get_int (value));
TRUE, g_value_get_int (value), FALSE);
break;
case PROP_DESTROY_WITH_PARENT:
gtk_window_set_destroy_with_parent (window, g_value_get_boolean (value));
......@@ -1755,6 +1762,7 @@ gtk_window_get_geometry_info (GtkWindow *window,
info->initial_x = 0;
info->initial_y = 0;
info->initial_pos_set = FALSE;
info->default_is_geometry = FALSE;
info->position_constraints_changed = FALSE;
info->last.configure_request.x = 0;
info->last.configure_request.y = 0;
......@@ -2340,7 +2348,8 @@ gtk_window_set_default_size_internal (GtkWindow *window,
gboolean change_width,
gint width,
gboolean change_height,
gint height)
gint height,
gboolean is_geometry)
{
GtkWindowGeometryInfo *info;
......@@ -2351,6 +2360,8 @@ gtk_window_set_default_size_internal (GtkWindow *window,
g_object_freeze_notify (G_OBJECT (window));
info->default_is_geometry = is_geometry != FALSE;
if (change_width)
{
if (width == 0)
......@@ -2426,7 +2437,7 @@ gtk_window_set_default_size (GtkWindow *window,
g_return_if_fail (width >= -1);
g_return_if_fail (height >= -1);
gtk_window_set_default_size_internal (window, TRUE, width, TRUE, height);
gtk_window_set_default_size_internal (window, TRUE, width, TRUE, height, FALSE);
}
/**
......@@ -3875,11 +3886,41 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
if (info)
{
if (info->default_width > 0)
*width = info->default_width;
if (info->default_height > 0)
*height = info->default_height;
gint base_width = 0;
gint base_height = 0;
gint width_inc = 1;
gint height_inc = 1;
if (info->default_is_geometry &&
(info->default_width > 0 || info->default_height > 0))
{
GdkGeometry geometry;
guint flags;
gtk_window_compute_hints (window, &geometry, &flags);
if (flags & GDK_HINT_BASE_SIZE)
{
base_width = geometry.base_width;
base_height = geometry.base_height;
}
else if (flags & GDK_HINT_MIN_SIZE)
{
base_width = geometry.min_width;
base_height = geometry.min_height;
}
if (flags & GDK_HINT_RESIZE_INC)
{
width_inc = geometry.width_inc;
height_inc = geometry.height_inc;
}
}
if (info->default_width > 0)
*width = info->default_width * width_inc + base_width;
if (info->default_height > 0)
*height = info->default_height * height_inc + base_height;
}
}
else
......@@ -5602,14 +5643,7 @@ gtk_window_parse_geometry (GtkWindow *window,
size_set = FALSE;
if ((result & WidthValue) || (result & HeightValue))
{
GtkWindowGeometryInfo *info;
info = gtk_window_get_geometry_info (window, FALSE);
if (info && info->mask & GDK_HINT_RESIZE_INC)
{
w *= info->geometry.width_inc;
h *= info->geometry.height_inc;
}
gtk_window_set_default_size (window, w, h);
gtk_window_set_default_size_internal (window, TRUE, w, TRUE, h, TRUE);
size_set = TRUE;
}
......
......@@ -1762,6 +1762,150 @@ create_tree_mode_window(void)
gtk_widget_destroy (window);
}
/*
* Gridded geometry
*/
#define GRID_SIZE 20
#define DEFAULT_GEOMETRY "10x10"
static gboolean
gridded_geometry_expose (GtkWidget *widget,
GdkEventExpose *event)
{
int i, j;
gdk_draw_rectangle (widget->window, widget->style->base_gc[widget->state], TRUE,
0, 0, widget->allocation.width, widget->allocation.height);
for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++)
for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++)
{
if ((i + j) % 2 == 0)
gdk_draw_rectangle (widget->window, widget->style->text_gc[widget->state], TRUE,
i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
}
return FALSE;
}
static void
gridded_geometry_subresponse (GtkDialog *dialog,
gint response_id,
gchar *geometry_string)
{
if (response_id == GTK_RESPONSE_NONE)
{
gtk_widget_destroy (GTK_WIDGET (dialog));
}
else
{
if (!gtk_window_parse_geometry (GTK_WINDOW (dialog), geometry_string))
{
g_print ("Can't parse geometry string %s\n", geometry_string);
gtk_window_parse_geometry (GTK_WINDOW (dialog), DEFAULT_GEOMETRY);
}
}
}
static void
gridded_geometry_response (GtkDialog *dialog,
gint response_id,
GtkEntry *entry)
{
if (response_id == GTK_RESPONSE_NONE)
{
gtk_widget_destroy (GTK_WIDGET (dialog));
}
else
{
gchar *geometry_string = g_strdup (gtk_entry_get_text (entry));
gchar *title = g_strdup_printf ("Gridded window at: %s", geometry_string);
GtkWidget *window;
GtkWidget *drawing_area;
GtkWidget *box;
GdkGeometry geometry;
window = gtk_dialog_new_with_buttons (title,
NULL, 0,
"Reset", 1,
GTK_STOCK_CLOSE, GTK_RESPONSE_NONE,
NULL);
g_free (title);
g_signal_connect (window, "response",
G_CALLBACK (gridded_geometry_subresponse), geometry_string);
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), box, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 7);
drawing_area = gtk_drawing_area_new ();
g_signal_connect (drawing_area, "expose_event",
G_CALLBACK (gridded_geometry_expose), NULL);
gtk_box_pack_start (GTK_BOX (box), drawing_area, TRUE, TRUE, 0);
/* Gross hack to work around bug 68668... if we set the size request
* large enough, then the current
*
* request_of_window - request_of_geometry_widget
*
* method of getting the base size works more or less works.
*/
gtk_widget_set_size_request (drawing_area, 2000, 2000);
geometry.base_width = 0;
geometry.base_height = 0;
geometry.min_width = 2 * GRID_SIZE;
geometry.min_height = 2 * GRID_SIZE;
geometry.width_inc = GRID_SIZE;
geometry.height_inc = GRID_SIZE;
gtk_window_set_geometry_hints (GTK_WINDOW (window), drawing_area,
&geometry,
GDK_HINT_BASE_SIZE | GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
if (!gtk_window_parse_geometry (GTK_WINDOW (window), geometry_string))
{
g_print ("Can't parse geometry string %s\n", geometry_string);
gtk_window_parse_geometry (GTK_WINDOW (window), DEFAULT_GEOMETRY);
}
gtk_widget_show_all (window);
}
}
static void
create_gridded_geometry (void)
{
static GtkWidget *window = NULL;
GtkWidget *entry;
GtkWidget *label;
if (!window)
{
window = gtk_dialog_new_with_buttons ("Gridded Geometry",
NULL, 0,
"Create", 1,
GTK_STOCK_CLOSE, GTK_RESPONSE_NONE,
NULL);
label = gtk_label_new ("Geometry string:");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), label, FALSE, FALSE, 0);
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), DEFAULT_GEOMETRY);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), entry, FALSE, FALSE, 0);
g_signal_connect (window, "response",
G_CALLBACK (gridded_geometry_response), entry);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_widget_show_all (window);
}
else
gtk_widget_destroy (window);
}
/*
* GtkHandleBox
*/
......@@ -11444,6 +11588,7 @@ struct {
{ "focus", create_focus },
{ "font selection", create_font_selection },
{ "gamma curve", create_gamma_curve, TRUE },
{ "gridded geometry", create_gridded_geometry, TRUE },
{ "handle box", create_handle_box },
{ "image from drawable", create_get_image },
{ "image", create_image },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment