[gtk+/picture: 5/17] gtk: Add GtkStylablePicture
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/picture: 5/17] gtk: Add GtkStylablePicture
- Date: Thu, 10 Feb 2011 13:55:53 +0000 (UTC)
commit e4879d675ae2a8229e3a684ce2cbc94c463f291e
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 5 15:16:01 2011 +0100
gtk: Add GtkStylablePicture
This interface allows adding styling information to GdkPicture
subclasses that can be used by widgets to draw them.
gtk/Makefile.am | 2 +
gtk/gtk.h | 1 +
gtk/gtkstylablepicture.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkstylablepicture.h | 63 +++++++++++++++++++++++++++++++++++++
4 files changed, 144 insertions(+), 0 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 3d7b9f4..ae8e858 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -296,6 +296,7 @@ gtk_public_h_sources = \
gtkstatusbar.h \
gtkstatusicon.h \
gtkstock.h \
+ gtkstylablepicture.h \
gtkstylecontext.h \
gtkstyleproperties.h \
gtkstyleprovider.h \
@@ -622,6 +623,7 @@ gtk_base_c_sources = \
gtkstatusbar.c \
gtkstatusicon.c \
gtkstock.c \
+ gtkstylablepicture.c \
gtkstylecontext.c \
gtkstyleproperties.c \
gtkstyleprovider.c \
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 0a72d24..b0c595d 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -179,6 +179,7 @@
#include <gtk/gtkstatusbar.h>
#include <gtk/gtkstatusicon.h>
#include <gtk/gtkstock.h>
+#include <gtk/gtkstylablepicture.h>
#include <gtk/gtkstylecontext.h>
#include <gtk/gtkstyleproperties.h>
#include <gtk/gtkstyleprovider.h>
diff --git a/gtk/gtkstylablepicture.c b/gtk/gtkstylablepicture.c
new file mode 100644
index 0000000..259f8f9
--- /dev/null
+++ b/gtk/gtkstylablepicture.c
@@ -0,0 +1,78 @@
+/* gtktreesortable.c
+ * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#include "config.h"
+
+#include "gtkstylablepicture.h"
+#include "gtkintl.h"
+
+
+/**
+ * SECTION:gtkstylablepicture
+ * @Short_description: Pictures that can be styled when attached to widgets
+ * @Title: GtkStylablePicture
+ * @See_also:#GdkPicture, #GtkWidget
+ *
+ * #GtkStylablePicture is an interface to be implemented by pictures that can be
+ * styled according to a #GtkWidget's #GtkStyleContext.
+ */
+
+G_DEFINE_INTERFACE (GtkStylablePicture, gtk_stylable_picture, GDK_TYPE_PICTURE)
+
+static void
+gtk_stylable_picture_default_init (GtkStylablePictureInterface *iface)
+{
+}
+
+GdkPicture *
+gtk_widget_style_picture (GtkWidget *widget,
+ GdkPicture *picture)
+{
+ GtkStylablePictureInterface *iface;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (GDK_IS_PICTURE (picture), NULL);
+
+ if (!GTK_IS_STYLABLE_PICTURE (picture))
+ return g_object_ref (picture);
+
+ iface = GTK_STYLABLE_PICTURE_GET_IFACE (picture);
+ if (iface->attach == NULL)
+ return g_object_ref (picture);
+
+ return (* iface->attach) (picture, widget);
+}
+
+GdkPicture *
+gtk_picture_get_unstyled (GdkPicture *styled)
+{
+ GtkStylablePictureInterface *iface;
+
+ g_return_val_if_fail (GDK_IS_PICTURE (styled), NULL);
+
+ if (!GTK_IS_STYLABLE_PICTURE (styled))
+ return styled;
+
+ iface = GTK_STYLABLE_PICTURE_GET_IFACE (styled);
+ if (iface->get_unstyled == NULL)
+ return styled;
+
+ return iface->get_unstyled (styled);
+}
diff --git a/gtk/gtkstylablepicture.h b/gtk/gtkstylablepicture.h
new file mode 100644
index 0000000..a861069
--- /dev/null
+++ b/gtk/gtkstylablepicture.h
@@ -0,0 +1,63 @@
+/* gtktreesortable.h
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_STYLABLE_PICTURE_H__
+#define __GTK_STYLABLE_PICTURE_H__
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkwidget.h>
+
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_STYLABLE_PICTURE (gtk_stylable_picture_get_type ())
+#define GTK_STYLABLE_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STYLABLE_PICTURE, GtkStylablePicture))
+#define GTK_STYLABLE_PICTURE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_TYPE_STYLABLE_PICTURE, GtkStylablePictureInterface))
+#define GTK_IS_STYLABLE_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STYLABLE_PICTURE))
+#define GTK_STYLABLE_PICTURE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_STYLABLE_PICTURE, GtkStylablePictureInterface))
+
+typedef struct _GtkStylablePicture GtkStylablePicture; /* Dummy typedef */
+typedef struct _GtkStylablePictureInterface GtkStylablePictureInterface;
+
+struct _GtkStylablePictureInterface
+{
+ GTypeInterface g_iface;
+
+ /* virtual table */
+ GdkPicture * (* attach) (GdkPicture *picture,
+ GtkWidget *widget);
+ GdkPicture * (* get_unstyled) (GdkPicture *picture);
+};
+
+
+GType gtk_stylable_picture_get_type (void) G_GNUC_CONST;
+
+GdkPicture * gtk_widget_style_picture (GtkWidget *widget,
+ GdkPicture *picture);
+GdkPicture * gtk_picture_get_unstyled (GdkPicture *styled);
+
+
+G_END_DECLS
+
+#endif /* __GTK_STYLABLE_PICTURE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]