aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/e-book-shell-view-private.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-09-05 23:47:38 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-09-05 23:47:38 +0800
commiteca687589d106ff87cd4fca7bf581cb0532caf96 (patch)
treec6832474edfc52edd323a7d8d3ee5726f2b83ae3 /addressbook/gui/component/e-book-shell-view-private.c
parent8bbf952350c37970e8947b807513e58e91435998 (diff)
downloadgsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar.gz
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar.bz2
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar.lz
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar.xz
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.tar.zst
gsoc2013-evolution-eca687589d106ff87cd4fca7bf581cb0532caf96.zip
Saving progress. Lots of changes. Things are a bit broken at the moment.
svn path=/branches/kill-bonobo/; revision=36260
Diffstat (limited to 'addressbook/gui/component/e-book-shell-view-private.c')
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c220
1 files changed, 214 insertions, 6 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index 0bf0832c58..b75a8c6f60 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -20,6 +20,191 @@
#include "e-book-shell-view-private.h"
+#include <addressbook.h>
+
+static void
+set_status_message (EABView *view,
+ const gchar *message,
+ EBookShellView *book_shell_view)
+{
+ /* XXX Give EABView an EShellView pointer
+ * and have it handle this directly. */
+
+ EActivityHandler *activity_handler;
+ guint activity_id;
+
+ activity_handler = book_shell_view->priv->activity_handler;
+ activity_id = book_shell_view->priv->activity_id;
+
+ if (message == NULL || *message == '\0') {
+ if (activity_id > 0) {
+ e_activity_handler_operation_finished (
+ activity_handler, activity_id);
+ activity_id = 0;
+ }
+ } else if (activity_id == 0) {
+ gchar *client_id = g_strdup_printf ("%p", book_shell_view);
+
+ activity_id = e_activity_handler_operation_started (
+ activity_handler, client_id, message, TRUE);
+ } else
+ e_activity_handler_operation_progressing (
+ activity_handler, activity_id, message, -1.0);
+
+ book_shell_view->priv->activity_id = activity_id;
+}
+
+static void
+search_result (EABView *view,
+ EBookViewStatus status,
+ EBookShellView *book_shell_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;
+ EABView *current_view;
+ const gchar *name;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ current_view = e_book_shell_view_get_current_view (book_shell_view);
+ if (view != current_view || view->source == NULL)
+ return;
+
+ name = e_source_peek_name (view->source);
+
+ e_shell_view_set_primary_text (shell_view, name);
+ e_shell_view_set_secondary_text (shell_view, message);
+}
+
+static void
+book_open_cb (EBook *book,
+ EBookStatus status,
+ gpointer user_data)
+{
+ EABView *view = user_data;
+ ESource *source;
+
+ source = e_book_get_source (book);
+
+ /* We always set the "source" property on the EABView
+ * 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);
+ } 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)
+{
+ ESource *source;
+ ESourceSelector *selector;
+ GHashTable *hash_table;
+ GtkNotebook *notebook;
+ GtkWidget *uid_view;
+ 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:
+ *
+ * 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;
+ uid_view = g_hash_table_lookup (hash_table, uid);
+
+ if (uid_view != 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);
+
+ if (book != NULL)
+ g_object_unref (book);
+ else {
+ g_object_get (uid_view, "source", &source, NULL);
+
+ /* Source can be NULL if a previous load
+ * has not yet reached book_open_cb(). */
+ if (source != NULL) {
+ book = e_book_new (source, NULL);
+
+ if (book != NULL)
+ addressbook_load (book, book_open_cb, uid_view);
+
+ g_object_unref (source);
+ }
+ }
+
+ } else {
+ 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);
+
+ gtk_notebook_append_page (notebook, uid_view, NULL);
+ g_hash_table_insert (hash_table, g_strdup (uid), uid_view);
+
+ g_signal_connect (
+ uid_view, "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",
+ G_CALLBACK (e_book_shell_view_update_actions),
+ book_shell_view);
+
+ book = e_book_new (source, NULL);
+
+ if (book != NULL)
+ addressbook_load (book, book_open_cb, uid_view);
+ }
+
+ page_num = gtk_notebook_page_num (notebook, uid_view);
+ 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);
+}
+
static gboolean
book_shell_view_show_popup_menu (GdkEventButton *event,
EShellView *shell_view)
@@ -48,6 +233,8 @@ static gboolean
book_shell_view_selector_button_press_event_cb (EShellView *shell_view,
GdkEventButton *event)
{
+ /* XXX Use ESourceSelector's "popup-event" signal instead. */
+
if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
return book_shell_view_show_popup_menu (event, shell_view);
@@ -57,6 +244,8 @@ book_shell_view_selector_button_press_event_cb (EShellView *shell_view,
static gboolean
book_shell_view_selector_popup_menu_cb (EShellView *shell_view)
{
+ /* XXX Use ESourceSelector's "popup-event" signal instead. */
+
return book_shell_view_show_popup_menu (NULL, shell_view);
}
@@ -77,15 +266,25 @@ book_shell_view_selector_key_press_event_cb (EShellView *shell_view,
return FALSE;
}
+static void
+book_shell_view_primary_selection_changed_cb (EBookShellView *book_shell_view,
+ ESourceSelector *selector)
+{
+ book_shell_view_activate_selected_source (book_shell_view);
+}
+
void
e_book_shell_view_private_init (EBookShellView *book_shell_view)
{
EBookShellViewPrivate *priv = book_shell_view->priv;
+ EShellView *shell_view;
GHashTable *uid_to_view;
GHashTable *uid_to_editor;
GtkWidget *container;
GtkWidget *widget;
+ shell_view = E_SHELL_VIEW (book_shell_view);
+
uid_to_view = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
@@ -103,30 +302,32 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
e_book_get_addressbooks (&priv->source_list, NULL);
+ /* Construct view widgets. */
+
widget = gtk_notebook_new ();
+ container = e_shell_view_get_content_widget (shell_view);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- priv->notebook = g_object_ref_sink (widget);
+ gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
- widget = e_task_bar_new ();
+ widget = e_shell_view_get_taskbar_widget (shell_view);
e_activity_handler_attach_task_bar (
priv->activity_handler, E_TASK_BAR (widget));
- priv->task_bar = g_object_ref (widget);
- gtk_widget_show (widget);
widget = gtk_scrolled_window_new (NULL, NULL);
+ container = e_shell_view_get_sidebar_widget (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);
- priv->scrolled_window = g_object_ref_sink (widget);
+ gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
container = widget;
- widget = e_source_selector_new (priv->source_list);
+ widget = e_addressbook_selector_new (priv->source_list);
e_source_selector_show_selection (E_SOURCE_SELECTOR (widget), FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
priv->selector = g_object_ref (widget);
@@ -146,6 +347,13 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
widget, "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),
+ book_shell_view);
+
+ book_shell_view_activate_selected_source (book_shell_view);
}
void