void e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, const gchar *status_message, gdouble percent) { EActivity *activity; EShellView *shell_view; EShellBackend *shell_backend; g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); activity = task_shell_view->priv->activity; shell_view = E_SHELL_VIEW (task_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); if (status_message == NULL || *status_message == '\0') { if (activity != NULL) { e_activity_set_state (activity, E_ACTIVITY_COMPLETED); g_object_unref (activity); activity = NULL; } } else if (activity == NULL) { activity = e_activity_new (); e_activity_set_percent (activity, percent); e_activity_set_text (activity, status_message); e_shell_backend_add_activity (shell_backend, activity); } else { e_activity_set_percent (activity, percent); e_activity_set_text (activity, status_message); } task_shell_view->priv->activity = activity; }
static void action_calendar_taskpad_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { EShell *shell; EShellView *shell_view; EShellWindow *shell_window; EShellBackend *shell_backend; ECalShellContent *cal_shell_content; ECalModelComponent *comp_data; ETaskTable *task_table; EActivity *activity; GSList *list; GFile *file; gchar *string; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell = e_shell_window_get_shell (shell_window); cal_shell_content = cal_shell_view->priv->cal_shell_content; task_table = e_cal_shell_content_get_task_table (cal_shell_content); list = e_task_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); /* Translators: Default filename part saving a task to a file when * no summary is filed, the '.ics' extension is concatenated to it. */ string = icalcomp_suggest_filename (comp_data->icalcomp, _("task")); file = e_shell_run_save_dialog ( shell, _("Save as iCalendar"), string, "*.ics:text/calendar", NULL, NULL); g_free (string); if (file == NULL) return; string = e_cal_client_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert task to a string"); g_object_unref (file); return; } /* XXX No callback means errors are discarded. */ activity = e_file_replace_contents_async ( file, string, strlen (string), NULL, FALSE, G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); e_shell_backend_add_activity (shell_backend, activity); /* Free the string when the activity is finalized. */ g_object_set_data_full ( G_OBJECT (activity), "file-content", string, (GDestroyNotify) g_free); g_object_unref (file); }
static void action_contact_save_as_cb (GtkAction *action, EBookShellView *book_shell_view) { EShell *shell; EShellView *shell_view; EShellWindow *shell_window; EShellBackend *shell_backend; EBookShellContent *book_shell_content; EAddressbookView *view; EActivity *activity; GSList *list; GFile *file; gchar *string; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell = e_shell_window_get_shell (shell_window); book_shell_content = book_shell_view->priv->book_shell_content; view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); list = e_addressbook_view_get_selected (view); if (list == NULL) goto exit; string = eab_suggest_filename (list); file = e_shell_run_save_dialog ( /* Translators: This is a save dialog title */ shell, _("Save as vCard"), string, "*.vcf:text/x-vcard,text/directory", NULL, NULL); g_free (string); if (file == NULL) goto exit; string = eab_contact_list_to_string (list); if (string == NULL) { g_warning ("Could not convert contact list to a string"); g_object_unref (file); goto exit; } /* XXX No callback means errors are discarded. * * There's an EAlert for this which I'm not using * until I figure out a better way to display errors: * * "addressbook:save-error" */ activity = e_file_replace_contents_async ( file, string, strlen (string), NULL, FALSE, G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); e_shell_backend_add_activity (shell_backend, activity); /* Free the string when the activity is finalized. */ g_object_set_data_full ( G_OBJECT (activity), "file-content", string, (GDestroyNotify) g_free); g_object_unref (file); exit: e_client_util_free_object_slist (list); }
static void action_address_book_refresh_cb (GtkAction *action, EBookShellView *book_shell_view) { EBookShellSidebar *book_shell_sidebar; ESourceSelector *selector; EClient *client = NULL; ESource *source; EActivity *activity; EAlertSink *alert_sink; EShellBackend *shell_backend; EShellContent *shell_content; EShellView *shell_view; EShell *shell; GCancellable *cancellable; book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); shell_view = E_SHELL_VIEW (book_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell = e_shell_backend_get_shell (shell_backend); source = e_source_selector_ref_primary_selection (selector); if (source != NULL) { client = e_client_selector_ref_cached_client ( E_CLIENT_SELECTOR (selector), source); if (!client) { ESource *primary; e_shell_allow_auth_prompt_for (shell, source); primary = e_source_selector_ref_primary_selection (selector); if (primary == source) e_source_selector_set_primary_selection (selector, source); g_clear_object (&primary); } g_object_unref (source); } if (client == NULL) return; g_return_if_fail (e_client_check_refresh_supported (client)); alert_sink = E_ALERT_SINK (shell_content); activity = e_activity_new (); cancellable = g_cancellable_new (); e_activity_set_alert_sink (activity, alert_sink); e_activity_set_cancellable (activity, cancellable); e_shell_allow_auth_prompt_for (shell, source); e_client_refresh (client, cancellable, address_book_refresh_done_cb, activity); e_shell_backend_add_activity (shell_backend, activity); g_object_unref (cancellable); g_object_unref (client); }