[gtk+/wip/actor: 34/42] actor: Add a screen_changed vfunc



commit 2fe425d0beb2259c34e6cec8354f34bd8b133f4f
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 59dad98..8ee5ee9 100644
--- a/gtk/actors/gtkactor.c
+++ b/gtk/actors/gtkactor.c
@@ -463,6 +463,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);
@@ -485,6 +492,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 7f16b80..949b9dd 100644
--- a/gtk/actors/gtkactorprivate.h
+++ b/gtk/actors/gtkactorprivate.h
@@ -81,6 +81,10 @@ struct _GtkActorClass
   void                  (* allocate)             (GtkActor                 *self,
                                                   gfloat                    width,
                                                   gfloat                    height);
+
+  void                  (* screen_changed)       (GtkActor                 *self,
+                                                  GdkScreen                *new_screen,
+                                                  GdkScreen                *old_screen);
 };
 
 /**
diff --git a/gtk/actors/gtkcssbox.c b/gtk/actors/gtkcssbox.c
index c032032..4f29202 100644
--- a/gtk/actors/gtkcssbox.c
+++ b/gtk/actors/gtkcssbox.c
@@ -465,6 +465,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_class_init (GtkCssBoxClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -482,6 +494,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;
 
   /**
    * GtkCssBox:state:
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 942e679..1d4f628 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8338,6 +8338,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]