From 0d8bd54b5867ccdc3e39eb5b912193046eed0c0d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 16 Feb 2013 15:44:00 -0500 Subject: ECalShellSidebar: Remove internal client table. No longer needed, replaced by EClientCache. --- modules/calendar/e-cal-shell-sidebar.c | 121 ++++----------------------------- 1 file changed, 14 insertions(+), 107 deletions(-) (limited to 'modules/calendar') diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 49245a3c31..fc6c0ddde0 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -47,9 +47,6 @@ struct _ECalShellSidebarPrivate { GtkWidget *date_navigator; GtkWidget *new_calendar_button; - /* 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 @@ -142,7 +139,7 @@ cal_shell_sidebar_emit_client_added (ECalShellSidebar *cal_shell_sidebar, static void cal_shell_sidebar_emit_client_removed (ECalShellSidebar *cal_shell_sidebar, - ECalClient *client) + EClient *client) { guint signal_id = signals[CLIENT_REMOVED]; @@ -174,25 +171,6 @@ cal_shell_sidebar_ref_client_cache (ECalShellSidebar *cal_shell_sidebar) return g_object_ref (e_shell_get_client_cache (shell)); } -static void -cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, - ECalClient *client) -{ - GHashTable *client_table; - ESource *source; - gchar *uid; - - client_table = cal_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); - cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL); - - g_free (uid); -} - static void cal_shell_sidebar_handle_connect_error (ECalShellSidebar *cal_shell_sidebar, const gchar *parent_display_name, @@ -541,25 +519,10 @@ cal_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_cal_shell_sidebar_parent_class)->dispose (object); } -static void -cal_shell_sidebar_finalize (GObject *object) -{ - ECalShellSidebarPrivate *priv; - - priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); - - g_hash_table_destroy (priv->client_table); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_cal_shell_sidebar_parent_class)->finalize (object); -} - static void cal_shell_sidebar_constructed (GObject *object) { @@ -740,21 +703,11 @@ cal_shell_sidebar_client_removed (ECalShellSidebar *cal_shell_sidebar, ECalClient *client) { ESourceSelector *selector; - GHashTable *client_table; ESource *source; - const gchar *uid; - - client_table = cal_shell_sidebar->priv->client_table; - selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); - - g_signal_handlers_disconnect_matched ( - client, G_SIGNAL_MATCH_DATA, 0, 0, - NULL, NULL, cal_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_cal_shell_sidebar_get_selector (cal_shell_sidebar); e_source_selector_unselect_source (selector, source); cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL); @@ -771,7 +724,6 @@ e_cal_shell_sidebar_class_init (ECalShellSidebarClass *class) object_class = G_OBJECT_CLASS (class); object_class->get_property = cal_shell_sidebar_get_property; object_class->dispose = cal_shell_sidebar_dispose; - object_class->finalize = cal_shell_sidebar_finalize; object_class->constructed = cal_shell_sidebar_constructed; shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class); @@ -848,17 +800,9 @@ e_cal_shell_sidebar_class_finalize (ECalShellSidebarClass *class) static void e_cal_shell_sidebar_init (ECalShellSidebar *cal_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); - cal_shell_sidebar->priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (cal_shell_sidebar); - cal_shell_sidebar->priv->client_table = client_table; cal_shell_sidebar->priv->loading_clients = g_cancellable_new (); /* Postpone widget construction until we have a shell view. */ @@ -925,28 +869,12 @@ e_cal_shell_sidebar_add_client (ECalShellSidebar *cal_shell_sidebar, { ESource *source; ESourceSelector *selector; - GHashTable *client_table; const gchar *message; - const gchar *uid; g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); g_return_if_fail (E_IS_CAL_CLIENT (client)); - client_table = cal_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 (cal_shell_sidebar_backend_died_cb), - cal_shell_sidebar); selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); e_source_selector_select_source (selector, source); @@ -963,36 +891,14 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_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_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - client_table = cal_shell_sidebar->priv->client_table; - default_client = cal_shell_sidebar->priv->default_client; selector = e_cal_shell_sidebar_get_selector (cal_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_cal_shell_sidebar_add_client ( - cal_shell_sidebar, default_client); - return; - } - } - e_source_selector_select_source (selector, source); display_name = e_source_get_display_name (source); @@ -1017,20 +923,21 @@ void e_cal_shell_sidebar_remove_source (ECalShellSidebar *cal_shell_sidebar, ESource *source) { - GHashTable *client_table; - ECalClient *client; - const gchar *uid; + EClientCache *client_cache; + EClient *client; g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - client_table = cal_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 = + cal_shell_sidebar_ref_client_cache (cal_shell_sidebar); + client = e_client_cache_ref_cached_client ( + client_cache, source, E_SOURCE_EXTENSION_CALENDAR); + g_object_unref (client_cache); - cal_shell_sidebar_emit_client_removed (cal_shell_sidebar, client); + if (client != NULL) { + cal_shell_sidebar_emit_client_removed ( + cal_shell_sidebar, client); + g_object_unref (client); + } } -- cgit v1.2.3