~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimppixmap.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Boston, MA 02111-1307, USA.
21
21
 */
22
22
 
 
23
#include "config.h"
 
24
 
23
25
#include <stdio.h>
24
26
 
25
27
#include <gtk/gtk.h>
30
32
#include "gimppixmap.h"
31
33
 
32
34
 
33
 
static void   gimp_pixmap_class_init        (GimpPixmapClass *klass);
34
 
static void   gimp_pixmap_init              (GimpPixmap      *pixmap);
35
 
 
36
 
static void   gimp_pixmap_realize           (GtkWidget       *widget);
37
 
static void   gimp_pixmap_create_from_xpm_d (GimpPixmap      *pixmap);
38
 
 
39
 
 
40
 
static GtkImageClass *parent_class = NULL;
41
 
 
42
 
 
43
 
GType
44
 
gimp_pixmap_get_type (void)
45
 
{
46
 
  static GType pixmap_type = 0;
47
 
 
48
 
  if (! pixmap_type)
49
 
    {
50
 
      static const GTypeInfo pixmap_info =
51
 
      {
52
 
        sizeof (GimpPixmapClass),
53
 
        (GBaseInitFunc) NULL,
54
 
        (GBaseFinalizeFunc) NULL,
55
 
        (GClassInitFunc) gimp_pixmap_class_init,
56
 
        NULL,           /* class_finalize */
57
 
        NULL,           /* class_data     */
58
 
        sizeof (GimpPixmap),
59
 
        0,              /* n_preallocs    */
60
 
        (GInstanceInitFunc) gimp_pixmap_init,
61
 
      };
62
 
 
63
 
      pixmap_type = g_type_register_static (GTK_TYPE_IMAGE,
64
 
                                            "GimpPixmap",
65
 
                                            &pixmap_info, 0);
66
 
    }
67
 
 
68
 
  return pixmap_type;
69
 
}
 
35
static void   gimp_pixmap_realize           (GtkWidget  *widget);
 
36
static void   gimp_pixmap_create_from_xpm_d (GimpPixmap *pixmap);
 
37
 
 
38
 
 
39
G_DEFINE_TYPE (GimpPixmap, gimp_pixmap, GTK_TYPE_IMAGE)
 
40
 
 
41
#define parent_class gimp_pixmap_parent_class
 
42
 
70
43
 
71
44
static void
72
45
gimp_pixmap_class_init (GimpPixmapClass *klass)
73
46
{
74
47
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
75
48
 
76
 
  parent_class = g_type_class_peek_parent (klass);
77
 
 
78
49
  widget_class->realize = gimp_pixmap_realize;
79
50
}
80
51
 
111
82
 **/
112
83
void
113
84
gimp_pixmap_set (GimpPixmap  *pixmap,
114
 
                 gchar      **xpm_data)
 
85
                 gchar      **xpm_data)
115
86
{
116
87
  g_return_if_fail (GIMP_IS_PIXMAP (pixmap));
117
88
 
123
94
  if (! GTK_WIDGET_REALIZED (GTK_WIDGET (pixmap)))
124
95
    {
125
96
      if (xpm_data)
126
 
        {
127
 
          gint width, height;
 
97
        {
 
98
          gint width, height;
128
99
 
129
 
          if (sscanf (xpm_data[0], "%d %d", &width, &height) != 2)
130
 
            {
131
 
              g_warning ("%s: passed pointer is no XPM data", G_STRFUNC);
132
 
            }
133
 
          else
134
 
            {
135
 
              GTK_WIDGET (pixmap)->requisition.width =
136
 
                width + GTK_MISC (pixmap)->xpad * 2;
137
 
              GTK_WIDGET (pixmap)->requisition.height =
138
 
                height + GTK_MISC (pixmap)->ypad * 2;
139
 
            }
140
 
        }
 
100
          if (sscanf (xpm_data[0], "%d %d", &width, &height) != 2)
 
101
            {
 
102
              g_warning ("%s: passed pointer is no XPM data", G_STRFUNC);
 
103
            }
 
104
          else
 
105
            {
 
106
              GTK_WIDGET (pixmap)->requisition.width =
 
107
                width + GTK_MISC (pixmap)->xpad * 2;
 
108
              GTK_WIDGET (pixmap)->requisition.height =
 
109
                height + GTK_MISC (pixmap)->ypad * 2;
 
110
            }
 
111
        }
141
112
    }
142
113
  else
143
114
    {
170
141
      style = gtk_widget_get_style (widget);
171
142
 
172
143
      gdk_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
173
 
                                                 &mask,
174
 
                                                 &style->bg[GTK_STATE_NORMAL],
175
 
                                                 pixmap->xpm_data);
 
144
                                                 &mask,
 
145
                                                 &style->bg[GTK_STATE_NORMAL],
 
146
                                                 pixmap->xpm_data);
176
147
    }
177
148
 
178
149
  gtk_image_set_from_pixmap (GTK_IMAGE (pixmap), gdk_pixmap, mask);