aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-10-04 12:46:50 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-10-04 12:46:50 +0800
commit2c71859895d091f51dea23f9ed9552a0962b7ba4 (patch)
tree0b5e24581de31595b494e9c1b359d487ad1f3f48 /addressbook
parentff5e0b312d04daf97b35616b55280ae7f2d17cf7 (diff)
downloadgsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar.gz
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar.bz2
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar.lz
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar.xz
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.tar.zst
gsoc2013-evolution-2c71859895d091f51dea23f9ed9552a0962b7ba4.zip
Tweak some aspects of the Contacts module to be more consistent with
Tasks and Memos. Take a crack at handling command-line URIs. It's far too long-winded though. Will need to revisit and tighten up the code. svn path=/branches/kill-bonobo/; revision=36554
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.c208
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c106
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.h2
-rw-r--r--addressbook/gui/component/e-book-shell-view.c126
4 files changed, 230 insertions, 212 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c
index b9b03b4342..8ade5e6805 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.c
+++ b/addressbook/gui/component/e-book-shell-view-actions.c
@@ -463,93 +463,7 @@ static void
action_search_execute_cb (GtkAction *action,
EBookShellView *book_shell_view)
{
- EBookShellContent *book_shell_content;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GString *string;
- EAddressbookView *view;
- EAddressbookModel *model;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- gchar *query;
- gint value;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- shell_content = e_shell_view_get_shell_content (shell_view);
- text = e_shell_content_get_search_text (shell_content);
-
- shell_window = e_shell_view_get_shell_window (shell_view);
- action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
- value = gtk_radio_action_get_current_value (
- GTK_RADIO_ACTION (action));
-
- if (text == NULL || *text == '\0') {
- text = "";
- value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
- }
-
- switch (value) {
- case CONTACT_SEARCH_NAME_CONTAINS:
- format = "(contains \"full_name\" %s)";
- break;
-
- case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
- format = "(beginswith \"email\" %s)";
- break;
-
- default:
- text = "";
- /* fall through */
-
- case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
- format = "(contains \"x-evolution-any-field\" %s)";
- break;
- }
-
- /* Build the query. */
- string = g_string_new ("");
- e_sexp_encode_string (string, text);
- query = g_strdup_printf (format, string->str);
- g_string_free (string, TRUE);
-
- /* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
- if (value > CONTACT_FILTER_ANY_CATEGORY) {
- GList *categories;
- const gchar *category_name;
- gchar *temp;
-
- categories = e_categories_get_list ();
- category_name = g_list_nth_data (categories, value);
- g_list_free (categories);
-
- temp = g_strdup_printf (
- "(and (is \"category_list\" \"%s\") %s)",
- category_name, query);
- g_free (query);
- query = temp;
- }
-
- /* XXX This is wrong. We need to programmatically construct a
- * FilterRule, tell it to build code, and pass the resulting
- * expression string to EAddressbookModel. */
- rule = filter_rule_new ();
- e_shell_content_set_search_rule (shell_content, rule);
- g_object_unref (rule);
-
- /* Submit the query. */
- book_shell_content = book_shell_view->priv->book_shell_content;
- view = e_book_shell_content_get_current_view (book_shell_content);
- model = e_addressbook_view_get_model (view);
- e_addressbook_model_set_query (model, query);
- g_free (query);
-
- e_book_shell_content_set_preview_contact (book_shell_content, NULL);
+ e_book_shell_view_execute_search (book_shell_view);
}
static void
@@ -856,126 +770,6 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
}
void
-e_book_shell_view_actions_update (EBookShellView *book_shell_view)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- EAddressbookModel *model;
- EAddressbookView *view;
- EBookShellContent *book_shell_content;
- EBookShellSidebar *book_shell_sidebar;
- ESelectionModel *selection_model;
- ESourceSelector *selector;
- ESource *source;
- GtkAction *action;
- const gchar *label;
- gboolean editable;
- gboolean sensitive;
- gint n_contacts;
- gint n_selected;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- book_shell_content = book_shell_view->priv->book_shell_content;
- view = e_book_shell_content_get_current_view (book_shell_content);
-
- book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
- selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
-
- model = e_addressbook_view_get_model (view);
- editable = e_addressbook_model_get_editable (model);
-
- selection_model = e_addressbook_view_get_selection_model (view);
- n_contacts = (selection_model != NULL) ?
- e_selection_model_row_count (selection_model) : 0;
- n_selected = (selection_model != NULL) ?
- e_selection_model_selected_count (selection_model) : 0;
-
- action = ACTION (ADDRESS_BOOK_STOP);
- sensitive = e_addressbook_model_can_stop (model);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_COPY);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_CUT);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_PASTE);
- sensitive = editable;
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_COPY);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_DELETE);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_FORWARD);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
- label = ngettext (
- "_Forward Contact",
- "_Forward Contacts", n_selected);
- g_object_set (action, "label", label, NULL);
-
- action = ACTION (CONTACT_MOVE);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_OPEN);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_PRINT);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_PRINT_PREVIEW);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_SAVE_AS);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_SELECT_ALL);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- /* FIXME Also check for email address. */
- action = ACTION (CONTACT_SEND_MESSAGE);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
- label = ngettext (
- "_Send Message to Contact",
- "_Send Message to Contacts", n_selected);
- g_object_set (action, "label", label, NULL);
-
- /* TODO Add some context sensitivity to SEND_MESSAGE:
- * Send Message to Contact (n_selected == 1)
- * Send Message to Contacts (n_selected > 1)
- * Send Message to List (n_selected == 1 && is_list)
- */
-
- action = ACTION (ADDRESS_BOOK_DELETE);
- if (source != NULL) {
- const gchar *uri;
-
- uri = e_source_peek_relative_uri (source);
- sensitive = (uri == NULL || strcmp ("system", uri) != 0);
- } else
- sensitive = FALSE;
- gtk_action_set_sensitive (action, sensitive);
-}
-
-void
e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
{
EShellContent *shell_content;
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index af8f199799..bbabb6d1cd 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -36,7 +36,6 @@ popup_event (EBookShellView *book_shell_view,
widget_path = "/contact-popup";
shell_view = E_SHELL_VIEW (book_shell_view);
- e_book_shell_view_actions_update (book_shell_view);
e_shell_view_show_popup_menu (shell_view, widget_path, event);
}
@@ -68,15 +67,17 @@ selection_change (EBookShellView *book_shell_view,
EBookShellContent *book_shell_content;
EAddressbookView *current_view;
ESelectionModel *selection_model;
+ EShellView *shell_view;
gint n_selected;
+ shell_view = E_SHELL_VIEW (shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
current_view = e_book_shell_content_get_current_view (book_shell_content);
if (view != current_view)
return;
- e_book_shell_view_actions_update (book_shell_view);
+ e_shell_view_update_actions (shell_view);
selection_model = e_addressbook_view_get_selection_model (view);
@@ -219,7 +220,7 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
g_signal_connect_swapped (
widget, "command-state-change",
- G_CALLBACK (e_book_shell_view_actions_update),
+ G_CALLBACK (e_shell_view_update_actions),
book_shell_view);
g_signal_connect_swapped (
@@ -475,6 +476,105 @@ e_book_shell_view_private_finalize (EBookShellView *book_shell_view)
}
void
+e_book_shell_view_execute_search (EBookShellView *book_shell_view)
+{
+ EBookShellContent *book_shell_content;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ GtkAction *action;
+ GString *string;
+ EAddressbookView *view;
+ EAddressbookModel *model;
+ FilterRule *rule;
+ const gchar *format;
+ const gchar *text;
+ gchar *query;
+ gchar *temp;
+ gint value;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ text = e_shell_content_get_search_text (shell_content);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
+ value = gtk_radio_action_get_current_value (
+ GTK_RADIO_ACTION (action));
+
+ if (text == NULL || *text == '\0') {
+ text = "";
+ value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
+ }
+
+ switch (value) {
+ case CONTACT_SEARCH_NAME_CONTAINS:
+ format = "(contains \"full_name\" %s)";
+ break;
+
+ case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
+ format = "(beginswith \"email\" %s)";
+ break;
+
+ default:
+ text = "";
+ /* fall through */
+
+ case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
+ format = "(contains \"x-evolution-any-field\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, text);
+ query = g_strdup_printf (format, string->str);
+ g_string_free (string, TRUE);
+
+ /* Apply selected filter. */
+ value = e_shell_content_get_filter_value (shell_content);
+ switch (value) {
+ case CONTACT_FILTER_ANY_CATEGORY:
+ break;
+
+ default:
+ {
+ GList *categories;
+ const gchar *category_name;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (is \"category_list\" \"%s\") %s)",
+ category_name, query);
+ g_free (query);
+ query = temp;
+ }
+ }
+
+ /* XXX This is wrong. We need to programmatically construct a
+ * FilterRule, tell it to build code, and pass the resulting
+ * expression string to EAddressbookModel. */
+ rule = filter_rule_new ();
+ e_shell_content_set_search_rule (shell_content, rule);
+ g_object_unref (rule);
+
+ /* Submit the query. */
+ book_shell_content = book_shell_view->priv->book_shell_content;
+ view = e_book_shell_content_get_current_view (book_shell_content);
+ model = e_addressbook_view_get_model (view);
+ e_addressbook_model_set_query (model, query);
+ g_free (query);
+
+ e_book_shell_content_set_preview_contact (book_shell_content, NULL);
+}
+
+void
e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
GObject *where_the_object_was)
{
diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h
index f0250a5687..0d7fd706f6 100644
--- a/addressbook/gui/component/e-book-shell-view-private.h
+++ b/addressbook/gui/component/e-book-shell-view-private.h
@@ -120,7 +120,7 @@ void e_book_shell_view_private_finalize
void e_book_shell_view_actions_init
(EBookShellView *book_shell_view);
-void e_book_shell_view_actions_update
+void e_book_shell_view_execute_search
(EBookShellView *book_shell_view);
void e_book_shell_view_editor_weak_notify
(EditorUidClosure *closure,
diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c
index d6fe16c0d3..05b7f91f30 100644
--- a/addressbook/gui/component/e-book-shell-view.c
+++ b/addressbook/gui/component/e-book-shell-view.c
@@ -35,8 +35,10 @@ book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view,
{
EBookShellViewPrivate *priv = book_shell_view->priv;
EBookShellContent *book_shell_content;
+ EShellView *shell_view;
GList *keys, *iter;
+ shell_view = E_SHELL_VIEW (book_shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
keys = g_hash_table_get_keys (priv->uid_to_view);
@@ -74,7 +76,7 @@ book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view,
}
g_list_free (keys);
- e_book_shell_view_actions_update (book_shell_view);
+ e_shell_view_update_actions (shell_view);
}
static void
@@ -131,6 +133,127 @@ book_shell_view_constructed (GObject *object)
}
static void
+book_shell_view_update_actions (EShellView *shell_view)
+{
+ EBookShellViewPrivate *priv;
+ EBookShellContent *book_shell_content;
+ EBookShellSidebar *book_shell_sidebar;
+ EShellWindow *shell_window;
+ EAddressbookModel *model;
+ EAddressbookView *view;
+ ESelectionModel *selection_model;
+ ESourceSelector *selector;
+ ESource *source;
+ GtkAction *action;
+ const gchar *label;
+ gboolean editable;
+ gboolean sensitive;
+ gint n_contacts;
+ gint n_selected;
+
+ priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ book_shell_content = priv->book_shell_content;
+ view = e_book_shell_content_get_current_view (book_shell_content);
+
+ book_shell_sidebar = priv->book_shell_sidebar;
+ selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+
+ model = e_addressbook_view_get_model (view);
+ editable = e_addressbook_model_get_editable (model);
+
+ selection_model = e_addressbook_view_get_selection_model (view);
+ n_contacts = (selection_model != NULL) ?
+ e_selection_model_row_count (selection_model) : 0;
+ n_selected = (selection_model != NULL) ?
+ e_selection_model_selected_count (selection_model) : 0;
+
+ action = ACTION (ADDRESS_BOOK_STOP);
+ sensitive = e_addressbook_model_can_stop (model);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_COPY);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_CUT);
+ sensitive = editable && (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_PASTE);
+ sensitive = editable;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_COPY);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_DELETE);
+ sensitive = editable && (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_FORWARD);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+ label = ngettext (
+ "_Forward Contact",
+ "_Forward Contacts", n_selected);
+ g_object_set (action, "label", label, NULL);
+
+ action = ACTION (CONTACT_MOVE);
+ sensitive = editable && (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_OPEN);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_PRINT);
+ sensitive = (n_contacts > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_PRINT_PREVIEW);
+ sensitive = (n_contacts > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_SAVE_AS);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_SELECT_ALL);
+ sensitive = (n_contacts > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ /* FIXME Also check for email address. */
+ action = ACTION (CONTACT_SEND_MESSAGE);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+ label = ngettext (
+ "_Send Message to Contact",
+ "_Send Message to Contacts", n_selected);
+ g_object_set (action, "label", label, NULL);
+
+ /* TODO Add some context sensitivity to SEND_MESSAGE:
+ * Send Message to Contact (n_selected == 1)
+ * Send Message to Contacts (n_selected > 1)
+ * Send Message to List (n_selected == 1 && is_list)
+ */
+
+ action = ACTION (ADDRESS_BOOK_DELETE);
+ if (source != NULL) {
+ const gchar *uri;
+
+ uri = e_source_peek_relative_uri (source);
+ sensitive = (uri == NULL || strcmp ("system", uri) != 0);
+ } else
+ sensitive = FALSE;
+ gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
book_shell_view_class_init (EBookShellViewClass *class,
GTypeModule *type_module)
{
@@ -155,6 +278,7 @@ book_shell_view_class_init (EBookShellViewClass *class,
shell_view_class->type_module = type_module;
shell_view_class->new_shell_content = e_book_shell_content_new;
shell_view_class->new_shell_sidebar = e_book_shell_sidebar_new;
+ shell_view_class->update_actions = book_shell_view_update_actions;
g_object_class_install_property (
object_class,