aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-print.c
diff options
context:
space:
mode:
Diffstat (limited to 'e-util/e-print.c')
-rw-r--r--e-util/e-print.c169
1 files changed, 134 insertions, 35 deletions
diff --git a/e-util/e-print.c b/e-util/e-print.c
index 63d7bf3e1e..33eecca14b 100644
--- a/e-util/e-print.c
+++ b/e-util/e-print.c
@@ -23,75 +23,174 @@
#include <string.h>
#include <gconf/gconf-client.h>
#include "e-print.h"
-
-#define PRINT_CONFIG_KEY "/apps/evolution/shell/print_config"
-
-GnomePrintConfig *
+#include <gtk/gtk.h>
+#include <gtk/gtkprintunixdialog.h>
+#define PRINTER "/apps/evolution/shell/printer"
+#define SCALE "/apps/evolution/shell/scale"
+#define PRINT_PAGES "/apps/evolution/shell/print_pages"
+#define PAGE_RANGES "/apps/evolution/shell/page_ranges"
+#define PAGE_SET "/apps/evolution/shell/page_set"
+#define COLLATE "/apps/evolution/shell/collate"
+#define REVERSE "/apps/evolution/shell/reverse"
+#define N_COPIES "/apps/evolution/shell/n_copies"
+#define LPR_COMMANDLINE "/apps/evolution/shell/lpr_commandline"
+#define OUTPUT_URI "/apps/evolution/shell/output_uri"
+#define OUTPUT_FILE_FORMAT "/apps/evolution/shell/output_file_format"
+
+/* Loads the print settings that were saved previously */
+
+GtkPrintSettings *
e_print_load_config (void)
{
GConfClient *gconf;
- GnomePrintConfig *config;
- char *str;
+ GtkPrintSettings *settings;
+ gchar *printer_name;
+ gchar *collate;
+ gchar *n_copies;
+ gchar *print_pages;
+ gchar *page_set;
+ gchar *scale;
+ gchar *output_uri;
+ gchar *output_file_format;
+ gchar *reverse;
+ gchar *page_ranges;
+ gchar *lpr_commandline;
+
+ settings = gtk_print_settings_new ();
gconf = gconf_client_get_default ();
- str = gconf_client_get_string (gconf, PRINT_CONFIG_KEY, NULL);
- g_object_unref (gconf);
+
+ printer_name = gconf_client_get_string (gconf, PRINTER, NULL);
+ gtk_print_settings_set (settings, "printer", printer_name);
- if (!str)
- return gnome_print_config_default ();
+ n_copies = gconf_client_get_string (gconf, N_COPIES, NULL);
+ gtk_print_settings_set (settings, "n-copies",n_copies);
+
+ collate = gconf_client_get_string (gconf, COLLATE, NULL);
+ gtk_print_settings_set (settings, "collate", collate);
- config = gnome_print_config_from_string (str, 0);
+ lpr_commandline = gconf_client_get_string (gconf, LPR_COMMANDLINE, NULL);
+ gtk_print_settings_set (settings, "lpr-commandline", lpr_commandline);
- /* Its unlikely people will want to preserve this too often */
- gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1);
- gnome_print_config_set_boolean (config, GNOME_PRINT_KEY_COLLATE, FALSE);
+ print_pages = gconf_client_get_string (gconf, PRINT_PAGES, NULL);
+ gtk_print_settings_set (settings, "print-pages", print_pages);
+
+ page_set = gconf_client_get_string (gconf, PAGE_SET, NULL);
+ gtk_print_settings_set (settings, "page-set", page_set);
- return config;
+ output_uri = gconf_client_get_string (gconf, OUTPUT_URI, NULL);
+ gtk_print_settings_set (settings, "output-uri", output_uri);
+
+ output_file_format = gconf_client_get_string (gconf, OUTPUT_FILE_FORMAT, NULL);
+ gtk_print_settings_set (settings, "output-file-format",output_file_format);
+
+ reverse = gconf_client_get_string (gconf, REVERSE, NULL);
+ gtk_print_settings_set (settings, "reverse", reverse);
+
+ scale = gconf_client_get_string (gconf, SCALE, NULL);
+ gtk_print_settings_set (settings, "scale", scale);
+
+ page_ranges = gconf_client_get_string (gconf, PAGE_RANGES, NULL);
+ gtk_print_settings_set (settings, "page-ranges", page_ranges);
+
+ g_free (printer_name);
+ g_free (collate);
+ g_free (n_copies);
+ g_free (print_pages);
+ g_free (page_set);
+ g_free (scale);
+ g_free (output_uri);
+ g_free (output_file_format);
+ g_free (reverse);
+ g_free (page_ranges);
+ g_free (lpr_commandline);
+ g_object_unref (gconf);
+ return settings;
}
-
+/* Saves the print settings */
+
void
-e_print_save_config (GnomePrintConfig *config)
+e_print_save_config (GtkPrintSettings *settings)
{
GConfClient *gconf;
- char *str;
-
- str = gnome_print_config_to_string (config, 0);
+ const gchar *printer_name;
+ const gchar *collate;
+ const gchar *n_copies;
+ const gchar *print_pages;
+ const gchar *page_set;
+ const gchar *scale;
+ const gchar *output_uri;
+ const gchar *output_file_format;
+ const gchar *reverse;
+ const gchar *page_ranges;
+ const gchar *lpr_commandline;
gconf = gconf_client_get_default ();
- gconf_client_set_string (gconf, PRINT_CONFIG_KEY, str, NULL);
+ printer_name = gtk_print_settings_get (settings, "printer");
+ gconf_client_set_string (gconf, PRINTER, printer_name, NULL);
+
+ scale = gtk_print_settings_get (settings, "scale");
+ gconf_client_set_string (gconf, SCALE, scale, NULL);
+
+ page_set = gtk_print_settings_get (settings, "page-set");
+ gconf_client_set_string (gconf, PAGE_SET, page_set, NULL);
+
+ print_pages = gtk_print_settings_get (settings, "print-pages");
+ gconf_client_set_string (gconf, PRINT_PAGES, print_pages, NULL);
+
+ lpr_commandline = gtk_print_settings_get (settings, "lpr-commandline");
+ gconf_client_set_string (gconf, LPR_COMMANDLINE, lpr_commandline, NULL);
+
+ collate = gtk_print_settings_get (settings, "collate");
+ gconf_client_set_string (gconf, COLLATE, collate, NULL);
+
+ output_uri = gtk_print_settings_get (settings, "output-uri");
+ gconf_client_set_string (gconf, OUTPUT_URI, output_uri, NULL);
+
+ output_file_format = gtk_print_settings_get (settings, "output-file-format");
+ gconf_client_set_string (gconf, OUTPUT_FILE_FORMAT, output_file_format, NULL);
+
+ reverse = gtk_print_settings_get (settings, "reverse");
+ gconf_client_set_string (gconf, REVERSE, reverse, NULL);
+
+ n_copies = gtk_print_settings_get (settings, "n_copies");
+ gconf_client_set_string (gconf, N_COPIES, n_copies, NULL);
+
+ page_ranges = gtk_print_settings_get (settings, "page-ranges");
+ gconf_client_set_string (gconf, PAGE_RANGES, "page-ranges",NULL);
+
g_object_unref (gconf);
}
static void
print_dialog_response(GtkWidget *widget, int resp, gpointer data)
{
- if (resp == GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- e_print_save_config (gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (widget)));
+ if (resp == GTK_RESPONSE_OK) {
+ e_print_save_config (gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG (widget)));
+ }
}
+/* Creates a dialog with the print settings */
GtkWidget *
e_print_get_dialog (const char *title, int flags)
{
- GnomePrintConfig *config;
+ GtkPrintSettings *settings;
GtkWidget *dialog;
- config = e_print_load_config ();
- dialog = e_print_get_dialog_with_config (title, flags, config);
- g_object_unref (config);
-
+ settings = e_print_load_config ();
+ dialog = e_print_get_dialog_with_config (title, flags, settings);
+ g_object_unref (settings);
return dialog;
}
GtkWidget *
-e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config)
+e_print_get_dialog_with_config (const char *title, int flags, GtkPrintSettings *settings)
{
GtkWidget *dialog;
-
- dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config", config, NULL);
- gnome_print_dialog_construct (GNOME_PRINT_DIALOG (dialog), title, flags);
-
- g_signal_connect(dialog, "response", G_CALLBACK(print_dialog_response), NULL);
-
+
+ dialog = gtk_print_unix_dialog_new (title, NULL);
+ gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG(dialog), settings);
+ g_signal_connect(dialog, "response", G_CALLBACK(print_dialog_response), NULL);
return dialog;
}