aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c183
1 files changed, 86 insertions, 97 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 6b0899c60e..ab4ac99149 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -881,7 +881,7 @@ get_signature_html (EMsgComposer *composer)
if (!text) {
if (!sig_file)
return NULL;
- printf ("sig file: %s\n", sig_file);
+ /* printf ("sig file: %s\n", sig_file); */
mail_config_signature_run_script (script);
text = e_msg_composer_get_sig_file_content (sig_file, format_html);
@@ -1515,7 +1515,7 @@ menu_edit_delete_all_cb (BonoboUIComponent *uic, void *data, const char *path)
GNOME_GtkHTML_Editor_Engine_undoEnd (composer->editor_engine, &ev);
CORBA_exception_free (&ev);
- printf ("delete all\n");
+ /* printf ("delete all\n"); */
}
static void
@@ -1745,71 +1745,45 @@ static EPixmap pixcache [] = {
};
static void
-signature_cb (BonoboUIComponent *uic, const char *path, Bonobo_UIComponent_EventType type,
- const char *state, gpointer user_data)
+signature_cb (GtkWidget *w, EMsgComposer *composer)
{
- EMsgComposer *composer = (EMsgComposer *) user_data;
+ MailConfigSignature *old_sig;
+ gboolean old_auto;
+ gint idx = g_list_index (GTK_MENU_SHELL (w)->children, gtk_menu_get_active (GTK_MENU (w)));
- printf ("signature_cb: %s (%s)\n", path, state);
+ /* printf ("signature_cb: %d\n", idx); */
- if (state && *state == '1') {
- if (path && !strncmp (path, "Signature", 9)) {
- MailConfigSignature *old_sig;
- gboolean old_auto;
+ old_sig = composer->signature;
+ old_auto = composer->auto_signature;
- old_sig = composer->signature;
- old_auto = composer->auto_signature;
-
- printf ("I'm going to set signature (%d)\n", atoi (path + 9));
- if (path [9] == 'N') { /* none */
- composer->signature = NULL;
- composer->auto_signature = FALSE;
- } else if (path [9] == 'A') { /* auto */
- composer->signature = NULL;
- composer->auto_signature = TRUE;
- } else {
- composer->signature = g_list_nth_data (mail_config_get_signature_list (), atoi (path + 9));
- composer->auto_signature = FALSE;
- }
- if (old_sig != composer->signature || old_auto != composer->auto_signature)
- e_msg_composer_show_sig_file (composer);
- }
+ if (idx == 0) { /* none */
+ composer->signature = NULL;
+ composer->auto_signature = FALSE;
+ } else if (idx == 1) { /* auto */
+ composer->signature = NULL;
+ composer->auto_signature = TRUE;
+ } else {
+ composer->signature = g_list_nth_data (mail_config_get_signature_list (), idx - 2);
+ composer->auto_signature = FALSE;
}
+ if (old_sig != composer->signature || old_auto != composer->auto_signature)
+ e_msg_composer_show_sig_file (composer);
- printf ("signature_cb end\n");
+ /* printf ("signature_cb end\n"); */
}
static void setup_signatures_menu (EMsgComposer *composer);
static void
-remove_signature_list (EMsgComposer *composer)
-{
- gchar path [64];
- gint len = g_list_length (mail_config_get_signature_list ());
-
- bonobo_ui_component_rm (composer->uic, "/menu/Edit/EditMisc/EditSignaturesSubmenu/SeparatorList", NULL);
- for (; len; len --) {
- g_snprintf (path, 64, "/menu/Edit/EditMisc/EditSignaturesSubmenu/Signature%d", len - 1);
- bonobo_ui_component_rm (composer->uic, path, NULL);
- }
-}
-
-static void
sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, EMsgComposer *composer)
{
- gchar *path;
-
- bonobo_ui_component_freeze (composer->uic, NULL);
switch (event) {
case MAIL_CONFIG_SIG_EVENT_DELETED:
if (sig == composer->signature) {
composer->signature = NULL;
composer->auto_signature = TRUE;
+ e_msg_composer_show_sig_file (composer);
}
- path = g_strdup_printf ("/menu/Edit/EditMisc/EditSignaturesSubmenu/Signature%d",
- g_list_length (mail_config_get_signature_list ()));
- bonobo_ui_component_rm (composer->uic, path, NULL);
- g_free (path);
setup_signatures_menu (composer);
break;
case MAIL_CONFIG_SIG_EVENT_ADDED:
@@ -1818,52 +1792,75 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, EMsgCompos
default:
;
}
- bonobo_ui_component_thaw (composer->uic, NULL);
+}
+
+static void
+prepare_signatures_menu (EMsgComposer *composer)
+{
+ GtkWidget *hbox;
+ GtkWidget *label;
+
+ hbox = e_msg_composer_hdrs_get_from_hbox (E_MSG_COMPOSER_HDRS (composer->hdrs));
+
+ label = gtk_label_new (_("Signature:"));
+ gtk_widget_show (label);
+
+ composer->sig_omenu = gtk_option_menu_new ();
+ gtk_widget_show (composer->sig_omenu);
+
+ gtk_box_pack_end_defaults (GTK_BOX (hbox), composer->sig_omenu);
+ gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+}
+
+static void
+sig_select_item (EMsgComposer *composer)
+{
+ gint idx;
+
+ if (composer->auto_signature) {
+ idx = 1;
+ } else if (composer->signature == NULL) {
+ idx = 0;
+ } else {
+ idx = composer->signature->id + 2;
+ }
+
+ gtk_option_menu_set_history (GTK_OPTION_MENU (composer->sig_omenu), idx);
}
static void
setup_signatures_menu (EMsgComposer *composer)
{
GList *l, *list;
- GString *str;
- gchar *line;
- gint i, len = 0;
+ gint len = 0;
+ GtkWidget *menu;
+ GtkWidget *mi;
- str = g_string_new ("<submenu name=\"EditSignaturesSubmenu\" _label=\"Signatures\">\n"
- "<menuitem name=\"SignatureNone\" _label=\"None\" verb=\"SignatureNone\""
- " type=\"radio\" group=\"signatures_group\"/>\n"
- "<menuitem name=\"SignatureAuto\" _label=\"Autogenerated\" verb=\"SignatureAuto\""
- " type=\"radio\" group=\"signatures_group\"/>\n");
+#define ADD(x) \
+ mi = gtk_menu_item_new_with_label (x); \
+ gtk_widget_show (mi); \
+ gtk_menu_append (GTK_MENU (menu), mi);
- list = mail_config_get_signature_list ();
- if (list) {
- gchar *gtk_str;
- g_string_append (str, "<separator name=\"SeparatorList\"/>");
+ menu = gtk_menu_new ();
+ ADD (_("None"));
+ ADD (_("Autogenerated"));
+ list = mail_config_get_signature_list ();
+ if (list)
for (l = list; l; len ++, l = l->next) {
- gtk_str = e_utf8_to_gtk_string (GTK_WIDGET (composer), ((MailConfigSignature *)l->data)->name);
- line = g_strdup_printf ("<menuitem name=\"Signature%d\" _label=\"%s\""
- " verb=\"Signature%d\" type=\"radio\" group=\"signatures_group\"/>\n",
- len, gtk_str, len);
+ gchar *gtk_str;
+
+ gtk_str = e_utf8_to_gtk_string (menu, ((MailConfigSignature *)l->data)->name);
+ ADD (gtk_str);
g_free (gtk_str);
- g_string_append (str, line);
- g_free (line);
}
- }
-
- g_string_append (str, "</submenu>\n");
-
- bonobo_ui_component_set_translate (composer->uic, "/menu/Edit/EditMisc/", str->str, NULL);
- bonobo_ui_component_set (composer->uic, "/menu/Edit/EditMisc/", "<separator/>", NULL);
+#undef ADD
- bonobo_ui_component_add_listener (composer->uic, "SignatureNone", signature_cb, composer);
- bonobo_ui_component_add_listener (composer->uic, "SignatureAuto", signature_cb, composer);
+ gtk_widget_show (menu);
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (composer->sig_omenu), menu);
+ sig_select_item (composer);
- for (i = 0; i < len; i ++) {
- g_string_sprintf (str, "Signature%d", i + 1);
- bonobo_ui_component_add_listener (composer->uic, str->str, signature_cb, composer);
- }
- g_string_free (str, TRUE);
+ gtk_signal_connect (GTK_OBJECT (menu), "selection-done", signature_cb, composer);
}
static void
@@ -2018,7 +2015,6 @@ setup_ui (EMsgComposer *composer)
composer->uic, "ViewAttach",
menu_view_attachments_activate_cb, composer);
- setup_signatures_menu (composer);
mail_config_signature_register_client ((MailConfigSignatureClient) sig_event_client, composer);
bonobo_ui_component_thaw (composer->uic, NULL);
@@ -2705,6 +2701,9 @@ create_composer (void)
gtk_signal_connect (GTK_OBJECT (composer->hdrs), "from_changed",
GTK_SIGNAL_FUNC (from_changed_cb), composer);
gtk_widget_show (composer->hdrs);
+
+ prepare_signatures_menu (composer);
+ setup_signatures_menu (composer);
/* Editor component. */
composer->editor = bonobo_widget_new_control (
@@ -2788,30 +2787,20 @@ create_composer (void)
static void
set_editor_signature (EMsgComposer *composer)
{
- printf ("set_editor_signature\n");
+ /* printf ("set_editor_signature\n"); */
if (E_MSG_COMPOSER_HDRS (composer->hdrs)->account->id) {
MailConfigIdentity *id;
- char *verb;
id = E_MSG_COMPOSER_HDRS (composer->hdrs)->account->id;
composer->signature = id->def_signature;
composer->auto_signature = id->auto_signature;
- printf ("auto: %d\n", id->auto_signature);
+ /* printf ("auto: %d\n", id->auto_signature); */
- if (composer->auto_signature) {
- verb = g_strdup ("/commands/SignatureAuto");
- } else if (composer->signature == NULL) {
- verb = g_strdup ("/commands/SignatureNone");
- } else {
- verb = g_strdup_printf ("/commands/Signature%d", composer->signature->id);
- }
-
- bonobo_ui_component_set_prop (composer->uic, verb, "state", "1", NULL);
- g_free (verb);
+ sig_select_item (composer);
}
- printf ("set_editor_signature end\n");
+ /* printf ("set_editor_signature end\n"); */
}
/**
@@ -3733,7 +3722,7 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
g_return_if_fail (composer != NULL);
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- printf ("e_msg_composer_show_sig_file\n");
+ /* printf ("e_msg_composer_show_sig_file\n"); */
/* printf ("set sig '%s' '%s'\n", sig_file, composer->sig_file); */
composer->in_signature_insert = TRUE;
@@ -3764,7 +3753,7 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
CORBA_exception_free (&ev);
composer->in_signature_insert = FALSE;
- printf ("e_msg_composer_show_sig_file end\n");
+ /* printf ("e_msg_composer_show_sig_file end\n"); */
}
/**