diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 8 | ||||
-rw-r--r-- | gtk/gtkfontsel.c | 55 | ||||
-rw-r--r-- | gtk/gtkinvisible.c | 11 | ||||
-rw-r--r-- | gtk/gtktoolbar.c | 31 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 97 | ||||
-rw-r--r-- | gtk/gtkwidget.h | 4 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 9 |
12 files changed, 172 insertions, 83 deletions
@@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 1018bae2b6..08b46a5cd7 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 1018bae2b6..08b46a5cd7 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 1018bae2b6..08b46a5cd7 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 1018bae2b6..08b46a5cd7 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 1018bae2b6..08b46a5cd7 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Thu Nov 7 12:53:08 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.[ch] gtk/gtkwindow.c gtk/gtkinvisible.c: + Add ::screen-changed signal. + + * gtk/gtkfontsel.c gtk/gtktoolbar.c: Use ::screen-changed + signal to simplify logic. + 2002-11-07 Anders Carlsson <andersca@gnu.org> * tests/testgtk.c (create_resize_grips): Add resize grips test. diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index 63a8fa981a..d1bb6a2243 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -118,8 +118,8 @@ static void gtk_font_selection_get_property (GObject *object, GParamSpec *pspec); static void gtk_font_selection_init (GtkFontSelection *fontsel); static void gtk_font_selection_finalize (GObject *object); -static void gtk_font_selection_hierarchy_changed (GtkWidget *widget, - GtkWidget *previous_toplevel); +static void gtk_font_selection_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen); /* These are the callbacks & related functions. */ static void gtk_font_selection_select_font (GtkTreeSelection *selection, @@ -200,7 +200,7 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass) gobject_class->set_property = gtk_font_selection_set_property; gobject_class->get_property = gtk_font_selection_get_property; - widget_class->hierarchy_changed = gtk_font_selection_hierarchy_changed; + widget_class->screen_changed = gtk_font_selection_screen_changed; g_object_class_install_property (gobject_class, PROP_FONT_NAME, @@ -522,60 +522,17 @@ gtk_font_selection_finalize (GObject *object) } static void -fontsel_screen_changed (GtkFontSelection *fontsel) +gtk_font_selection_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) { - GdkScreen *old_screen = g_object_get_data (G_OBJECT (fontsel), "gtk-font-selection-screen"); - GdkScreen *screen; + GtkFontSelection *fontsel = GTK_FONT_SELECTION (widget); if (gtk_widget_has_screen (GTK_WIDGET (fontsel))) - screen = gtk_widget_get_screen (GTK_WIDGET (fontsel)); - else - screen = NULL; - - if (screen == old_screen) - return; - - if (fontsel->font) { - gdk_font_unref (fontsel->font); - fontsel->font = NULL; - } - - if (old_screen) - g_object_unref (old_screen); - - if (screen) - { - g_object_ref (screen); - g_object_set_data (G_OBJECT (fontsel), "gtk-font-selection-screen", screen); - gtk_font_selection_show_available_fonts (fontsel); gtk_font_selection_show_available_sizes (fontsel, TRUE); gtk_font_selection_show_available_styles (fontsel); } - else - g_object_set_data (G_OBJECT (fontsel), "gtk-font-selection-screen", NULL); -} - -static void -gtk_font_selection_hierarchy_changed (GtkWidget *widget, - GtkWidget *previous_toplevel) -{ - GtkWidget *toplevel; - - if (previous_toplevel) - g_signal_handlers_disconnect_by_func (previous_toplevel, - fontsel_screen_changed, - widget); - - toplevel = gtk_widget_get_toplevel (widget); - if (GTK_WIDGET_TOPLEVEL (toplevel)) - g_signal_connect_swapped (toplevel, - "notify::screen", - G_CALLBACK (fontsel_screen_changed), - widget); - - fontsel_screen_changed (GTK_FONT_SELECTION (widget)); } static void diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c index 0e6b4a50e7..4e1418e0ac 100644 --- a/gtk/gtkinvisible.c +++ b/gtk/gtkinvisible.c @@ -189,6 +189,8 @@ void gtk_invisible_set_screen (GtkInvisible *invisible, GdkScreen *screen) { + GtkWidget *widget; + GdkScreen *previous_screen; gboolean was_realized; g_return_if_fail (GTK_IS_INVISIBLE (invisible)); @@ -197,16 +199,21 @@ gtk_invisible_set_screen (GtkInvisible *invisible, if (screen == invisible->screen) return; + widget = GTK_WIDGET (invisible); + + previous_screen = invisible->screen; was_realized = GTK_WIDGET_REALIZED (invisible); if (was_realized) - gtk_widget_unrealize (GTK_WIDGET (invisible)); + gtk_widget_unrealize (widget); invisible->screen = screen; + if (screen != previous_screen) + _gtk_widget_propagate_screen_changed (widget, previous_screen); g_object_notify (G_OBJECT (invisible), "screen"); if (was_realized) - gtk_widget_realize (GTK_WIDGET (invisible)); + gtk_widget_realize (widget); } /** diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 420e6a141b..6870f4737d 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -94,8 +94,8 @@ static void gtk_toolbar_style_set (GtkWidget *widget, GtkStyle *prev_style); static gboolean gtk_toolbar_focus (GtkWidget *widget, GtkDirectionType dir); -static void gtk_toolbar_hierarchy_changed (GtkWidget *widget, - GtkWidget *previous_toplevel); +static void gtk_toolbar_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen); static void gtk_toolbar_show_all (GtkWidget *widget); static void gtk_toolbar_add (GtkContainer *container, GtkWidget *widget); @@ -195,7 +195,7 @@ gtk_toolbar_class_init (GtkToolbarClass *class) widget_class->style_set = gtk_toolbar_style_set; widget_class->show_all = gtk_toolbar_show_all; widget_class->focus = gtk_toolbar_focus; - widget_class->hierarchy_changed = gtk_toolbar_hierarchy_changed; + widget_class->screen_changed = gtk_toolbar_screen_changed; container_class->add = gtk_toolbar_add; container_class->remove = gtk_toolbar_remove; @@ -329,8 +329,10 @@ toolbar_get_settings (GtkToolbar *toolbar) } static void -toolbar_screen_changed (GtkToolbar *toolbar) +gtk_toolbar_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) { + GtkToolbar *toolbar = GTK_TOOLBAR (widget); GtkSettings *old_settings = toolbar_get_settings (toolbar); GtkSettings *settings; @@ -376,27 +378,6 @@ toolbar_screen_changed (GtkToolbar *toolbar) } static void -gtk_toolbar_hierarchy_changed (GtkWidget *widget, - GtkWidget *previous_toplevel) -{ - GtkWidget *toplevel; - - if (previous_toplevel) - g_signal_handlers_disconnect_by_func (previous_toplevel, - toolbar_screen_changed, - widget); - - toplevel = gtk_widget_get_toplevel (widget); - if (GTK_WIDGET_TOPLEVEL (toplevel)) - g_signal_connect_swapped (toplevel, - "notify::screen", - G_CALLBACK (toolbar_screen_changed), - widget); - - toolbar_screen_changed (GTK_TOOLBAR (widget)); -} - -static void gtk_toolbar_init (GtkToolbar *toolbar) { GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8fe9579e20..0b58339f08 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -116,6 +116,7 @@ enum { POPUP_MENU, SHOW_HELP, ACCEL_CLOSURES_CHANGED, + SCREEN_CHANGED, LAST_SIGNAL }; @@ -379,6 +380,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->drag_motion = NULL; klass->drag_drop = NULL; klass->drag_data_received = NULL; + klass->screen_changed = NULL; klass->show_help = gtk_widget_real_show_help; @@ -1053,6 +1055,15 @@ gtk_widget_class_init (GtkWidgetClass *klass) NULL, NULL, _gtk_marshal_NONE__NONE, G_TYPE_NONE, 0); + widget_signals[SCREEN_CHANGED] = + g_signal_new ("screen_changed", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkWidgetClass, hierarchy_changed), + NULL, NULL, + _gtk_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + GDK_TYPE_SCREEN); binding_set = gtk_binding_set_by_class (klass); gtk_binding_entry_add_signal (binding_set, GDK_F10, GDK_SHIFT_MASK, @@ -4289,11 +4300,27 @@ gtk_widget_set_style_internal (GtkWidget *widget, g_object_unref (widget); } +typedef struct { + GtkWidget *previous_toplevel; + GdkScreen *previous_screen; + GdkScreen *new_screen; +} HierarchyChangedInfo; + +static void +do_screen_change (GtkWidget *widget, + GdkScreen *old_screen, + GdkScreen *new_screen) +{ + if (old_screen != new_screen) + g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen); +} + static void gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget, gpointer client_data) { gboolean new_anchored; + HierarchyChangedInfo *info = client_data; new_anchored = GTK_WIDGET_TOPLEVEL (widget) || (widget->parent && GTK_WIDGET_ANCHORED (widget->parent)); @@ -4307,8 +4334,9 @@ gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget, else GTK_PRIVATE_UNSET_FLAG (widget, GTK_ANCHORED); - g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, client_data); - + g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel); + do_screen_change (widget, info->previous_screen, info->new_screen); + if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), gtk_widget_propagate_hierarchy_changed_recurse, @@ -4331,13 +4359,72 @@ void _gtk_widget_propagate_hierarchy_changed (GtkWidget *widget, GtkWidget *previous_toplevel) { + HierarchyChangedInfo info; + + info.previous_toplevel = previous_toplevel; + info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL; + + if (GTK_WIDGET_TOPLEVEL (widget) || + (widget->parent && GTK_WIDGET_ANCHORED (widget->parent))) + info.new_screen = gtk_widget_get_screen (widget); + else + info.new_screen = NULL; + + if (info.previous_screen) + g_object_ref (info.previous_screen); if (previous_toplevel) g_object_ref (previous_toplevel); - gtk_widget_propagate_hierarchy_changed_recurse (widget, previous_toplevel); - + gtk_widget_propagate_hierarchy_changed_recurse (widget, &info); + if (previous_toplevel) g_object_unref (previous_toplevel); + if (info.previous_screen) + g_object_unref (info.previous_screen); +} + +static void +gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget, + gpointer client_data) +{ + HierarchyChangedInfo *info = client_data; + + g_object_ref (widget); + + do_screen_change (widget, info->previous_screen, info->new_screen); + + if (GTK_IS_CONTAINER (widget)) + gtk_container_forall (GTK_CONTAINER (widget), + gtk_widget_propagate_hierarchy_changed_recurse, + client_data); + + g_object_unref (widget); +} + +/** + * _gtk_widget_propagate_screen_changed: + * @widget: a #GtkWidget + * @previous_screen: Previous screen + * + * Propagates changes in the screen for a widget to all + * children, emitting ::screen_changed. + **/ +void +_gtk_widget_propagate_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) +{ + HierarchyChangedInfo info; + + info.previous_screen = previous_screen; + info.new_screen = gtk_widget_get_screen (widget); + + if (previous_screen) + g_object_ref (previous_screen); + + gtk_widget_propagate_screen_changed_recurse (widget, &info); + + if (previous_screen) + g_object_unref (previous_screen); } static void @@ -4666,7 +4753,7 @@ gtk_widget_get_screen_unchecked (GtkWidget *widget) * * Get the #GdkScreen from the toplevel window associated with * this widget. This function can only be called after the widget - * has been added to a widget heirarchy with a #GtkWindow + * has been added to a widget hierarchy with a #GtkWindow * at the top. * * In general, you should only create screen specific diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 2a4d81123b..fe624c2034 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -398,6 +398,8 @@ struct _GtkWidgetClass */ AtkObject* (* get_accessible) (GtkWidget *widget); + void (* screen_changed) (GtkWidget *widget, + GdkScreen *previous_screen); /* Padding for future expansion */ void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); @@ -761,6 +763,8 @@ GtkWidgetAuxInfo *_gtk_widget_get_aux_info (GtkWidget *widget, gboolean create); void _gtk_widget_propagate_hierarchy_changed (GtkWidget *widget, GtkWidget *previous_toplevel); +void _gtk_widget_propagate_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen); GdkColormap* _gtk_widget_peek_colormap (void); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 019bb5201a..324e1c986f 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -5982,6 +5982,8 @@ gtk_window_set_screen (GtkWindow *window, GdkScreen *screen) { GtkWidget *widget; + GdkScreen *previous_screen; + GdkScreen *new_screen; gboolean was_mapped; g_return_if_fail (GTK_IS_WINDOW (window)); @@ -5991,17 +5993,20 @@ gtk_window_set_screen (GtkWindow *window, return; widget = GTK_WIDGET (window); - + + previous_screen = window->screen; was_mapped = GTK_WIDGET_MAPPED (widget); if (was_mapped) gtk_widget_unmap (widget); if (GTK_WIDGET_REALIZED (widget)) gtk_widget_unrealize (widget); - + gtk_window_free_key_hash (window); window->screen = screen; gtk_widget_reset_rc_styles (widget); + if (screen != previous_screen) + _gtk_widget_propagate_screen_changed (widget, previous_screen); g_object_notify (G_OBJECT (window), "screen"); if (was_mapped) |