Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-application.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2009-10-23 08:27:37 (GMT)
committer Carlos Garcia Campos <carlosgc@gnome.org>2009-10-23 08:31:24 (GMT)
commit70919434b478e8f1073eed56097d29b6f2dba314 (patch)
tree91d22babd13dd6109d43db62154983358a8b9010 /shell/ev-application.c
parentf8a0165d07b14ac0c877e638c86e0dc0a8905d8f (diff)
Move load/save print settings code from EvApplication to EvWindow
Settings are now loaded everytime before printing and saved after.
Diffstat (limited to 'shell/ev-application.c')
-rw-r--r--shell/ev-application.c167
1 files changed, 0 insertions, 167 deletions
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 6e4cf62..cc271f5 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -58,8 +58,6 @@ static gboolean ev_application_open_uri (EvApplication *application,
#include "ev-application-service.h"
#endif
-static void ev_application_save_print_settings (EvApplication *application);
-
struct _EvApplication {
GObject base_instance;
@@ -85,10 +83,6 @@ struct _EvApplication {
gchar *filechooser_open_uri;
gchar *filechooser_save_uri;
-
- GtkPrintSettings *print_settings;
- GtkPageSetup *page_setup;
- GKeyFile *print_settings_file;
};
struct _EvApplicationClass {
@@ -104,10 +98,6 @@ G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT);
#define APPLICATION_DBUS_INTERFACE "org.gnome.evince.Application"
#endif
-#define EV_PRINT_SETTINGS_FILE "print-settings"
-#define EV_PRINT_SETTINGS_GROUP "Print Settings"
-#define EV_PAGE_SETUP_GROUP "Page Setup"
-
/**
* ev_application_get_instance:
*
@@ -824,23 +814,6 @@ ev_application_shutdown (EvApplication *application)
application->toolbars_file = NULL;
}
- ev_application_save_print_settings (application);
-
- if (application->print_settings_file) {
- g_key_file_free (application->print_settings_file);
- application->print_settings_file = NULL;
- }
-
- if (application->print_settings) {
- g_object_unref (application->print_settings);
- application->print_settings = NULL;
- }
-
- if (application->page_setup) {
- g_object_unref (application->page_setup);
- application->page_setup = NULL;
- }
-
#ifdef ENABLE_DBUS
if (application->keys) {
g_object_unref (application->keys);
@@ -1055,146 +1028,6 @@ ev_application_screensaver_disable (EvApplication *application)
totem_scrsaver_disable (application->scr_saver);
}
-static GKeyFile *
-ev_application_get_print_settings_file (EvApplication *application)
-{
- gchar *filename;
-
- if (application->print_settings_file)
- return application->print_settings_file;
-
- application->print_settings_file = g_key_file_new ();
-
- filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
- if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
- GError *error = NULL;
-
- g_key_file_load_from_file (application->print_settings_file,
- filename,
- G_KEY_FILE_KEEP_COMMENTS |
- G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- }
- g_free (filename);
-
- return application->print_settings_file;
-}
-
-static void
-ev_application_save_print_settings (EvApplication *application)
-{
- GKeyFile *key_file;
- gchar *filename;
- gchar *data;
- gssize data_length;
- GError *error = NULL;
-
- if (!application->print_settings && !application->page_setup)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
- if (application->print_settings)
- gtk_print_settings_to_key_file (application->print_settings,
- key_file,
- EV_PRINT_SETTINGS_GROUP);
- if (application->page_setup)
- gtk_page_setup_to_key_file (application->page_setup,
- key_file,
- EV_PAGE_SETUP_GROUP);
-
- filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
- data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL);
- g_file_set_contents (filename, data, data_length, &error);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- g_free (data);
- g_free (filename);
-}
-
-GtkPrintSettings *
-ev_application_get_print_settings (EvApplication *application)
-{
- GKeyFile *key_file;
- GtkPrintSettings *print_settings;
-
- if (application->print_settings)
- return application->print_settings;
-
- key_file = ev_application_get_print_settings_file (application);
- print_settings = g_key_file_has_group (key_file, EV_PRINT_SETTINGS_GROUP) ?
- gtk_print_settings_new_from_key_file (key_file, EV_PRINT_SETTINGS_GROUP, NULL) :
- gtk_print_settings_new ();
-
- application->print_settings = print_settings ? print_settings : gtk_print_settings_new ();
-
- return application->print_settings;
-}
-
-void
-ev_application_set_print_settings (EvApplication *application,
- GtkPrintSettings *settings)
-{
- GKeyFile *key_file;
-
- g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
-
- if (settings == application->print_settings)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
-
- if (application->print_settings)
- g_object_unref (application->print_settings);
-
- application->print_settings = g_object_ref (settings);
- gtk_print_settings_to_key_file (settings, key_file, EV_PRINT_SETTINGS_GROUP);
-}
-
-GtkPageSetup *
-ev_application_get_page_setup (EvApplication *application)
-{
- GKeyFile *key_file;
- GtkPageSetup *page_setup;
-
- if (application->page_setup)
- return application->page_setup;
-
- key_file = ev_application_get_print_settings_file (application);
- page_setup = g_key_file_has_group (key_file, EV_PAGE_SETUP_GROUP) ?
- gtk_page_setup_new_from_key_file (key_file, EV_PAGE_SETUP_GROUP, NULL) :
- gtk_page_setup_new ();
-
- application->page_setup = page_setup ? page_setup : gtk_page_setup_new ();
-
- return application->page_setup;
-}
-
-void
-ev_application_set_page_setup (EvApplication *application,
- GtkPageSetup *page_setup)
-{
- GKeyFile *key_file;
-
- g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
-
- if (page_setup == application->page_setup)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
-
- if (application->page_setup)
- g_object_unref (application->page_setup);
-
- application->page_setup = g_object_ref (page_setup);
- gtk_page_setup_to_key_file (page_setup, key_file, EV_PAGE_SETUP_GROUP);
-}
-
const gchar *
ev_application_get_dot_dir (EvApplication *application)
{