static void action_save_cb (GtkAction *action, EMsgComposer *composer) { EHTMLEditor *editor; EHTMLEditorView *view; const gchar *filename; gint fd; GError *error = NULL; editor = e_msg_composer_get_editor (composer); filename = e_html_editor_get_filename (editor); if (filename == NULL) { gtk_action_activate (ACTION (SAVE_AS)); return; } /* Check if the file already exists and we can create it. */ fd = g_open (filename, O_RDONLY | O_CREAT | O_EXCL, 0777); if (fd < 0) { gint errno_saved = errno; if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { gint response; response = e_alert_run_dialog_for_args ( GTK_WINDOW (composer), E_ALERT_ASK_FILE_EXISTS_OVERWRITE, filename, NULL); if (response != GTK_RESPONSE_OK) return; } else { e_alert_submit ( E_ALERT_SINK (composer), E_ALERT_NO_SAVE_FILE, filename, g_strerror (errno_saved), NULL); return; } } else close (fd); if (!e_html_editor_save (editor, filename, TRUE, &error)) { e_alert_submit ( E_ALERT_SINK (composer), E_ALERT_NO_SAVE_FILE, filename, error->message, NULL); g_error_free (error); return; } view = e_html_editor_get_view (editor); e_html_editor_view_set_changed (view, TRUE); }
/** * e_shell_utils_find_alternate_alert_sink: * @widget: a #GtkWidget for which to do the search * * Search an alternate #EAlertSink in the widget hierarchy up-wards * from the @widget (skipping the @widget itself). * * Returns: (nullable) (transfer none): an alert sink, different than @widget, * or %NULL, when none found * * Since: 3.24 **/ EAlertSink * e_shell_utils_find_alternate_alert_sink (GtkWidget *widget) { g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); while (widget = gtk_widget_get_parent (widget), widget) { if (E_IS_ALERT_SINK (widget)) return E_ALERT_SINK (widget); } return NULL; }
static void cal_shell_view_backend_error_cb (EClientCache *client_cache, EClient *client, EAlert *alert, ECalShellView *cal_shell_view) { ECalShellContent *cal_shell_content; ESource *source; const gchar *extension_name; cal_shell_content = cal_shell_view->priv->cal_shell_content; source = e_client_get_source (client); extension_name = E_SOURCE_EXTENSION_CALENDAR; /* Only submit alerts from calendar backends. */ if (e_source_has_extension (source, extension_name)) { EAlertSink *alert_sink; alert_sink = E_ALERT_SINK (cal_shell_content); e_alert_sink_submit_alert (alert_sink, alert); } }
static void task_shell_view_backend_error_cb (EClientCache *client_cache, EClient *client, EAlert *alert, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; ESource *source; const gchar *extension_name; task_shell_content = task_shell_view->priv->task_shell_content; source = e_client_get_source (client); extension_name = E_SOURCE_EXTENSION_TASK_LIST; /* Only submit alerts from task list backends. */ if (e_source_has_extension (source, extension_name)) { EAlertSink *alert_sink; alert_sink = E_ALERT_SINK (task_shell_content); e_alert_sink_submit_alert (alert_sink, alert); } }
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); }
static gboolean report_error_to_ui_cb (gpointer user_data) { struct ReportErrorToUIData *data = user_data; EShellView *shell_view = NULL; g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data->display_name != NULL, FALSE); g_return_val_if_fail (data->error_ident != NULL, FALSE); g_return_val_if_fail (data->error != NULL, FALSE); if (send_recv_dialog) { GtkWidget *parent; parent = gtk_widget_get_parent (send_recv_dialog); if (parent && E_IS_SHELL_WINDOW (parent)) { EShellWindow *shell_window = E_SHELL_WINDOW (parent); shell_view = e_shell_window_get_shell_view (shell_window, "mail"); } } if (!shell_view) { EShell *shell; GtkWindow *active_window; shell = e_shell_get_default (); active_window = e_shell_get_active_window (shell); if (E_IS_SHELL_WINDOW (active_window)) { EShellWindow *shell_window = E_SHELL_WINDOW (active_window); shell_view = e_shell_window_get_shell_view (shell_window, "mail"); } } if (shell_view) { EShellContent *shell_content; EAlertSink *alert_sink; EAlert *alert; shell_content = e_shell_view_get_shell_content (shell_view); alert_sink = E_ALERT_SINK (shell_content); alert = e_alert_new (data->error_ident, data->display_name, data->error->message, NULL); e_alert_sink_submit_alert (alert_sink, alert); g_object_unref (alert); } else { /* This may not happen, but just in case... */ g_warning ("%s: %s '%s': %s\n", G_STRFUNC, data->error_ident, data->display_name, data->error->message); } g_free (data->display_name); g_free (data->error_ident); g_error_free (data->error); g_free (data); return FALSE; }