[gtk+/wip/actor: 15/24] actors: Add a custom subclass for the base widget actor



commit 17cb423a719f338e0f222b3f41c57b8a5978358a
Author: Benjamin Otte <otte redhat com>
Date:   Sun Dec 16 18:37:05 2012 +0100

    actors: Add a custom subclass for the base widget actor
    
    This custom class needs to do all the hacks that are necessary because
    of the interaction with GtkWidget. The class should be removed with GTK
    4.

 gtk/actors/Makefile.am             |    6 +-
 gtk/actors/gtkcssactor.c           |    4 +
 gtk/actors/gtkwidgetactor.c        |  107 ++++++++++++++++++++++++++++++++++++
 gtk/actors/gtkwidgetactorprivate.h |   61 ++++++++++++++++++++
 4 files changed, 176 insertions(+), 2 deletions(-)
---
diff --git a/gtk/actors/Makefile.am b/gtk/actors/Makefile.am
index 0e4236e..73f5c61 100644
--- a/gtk/actors/Makefile.am
+++ b/gtk/actors/Makefile.am
@@ -8,7 +8,8 @@ gtkactors_c_sources =			\
 	gtkcssactor.c			\
 	gtkcssbox.c			\
 	gtkcsstext.c			\
-	gtklayoutmanager.c
+	gtklayoutmanager.c		\
+	gtkwidgetactor.c
 
 gtkactors_private_h_sources =		\
 	gtkactorprivate.h		\
@@ -16,7 +17,8 @@ gtkactors_private_h_sources =		\
 	gtkcssactorprivate.h		\
 	gtkcssboxprivate.h		\
 	gtkcsstextprivate.h		\
-	gtklayoutmanagerprivate.h
+	gtklayoutmanagerprivate.h	\
+	gtkwidgetactorprivate.h
 
 libgtkactors_la_SOURCES = 		\
 	$(gtkactors_c_sources)		\
diff --git a/gtk/actors/gtkcssactor.c b/gtk/actors/gtkcssactor.c
index 9d43c33..b2fbf92 100644
--- a/gtk/actors/gtkcssactor.c
+++ b/gtk/actors/gtkcssactor.c
@@ -31,6 +31,7 @@
 #include "gtkstylecontext.h"
 #include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
+#include "gtkwidgetactorprivate.h"
 #include "gtkwidgetprivate.h"
 
 struct _GtkCssActorPrivate {
@@ -238,6 +239,9 @@ actor_needs_to_use_widget_path (GtkActor *actor)
 {
   GtkWidget *widget, *parent;
 
+  if (!GTK_IS_WIDGET_ACTOR (actor))
+    return FALSE;
+
   widget = _gtk_actor_get_widget (actor);
   if (widget == NULL)
     return FALSE;
diff --git a/gtk/actors/gtkwidgetactor.c b/gtk/actors/gtkwidgetactor.c
new file mode 100644
index 0000000..cec2653
--- /dev/null
+++ b/gtk/actors/gtkwidgetactor.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright  2012 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte gnome org>
+ */
+
+#include "config.h"
+
+#include "gtkwidgetactorprivate.h"
+
+struct _GtkWidgetActorPrivate {
+  gpointer dummy;
+};
+
+G_DEFINE_TYPE (GtkWidgetActor, _gtk_widget_actor, GTK_TYPE_CSS_BOX)
+
+static void
+_gtk_widget_actor_class_init (GtkWidgetActorClass *klass)
+{
+#if 0
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkActorClass *actor_class = GTK_ACTOR_CLASS (klass);
+
+  actor_class->parent_set = gtk_widget_actor_real_parent_set;
+  actor_class->show = gtk_css_box_real_show;
+  actor_class->hide = gtk_css_box_real_hide;
+  actor_class->map = gtk_css_box_real_map;
+  actor_class->unmap = gtk_css_box_real_unmap;
+  actor_class->draw = gtk_css_box_real_draw;
+  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;
+
+  klass->style_updated = gtk_widget_actor_real_style_updated;
+#endif
+
+  g_type_class_add_private (klass, sizeof (GtkWidgetActorPrivate));
+}
+
+static void
+_gtk_widget_actor_init (GtkWidgetActor *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+                                            GTK_TYPE_WIDGET_ACTOR,
+                                            GtkWidgetActorPrivate);
+}
+
+void
+_gtk_widget_actor_show (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->show (actor);
+}
+
+void
+_gtk_widget_actor_hide (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->hide (actor);
+}
+
+void
+_gtk_widget_actor_map (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->map (actor);
+}
+
+void
+_gtk_widget_actor_unmap (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->unmap (actor);
+}
+
+void
+_gtk_widget_actor_realize (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->realize (actor);
+}
+
+void
+_gtk_widget_actor_unrealize (GtkActor *actor)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->unrealize (actor);
+}
diff --git a/gtk/actors/gtkwidgetactorprivate.h b/gtk/actors/gtkwidgetactorprivate.h
new file mode 100644
index 0000000..77a3a88
--- /dev/null
+++ b/gtk/actors/gtkwidgetactorprivate.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright  2012 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte gnome org>
+ */
+
+#ifndef __GTK_WIDGET_ACTOR_PRIVATE_H__
+#define __GTK_WIDGET_ACTOR_PRIVATE_H__
+
+#include <gtk/actors/gtkcssboxprivate.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_WIDGET_ACTOR           (_gtk_widget_actor_get_type ())
+#define GTK_WIDGET_ACTOR(obj)           (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_WIDGET_ACTOR, GtkWidgetActor))
+#define GTK_WIDGET_ACTOR_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_WIDGET_ACTOR, GtkWidgetActorClass))
+#define GTK_IS_WIDGET_ACTOR(obj)        (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_WIDGET_ACTOR))
+#define GTK_IS_WIDGET_ACTOR_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_WIDGET_ACTOR))
+#define GTK_WIDGET_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET_ACTOR, GtkWidgetActorClass))
+
+typedef struct _GtkWidgetActor           GtkWidgetActor;
+typedef struct _GtkWidgetActorPrivate    GtkWidgetActorPrivate;
+typedef struct _GtkWidgetActorClass      GtkWidgetActorClass;
+
+struct _GtkWidgetActor
+{
+  GtkCssBox                 parent;
+
+  GtkWidgetActorPrivate    *priv;
+};
+
+struct _GtkWidgetActorClass
+{
+  GtkCssBoxClass            parent_class;
+};
+
+GType                       _gtk_widget_actor_get_type                  (void) G_GNUC_CONST;
+
+void                        _gtk_widget_actor_show                      (GtkActor       *actor);
+void                        _gtk_widget_actor_hide                      (GtkActor       *actor);
+void                        _gtk_widget_actor_map                       (GtkActor       *actor);
+void                        _gtk_widget_actor_unmap                     (GtkActor       *actor);
+void                        _gtk_widget_actor_realize                   (GtkActor       *actor);
+void                        _gtk_widget_actor_unrealize                 (GtkActor       *actor);
+
+G_END_DECLS
+
+#endif /* __GTK_WIDGET_ACTOR_PRIVATE_H__ */



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