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.
This commit is contained in:
Martin Nordholts 2009-04-30 19:53:19 +02:00
parent a51521fe1d
commit e622dc3cad
8 changed files with 46 additions and 9 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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)

View File

@ -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);

30
app/file/gimpfile.h Normal file
View File

@ -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__ */

View File

@ -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);