From e85c9f204c37e9a2bfa4ce8d056bc475b85130d7 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 16 Feb 2013 15:51:35 -0500 Subject: EMemoShellSidebar: Remove internal client table. No longer needed, replaced by EClientCache. --- modules/calendar/e-memo-shell-sidebar.c | 121 ++++---------------------------- 1 file changed, 14 insertions(+), 107 deletions(-) (limited to 'modules/calendar') diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index bc09d90972..74942fa5fd 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -45,9 +45,6 @@ typedef struct _ConnectClosure ConnectClosure; struct _EMemoShellSidebarPrivate { GtkWidget *selector; - /* UID -> Client */ - GHashTable *client_table; - /* The default client is for ECalModel. It follows the * sidebar's primary selection, even if the highlighted * source is not selected. The tricky part is we don't @@ -139,7 +136,7 @@ memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar, static void memo_shell_sidebar_emit_client_removed (EMemoShellSidebar *memo_shell_sidebar, - ECalClient *client) + EClient *client) { guint signal_id = signals[CLIENT_REMOVED]; @@ -171,25 +168,6 @@ memo_shell_sidebar_ref_client_cache (EMemoShellSidebar *memo_shell_sidebar) return g_object_ref (e_shell_get_client_cache (shell)); } -static void -memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, - ECalClient *client) -{ - GHashTable *client_table; - ESource *source; - gchar *uid; - - client_table = memo_shell_sidebar->priv->client_table; - - source = e_client_get_source (E_CLIENT (client)); - uid = e_source_dup_uid (source); - - g_hash_table_remove (client_table, uid); - memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL); - - g_free (uid); -} - static void memo_shell_sidebar_handle_connect_error (EMemoShellSidebar *memo_shell_sidebar, const gchar *parent_display_name, @@ -505,25 +483,10 @@ memo_shell_sidebar_dispose (GObject *object) priv->loading_clients = NULL; } - g_hash_table_remove_all (priv->client_table); - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_memo_shell_sidebar_parent_class)->dispose (object); } -static void -memo_shell_sidebar_finalize (GObject *object) -{ - EMemoShellSidebarPrivate *priv; - - priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); - - g_hash_table_destroy (priv->client_table); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_memo_shell_sidebar_parent_class)->finalize (object); -} - static void memo_shell_sidebar_constructed (GObject *object) { @@ -654,21 +617,11 @@ memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar, ECalClient *client) { ESourceSelector *selector; - GHashTable *client_table; ESource *source; - const gchar *uid; - - client_table = memo_shell_sidebar->priv->client_table; - selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); - - g_signal_handlers_disconnect_matched ( - client, G_SIGNAL_MATCH_DATA, 0, 0, - NULL, NULL, memo_shell_sidebar); source = e_client_get_source (E_CLIENT (client)); - uid = e_source_get_uid (source); - g_hash_table_remove (client_table, uid); + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); e_source_selector_unselect_source (selector, source); memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL); @@ -685,7 +638,6 @@ e_memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) object_class = G_OBJECT_CLASS (class); object_class->get_property = memo_shell_sidebar_get_property; object_class->dispose = memo_shell_sidebar_dispose; - object_class->finalize = memo_shell_sidebar_finalize; object_class->constructed = memo_shell_sidebar_constructed; shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class); @@ -753,17 +705,9 @@ e_memo_shell_sidebar_class_finalize (EMemoShellSidebarClass *class) static void e_memo_shell_sidebar_init (EMemoShellSidebar *memo_shell_sidebar) { - GHashTable *client_table; - - client_table = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) g_object_unref); - memo_shell_sidebar->priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (memo_shell_sidebar); - memo_shell_sidebar->priv->client_table = client_table; memo_shell_sidebar->priv->loading_clients = g_cancellable_new (); /* Postpone widget construction until we have a shell view. */ @@ -812,28 +756,12 @@ e_memo_shell_sidebar_add_client (EMemoShellSidebar *memo_shell_sidebar, { ESource *source; ESourceSelector *selector; - GHashTable *client_table; const gchar *message; - const gchar *uid; g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); g_return_if_fail (E_IS_CAL_CLIENT (client)); - client_table = memo_shell_sidebar->priv->client_table; - source = e_client_get_source (client); - uid = e_source_get_uid (source); - - if (g_hash_table_contains (client_table, uid)) - return; - - g_hash_table_insert ( - client_table, g_strdup (uid), g_object_ref (client)); - - g_signal_connect_swapped ( - client, "backend-died", - G_CALLBACK (memo_shell_sidebar_backend_died_cb), - memo_shell_sidebar); selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); e_source_selector_select_source (selector, source); @@ -850,36 +778,14 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, { ESourceSelector *selector; EClientCache *client_cache; - GHashTable *client_table; - EClient *default_client; const gchar *display_name; - const gchar *uid; gchar *message; g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - client_table = memo_shell_sidebar->priv->client_table; - default_client = memo_shell_sidebar->priv->default_client; selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); - uid = e_source_get_uid (source); - - if (g_hash_table_contains (client_table, uid)) - return; - - if (default_client != NULL) { - ESource *default_source; - - default_source = e_client_get_source (default_client); - - if (e_source_equal (source, default_source)) { - e_memo_shell_sidebar_add_client ( - memo_shell_sidebar, default_client); - return; - } - } - e_source_selector_select_source (selector, source); display_name = e_source_get_display_name (source); @@ -904,20 +810,21 @@ void e_memo_shell_sidebar_remove_source (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { - GHashTable *client_table; - ECalClient *client; - const gchar *uid; + EClientCache *client_cache; + EClient *client; g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - client_table = memo_shell_sidebar->priv->client_table; - - uid = e_source_get_uid (source); - client = g_hash_table_lookup (client_table, uid); - - if (client == NULL) - return; + client_cache = + memo_shell_sidebar_ref_client_cache (memo_shell_sidebar); + client = e_client_cache_ref_cached_client ( + client_cache, source, E_SOURCE_EXTENSION_MEMO_LIST); + g_object_unref (client_cache); - memo_shell_sidebar_emit_client_removed (memo_shell_sidebar, client); + if (client != NULL) { + memo_shell_sidebar_emit_client_removed ( + memo_shell_sidebar, client); + g_object_unref (client); + } } -- cgit v1.2.3