aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-12-01 09:59:29 +0800
committerChris Lahey <clahey@src.gnome.org>2001-12-01 09:59:29 +0800
commit7094e925a6b2c7556a395e120d5514c0abef8d0b (patch)
treec0de5061ff0d288dd042dde054444d76cd58a9bd
parent3270da024215ea9ae0949375a479bb4f474c2858 (diff)
downloadgsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar.gz
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar.bz2
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar.lz
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar.xz
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.tar.zst
gsoc2013-evolution-7094e925a6b2c7556a395e120d5514c0abef8d0b.zip
Merging fixes:
2001-11-28 Christopher James Lahey <clahey@ximian.com> * gui/component/addressbook.c (connect_master_list_changed, make_suboptions): Changed how this list of categories gets computed. Fixes Ximian bugs #7707 and #7708. svn path=/trunk/; revision=14838
-rw-r--r--addressbook/ChangeLog6
-rw-r--r--addressbook/gui/component/addressbook.c110
2 files changed, 79 insertions, 37 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index f8eafff421..f1bb09dffb 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-28 Christopher James Lahey <clahey@ximian.com>
+
+ * gui/component/addressbook.c (connect_master_list_changed,
+ make_suboptions): Changed how this list of categories gets
+ computed. Fixes Ximian bugs #7707 and #7708.
+
2001-11-15 Zbigniew Chyla <cyba@gnome.pl>
* printing/e-contact-print-envelope.c (ecpe_linelist_dimensions),
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 10ef247d06..4741e5196a 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -59,6 +59,7 @@ typedef struct {
gint refs;
EAddressbookView *view;
ESearchBar *search;
+ gint ecml_changed_id;
GtkWidget *vbox;
EvolutionActivityClient *activity;
BonoboControl *control;
@@ -419,6 +420,16 @@ addressbook_view_unref (AddressbookView *view)
g_free (view);
}
+static ECategoriesMasterList *
+get_master_list (void)
+{
+ static ECategoriesMasterList *category_list = NULL;
+
+ if (category_list == NULL)
+ category_list = e_categories_master_list_wombat_new ();
+ return category_list;
+}
+
static void
addressbook_view_clear (AddressbookView *view)
{
@@ -449,6 +460,12 @@ addressbook_view_clear (AddressbookView *view)
if (view->refs == 0)
g_free(view);
+
+ if (view->ecml_changed_id != 0) {
+ gtk_signal_disconnect (GTK_OBJECT(get_master_list()),
+ view->ecml_changed_id);
+ view->ecml_changed_id = 0;
+ }
}
static void
@@ -813,16 +830,6 @@ addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view)
}
}
-static ECategoriesMasterList *
-get_master_list (void)
-{
- static ECategoriesMasterList *category_list = NULL;
-
- if (category_list == NULL)
- category_list = e_categories_master_list_wombat_new ();
- return category_list;
-}
-
static void
addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
{
@@ -994,6 +1001,59 @@ addressbook_config_database (CORBA_Environment *ev)
return config_db;
}
+static int
+compare_subitems (const void *a, const void *b)
+{
+ const ESearchBarSubitem *subitem_a = a;
+ const ESearchBarSubitem *subitem_b = b;
+
+ return strcoll (subitem_a->text, subitem_b->text);
+}
+
+static void
+make_suboptions (AddressbookView *view)
+{
+ ESearchBarSubitem *subitems;
+ ECategoriesMasterList *master_list;
+ gint i, N;
+
+ master_list = get_master_list ();
+ N = e_categories_master_list_count (master_list);
+ subitems = g_new (ESearchBarSubitem, N+2);
+
+ subitems[0].id = G_MAXINT;
+ subitems[0].text = g_strdup (_("Any Category"));
+ subitems[0].translate = FALSE;
+
+ for (i=0; i<N; ++i) {
+ const char *category = e_categories_master_list_nth (master_list, i);
+
+ subitems[i+1].id = i;
+ subitems[i+1].text = e_utf8_to_locale_string (category);
+ subitems[i+1].translate = FALSE;
+ }
+ subitems[N+1].id = -1;
+ subitems[N+1].text = NULL;
+
+ qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems);
+
+ e_search_bar_set_suboption (view->search, ESB_CATEGORY, subitems);
+}
+
+static void
+ecml_changed (ECategoriesMasterList *ecml, AddressbookView *view)
+{
+ make_suboptions (view);
+}
+
+static void
+connect_master_list_changed (AddressbookView *view)
+{
+ view->ecml_changed_id =
+ gtk_signal_connect (GTK_OBJECT (get_master_list()), "changed",
+ GTK_SIGNAL_FUNC (ecml_changed), view);
+}
+
BonoboControl *
addressbook_factory_new_control (void)
{
@@ -1015,35 +1075,11 @@ addressbook_factory_new_control (void)
/* Create the control. */
view->control = bonobo_control_new (view->vbox);
- /* We attach subitems to the "Category is" item, so that we get an option menu of categories. */
- if (addressbook_search_option_items[ESB_CATEGORY].subitems == NULL) {
- ESearchBarSubitem *subitems;
- ECategoriesMasterList *master_list;
- gint i, N;
-
- g_assert (addressbook_search_option_items[ESB_CATEGORY].id == ESB_CATEGORY); /* sanity check */
-
- master_list = get_master_list ();
- N = e_categories_master_list_count (master_list);
- addressbook_search_option_items[ESB_CATEGORY].subitems = subitems = g_new (ESearchBarSubitem, N+2);
-
- subitems[0].id = G_MAXINT;
- subitems[0].text = g_strdup (_("Any Category"));
- subitems[0].translate = FALSE;
-
- for (i=0; i<N; ++i) {
- const char *category = e_categories_master_list_nth (master_list, i);
-
- subitems[i+1].id = i;
- subitems[i+1].text = e_utf8_to_locale_string (category);
- subitems[i+1].translate = FALSE;
- }
- subitems[N+1].id = -1;
- subitems[N+1].text = NULL;
- }
-
view->search = E_SEARCH_BAR(e_search_bar_new(addressbook_search_menu_items,
addressbook_search_option_items));
+ make_suboptions (view);
+ connect_master_list_changed (view);
+
gtk_box_pack_start (GTK_BOX (view->vbox), GTK_WIDGET (view->search),
FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (view->search), "query_changed",