aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-01-11 15:24:08 +0800
committerChris Lahey <clahey@src.gnome.org>2002-01-11 15:24:08 +0800
commit5027f2008badcb8d8056190dac1403335754f202 (patch)
tree768d6583b3a3b86e104e59a828eb442907d26680
parentd17adcedf443dde2018070d868e53e75790d5936 (diff)
downloadgsoc2013-evolution-5027f2008badcb8d8056190dac1403335754f202.tar.gz
gsoc2013-evolution-5027f2008badcb8d8056190dac1403335754f202.tar.zst
gsoc2013-evolution-5027f2008badcb8d8056190dac1403335754f202.zip
Handle setting the search bar to "Advanced..." when the alphabet buttons
2002-01-11 Christopher James Lahey <clahey@ximian.com> * gui/component/addressbook.c (alphabet_state_changed): Handle setting the search bar to "Advanced..." when the alphabet buttons are pushed and back when they're cleared. Fixes Ximian bug #12904. (addressbook_menu_activated): When the user calls Search->clear, set the search to ESB_ANY and "", don't just set the text. This is especially useful when it's set to ESB_ADVANCED. * gui/widgets/e-addressbook-view.c, gui/widgets/e-addressbook-view.h (alphabet_state_change): Added this signal which gets emitted when the alphabet buttons are pushed. (command_state_change): Removed the ref pair here. It's not necessary. gtk_signal_emit refs the object itself. svn path=/trunk/; revision=15295
-rw-r--r--addressbook/ChangeLog17
-rw-r--r--addressbook/gui/component/addressbook.c40
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c35
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h8
4 files changed, 80 insertions, 20 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 055ce37e1e..64dc041ae6 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,22 @@
2002-01-11 Christopher James Lahey <clahey@ximian.com>
+ * gui/component/addressbook.c (alphabet_state_changed): Handle
+ setting the search bar to "Advanced..." when the alphabet buttons
+ are pushed and back when they're cleared. Fixes Ximian bug
+ #12904.
+ (addressbook_menu_activated): When the user calls Search->clear,
+ set the search to ESB_ANY and "", don't just set the text. This
+ is especially useful when it's set to ESB_ADVANCED.
+
+ * gui/widgets/e-addressbook-view.c,
+ gui/widgets/e-addressbook-view.h (alphabet_state_change): Added
+ this signal which gets emitted when the alphabet buttons are
+ pushed.
+ (command_state_change): Removed the ref pair here. It's not
+ necessary. gtk_signal_emit refs the object itself.
+
+2002-01-11 Christopher James Lahey <clahey@ximian.com>
+
* backend/ebook/e-card-compare.c (name_synonyms): Added a couple
of names here.
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 619a89cdd5..38d44727ed 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -66,6 +66,7 @@ typedef struct {
BonoboPropertyBag *properties;
char *uri;
char *passwd;
+ gboolean ignore_search_changes;
} AddressbookView;
static void addressbook_view_ref (AddressbookView *);
@@ -814,23 +815,28 @@ static ESearchBarItem addressbook_search_option_items[] = {
};
static void
+alphabet_state_changed (EAddressbookView *eav, gunichar letter, AddressbookView *view)
+{
+ view->ignore_search_changes = TRUE;
+ if (letter == 0) {
+ e_search_bar_set_item_id (view->search, ESB_ANY);
+ e_search_bar_set_text (view->search, "");
+ } else {
+ e_search_bar_set_item_id (view->search, ESB_ADVANCED);
+ }
+ view->ignore_search_changes = FALSE;
+}
+
+static void
addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view)
{
switch (id) {
case E_FILTERBAR_RESET_ID:
/* e_addressbook_view_show_all(view->view); */
-
- /* Fix option menu if we are using "Category is" */
- if (e_search_bar_get_item_id (esb) == ESB_CATEGORY) {
-
- e_search_bar_set_subitem_id (esb, G_MAXINT);
-
- } else {
-
- e_search_bar_set_text (esb, "");
-
- }
-
+ view->ignore_search_changes = TRUE;
+ e_search_bar_set_item_id (view->search, ESB_ANY);
+ view->ignore_search_changes = FALSE;
+ e_search_bar_set_text (esb, "");
break;
}
}
@@ -843,6 +849,10 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
const char *category_name;
int search_type, subid;
+ if (view->ignore_search_changes) {
+ return;
+ }
+
gtk_object_get(GTK_OBJECT(esb),
"text", &search_word,
"item_id", &search_type,
@@ -1070,6 +1080,7 @@ addressbook_factory_new_control (void)
view = g_new0 (AddressbookView, 1);
view->refs = 1;
+ view->ignore_search_changes = FALSE;
view->vbox = gtk_vbox_new (FALSE, 0);
@@ -1129,6 +1140,11 @@ addressbook_factory_new_control (void)
GTK_SIGNAL_FUNC(update_command_state),
view);
+ gtk_signal_connect (GTK_OBJECT (view->view),
+ "alphabet_state_change",
+ GTK_SIGNAL_FUNC(alphabet_state_changed),
+ view);
+
view->uri = NULL;
gtk_signal_connect (GTK_OBJECT (view->control), "activate",
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index a7257f5e89..a421400f3c 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -61,6 +61,8 @@
#include <gdk/gdkkeysyms.h>
#include <ctype.h>
+#define SHOW_ALL_SEARCH "(contains \"x-evolution-any-field\" \"\")"
+
static void e_addressbook_view_init (EAddressbookView *card);
static void e_addressbook_view_class_init (EAddressbookViewClass *klass);
static void e_addressbook_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
@@ -73,6 +75,7 @@ static void folder_bar_message (GtkObject *object, const gchar *status, EAddress
static void stop_state_changed (GtkObject *object, EAddressbookView *eav);
static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav);
static void command_state_change (EAddressbookView *eav);
+static void alphabet_state_change (EAddressbookView *eav, gunichar letter);
static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event,
EAddressbookView *view);
@@ -96,6 +99,7 @@ enum {
STATUS_MESSAGE,
FOLDER_BAR_MESSAGE,
COMMAND_STATE_CHANGE,
+ ALPHABET_STATE_CHANGE,
LAST_SIGNAL
};
@@ -182,6 +186,14 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
+ e_addressbook_view_signals [ALPHABET_STATE_CHANGE] =
+ gtk_signal_new ("alphabet_state_change",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EAddressbookViewClass, alphabet_state_change),
+ gtk_marshal_NONE__UINT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_UINT);
+
gtk_object_class_add_signals (object_class, e_addressbook_view_signals, LAST_SIGNAL);
if (!clipboard_atom)
@@ -217,7 +229,7 @@ e_addressbook_view_init (EAddressbookView *eav)
eav->editable = FALSE;
eav->book = NULL;
- eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ eav->query = g_strdup (SHOW_ALL_SEARCH);
eav->object = NULL;
eav->widget = NULL;
@@ -330,12 +342,18 @@ e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
"book", eav->book,
NULL);
+
break;
case ARG_QUERY:
+#if 0 /* This code will mess up ldap a bit. We need to think about the ramifications of this more. */
+ if ((GTK_VALUE_STRING (*arg) == NULL && !strcmp (eav->query, SHOW_ALL_SEARCH)) ||
+ (GTK_VALUE_STRING (*arg) != NULL && !strcmp (eav->query, GTK_VALUE_STRING (*arg))))
+ break;
+#endif
g_free(eav->query);
eav->query = g_strdup(GTK_VALUE_STRING(*arg));
if (!eav->query)
- eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ eav->query = g_strdup (SHOW_ALL_SEARCH);
gtk_object_set(GTK_OBJECT(eav->model),
"query", eav->query,
NULL);
@@ -493,13 +511,15 @@ button_toggled(GtkWidget *button, LetterClosure *closure)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current), FALSE);
jump_to_letter (view, closure->letter);
view->current_alphabet_widget = button;
+ alphabet_state_change (view, closure->letter);
} else {
if (view->current_alphabet_widget != NULL &&
view->current_alphabet_widget == button) {
view->current_alphabet_widget = NULL;
gtk_object_set (GTK_OBJECT (view),
- "query", "(contains \"x-evolution-any-field\" \"\")",
+ "query", NULL,
NULL);
+ alphabet_state_change (view, 0);
}
}
}
@@ -923,9 +943,14 @@ writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav)
static void
command_state_change (EAddressbookView *eav)
{
- gtk_object_ref (GTK_OBJECT (eav)); /* who knows what might happen during this emission? */
+ /* Reffing during emission is unnecessary. Gtk automatically refs during an emission. */
gtk_signal_emit (GTK_OBJECT (eav), e_addressbook_view_signals [COMMAND_STATE_CHANGE]);
- gtk_object_unref (GTK_OBJECT (eav));
+}
+
+static void
+alphabet_state_change (EAddressbookView *eav, gunichar letter)
+{
+ gtk_signal_emit (GTK_OBJECT (eav), e_addressbook_view_signals [ALPHABET_STATE_CHANGE], letter);
}
#ifdef JUST_FOR_TRANSLATORS
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index b3034ef3fd..d338bd9797 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -26,6 +26,7 @@
#include "e-addressbook-model.h"
#include "widgets/menus/gal-view-menus.h"
#include "addressbook/backend/ebook/e-book.h"
+#include <gal/unicode/gunicode.h>
#ifdef __cplusplus
extern "C" {
@@ -90,9 +91,10 @@ struct _EAddressbookViewClass
/*
* Signals
*/
- void (*status_message) (EAddressbookView *view, const gchar *message);
- void (*folder_bar_message) (EAddressbookView *view, const gchar *message);
- void (*command_state_change) (EAddressbookView *view);
+ void (*status_message) (EAddressbookView *view, const gchar *message);
+ void (*folder_bar_message) (EAddressbookView *view, const gchar *message);
+ void (*command_state_change) (EAddressbookView *view);
+ void (*alphabet_state_change) (EAddressbookView *view, gunichar letter);
};
GtkWidget *e_addressbook_view_new (void);