diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-19 05:10:23 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-19 05:10:23 +0800 |
commit | 0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf (patch) | |
tree | facfeee294e47aab5fc57c0c86aa0dea96d13f16 /addressbook/gui/component | |
parent | 979203663083ef89f678dc1e95bc0c9b24f55a9e (diff) | |
download | gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar.gz gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar.bz2 gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar.lz gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar.xz gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.tar.zst gsoc2013-evolution-0c27b4ab1b75a29a0ea2b2c6ae3a568663179bdf.zip |
Finally got the "Current View" menu under control.
svn path=/branches/kill-bonobo/; revision=36380
Diffstat (limited to 'addressbook/gui/component')
-rw-r--r-- | addressbook/gui/component/e-book-shell-view-actions.c | 27 | ||||
-rw-r--r-- | addressbook/gui/component/e-book-shell-view-private.c | 51 |
2 files changed, 65 insertions, 13 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index 814b69d82c..9a26608d84 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -385,6 +385,23 @@ action_contact_send_message_cb (GtkAction *action, } static void +action_gal_save_custom_view_cb (GtkAction *action, + EBookShellView *book_shell_view) +{ + EShellView *shell_view; + EAddressbookView *address_view; + GalViewInstance *view_instance; + + shell_view = E_SHELL_VIEW (book_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + + address_view = e_book_shell_view_get_current_view (book_shell_view); + view_instance = e_addressbook_view_get_view_instance (address_view); + gal_view_instance_save_as (view_instance); +} + +static void action_search_execute_cb (GtkAction *action, EBookShellView *book_shell_view) { @@ -741,6 +758,10 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) g_object_set (action, "short-label", _("Delete"), NULL); g_signal_connect ( + ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", + G_CALLBACK (action_gal_save_custom_view_cb), book_shell_view); + + g_signal_connect ( ACTION (SEARCH_EXECUTE), "activate", G_CALLBACK (action_search_execute_cb), book_shell_view); } @@ -775,8 +796,10 @@ e_book_shell_view_actions_update (EBookShellView *book_shell_view) editable = e_addressbook_model_get_editable (model); selection_model = e_addressbook_view_get_selection_model (view); - n_contacts = e_selection_model_row_count (selection_model); - n_selected = e_selection_model_selected_count (selection_model); + 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); diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index ce995a1859..94bc96588a 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -99,6 +99,7 @@ selection_change (EBookShellView *book_shell_view, EAddressbookView *current_view; ESelectionModel *selection_model; EABContactDisplay *display; + gint n_selected; current_view = e_book_shell_view_get_current_view (book_shell_view); @@ -110,7 +111,10 @@ selection_change (EBookShellView *book_shell_view, display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); selection_model = e_addressbook_view_get_selection_model (view); - if (e_selection_model_selected_count (selection_model) == 1) + n_selected = (selection_model != NULL) ? + e_selection_model_selected_count (selection_model) : 0; + + if (n_selected == 1) e_selection_model_foreach ( selection_model, (EForeachFunc) book_shell_view_selection_change_foreach, @@ -181,28 +185,25 @@ static void book_shell_view_activate_selected_source (EBookShellView *book_shell_view, ESourceSelector *selector) { + EShellView *shell_view; EAddressbookView *view; EAddressbookModel *model; ESource *source; + GalViewInstance *view_instance; GHashTable *hash_table; GtkNotebook *notebook; GtkWidget *widget; const gchar *uid; + gchar *view_id; gint page_num; + shell_view = E_SHELL_VIEW (book_shell_view); notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook); source = e_source_selector_peek_primary_selection (selector); if (source == NULL) return; - /* XXX Add some get/set functions to EAddressbookView: - * - * eab_view_get_book() / eab_view_set_book() - * eab_view_get_type() / eab_view_set_type() - * eab_view_get_source() / eab_view_set_source() - */ - uid = e_source_peek_uid (source); hash_table = book_shell_view->priv->uid_to_view; widget = g_hash_table_lookup (hash_table, uid); @@ -225,13 +226,10 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, } } else { - EShellView *shell_view; EBook *book; /* Create a view for this UID. */ - shell_view = E_SHELL_VIEW (book_shell_view); widget = e_addressbook_view_new (shell_view, source); - g_object_set (widget, "type", E_ADDRESSBOOK_VIEW_TABLE, NULL); gtk_widget_show (widget); g_object_ref_sink (widget); @@ -275,6 +273,11 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, page_num = gtk_notebook_page_num (notebook, widget); gtk_notebook_set_current_page (notebook, page_num); + view_instance = e_addressbook_view_get_view_instance (view); + view_id = gal_view_instance_get_current_view_id (view_instance); + e_shell_view_set_view_id (shell_view, view_id); + g_free (view_id); + e_addressbook_model_force_folder_bar_message (model); selection_change (book_shell_view, view); } @@ -367,6 +370,28 @@ book_shell_view_load_view_collection (EShellViewClass *shell_view_class) gal_view_collection_load (collection); } +static void +book_shell_view_notify_view_id_cb (EBookShellView *book_shell_view) +{ + EAddressbookView *address_view; + GalViewInstance *view_instance; + const gchar *view_id; + + address_view = e_book_shell_view_get_current_view (book_shell_view); + view_instance = e_addressbook_view_get_view_instance (address_view); + view_id = e_shell_view_get_view_id (E_SHELL_VIEW (book_shell_view)); + + /* A NULL view ID implies we're in a custom view. But you can + * only get to a custom view via the "Define Views" dialog, which + * would have already modified the view instance appropriately. + * Furthermore, there's no way to refer to a custom view by ID + * anyway, since custom views have no IDs. */ + if (view_id == NULL) + return; + + gal_view_instance_set_current_view_id (view_instance, view_id); +} + void e_book_shell_view_private_init (EBookShellView *book_shell_view, EShellViewClass *shell_view_class) @@ -399,6 +424,10 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view, if (!gal_view_collection_loaded (shell_view_class->view_collection)) book_shell_view_load_view_collection (shell_view_class); + + g_signal_connect ( + book_shell_view, "notify::view-id", + G_CALLBACK (book_shell_view_notify_view_id_cb), NULL); } void |