File: fo-pixbuf.c

package info (click to toggle)
xmlroff 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 36,456 kB
  • ctags: 25,964
  • sloc: ansic: 178,200; xml: 109,155; sh: 8,973; makefile: 1,331; perl: 30
file content (127 lines) | stat: -rw-r--r-- 3,063 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* Fo
 * fo-pixbuf.c: Interface for getting GdkPixbuf contained by an object.
 *
 * Copyright (C) 2005 Sun Microsystems
 * Copyright (C) 2007 Menteith Consulting Ltd
 *
 * See COPYING for the status of this software.
 */

#include "fo-pixbuf.h"

static void        fo_pixbuf_base_class_init    (FoPixbufIface *klass);
static GdkPixbuf * fo_pixbuf_get_pixbuf_default (FoImage       *fo_image);
static void        fo_pixbuf_set_pixbuf_default (FoImage       *fo_image,
						 GdkPixbuf     *pixbuf);

/**
 * fo_pixbuf_get_type:
 *
 * Register the #FoPixbuf interface type.
 * 
 * Return value: #GType value of the #FoPixbuf interface type.
 **/
GType
fo_pixbuf_get_type (void)
{
  static GType pixbuf_type = 0;

  if (!pixbuf_type)
    {
      static const GTypeInfo pixbuf_info =
      {
        sizeof (FoPixbufIface), /* class_size */
	(GBaseInitFunc) fo_pixbuf_base_class_init,   	/* base_init */
	NULL,		/* base_finalize */
	NULL,
	NULL,		/* class_finalize */
	NULL,		/* class_data */
	0,
	0,              /* n_preallocs */
        NULL,		/* instance_init */
	NULL		/* value_table */
      };

      pixbuf_type = g_type_register_static (G_TYPE_INTERFACE,
					    "FoPixbufIface",
					    &pixbuf_info, 0);
      g_type_interface_add_prerequisite (pixbuf_type, FO_TYPE_OBJECT);
    }

  return pixbuf_type;
}

/**
 * fo_pixbuf_base_class_init:
 * @klass: #FoPixbufIface base interface object to initialise.
 * 
 * Implements #GBaseInitFunc for #FoPixbufIface.
 **/
void
fo_pixbuf_base_class_init  (FoPixbufIface *klass)
{
  klass->get_pixbuf =
    fo_pixbuf_get_pixbuf_default;
  klass->set_pixbuf =
    fo_pixbuf_set_pixbuf_default;
}

/**
 * fo_pixbuf_get_pixbuf:
 * @fo_image: The @FoImage containing the pixbuf.
 * 
 * Gets the #GdkPixbuf contained by @fo_image.
 *
 * Return value: The #GdkPixbuf contained by @fo_image.
 **/
GdkPixbuf *
fo_pixbuf_get_pixbuf (FoImage *fo_image)
{
  g_return_val_if_fail (fo_image != NULL, NULL);
  g_return_val_if_fail (FO_IS_PIXBUF (fo_image), NULL);

  return FO_PIXBUF_GET_IFACE (fo_image)->get_pixbuf (fo_image);
}

GdkPixbuf *
fo_pixbuf_get_pixbuf_default (FoImage *fo_image)
{
  g_return_val_if_fail (FO_IS_PIXBUF (fo_image), NULL);

  g_log (G_LOG_DOMAIN,
	 G_LOG_LEVEL_DEBUG,
	 _("%s does not have a 'get_pixbuf' function."),
	 fo_object_sprintf (FO_OBJECT (fo_image)));

  return NULL;
}

/**
 * fo_pixbuf_set_pixbuf:
 * @fo_image: The #FoImage containing the pixbuf.
 * @pixbuf:   #GdkPixbuf to be contained by @fo_image.
 * 
 * Sets the #GdkPixbuf contained by @fo_image.
 **/
void
fo_pixbuf_set_pixbuf (FoImage   *fo_image,
		      GdkPixbuf *pixbuf)
{
  g_return_if_fail (fo_image != NULL);
  g_return_if_fail (FO_IS_PIXBUF (fo_image));

  FO_PIXBUF_GET_IFACE (fo_image)->set_pixbuf (fo_image,
					       pixbuf);
}

void
fo_pixbuf_set_pixbuf_default (FoImage   *fo_image,
			      GdkPixbuf *pixbuf G_GNUC_UNUSED)
{
  g_return_if_fail (FO_IS_PIXBUF (fo_image));

  g_log (G_LOG_DOMAIN,
	 G_LOG_LEVEL_DEBUG,
	 _("%s does not have a 'set_pixbuf' function."),
	 fo_object_sprintf (FO_OBJECT (fo_image)));
}