#include "modest-account-mgr-helpers.h"
#include "modest-mail-operation.h"
+
+#ifdef MODEST_HAVE_EASYSETUP
+#include "easysetup/modest-easysetup-wizard.h"
+#endif /*MODEST_HAVE_EASYSETUP*/
+
#include <modest-widget-memory.h>
#include <tny-error.h>
#include <tny-simple-list.h>
void
modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
{
- /* GtkDialog *account_win; */
-/* account_win = GTK_DIALOG(modest_account_view_window_new ()); */
+ GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
+
+ gboolean accounts_exist = account_names != NULL;
+ g_slist_free (account_names);
-
-/* gtk_dialog_run (account_win); */
- //gtk_widget_destroy (GTK_WIDGET(account_win));
- GtkWidget *dialog, *label;
+ /* This is currently only implemented for Maemo,
+ * because it requires a providers preset file which is not publically available.
+ */
+#ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
+ /* To test, while modest_account_mgr_account_names() is broken: accounts_exist = TRUE; */
+ if (!accounts_exist) {
+ /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */
+ ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
+ gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
+ gtk_dialog_run (GTK_DIALOG (wizard));
+ gtk_widget_destroy (GTK_WIDGET (wizard));
+ }
+ else
+ {
+ /* Show the list of accounts: */
+ GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
+ gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
+ gtk_dialog_run (account_win);
+ gtk_widget_destroy (GTK_WIDGET(account_win));
+ }
+#else
+ GtkWidget *dialog, *label;
/* Create the widgets */
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
label);
gtk_widget_show_all (dialog);
+#endif /* MODEST_PLATFORM_MAEMO */
}
void
gtk_widget_destroy (dialog);
}
+
+void
+modest_ui_actions_on_cut (GtkAction *action,
+ ModestWindow *window)
+{
+ GtkWidget *focused_widget;
+
+ focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (GTK_IS_EDITABLE (focused_widget)) {
+ gtk_editable_cut_clipboard (GTK_EDITABLE(focused_widget));
+ } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
+ gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE);
+ }
+}
+
+void
+modest_ui_actions_on_copy (GtkAction *action,
+ ModestWindow *window)
+{
+ GtkClipboard *clipboard;
+ GtkWidget *focused_widget;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (GTK_IS_LABEL (focused_widget)) {
+ gtk_clipboard_set_text (clipboard, gtk_label_get_text (GTK_LABEL (focused_widget)), -1);
+ } else if (GTK_IS_EDITABLE (focused_widget)) {
+ gtk_editable_copy_clipboard (GTK_EDITABLE(focused_widget));
+ } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
+ gtk_text_buffer_copy_clipboard (buffer, clipboard);
+ }
+}
+
+void
+modest_ui_actions_on_paste (GtkAction *action,
+ ModestWindow *window)
+{
+ GtkWidget *focused_widget;
+
+ focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (GTK_IS_EDITABLE (focused_widget)) {
+ gtk_editable_paste_clipboard (GTK_EDITABLE(focused_widget));
+ } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
+ gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
+ }
+}
+
+void
+modest_ui_actions_on_select_all (GtkAction *action,
+ ModestWindow *window)
+{
+ GtkWidget *focused_widget;
+
+ focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (GTK_IS_LABEL (focused_widget)) {
+ gtk_label_select_region (GTK_LABEL (focused_widget), 0, -1);
+ } else if (GTK_IS_EDITABLE (focused_widget)) {
+ gtk_editable_select_region (GTK_EDITABLE(focused_widget), 0, -1);
+ } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ gtk_text_buffer_select_range (buffer, &start, &end);
+ }
+}