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

« back to all changes in this revision

Viewing changes to app/widgets/gimppluginaction.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:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimppluginaction.c
27
27
 
28
28
#include "core/gimpmarshal.h"
29
29
 
30
 
#include "plug-in/plug-in-proc-def.h"
 
30
#include "plug-in/gimppluginprocedure.h"
31
31
 
32
32
#include "gimppluginaction.h"
33
33
 
41
41
enum
42
42
{
43
43
  PROP_0,
44
 
  PROP_PROC_DEF
 
44
  PROP_PROCEDURE
45
45
};
46
46
 
47
47
 
48
 
static void   gimp_plug_in_action_init          (GimpPlugInAction      *action);
49
 
static void   gimp_plug_in_action_class_init    (GimpPlugInActionClass *klass);
50
 
 
 
48
static void   gimp_plug_in_action_finalize      (GObject      *object);
51
49
static void   gimp_plug_in_action_set_property  (GObject      *object,
52
50
                                                 guint         prop_id,
53
51
                                                 const GValue *value,
62
60
                                                 GtkWidget    *proxy);
63
61
 
64
62
 
65
 
static GtkActionClass *parent_class                = NULL;
66
 
static guint           action_signals[LAST_SIGNAL] = { 0 };
67
 
 
68
 
 
69
 
GType
70
 
gimp_plug_in_action_get_type (void)
71
 
{
72
 
  static GType type = 0;
73
 
 
74
 
  if (!type)
75
 
    {
76
 
      static const GTypeInfo type_info =
77
 
      {
78
 
        sizeof (GimpPlugInActionClass),
79
 
        (GBaseInitFunc) NULL,
80
 
        (GBaseFinalizeFunc) NULL,
81
 
        (GClassInitFunc) gimp_plug_in_action_class_init,
82
 
        (GClassFinalizeFunc) NULL,
83
 
        NULL,
84
 
        sizeof (GimpPlugInAction),
85
 
        0, /* n_preallocs */
86
 
        (GInstanceInitFunc) gimp_plug_in_action_init,
87
 
      };
88
 
 
89
 
      type = g_type_register_static (GIMP_TYPE_ACTION,
90
 
                                     "GimpPlugInAction",
91
 
                                     &type_info, 0);
92
 
    }
93
 
 
94
 
  return type;
95
 
}
 
63
G_DEFINE_TYPE (GimpPlugInAction, gimp_plug_in_action, GIMP_TYPE_ACTION)
 
64
 
 
65
#define parent_class gimp_plug_in_action_parent_class
 
66
 
 
67
static guint action_signals[LAST_SIGNAL] = { 0 };
 
68
 
96
69
 
97
70
static void
98
71
gimp_plug_in_action_class_init (GimpPlugInActionClass *klass)
100
73
  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
101
74
  GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
102
75
 
103
 
  parent_class = g_type_class_peek_parent (klass);
104
 
 
105
 
  object_class->set_property = gimp_plug_in_action_set_property;
106
 
  object_class->get_property = gimp_plug_in_action_get_property;
 
76
  object_class->finalize      = gimp_plug_in_action_finalize;
 
77
  object_class->set_property  = gimp_plug_in_action_set_property;
 
78
  object_class->get_property  = gimp_plug_in_action_get_property;
107
79
 
108
80
  action_class->activate      = gimp_plug_in_action_activate;
109
81
  action_class->connect_proxy = gimp_plug_in_action_connect_proxy;
110
82
 
111
 
  g_object_class_install_property (object_class, PROP_PROC_DEF,
112
 
                                   g_param_spec_pointer ("proc-def",
113
 
                                                         NULL, NULL,
114
 
                                                         G_PARAM_READWRITE));
 
83
  g_object_class_install_property (object_class, PROP_PROCEDURE,
 
84
                                   g_param_spec_object ("procedure",
 
85
                                                        NULL, NULL,
 
86
                                                        GIMP_TYPE_PLUG_IN_PROCEDURE,
 
87
                                                        GIMP_PARAM_READWRITE));
115
88
 
116
89
  action_signals[SELECTED] =
117
90
    g_signal_new ("selected",
118
91
                  G_TYPE_FROM_CLASS (klass),
119
92
                  G_SIGNAL_RUN_FIRST,
120
93
                  G_STRUCT_OFFSET (GimpPlugInActionClass, selected),
121
 
                  NULL, NULL,
122
 
                  gimp_marshal_VOID__POINTER,
 
94
                  NULL, NULL,
 
95
                  gimp_marshal_VOID__OBJECT,
123
96
                  G_TYPE_NONE, 1,
124
 
                  G_TYPE_POINTER);
 
97
                  GIMP_TYPE_PLUG_IN_PROCEDURE);
