From 7c02582ae70e45d58bf0966d60e23b50f854a06a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 22 Jan 2010 17:14:47 -0500 Subject: Remove a bunch of dead code in GnomeCalendar. --- calendar/gui/gnome-cal.c | 417 ---------------------------- calendar/gui/gnome-cal.h | 8 - modules/calendar/e-cal-shell-view-private.c | 24 -- 3 files changed, 449 deletions(-) diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index c1b321f781..987d3dad9c 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -78,10 +78,6 @@ struct _GnomeCalendarPrivate { ECalModel *model; - /* The clients for display */ - GHashTable *clients; - ECal *default_client; - /* * Fields for the calendar view */ @@ -165,8 +161,6 @@ static gboolean gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, G static void update_todo_view (GnomeCalendar *gcal); static void update_memo_view (GnomeCalendar *gcal); -static void default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal); -static void client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal); /* Simple asynchronous message dispatcher */ typedef struct _Message Message; @@ -1365,8 +1359,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv = g_new0 (GnomeCalendarPrivate, 1); gcal->priv = priv; - priv->clients = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - if (non_intrusive_error_table == NULL) non_intrusive_error_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); @@ -1420,18 +1412,6 @@ gnome_calendar_destroy (GtkObject *object) priv->model = NULL; } - g_hash_table_destroy (priv->clients); - - priv->clients = NULL; - - if (priv->default_client) { - g_signal_handlers_disconnect_matched (priv->default_client, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, gcal); - g_object_unref (priv->default_client); - } - priv->default_client = NULL; - for (l = priv->notifications; l; l = l->next) calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); g_list_free (priv->notifications); @@ -1820,299 +1800,12 @@ gnome_calendar_display_view (GnomeCalendar *gcal, } -struct _mclient_msg { - Message header; - ECalModel *model; - ECal *client; -}; - -static void -add_mclient_async (struct _mclient_msg *msg) -{ - e_cal_model_add_client (msg->model, msg->client); - - g_object_unref (msg->client); - g_object_unref (msg->model); - g_slice_free (struct _mclient_msg, msg); -} - -static void -add_mclient (ECalModel *model, ECal *client) -{ - struct _mclient_msg *msg; - - msg = g_slice_new0 (struct _mclient_msg); - msg->header.func = (MessageFunc) add_mclient_async; - msg->model = g_object_ref (model); - msg->client = g_object_ref (client); - - message_push ((Message *) msg); -} - static void non_intrusive_error_remove(GtkWidget *w, gpointer data) { g_hash_table_remove(non_intrusive_error_table, data); } -static void -client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) -{ - GnomeCalendarPrivate *priv; - ESource *source; - ECalModel *model; - ECalLoadState state; - gchar *msg; - GtkWidget *w = NULL; - gpointer parent; - gchar *id; - - priv = gcal->priv; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal)); - parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - - source = e_cal_get_source (ecal); - state = e_cal_get_load_state (ecal); - - if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED) - e_auth_cal_forget_password (ecal); - - switch (status) { - case E_CALENDAR_STATUS_OK: - break; - case E_CALENDAR_STATUS_BUSY: - if (state == E_CAL_LOAD_NOT_LOADED) - e_cal_open_async (ecal, FALSE); - else - gcal_update_status_message (gcal, NULL, -1); - return; - case E_CALENDAR_STATUS_INVALID_SERVER_VERSION: - id = g_strdup ("calendar:server-version"); - - if (g_hash_table_lookup(non_intrusive_error_table, id)) { - /* We already have it */ - g_message("Error occurred while existing dialog active:\n"); - gcal_update_status_message (gcal, NULL, -1); - return; - } - - w = e_alert_dialog_new_for_args (parent, "calendar:server-version", NULL); - /*e_calendar_utils_show_error_silent (w); KILL-BONOBO */ - g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w)); - g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id); - - break; - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED: - /* try to reopen calendar - it'll ask for a password once again */ - e_cal_open_async (ecal, FALSE); - return; - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: - /* check to see if we have dialog already running for this operation */ - id = g_strdup ("calendar:unable-to-load-the-calendar"); - - if (g_hash_table_lookup(non_intrusive_error_table, id)) { - /* We already have it */ - g_message("Error occurred while existing dialog active:\n"); - gcal_update_status_message (gcal, NULL, -1); - return; - } - - w = e_alert_dialog_new_for_args (parent, "calendar:unable-to-load-the-calendar", e_cal_get_error_message (status), NULL); - /*e_calendar_utils_show_error_silent (w); KILL-BONOBO */ - g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w)); - g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id); - default: - /* Make sure the source doesn't disappear on us */ - g_object_ref (source); - - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - g_signal_emit (gcal, signals[SOURCE_REMOVED], 0, source); - g_object_unref (source); - - g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status)); - gcal_update_status_message (gcal, NULL, -1); - - return; - } - - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL); - - msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal)); - gcal_update_status_message (gcal, msg, -1); - g_free (msg); - - /* add client to the views */ - model = gnome_calendar_get_model (gcal); - add_mclient (model, ecal); - - /* update date navigator query */ - gnome_calendar_update_query (gcal); - - gcal_update_status_message (gcal, NULL, -1); -} - -static void -default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) -{ - GnomeCalendarPrivate *priv; - ESource *source; - ECalLoadState state; - ECalModel *model; - - priv = gcal->priv; - - source = e_cal_get_source (ecal); - state = e_cal_get_load_state (ecal); - - if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED) - e_auth_cal_forget_password (ecal); - - switch (status) { - case E_CALENDAR_STATUS_OK: - break; - case E_CALENDAR_STATUS_BUSY: - if (state == E_CAL_LOAD_NOT_LOADED) - e_cal_open_async (ecal, FALSE); - else - gcal_update_status_message (gcal, NULL, -1.0); - return; - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED: - /* try to reopen calendar - it'll ask for a password once again */ - e_cal_open_async (ecal, FALSE); - return; - case E_CALENDAR_STATUS_INVALID_SERVER_VERSION: - e_alert_run_dialog_for_args (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:server-version", NULL); - default: - /* Make sure the source doesn't disappear on us */ - g_object_ref (source); - - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal); - - /* FIXME should we do this to prevent multiple error dialogs? */ - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - /* FIXME Is there a better way to handle this? */ - if (priv->default_client) - g_object_unref (priv->default_client); - priv->default_client = NULL; - - g_signal_emit (gcal, signals[SOURCE_REMOVED], 0, source); - g_object_unref (source); - - g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status)); - gcal_update_status_message (gcal, NULL, -1.0); - - return; - } - - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, default_client_cal_opened_cb, NULL); - - model = gnome_calendar_get_model (gcal); - e_cal_model_set_default_client (model, ecal); - gcal_update_status_message (gcal, NULL, -1.0); -} - -typedef void (*open_func) (ECal *, ECalendarStatus, GnomeCalendar *); - -static gboolean -open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of) -{ - gchar *msg; - icaltimezone *zone; - - zone = calendar_config_get_icaltimezone (); - e_cal_set_default_timezone (cal, zone, NULL); - - msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal)); - gcal_update_status_message (gcal, msg, -1.0); - - g_free (msg); - - g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), gcal); - e_cal_open_async (cal, only_if_exists); - - return TRUE; -} - -/* Callback when we get an error message from the backend */ -static void -backend_error_cb (ECal *client, const gchar *message, gpointer data) -{ - GnomeCalendar *gcal; - GtkDialog *dialog; - gpointer parent; - gchar *uristr; - gchar *id; - - gcal = GNOME_CALENDAR (data); - - parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal)); - parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - - uristr = get_uri_without_password (e_cal_get_uri (client)); - id = g_strdup ("calendar:error-on-loading-the-calendar"); - - if (g_hash_table_lookup(non_intrusive_error_table,id)) { - /* We already have it */ - g_message("Error occurred while existing dialog active:\n"); - return; - } - - dialog = (GtkDialog *)e_alert_new(parent, "calendar:error-on-loading-the-calendar", uristr, message, NULL); - /* e_calendar_utils_show_error_silent(GTK_WIDGET (dialog)); KILL-BONOBO */ - - g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(dialog)); - g_signal_connect(GTK_WIDGET (dialog), "destroy", G_CALLBACK(non_intrusive_error_remove), id); - - g_free (uristr); -} - -/* Callback when the backend dies */ -static void -backend_died_cb (ECal *ecal, gpointer data) -{ - GnomeCalendar *gcal; - GnomeCalendarPrivate *priv; - ESource *source; - gpointer parent; - const gchar *id; - GtkWidget *w = NULL; - - gcal = GNOME_CALENDAR (data); - priv = gcal->priv; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal)); - parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - - /* FIXME What about default sources? */ - - /* Make sure the source doesn't go away on us since we use it below */ - source = g_object_ref (e_cal_get_source (ecal)); - - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - id = g_strdup ("calendar:calendar-crashed"); - - gcal_update_status_message (gcal, NULL, -1); - - g_signal_emit (gcal, signals[SOURCE_REMOVED], 0, source); - - g_object_unref (source); - - if (g_hash_table_lookup(non_intrusive_error_table,id)) { - /* We already have it */ - g_message("Error occurred while existing dialog active:\n"); - return; - } - - w = e_alert_dialog_new_for_args (parent, "calendar:backend_died", NULL); - /* e_calendar_utils_show_error_silent (w); KILL-BONOBO */ - g_hash_table_insert (non_intrusive_error_table, (gpointer) id, g_object_ref(w)); - g_signal_connect((GtkObject *)w, "destroy", G_CALLBACK(non_intrusive_error_remove), (gpointer) id); -} - GtkWidget * gnome_calendar_new (EShellSettings *shell_settings) { @@ -2177,116 +1870,6 @@ gnome_calendar_get_model (GnomeCalendar *gcal) return gcal->priv->model; } -/** - * gnome_calendar_remove_source - * @gcal: A #GnomeCalendar. - * @source: #ESource to be removed from the clients. - * - * Removes the given source from the list of clients being shown by the - * calendar views. - * - * Returns: TRUE if successful, FALSE otherwise. - */ -gboolean -gnome_calendar_remove_source (GnomeCalendar *gcal, ESource *source) -{ - gboolean result; - - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); - - result = gnome_calendar_remove_source_by_uid (gcal, e_source_peek_uid (source)); - if (result) - g_signal_emit (gcal, signals[SOURCE_REMOVED], 0, source); - - return result; -} - -gboolean -gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, const gchar *uid) -{ - GnomeCalendarPrivate *priv; - ECal *client; - ECalModel *model; - GList *l; - - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - - priv = gcal->priv; - - client = g_hash_table_lookup (priv->clients, uid); - if (!client) - return TRUE; - - g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, gcal); - - /* remove the query for this client */ - for (l = priv->dn_queries; l != NULL; l = l->next) { - ECalView *query = l->data; - - if (query && (client == e_cal_view_get_client (query))) { - g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, gcal); - priv->dn_queries = g_list_remove (priv->dn_queries, query); - g_object_unref (query); - break; - } - } - - model = gnome_calendar_get_model (gcal); - e_cal_model_remove_client (model, client); - - /* update date navigator query */ - gnome_calendar_update_query (gcal); - - g_hash_table_remove (priv->clients, uid); - - return TRUE; -} - -/** - * gnome_calendar_set_default_source: - * @gcal: A calendar view - * @source: The #ESource to use as default - * - * Set the default uri on the given calendar view, the default uri - * will be used as the default when creating events in the view. - - * - * Return value: TRUE if the uri was already added and is set, FALSE - * otherwise - **/ -gboolean -gnome_calendar_set_default_source (GnomeCalendar *gcal, ESource *source) -{ - GnomeCalendarPrivate *priv; - ECal *client; - - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); - - priv = gcal->priv; - - client = g_hash_table_lookup (priv->clients, e_source_peek_uid (source)); - - if (priv->default_client) - g_object_unref (priv->default_client); - - if (client) { - priv->default_client = g_object_ref (client); - } else { - priv->default_client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT); - if (!priv->default_client) - return FALSE; - } - - open_ecal (gcal, priv->default_client, FALSE, default_client_cal_opened_cb); - - return TRUE; -} - gboolean gnome_calendar_get_range_selected (GnomeCalendar *gcal) { diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 5703b99811..91d80f0c20 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -122,14 +122,6 @@ void gnome_calendar_set_date_navigator (GnomeCalendar *gcal, ECalendar *date_navigator); ECalModel * gnome_calendar_get_model (GnomeCalendar *gcal); -gboolean gnome_calendar_remove_source (GnomeCalendar *gcal, - ESource *source); -gboolean gnome_calendar_remove_source_by_uid - (GnomeCalendar *gcal, - const gchar *uid); -gboolean gnome_calendar_set_default_source - (GnomeCalendar *gcal, - ESource *source); void gnome_calendar_update_query (GnomeCalendar *gcal); void gnome_calendar_set_search_query (GnomeCalendar *gcal, const gchar *sexp, diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 0a12f73743..74a2bbcaf5 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -265,25 +265,6 @@ cal_shell_view_selector_popup_event_cb (EShellView *shell_view, return TRUE; } -static void -cal_shell_view_selector_primary_changed_cb (ECalShellView *cal_shell_view, - ESourceSelector *selector) -{ - ECalShellContent *cal_shell_content; - GnomeCalendar *calendar; - ESource *source; - - /* XXX ESourceSelector -really- needs a "primary-selection" - * ESource property. Then we could just use EBindings. */ - - cal_shell_content = cal_shell_view->priv->cal_shell_content; - calendar = e_cal_shell_content_get_calendar (cal_shell_content); - source = e_source_selector_peek_primary_selection (selector); - - if (source != NULL) - gnome_calendar_set_default_source (calendar, source); -} - static void cal_shell_view_selector_client_added_cb (ECalShellView *cal_shell_view, ECal *client) @@ -536,11 +517,6 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) G_CALLBACK (cal_shell_view_selector_popup_event_cb), cal_shell_view); - g_signal_connect_swapped ( - selector, "primary-selection-changed", - G_CALLBACK (cal_shell_view_selector_primary_changed_cb), - cal_shell_view); - g_signal_connect_swapped ( cal_shell_sidebar, "client-added", G_CALLBACK (cal_shell_view_selector_client_added_cb), -- cgit v1.2.3