Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-utils.c
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>2006-01-04 09:07:54 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2006-01-04 09:07:54 (GMT)
commit90a8680bba08da4ae9aa5f0f5382c625eef2f86c (patch)
treed81ed27d2655b27158438b9011f3739d2ed38b44 /shell/ev-utils.c
parent15602b141e3634e1dc741f5057853af07d3de706 (diff)
Setting saving behaviour fixes.
* shell/ev-metadata-manager.c: * shell/ev-utils.c: (using_pdf_printer), (using_postscript_printer), (load_print_config_from_file), (save_print_config_to_file): * shell/ev-utils.h: * shell/ev-window.c: (update_sizing_buttons), (page_changed_cb), (update_sidebar_visibility), (setup_sidebar_from_metadata), (setup_view_from_metadata), (ev_window_setup_document), (ev_window_load_job_cb), (ev_window_sidebar_position_change_cb), (ev_window_run_fullscreen), (ev_window_stop_fullscreen), (ev_window_run_presentation), (ev_window_stop_presentation), (save_sizing_mode), (ev_window_zoom_changed_cb), (ev_window_continuous_changed_cb), (ev_window_rotation_changed_cb), (ev_window_dual_mode_changed_cb), (ev_window_sidebar_current_page_changed_cb), (ev_window_sidebar_visibility_changed_cb), (ev_window_dispose), (window_state_event_cb), (window_configure_event_cb), (ev_window_init): Setting saving behaviour fixes.
Diffstat (limited to 'shell/ev-utils.c')
-rw-r--r--shell/ev-utils.c100
1 files changed, 99 insertions, 1 deletions
diff --git a/shell/ev-utils.c b/shell/ev-utils.c
index 9fc74c6..7508786 100644
--- a/shell/ev-utils.c
+++ b/shell/ev-utils.c
@@ -18,9 +18,14 @@
*
*/
+#include <config.h>
+
#include "ev-utils.h"
+#include "ev-file-helpers.h"
#include <math.h>
+#define PRINT_CONFIG_FILENAME "ev-print-config.xml"
+
typedef struct
{
int size;
@@ -372,7 +377,7 @@ write_to_temp_file (const gchar *contents,
return retval;
}
-gboolean
+static gboolean
ev_file_set_contents (const gchar *filename,
const gchar *contents,
gssize length,
@@ -415,3 +420,96 @@ ev_file_set_contents (const gchar *filename,
#endif /* HAVE_G_FILE_SET_CONTENTS */
+gboolean
+using_pdf_printer (GnomePrintConfig *config)
+{
+ const guchar *driver;
+
+ driver = gnome_print_config_get (
+ config, (const guchar *)"Settings.Engine.Backend.Driver");
+
+ if (driver) {
+ if (!strcmp ((const gchar *)driver, "gnome-print-pdf"))
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+using_postscript_printer (GnomePrintConfig *config)
+{
+ const guchar *driver;
+ const guchar *transport;
+
+ driver = gnome_print_config_get (
+ config, (const guchar *)"Settings.Engine.Backend.Driver");
+
+ transport = gnome_print_config_get (
+ config, (const guchar *)"Settings.Transport.Backend");
+
+ if (driver) {
+ if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
+ return TRUE;
+ else
+ return FALSE;
+ } else if (transport) { /* these transports default to PostScript */
+ if (!strcmp ((const gchar *)transport, "CUPS"))
+ return TRUE;
+ else if (!strcmp ((const gchar *)transport, "LPD"))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+GnomePrintConfig *
+load_print_config_from_file (void)
+{
+ GnomePrintConfig *print_config = NULL;
+ char *file_name, *contents = NULL;
+
+ file_name = g_build_filename (ev_dot_dir (), PRINT_CONFIG_FILENAME,
+ NULL);
+
+ if (g_file_get_contents (file_name, &contents, NULL, NULL)) {
+ print_config = gnome_print_config_from_string (contents, 0);
+ g_free (contents);
+ }
+
+ if (print_config == NULL) {
+ print_config = gnome_print_config_default ();
+ }
+
+ g_free (file_name);
+
+ return print_config;
+}
+
+void
+save_print_config_to_file (GnomePrintConfig *config)
+{
+ char *file_name, *str;
+
+ g_return_if_fail (config != NULL);
+
+ str = gnome_print_config_to_string (config, 0);
+ if (str == NULL) return;
+
+ file_name = g_build_filename (ev_dot_dir (),
+ PRINT_CONFIG_FILENAME,
+ NULL);
+
+#ifdef HAVE_G_FILE_SET_CONTENTS
+ g_file_set_contents (file_name, str, -1, NULL);
+#else
+ ev_file_set_contents (file_name, str, -1, NULL);
+#endif
+
+ g_free (file_name);
+ g_free (str);
+}
+
+