[gimp] app: Introduce gimpfile.h



commit e622dc3cade791e3ad625ec6fbddbfa5d5f4f122
Author: Martin Nordholts <martinn src gnome org>
Date:   Thu Apr 30 19:53:19 2009 +0200

    app: Introduce gimpfile.h
    
    Introduce gimpfile.h which for now contains defines for GObject data
    keys used when managing save and open dialog URI defaults. More are to
    be added.
---
 app/actions/file-commands.c    |    3 ++-
 app/dialogs/file-open-dialog.c |    3 ++-
 app/dialogs/file-save-dialog.c |    5 +++--
 app/file/Makefile.am           |    3 ++-
 app/file/file-open.c           |    3 ++-
 app/file/file-save.c           |    5 +++--
 app/file/gimpfile.h            |   30 ++++++++++++++++++++++++++++++
 app/widgets/gimpfiledialog.c   |    3 ++-
 8 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index c6b8eb7..4d3b330 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -40,6 +40,7 @@
 #include "file/file-procedure.h"
 #include "file/file-save.h"
 #include "file/file-utils.h"
+#include "file/gimpfile.h"
 
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimpdialogfactory.h"
@@ -440,7 +441,7 @@ file_open_dialog_show (Gimp        *gimp,
         uri = gimp_object_get_name (GIMP_OBJECT (image));
 
       if (! uri)
-        uri = g_object_get_data (G_OBJECT (gimp), "gimp-file-open-last-uri");
+        uri = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY);
 
       if (uri)
         gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c
index 942fef3..de2cc7f 100644
--- a/app/dialogs/file-open-dialog.c
+++ b/app/dialogs/file-open-dialog.c
@@ -35,6 +35,7 @@
 
 #include "file/file-open.h"
 #include "file/file-utils.h"
+#include "file/gimpfile.h"
 
 #include "widgets/gimpfiledialog.h"
 #include "widgets/gimphelp-ids.h"
@@ -119,7 +120,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
   uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (open_dialog));
 
   if (uris)
-    g_object_set_data_full (G_OBJECT (gimp), "gimp-file-open-last-uri",
+    g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY,
                             g_strdup (uris->data), (GDestroyNotify) g_free);
 
   gimp_file_dialog_set_sensitive (dialog, FALSE);
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index 16a69bc..d0d7fbe 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -37,6 +37,7 @@
 #include "file/file-procedure.h"
 #include "file/file-save.h"
 #include "file/file-utils.h"
+#include "file/gimpfile.h"
 
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimpfiledialog.h"
@@ -96,7 +97,7 @@ file_save_dialog_new (Gimp *gimp)
   if (state)
     gimp_file_dialog_set_state (GIMP_FILE_DIALOG (dialog), state);
 
-  uri = g_object_get_data (G_OBJECT (gimp), "gimp-file-save-last-uri");
+  uri = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_SAVE_LAST_URI_KEY);
 
   if (uri)
     {
@@ -498,7 +499,7 @@ file_save_dialog_save_image (GtkWidget           *save_dialog,
                       GIMP_RUN_INTERACTIVE, save_a_copy, &error);
 
   if (status == GIMP_PDB_SUCCESS)
-    g_object_set_data_full (G_OBJECT (image->gimp), "gimp-file-save-last-uri",
+    g_object_set_data_full (G_OBJECT (image->gimp), GIMP_FILE_SAVE_LAST_URI_KEY,
                             g_strdup (uri), (GDestroyNotify) g_free);
 
   g_object_unref (image);
diff --git a/app/file/Makefile.am b/app/file/Makefile.am
index 08c53c6..74edfb6 100644
--- a/app/file/Makefile.am
+++ b/app/file/Makefile.am
@@ -22,6 +22,7 @@ libappfile_a_SOURCES = \
 	file-save.c		\
 	file-save.h		\
 	file-utils.c		\
-	file-utils.h
+	file-utils.h		\
+	gimpfile.h
 
 EXTRA_DIST = makefile.msc
diff --git a/app/file/file-open.c b/app/file/file-open.c
index f27bcb5..13b2f00 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -68,6 +68,7 @@
 #include "file-open.h"
 #include "file-procedure.h"
 #include "file-utils.h"
+#include "gimpfile.h"
 
 #include "gimp-intl.h"
 
@@ -543,7 +544,7 @@ file_open_from_command_line (Gimp        *gimp,
         {
           success = TRUE;
 
-          g_object_set_data_full (G_OBJECT (gimp), "gimp-file-open-last-uri",
+          g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY,
                                   uri, (GDestroyNotify) g_free);
         }
       else if (status != GIMP_PDB_CANCEL)
diff --git a/app/file/file-save.c b/app/file/file-save.c
index d99ae2b..3e69401 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -59,6 +59,7 @@
 
 #include "file-save.h"
 #include "file-utils.h"
+#include "gimpfile.h"
 
 #include "gimp-intl.h"
 
@@ -155,7 +156,7 @@ file_save (GimpImage           *image,
       if (save_a_copy)
         {
           /*  remember the "save-a-copy" filename for the next invocation  */
-          g_object_set_data_full (G_OBJECT (image), "gimp-file-save-a-copy-uri",
+          g_object_set_data_full (G_OBJECT (image), GIMP_FILE_SAVE_A_COPY_URI_KEY,
                                   g_strdup (uri),
                                   (GDestroyNotify) g_free);
         }
@@ -164,7 +165,7 @@ file_save (GimpImage           *image,
           /*  reset the "save-a-copy" filename when the image URI changes  */
           if (strcmp (uri, gimp_image_get_uri (image)))
             g_object_set_data (G_OBJECT (image),
-                               "gimp-file-save-a-copy-uri", NULL);
+                               GIMP_FILE_SAVE_A_COPY_URI_KEY, NULL);
 
           gimp_image_set_uri (image, uri);
           gimp_image_set_save_proc (image, file_proc);
diff --git a/app/file/gimpfile.h b/app/file/gimpfile.h
new file mode 100644
index 0000000..09c7a45
--- /dev/null
+++ b/app/file/gimpfile.h
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * file.h
+ * Copyright (C) 2009 Martin Nordholts <martinn src gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FILE_H__
+#define __FILE_H__
+
+
+#define GIMP_FILE_SAVE_LAST_URI_KEY   "gimp-file-save-last-uri"
+#define GIMP_FILE_OPEN_LAST_URI_KEY   "gimp-file-open-last-uri"
+#define GIMP_FILE_SAVE_A_COPY_URI_KEY "gimp-file-save-a-copy-uri"
+
+
+#endif /* __FILE_H__ */
diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c
index 7939bb9..9f806a3 100644
--- a/app/widgets/gimpfiledialog.c
+++ b/app/widgets/gimpfiledialog.c
@@ -37,6 +37,7 @@
 #include "config/gimpguiconfig.h"
 
 #include "file/file-utils.h"
+#include "file/gimpfile.h"
 
 #include "pdb/gimppdb.h"
 
@@ -469,7 +470,7 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
   dialog->close_after_saving = close_after_saving;
 
   if (save_a_copy)
-    uri = g_object_get_data (G_OBJECT (image), "gimp-file-save-a-copy-uri");
+    uri = g_object_get_data (G_OBJECT (image), GIMP_FILE_SAVE_A_COPY_URI_KEY);
 
   if (! uri)
     uri = gimp_image_get_uri (image);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]