X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fgnome%2Fmodest-platform.c;h=28885ee1f09ae4157a73643615c4ea850ab50861;hp=0143b453282ca79472945baaed26a1e8930029d7;hb=564a7388a2f74368147b0a241ca4a0b65c68167f;hpb=5665c1728b8a91813db3ed9c29f208b6855f03c6 diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 0143b45..28885ee 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -30,11 +30,18 @@ #include #include #include +#include +#include #include "modest-platform.h" #include "modest-mail-operation-queue.h" #include "modest-runtime.h" + #include "gnome/modest-gnome-global-settings-dialog.h" +#include "widgets/modest-account-settings-dialog.h" +#include "gnome/modest-account-assistant.h" +#include "gnome/modest-gnome-sort-dialog.h" +#include "widgets/modest-details-dialog.h" gboolean modest_platform_init (int argc, char *argv[]) @@ -43,6 +50,12 @@ modest_platform_init (int argc, char *argv[]) } +gboolean modest_platform_uninit (void) +{ + return TRUE; /*nothing to do */ +} + + TnyDevice* modest_platform_get_new_device (void) { @@ -85,26 +98,26 @@ modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type, gboolean modest_platform_activate_uri (const gchar *uri) { - modest_runtime_not_implemented (NULL); + g_message ("NOT IMPLEMENTED");; return FALSE; } gboolean modest_platform_activate_file (const gchar *path, const gchar *mime_type) { - modest_runtime_not_implemented (NULL); + g_message ("NOT IMPLEMENTED");; return FALSE; } gboolean modest_platform_show_uri_popup (const gchar *uri) { - modest_runtime_not_implemented (NULL); + g_message ("NOT IMPLEMENTED");; return FALSE; } GdkPixbuf* -modest_platform_get_icon (const gchar *name) +modest_platform_get_icon (const gchar *name, guint icon_size) { GError *err = NULL; GdkPixbuf* pixbuf; @@ -114,9 +127,15 @@ modest_platform_get_icon (const gchar *name) pixbuf = gdk_pixbuf_new_from_file (name, &err); if (!pixbuf) { - g_printerr ("modest: error while loading icon '%s': %s\n", - name, err->message); +/* g_printerr ("modest: error while loading icon '%s': %s\n", */ +/* name, err->message); */ g_error_free (err); + err = NULL; + + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name, icon_size, 0, &err); + if (!pixbuf) { + g_error_free (err); + } } return pixbuf; @@ -172,35 +191,138 @@ gint modest_platform_run_confirmation_dialog (GtkWindow *parent_window, const gchar *msg) { - /* TODO implement confirmation dialog */ - return GTK_RESPONSE_CANCEL; + gint response; + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (parent_window, + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_OK_CANCEL, + msg); + + response = gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (dialog); + + return response; +} + +gint +modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window, + const gchar *message, + const gchar *button_accept, + const gchar *button_cancel) +{ + gint response; + GtkWidget *dialog; + + dialog = gtk_dialog_new_with_buttons (message, + parent_window, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + button_accept, + GTK_RESPONSE_ACCEPT, + button_cancel, + GTK_RESPONSE_CANCEL, + NULL); + + response = gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (dialog); + + return response; } void modest_platform_run_information_dialog (GtkWindow *parent_window, - const gchar *message) + const gchar *message, + gboolean block) { - /* TODO: implement a information dialog */ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (parent_window, + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } -gboolean modest_platform_connect_and_wait (GtkWindow *parent_window) +gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account) { /* TODO: Do something with network-manager? Otherwise, maybe it is safe to assume that we would already be online if we could be. */ return TRUE; } +gboolean modest_platform_connect_and_wait_if_network_account (GtkWindow *parent_window, TnyAccount *account) +{ + /* TODO: Do something with network-manager? + Otherwise, maybe it is safe to assume that we would already be online if we could be. */ + return TRUE; +} + + +void +modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, + gboolean force, + TnyFolderStore *folder_store, + ModestConnectedPerformer callback, + gpointer user_data) +{ + TnyAccount *account = NULL; + + if (!folder_store) { + /* We promise to instantly perform the callback, so ... */ + if (callback) { + callback (FALSE, NULL, parent_window, NULL, user_data); + } + return; + + /* Original comment: Maybe it is something local. */ + /* PVH's comment: maybe we should KNOW this in stead of assuming? */ + + } else if (TNY_IS_FOLDER (folder_store)) { + /* Get the folder's parent account: */ + account = tny_folder_get_account(TNY_FOLDER (folder_store)); + } else if (TNY_IS_ACCOUNT (folder_store)) { + /* Use the folder store as an account: */ + account = TNY_ACCOUNT (folder_store); + } + + if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) { + if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) && + !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) { + + /* This IS a local account like a maildir account, which does not require + * a connection. (original comment had a vague assumption in its language + * usage. There's no assuming needed, this IS what it IS: a local account), */ + + /* We promise to instantly perform the callback, so ... */ + if (callback) { + callback (FALSE, NULL, parent_window, account, user_data); + } + + return; + } + } + + modest_platform_connect_and_perform (parent_window, force, account, callback, user_data); + + return; +} + + gboolean modest_platform_set_update_interval (guint minutes) { /* TODO. */ return FALSE; } -void -modest_platform_run_sort_dialog (GtkWindow *parent_window, - ModestSortDialogType type) +GtkWidget * +modest_platform_create_sort_dialog (GtkWindow *parent_window) { - /* TODO */ + return modest_gnome_sort_dialog_new (parent_window); } GtkWidget * @@ -209,8 +331,16 @@ modest_platform_get_global_settings_dialog () return modest_gnome_global_settings_dialog_new (); } +void +modest_platform_push_email_notification(void) +{ + /* TODO: implement this */ + g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n"); +} + void -modest_platform_on_new_msg (void) +modest_platform_on_new_headers_received (TnyList *header_list, + gboolean show_visual) { /* TODO: implement this */ g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n"); @@ -218,16 +348,43 @@ modest_platform_on_new_msg (void) -gboolean -modest_platform_show_help (GtkWidget *widget, const gchar *help_id) +void +modest_platform_show_help (GtkWindow *parent_window, const gchar *help_id) +{ + return; /* TODO */ +} + +void +modest_platform_information_banner (GtkWidget *widget, + const gchar *icon_name, + const gchar *text) { - return TRUE; /* TODO */ + g_message ("NOT IMPLEMENTED");; } void +modest_platform_information_banner_with_timeout (GtkWidget *widget, + const gchar *icon_name, + const gchar *text, + gint timeout) +{ + g_message ("NOT IMPLEMENTED");; +} + +GtkWidget * +modest_platform_animation_banner (GtkWidget *widget, + const gchar *icon_name, + const gchar *text) +{ + g_message ("NOT IMPLEMENTED"); + return NULL; +} + + +void modest_platform_show_search_messages (GtkWindow *parent_window) { - modest_runtime_not_implemented (NULL); + g_message ("NOT IMPLEMENTED");; } GtkWidget * @@ -235,9 +392,163 @@ modest_platform_create_folder_view (TnyFolderStoreQuery *query) { GtkWidget *widget = modest_folder_view_new (query); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE); /* Show all accounts by default */ modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget), MODEST_FOLDER_VIEW_STYLE_SHOW_ALL); return widget; } + +gboolean +modest_platform_run_alert_dialog (const gchar* prompt, + gboolean is_question) +{ + /* TODO */ + return TRUE; +} + +void +modest_platform_connect_and_perform (GtkWindow *parent_window, + gboolean force, + TnyAccount *account, + ModestConnectedPerformer callback, + gpointer user_data) +{ + if (callback) + callback (FALSE, NULL, parent_window, account, user_data); +} + +void +modest_platform_double_connect_and_perform (GtkWindow *parent_window, + gboolean force, + TnyFolderStore *folder_store, + DoubleConnectionInfo *connect_info) +{ + if (connect_info->callback) + connect_info->callback (FALSE, NULL, parent_window, TNY_ACCOUNT (folder_store), connect_info->data); +} + +void +modest_platform_connect_and_perform_if_network_account (GtkWindow *parent_window, + gboolean force, + TnyAccount *account, + ModestConnectedPerformer callback, + gpointer user_data) +{ + if (callback) + callback (FALSE, NULL, parent_window, account, user_data); +} + +void +modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_window, + TnyFolderStore *folder_store, + ModestConnectedPerformer callback, + gpointer user_data) +{ + if (callback) + callback (FALSE, NULL, parent_window, NULL, user_data); +} + + +void +modest_platform_remove_new_mail_notifications (gboolean only_visuals) +{ + g_message ("NOT IMPLEMENTED %s", __FUNCTION__); +} + +gboolean +modest_platform_check_and_wait_for_account_is_online(TnyAccount *account) +{ + g_message ("NOT IMPLEMENTED %s", __FUNCTION__); + return TRUE; +} + +gboolean +modest_platform_run_certificate_confirmation_dialog (const gchar* server_name, + const gchar *certificate) +{ + g_message ("NOT IMPLEMENTED %s", __FUNCTION__); + return TRUE; +} + +gint +modest_platform_run_rename_folder_dialog (GtkWindow *parent_window, + TnyFolderStore *parent_folder, + const gchar *suggested_name, + gchar **folder_name) +{ + g_message ("NOT IMPLEMENTED %s", __FUNCTION__); + return GTK_RESPONSE_CANCEL; +} + +void +modest_platform_show_addressbook (GtkWindow *parent_window) +{ + g_message ("NOT IMPLEMENTED %s", __FUNCTION__); +} + +GtkWidget * +modest_platform_get_account_settings_dialog (ModestAccountSettings *settings) +{ + ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new (); + + modest_account_settings_dialog_set_account (dialog, settings); + return GTK_WIDGET (dialog); +} + +GtkWidget * +modest_platform_get_account_settings_wizard (void) +{ + GtkWidget *widget = modest_account_assistant_new (modest_runtime_get_account_mgr ()); + return widget; +} + + + +gboolean modest_platform_check_memory_low (ModestWindow *win, + gboolean visuals) +{ + g_debug ("%s not implemented", __FUNCTION__); + return FALSE; +} + +void +modest_platform_run_folder_details_dialog (GtkWindow *parent_window, + TnyFolder *folder) +{ + GtkWidget *dialog; + + /* Create dialog */ + dialog = modest_details_dialog_new_with_folder (parent_window, folder); + + /* Run dialog */ + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (dialog), + parent_window); + gtk_widget_show_all (dialog); + + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); +} + +void +modest_platform_run_header_details_dialog (GtkWindow *parent_window, + TnyHeader *header) +{ + GtkWidget *dialog; + + /* Create dialog */ + dialog = modest_details_dialog_new_with_header (parent_window, header); + + /* Run dialog */ + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (dialog), + parent_window); + gtk_widget_show_all (dialog); + + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); +}