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

« back to all changes in this revision

Viewing changes to app/plug-in/gimppluginprocframe.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
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * gimppluginprocframe.c
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include <string.h>
 
24
 
 
25
#include <glib-object.h>
 
26
 
 
27
#include "plug-in-types.h"
 
28
 
 
29
#include "core/gimpcontext.h"
 
30
#include "core/gimpprogress.h"
 
31
 
 
32
#include "gimpplugin.h"
 
33
#include "gimpplugin-cleanup.h"
 
34
#include "gimpplugin-progress.h"
 
35
#include "gimppluginprocedure.h"
 
36
 
 
37
 
 
38
/*  public functions  */
 
39
 
 
40
GimpPlugInProcFrame *
 
41
gimp_plug_in_proc_frame_new (GimpContext         *context,
 
42
                             GimpProgress        *progress,
 
43
                             GimpPlugInProcedure *procedure)
 
44
{
 
45
  GimpPlugInProcFrame *proc_frame;
 
46
 
 
47
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
48
  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
 
49
  g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
 
50
 
 
51
  proc_frame = g_new0 (GimpPlugInProcFrame, 1);
 
52
 
 
53
  proc_frame->ref_count = 1;
 
54
 
 
55
  gimp_plug_in_proc_frame_init (proc_frame, context, progress, procedure);
 
56
 
 
57
  return proc_frame;
 
58
}
 
59
 
 
60
void
 
61
gimp_plug_in_proc_frame_init (GimpPlugInProcFrame *proc_frame,
 
62
                              GimpContext         *context,
 
63
                              GimpProgress        *progress,
 
64
                              GimpPlugInProcedure *procedure)
 
65
{
 
66
  g_return_if_fail (proc_frame != NULL);
 
67
  g_return_if_fail (GIMP_IS_CONTEXT (context));
 
68
  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
 
69
  g_return_if_fail (procedure == NULL ||
 
70
                    GIMP_IS_PLUG_IN_PROCEDURE (procedure));
 
71
 
 
72
  proc_frame->main_context       = g_object_ref (context);
 
73
  proc_frame->context_stack      = NULL;
 
74
  proc_frame->procedure          = GIMP_PROCEDURE (procedure);
 
75
  proc_frame->main_loop          = NULL;
 
76
  proc_frame->return_vals        = NULL;
 
77
  proc_frame->progress           = progress ? g_object_ref (progress) : NULL;
 
78
  proc_frame->progress_created   = FALSE;
 
79
  proc_frame->progress_cancel_id = 0;
 
80
 
 
81
  if (progress)
 
82
    gimp_plug_in_progress_attach (progress);
 
83
}
 
84
 
 
85
void
 
86
gimp_plug_in_proc_frame_dispose (GimpPlugInProcFrame *proc_frame,
 
87
                                 GimpPlugIn          *plug_in)
 
88
{
 
89
  g_return_if_fail (proc_frame != NULL);
 
90
  g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
 
91
 
 
92
  if (proc_frame->progress)
 
93
    {
 
94
      gimp_plug_in_progress_end (plug_in, proc_frame);
 
95
 
 
96
      if (proc_frame->progress)
 
97
        {
 
98
          g_object_unref (proc_frame->progress);
 
99
          proc_frame->progress = NULL;
 
100
        }
 
101
    }
 
102
 
 
103
  if (proc_frame->context_stack)
 
104
    {
 
105
      g_list_foreach (proc_frame->context_stack, (GFunc) g_object_unref, NULL);
 
106
      g_list_free (proc_frame->context_stack);
 
107
      proc_frame->context_stack = NULL;
 
108
    }
 
109
 
 
110
  if (proc_frame->main_context)
 
111
    {
 
112
      g_object_unref (proc_frame->main_context);
 
113
      proc_frame->main_context = NULL;
 
114
    }
 
115
 
 
116
  if (proc_frame->return_vals)
 
117
    {
 
118
      g_value_array_free (proc_frame->return_vals);
 
119
      proc_frame->return_vals = NULL;
 
120
    }
 
121
 
 
122
  if (proc_frame->main_loop)
 
123
    {
 
124
      g_main_loop_unref (proc_frame->main_loop);
 
125
      proc_frame->main_loop = NULL;
 
126
    }
 
127
 
 
128
  if (proc_frame->cleanups)
 
129
    gimp_plug_in_cleanup (plug_in, proc_frame);
 
130
}
 
131
 
 
132
GimpPlugInProcFrame *
 
133
gimp_plug_in_proc_frame_ref (GimpPlugInProcFrame *proc_frame)
 
134
{
 
135
  g_return_val_if_fail (proc_frame != NULL, NULL);
 
136
 
 
137
  proc_frame->ref_count++;
 
138
 
 
139
  return proc_frame;
 
140
}
 
141
 
 
142
void
 
143
gimp_plug_in_proc_frame_unref (GimpPlugInProcFrame *proc_frame,
 
144
                               GimpPlugIn          *plug_in)
 
145
{
 
146
  g_return_if_fail (proc_frame != NULL);
 
147
  g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
 
148
 
 
149
  proc_frame->ref_count--;
 
150
 
 
151
  if (proc_frame->ref_count < 1)
 
152
    {
 
153
      gimp_plug_in_proc_frame_dispose (proc_frame, plug_in);
 
154
      g_free (proc_frame);
 
155
    }
 
156
}
 
157
 
 
158
GValueArray *
 
159
gimp_plug_in_proc_frame_get_return_vals (GimpPlugInProcFrame *proc_frame)
 
160
{
 
161
  GValueArray *return_vals;
 
162
 
 
163
  g_return_val_if_fail (proc_frame != NULL, NULL);
 
164
 
 
165
  if (proc_frame->return_vals)
 
166
    {
 
167
      if (proc_frame->return_vals->n_values >=
 
168
          proc_frame->procedure->num_values + 1)
 
169
        {
 
170
          return_vals = proc_frame->return_vals;
 
171
        }
 
172
      else
 
173
        {
 
174
          /* Allocate new return values of the correct size. */
 
175
          return_vals = gimp_procedure_get_return_values (proc_frame->procedure,
 
176
                                                          FALSE);
 
177
 
 
178
          /* Copy all of the arguments we can. */
 
179
          memcpy (return_vals->values, proc_frame->return_vals->values,
 
180
                  sizeof (GValue) * proc_frame->return_vals->n_values);
 
181
 
 
182
          /* Free the old arguments. */
 
183
          g_free (proc_frame->return_vals->values);
 
184
          proc_frame->return_vals->values = 0;
 
185
          proc_frame->return_vals->n_values = 0;
 
186
          g_value_array_free (proc_frame->return_vals);
 
187
        }
 
188
 
 
189
      /* We have consumed any saved values, so clear them. */
 
190
      proc_frame->return_vals = NULL;
 
191
    }
 
192
  else
 
193
    {
 
194
      /* Just return a dummy set of values. */
 
195
      return_vals = gimp_procedure_get_return_values (proc_frame->procedure,
 
196
                                                      FALSE);
 
197
    }
 
198
 
 
199
  return return_vals;
 
200
}