summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-02-05 15:16:01 +0100
committerBenjamin Otte <otte@redhat.com>2011-02-14 19:33:03 +0100
commit9668dcba7da4ed95d9b920ad73a9d9d3c545a465 (patch)
tree7e2481ec0a7f93c4b3991a08e737e0e28a68608a
parente56f0136984e46e77a07c1213a2e6d25301107f5 (diff)
downloadgtk+-9668dcba7da4ed95d9b920ad73a9d9d3c545a465.tar.gz
gtk: Add GtkStylablePicture
This interface allows adding styling information to GdkPicture subclasses that can be used by widgets to draw them.
-rw-r--r--gtk/Makefile.am2
-rw-r--r--gtk/gtk.h1
-rw-r--r--gtk/gtkstylablepicture.c78
-rw-r--r--gtk/gtkstylablepicture.h63
4 files changed, 144 insertions, 0 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index c95adb7323..299bc5782b 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 0a72d249cf..b0c595d9ef 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 0000000000..259f8f9039
--- /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 0000000000..a86106949b
--- /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__ */