aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorSankar P <psankar@novell.com>2005-10-18 15:12:15 +0800
committerSankarasivasubramanian Pasupathilingam <psankar@src.gnome.org>2005-10-18 15:12:15 +0800
commite751338e4953544b113b19ed0ea8eeebfb0b111d (patch)
treefdfcc479482c69ed07ee40ed1bf336d0abe02946 /mail
parent789a6ed0cde0f8b797540118ef840d2a172cbabb (diff)
downloadgsoc2013-evolution-e751338e4953544b113b19ed0ea8eeebfb0b111d.tar.gz
gsoc2013-evolution-e751338e4953544b113b19ed0ea8eeebfb0b111d.tar.zst
gsoc2013-evolution-e751338e4953544b113b19ed0ea8eeebfb0b111d.zip
- Enhances Signature-Preferences. - Added shortcuts for common operations.
2005-10-18 Sankar P <psankar@novell.com> - Enhances Signature-Preferences. - Added shortcuts for common operations. -- Delete on Del key -- Edit on Dbl.Click - Prevents adding duplicate and NULL signatures * mail-signature-editor.c (menu_file_save_cb) (mail_signature_editor) (sig_name_changed) (menu_file_save_close_cb) (delete_event_cb) (do_exit): Modified the functions for handling the above scenarios. * mail.error.xml: Added error strings for duplicate and NULL signatures. * em-composer-prefs.c (em_composer_prefs_construct) (sig_delete_cb) (sig_add_cb): Modified the functions so as to handle the keyboard accelarators and to grab focus to the list on deletion/insertion of signatures. * em-composer-prefs.c (signature_key_press)(sig_tree_event_cb): Added new functions to handle the keypress events on the signatures list tree. Fixes #269749 svn path=/trunk/; revision=30519
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog22
-rw-r--r--mail/em-composer-prefs.c39
-rw-r--r--mail/mail-signature-editor.c85
-rw-r--r--mail/mail.error.xml12
4 files changed, 117 insertions, 41 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ed4f77c765..f77edd206e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,25 @@
+2005-10-18 Sankar P <psankar@novell.com>
+
+ - Enhances Signature-Preferences.
+ - Added shortcuts for common operations.
+ -- Delete on Del key
+ -- Edit on Dbl.Click
+ - Prevents adding duplicate and NULL signatures
+
+ * mail-signature-editor.c (menu_file_save_cb) (mail_signature_editor)
+ (sig_name_changed) (menu_file_save_close_cb) (delete_event_cb) (do_exit):
+ Modified the functions for handling the above scenarios.
+ * mail.error.xml:
+ Added error strings for duplicate and NULL signatures.
+ * em-composer-prefs.c (em_composer_prefs_construct) (sig_delete_cb) (sig_add_cb):
+ Modified the functions so as to handle the keyboard accelarators
+ and to grab focus to the list on deletion/insertion of signatures.
+ * em-composer-prefs.c (signature_key_press)(sig_tree_event_cb):
+ Added new functions to handle the
+ keypress events on the signatures list tree.
+
+ Fixes #269749
+
2005-09-29 Parthasarathi Susarla <sparthasarathi@novell.com>
** See bug 317284
diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c
index 5675ddc3b4..7e80c38284 100644
--- a/mail/em-composer-prefs.c
+++ b/mail/em-composer-prefs.c
@@ -41,6 +41,8 @@
#include <libedataserver/e-iconv.h>
#include <misc/e-gui-utils.h>
+#include <gdk/gdkkeysyms.h>
+
#include <gtk/gtkentry.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtkliststore.h>
@@ -336,19 +338,21 @@ em_composer_prefs_new_signature (GtkWindow *parent, gboolean html)
mail_signature_editor (sig, parent, TRUE);
}
-static void
+static void
sig_delete_cb (GtkWidget *widget, EMComposerPrefs *prefs)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
ESignature *sig;
-
+
selection = gtk_tree_view_get_selection (prefs->sig_list);
+
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
gtk_tree_model_get (model, &iter, 1, &sig, -1);
mail_config_remove_signature (sig);
}
+ gtk_widget_grab_focus ((GtkWidget *)prefs->sig_list);
}
static void
@@ -365,6 +369,7 @@ sig_add_cb (GtkWidget *widget, EMComposerPrefs *prefs)
parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
em_composer_prefs_new_signature ((GtkWindow *) parent, send_html);
+ gtk_widget_grab_focus ((GtkWidget *)prefs->sig_list);
}
static void
@@ -815,6 +820,29 @@ emcp_free(EConfig *ec, GSList *items, void *data)
g_slist_free(items);
}
+static void
+signature_key_press (GtkTreeView *tree_view, GdkEventKey *event, EMComposerPrefs *prefs)
+{
+ /* No need to care about anything other than DEL key */
+ if (event->keyval == GDK_Delete)
+ sig_delete_cb ((GtkWidget *)tree_view, prefs);
+
+ return ;
+}
+
+static gboolean
+sig_tree_event_cb (GtkTreeView *tree_view, GdkEvent *event, EMComposerPrefs *prefs)
+{
+ gboolean ret = FALSE;
+
+ if (event->type == GDK_2BUTTON_PRESS) {
+ sig_edit_cb ((GtkWidget *)tree_view, prefs);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
static void
em_composer_prefs_construct (EMComposerPrefs *prefs)
{
@@ -949,10 +977,10 @@ em_composer_prefs_construct (EMComposerPrefs *prefs)
g_signal_connect (prefs->sig_add_script, "clicked", G_CALLBACK (sig_add_script_cb), prefs);
prefs->sig_edit = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureEdit"));
- g_signal_connect (prefs->sig_edit, "clicked", G_CALLBACK (sig_edit_cb), prefs);
+ g_signal_connect (prefs->sig_edit, "pressed", G_CALLBACK (sig_edit_cb), prefs);
prefs->sig_delete = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureDelete"));
- g_signal_connect (prefs->sig_delete, "clicked", G_CALLBACK (sig_delete_cb), prefs);
+ g_signal_connect (prefs->sig_delete, "pressed", G_CALLBACK (sig_delete_cb), prefs);
prefs->sig_list = GTK_TREE_VIEW (glade_xml_get_widget (gui, "listSignatures"));
model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
@@ -964,6 +992,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs)
selection = gtk_tree_view_get_selection (prefs->sig_list);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
g_signal_connect (selection, "changed", G_CALLBACK (sig_selection_changed), prefs);
+ g_signal_connect (prefs->sig_list, "event", G_CALLBACK (sig_tree_event_cb), prefs);
sig_fill_list (prefs);
@@ -979,6 +1008,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs)
e_config_set_target((EConfig *)ec, (EConfigTarget *)target);
toplevel = e_config_create_widget((EConfig *)ec);
gtk_container_add (GTK_CONTAINER (prefs), toplevel);
+
+ g_signal_connect (prefs->sig_list, "key-press-event", G_CALLBACK(signature_key_press), prefs);
}
GtkWidget *
diff --git a/mail/mail-signature-editor.c b/mail/mail-signature-editor.c
index b34644676e..8ee79f9243 100644
--- a/mail/mail-signature-editor.c
+++ b/mail/mail-signature-editor.c
@@ -136,12 +136,13 @@ static void
menu_file_save_cb (BonoboUIComponent *uic, void *user_data, const char *path)
{
ESignatureEditor *editor = user_data;
+ ESignature *signature;
Bonobo_PersistStream pstream_iface;
- char *dirname, *base, *filename;
+ char *dirname, *base, *filename, *name;
CORBA_Environment ev;
GByteArray *text;
int fd;
-
+
d(printf ("editor->sig->filename = %s\n", editor->sig->filename));
dirname = g_path_get_dirname (editor->sig->filename);
d(printf ("dirname = %s\n", dirname));
@@ -151,40 +152,57 @@ menu_file_save_cb (BonoboUIComponent *uic, void *user_data, const char *path)
d(printf ("filename = %s\n", filename));
g_free (dirname);
g_free (base);
-
+
CORBA_exception_init (&ev);
pstream_iface = Bonobo_Unknown_queryInterface
- (bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistStream:1.0", &ev);
-
+ (bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),
+ "IDL:Bonobo/PersistStream:1.0", &ev);
+
if (ev._major != CORBA_NO_EXCEPTION)
goto exception;
-
+
if ((fd = open (filename, O_WRONLY | O_TRUNC | O_CREAT, 0666)) == -1)
goto exception;
-
+
text = get_text (pstream_iface, editor->html ? "text/html" : "text/plain", &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
close (fd);
goto exception;
}
-
+
if (write_all (fd, text->data, text->len) == -1) {
g_byte_array_free (text, TRUE);
close (fd);
goto exception;
}
-
+
g_byte_array_free (text, TRUE);
close (fd);
-
+
if (rename (filename, editor->sig->filename) == -1)
goto exception;
-
+
g_free (filename);
-
+
editor->sig->html = editor->html;
+
+ name = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (editor->name_entry))));
+
+ if (g_str_equal(name, "") ) {
+ e_error_run ((GtkWindow *)editor->win, "mail:blank-signature", NULL);
+ return;
+ }
+ if ( (signature = (ESignature *)e_signature_list_find (mail_config_get_signatures (), E_SIGNATURE_FIND_NAME, name)) && !g_str_equal(signature->uid, editor->sig->uid) ) {
+ e_error_run ((GtkWindow *)editor->win, "mail:signature-already-exists", name, NULL);
+ return;
+ }
+
+ if (editor->sig->name)
+ g_free (editor->sig->name);
+
+ editor->sig->name = name;
+
/* if the signature isn't already saved in the config, save it there now... */
if (editor->is_new) {
mail_config_add_signature (editor->sig);
@@ -192,11 +210,12 @@ menu_file_save_cb (BonoboUIComponent *uic, void *user_data, const char *path)
} else {
e_signature_list_change (mail_config_get_signatures (), editor->sig);
}
-
+
+ destroy_editor (editor);
+
return;
-
- exception:
-
+
+exception:
menu_file_save_error (uic, &ev);
CORBA_exception_free (&ev);
unlink (filename);
@@ -220,26 +239,26 @@ static void
do_exit (ESignatureEditor *editor)
{
CORBA_Environment ev;
-
+
CORBA_exception_init (&ev);
-
- if (GNOME_GtkHTML_Editor_Engine_hasUndo (editor->engine, &ev)) {
+
+ if (GNOME_GtkHTML_Editor_Engine_hasUndo (editor->engine, &ev) || GPOINTER_TO_INT( g_object_get_data( G_OBJECT(editor->win), "name-changed"))) {
int button;
button = e_error_run((GtkWindow *)editor->win, "mail:ask-signature-changed", NULL);
exit_dialog_cb (button, editor);
- } else
+ } else
destroy_editor (editor);
-
+
CORBA_exception_free (&ev);
}
-static int
+static int
delete_event_cb (GtkWidget *w, GdkEvent *event, ESignatureEditor *editor)
{
do_exit (editor);
- return FALSE;
+ return TRUE;
}
static void
@@ -259,7 +278,6 @@ menu_file_save_close_cb (BonoboUIComponent *uic, gpointer data, const char *path
editor = E_SIGNATURE_EDITOR (data);
menu_file_save_cb (uic, editor, path);
- destroy_editor (editor);
}
static BonoboUIVerb verbs [] = {
@@ -280,8 +298,7 @@ load_signature (ESignatureEditor *editor)
Bonobo_PersistFile pfile_iface;
CORBA_exception_init (&ev);
- pfile_iface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistFile:1.0", &ev);
+ pfile_iface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),"IDL:Bonobo/PersistFile:1.0", &ev);
Bonobo_PersistFile_load (pfile_iface, editor->sig->filename, &ev);
CORBA_exception_free (&ev);
} else {
@@ -323,15 +340,7 @@ load_signature (ESignatureEditor *editor)
static void
sig_name_changed (GtkWidget *w, ESignatureEditor *editor)
{
- const char *name;
-
- name = gtk_entry_get_text (GTK_ENTRY (editor->name_entry));
-
- g_free (editor->sig->name);
- editor->sig->name = g_strdup (name);
-
- if (!editor->is_new)
- e_signature_list_change (mail_config_get_signatures (), editor->sig);
+ g_object_set_data ( G_OBJECT(editor->win), "name-changed", GINT_TO_POINTER(1));
}
static void
@@ -368,13 +377,15 @@ mail_signature_editor (ESignature *sig, GtkWindow *parent, gboolean is_new)
editor->sig = sig;
editor->html = sig->html;
editor->is_new = is_new;
-
+
editor->win = bonobo_window_new ("e-sig-editor", _("Edit signature"));
gtk_window_set_type_hint (GTK_WINDOW (editor->win), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_default_size (GTK_WINDOW (editor->win), DEFAULT_WIDTH, DEFAULT_HEIGHT);
if (parent != NULL)
gtk_window_set_transient_for (GTK_WINDOW (editor->win), parent);
g_object_set (editor->win, "allow_shrink", FALSE, "allow_grow", TRUE, NULL);
+
+ g_object_set_data (G_OBJECT(editor->win), "name-changed", GINT_TO_POINTER(0));
container = bonobo_window_get_ui_container (BONOBO_WINDOW(editor->win));
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 7ab4d23209..2b23652f03 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -367,5 +367,17 @@ You can choose to ignore this folder, overwrite or append its contents, or quit.
<button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
<button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
</error>
+
+
+ <error id="signature-already-exists" type="error" modal="true">
+ <_primary>Signature Already Exists</_primary>
+ <_secondary>A signature already exists with the name &quot;{0}&quot;. Please specify a different name. </_secondary>
+ </error>
+
+ <error id="blank-signature" type="error" modal="true">
+ <_primary>Blank Signature</_primary>
+ <_secondary>Please provide an unique name to identify this signature.</_secondary>
+ </error>
+
</error-list>