aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog40
-rw-r--r--mail/folder-browser-factory.c2
-rw-r--r--mail/mail-account-gui.c6
-rw-r--r--mail/mail-composer-prefs.c124
-rw-r--r--mail/mail-composer-prefs.h3
-rw-r--r--mail/mail-config.c19
-rw-r--r--mail/mail-config.h3
-rw-r--r--mail/mail-signature-editor.c116
-rw-r--r--mail/mail-signature-editor.h3
9 files changed, 186 insertions, 130 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 10b6e6586b..831777da79 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,45 @@
2003-03-07 Jeffrey Stedfast <fejj@ximian.com>
+ All this snot just to fix bug #38925 and an attempt to fix bug
+ #38926 (but it seems no matter what I do, I can't work around the
+ bonoboness/modality/whatever of the shell's preferences dialog).
+
+ * mail-account-gui.c (sig_add_new_signature): Get the toplevel
+ parent GtkWindow and pass that along to
+ mail_composer_prefs_new_signature() so that window layering can be
+ done correctly.
+
+ * mail-composer-prefs.c (mail_composer_prefs_new_signature):
+ Simplify. We don't want to add the signature to the list until
+ after they have saved.
+ (sig_edit_cb): Pass FALSE as the is_new argument to
+ mail_signature_editor().
+ (sig_event_client): Listen for signatures being added.
+ (mail_composer_prefs_new_signature): Now takes a GtkWindow arg as
+ the first arg rather than a MailComposerPrefs arg since we don't
+ really need it to be a MailComposerPrefs object. We'd rather use
+ the first arg as the parent GtkWindow so that we can set
+ transience for the editor window.
+
+ * mail-signature-editor.c (mail_signature_editor): Now takes a
+ 'parent' argument (so we can set transient_for()) and a 'is_new'
+ argument specifying whether the editor is editing a new signature
+ or not. If it is, when the user saves, it will be added to the
+ signature list. otherwise it won't.
+ (sig_name_changed): Only use the mail_config_signature_set_name()
+ interface if it is *not* a new signature.
+ (menu_file_save_cb): If is_new, then save the signature to the
+ config - otherwise do what we did before and set the modifications
+ to it and emit the CHANGED event.
+
+ * mail-config.c (mail_config_signature_new): Renamed from
+ mail_config_signature_add(). We no longer immediately add the
+ signature to the list of saved signatures.
+ (mail_config_signature_add): New function which adds the signature
+ and emits the SIG_ADDED event.
+
+2003-03-07 Jeffrey Stedfast <fejj@ximian.com>
+
* mail-display.c (on_url_requested): If the part url is a text
part, use mail_format_data_wrapper_write_to_stream(). This should
fix bug #39204.
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 8a9b5bfbc4..b8b1d2a304 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -107,7 +107,7 @@ control_activate (BonoboControl *control,
folder_browser_ui_add_global (fb);
folder_browser_ui_add_list (fb);
folder_browser_ui_add_message (fb);
-
+
/*bonobo_ui_component_thaw (uic, NULL);*/
folder_browser_set_shell_view (fb, fb_get_svi (control));
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index abedd1886f..71202de030 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -1290,6 +1290,7 @@ sig_add_new_signature (GtkWidget *w, MailAccountGui *gui)
{
GConfClient *gconf;
gboolean send_html;
+ GtkWidget *parent;
if (!gui->dialog)
return;
@@ -1299,7 +1300,10 @@ sig_add_new_signature (GtkWidget *w, MailAccountGui *gui)
gconf = gconf_client_get_default ();
send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL);
- gui->def_signature = mail_composer_prefs_new_signature (NULL, send_html, NULL);
+ parent = gtk_widget_get_toplevel (w);
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ gui->def_signature = mail_composer_prefs_new_signature ((GtkWindow *) parent, send_html, NULL);
gui->auto_signature = FALSE;
gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui));
diff --git a/mail/mail-composer-prefs.c b/mail/mail-composer-prefs.c
index b08fbcba47..f35306aa2d 100644
--- a/mail/mail-composer-prefs.c
+++ b/mail/mail-composer-prefs.c
@@ -184,7 +184,7 @@ sig_load_preview (MailComposerPrefs *prefs, MailConfigSignature *sig)
else
str = e_msg_composer_get_sig_file_content (sig->filename, sig->html);
if (!str)
- str = g_strdup (" ");
+ str = g_strdup ("");
/* printf ("HTML: %s\n", str); */
if (sig->html) {
@@ -206,12 +206,13 @@ sig_load_preview (MailComposerPrefs *prefs, MailConfigSignature *sig)
}
static void
-sig_edit (GtkWidget *widget, MailComposerPrefs *prefs)
+sig_edit_cb (GtkWidget *widget, MailComposerPrefs *prefs)
{
+ GtkTreeSelection *selection;
MailConfigSignature *sig;
GtkTreeModel *model;
+ GtkWidget *parent;
GtkTreeIter iter;
- GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (prefs->sig_list);
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
@@ -219,60 +220,36 @@ sig_edit (GtkWidget *widget, MailComposerPrefs *prefs)
gtk_tree_model_get (model, &iter, 1, &sig, -1);
- if (sig->filename && *sig->filename)
- mail_signature_editor (sig);
- else
- e_notice (GTK_WINDOW (prefs), GTK_MESSAGE_ERROR,
- _("Please specify signature filename\nin Advanced section of signature settings."));
+ if (!sig->filename || *sig->filename == '\0') {
+ g_free (sig->filename);
+ sig->filename = g_strdup (_("Unnamed"));
+ }
+
+ parent = gtk_widget_get_toplevel ((GtkWidget *) prefs);
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ mail_signature_editor (sig, (GtkWindow *) parent, FALSE);
}
MailConfigSignature *
-mail_composer_prefs_new_signature (MailComposerPrefs *prefs, gboolean html, const char *script)
+mail_composer_prefs_new_signature (GtkWindow *parent, gboolean html, const char *script)
{
MailConfigSignature *sig;
- sig = mail_config_signature_add (html, script);
-
- if (prefs) {
- GtkListStore *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- char *name = NULL, *val;
-
- model = (GtkListStore *) gtk_tree_view_get_model (prefs->sig_list);
- selection = gtk_tree_view_get_selection (prefs->sig_list);
- if (sig->name) {
- if (sig->script)
- val = name = g_strconcat (sig->name, " ", _("[script]"), NULL);
- else
- val = sig->name;
- } else {
- if (sig->script)
- val = _("Unnamed [script]");
- else
- val = _("[script]");
- }
-
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter, 0, val, 1, sig, -1);
- gtk_tree_selection_select_iter (selection, &iter);
- g_free (name);
- }
-
- if (sig->filename && *sig->filename)
- mail_signature_editor (sig);
+ sig = mail_config_signature_new (html, script);
+ mail_signature_editor (sig, parent, TRUE);
return sig;
}
static void
-sig_delete (GtkWidget *widget, MailComposerPrefs *prefs)
+sig_delete_cb (GtkWidget *widget, MailComposerPrefs *prefs)
{
MailConfigSignature *sig;
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
-
+
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);
@@ -282,15 +259,19 @@ sig_delete (GtkWidget *widget, MailComposerPrefs *prefs)
}
static void
-sig_add (GtkWidget *widget, MailComposerPrefs *prefs)
+sig_add_cb (GtkWidget *widget, MailComposerPrefs *prefs)
{
GConfClient *gconf;
gboolean send_html;
+ GtkWidget *parent;
gconf = gconf_client_get_default ();
send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL);
- mail_composer_prefs_new_signature (prefs, send_html, NULL);
+ parent = gtk_widget_get_toplevel ((GtkWidget *) prefs);
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ mail_composer_prefs_new_signature ((GtkWindow *) parent, send_html, NULL);
}
static void
@@ -309,10 +290,14 @@ sig_add_script_response (GtkWidget *widget, int button, MailComposerPrefs *prefs
if (script && *script) {
struct stat st;
- if (!stat (script, &st) && S_ISREG (st.st_mode) && (st.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR))) {
+ if (!stat (script, &st) && S_ISREG (st.st_mode) && access (script, X_OK) == 0) {
MailConfigSignature *sig;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_toplevel ((GtkWidget *) prefs);
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
- sig = mail_composer_prefs_new_signature (prefs, TRUE, script);
+ sig = mail_composer_prefs_new_signature ((GtkWindow *) parent, TRUE, script);
mail_config_signature_set_name (sig, name);
gtk_widget_hide (prefs->sig_script_dialog);
@@ -322,8 +307,7 @@ sig_add_script_response (GtkWidget *widget, int button, MailComposerPrefs *prefs
dialog = gtk_message_dialog_new (GTK_WINDOW (prefs->sig_script_dialog),
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"%s", _("You must specify a valid script name."));
gtk_dialog_run ((GtkDialog *) dialog);
@@ -334,7 +318,7 @@ sig_add_script_response (GtkWidget *widget, int button, MailComposerPrefs *prefs
}
static void
-sig_add_script (GtkWidget *widget, MailComposerPrefs *prefs)
+sig_add_script_cb (GtkWidget *widget, MailComposerPrefs *prefs)
{
GtkWidget *entry;
@@ -346,19 +330,19 @@ sig_add_script (GtkWidget *widget, MailComposerPrefs *prefs)
}
static void
-sig_selection_changed(GtkTreeSelection *selection, MailComposerPrefs *prefs)
+sig_selection_changed (GtkTreeSelection *selection, MailComposerPrefs *prefs)
{
+ MailConfigSignature *sig;
GtkTreeModel *model;
GtkTreeIter iter;
- MailConfigSignature *sig;
int state;
-
+
state = gtk_tree_selection_get_selected (selection, &model, &iter);
if (state) {
gtk_tree_model_get (model, &iter, 1, &sig, -1);
sig_load_preview (prefs, sig);
}
-
+
gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, state);
gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, state);
}
@@ -418,16 +402,23 @@ url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle)
static void
sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailComposerPrefs *prefs)
{
- GtkTreeIter iter;
- char path[16];
- GtkTreeModel *model;
MailConfigSignature *current;
GtkTreeSelection *selection;
-
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char path[16];
+
switch (event) {
+ case MAIL_CONFIG_SIG_EVENT_ADDED:
+ d(printf ("signature ADDED\n"));
+
+ model = gtk_tree_view_get_model (prefs->sig_list);
+ gtk_list_store_append ((GtkListStore *) model, &iter);
+ gtk_list_store_set ((GtkListStore *) model, &iter, 0, sig->name, 1, sig, -1);
+ break;
case MAIL_CONFIG_SIG_EVENT_NAME_CHANGED:
- d(printf ("accounts NAME CHANGED\n"));
-
+ d(printf ("signature NAME CHANGED\n"));
+
/* this is one bizarro interface */
model = gtk_tree_view_get_model (prefs->sig_list);
sprintf (path, "%d", sig->id);
@@ -444,7 +435,7 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailCompos
}
break;
case MAIL_CONFIG_SIG_EVENT_CONTENT_CHANGED:
- d(printf ("accounts CONTENT CHANGED\n"));
+ d(printf ("signature CONTENT CHANGED\n"));
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, &current, -1);
@@ -859,25 +850,24 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs)
/* Signatures */
dialog = (GtkDialog *) gtk_dialog_new ();
prefs->sig_script_dialog = (GtkWidget *) dialog;
- gtk_dialog_add_buttons (dialog,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- NULL);
+ gtk_dialog_add_buttons (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_window_set_title ((GtkWindow *) dialog, _("Add script signature"));
g_signal_connect (dialog, "response", G_CALLBACK (sig_add_script_response), prefs);
widget = glade_xml_get_widget (prefs->sig_script_gui, "vbox_add_script_signature");
gtk_box_pack_start_defaults ((GtkBox *) dialog->vbox, widget);
prefs->sig_add = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureAdd"));
- g_signal_connect (prefs->sig_add, "clicked", G_CALLBACK (sig_add), prefs);
+ g_signal_connect (prefs->sig_add, "clicked", G_CALLBACK (sig_add_cb), prefs);
- glade_xml_signal_connect_data (gui, "cmdSignatureAddScriptClicked", G_CALLBACK(sig_add_script), prefs);
+ glade_xml_signal_connect_data (gui, "cmdSignatureAddScriptClicked",
+ 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), prefs);
+ g_signal_connect (prefs->sig_edit, "clicked", 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), prefs);
+ g_signal_connect (prefs->sig_delete, "clicked", G_CALLBACK (sig_delete_cb), prefs);
prefs->sig_list = GTK_TREE_VIEW (glade_xml_get_widget (gui, "clistSignatures"));
model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
diff --git a/mail/mail-composer-prefs.h b/mail/mail-composer-prefs.h
index 884953dd9e..666c1bb646 100644
--- a/mail/mail-composer-prefs.h
+++ b/mail/mail-composer-prefs.h
@@ -123,8 +123,7 @@ GtkWidget *mail_composer_prefs_new (void);
void mail_composer_prefs_apply (MailComposerPrefs *prefs);
-
-MailConfigSignature *mail_composer_prefs_new_signature (MailComposerPrefs *prefs, gboolean html, const char *script);
+MailConfigSignature *mail_composer_prefs_new_signature (GtkWindow *parent, gboolean html, const char *script);
/* needed by global config */
#define MAIL_COMPOSER_PREFS_CONTROL_ID "OAFIID:GNOME_Evolution_Mail_ComposerPrefs_ConfigControl"
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 4e3f634aaf..f65eee55da 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -1206,14 +1206,14 @@ get_new_signature_filename (void)
return NULL;
}
+
MailConfigSignature *
-mail_config_signature_add (gboolean html, const char *script)
+mail_config_signature_new (gboolean html, const char *script)
{
MailConfigSignature *sig;
sig = g_new0 (MailConfigSignature, 1);
- /* printf ("mail_config_signature_add %d\n", config->sig_nextid); */
sig->id = config->sig_nextid++;
sig->name = g_strdup (_("Unnamed"));
if (script)
@@ -1222,14 +1222,17 @@ mail_config_signature_add (gboolean html, const char *script)
sig->filename = get_new_signature_filename ();
sig->html = html;
- config->signatures = g_slist_append (config->signatures, sig);
-
- config_write_signatures ();
+ return sig;
+}
+
+
+void
+mail_config_signature_add (MailConfigSignature *sig)
+{
+ g_assert (g_slist_find (config->signatures, sig) == NULL);
+ config->signatures = g_slist_append (config->signatures, sig);
mail_config_signature_emit_event (MAIL_CONFIG_SIG_EVENT_ADDED, sig);
- /* printf ("mail_config_signature_add end\n"); */
-
- return sig;
}
static void
diff --git a/mail/mail-config.h b/mail/mail-config.h
index cc617768e5..b84f262273 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -126,7 +126,8 @@ EAccountService *mail_config_get_default_transport (void);
void mail_config_save_accounts (void);
GSList *mail_config_get_signature_list (void);
-MailConfigSignature *mail_config_signature_add (gboolean html, const char *script);
+MailConfigSignature *mail_config_signature_new (gboolean html, const char *script);
+void mail_config_signature_add (MailConfigSignature *sig);
void mail_config_signature_delete (MailConfigSignature *sig);
void mail_config_signature_set_name (MailConfigSignature *sig, const char *name);
void mail_config_signature_set_html (MailConfigSignature *sig, gboolean html);
diff --git a/mail/mail-signature-editor.c b/mail/mail-signature-editor.c
index 386af9c00a..c0f3fbaba3 100644
--- a/mail/mail-signature-editor.c
+++ b/mail/mail-signature-editor.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Radek Doulik <rodo@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 2002 Ximian, Inc. (www.ximian.com)
*
@@ -36,10 +37,8 @@
#include "mail-signature-editor.h"
#include "mail-config.h"
-/*
- * Signature editor
- *
- */
+#define d(x) x
+
struct _ESignatureEditor {
GtkWidget *win;
@@ -48,8 +47,9 @@ struct _ESignatureEditor {
GtkWidget *info_frame;
MailConfigSignature *sig;
+ gboolean is_new;
gboolean html;
-
+
GNOME_GtkHTML_Editor_Engine engine;
};
typedef struct _ESignatureEditor ESignatureEditor;
@@ -95,33 +95,33 @@ menu_file_save_cb (BonoboUIComponent *uic,
editor = E_SIGNATURE_EDITOR (data);
- printf ("editor->sig->filename = %s\n", editor->sig->filename);
+ d(printf ("editor->sig->filename = %s\n", editor->sig->filename));
dirname = g_path_get_dirname (editor->sig->filename);
- printf ("dirname = %s\n", dirname);
+ d(printf ("dirname = %s\n", dirname));
base = g_path_get_basename (editor->sig->filename);
- printf ("basename = %s\n", base);
+ d(printf ("basename = %s\n", base));
filename = g_strdup_printf ("%s/.#%s", dirname, base);
- printf ("filename = %s\n", filename);
+ d(printf ("filename = %s\n", filename));
g_free (dirname);
g_free (base);
-
+
CORBA_exception_init (&ev);
if (editor->html) {
Bonobo_PersistFile pfile_iface;
- pfile_iface = Bonobo_Unknown_queryInterface(bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistFile:1.0", NULL);
+ pfile_iface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)),
+ "IDL:Bonobo/PersistFile:1.0", NULL);
Bonobo_PersistFile_save (pfile_iface, filename, &ev);
} else {
Bonobo_PersistStream pstream_iface;
Bonobo_Stream stream;
char *uri;
-
+
uri = g_strdup_printf ("file://%s", filename);
stream = bonobo_get_object (uri, "IDL:Bonobo/Stream:1.0", NULL);
g_free (uri);
-
+
/* FIXME: truncate? */
pstream_iface = Bonobo_Unknown_queryInterface
@@ -129,8 +129,8 @@ menu_file_save_cb (BonoboUIComponent *uic,
"IDL:Bonobo/PersistStream:1.0", NULL);
Bonobo_PersistStream_save (pstream_iface, stream, "text/plain", &ev);
-
- bonobo_object_release_unref(stream, NULL);
+
+ bonobo_object_release_unref (stream, NULL);
}
if (ev._major != CORBA_NO_EXCEPTION || rename (filename, editor->sig->filename) == -1) {
@@ -142,8 +142,14 @@ menu_file_save_cb (BonoboUIComponent *uic,
CORBA_exception_free (&ev);
- mail_config_signature_set_html (editor->sig, editor->html);
- mail_config_signature_emit_event (MAIL_CONFIG_SIG_EVENT_CONTENT_CHANGED, editor->sig);
+ /* if the signature isn't already saved in the config, save it there now... */
+ if (editor->is_new) {
+ mail_config_signature_add (editor->sig);
+ editor->is_new = FALSE;
+ } else {
+ mail_config_signature_set_html (editor->sig, editor->html);
+ mail_config_signature_emit_event (MAIL_CONFIG_SIG_EVENT_CONTENT_CHANGED, editor->sig);
+ }
}
static void
@@ -163,32 +169,33 @@ static void
do_exit (ESignatureEditor *editor)
{
CORBA_Environment ev;
-
+
CORBA_exception_init (&ev);
+
if (GNOME_GtkHTML_Editor_Engine_hasUndo (editor->engine, &ev)) {
GtkWidget *dialog;
- gint button;
+ int button;
- dialog = gtk_message_dialog_new(GTK_WINDOW (editor->win),
- GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("This signature has been changed, but hasn't been saved.\n"
+ dialog = gtk_message_dialog_new (GTK_WINDOW (editor->win),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s",
+ _("This signature has been changed, but hasn't been saved.\n"
"\nDo you wish to save your changes?"));
- gtk_dialog_add_buttons ((GtkDialog *)dialog,
+ gtk_dialog_add_buttons ((GtkDialog *) dialog,
_("_Discard changes"), GTK_RESPONSE_NO,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_YES,
NULL);
- gtk_window_set_title((GtkWindow *)dialog, _("Save signature"));
- gtk_dialog_set_default_response((GtkDialog *)dialog, GTK_RESPONSE_YES);
-
- button = gtk_dialog_run((GtkDialog *)dialog);
- gtk_widget_destroy(dialog);
-
+ gtk_window_set_title ((GtkWindow *) dialog, _("Save signature"));
+ gtk_dialog_set_default_response ((GtkDialog *) dialog, GTK_RESPONSE_YES);
+
+ button = gtk_dialog_run ((GtkDialog *) dialog);
+ gtk_widget_destroy (dialog);
+
exit_dialog_cb (button, editor);
} else
destroy_editor (editor);
+
CORBA_exception_free (&ev);
}
@@ -215,7 +222,7 @@ menu_file_save_close_cb (BonoboUIComponent *uic, gpointer data, const gchar *pat
ESignatureEditor *editor;
editor = E_SIGNATURE_EDITOR (data);
-
+
menu_file_save_cb (uic, editor, path);
destroy_editor (editor);
}
@@ -232,7 +239,7 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("FileClose", menu_file_close_cb),
BONOBO_UI_VERB ("FileSaveClose", menu_file_save_close_cb),
BONOBO_UI_VERB ("HelpSigEditor", menu_help),
-
+
BONOBO_UI_VERB_END
};
@@ -252,7 +259,7 @@ load_signature (ESignatureEditor *editor)
} else {
Bonobo_PersistStream pstream_iface;
BonoboStream *stream;
- gchar *data, *html;
+ char *data, *html;
data = e_msg_composer_get_sig_file_content (editor->sig->filename, FALSE);
html = g_strdup_printf ("<PRE>\n%s", data);
@@ -288,7 +295,16 @@ load_signature (ESignatureEditor *editor)
static void
sig_name_changed (GtkWidget *w, ESignatureEditor *editor)
{
- mail_config_signature_set_name (editor->sig, gtk_entry_get_text(GTK_ENTRY (editor->name_entry)));
+ const char *name;
+
+ name = gtk_entry_get_text (GTK_ENTRY (editor->name_entry));
+
+ if (editor->is_new) {
+ g_free (editor->sig->name);
+ editor->sig->name = g_strdup (name);
+ } else {
+ mail_config_signature_set_name (editor->sig, name);
+ }
}
static void
@@ -309,7 +325,7 @@ format_html_cb (BonoboUIComponent *component,
}
void
-mail_signature_editor (MailConfigSignature *sig)
+mail_signature_editor (MailConfigSignature *sig, GtkWindow *parent, gboolean is_new)
{
CORBA_Environment ev;
ESignatureEditor *editor;
@@ -324,11 +340,14 @@ mail_signature_editor (MailConfigSignature *sig)
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_default_size (GTK_WINDOW (editor->win), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- g_object_set(editor->win, "allow_shrink", FALSE, "allow_grow", TRUE, NULL);
-
+ 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);
+
container = bonobo_window_get_ui_container (BONOBO_WINDOW(editor->win));
component = bonobo_ui_component_new_default ();
@@ -347,18 +366,17 @@ mail_signature_editor (MailConfigSignature *sig)
destroy_editor (editor);
return;
}
-
+
editor->engine = (GNOME_GtkHTML_Editor_Engine) Bonobo_Unknown_queryInterface
(bonobo_widget_get_objref (BONOBO_WIDGET (editor->control)), "IDL:GNOME/GtkHTML/Editor/Engine:1.0", NULL);
load_signature (editor);
-
+
bonobo_ui_component_set_prop (component, "/commands/FormatHtml", "state", editor->html ? "1" : "0", NULL);
bonobo_ui_component_add_listener (component, "FormatHtml", format_html_cb, editor);
-
- g_signal_connect(editor->win, "delete_event",
- G_CALLBACK (delete_event_cb), editor);
-
+
+ g_signal_connect (editor->win, "delete_event", G_CALLBACK (delete_event_cb), editor);
+
vbox = gtk_vbox_new (FALSE, 0);
hbox = gtk_hbox_new (FALSE, 4);
vbox1 = gtk_vbox_new (FALSE, 3);
@@ -369,8 +387,8 @@ mail_signature_editor (MailConfigSignature *sig)
label = gtk_label_new (_("Name:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
editor->name_entry = gtk_entry_new ();
- gtk_entry_set_text(GTK_ENTRY (editor->name_entry), sig->name);
- g_signal_connect(editor->name_entry, "changed", G_CALLBACK (sig_name_changed), editor);
+ gtk_entry_set_text (GTK_ENTRY (editor->name_entry), sig->name);
+ g_signal_connect (editor->name_entry, "changed", G_CALLBACK (sig_name_changed), editor);
gtk_box_pack_start_defaults (GTK_BOX (hbox), editor->name_entry);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
@@ -379,12 +397,12 @@ mail_signature_editor (MailConfigSignature *sig)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
gtk_widget_show_all (vbox);
gtk_box_pack_start_defaults (GTK_BOX (vbox), editor->control);
-
+
bonobo_window_set_contents (BONOBO_WINDOW (editor->win), vbox);
bonobo_widget_set_property (BONOBO_WIDGET (editor->control), "FormatHTML", TC_CORBA_boolean, editor->html, NULL);
gtk_widget_show (GTK_WIDGET (editor->win));
gtk_widget_show (GTK_WIDGET (editor->control));
-
+
CORBA_exception_init (&ev);
GNOME_GtkHTML_Editor_Engine_runCommand (editor->engine, "grab-focus", &ev);
CORBA_exception_free (&ev);
diff --git a/mail/mail-signature-editor.h b/mail/mail-signature-editor.h
index 60a5e6ae04..9dd58aade2 100644
--- a/mail/mail-signature-editor.h
+++ b/mail/mail-signature-editor.h
@@ -30,9 +30,10 @@ extern "C" {
#endif /* __cplusplus */
#include <glib.h>
+#include <gtk/gtkwindow.h>
#include <mail-config.h>
-void mail_signature_editor (MailConfigSignature *sig);
+void mail_signature_editor (MailConfigSignature *sig, GtkWindow *parent, gboolean is_new);
#ifdef __cplusplus
}