aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/ChangeLog14
-rw-r--r--e-util/e-print.c56
-rw-r--r--e-util/e-print.h1
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/em-format-html-print.c110
-rw-r--r--shell/ChangeLog7
-rw-r--r--shell/e-shell-window-commands.c10
-rw-r--r--ui/ChangeLog9
-rw-r--r--ui/evolution.xml6
9 files changed, 158 insertions, 60 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index c12d6c07e5..96bcbc6320 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,17 @@
+2007-07-06 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #446894
+
+ * e-print.c (load_page_setup):
+ Extract GtkPageSetup properties from a GtkPrintSettings object.
+
+ * e-print.c (save_page_setup):
+ Merge GtkPageSetup properties into a GtkPrintSettings object.
+
+ * e-print.[ch] (e_print_run_page_setup_dialog):
+ New function runs a preconfigured Page Setup dialog and saves
+ the configuration to GConf (/apps/evolution/shell/printing).
+
2007-06-18 Srinivasa Ragavan <sragavan@novell.com>
** Fix for bug #448223 from Gilles Dartiguelongue
diff --git a/e-util/e-print.c b/e-util/e-print.c
index 0a3cf7ee43..f5fe1804fb 100644
--- a/e-util/e-print.c
+++ b/e-util/e-print.c
@@ -43,7 +43,7 @@ unpack_settings (gchar *item, GtkPrintSettings *settings)
gchar *cp, *key, *value;
cp = strchr (item, '=');
if (cp == NULL)
- return;
+ return;
*cp ++ = '\0';
key = g_strstrip (item);
value = g_strstrip (cp);
@@ -78,15 +78,12 @@ load_settings (void)
}
static void
-save_settings (GtkPrintOperation *operation)
+save_settings (GtkPrintSettings *settings)
{
- GtkPrintSettings *settings;
GConfClient *client;
GSList *list = NULL;
GError *error = NULL;
- settings = gtk_print_operation_get_print_settings (operation);
-
client = gconf_client_get_default ();
gtk_print_settings_foreach (
@@ -103,6 +100,30 @@ save_settings (GtkPrintOperation *operation)
g_object_unref (client);
}
+static GtkPageSetup *
+load_page_setup (GtkPrintSettings *settings)
+{
+ GtkPageSetup *page_setup;
+ GtkPaperSize *paper_size;
+
+ page_setup = gtk_page_setup_new ();
+ gtk_page_setup_set_orientation (
+ page_setup, gtk_print_settings_get_orientation (settings));
+ paper_size = gtk_print_settings_get_paper_size (settings);
+ if (paper_size != NULL)
+ gtk_page_setup_set_paper_size_and_default_margins (
+ page_setup, paper_size);
+}
+
+static void
+save_page_setup (GtkPrintSettings *settings, GtkPageSetup *page_setup)
+{
+ gtk_print_settings_set_orientation (
+ settings, gtk_page_setup_get_orientation (page_setup));
+ gtk_print_settings_set_paper_size (
+ settings, gtk_page_setup_get_paper_size (page_setup));
+}
+
static void
handle_error (GtkPrintOperation *operation)
{
@@ -139,8 +160,12 @@ handle_error (GtkPrintOperation *operation)
static void
print_done_cb (GtkPrintOperation *operation, GtkPrintOperationResult result)
{
+ GtkPrintSettings *settings;
+
+ settings = gtk_print_operation_get_print_settings (operation);
+
if (result == GTK_PRINT_OPERATION_RESULT_APPLY)
- save_settings (operation);
+ save_settings (settings);
if (result == GTK_PRINT_OPERATION_RESULT_ERROR)
handle_error (operation);
}
@@ -161,3 +186,22 @@ e_print_operation_new (void)
return operation;
}
+
+void
+e_print_run_page_setup_dialog (GtkWindow *parent)
+{
+ GtkPageSetup *new_page_setup;
+ GtkPageSetup *old_page_setup;
+ GtkPrintSettings *settings;
+
+ settings = load_settings ();
+ old_page_setup = load_page_setup (settings);
+ new_page_setup = gtk_print_run_page_setup_dialog (
+ parent, old_page_setup, settings);
+ save_page_setup (settings, new_page_setup);
+ save_settings (settings);
+
+ g_object_unref (new_page_setup);
+ g_object_unref (old_page_setup);
+ g_object_unref (settings);
+}
diff --git a/e-util/e-print.h b/e-util/e-print.h
index 8044506c0c..a8c4f7862f 100644
--- a/e-util/e-print.h
+++ b/e-util/e-print.h
@@ -27,6 +27,7 @@
G_BEGIN_DECLS
GtkPrintOperation * e_print_operation_new (void);
+void e_print_run_page_setup_dialog (GtkWindow *parent);
G_END_DECLS
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 37ecdd21f0..7055fc695c 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-06 Matthew Barnes <mbarnes@redhat.com>
+
+ * em-format-html-print.c:
+ Use new gtk_html_print_operation_run() function in GtkHTML.
+
2007-07-04 Srinivasa Ragavan <sragavan@novell.com>
** Added the hook for plugging into Send/Receive dialog for the
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index ebda5aaf2a..a674b59368 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -112,84 +112,88 @@ em_format_html_print_new (EMFormatHTML *source, GtkPrintOperationAction action)
return efhp;
}
-struct footer_info {
- PangoLayout *layout;
- gint page_num, pages;
-};
-
-static void
-efhp_footer_cb (GtkHTML *html, GtkPrintContext *context, gdouble x, gdouble y,
- gdouble width, gdouble height, gpointer data)
+static gint
+efhp_calc_footer_height (GtkHTML *html,
+ GtkPrintOperation *operation,
+ GtkPrintContext *context)
{
- struct footer_info *info = data;
- gchar *footer_text;
- cairo_t *cr;
-
- footer_text = g_strdup_printf (_("Page %d of %d"),
- info->page_num++, info->pages);
+ PangoContext *pango_context;
+ PangoFontDescription *desc;
+ PangoFontMetrics *metrics;
+ gint footer_height;
- pango_layout_set_text (info->layout, footer_text, -1);
- pango_layout_set_width (info->layout, pango_units_from_double (width));
+ pango_context = gtk_print_context_create_pango_context (context);
+ desc = pango_font_description_from_string ("Sans Regular 10");
- cr = gtk_print_context_get_cairo_context (context);
+ metrics = pango_context_get_metrics (
+ pango_context, desc, pango_language_get_default ());
+ footer_height =
+ pango_font_metrics_get_ascent (metrics) +
+ pango_font_metrics_get_descent (metrics);
+ pango_font_metrics_unref (metrics);
- cairo_save (cr);
- cairo_set_source_rgb (cr, .0, .0, .0);
- cairo_move_to (cr, x, y);
- pango_cairo_show_layout (cr, info->layout);
- cairo_restore (cr);
+ pango_font_description_free (desc);
+ g_object_unref (pango_context);
- g_free (footer_text);
+ return footer_height;
}
-static void
-mail_draw_page (GtkPrintOperation *print, GtkPrintContext *context,
- gint page_nr, EMFormatHTMLPrint *efhp)
+static void
+efhp_draw_footer (GtkHTML *html,
+ GtkPrintOperation *operation,
+ GtkPrintContext *context,
+ gint page_nr,
+ PangoRectangle *rec)
{
- GtkHTML *html = efhp->parent.html;
PangoFontDescription *desc;
- PangoFontMetrics *metrics;
- struct footer_info info;
- gdouble footer_height;
+ PangoLayout *layout;
+ gdouble x, y;
+ gint n_pages;
+ gchar *text;
+ cairo_t *cr;
+
+ g_object_get (operation, "n-pages", &n_pages, NULL);
+ text = g_strdup_printf (_("Page %d of %d"), page_nr + 1, n_pages);
desc = pango_font_description_from_string ("Sans Regular 10");
+ layout = gtk_print_context_create_pango_layout (context);
+ pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+ pango_layout_set_font_description (layout, desc);
+ pango_layout_set_text (layout, text, -1);
+ pango_layout_set_width (layout, rec->width);
- info.layout = gtk_print_context_create_pango_layout (context);
- pango_layout_set_alignment (info.layout, PANGO_ALIGN_CENTER);
- pango_layout_set_font_description (info.layout, desc);
+ x = pango_units_to_double (rec->x);
+ y = pango_units_to_double (rec->y);
- metrics = pango_context_get_metrics (
- pango_layout_get_context (info.layout),
- desc, pango_language_get_default ());
- footer_height = pango_units_to_double (
- pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
- pango_font_metrics_unref (metrics);
+ cr = gtk_print_context_get_cairo_context (context);
- pango_font_description_free (desc);
+ cairo_save (cr);
+ cairo_set_source_rgb (cr, .0, .0, .0);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
- info.page_num = 1;
- info.pages = gtk_html_print_page_get_pages_num (
- html, context, 0.0, footer_height);
+ g_object_unref (layout);
+ pango_font_description_free (desc);
- gtk_html_print_page_with_header_footer (
- html, context, 0.0, footer_height,
- NULL, efhp_footer_cb, &info);
+ g_free (text);
}
static void
emfhp_complete (EMFormatHTMLPrint *efhp)
{
GtkPrintOperation *operation;
+ GError *error = NULL;
operation = e_print_operation_new ();
- gtk_print_operation_set_n_pages (operation, 1);
-
- g_signal_connect (
- operation, "draw-page",
- G_CALLBACK (mail_draw_page), efhp);
- gtk_print_operation_run (operation, efhp->action, NULL, NULL);
+ gtk_html_print_operation_run (
+ efhp->parent.html, operation, efhp->action, NULL,
+ (GtkHTMLPrintCalcHeight) NULL,
+ (GtkHTMLPrintCalcHeight) efhp_calc_footer_height,
+ (GtkHTMLPrintDrawFunc) NULL,
+ (GtkHTMLPrintDrawFunc) efhp_draw_footer,
+ NULL, &error);
g_object_unref (operation);
}
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 63356b1497..aa968b4a01 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-06 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #446894
+
+ * e-shell-window-commands.c (command_page_setup):
+ Callback for new FilePageSetup verb.
+
2007-07-03 Srinivasa Ragavan <sragavan@novell.com>
** Added a hook event after the shell is started.
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
index 010e229775..03ee4cdae5 100644
--- a/shell/e-shell-window-commands.c
+++ b/shell/e-shell-window-commands.c
@@ -44,6 +44,7 @@
#include "e-util/e-icon-factory.h"
#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
+#include "e-util/e-print.h"
#include "e-util/e-util-private.h"
#include "e-shell-window-commands.h"
@@ -96,6 +97,14 @@ command_import (BonoboUIComponent *uih,
}
static void
+command_page_setup (BonoboUIComponent *uih,
+ EShellWindow *window,
+ const char *path)
+{
+ e_print_run_page_setup_dialog (GTK_WINDOW (window));
+}
+
+static void
command_close (BonoboUIComponent *uih,
EShellWindow *window,
const char *path)
@@ -717,6 +726,7 @@ command_pilot_settings (BonoboUIComponent *uih,
static BonoboUIVerb file_verbs [] = {
BONOBO_UI_VERB ("FileImporter", (BonoboUIVerbFn) command_import),
+ BONOBO_UI_VERB ("FilePageSetup", (BonoboUIVerbFn) command_page_setup),
BONOBO_UI_VERB ("FileClose", (BonoboUIVerbFn) command_close),
BONOBO_UI_VERB ("FileExit", (BonoboUIVerbFn) command_quit),
diff --git a/ui/ChangeLog b/ui/ChangeLog
index cdaadd7420..e001abd2cf 100644
--- a/ui/ChangeLog
+++ b/ui/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-06 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #446894
+
+ * evolution.xml:
+ Add a FilePageSetup command, and a corresponding menu item within
+ the Print place holder. Net result is to add a "File -> Page Setup"
+ menu item to all components, just above the print menu items.
+
2007-05-15 Srinivasa Ragavan <sragavan@novell.com>
* evolution-mail-global.xml: Menu for sync for offline
diff --git a/ui/evolution.xml b/ui/evolution.xml
index b6e46987b6..f50d74c2ac 100644
--- a/ui/evolution.xml
+++ b/ui/evolution.xml
@@ -4,6 +4,8 @@
_tip="Create a new window displaying this folder"
accel="*Control**Shift*w"/>
+ <cmd name="FilePageSetup" _label="Page Set_up..." _tip="Set up the page settings for your current printer"/>
+
<cmd name="FileClose" _label="_Close Window" _tip="Close this window"
pixtype="stock" pixname="gtk-close" accel="*Control*w"/>
@@ -76,7 +78,9 @@
_tip="Import data from other programs"
pixtype="pixbuf"/>
- <placeholder name="Print" delimit="top"/>
+ <placeholder name="Print" delimit="top">
+ <menuitem name="FilePageSetup" verb=""/>
+ </placeholder>
<!--
<placeholder name="ComponentPlaceholder"/>