diff options
author | Radek Doulik <rodo@ximian.com> | 2002-06-06 05:16:41 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2002-06-06 05:16:41 +0800 |
commit | 5706b15132615bc427f27516bb599a1baa076523 (patch) | |
tree | dc16d4062ef830df9049fe4b75b623dd633e94f4 | |
parent | ba793447966329f53c4cf2b14f2bfd32fd6e9de9 (diff) | |
download | gsoc2013-evolution-5706b15132615bc427f27516bb599a1baa076523.tar.gz gsoc2013-evolution-5706b15132615bc427f27516bb599a1baa076523.tar.zst gsoc2013-evolution-5706b15132615bc427f27516bb599a1baa076523.zip |
put option menu to hbox to make space for signatures menu
2002-06-05 Radek Doulik <rodo@ximian.com>
* e-msg-composer-hdrs.c (create_from_optionmenu): put option menu
to hbox to make space for signatures menu
(e_msg_composer_hdrs_get_from_hbox): new helper function
* e-msg-composer.c: moved signatures from menu to option menu next
to From:
svn path=/trunk/; revision=17126
-rw-r--r-- | composer/ChangeLog | 9 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.c | 20 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.h | 1 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 183 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 1 |
5 files changed, 114 insertions, 100 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index df369ed280..21cbe77127 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,12 @@ +2002-06-05 Radek Doulik <rodo@ximian.com> + + * e-msg-composer-hdrs.c (create_from_optionmenu): put option menu + to hbox to make space for signatures menu + (e_msg_composer_hdrs_get_from_hbox): new helper function + + * e-msg-composer.c: moved signatures from menu to option menu next + to From: + 2002-06-03 Not Zed <NotZed@Ximian.com> * e-msg-composer.c (build_message): Properly handle user diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index 9930ee3b1a..f497f35f85 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -185,7 +185,7 @@ create_from_optionmenu (EMsgComposerHdrs *hdrs) { GtkWidget *omenu, *menu, *first = NULL; const GSList *accounts; - GtkWidget *item; + GtkWidget *item, *hbox; int i = 0, history = 0; int default_account; @@ -246,8 +246,13 @@ create_from_optionmenu (EMsgComposerHdrs *hdrs) gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), history); gtk_signal_emit_by_name (GTK_OBJECT (first), "activate", hdrs); } - - return omenu; + + hbox = gtk_hbox_new (FALSE, 3); + gtk_box_pack_start_defaults (GTK_BOX (hbox), omenu); + gtk_widget_show (omenu); + gtk_widget_show (hbox); + + return hbox; } static void @@ -1102,3 +1107,12 @@ e_msg_composer_hdrs_get_subject_entry (EMsgComposerHdrs *hdrs) return hdrs->priv->subject.entry; } + +GtkWidget * +e_msg_composer_hdrs_get_from_hbox (EMsgComposerHdrs *hdrs) +{ + g_return_val_if_fail (hdrs != NULL, NULL); + g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); + + return hdrs->priv->from.entry; +} diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h index 373bf36b8f..9ea076687b 100644 --- a/composer/e-msg-composer-hdrs.h +++ b/composer/e-msg-composer-hdrs.h @@ -114,6 +114,7 @@ GtkWidget *e_msg_composer_hdrs_get_to_entry (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_cc_entry (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_bcc_entry (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_subject_entry (EMsgComposerHdrs *hdrs); +GtkWidget *e_msg_composer_hdrs_get_from_hbox (EMsgComposerHdrs *hdrs); void e_msg_composer_set_hdrs_visible (EMsgComposerHdrs *hdrs, gint flags); 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"); */ } /** diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 584de4fa53..6cb0977cb2 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -102,6 +102,7 @@ struct _EMsgComposer { MailConfigSignature *signature; gboolean auto_signature; + GtkWidget *sig_omenu; }; struct _EMsgComposerClass { |