[gtk+/wip/actor: 18/24] actor: Add a screen_changed vfunc



commit a137e66648494613e267ab0fd3f0a57dc865ae52
Author: Benjamin Otte <otte redhat com>
Date:   Mon Dec 17 01:55:04 2012 +0100

    actor: Add a screen_changed vfunc
    
    ... and call it from GtkWidgetActor, when the screen changes.

 gtk/actors/gtkactor.c              |    8 ++++++++
 gtk/actors/gtkactorprivate.h       |    4 ++++
 gtk/actors/gtkcssbox.c             |   13 +++++++++++++
 gtk/actors/gtkwidgetactor.c        |   30 ++++++++++++++++++++++++++++++
 gtk/actors/gtkwidgetactorprivate.h |    4 ++++
 gtk/gtkwidget.c                    |    2 ++
 6 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/gtk/actors/gtkactor.c b/gtk/actors/gtkactor.c
index 8c95a58..ba6e9cb 100644
--- a/gtk/actors/gtkactor.c
+++ b/gtk/actors/gtkactor.c
@@ -485,6 +485,13 @@ gtk_actor_real_allocate (GtkActor             *self,
 }
 
 static void
+gtk_actor_real_screen_changed (GtkActor  *self,
+                               GdkScreen *new_screen,
+                               GdkScreen *old_screen)
+{
+}
+
+static void
 _gtk_actor_class_init (GtkActorClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -507,6 +514,7 @@ _gtk_actor_class_init (GtkActorClass *klass)
   klass->get_request_mode = gtk_actor_real_get_request_mode;
   klass->get_preferred_size = gtk_actor_real_get_preferred_size;
   klass->allocate = gtk_actor_real_allocate;
+  klass->screen_changed = gtk_actor_real_screen_changed;
 
   /**
    * GtkActor:visible:
diff --git a/gtk/actors/gtkactorprivate.h b/gtk/actors/gtkactorprivate.h
index 2aeef8b..b7887da 100644
--- a/gtk/actors/gtkactorprivate.h
+++ b/gtk/actors/gtkactorprivate.h
@@ -82,6 +82,10 @@ struct _GtkActorClass
                                                   gfloat                    width,
                                                   gfloat                    height);
 
+  void                  (* screen_changed)       (GtkActor                 *self,
+                                                  GdkScreen                *new_screen,
+                                                  GdkScreen                *old_screen);
+
   /* signals */
   void                  (* actor_added)          (GtkActor                 *self,
                                                   GtkActor                 *child);
diff --git a/gtk/actors/gtkcssbox.c b/gtk/actors/gtkcssbox.c
index 7da578a..a67802f 100644
--- a/gtk/actors/gtkcssbox.c
+++ b/gtk/actors/gtkcssbox.c
@@ -475,6 +475,18 @@ gtk_css_box_real_draw (GtkActor *actor,
 }
 
 static void
+gtk_css_box_real_screen_changed (GtkActor  *actor,
+                                 GdkScreen *new_screen,
+                                 GdkScreen *old_screen)
+{
+  GtkStyleContext *context;
+
+  context = _gtk_css_actor_get_style_context (GTK_CSS_ACTOR (actor));
+
+  gtk_style_context_set_screen (context, new_screen);
+}
+
+static void
 gtk_css_box_real_style_updated (GtkCssActor      *actor,
                                 const GtkBitmask *changes)
 {
@@ -503,6 +515,7 @@ _gtk_css_box_class_init (GtkCssBoxClass *klass)
   actor_class->parent_set = gtk_css_box_real_parent_set;
   actor_class->get_preferred_size = gtk_css_box_real_get_preferred_size;
   actor_class->allocate = gtk_css_box_real_allocate;
+  actor_class->screen_changed = gtk_css_box_real_screen_changed;
 
   css_actor_class->style_updated = gtk_css_box_real_style_updated;
 
diff --git a/gtk/actors/gtkwidgetactor.c b/gtk/actors/gtkwidgetactor.c
index cec2653..703eee0 100644
--- a/gtk/actors/gtkwidgetactor.c
+++ b/gtk/actors/gtkwidgetactor.c
@@ -105,3 +105,33 @@ _gtk_widget_actor_unrealize (GtkActor *actor)
 
   GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->unrealize (actor);
 }
+
+void
+_gtk_widget_actor_screen_changed (GtkActor  *actor,
+                                  GdkScreen *new_screen,
+                                  GdkScreen *old_screen)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+  g_return_if_fail (new_screen == NULL || GDK_IS_SCREEN (new_screen));
+  g_return_if_fail (old_screen == NULL || GDK_IS_SCREEN (old_screen));
+
+  if (new_screen == NULL)
+    new_screen = gdk_screen_get_default ();
+  if (old_screen == NULL)
+    old_screen = gdk_screen_get_default ();
+
+  if (new_screen == old_screen)
+    return;
+
+  GTK_ACTOR_GET_CLASS (actor)->screen_changed (actor, new_screen, old_screen);
+
+  for (actor = _gtk_actor_get_first_child (actor);
+       actor != NULL;
+       actor = _gtk_actor_get_next_sibling (actor))
+    {
+      if (GTK_IS_WIDGET_ACTOR (actor))
+        continue;
+
+      _gtk_widget_actor_screen_changed (actor, new_screen, old_screen);
+    }
+}
diff --git a/gtk/actors/gtkwidgetactorprivate.h b/gtk/actors/gtkwidgetactorprivate.h
index 77a3a88..3dfa91c 100644
--- a/gtk/actors/gtkwidgetactorprivate.h
+++ b/gtk/actors/gtkwidgetactorprivate.h
@@ -56,6 +56,10 @@ void                        _gtk_widget_actor_unmap                     (GtkActo
 void                        _gtk_widget_actor_realize                   (GtkActor       *actor);
 void                        _gtk_widget_actor_unrealize                 (GtkActor       *actor);
 
+void                        _gtk_widget_actor_screen_changed            (GtkActor       *actor,
+                                                                         GdkScreen      *new_screen,
+                                                                         GdkScreen      *old_screen);
+
 G_END_DECLS
 
 #endif /* __GTK_WIDGET_ACTOR_PRIVATE_H__ */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index aedcfc0..5c6e7aa 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8351,6 +8351,8 @@ do_screen_change (GtkWidget *widget,
       if (new_screen && priv->context)
         gtk_style_context_set_screen (priv->context, new_screen);
 
+      _gtk_widget_actor_screen_changed (priv->actor, new_screen, old_screen);
+
       g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]