diff options
author | Akhil Laddha <lakhil@src.gnome.org> | 2008-05-19 12:19:22 +0800 |
---|---|---|
committer | Akhil Laddha <lakhil@src.gnome.org> | 2008-05-19 12:19:22 +0800 |
commit | 7ea3da7607895f327690fdd03ec4608677ec62b4 (patch) | |
tree | 2a19dd6cc18f3293cee0093c12cbaeadda3e91f5 /plugins/email-custom-header | |
parent | bb8a109032df2f41f7dc677501f95ca4d7b9a0af (diff) | |
download | gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar.gz gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar.bz2 gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar.lz gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar.xz gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.tar.zst gsoc2013-evolution-7ea3da7607895f327690fdd03ec4608677ec62b4.zip |
Committing on behalf of Ashish Shrivastava <shashish@novell.com>
Commit for Custom header support
svn path=/trunk/; revision=35510
Diffstat (limited to 'plugins/email-custom-header')
7 files changed, 893 insertions, 0 deletions
diff --git a/plugins/email-custom-header/ChangeLog b/plugins/email-custom-header/ChangeLog new file mode 100644 index 0000000000..b9ec758404 --- /dev/null +++ b/plugins/email-custom-header/ChangeLog @@ -0,0 +1,10 @@ +2008-05-19 Ashish Shrivastava <shashish@novell.com> + + * org-gnome-email-custom-header.eplug.xml: + * org-gnome-email-custom-header.glade: + * apps_evolution_email_custom_header.schemas.in: + * Makefile.am: + * email-custom-header.c: + * email-custom-header.h: + ** Initial set of files. Implements Custom header support. + ** Added custom header plugin. diff --git a/plugins/email-custom-header/Makefile.am b/plugins/email-custom-header/Makefile.am new file mode 100644 index 0000000000..856052d6e3 --- /dev/null +++ b/plugins/email-custom-header/Makefile.am @@ -0,0 +1,56 @@ +INCLUDES = -I. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/widgets \ + -I$(top_srcdir)/widgets/misc \ + -I$(top_builddir)/mail \ + -I$(top_srcdir)/camel \ + -I$(top_builddir)/composer \ + $(EVOLUTION_MAIL_CFLAGS) \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DCONNECTOR_GLADEDIR=\""$(gladedir)"\" + + +@EVO_PLUGIN_RULE@ + +plugin_DATA = \ + org-gnome-email-custom-header.eplug + +plugin_LTLIBRARIES = liborg-gnome-email-custom-header.la + +liborg_gnome_email_custom_header_la_SOURCES = \ + email-custom-header.c \ + email-custom-header.h +liborg_gnome_email_custom_header_la_LIBADD = \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/mail/libevolution-mail.la \ + $(NO_UNDEFINED_REQUIRED_LIBS) + +liborg_gnome_email_custom_header_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) + +schemadir = $(GCONF_SCHEMA_FILE_DIR) +schema_in_files = apps_evolution_email_custom_header.schemas.in +schema_DATA = $(schema_in_files:.schemas.in=.schemas) + +@INTLTOOL_SCHEMAS_RULE@ + +install-data-local: + if test -z "$(DESTDIR)" ; then \ + for p in $(schema_DATA) ; do \ + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p; \ + done \ + fi + +glade_DATA = \ + org-gnome-email-custom-header.glade + +EXTRA_DIST = \ + org-gnome-email-custom-header.eplug.xml \ + $(schema_in_files) + +BUILT_SOURCES = \ + org-gnome-email-custom-header.eplug \ + $(error_i18n) + +CLEANFILES = $(BUILT_SOURCES) +DISTCLEANFILES = $(schema_DATA) diff --git a/plugins/email-custom-header/apps_evolution_email_custom_header.schemas.in b/plugins/email-custom-header/apps_evolution_email_custom_header.schemas.in new file mode 100644 index 0000000000..79c8a9d8ec --- /dev/null +++ b/plugins/email-custom-header/apps_evolution_email_custom_header.schemas.in @@ -0,0 +1,17 @@ +<gconfschemafile> + <schemalist> + <schema> + <key>/schemas/apps/evolution/eplugin/email_custom_header/customHeader</key> + <applyto>/apps/evolution/eplugin/email_custom_header/customHeader</applyto> + <owner>evolution-eplugin</owner> + <type>list</type> + <list_type>string</list_type> + <default>[Security=Personal;Unclassified;Protected;InConfidence;Secret;Topsecret]</default> + <locale name="C"> + <short>List of Custom Header</short> + <long>The key specifies the list of custom headers that you can add to an outgoing message. The format for specifying a Header and Header value is: Name of the custom header followed by "=" and the values separated by ";"</long> + </locale> + </schema> + </schemalist> +</gconfschemafile> + diff --git a/plugins/email-custom-header/email-custom-header.c b/plugins/email-custom-header/email-custom-header.c new file mode 100644 index 0000000000..6c7d7c8e6e --- /dev/null +++ b/plugins/email-custom-header/email-custom-header.c @@ -0,0 +1,563 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Authors: Ashish Shrivastava <shashish@novell.com> + * + * Copyright (C) 2008 Novell, Inc. + * + * 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., 51 Franklin Street, Fifth Floor, MA 02110-1301. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> +#include <glib.h> +#include <gtk/gtksignal.h> +#include <gtk/gtkcombobox.h> +#include <gtk/gtktable.h> +#include <glib/gi18n.h> +#include <gconf/gconf-client.h> +#include <e-util/e-error.h> +#include <libgnome/libgnome.h> +#include <glade/glade.h> +#include "mail/em-menu.h" +#include "mail/em-utils.h" +#include "mail/em-event.h" +#include "composer/e-msg-composer.h" +#include "libedataserver/e-account.h" +#include "email-custom-header.h" + + +#define d(x) x + +struct _EmailCustomHeaderOptionsDialogPrivate { + /* Glade XML data */ + GladeXML *xml; + /*Widgets*/ + GtkWidget *main; + GtkWidget *page; + GtkNotebook *notebook; + GtkWidget *header_table; + GtkWidget *header_type_name_label; + GArray *combo_box_header_value; + GArray *email_custom_header_details; + GArray *header_index_type; + gint flag; + char *help_section; +}; + +/* epech - e-plugin email custom header*/ +static void epech_dialog_class_init (GObjectClass *object_class); +static void epech_dialog_finalize (GObject *object); +static void epech_dialog_init (GObject *object); +static void epech_dialog_dispose (GObject *object); +static void epech_setup_widgets (CustomHeaderOptionsDialog *mch); +static gint epech_check_existing_composer_window(gconstpointer a, gconstpointer b); + +gboolean e_plugin_ui_init(GtkUIManager *manager, EMsgComposer *composer); + +static void +epech_get_widgets_data (CustomHeaderOptionsDialog *mch) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + HeaderValueComboBox *sub_combo_box_get; + gint selected_item; + gint index_row,index_column; + + priv = mch->priv; + priv->header_index_type = g_array_new (FALSE, FALSE, sizeof (gint)); + priv->flag++; + + for (index_row = 0,index_column = 0; + index_column < priv->email_custom_header_details->len; index_column++) { + + sub_combo_box_get = &g_array_index(priv->combo_box_header_value, HeaderValueComboBox,index_column); + selected_item = gtk_combo_box_get_active((GtkComboBox *)sub_combo_box_get->header_value_combo_box); + g_array_append_val (priv->header_index_type, selected_item); + } + + return; +} + +static gboolean +epech_get_widgets (CustomHeaderOptionsDialog *mch) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + priv = mch->priv; + +#define EMAIL_CUSTOM_HEADER(name) glade_xml_get_widget (priv->xml, name) + priv->main = EMAIL_CUSTOM_HEADER ("email-custom-header-dialog"); + + if (!priv->main) + return FALSE; + + priv->page = EMAIL_CUSTOM_HEADER ("email-custom-header-vbox"); + priv->notebook = (GtkNotebook *) EMAIL_CUSTOM_HEADER ("email-custom-header-notebook"); + priv->header_table = EMAIL_CUSTOM_HEADER ("email-custom-header-options"); +#undef EMAIL_CUSTOM_HEADER + + return (priv->page + &&priv->notebook + &&priv->header_table); +} + +static void +epech_fill_widgets_with_data (CustomHeaderOptionsDialog *mch) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + HeaderValueComboBox *sub_combo_box_fill; + gint set_index_row,set_index_column; + + priv = mch->priv; + priv->help_section = g_strdup ("usage-mail"); + + for (set_index_row = 0,set_index_column = 0; + set_index_column < priv->email_custom_header_details->len;set_index_column++) { + sub_combo_box_fill = &g_array_index(priv->combo_box_header_value, HeaderValueComboBox,set_index_column); + + if (priv->flag == 0) { + gtk_combo_box_set_active ((GtkComboBox *)sub_combo_box_fill->header_value_combo_box,0); + } else { + gtk_combo_box_set_active ((GtkComboBox *)sub_combo_box_fill->header_value_combo_box, + g_array_index(priv->header_index_type, gint, set_index_column)); + } + } +} + +CustomHeaderOptionsDialog * +epech_dialog_new (void) +{ + CustomHeaderOptionsDialog *mch; + + mch = g_object_new (EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG, NULL); + + return mch; +} + +GType +epech_dialog_get_type (void) +{ + static GType type = 0; + + if (type == 0) { + static const GTypeInfo info = { + sizeof (CustomHeaderOptionsDialogClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) epech_dialog_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CustomHeaderOptionsDialog), + 0, /* n_preallocs */ + (GInstanceInitFunc) epech_dialog_init, + NULL /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "CustomHeaderOptionsDialogType", + &info, 0); + } + + return type; +} + +static void +epech_header_options_cb (GtkDialog *dialog, gint state, gpointer func_data) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + CustomHeaderOptionsDialog *mch; + GError *error = NULL; + + mch = func_data; + priv = mch->priv; + + switch (state) { + case GTK_RESPONSE_OK: + epech_get_widgets_data (mch); + case GTK_RESPONSE_CANCEL: + gtk_widget_hide (priv->main); + gtk_widget_destroy (priv->main); + g_object_unref (priv->xml); + break; + case GTK_RESPONSE_HELP: + gnome_help_display ( + "evolution.xml", priv->help_section, &error); + if (error) { + g_warning ("%s", error->message); + g_error_free (error); + } + break; + } + + g_signal_emit (G_OBJECT (func_data), signals[MCH_RESPONSE], 0, state); +} + +static gboolean +epech_dialog_run (CustomHeaderOptionsDialog *mch, GtkWidget *parent) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + GtkWidget *toplevel; + gchar *filename; + + g_return_val_if_fail (mch != NULL || EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG (mch), FALSE); + priv = mch->priv; + epech_get_header_list (mch); + + filename = g_build_filename (EVOLUTION_GLADEDIR, + "org-gnome-email-custom-header.glade", + NULL); + priv->xml = glade_xml_new (filename, NULL, NULL); + g_free (filename); + + if (!priv->xml) { + d (printf ("\n Could not load the Glade XML file\n")); + } + + if (!epech_get_widgets(mch)) { + g_object_unref (priv->xml); + d (printf ("\n Could not get the Widgets\n")); + } + + epech_setup_widgets (mch); + toplevel = gtk_widget_get_toplevel (priv->main); + + if (parent) + gtk_window_set_transient_for (GTK_WINDOW (toplevel),GTK_WINDOW (parent)); + + epech_fill_widgets_with_data (mch); + g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(epech_header_options_cb), mch); + gtk_window_set_modal ((GtkWindow *) priv->main, TRUE); + gtk_widget_show (priv->main); + + return TRUE; +} + +static void +epech_get_header_list (CustomHeaderOptionsDialog *mch) +{ + GConfClient *client; + + client = gconf_client_get_default (); + g_return_if_fail (GCONF_IS_CLIENT (client)); + gconf_client_add_dir (client, "/apps/evolution/eplugin/email_custom_header" , GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + epech_load_from_gconf (client, "/apps/evolution/eplugin/email_custom_header/customHeader", mch); + + return; +} + +static void +epech_load_from_gconf (GConfClient *client,const char *path,CustomHeaderOptionsDialog *mch) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + EmailCustomHeaderDetails temp_header_details= {-1, -1, NULL, NULL}; + CustomSubHeader temp_header_value_details = {NULL}; + GSList *header_list,*q; + gchar *buffer; + char *str_colon; + gint index,pos; + + priv = mch->priv; + priv->email_custom_header_details = g_array_new (TRUE, TRUE, sizeof (EmailCustomHeaderDetails)); + header_list = gconf_client_get_list (client,path,GCONF_VALUE_STRING, NULL); + + for (q = header_list,pos = 0; q != NULL; q = q->next,pos++) { + memset(&temp_header_value_details,0,sizeof(CustomSubHeader)); + temp_header_details.sub_header_type_value = g_array_new (TRUE, TRUE, sizeof (CustomSubHeader)); + buffer = q->data; + gchar **parse_header_list = g_strsplit_set (buffer, "=;,", -1); + str_colon = g_strconcat (parse_header_list[0], ":", NULL); + temp_header_details.header_type_value = g_string_new(""); + if (temp_header_details.header_type_value) { + g_string_assign(temp_header_details.header_type_value, str_colon); + } + + g_free (str_colon); + for (index = 0; parse_header_list[index+1] ; ++index) { + temp_header_value_details.sub_header_string_value = g_string_new(""); + + if (temp_header_value_details.sub_header_string_value) { + g_string_assign(temp_header_value_details.sub_header_string_value, parse_header_list[index+1]); + } + + g_array_append_val(temp_header_details.sub_header_type_value, temp_header_value_details); + } + + temp_header_details.number_of_subtype_header = index; + g_array_append_val(priv->email_custom_header_details, temp_header_details); + } + + temp_header_details.number_of_header = pos; +} + +static void +epech_setup_widgets (CustomHeaderOptionsDialog *mch) +{ + EmailCustomHeaderOptionsDialogPrivate *priv; + EmailCustomHeaderDetails *temp_header_ptr,*temp; + CustomSubHeader *temp_header_value_ptr; + HeaderValueComboBox sub_combo_box = {NULL}; + HeaderValueComboBox *sub_combo_box_ptr; + gint sub_index,row_combo,column_combo; + gint header_section_id,sub_type_index,row,column,label_row; + + priv = mch->priv; + priv->combo_box_header_value = g_array_new (TRUE, FALSE, sizeof (HeaderValueComboBox)); + + for (header_section_id = 0,label_row = 0,row = 0,column = 1; + header_section_id < priv->email_custom_header_details->len; header_section_id++,row++,column++) { + + // To create an empty label widget. Text will be added dynamically. + priv->header_type_name_label = gtk_label_new (""); + temp_header_ptr = &g_array_index(priv->email_custom_header_details, EmailCustomHeaderDetails,header_section_id); + gtk_label_set_markup (GTK_LABEL (priv->header_type_name_label),(temp_header_ptr->header_type_value)->str); + + gtk_table_attach (GTK_TABLE (priv->header_table), priv->header_type_name_label, 0, 1, row, column, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + + gtk_misc_set_alignment (GTK_MISC (priv->header_type_name_label), 0, 0.5); + gtk_widget_show (priv->header_type_name_label); + sub_combo_box.header_value_combo_box = gtk_combo_box_new_text (); + g_array_append_val(priv->combo_box_header_value, sub_combo_box); + } + + for (sub_index = 0,row_combo = 0,column_combo = 1; sub_index < priv->combo_box_header_value->len; + sub_index++,row_combo++,column_combo++) { + temp = &g_array_index(priv->email_custom_header_details, EmailCustomHeaderDetails,sub_index); + + sub_combo_box_ptr = &g_array_index(priv->combo_box_header_value, HeaderValueComboBox,sub_index); + gtk_table_attach (GTK_TABLE (priv->header_table), + sub_combo_box_ptr->header_value_combo_box, 1, 2, row_combo, column_combo, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (GTK_FILL), 0, 0); + + for (sub_type_index = 0; sub_type_index < temp->number_of_subtype_header; sub_type_index++) { + temp_header_value_ptr = &g_array_index(temp->sub_header_type_value, CustomSubHeader,sub_type_index); + gtk_combo_box_append_text (GTK_COMBO_BOX (sub_combo_box_ptr->header_value_combo_box), + (temp_header_value_ptr->sub_header_string_value)->str); + } + + gtk_combo_box_append_text (GTK_COMBO_BOX (sub_combo_box_ptr->header_value_combo_box),"None"); + gtk_widget_show (sub_combo_box_ptr->header_value_combo_box); + } +} + +static void +epech_dialog_class_init (GObjectClass *object) +{ + CustomHeaderOptionsDialogClass *klass; + GObjectClass *object_class; + + klass = EMAIL_CUSTOM_HEADEROPTIONS_DIALOG_CLASS (object); + parent_class = g_type_class_peek_parent (klass); + object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = epech_dialog_finalize; + object_class->dispose = epech_dialog_dispose; + + signals[MCH_RESPONSE] = g_signal_new ("emch_response", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (CustomHeaderOptionsDialogClass, emch_response), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); +} + +static void +epech_dialog_init (GObject *object) +{ + CustomHeaderOptionsDialog *mch; + EmailCustomHeaderOptionsDialogPrivate *priv; + + mch = EMAIL_CUSTOM_HEADEROPTIONS_DIALOG (object); + priv = g_new0 (EmailCustomHeaderOptionsDialogPrivate, 1); + mch->priv = priv; + priv->xml = NULL; + priv->main = NULL; + priv->notebook = NULL; + priv->header_table = NULL; +} + +static void +epech_dialog_finalize (GObject *object) +{ + CustomHeaderOptionsDialog *mch = (CustomHeaderOptionsDialog *)object; + EmailCustomHeaderOptionsDialogPrivate *priv; + + g_return_if_fail (EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG (mch)); + priv = mch->priv; + g_free (priv->help_section); + + if (mch->priv) { + g_free (mch->priv); + mch->priv = NULL; + } + + if (parent_class->finalize) + (* parent_class->finalize) (object); +} + +static void +epech_dialog_dispose (GObject *object) +{ + CustomHeaderOptionsDialog *mch = (CustomHeaderOptionsDialog *) object; + + g_return_if_fail (EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG (mch)); + + if (parent_class->dispose) + (* parent_class->dispose) (object); +} + +static void +epech_append_to_custom_header (CustomHeaderOptionsDialog *dialog, gint state, gpointer data) +{ + EMsgComposer *composer; + EmailCustomHeaderOptionsDialogPrivate *priv; + EmailCustomHeaderDetails *temp_header_ptr; + CustomSubHeader *temp_header_value_ptr; + gint index, index_subtype,sub_type_index; + + composer = (EMsgComposer *)data; + priv = dialog->priv; + + if (state == GTK_RESPONSE_OK) { + + for (index = 0,index_subtype = 0; index_subtype < priv->email_custom_header_details->len; index_subtype++) { + + temp_header_ptr = &g_array_index(priv->email_custom_header_details, EmailCustomHeaderDetails,index_subtype); + + for (sub_type_index = 0; sub_type_index < temp_header_ptr->number_of_subtype_header; sub_type_index++) { + temp_header_value_ptr = &g_array_index(temp_header_ptr->sub_header_type_value, CustomSubHeader,sub_type_index); + + if (sub_type_index == g_array_index(priv->header_index_type, gint, index_subtype)){ + e_msg_composer_modify_header (composer, (temp_header_ptr->header_type_value)->str, + (temp_header_value_ptr->sub_header_string_value)->str); + } + } + } + } +} + +static void +epech_custom_header_options_commit (EMsgComposer *comp, gpointer user_data) +{ + EMsgComposer *composer; + EmailCustomHeaderWindow *new_email_custom_header_window = NULL; + CustomHeaderOptionsDialog *current_dialog = NULL; + + composer = (EMsgComposer *) user_data; + + if (!user_data || !EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG (user_data)) + return; + + new_email_custom_header_window = g_object_get_data ((GObject *) composer, "compowindow"); + + if (new_email_custom_header_window) { + current_dialog = new_email_custom_header_window->epech_dialog; + } + + if (current_dialog) { + g_free (current_dialog); + current_dialog = NULL; + } + + if (new_email_custom_header_window) { + g_free (new_email_custom_header_window); + new_email_custom_header_window = NULL; + } +} + +static gint +epech_check_existing_composer_window(gconstpointer compowindow, gconstpointer other_compowindow) +{ + if ((compowindow) && (other_compowindow)){ + if (((EmailCustomHeaderWindow *)compowindow)->epech_window == (GdkWindow *)other_compowindow) { + return 0; + } + } + + return -1; +} + +static void +destroy_compo_data (gpointer data) +{ + EmailCustomHeaderWindow *compo_data = (EmailCustomHeaderWindow *) data; + + if (!compo_data) + return; + + g_free (compo_data); +} + +static void action_email_custom_header_cb (GtkAction *action, EMsgComposer *composer) + +{ + GtkUIManager *manager; + GtkhtmlEditor *editor; + GtkWidget *menuitem; + CustomHeaderOptionsDialog *dialog = NULL; + EmailCustomHeaderWindow *new_email_custom_header_window = NULL; + + manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer)); + menuitem = gtk_ui_manager_get_widget (manager, "/main-menu/insert-menu/insert-menu-top/Custom Header"); + + new_email_custom_header_window = g_object_get_data ((GObject *) composer, "compowindow"); + + if (epech_check_existing_composer_window(new_email_custom_header_window,menuitem->window) == 0) { + dialog = new_email_custom_header_window->epech_dialog; + } else { + dialog = epech_dialog_new (); + if (dialog) { + EmailCustomHeaderWindow *new_email_custom_header_window; + new_email_custom_header_window = g_new0(EmailCustomHeaderWindow, 1); + new_email_custom_header_window->epech_window = menuitem->window; + new_email_custom_header_window->epech_dialog = dialog; + g_object_set_data_full ((GObject *) composer, "compowindow", new_email_custom_header_window, destroy_compo_data); + } + } + + epech_dialog_run (dialog, GTK_WIDGET (composer)); + g_signal_connect (dialog, "emch_response", G_CALLBACK (epech_append_to_custom_header), GTK_WIDGET (composer)); + g_signal_connect (GTK_WIDGET (composer), "destroy", G_CALLBACK (epech_custom_header_options_commit), composer); +} + +static GtkActionEntry entries[] = { + + { "Custom Header", + NULL, + N_("_Custom Header"), + NULL, + NULL, + G_CALLBACK (action_email_custom_header_cb) } +}; + +gboolean +e_plugin_ui_init (GtkUIManager *manager, + EMsgComposer *composer) +{ + GtkhtmlEditor *editor; + + editor = GTKHTML_EDITOR (composer); + + /* Add actions to the "composer" action group. */ + gtk_action_group_add_actions ( + gtkhtml_editor_get_action_group (editor, "composer"), + entries, G_N_ELEMENTS (entries), composer); + + return TRUE; +} + diff --git a/plugins/email-custom-header/email-custom-header.h b/plugins/email-custom-header/email-custom-header.h new file mode 100644 index 0000000000..c91f482458 --- /dev/null +++ b/plugins/email-custom-header/email-custom-header.h @@ -0,0 +1,82 @@ + /* Evolution Email custom header options + * Copyright (C) 2008 Novell, Inc. + * + * Authors: Ashish <shashish@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., 51 Franklin Street, Fifth Floor, MA 02110-1301. + */ + +#ifndef __EMAIL_CUSTOM_HEADEROPTIONS_DIALOG_H__ +#define __EMAIL_CUSTOM_HEADEROPTIONS_DIALOG_H__ + +#include <gtk/gtkwidget.h> + +#define EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG (epech_dialog_get_type ()) +#define EMAIL_CUSTOM_HEADEROPTIONS_DIALOG(obj) (GTK_CHECK_CAST ((obj), EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG, CustomHeaderOptionsDialog)) +#define EMAIL_CUSTOM_HEADEROPTIONS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG, CustomHeaderOptionsDialogClass)) +#define EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG(obj) (GTK_CHECK_TYPE ((obj), EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG)) +#define EMAIL_CUSTOM_HEADER_OPTIONS_IS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EMAIL_CUSTOM_HEADER_OPTIONS_DIALOG)) + +typedef struct _CustomHeaderOptionsDialog CustomHeaderOptionsDialog; +typedef struct _CustomHeaderOptionsDialogClass CustomHeaderOptionsDialogClass; +typedef struct _EmailCustomHeaderOptionsDialogPrivate EmailCustomHeaderOptionsDialogPrivate; + +struct _CustomHeaderOptionsDialog { + GObject object; + /* Private data */ + EmailCustomHeaderOptionsDialogPrivate *priv; +}; + +typedef struct { + gint number_of_header; + gint number_of_subtype_header; + GString *header_type_value; + GArray *sub_header_type_value; +} EmailCustomHeaderDetails; + +typedef struct { + GString *sub_header_string_value; +} CustomSubHeader; + +typedef struct { + GtkWidget *header_value_combo_box; +} HeaderValueComboBox; + + +struct _CustomHeaderOptionsDialogClass { + GObjectClass parent_class; + void (* emch_response) (CustomHeaderOptionsDialog *esd, gint status); +}; + +typedef struct _EmailCustomHeaderWindow +{ + GdkWindow *epech_window; + CustomHeaderOptionsDialog *epech_dialog; +}EmailCustomHeaderWindow; + +enum { + MCH_RESPONSE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; +static GObjectClass *parent_class = NULL; + +GType epech_dialog_get_type (void); +CustomHeaderOptionsDialog *epech_dialog_new (void); +static gboolean epech_dialog_run (CustomHeaderOptionsDialog *mch, GtkWidget *parent); +static void epech_get_header_list (CustomHeaderOptionsDialog *mch); +static void epech_load_from_gconf (GConfClient *client,const char *path,CustomHeaderOptionsDialog *mch); +#endif + diff --git a/plugins/email-custom-header/org-gnome-email-custom-header.eplug.xml b/plugins/email-custom-header/org-gnome-email-custom-header.eplug.xml new file mode 100644 index 0000000000..055acc1030 --- /dev/null +++ b/plugins/email-custom-header/org-gnome-email-custom-header.eplug.xml @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<e-plugin-list> + <e-plugin id="org.gnome.evolution.email-custom-header" type="shlib" _name="Custom Header" + location="@PLUGINDIR@/liborg-gnome-email-custom-header@SOEXT@"> + + <author name="Ashish Shrivastava" email="shashish@novell.com"/> + <!-- For Translators: 'custom header' string is used while adding a new message header to outgoing message, to specify what value for the message header would be added --> + <_description>Adds custom header to outgoing messages.</_description> + + <hook class="org.gnome.evolution.ui:1.0"> + <ui-manager id="org.gnome.evolution.composer"> + <menubar name='main-menu'> + <menu action='insert-menu'> + <placeholder name="insert-menu-top"> + <menuitem action="Custom Header"/> + </placeholder> + </menu> + </menubar> + </ui-manager> + </hook> + </e-plugin> +</e-plugin-list> diff --git a/plugins/email-custom-header/org-gnome-email-custom-header.glade b/plugins/email-custom-header/org-gnome-email-custom-header.glade new file mode 100644 index 0000000000..bd4910a480 --- /dev/null +++ b/plugins/email-custom-header/org-gnome-email-custom-header.glade @@ -0,0 +1,143 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkDialog" id="email-custom-header-dialog"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="title" translatable="yes">Email Custom Header</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_MOUSE</property> + <property name="modal">True</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="email-custom-header-vbox"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="helpbutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-11</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="cancelbutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="okbutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkNotebook" id="email-custom-header-notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_tabs">True</property> + <property name="show_border">True</property> + <property name="tab_pos">GTK_POS_TOP</property> + <property name="scrollable">False</property> + <property name="enable_popup">False</property> + + <child> + <widget class="GtkTable" id="email-custom-header-options"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">4</property> + <property name="homogeneous">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">12</property> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="gopts-label"> + <property name="visible">True</property> + <property name="label" translatable="yes">Custom Header Options</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> |