aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-print.c97
-rw-r--r--e-util/e-print.h39
4 files changed, 146 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index b8d92e78e1..2fdda896d3 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-21 JP Rosevear <jpr@novell.com>
+
+ Fixes #46404
+
+ * Makefile.am: build new files
+
+ * e-print.[hc]: print related config and dialog routines
+
2005-01-17 Rodrigo Moya <rodrigo@novell.com>
* e-url.[ch]:
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 5f34d776b4..6ae1ffc80d 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -43,6 +43,7 @@ eutilinclude_HEADERS = \
e-menu.h \
e-mktemp.h \
e-passwords.h \
+ e-print.h \
e-plugin.h \
e-popup.h \
e-request.h \
@@ -82,6 +83,7 @@ libeutil_la_SOURCES = \
e-passwords.c \
e-plugin.c \
e-popup.c \
+ e-print.c \
e-request.c \
e-signature.c \
e-signature-list.c \
diff --git a/e-util/e-print.c b/e-util/e-print.c
new file mode 100644
index 0000000000..63d7bf3e1e
--- /dev/null
+++ b/e-util/e-print.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-print.c - Uniform print setting/dialog routines for Evolution
+ *
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Authors: JP Rosevear <jpr@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <gconf/gconf-client.h>
+#include "e-print.h"
+
+#define PRINT_CONFIG_KEY "/apps/evolution/shell/print_config"
+
+GnomePrintConfig *
+e_print_load_config (void)
+{
+ GConfClient *gconf;
+ GnomePrintConfig *config;
+ char *str;
+
+ gconf = gconf_client_get_default ();
+ str = gconf_client_get_string (gconf, PRINT_CONFIG_KEY, NULL);
+ g_object_unref (gconf);
+
+ if (!str)
+ return gnome_print_config_default ();
+
+ config = gnome_print_config_from_string (str, 0);
+
+ /* 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);
+
+ return config;
+}
+
+
+void
+e_print_save_config (GnomePrintConfig *config)
+{
+ GConfClient *gconf;
+ char *str;
+
+ str = gnome_print_config_to_string (config, 0);
+
+ gconf = gconf_client_get_default ();
+ gconf_client_set_string (gconf, PRINT_CONFIG_KEY, str, 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)));
+}
+
+GtkWidget *
+e_print_get_dialog (const char *title, int flags)
+{
+ GnomePrintConfig *config;
+ GtkWidget *dialog;
+
+ config = e_print_load_config ();
+ dialog = e_print_get_dialog_with_config (title, flags, config);
+ g_object_unref (config);
+
+ return dialog;
+}
+
+GtkWidget *
+e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config)
+{
+ 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);
+
+ return dialog;
+}
diff --git a/e-util/e-print.h b/e-util/e-print.h
new file mode 100644
index 0000000000..738da0f418
--- /dev/null
+++ b/e-util/e-print.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-print.c - Uniform print setting/dialog routines for Evolution
+ *
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Authors: JP Rosevear <jpr@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+#include <libgnomeprint/gnome-print.h>
+#include <libgnomeprintui/gnome-print-dialog.h>
+
+#ifndef __E_PRINT__
+#define __E_PRINT__
+
+G_BEGIN_DECLS
+
+GnomePrintConfig *e_print_load_config (void);
+void e_print_save_config (GnomePrintConfig *config);
+
+GtkWidget *e_print_get_dialog (const char *title, int flags);
+GtkWidget *e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config);
+
+G_END_DECLS
+
+#endif