125
98
}
126
99
 
127
100
static void
128
101
gimp_plug_in_action_init (GimpPlugInAction *action)
129
102
{
130
 
  action->proc_def = NULL;
 
103
  action->procedure = NULL;
 
104
}
 
105
 
 
106
static void
 
107
gimp_plug_in_action_finalize (GObject *object)
 
108
{
 
109
  GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object);
 
110
 
 
111
  if (action->procedure)
 
112
    {
 
113
      g_object_unref (action->procedure);
 
114
      action->procedure = NULL;
 
115
    }
 
116
 
 
117
  G_OBJECT_CLASS (parent_class)->finalize (object);
131
118
}
132
119
 
133
120
static void
140
127
 
141
128
  switch (prop_id)
142
129
    {
143
 
    case PROP_PROC_DEF:
144
 
      g_value_set_pointer (value, action->proc_def);
 
130
    case PROP_PROCEDURE:
 
131
      g_value_set_object (value, action->procedure);
145
132
      break;
 
133
 
146
134
    default:
147
135
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
148
136
      break;
159
147
 
160
148
  switch (prop_id)
161
149
    {
162
 
    case PROP_PROC_DEF:
163
 
      action->proc_def = g_value_get_pointer (value);
 
150
    case PROP_PROCEDURE:
 
151
      if (action->procedure)
 
152
        g_object_unref (action->procedure);
 
153
      action->procedure = GIMP_PLUG_IN_PROCEDURE (g_value_dup_object (value));
164
154
      break;
 
155
 
165
156
    default:
166
157
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
167
158
      break;
173
164
{
174
165
  GimpPlugInAction *plug_in_action = GIMP_PLUG_IN_ACTION (action);
175
166
 
176
 
  gimp_plug_in_action_selected (plug_in_action, plug_in_action->proc_def);
 
167
  gimp_plug_in_action_selected (plug_in_action, plug_in_action->procedure);
177
168
}
178
169
 
179
170
static void
184
175
 
185
176
  GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
186
177
 
187
 
  if (GTK_IS_IMAGE_MENU_ITEM (proxy) && plug_in_action->proc_def)
 
178
  if (GTK_IS_IMAGE_MENU_ITEM (proxy) && plug_in_action->procedure)
188
179
    {
189
180
      GdkPixbuf *pixbuf;
190
181
 
191
 
      pixbuf = plug_in_proc_def_get_pixbuf (plug_in_action->proc_def);
 
182
      pixbuf = gimp_plug_in_procedure_get_pixbuf (plug_in_action->procedure);
192
183
 
193
184
      if (pixbuf)
194
185
        {
195
 
          GdkScreen   *screen   = gtk_widget_get_screen (proxy);
196
 
          GtkSettings *settings = gtk_settings_get_for_screen (screen);
 
186
          GtkSettings *settings = gtk_widget_get_settings (proxy);
197
187
          gint         width;
198
188
          gint         height;
199
189
          GtkWidget   *image;
223
213
/*  public functions  */
224
214
 
225
215
GimpPlugInAction *
226
 
gimp_plug_in_action_new (const gchar   *name,
227
 
                         const gchar   *label,
228
 
                         const gchar   *tooltip,
229
 
                         const gchar   *stock_id,
230
 
                         PlugInProcDef *proc_def)
 
216
gimp_plug_in_action_new (const gchar         *name,
 
217
                         const gchar         *label,
 
218
                         const gchar         *tooltip,
 
219
                         const gchar         *stock_id,
 
220
                         GimpPlugInProcedure *procedure)
231
221
{
232
222
  return g_object_new (GIMP_TYPE_PLUG_IN_ACTION,
233
 
                       "name",     name,
234
 
                       "label",    label,
235
 
                       "tooltip",  tooltip,
236
 
                       "stock_id", stock_id,
237
 
                       "proc-def", proc_def,
 
223
                       "name",      name,
 
224
                       "label",     label,
 
225
                       "tooltip",   tooltip,
 
226
                       "stock-id",  stock_id,
 
227
                       "procedure", procedure,
238
228
                       NULL);
239
229
}
240
230
 
241
231
void
242
 
gimp_plug_in_action_selected (GimpPlugInAction *action,
243
 
                              PlugInProcDef    *proc_def)
 
232
gimp_plug_in_action_selected (GimpPlugInAction    *action,
 
233
                              GimpPlugInProcedure *procedure)
244
234
{
245
235
  g_return_if_fail (GIMP_IS_PLUG_IN_ACTION (action));
246
236
 
247
 
  g_signal_emit (action, action_signals[SELECTED], 0, proc_def);
 
237
  g_signal_emit (action, action_signals[SELECTED], 0, procedure);
248
238
}