aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/e-book-shell-view-private.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/component/e-book-shell-view-private.c')
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c219
1 files changed, 130 insertions, 89 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index 037ef035bf..530d3fd1ed 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -20,14 +20,17 @@
#include "e-book-shell-view-private.h"
+#include <gal-view-factory-etable.h>
+#include <gal-view-factory-minicard.h>
+
#include <addressbook.h>
static void
-set_status_message (EABView *view,
+set_status_message (EAddressbookView *view,
const gchar *message,
EBookShellView *book_shell_view)
{
- /* XXX Give EABView an EShellView pointer
+ /* XXX Give EAddressbookView an EShellView pointer
* and have it handle this directly. */
EActivityHandler *activity_handler;
@@ -53,39 +56,20 @@ set_status_message (EABView *view,
}
static void
-search_result (EABView *view,
- EBookViewStatus status,
- EBookShellView *book_shell_view)
+preview_contact (EBookShellView *book_shell_view,
+ EContact *contact,
+ EAddressbookView *view)
{
- /* XXX Give EABView an EShellView pointer
- * and have it handle this directly. */
-
- eab_search_result_dialog (NULL /* XXX */, status);
-}
-
-static void
-set_folder_bar_message (EABView *view,
- const gchar *message,
- EBookShellView *book_shell_view)
-{
- /* XXX Give EABView an EShellView pointer
- * and have it handle this directly. */
-
- EShellView *shell_view;
- EShellSidebar *shell_sidebar;
- EABView *current_view;
- const gchar *name;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
+ EAddressbookView *current_view;
current_view = e_book_shell_view_get_current_view (book_shell_view);
- if (view != current_view || view->source == NULL)
+
+ if (view != current_view)
return;
- name = e_source_peek_name (view->source);
- shell_sidebar = e_shell_view_get_sidebar (shell_view);
- e_shell_sidebar_set_primary_text (shell_sidebar, name);
- e_shell_sidebar_set_secondary_text (shell_sidebar, message);
+ eab_contact_display_render (
+ EAB_CONTACT_DISPLAY (book_shell_view->priv->preview),
+ contact, EAB_CONTACT_DISPLAY_RENDER_NORMAL);
}
static void
@@ -93,42 +77,44 @@ book_open_cb (EBook *book,
EBookStatus status,
gpointer user_data)
{
- EABView *view = user_data;
+ EAddressbookView *view = user_data;
+ EAddressbookModel *model;
ESource *source;
source = e_book_get_source (book);
+ model = e_addressbook_view_get_model (view);
- /* We always set the "source" property on the EABView
+ /* We always set the "source" property on the EAddressbookView
* since we use it to reload a previously failed book. */
g_object_set (view, "source", source, NULL);
if (status == E_BOOK_ERROR_OK) {
- g_object_set (view, "book", book, NULL);
- if (view->model)
- eab_model_force_folder_bar_message (view->model);
+ e_addressbook_model_set_book (model, book);
+ e_addressbook_model_force_folder_bar_message (model);
} else if (status != E_BOOK_ERROR_CANCELLED)
eab_load_error_dialog (NULL /* XXX */, source, status);
}
static void
-book_shell_view_activate_selected_source (EBookShellView *book_shell_view)
+book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
+ ESourceSelector *selector)
{
+ EAddressbookView *view;
+ EAddressbookModel *model;
ESource *source;
- ESourceSelector *selector;
GHashTable *hash_table;
GtkNotebook *notebook;
- GtkWidget *uid_view;
+ GtkWidget *widget;
const gchar *uid;
gint page_num;
notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook);
- selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector);
source = e_source_selector_peek_primary_selection (selector);
if (source == NULL)
return;
- /* XXX Add some get/set functions to EABView:
+ /* XXX Add some get/set functions to EAddressbookView:
*
* eab_view_get_book() / eab_view_set_book()
* eab_view_get_type() / eab_view_set_type()
@@ -137,20 +123,22 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view)
uid = e_source_peek_uid (source);
hash_table = book_shell_view->priv->uid_to_view;
- uid_view = g_hash_table_lookup (hash_table, uid);
+ widget = g_hash_table_lookup (hash_table, uid);
- if (uid_view != NULL) {
+ if (widget != NULL) {
EBook *book;
/* There is a view for this UID. Make sure the view
* actually contains an EBook. The absence of an EBook
* suggests a previous load failed, so try again. */
- g_object_get (uid_view, "book", &book, NULL);
+ view = E_ADDRESSBOOK_VIEW (widget);
+ model = e_addressbook_view_get_model (view);
+ book = e_addressbook_model_get_book (model);
if (book != NULL)
g_object_unref (book);
else {
- g_object_get (uid_view, "source", &source, NULL);
+ g_object_get (view, "source", &source, NULL);
/* Source can be NULL if a previous load
* has not yet reached book_open_cb(). */
@@ -158,52 +146,52 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view)
book = e_book_new (source, NULL);
if (book != NULL)
- addressbook_load (book, book_open_cb, uid_view);
+ addressbook_load (book, book_open_cb, view);
g_object_unref (source);
}
}
} else {
+ EShellView *shell_view;
EBook *book;
/* Create a view for this UID. */
- uid_view = eab_view_new ();
- g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL);
- gtk_widget_show (uid_view);
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ widget = e_addressbook_view_new (shell_view);
+ g_object_set (widget, "type", E_ADDRESSBOOK_VIEW_TABLE, NULL);
+ gtk_widget_show (widget);
- g_object_ref_sink (uid_view);
- gtk_notebook_append_page (notebook, uid_view, NULL);
- g_hash_table_insert (hash_table, g_strdup (uid), uid_view);
+ g_object_ref_sink (widget);
+ gtk_notebook_append_page (notebook, widget, NULL);
+ g_hash_table_insert (hash_table, g_strdup (uid), widget);
g_signal_connect (
- uid_view, "status-message",
+ widget, "status-message",
G_CALLBACK (set_status_message), book_shell_view);
- g_signal_connect (
- uid_view, "search-result",
- G_CALLBACK (search_result), book_shell_view);
-
- g_signal_connect (
- uid_view, "folder-bar-message",
- G_CALLBACK (set_folder_bar_message), book_shell_view);
-
g_signal_connect_swapped (
- uid_view, "command-state-change",
+ widget, "command-state-change",
G_CALLBACK (e_book_shell_view_actions_update),
book_shell_view);
+ g_signal_connect_swapped (
+ widget, "preview-contact",
+ G_CALLBACK (preview_contact), book_shell_view);
+
book = e_book_new (source, NULL);
if (book != NULL)
- addressbook_load (book, book_open_cb, uid_view);
+ addressbook_load (book, book_open_cb, widget);
+
+ view = E_ADDRESSBOOK_VIEW (widget);
+ model = e_addressbook_view_get_model (view);
}
- page_num = gtk_notebook_page_num (notebook, uid_view);
+ page_num = gtk_notebook_page_num (notebook, widget);
gtk_notebook_set_current_page (notebook, page_num);
- if (EAB_VIEW (uid_view)->model)
- eab_model_force_folder_bar_message (EAB_VIEW (uid_view)->model);
+ e_addressbook_model_force_folder_bar_message (model);
}
static gboolean
@@ -274,10 +262,34 @@ book_shell_view_selector_key_press_event_cb (EShellView *shell_view,
}
static void
-book_shell_view_primary_selection_changed_cb (EBookShellView *book_shell_view,
- ESourceSelector *selector)
+book_shell_view_load_view_collection (EShellViewClass *shell_view_class)
{
- book_shell_view_activate_selected_source (book_shell_view);
+ GalViewCollection *collection;
+ GalViewFactory *factory;
+ ETableSpecification *spec;
+ const gchar *base_dir;
+ gchar *filename;
+
+ collection = shell_view_class->view_collection;
+
+ base_dir = EVOLUTION_ETSPECDIR;
+ spec = e_table_specification_new ();
+ filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL);
+ if (!e_table_specification_load_from_file (spec, filename))
+ g_critical ("Unable to load ETable specification file "
+ "for address book");
+ g_free (filename);
+
+ factory = gal_view_factory_etable_new (spec);
+ gal_view_collection_add_factory (collection, factory);
+ g_object_unref (factory);
+ g_object_unref (spec);
+
+ factory = gal_view_factory_minicard_new ();
+ gal_view_collection_add_factory (collection, factory);
+ g_object_unref (factory);
+
+ gal_view_collection_load (collection);
}
void
@@ -309,6 +321,9 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view,
priv->activity_handler = e_activity_handler_new ();
priv->uid_to_view = uid_to_view;
priv->uid_to_editor = uid_to_editor;
+
+ if (!gal_view_collection_loaded (shell_view_class->view_collection))
+ book_shell_view_load_view_collection (shell_view_class);
}
void
@@ -319,64 +334,81 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
EShellSidebar *shell_sidebar;
EShellTaskbar *shell_taskbar;
EShellView *shell_view;
+ EShellWindow *shell_window;
+ ESourceSelector *selector;
+ GConfBridge *bridge;
GtkWidget *container;
GtkWidget *widget;
+ GObject *object;
+ const gchar *key;
shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
/* Construct view widgets. */
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ container = GTK_WIDGET (shell_content);
+
+ widget = gtk_vpaned_new ();
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ priv->paned = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
widget = gtk_notebook_new ();
- shell_content = e_shell_view_get_content (shell_view);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- gtk_container_add (GTK_CONTAINER (shell_content), widget);
+ gtk_paned_add1 (GTK_PANED (container), widget);
priv->notebook = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_scrolled_window_new (NULL, NULL);
- shell_sidebar = e_shell_view_get_sidebar (shell_view);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (shell_sidebar), widget);
+ gtk_paned_add2 (GTK_PANED (container), widget);
gtk_widget_show (widget);
- shell_taskbar = e_shell_view_get_taskbar (shell_view);
- e_activity_handler_attach_task_bar (
- priv->activity_handler, shell_taskbar);
-
container = widget;
- widget = e_addressbook_selector_new (priv->source_list);
- e_source_selector_show_selection (E_SOURCE_SELECTOR (widget), FALSE);
+ widget = eab_contact_display_new ();
gtk_container_add (GTK_CONTAINER (container), widget);
- priv->selector = g_object_ref (widget);
+ priv->preview = g_object_ref (widget);
gtk_widget_show (widget);
+ shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
+ e_activity_handler_attach_task_bar (
+ priv->activity_handler, shell_taskbar);
+
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ selector = e_book_shell_sidebar_get_selector (
+ E_BOOK_SHELL_SIDEBAR (shell_sidebar));
+
g_signal_connect_swapped (
- widget, "button-press-event",
+ selector, "button-press-event",
G_CALLBACK (book_shell_view_selector_button_press_event_cb),
book_shell_view);
g_signal_connect_swapped (
- widget, "key-press-event",
+ selector, "key-press-event",
G_CALLBACK (book_shell_view_selector_key_press_event_cb),
book_shell_view);
g_signal_connect_swapped (
- widget, "popup-menu",
+ selector, "popup-menu",
G_CALLBACK (book_shell_view_selector_popup_menu_cb),
book_shell_view);
g_signal_connect_swapped (
- widget, "primary-selection-changed",
- G_CALLBACK (book_shell_view_primary_selection_changed_cb),
+ selector, "primary-selection-changed",
+ G_CALLBACK (book_shell_view_activate_selected_source),
book_shell_view);
- book_shell_view_activate_selected_source (book_shell_view);
+ book_shell_view_activate_selected_source (book_shell_view, selector);
e_categories_register_change_listener (
G_CALLBACK (book_shell_view_categories_changed_cb),
@@ -384,6 +416,14 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
e_book_shell_view_actions_init (book_shell_view);
e_book_shell_view_update_search_filter (book_shell_view);
+
+ /* Bind GObject properties to GConf keys. */
+
+ bridge = gconf_bridge_get ();
+
+ object = G_OBJECT (ACTION (CONTACT_PREVIEW));
+ key = "/apps/evolution/addressbook/display/vpane_position";
+ gconf_bridge_bind_property_delayed (bridge, key, object, "position");
}
void
@@ -395,8 +435,9 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
DISPOSE (priv->contact_actions);
+ DISPOSE (priv->paned);
DISPOSE (priv->notebook);
- DISPOSE (priv->selector);
+ DISPOSE (priv->preview);
DISPOSE (priv->activity_handler);
@@ -417,7 +458,7 @@ e_book_shell_view_private_finalize (EBookShellView *book_shell_view)
g_free (priv->password);
}
-EABView *
+EAddressbookView *
e_book_shell_view_get_current_view (EBookShellView *book_shell_view)
{
GtkNotebook *notebook;
@@ -430,7 +471,7 @@ e_book_shell_view_get_current_view (EBookShellView *book_shell_view)
page_num = gtk_notebook_get_current_page (notebook);
widget = gtk_notebook_get_nth_page (notebook, page_num);
- return EAB_VIEW (widget);
+ return E_ADDRESSBOOK_VIEW (widget);
}
void
@@ -454,7 +495,7 @@ e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (book_shell_view);
- shell_content = e_shell_view_get_content (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
action = gtk_radio_action_new (
"category-any", _("Any Category"), NULL, NULL, -1);