diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-09-10 06:01:42 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-09-10 06:01:42 +0800 |
commit | adc1b15126a1f83d40ea5a66db79f1b55e0fbde6 (patch) | |
tree | 7f13869cfc0de389971621e814d7838f70ddd382 /addressbook/gui/component | |
parent | afdc8acc65f24b38879ec991b2e335a069633a4a (diff) | |
download | gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar.gz gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar.bz2 gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar.lz gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar.xz gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.tar.zst gsoc2013-evolution-adc1b15126a1f83d40ea5a66db79f1b55e0fbde6.zip |
Added. Treat right-clicks on a contact list as a special case.
2001-09-09 Jon Trowbridge <trow@ximian.com>
* gui/component/select-names/e-select-names-popup.c
(popup_menu_list): Added. Treat right-clicks on a contact list as
a special case.
(e_select_names_popup): Check if we are dealing with a contact
list. (Bug #9322)
svn path=/trunk/; revision=12716
Diffstat (limited to 'addressbook/gui/component')
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names-popup.c | 107 |
1 files changed, 104 insertions, 3 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index 69754f1976..77ecd8f521 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -291,7 +291,8 @@ popup_menu_card (PopupInfo *info) gchar *label = (gchar *)e_iterator_get (iterator); if (label && *label) { - /* Magically convert embedded XML into an address. */ + /* Magically convert embedded XML into an address. FIXME: We shouldn't need + this anymore, since we handle contact lists as a separate case. */ if (!strncmp (label, "<?xml", 4)) { EDestination *dest = e_destination_import (label); radioinfo[j].label = g_strdup (e_destination_get_address (dest)); @@ -372,6 +373,99 @@ popup_menu_card (PopupInfo *info) return pop; } +static GtkWidget * +popup_menu_list (PopupInfo *info) +{ + GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; + GtkWidget *pop, *label; + GList *item_children; + const gchar *str; + gchar *name_label, *quoted_name_label, *gs; + gint i = 0, subcount = 0, max_subcount = 10; + ECard *card; + EIterator *iterator; + GList *garbage = NULL; + + + memset (uiinfo, 0, sizeof (uiinfo)); + + uiinfo[i].type = GNOME_APP_UI_ITEM; + uiinfo[i].label = ""; + ++i; + + uiinfo[i].type = GNOME_APP_UI_SEPARATOR; + ++i; + + card = e_destination_get_card (info->dest); + iterator = e_list_get_iterator (card->email); + for (e_iterator_reset (iterator); e_iterator_is_valid (iterator) && subcount < max_subcount; e_iterator_next (iterator)) { + gchar *label = (gchar *) e_iterator_get (iterator); + if (label && *label) { + EDestination *subdest = e_destination_import (label); + uiinfo[i].type = GNOME_APP_UI_ITEM; + name_label = e_utf8_to_locale_string (e_destination_get_address (subdest)); + quoted_name_label = quote_label (name_label); + uiinfo[i].label = quoted_name_label; + g_free (name_label); + garbage = g_list_prepend (garbage, quoted_name_label); + ++i; + ++subcount; + gtk_object_unref (GTK_OBJECT (subdest)); + } + } + if (e_iterator_is_valid (iterator)) { + uiinfo[i].type = GNOME_APP_UI_ITEM; + gs = g_strdup_printf (N_("(%d not shown)"), e_list_length (card->email) - max_subcount); + name_label = e_utf8_to_locale_string (gs); + quoted_name_label = quote_label (name_label); + uiinfo[i].label = quoted_name_label; + garbage = g_list_prepend (garbage, quoted_name_label); + g_free (gs); + g_free (name_label); + ++i; + } + + uiinfo[i].type = GNOME_APP_UI_SEPARATOR; + ++i; + + uiinfo[i].type = GNOME_APP_UI_ITEM; + uiinfo[i].label = N_("Edit Contact List"); + uiinfo[i].moreinfo = edit_contact_info_cb; + ++i; + + add_remove_recipient (&(uiinfo[i]), info); + ++i; + + add_remove_all_recipients (&(uiinfo[i]), info); + ++i; + + uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; + + pop = gnome_popup_menu_new (uiinfo); + + /* Now set label of the first item to contact name */ + str = e_destination_get_name (info->dest); + if (str == NULL) + str = e_destination_get_email (info->dest); + if (str != NULL) { + name_label = e_utf8_to_locale_string (str); + } else { + name_label = g_strdup (_("Unnamed Contact List")); + } + quoted_name_label = quote_label (name_label); + item_children = gtk_container_children (GTK_CONTAINER (uiinfo[0].widget)); + label = item_children->data; + g_list_free (item_children); + gtk_label_set_text (GTK_LABEL (label), quoted_name_label); + g_free (name_label); + g_free (quoted_name_label); + + g_list_foreach (garbage, (GFunc) g_free, NULL); + g_list_free (garbage); + + return pop; +} + static void quick_add_cb (GtkWidget *w, gpointer user_data) { @@ -467,8 +561,15 @@ e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos) card = e_destination_get_card (dest); info = popup_info_new (model, dest, pos, index); - - popup = card ? popup_menu_card (info) : popup_menu_nocard (info); + + if (e_destination_contains_card (dest)) { + if (e_destination_is_evolution_list (dest)) + popup = popup_menu_list (info); + else + popup = popup_menu_card (info); + } else { + popup = popup_menu_nocard (info); + } if (popup) { /* Clean up our info item after we've made our selection. */ |