[gimp] app: Introduce file_write_with_uri_and_proc()
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] app: Introduce file_write_with_uri_and_proc()
- Date: Sun, 26 Apr 2009 11:23:27 -0400 (EDT)
commit 9e7edcd6f478a78b8436ba776e69c148c04eda63
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Apr 26 17:22:56 2009 +0200
app: Introduce file_write_with_uri_and_proc()
Introduce file_write_with_uri_and_proc() so that the
file_save_cmd_callback() switch case becomes more managable and so
that we can reuse that logic later.
---
app/actions/file-commands.c | 166 ++++++++++++++++++++++++-------------------
1 files changed, 94 insertions(+), 72 deletions(-)
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 4394a1a..c6b8eb7 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -64,25 +64,31 @@
/* local function prototypes */
-static void file_open_dialog_show (Gimp *gimp,
- GtkWidget *parent,
- const gchar *title,
- GimpImage *image,
- const gchar *uri,
- gboolean open_as_layers);
-static void file_save_dialog_show (GimpImage *image,
- GtkWidget *parent,
- const gchar *title,
- gboolean save_a_copy,
- gboolean close_after_saving);
-static void file_save_dialog_destroyed (GtkWidget *dialog,
- GimpImage *image);
-static void file_new_template_callback (GtkWidget *widget,
- const gchar *name,
- gpointer data);
-static void file_revert_confirm_response (GtkWidget *dialog,
- gint response_id,
- GimpDisplay *display);
+static void file_open_dialog_show (Gimp *gimp,
+ GtkWidget *parent,
+ const gchar *title,
+ GimpImage *image,
+ const gchar *uri,
+ gboolean open_as_layers);
+static void file_save_dialog_show (GimpImage *image,
+ GtkWidget *parent,
+ const gchar *title,
+ gboolean save_a_copy,
+ gboolean close_after_saving);
+static gboolean file_write_with_uri_and_proc (GimpImage *image,
+ GimpContext *context,
+ GimpDisplay *display,
+ const gchar *uri,
+ GimpPlugInProcedure *proc);
+static void file_save_dialog_destroyed (GtkWidget *dialog,
+ GimpImage *image);
+static void file_new_template_callback (GtkWidget *widget,
+ const gchar *name,
+ gpointer data);
+static void file_revert_confirm_response (GtkWidget *dialog,
+ gint response_id,
+ GimpDisplay *display);
+
/* public functions */
@@ -236,59 +242,11 @@ file_save_cmd_callback (GtkAction *action,
if (uri && save_proc)
{
- GimpPDBStatusType status;
- GError *error = NULL;
- GList *list;
-
- for (list = gimp_action_groups_from_name ("file");
- list;
- list = g_list_next (list))
- {
- gimp_action_group_set_action_sensitive (list->data,
- "file-quit",
- FALSE);
- }
-
- status = file_save (image, action_data_get_context (data),
- GIMP_PROGRESS (display),
- uri, save_proc,
- GIMP_RUN_WITH_LAST_VALS, FALSE, &error);
-
- switch (status)
- {
- case GIMP_PDB_SUCCESS:
- saved = TRUE;
- break;
-
- case GIMP_PDB_CANCEL:
- gimp_message_literal (image->gimp,
- G_OBJECT (display), GIMP_MESSAGE_INFO,
- _("Saving canceled"));
- break;
-
- default:
- {
- gchar *filename = file_utils_uri_display_name (uri);
-
- gimp_message (image->gimp, G_OBJECT (display),
- GIMP_MESSAGE_ERROR,
- _("Saving '%s' failed:\n\n%s"),
- filename, error->message);
- g_free (filename);
- g_clear_error (&error);
- }
- break;
- }
-
- for (list = gimp_action_groups_from_name ("file");
- list;
- list = g_list_next (list))
- {
- gimp_action_group_set_action_sensitive (list->data,
- "file-quit",
- TRUE);
- }
-
+ saved = file_write_with_uri_and_proc (image,
+ action_data_get_context (data),
+ display,
+ uri,
+ save_proc);
break;
}
@@ -543,6 +501,70 @@ file_save_dialog_show (GimpImage *image,
}
}
+static gboolean
+file_write_with_uri_and_proc (GimpImage *image,
+ GimpContext *context,
+ GimpDisplay *display,
+ const gchar *uri,
+ GimpPlugInProcedure *proc)
+{
+ gboolean saved = FALSE;
+ GimpPDBStatusType status;
+ GError *error = NULL;
+ GList *list;
+
+ for (list = gimp_action_groups_from_name ("file");
+ list;
+ list = g_list_next (list))
+ {
+ gimp_action_group_set_action_sensitive (list->data,
+ "file-quit",
+ FALSE);
+ }
+
+ status = file_save (image, context,
+ GIMP_PROGRESS (display),
+ uri, proc,
+ GIMP_RUN_WITH_LAST_VALS, FALSE, &error);
+
+ switch (status)
+ {
+ case GIMP_PDB_SUCCESS:
+ saved = TRUE;
+ break;
+
+ case GIMP_PDB_CANCEL:
+ gimp_message_literal (image->gimp,
+ G_OBJECT (display), GIMP_MESSAGE_INFO,
+ _("Saving canceled"));
+ break;
+
+ default:
+ {
+ gchar *filename = file_utils_uri_display_name (uri);
+
+ gimp_message (image->gimp, G_OBJECT (display),
+ GIMP_MESSAGE_ERROR,
+ _("Saving '%s' failed:\n\n%s"),
+ filename, error->message);
+ g_free (filename);
+ g_clear_error (&error);
+ }
+ break;
+ }
+
+ for (list = gimp_action_groups_from_name ("file");
+ list;
+ list = g_list_next (list))
+ {
+ gimp_action_group_set_action_sensitive (list->data,
+ "file-quit",
+ TRUE);
+ }
+
+ return saved;
+}
+
static void
file_save_dialog_destroyed (GtkWidget *dialog,
GimpImage *image)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]