some cleanups and a bug-fix for my last commit here

svn path=/trunk/; revision=24963
This commit is contained in:
Sven Neumann 2008-02-25 21:21:15 +00:00
parent ca9b98a88e
commit 8626406371
3 changed files with 23 additions and 21 deletions

View File

@ -24,6 +24,8 @@
#include "print-page-setup.h"
#include "print-utils.h"
#define PRINT_PAGE_SETUP_NAME "print-page-setup"
void
print_page_setup_dialog (GtkPrintOperation *operation)
@ -51,29 +53,23 @@ print_page_setup_load (GtkPrintOperation *operation,
g_return_if_fail (GTK_IS_PRINT_OPERATION (operation));
key_file = print_utils_key_file_load_from_parasite (image_ID,
"print-page-setup");
PRINT_PAGE_SETUP_NAME);
if (! key_file)
key_file = print_utils_key_file_load_from_rcfile ("print-page-setup");
key_file = print_utils_key_file_load_from_rcfile (PRINT_PAGE_SETUP_NAME);
if (key_file)
{
GtkPageSetup *setup;
GError *error = NULL;
setup = gtk_page_setup_new_from_key_file (key_file, NULL, &error);
setup = gtk_page_setup_new_from_key_file (key_file,
PRINT_PAGE_SETUP_NAME, NULL);
if (setup)
{
gtk_print_operation_set_default_page_setup (operation, setup);
g_object_unref (setup);
}
else
{
g_warning ("unable to read page setup from key file: %s",
error->message);
g_error_free (error);
}
g_key_file_free (key_file);
}
@ -92,12 +88,12 @@ print_page_setup_save (GtkPrintOperation *operation,
setup = gtk_print_operation_get_default_page_setup (operation);
gtk_page_setup_to_key_file (setup, key_file, NULL);
gtk_page_setup_to_key_file (setup, key_file, PRINT_PAGE_SETUP_NAME);
print_utils_key_file_save_as_parasite (key_file,
image_ID, "print-page-setup");
image_ID, PRINT_PAGE_SETUP_NAME);
print_utils_key_file_save_as_rcfile (key_file,
"print-page-setup");
PRINT_PAGE_SETUP_NAME);
g_key_file_free (key_file);
}

View File

@ -29,6 +29,8 @@
#define PRINT_SETTINGS_MAJOR_VERSION 0
#define PRINT_SETTINGS_MINOR_VERSION 4
#define PRINT_SETTINGS_NAME "print-settings"
static GKeyFile * print_settings_key_file_from_settings (PrintData *data);
@ -77,7 +79,7 @@ print_settings_save (PrintData *data)
{
GKeyFile *key_file = print_settings_key_file_from_settings (data);
print_utils_key_file_save_as_rcfile (key_file, "print-settings");
print_utils_key_file_save_as_rcfile (key_file, PRINT_SETTINGS_NAME);
/* image setup */
if (gimp_image_is_valid (data->image_id))
@ -98,7 +100,8 @@ print_settings_save (PrintData *data)
"use-full-page", data->use_full_page);
print_utils_key_file_save_as_parasite (key_file,
data->image_id, "print-settings");
data->image_id,
PRINT_SETTINGS_NAME);
}
g_key_file_free (key_file);
@ -140,7 +143,7 @@ print_settings_add_to_key_file (const gchar *key,
{
GKeyFile *key_file = data;
g_key_file_set_value (key_file, "print-settings", key, value);
g_key_file_set_value (key_file, PRINT_SETTINGS_NAME, key, value);
}
/*
@ -149,7 +152,9 @@ print_settings_add_to_key_file (const gchar *key,
static GKeyFile *
print_settings_key_file_from_resource_file (void)
{
GKeyFile *key_file = print_utils_key_file_load_from_rcfile ("print-settings");
GKeyFile *key_file;
key_file = print_utils_key_file_load_from_rcfile (PRINT_SETTINGS_NAME);
if (key_file && ! print_settings_check_version (key_file))
{
@ -170,7 +175,7 @@ print_settings_key_file_from_parasite (gint32 image_ID)
GKeyFile *key_file;
key_file = print_utils_key_file_load_from_parasite (image_ID,
"print-settings");
PRINT_SETTINGS_NAME);
if (key_file && ! print_settings_check_version (key_file))
{
@ -195,7 +200,7 @@ print_settings_load_from_key_file (PrintData *data,
if (! settings)
settings = gtk_print_settings_new ();
keys = g_key_file_get_keys (key_file, "print-settings", &n_keys, NULL);
keys = g_key_file_get_keys (key_file, PRINT_SETTINGS_NAME, &n_keys, NULL);
if (! keys)
return FALSE;
@ -204,7 +209,8 @@ print_settings_load_from_key_file (PrintData *data,
{
gchar *value;
value = g_key_file_get_value (key_file, "print-settings", keys[i], NULL);
value = g_key_file_get_value (key_file,
PRINT_SETTINGS_NAME, keys[i], NULL);
if (value)
{

View File

@ -31,7 +31,7 @@ print_utils_key_file_load_from_rcfile (const gchar *basename)
g_return_val_if_fail (basename != NULL, NULL);
filename = g_build_filename (gimp_directory (), "print-settings", NULL);
filename = g_build_filename (gimp_directory (), basename, NULL);
key_file = g_key_file_new ();