aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-09-19 16:36:35 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-09-19 16:36:35 +0800
commit19648dad9c6459b564addd020320ba5fe821ddad (patch)
treeea8197e15015737f179a60737f30d07691d417ab /addressbook
parent73c74dd70d7e023cc24f7e28d52417b3c4e72805 (diff)
downloadgsoc2013-evolution-19648dad9c6459b564addd020320ba5fe821ddad.tar.gz
gsoc2013-evolution-19648dad9c6459b564addd020320ba5fe821ddad.tar.zst
gsoc2013-evolution-19648dad9c6459b564addd020320ba5fe821ddad.zip
Properly handle our GnomeUIInfo labels so that they won't be leaked if
2001-09-19 Jon Trowbridge <trow@ximian.com> * gui/component/select-names/e-select-names-popup.c (popup_menu_card): Properly handle our GnomeUIInfo labels so that they won't be leaked if they are dynamic strings, so that they will be i18n-correct, and so that underscores won't be interpreted as key accelerators. What a PITA. Also, don't leak our iterators. (Bug #10200.) (popup_menu_list): The same GnomeUIInfo tweaking as in popup_menu_card. (popup_menu_nocard): Ditto. svn path=/trunk/; revision=12975
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/gui/component/select-names/e-select-names-popup.c276
2 files changed, 137 insertions, 151 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 5f0f82be0c..619c419486 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,15 @@
+2001-09-19 Jon Trowbridge <trow@ximian.com>
+
+ * gui/component/select-names/e-select-names-popup.c
+ (popup_menu_card): Properly handle our GnomeUIInfo labels so that
+ they won't be leaked if they are dynamic strings, so that they
+ will be i18n-correct, and so that underscores won't be interpreted
+ as key accelerators. What a PITA. Also, don't leak our
+ iterators. (Bug #10200.)
+ (popup_menu_list): The same GnomeUIInfo tweaking as in
+ popup_menu_card.
+ (popup_menu_nocard): Ditto.
+
2001-09-18 JP Rosevear <jpr@ximian.com>
* backend/ebook/e-card-simple.c (field_data): add caluri field data
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 77ecd8f521..4b34ff2d01 100644
--- a/addressbook/gui/component/select-names/e-select-names-popup.c
+++ b/addressbook/gui/component/select-names/e-select-names-popup.c
@@ -213,38 +213,19 @@ init_html_mail (GnomeUIInfo *uiinfo, PopupInfo *info)
}
-/* Duplicate the string, mapping _ to __. This is to make sure that underscores in
- e-mail addresses don't get mistaken for keyboard accelerators. */
-static gchar *
-quote_label (const gchar *str)
+static void
+set_uiinfo_label (GnomeUIInfo *uiinfo, const gchar *str)
{
- gint len = str ? strlen (str) : -1;
- const gchar *c = str;
- gchar *d, *q;
-
- if (len < 0)
- return NULL;
-
- while (*c) {
- if (*c == '_')
- ++len;
- ++c;
- }
-
- q = g_new (gchar, len+1);
- c = str;
- d = q;
- while (*c) {
- *d = *c;
- if (*c == '_') {
- ++d;
- *d = '_';
- }
- ++c;
- ++d;
- }
- *d = '\0';
- return q;
+ GtkWidget *label;
+ gchar *label_txt;
+ GList *item_children;
+
+ label_txt = e_utf8_to_locale_string (str);
+ item_children = gtk_container_children (GTK_CONTAINER (uiinfo->widget));
+ label = item_children->data;
+ g_list_free (item_children);
+ gtk_label_set_text (GTK_LABEL (label), label_txt);
+ g_free (label_txt);
}
#define ARBITRARY_UIINFO_LIMIT 64
@@ -256,11 +237,11 @@ popup_menu_card (PopupInfo *info)
gboolean using_radio = FALSE;
ECard *card;
gint i=0;
- GtkWidget *pop, *label;
- GList *item_children;
+ GtkWidget *pop;
EIterator *iterator;
gint html_toggle;
- gchar *name_label, *quoted_name_label;
+ gint mail_label = -1;
+ const gchar *mail_label_str = NULL;
/*
* Build up our GnomeUIInfo array.
@@ -281,49 +262,43 @@ popup_menu_card (PopupInfo *info)
uiinfo[i].type = GNOME_APP_UI_SEPARATOR;
++i;
- if (e_list_length (card->email) > 1) {
- gint j = 0;
-
- using_radio = TRUE;
-
- iterator = e_list_get_iterator (card->email);
- for (e_iterator_reset (iterator); e_iterator_is_valid (iterator); e_iterator_next (iterator)) {
- gchar *label = (gchar *)e_iterator_get (iterator);
-
- if (label && *label) {
- /* 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));
- gtk_object_unref (GTK_OBJECT (dest));
-
- }
- else {
- radioinfo[j].label = g_strdup (label);
+ if (card->email) {
+
+ if (e_list_length (card->email) > 1) {
+ gint j = 0;
+
+ using_radio = TRUE;
+
+ iterator = e_list_get_iterator (card->email);
+ for (e_iterator_reset (iterator); e_iterator_is_valid (iterator); e_iterator_next (iterator)) {
+ gchar *label = (gchar *)e_iterator_get (iterator);
+ if (label && *label) {
+ radioinfo[j].label = "";
+ radioinfo[j].type = GNOME_APP_UI_ITEM;
+ radioinfo[j].moreinfo = change_email_num_cb;
+ ++j;
}
-
- radioinfo[j].type = GNOME_APP_UI_ITEM;
- radioinfo[j].moreinfo = change_email_num_cb;
- ++j;
}
+ gtk_object_unref (GTK_OBJECT (iterator));
+
+ radioinfo[j].type = GNOME_APP_UI_ENDOFINFO;
+
+ uiinfo[i].type = GNOME_APP_UI_RADIOITEMS;
+ uiinfo[i].moreinfo = radioinfo;
+ ++i;
+
+ } else {
+ uiinfo[i].type = GNOME_APP_UI_ITEM;
+ uiinfo[i].label = "";
+ mail_label_str = e_destination_get_email (info->dest);
+ mail_label = i;
+ ++i;
}
- radioinfo[j].type = GNOME_APP_UI_ENDOFINFO;
-
- uiinfo[i].type = GNOME_APP_UI_RADIOITEMS;
- uiinfo[i].moreinfo = radioinfo;
- ++i;
-
- } else {
- uiinfo[i].type = GNOME_APP_UI_ITEM;
- uiinfo[i].label = (gchar *) e_destination_get_email (info->dest);
+ uiinfo[i].type = GNOME_APP_UI_SEPARATOR;
++i;
}
- uiinfo[i].type = GNOME_APP_UI_SEPARATOR;
- ++i;
-
add_html_mail (&(uiinfo[i]), info);
html_toggle = i;
++i;
@@ -347,29 +322,37 @@ popup_menu_card (PopupInfo *info)
pop = gnome_popup_menu_new (uiinfo);
+ init_html_mail (&(uiinfo[html_toggle]), info);
+
+ /* Properly handle the names & e-mail addresses so that they don't get leaked and so that
+ underscores are interpreted as key accelerators. This sucks. */
+
+ set_uiinfo_label (&(uiinfo[0]), e_destination_get_name (info->dest));
+
+ if (mail_label >= 0) {
+ set_uiinfo_label (&(uiinfo[mail_label]), e_destination_get_email (info->dest));
+ }
+
if (using_radio) {
gint n = e_destination_get_email_num (info->dest);
- gint j;
- for (j=0; radioinfo[j].type != GNOME_APP_UI_ENDOFINFO; ++j) {
- gtk_object_set_data (GTK_OBJECT (radioinfo[j].widget), "number", GINT_TO_POINTER (j));
- g_free (radioinfo[j].label);
- if (j == n)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (radioinfo[n].widget), TRUE);
+ gint j = 0;
+ iterator = e_list_get_iterator (card->email);
+ for (e_iterator_reset (iterator); e_iterator_is_valid (iterator); e_iterator_next (iterator)) {
+ gchar *label = (gchar *)e_iterator_get (iterator);
+ if (label && *label) {
+ set_uiinfo_label (&(radioinfo[j]), label);
+
+ gtk_object_set_data (GTK_OBJECT (radioinfo[j].widget), "number", GINT_TO_POINTER (j));
+
+ if (j == n)
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (radioinfo[n].widget), TRUE);
+
+ ++j;
+ }
}
+ gtk_object_unref (GTK_OBJECT (iterator));
}
- init_html_mail (&(uiinfo[html_toggle]), info);
-
- /* Now set label of the first item to contact name */
- name_label = e_utf8_to_locale_string (e_destination_get_name (info->dest));
- 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);
-
return pop;
}
@@ -377,16 +360,13 @@ static GtkWidget *
popup_menu_list (PopupInfo *info)
{
GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT];
- GtkWidget *pop, *label;
- GList *item_children;
+ GtkWidget *pop;
const gchar *str;
- gchar *name_label, *quoted_name_label, *gs;
+ gchar *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;
@@ -397,36 +377,30 @@ popup_menu_list (PopupInfo *info)
++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);
+
+ if (card->email) {
+
+ 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) {
+ uiinfo[i].type = GNOME_APP_UI_ITEM;
+ uiinfo[i].label = "";
+ ++i;
+ ++subcount;
+ }
+ }
+ if (e_iterator_is_valid (iterator)) {
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);
+ uiinfo[i].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);
+
+ uiinfo[i].type = GNOME_APP_UI_SEPARATOR;
++i;
- }
- uiinfo[i].type = GNOME_APP_UI_SEPARATOR;
- ++i;
+ gtk_object_unref (GTK_OBJECT (iterator));
+ }
uiinfo[i].type = GNOME_APP_UI_ITEM;
uiinfo[i].label = N_("Edit Contact List");
@@ -443,26 +417,36 @@ popup_menu_list (PopupInfo *info)
pop = gnome_popup_menu_new (uiinfo);
- /* Now set label of the first item to contact name */
+ /* Now set labels properly. */
+
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"));
+ if (!(str && *str))
+ str = _("Unnamed Contact List");
+ set_uiinfo_label (&(uiinfo[0]), str);
+
+ if (card->email) {
+
+ iterator = e_list_get_iterator (card->email);
+ i = 2;
+ 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);
+ set_uiinfo_label (&(uiinfo[i]), e_destination_get_address (subdest));
+ ++i;
+ gtk_object_unref (GTK_OBJECT (subdest));
+ }
+ }
+ if (e_iterator_is_valid (iterator)) {
+ gs = g_strdup_printf (N_("(%d not shown)"), e_list_length (card->email) - max_subcount);
+ set_uiinfo_label (&(uiinfo[i]), gs);
+ g_free (gs);
+ }
+
+ gtk_object_unref (GTK_OBJECT (iterator));
}
- 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;
}
@@ -478,10 +462,8 @@ popup_menu_nocard (PopupInfo *info)
{
GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT];
gint i=0;
- GtkWidget *pop, *label;
- GList *item_children;
+ GtkWidget *pop;
const gchar *str;
- gchar *name_label, *quoted_name_label;
gint html_toggle;
memset (uiinfo, 0, sizeof (uiinfo));
@@ -519,20 +501,12 @@ popup_menu_nocard (PopupInfo *info)
/* Now set label of the first item to contact name */
str = e_destination_get_name (info->dest);
- if (str == NULL)
+ if (! (str && *str))
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"));
- }
- 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);
+ if (! (str && *str))
+ str = _("Unnamed Contact");
+
+ set_uiinfo_label (&(uiinfo[0]), str);
return pop;
}
to 2.27.2.kwm2009-05-277-19/+21 * Update to 2.27.2.kwm2009-05-278-26/+65 * Update to 2.27.2.kwm2009-05-272-6/+7 * Update to 2.27.2.kwm2009-05-272-5/+7 * Update to 2.27.2.kwm2009-05-275-41/+11 * Update to 2.27.2.kwm2009-05-274-0/+143 * Update to 5.27.2.kwm2009-05-274-8/+11 * Update to 2.15.1.kwm2009-05-272-5/+5 * Drop gnomevfs gstreamer plugin, depend only on plugins.kwm2009-05-262-9/+3 * Chase libgdata lib bump.kwm2009-05-261-3/+3 * Chase the webkit shared lib version.marcus2009-05-251-3/+3 * Chase the webkit shared lib version.marcus2009-05-256-15/+15 * Update to 1.1.7.marcus2009-05-258-17/+51 * Update to 1.7.2.marcus2009-05-253-9/+9 * Optimize the check for an existing GEOM object and correct a nearby memorymarcus2009-05-242-17/+28 * Update to 2.27.1.1.marcus2009-05-244-0/+620 * Sync with FreeBSD ports.marcus2009-05-245-28/+35 * Add a missing dependency on lcms.marcus2009-05-221-3/+4 * Sync with FreeBSD ports.marcus2009-05-191-2/+2 * This port isn't required to be in MarcusCom.marcus2009-05-172-61/+0 * Chase the poppler shared lib version.marcus2009-05-173-0/+43 * Update to 0.11.0.marcus2009-05-1714-0/+522 * Update to 0.5.12.marcus2009-05-1746-0/+4379 * Remove the leftover DOCSDIR.marcus2009-05-142-2/+3 * Remove some files which no longer exist.marcus2009-05-142-4/+2 * Apparently, we no longer need py-elementtree.marcus2009-05-141-5/+9 * Fix the pkg-config installation path.marcus2009-05-141-3/+3 * Readd removed file.kwm2009-05-132-1/+3 * Correct swfdec detection.kwm2009-05-131-2/+2 * Fix build by teaching configure to look for swfdec 0.9.kwm2009-05-121-2/+6 * Add some leftover files to the plist.marcus2009-05-122-2/+8 * Clean up some leftover directories.marcus2009-05-122-1/+4 * Use MAKE_JOBS_SAFE.kwm2009-05-112-15/+14 * Remove, FreeBSD port was updated.kwm2009-05-1110-1271/+0 * Remove, FreeBSD ports was updated.kwm2009-05-115-270/+0 * Fix the EVO_VERSION.marcus2009-05-111-2/+3 * Chase the swfdec shared library version.marcus2009-05-114-0/+140 * Add a missing dependency on libcanberra.marcus2009-05-111-1/+4 * Add a missing dependency on libcanberra.marcus2009-05-111-2/+4 * Add a missing dependency on libsoup.marcus2009-05-111-2/+4 * Add a missing file to the plist.marcus2009-05-112-0/+2 * Re-add the patches which were left out in the 2.17.0 update.marcus2009-05-119-2/+101 * Chase webkit lib dump.kwm2009-05-1037-0/+3233 * Fix the build by making sure the generated totem-docs.h file ismarcus2009-05-101-0/+11 * This patch is no longer required.marcus2009-05-101-13/+0 * Add the missing pkg-descr file.marcus2009-05-101-0/+17 * Chase the webkit shared lib version.marcus2009-05-105-0/+204 * Reset $FreeBSD$kwm2009-05-103-4/+4 * Rerolled tarballs with tar -L.kwm2009-05-102-6/+6 * Update to 2.27.1.kwm2009-05-108-0/+720 * Update to 0.10.22.6.kwm2009-05-109-0/+1254 * Update to 0.10.22.4.kwm2009-05-105-0/+270 * Reset the $FreeBSD$ tag.marcus2009-05-101-2/+2 * Presenting GNOME 2.27.1 for FreeBSD.marcus2009-05-104-0/+134 * Update to 2.27.1.marcus2009-05-106-0/+382 * Update to 2.27.1.kwm2009-05-084-0/+147 * Update to 2.27.1.marcus2009-05-084-0/+179 * Update to 2.27.1.kwm2009-05-085-0/+1442 * Update to 2.27.1.kwm2009-05-087-0/+2710 * Update to 0.9.0 git snapshot.kwm2009-05-084-0/+75 * Update to 0.9.3 git snapshot.kwm2009-05-084-0/+125 * Update to 2.27.1.marcus2009-05-084-0/+127 * Update to 2.27.1.marcus2009-05-088-0/+844 * Update to 2.27.1.marcus2009-05-088-0/+418 * Update to 2.27.1.marcus2009-05-084-0/+507 * Update to 2.27.1.marcus2009-05-084-0/+499 * Update to 2.27.1.kwm2009-05-075-0/+326 * Update to 2.27.1.0.kwm2009-05-0713-0/+1583 * Update to 2.27.1.kwm2009-05-074-0/+171 * Update to 2.27.1.kwm2009-05-0710-0/+868 * Update to 2.27.1.kwm2009-05-0713-0/+2796 * Update to 2.27.1.kwm2009-05-074-0/+294 * Update to 2.27.1.kwm2009-05-075-0/+588 * Update to 2.27.1.kwm2009-05-066-0/+227 * Update to 2.27.1.kwm2009-05-065-0/+247 * Update to 2.27.1.kwm2009-05-064-0/+1095 * Update to 2.27.1.kwm2009-05-068-0/+1029 * Update to 1.7.1.kwm2009-05-064-0/+393 * Update to 3.27.1.kwm2009-05-064-0/+206 * Update to 2.27.1.kwm2009-05-0613-0/+3747 * Update to 2.27.1.kwm2009-05-064-0/+255 * Update to 5.27.1.kwm2009-05-065-0/+357 * Update to 2.17.0.kwm2009-05-064-0/+861 * Update to 2.21.0.marcus2009-05-0628-0/+1033 * Update to 2.27.2.kwm2009-05-0418-0/+859 * Update to 2.27.1.kwm2009-05-044-0/+208 * Add entry for epiphany-webkit -> epiphanykwm2009-05-041-0/+1 * Update to 2.27.1.kwm2009-05-045-0/+181 * Update to 2.15.0.kwm2009-05-046-0/+865 * Update to 2.17.0.kwm2009-05-046-0/+233 * Update to 2.27.1.kwm2009-05-045-0/+365 * Update to 2.27.1.kwm2009-05-045-0/+552 * Update to 1.1.6.kwm2009-05-046-0/+258 * Update to 2.27.0.kwm2009-05-036-0/+346 * Remove this port now that miwi has assumed control of Gecko. Yay for miwi!marcus2009-04-1425-1896/+0 * Sync with FreeBSD ports.marcus2009-04-141-2/+2 * Remove these ports now that they are in FreeBSD ports.marcus2009-04-1177-6274/+0 * Remove these ports now that they have been merged into FreeBSD ports.marcus2009-04-11