~ubuntu-branches/ubuntu/karmic/gimp/karmic-security

« back to all changes in this revision

Viewing changes to app/actions/file-commands.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20081006133041-axco233xt49jobn7
Tags: 2.6.0-1ubuntu1
* Sync on debian and new version (lp: #276839)
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch:
  - updated some strings for ubuntu
* debian/rules:
  - updated translation templates

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
/*  local function prototypes  */
66
66
 
67
67
static void   file_open_dialog_show        (GtkWidget   *parent,
 
68
                                            Gimp        *gimp,
68
69
                                            GimpImage   *image,
69
70
                                            const gchar *uri,
70
71
                                            gboolean     open_as_layers);
90
91
file_open_cmd_callback (GtkAction *action,
91
92
                        gpointer   data)
92
93
{
 
94
  Gimp        *gimp;
93
95
  GimpImage   *image;
94
96
  GtkWidget   *widget;
95
97
  const gchar *uri = NULL;
 
98
  return_if_no_gimp (gimp, data);
96
99
  return_if_no_widget (widget, data);
97
100
 
98
101
  image = action_data_get_image (data);
100
103
  if (image)
101
104
    uri = gimp_object_get_name (GIMP_OBJECT (image));
102
105
 
103
 
  file_open_dialog_show (widget, NULL, uri, FALSE);
 
106
  file_open_dialog_show (widget, gimp, NULL, uri, FALSE);
104
107
}
105
108
 
106
109
void
107
110
file_open_as_layers_cmd_callback (GtkAction *action,
108
111
                                  gpointer   data)
109
112
{
 
113
  Gimp        *gimp;
110
114
  GimpDisplay *display;
111
115
  GtkWidget   *widget;
112
116
  GimpImage   *image;
113
117
  const gchar *uri;
 
118
  return_if_no_gimp (gimp, data);
114
119
  return_if_no_display (display, data);
115
120
  return_if_no_widget (widget, data);
116
121
 
117
122
  image = display->image;
118
123
  uri = gimp_object_get_name (GIMP_OBJECT (image));
119
124
 
120
 
  file_open_dialog_show (widget, image, uri, TRUE);
 
125
  file_open_dialog_show (widget, gimp, image, uri, TRUE);
121
126
}
122
127
 
123
128
void
133
138
}
134
139
 
135
140
void
136
 
file_last_opened_cmd_callback (GtkAction *action,
 
141
file_open_recent_cmd_callback (GtkAction *action,
137
142
                               gint       value,
138
143
                               gpointer   data)
139
144
{
152
157
 
153
158
  if (imagefile)
154
159
    {
 
160
      GimpDisplay       *display;
 
161
      GimpProgress      *progress;
155
162
      GimpImage         *image;
156
163
      GimpPDBStatusType  status;
157
164
      GError            *error = NULL;
 
165
      return_if_no_display (display, data);
 
166
 
 
167
      progress = display->image ? NULL : GIMP_PROGRESS (display);
158
168
 
159
169
      image = file_open_with_display (gimp, action_data_get_context (data),
160
 
                                      NULL,
 
170
                                      progress,
161
171
                                      GIMP_OBJECT (imagefile)->name, FALSE,
162
172
                                      &status, &error);
163
173
 
166
176
          gchar *filename =
167
177
            file_utils_uri_display_name (GIMP_OBJECT (imagefile)->name);
168
178
 
169
 
          gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR,
 
179
          gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
170
180
                        _("Opening '%s' failed:\n\n%s"),
171
181
                        filename, error->message);
172
182
          g_clear_error (&error);
185
195
  GimpImage    *image;
186
196
  GtkWidget    *widget;
187
197
  GimpSaveMode  save_mode;
 
198
  const gchar  *uri;
188
199
  gboolean      saved = FALSE;
189
200
  return_if_no_display (display, data);
190
201
  return_if_no_widget (widget, data);
196
207
  if (! gimp_image_get_active_drawable (image))
197
208
    return;
198
209
 
 
210
  uri = gimp_object_get_name (GIMP_OBJECT (image));
 
211
 
199
212
  switch (save_mode)
200
213
    {
201
214
    case GIMP_SAVE_MODE_SAVE:
202
215
    case GIMP_SAVE_MODE_SAVE_AND_CLOSE:
203
 
      /*  Only save if the image has been modified  */
204
 
      if (image->dirty ||
205
 
          ! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag)
 
216
      /*  Only save if the image has been modified, or if it is new.  */
 
217
      if ((image->dirty ||
 
218
           ! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag) ||
 
219
          uri == NULL)
206
220
        {
207
 
          const gchar         *uri;
208
 
          GimpPlugInProcedure *save_proc = NULL;
209
 
 
210
 
          uri       = gimp_object_get_name (GIMP_OBJECT (image));
211
 
          save_proc = gimp_image_get_save_proc (image);
 
221
          GimpPlugInProcedure *save_proc = gimp_image_get_save_proc (image);
212
222
 
213
223
          if (uri && ! save_proc)
214
 
            save_proc =
215
 
              file_procedure_find (image->gimp->plug_in_manager->save_procs,
216
 
                                   uri, NULL);
 
224
            {
 
225
              save_proc =
 
226
                file_procedure_find (image->gimp->plug_in_manager->save_procs,
 
227
                                     uri, NULL);
 
228
            }
217
229
 
218
230
          if (uri && save_proc)
219
231
            {
277
289
        }
278
290
      else
279
291
        {
 
292
          gimp_message (image->gimp, G_OBJECT (display),
 
293
                        GIMP_MESSAGE_INFO, _("No changes need to be saved"));
280
294
          saved = TRUE;
281
295
          break;
282
296
        }
297
311
  if (save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE &&
298
312
      saved && ! display->image->dirty)
299
313
    {
300
 
      gimp_display_delete (display);
 
314
      gimp_display_close (display);
301
315
    }
302
316
}
303
317
 
403
417
 
404
418
  if (! gimp_displays_dirty (gimp))
405
419
    {
406
 
      gimp_displays_delete (gimp);
 
420
      gimp_displays_close (gimp);
407
421
    }
408
422
  else
409
423
    {
431
445
                       const gchar *uri,
432
446
                       GtkWidget   *parent)
433
447
{
434
 
  file_open_dialog_show (parent, NULL, uri, FALSE);
 
448
  file_open_dialog_show (parent, gimp, NULL, uri, FALSE);
435
449
}
436
450
 
437
451
 
439
453
 
440
454
static void
441
455
file_open_dialog_show (GtkWidget   *parent,
 
456
                       Gimp        *gimp,
442
457
                       GimpImage   *image,
443
458
                       const gchar *uri,
444
459
                       gboolean     open_as_layers)
451
466
 
452
467
  if (dialog)
453
468
    {
 
469
      if (! uri)
 
470
        uri = g_object_get_data (G_OBJECT (gimp), "gimp-file-open-last-uri");
 
471
 
454
472
      if (uri)
455
473
        gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
456
474