diff options
-rw-r--r-- | plugins/print-message/ChangeLog | 9 | ||||
-rw-r--r-- | plugins/print-message/Makefile.am | 16 | ||||
-rw-r--r-- | plugins/print-message/org-gnome-print-message.eplug.xml | 31 | ||||
-rw-r--r-- | plugins/print-message/org-gnome-print-message.xml | 17 | ||||
-rw-r--r-- | plugins/print-message/print-message.c | 106 |
5 files changed, 179 insertions, 0 deletions
diff --git a/plugins/print-message/ChangeLog b/plugins/print-message/ChangeLog new file mode 100644 index 0000000000..c393c49b2b --- /dev/null +++ b/plugins/print-message/ChangeLog @@ -0,0 +1,9 @@ +2005-05-19 Vivek Jain <jvivek@novell.com> + + Plugin to provide "print" option to composer. Files added: + + * print-message.c + * Makefile.am + * org-gnome-print-message.eplug.xml + * org-gnome-print-message.xml + diff --git a/plugins/print-message/Makefile.am b/plugins/print-message/Makefile.am new file mode 100644 index 0000000000..f039acd514 --- /dev/null +++ b/plugins/print-message/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = \ + -I$(top_srcdir) \ + $(EVOLUTION_MAIL_CFLAGS) + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-print-message.eplug org-gnome-print-message.xml +plugin_LTLIBRARIES = liborg-gnome-print-message.la + +liborg_gnome_print_message_la_SOURCES = print-message.c +liborg_gnome_print_message_la_LDFLAGS = -module -avoid-version + +EXTRA_DIST = \ + org-gnome-compose-print-message.eplug.xml\ + org-gnome-compose-print-message.xml +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/print-message/org-gnome-print-message.eplug.xml b/plugins/print-message/org-gnome-print-message.eplug.xml new file mode 100644 index 0000000000..8a21072b52 --- /dev/null +++ b/plugins/print-message/org-gnome-print-message.eplug.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<e-plugin-list> + <e-plugin + type="shlib" + id="org.gnome.evolution.plugin.compose.PrintMessage" + location="@PLUGINDIR@/liborg-gnome-print-message.so" + _name="Print Message"> + <_description>Gives an option to print mail from composer</_description> + <author name="Vivek Jain" email="jvivek@novell.com"/> + + <!-- hook into the popup menu --> + <hook class="org.gnome.evolution.mail.bonobomenu:1.0"> + <menu id="org.gnome.evolution.mail.composer" target="widget"> + <ui file="@PLUGINDIR@/org-gnome-print-message.xml"/> + <item + type="item" + verb="EPPrintPreview" + path="/commands/EPPrintPreview" + enable="one" + activate="org_gnome_print_preview"/> + <item + type="item" + verb="EPPrintMessage" + path="/commands/EPPrintMessage" + enable="one" + activate="org_gnome_print_message"/> + </menu> + </hook> + + </e-plugin> +</e-plugin-list> diff --git a/plugins/print-message/org-gnome-print-message.xml b/plugins/print-message/org-gnome-print-message.xml new file mode 100644 index 0000000000..49d6f2cfe0 --- /dev/null +++ b/plugins/print-message/org-gnome-print-message.xml @@ -0,0 +1,17 @@ +<Root> + <commands> + <cmd name="EPPrintMessage" _label="_Print..." + _tip="Prints the message" pixtype="stock" pixname="Print"/> + <cmd name="EPPrintPreview" _label="Print Pre_view" + pixtype="stock" pixname="Print-Preview"/> + + </commands> + <menu> + <submenu name="File"> + <placeholder name="Print"> + <menuitem name="EPPrintPreview" verb="" accel="*Control**Shift*p"/> + <menuitem name="EPPrintMessage" verb="" accel="*Control*p"/> + </placeholder> + </submenu> + </menu> +</Root> diff --git a/plugins/print-message/print-message.c b/plugins/print-message/print-message.c new file mode 100644 index 0000000000..aac3217eab --- /dev/null +++ b/plugins/print-message/print-message.c @@ -0,0 +1,106 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Authors: Vivek Jain <jvivek@novell.com> + * + * Copyright 2004 Novell, Inc. (www.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 Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <gtkhtml/gtkhtml.h> +#include "mail/em-format-html-display.h" +#include "mail/em-format-html-print.h" +#include <glib.h> +#include <glib/gi18n.h> +#include <libgnomeprintui/gnome-print-dialog.h> +#include "mail/em-menu.h" +#include "mail/em-utils.h" +#include "e-util/e-print.h" +#include "composer/e-msg-composer.h" + +void org_gnome_compose_print_message (EPlugin *ep, EMMenuTargetWidget *t); + +struct _print_data { + GnomePrintConfig *config; + CamelMimeMessage *msg; + int preview; +}; + +static void +print_response (GtkWidget *w, int resp, struct _print_data *data) +{ + EMFormatHTMLPrint *print; + + switch (resp) { + case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: + data->preview = TRUE; + case GNOME_PRINT_DIALOG_RESPONSE_PRINT: + print = em_format_html_print_new(); + em_format_html_print_raw_message(print, data->config, data->msg, data->preview); + g_object_unref(print); + break; + } + + if (w) + gtk_widget_destroy(w); + + e_print_save_config (data->config); + g_object_unref(data->config); + g_free(data); + +} + +void +org_gnome_print_message (EPlugin *ep, EMMenuTargetWidget *t) +{ + + EMsgComposer *composer = (EMsgComposer *)t->target.widget; + struct _print_data *data; + + data = g_malloc0(sizeof(*data)); + data->config = e_print_load_config (); + data->preview = 0; + + data->msg = e_msg_composer_get_message (composer, 1); + GtkDialog *dialog = (GtkDialog *)e_print_get_dialog_with_config (_("Print Message"), GNOME_PRINT_DIALOG_COPIES, data->config); + gtk_dialog_set_default_response(dialog, GNOME_PRINT_DIALOG_RESPONSE_PRINT); + e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) composer); + g_signal_connect(dialog, "response", G_CALLBACK(print_response), data); + gtk_widget_show((GtkWidget *)dialog); + +} + +void +org_gnome_print_preview (EPlugin *ep, EMMenuTargetWidget *t) +{ + EMsgComposer *composer = (EMsgComposer *)t->target.widget; + struct _print_data *data; + + data = g_malloc0(sizeof(*data)); + data->config = e_print_load_config (); + data->preview = 0; + + data->msg = e_msg_composer_get_message (composer, 1); + + print_response(NULL, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, data); +} + + |