diff options
author | Owen Taylor <otaylor@gtk.org> | 1998-06-19 01:26:24 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-06-19 01:26:24 +0000 |
commit | 913831b26f3b4b0a69dce8574017a78828e93b83 (patch) | |
tree | 6454867cb387f24084917262261e1cdd7c4dcf89 /gtk/gtkwindow.c | |
parent | 25bd56b9957d930a2edd573d52ef389493a224ae (diff) | |
download | gtk+-913831b26f3b4b0a69dce8574017a78828e93b83.tar.gz |
Remove --g-fatal-warnings flag from argv.
Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag
from argv.
Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org>
* gtk/genmarshal.pl: Modified to be more idiomatic Perl,
to be more readable perl, to spit out stuff that looks
more like readable C, and to pipe output through indent
so output looks a lot like readable C. No functional
changes.
Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if
necessary when switching to a masked pixmap. (Based on a patch
from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>)
Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkeditable.[ch]: Added action signals for keyboard
bindings. (move_cursor, kill_word, etc, etc, etc).
removed the time argument from
gtk_editable_cut/copy/paste_clipboard (source but not
binary incompatible...) Instead get time from
gtk_get_current_event ().
* gtk/gtktext.c gtk/gtkentry.c: Support the new editable
signals.
Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org>
Patches from Damon Chaplin <DAChaplin@email.msn.com>:
gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change
parent class to GtkNotebookClass when splitting the widget in
two. Also updated some comments.
gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps'
button without a font selected.
Fixed bug in set_font_name - I hadn't updated the code to
search for the style in the font_style clist - it was
still assuming the style row was equal to its index,
but it isn't any more.
Changed 'Reset' button on filter page to 'Clear Filter'.
Deleted old code relating to the old 'Filter Fonts' toggle
Updated some comments.
Cleared 'Actual Fontname' if no font is set.
gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was
destroying the GtkFontSelection instead of the
GtkFontSelectionDialog.
Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings
flag to make all warnings fatal errors.
* gtk/testthreads.c: moved <pthreads.h> include inside
#ifdef USE_PTHREADS
Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c
gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c:
- Added new function gtk_container_set_resize_mode() for
fine-grained control of where resize-queueing is done.
- Removed GtkContainer::need_resize and GtkWindow::move_resize
- Added GtkContainer::check_resize to replace need_resize.
- Added function gtk_container_check_resize() to trigger
queued resizes, and gtk_container_resize_children() to
Figure which children need to be size-allocated. (logic
moved from gtkwindow.c)
- Reorganized code in gtkwindow.c
- Set the resize-mode for viewports so that resizes within
a viewport don't propagate out of it.
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r-- | gtk/gtkwindow.c | 316 |
1 files changed, 87 insertions, 229 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 6a5c89dfcb..04ab0b14ff 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -28,7 +28,6 @@ #include "gtkbindings.h" enum { - MOVE_RESIZE, SET_FOCUS, LAST_SIGNAL }; @@ -52,10 +51,6 @@ typedef void (*GtkWindowSignal2) (GtkObject *object, gpointer arg1, gpointer data); -static void gtk_window_marshal_signal_1 (GtkObject *object, - GtkSignalFunc func, - gpointer func_data, - GtkArg *args); static void gtk_window_marshal_signal_2 (GtkObject *object, GtkSignalFunc func, gpointer func_data, @@ -97,15 +92,10 @@ static gint gtk_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event); static gint gtk_window_client_event (GtkWidget *widget, GdkEventClient *event); -static gint gtk_window_need_resize (GtkContainer *container); -static gint gtk_real_window_move_resize (GtkWindow *window, - gint *x, - gint *y, - gint width, - gint height); +static void gtk_window_check_resize (GtkContainer *container); static void gtk_real_window_set_focus (GtkWindow *window, GtkWidget *focus); -static gint gtk_window_move_resize (GtkWidget *widget); +static void gtk_window_move_resize (GtkWindow *window); static void gtk_window_set_hints (GtkWidget *widget, GtkRequisition *requisition); @@ -161,16 +151,6 @@ gtk_window_class_init (GtkWindowClass *klass) gtk_object_add_arg_type ("GtkWindow::allow_grow", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_GROW); gtk_object_add_arg_type ("GtkWindow::window_position", GTK_TYPE_WINDOW_POSITION, GTK_ARG_READWRITE, ARG_WIN_POS); - window_signals[MOVE_RESIZE] = - gtk_signal_new ("move_resize", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GtkWindowClass, move_resize), - gtk_window_marshal_signal_1, - GTK_TYPE_BOOL, 4, - GTK_TYPE_POINTER, GTK_TYPE_POINTER, - GTK_TYPE_INT, GTK_TYPE_INT); - window_signals[SET_FOCUS] = gtk_signal_new ("set_focus", GTK_RUN_LAST, @@ -202,9 +182,8 @@ gtk_window_class_init (GtkWindowClass *klass) widget_class->focus_out_event = gtk_window_focus_out_event; widget_class->client_event = gtk_window_client_event; - container_class->need_resize = gtk_window_need_resize; + container_class->check_resize = gtk_window_check_resize; - klass->move_resize = gtk_real_window_move_resize; klass->set_focus = gtk_real_window_set_focus; } @@ -221,7 +200,6 @@ gtk_window_init (GtkWindow *window) window->focus_widget = NULL; window->default_widget = NULL; window->resize_count = 0; - window->need_resize = FALSE; window->allow_shrink = FALSE; window->allow_grow = TRUE; window->auto_shrink = FALSE; @@ -229,6 +207,7 @@ gtk_window_init (GtkWindow *window) window->position = GTK_WIN_POS_NONE; window->use_uposition = TRUE; + gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE); gtk_container_register_toplevel (GTK_CONTAINER (window)); } @@ -455,26 +434,6 @@ gtk_window_activate_default (GtkWindow *window) } static void -gtk_window_marshal_signal_1 (GtkObject *object, - GtkSignalFunc func, - gpointer func_data, - GtkArg *args) -{ - GtkWindowSignal1 rfunc; - gint *return_val; - - rfunc = (GtkWindowSignal1) func; - return_val = GTK_RETLOC_BOOL (args[4]); - - *return_val = (* rfunc) (object, - GTK_VALUE_POINTER (args[0]), - GTK_VALUE_POINTER (args[1]), - GTK_VALUE_INT (args[2]), - GTK_VALUE_INT (args[3]), - func_data); -} - -static void gtk_window_marshal_signal_2 (GtkObject *object, GtkSignalFunc func, gpointer func_data, @@ -522,7 +481,7 @@ gtk_window_show (GtkWidget *widget) g_return_if_fail (GTK_IS_WINDOW (widget)); GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE); - gtk_container_need_resize (GTK_CONTAINER (widget)); + gtk_container_check_resize (GTK_CONTAINER (widget)); gtk_widget_map (widget); } @@ -650,7 +609,7 @@ gtk_window_size_request (GtkWidget *widget, else { if (!GTK_WIDGET_VISIBLE (window)) - window->need_resize = TRUE; + GTK_CONTAINER (window)->need_resize = TRUE; } } @@ -973,47 +932,92 @@ gtk_window_client_event (GtkWidget *widget, return FALSE; } -static gint -gtk_window_need_resize (GtkContainer *container) +static void +gtk_window_check_resize (GtkContainer *container) { GtkWindow *window; - gint return_val; - - g_return_val_if_fail (container != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WINDOW (container), FALSE); - return_val = FALSE; + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_WINDOW (container)); window = GTK_WINDOW (container); - if (window->handling_resize) - return return_val; - - if (GTK_WIDGET_VISIBLE (container)) - return_val = gtk_window_move_resize (GTK_WIDGET (window)); - else - window->need_resize = TRUE; - - return return_val; + if (!window->handling_resize) + { + if (GTK_WIDGET_VISIBLE (container)) + gtk_window_move_resize (window); + else + GTK_CONTAINER (window)->need_resize = TRUE; + } } -static gint -gtk_real_window_move_resize (GtkWindow *window, - gint *x, - gint *y, - gint width, - gint height) +/* FIXME: we leave container->resize_widgets set under some + circumstances ? */ +static void +gtk_window_move_resize (GtkWindow *window) { - GtkWidget *widget; + GtkWidget *widget; + GtkContainer *container; + gint x, y; + gint width, height; + gint screen_width; + gint screen_height; gboolean needed_resize; - - g_return_val_if_fail (window != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); - g_return_val_if_fail ((x != NULL) || (y != NULL), FALSE); + + g_return_if_fail (window != NULL); + g_return_if_fail (GTK_IS_WINDOW (window)); widget = GTK_WIDGET (window); + container = GTK_CONTAINER (widget); + + /* Remember old size, to know if we have to reset hints */ + width = widget->requisition.width; + height = widget->requisition.height; + gtk_widget_size_request (widget, &widget->requisition); + + if ((width != widget->requisition.width || + height != widget->requisition.height)) + gtk_window_set_hints (widget, &widget->requisition); + + x = -1; + y = -1; + width = widget->requisition.width; + height = widget->requisition.height; + + if (window->use_uposition) + switch (window->position) + { + case GTK_WIN_POS_CENTER: + x = (gdk_screen_width () - width) / 2; + y = (gdk_screen_height () - height) / 2; + gtk_widget_set_uposition (widget, x, y); + break; + case GTK_WIN_POS_MOUSE: + gdk_window_get_pointer (NULL, &x, &y, NULL); + + x -= width / 2; + y -= height / 2; + + screen_width = gdk_screen_width (); + screen_height = gdk_screen_height (); + + if (x < 0) + x = 0; + else if (x > (screen_width - width)) + x = screen_width - width; + + if (y < 0) + y = 0; + else if (y > (screen_height - height)) + y = screen_height - height; + + gtk_widget_set_uposition (widget, x, y); + break; + } - needed_resize = window->need_resize; - window->need_resize = FALSE; + /* Now, do the resizing */ + + needed_resize = container->need_resize; + container->need_resize = FALSE; if ((widget->requisition.width == 0) || (widget->requisition.height == 0)) @@ -1033,7 +1037,7 @@ gtk_real_window_move_resize (GtkWindow *window, gtk_widget_size_allocate (widget, &allocation); - return FALSE; + return; } gdk_window_get_geometry (widget->window, NULL, NULL, &width, &height, NULL); @@ -1045,8 +1049,8 @@ gtk_real_window_move_resize (GtkWindow *window, (height < widget->requisition.height)) { window->resize_count += 1; - if ((*x != -1) && (*y != -1)) - gdk_window_move_resize (widget->window, *x, *y, + if ((x != -1) && (y != -1)) + gdk_window_move_resize (widget->window, x, y, widget->requisition.width, widget->requisition.height); else @@ -1068,161 +1072,15 @@ gtk_real_window_move_resize (GtkWindow *window, allocation.height = widget->requisition.height; gtk_widget_size_allocate (widget, &allocation); + gtk_container_clear_resize_widgets (GTK_CONTAINER (window)); } else { - /* The window hasn't changed size but one of its children - * queued a resize request. Which means that the allocation - * is not sufficient for the requisition of some child. - * We've already performed a size request at this point, - * so we simply need to run through the list of resize - * widgets and reallocate their sizes appropriately. We - * make the optimization of not performing reallocation - * for a widget who also has a parent in the resize widgets - * list. GTK_RESIZE_NEEDED is used for flagging those - * parents inside this function. - */ - GSList *resize_widgets; - GSList *resize_containers; - GSList *node; - - if ((*x != -1) && (*y != -1)) - gdk_window_move (widget->window, *x, *y); + if ((x != -1) && (y != -1)) + gdk_window_move (widget->window, x, y); - resize_widgets = GTK_CONTAINER (window)->resize_widgets; - GTK_CONTAINER (window)->resize_widgets = NULL; - - for (node = resize_widgets; node; node = node->next) - { - widget = node->data; - - GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED); - - while (widget && widget->parent && - ((widget->allocation.width < widget->requisition.width) || - (widget->allocation.height < widget->requisition.height))) - widget = widget->parent; - - GTK_PRIVATE_SET_FLAG (widget, GTK_RESIZE_NEEDED); - node->data = widget; - } - - resize_containers = NULL; - - for (node = resize_widgets; node; node = node->next) - { - GtkWidget *resize_container; - - widget = node->data; - - if (!GTK_WIDGET_RESIZE_NEEDED (widget)) - continue; - - resize_container = widget->parent; - - if (resize_container) - { - GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED); - widget = resize_container->parent; - - while (widget) - { - if (GTK_WIDGET_RESIZE_NEEDED (widget)) - { - GTK_PRIVATE_UNSET_FLAG (resize_container, GTK_RESIZE_NEEDED); - resize_container = widget; - } - widget = widget->parent; - } - } - else - resize_container = widget; - - if (!g_slist_find (resize_containers, resize_container)) - resize_containers = g_slist_prepend (resize_containers, - resize_container); - } - g_slist_free (resize_widgets); - - for (node = resize_containers; node; node = node->next) - { - widget = node->data; - - GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED); - gtk_widget_size_allocate (widget, &widget->allocation); - gtk_widget_queue_draw (widget); - } - g_slist_free (resize_containers); + gtk_container_resize_children (GTK_CONTAINER (window)); } - - return FALSE; -} - -static gint -gtk_window_move_resize (GtkWidget *widget) -{ - GtkWindow *window; - gint x, y; - gint width, height; - gint screen_width; - gint screen_height; - gint return_val; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE); - - window = GTK_WINDOW (widget); - return_val = FALSE; - - /* Remember old size, to know if we have to reset hints */ - width = widget->requisition.width; - height = widget->requisition.height; - gtk_widget_size_request (widget, &widget->requisition); - - if ((width != widget->requisition.width || - height != widget->requisition.height)) - gtk_window_set_hints (widget, &widget->requisition); - - x = -1; - y = -1; - width = widget->requisition.width; - height = widget->requisition.height; - - if (window->use_uposition) - switch (window->position) - { - case GTK_WIN_POS_CENTER: - x = (gdk_screen_width () - width) / 2; - y = (gdk_screen_height () - height) / 2; - gtk_widget_set_uposition (widget, x, y); - break; - case GTK_WIN_POS_MOUSE: - gdk_window_get_pointer (NULL, &x, &y, NULL); - - x -= width / 2; - y -= height / 2; - - screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - if (x < 0) - x = 0; - else if (x > (screen_width - width)) - x = screen_width - width; - - if (y < 0) - y = 0; - else if (y > (screen_height - height)) - y = screen_height - height; - - gtk_widget_set_uposition (widget, x, y); - break; - } - - gtk_signal_emit (GTK_OBJECT (widget), window_signals[MOVE_RESIZE], - &x, &y, width, height, &return_val); - - return return_val; } static void |