From 2b4e8c186fd0ee99db60d4dbe18e35c617f91abe Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Thu, 14 Jun 2007 14:52:59 +0000 Subject: [PATCH] * Added modest_platform_create_folder_view * Fixes NB#59468, the move to folder shows the folder view even if there is no main window pmo-trunk-r2235 --- src/gnome/modest-platform.c | 12 ++++++++++++ src/maemo/modest-main-window.c | 15 ++++----------- src/maemo/modest-platform.c | 21 +++++++++++++++++++-- src/modest-platform.h | 4 ++++ src/modest-ui-actions.c | 5 ++++- src/widgets/modest-folder-view.c | 4 +--- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 861eca3..c92d1da 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -229,3 +229,15 @@ modest_platform_show_search_messages (GtkWindow *parent_window) { modest_runtime_not_implemented (NULL); } + +GtkWidget * +modest_platform_create_folder_view (TnyFolderStoreQuery *query) +{ + GtkWidget *widget = modest_folder_view_new (query); + + /* Show all accounts by default */ + modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget), + MODEST_FOLDER_VIEW_STYLE_SHOW_ALL); + + return widget; +} diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 860ea84..f70dab8 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -625,19 +625,13 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) GtkWidget *folder_win = (GtkWidget *) user_data; ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self); - priv->folder_view = MODEST_FOLDER_VIEW(modest_folder_view_new (NULL)); - if (!priv->folder_view) - g_printerr ("modest: cannot instantiate folder view\n"); + priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL)); gtk_widget_show (GTK_WIDGET (priv->folder_view)); /* Connect signals */ connect_signals ((ModestMainWindow*)self); - modest_folder_view_set_style (priv->folder_view, - MODEST_FOLDER_VIEW_STYLE_SHOW_ONE); - - /* Set account store */ tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view), TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); @@ -649,7 +643,7 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) /* Load previous osso state, for instance if we are being restored from * hibernation: */ - modest_osso_load_state(); + modest_osso_load_state (); /* Restore window & widget settings */ @@ -665,7 +659,6 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) gtk_widget_show_all(GTK_WIDGET(self)); modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self)); } - } ModestWindow* @@ -771,8 +764,8 @@ modest_main_window_new (void) modest_maemo_utils_get_device_name (); /* header view */ - priv->header_view = - MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS)); + priv->header_view = + MODEST_HEADER_VIEW (modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS)); if (!priv->header_view) g_printerr ("modest: cannot instantiate header view\n"); modest_header_view_set_style (priv->header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES); diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index e8c15aa..bd8a6ad 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -34,7 +34,7 @@ #include #include #include "maemo/modest-maemo-global-settings-dialog.h" - +#include "modest-widget-memory.h" #include #include #include @@ -816,7 +816,7 @@ modest_platform_on_new_msg (void) "system.note.dialog"); /* Play sound SR-SND-18. TODO: play the right file */ -/* hildon_notification_set_sound (not, "/usr/share/sounds/ui-battery_low.wav"); */ +/* hildon_notification_set_sound (not, "/usr/share/sounds/ui-new_email.wav"); */ /* Set the led pattern */ notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (not), "led-pattern", 3); @@ -879,3 +879,20 @@ modest_platform_show_addressbook (GtkWindow *parent_window) /* TODO: warning about error showing dialog */ } } + +GtkWidget * +modest_platform_create_folder_view (TnyFolderStoreQuery *query) +{ + GtkWidget *widget = modest_folder_view_new (query); + + /* Show all accounts by default */ + modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget), + MODEST_FOLDER_VIEW_STYLE_SHOW_ONE); + + /* Restore settings */ + modest_widget_memory_restore (modest_runtime_get_conf(), + G_OBJECT (widget), + MODEST_CONF_FOLDER_VIEW_KEY); + + return widget; +} diff --git a/src/modest-platform.h b/src/modest-platform.h index 0bb7952..0d6f41c 100644 --- a/src/modest-platform.h +++ b/src/modest-platform.h @@ -32,6 +32,7 @@ #include #include "widgets/modest-window.h" +#include "widgets/modest-folder-view.h" G_BEGIN_DECLS @@ -241,6 +242,9 @@ void modest_platform_show_search_messages (GtkWindow *parent_window); **/ void modest_platform_show_addressbook (GtkWindow *parent_window); + +GtkWidget* modest_platform_create_folder_view (TnyFolderStoreQuery *query); + G_END_DECLS #endif /* __MODEST_PLATFORM_UTILS_H__ */ diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 71ff9dc..71f925f 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -2577,7 +2577,7 @@ create_move_to_dialog (ModestWindow *win, GTK_POLICY_AUTOMATIC); /* Create folder view */ - *tree_view = modest_folder_view_new (NULL); + *tree_view = modest_platform_create_folder_view (NULL); /* It could happen that we're trying to move a message from a window (msg window for example) after the main window was @@ -2598,6 +2598,9 @@ create_move_to_dialog (ModestWindow *win, gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); + /* Select INBOX or local account */ + modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (*tree_view)); + return dialog; } diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index 0c4dbe8..e86574f 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -1663,8 +1663,6 @@ find_inbox_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *inbox_iter return FALSE; } - - void modest_folder_view_select_first_inbox_or_local (ModestFolderView *self) { @@ -1674,7 +1672,7 @@ modest_folder_view_select_first_inbox_or_local (ModestFolderView *self) /* Do not set it if the folder view was not painted */ if (!GTK_WIDGET_MAPPED (self)) - return; + return; model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); if (!model) -- 1.7.9.5