X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-main-window.c;h=65b175ddd7b4a903bcf9a4b17deda88d434067ce;hp=c444b747bb9b20a129e97d42739eb52ea693fcdd;hb=594387ddd061af8176bcdf5b1710702725e621fa;hpb=2d83522afb171edecdbf848a47d1348dc0c7694e diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index c444b74..65b175d 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -166,10 +166,10 @@ static gboolean on_header_view_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer userdata); -static void modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, - TnyFolderStore *folder_store, - gboolean selected, - ModestMainWindow *main_window); +static void on_folder_selection_changed (ModestFolderView *folder_view, + TnyFolderStore *folder_store, + gboolean selected, + ModestMainWindow *main_window); static void set_at_least_one_account_visible(ModestMainWindow *self); @@ -354,6 +354,10 @@ modest_main_window_init (ModestMainWindow *obj) priv->sighandlers = NULL; priv->updating_banner = NULL; priv->updating_banner_timeout = 0; + + modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(), + GTK_WINDOW(obj), + "applications_email_mainview"); } static void @@ -383,6 +387,11 @@ modest_main_window_finalize (GObject *obj) priv->updating_banner_timeout = 0; } + if (priv->updating_banner) { + gtk_widget_destroy (priv->updating_banner); + priv->updating_banner = NULL; + } + if (priv->restore_paned_timeout > 0) { g_source_remove (priv->restore_paned_timeout); priv->restore_paned_timeout = 0; @@ -423,11 +432,15 @@ restore_paned_timeout_handler (gpointer *data) ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window); ModestConf *conf; + /* Timeouts are outside the main lock */ + gdk_threads_enter (); if (GTK_WIDGET_VISIBLE (main_window)) { conf = modest_runtime_get_conf (); modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned), MODEST_CONF_MAIN_PANED_KEY); } + gdk_threads_leave (); + return FALSE; } @@ -500,6 +513,7 @@ update_menus (ModestMainWindow* self) gint i, num_accounts; GList *groups; gchar *default_account; + const gchar *active_account_name; GtkWidget *send_receive_button, *item; GtkAction *send_receive_all = NULL; GSList *radio_group; @@ -529,7 +543,7 @@ update_menus (ModestMainWindow* self) send_receive_all = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu"); - gtk_action_set_visible (send_receive_all, num_accounts > 1); + gtk_action_set_visible (send_receive_all, num_accounts > 0); /* Delete old send&receive popup items. We can not just do a menu_detach because it does not work well with @@ -582,26 +596,35 @@ update_menus (ModestMainWindow* self) /* Create a new action group */ default_account = modest_account_mgr_get_default_account (mgr); + active_account_name = modest_window_get_active_account (MODEST_WINDOW (self)); + + if (!active_account_name) + modest_window_set_active_account (MODEST_WINDOW (self), default_account); + priv->view_additions_group = gtk_action_group_new (MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS); radio_group = NULL; for (i = 0; i < num_accounts; i++) { gchar *display_name = NULL; ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i); + if (!account_data) { + g_warning ("%s: BUG: account_data == NULL", __FUNCTION__); + continue; + } + if (default_account && account_data->account_name && - !(strcmp (default_account, account_data->account_name) == 0)) { + !(strcmp (default_account, account_data->account_name) == 0)) { display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"), account_data->display_name); - } - else { + } else { display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_mailbox_n"), account_data->display_name); } - + /* Create action and add it to the action group. The action name must be the account name, this way we could know in the handlers the account to show */ - if(account_data && account_data->account_name) { + if (account_data && account_data->account_name) { gchar* item_name, *refresh_action_name; guint8 merge_id = 0; GtkAction *view_account_action, *refresh_account_action; @@ -612,9 +635,11 @@ update_menus (ModestMainWindow* self) gtk_radio_action_set_group (GTK_RADIO_ACTION (view_account_action), radio_group); radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (view_account_action)); - if (default_account && account_data->account_name && - (strcmp (default_account, account_data->account_name) == 0)) { - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_account_action), TRUE); + if (active_account_name) { + if (active_account_name && account_data->account_name && + (strcmp (active_account_name, account_data->account_name) == 0)) { + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_account_action), TRUE); + } } /* Add ui from account data. We allow 2^9-1 account @@ -843,14 +868,20 @@ connect_signals (ModestMainWindow *self) G_OBJECT(priv->folder_view), "key-press-event", G_CALLBACK(on_inner_widgets_key_pressed), self); priv->sighandlers = - modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), "folder_selection_changed", - G_CALLBACK (modest_main_window_on_folder_selection_changed), self); + modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), + "folder_selection_changed", + G_CALLBACK (on_folder_selection_changed), + self); priv->sighandlers = - modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), "folder-display-name-changed", - G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), self); + modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), + "folder-display-name-changed", + G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), + self); priv->sighandlers = - modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), "focus-in-event", - G_CALLBACK (on_folder_view_focus_in), self); + modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), + "focus-in-event", + G_CALLBACK (on_folder_view_focus_in), + self); /* Folder view CSM */ menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/FolderViewCSM"); @@ -1002,7 +1033,6 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL)); wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view)); -/* wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET(priv->header_view)); */ gtk_widget_show (GTK_WIDGET (priv->folder_view)); @@ -1020,12 +1050,6 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) /* Restore window & widget settings */ restore_settings (MODEST_MAIN_WINDOW(self), TRUE); -/* /\* The UI spec wants us to show a connection dialog when the application is */ -/* * started by the user, if there is no connection. */ -/* * Do this before showing the account wizard, */ -/* * because wizard needs a connection to discover capabilities. *\/ */ -/* modest_platform_connect_and_wait (GTK_WINDOW (self), NULL); */ - /* Check if accounts exist and show the account wizard if not */ gboolean accounts_exist = modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE); @@ -1042,8 +1066,9 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) accounts = modest_account_mgr_account_names (modest_runtime_get_account_mgr (), TRUE); send_receive_all = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu"); - gtk_action_set_visible (send_receive_all, g_slist_length (accounts) > 1); + gtk_action_set_visible (send_receive_all, g_slist_length (accounts) > 0); modest_account_mgr_free_account_names (accounts); + update_menus (MODEST_MAIN_WINDOW (self)); } } @@ -1219,29 +1244,6 @@ modest_main_window_new (void) return MODEST_WINDOW(self); } -gboolean -modest_main_window_close_all (ModestMainWindow *self) -{ - GtkWidget *note; - GtkResponseType response; - - /* Create the confirmation dialog MSG-NOT308 */ - note = hildon_note_new_confirmation_add_buttons (GTK_WINDOW (self), - _("emev_nc_close_windows"), - _("mcen_bd_yes"), GTK_RESPONSE_YES, - _("mcen_bd_no"), GTK_RESPONSE_NO, - NULL); - - response = gtk_dialog_run (GTK_DIALOG (note)); - gtk_widget_destroy (GTK_WIDGET (note)); - - if (response == GTK_RESPONSE_YES) - return TRUE; - else - return FALSE; -} - - void modest_main_window_set_style (ModestMainWindow *self, ModestMainWindowStyle style) @@ -1429,7 +1431,10 @@ modest_main_window_show_toolbar (ModestWindow *self, gtk_container_set_resize_mode (GTK_CONTAINER(parent_priv->toolbar), GTK_RESIZE_IMMEDIATE); gtk_widget_show (GTK_WIDGET (parent_priv->toolbar)); - set_toolbar_mode (MODEST_MAIN_WINDOW(self), TOOLBAR_MODE_NORMAL); + if (modest_main_window_transfer_mode_enabled (MODEST_MAIN_WINDOW(self))) + set_toolbar_mode (MODEST_MAIN_WINDOW(self), TOOLBAR_MODE_TRANSFER); + else + set_toolbar_mode (MODEST_MAIN_WINDOW(self), TOOLBAR_MODE_NORMAL); } else { gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar)); @@ -1542,17 +1547,18 @@ create_empty_view (void) static gchar * get_gray_color_markup (GtkWidget *styled_widget) { - gchar *gray_color_markup; - + gchar *gray_color_markup = NULL; +#ifndef MODEST_HAVE_HILDON0_WIDGETS /* Obtain the secondary text color. We need a realized widget, that's why we get styled_widget from outside */ -#ifndef MODEST_HAVE_HILDON0_WIDGETS GdkColor color; - gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color); - gray_color_markup = modest_text_utils_get_color_string (&color); -#else - gray_color_markup = g_strdup ("#BBBBBB"); -#endif + if (gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color)) + gray_color_markup = modest_text_utils_get_color_string (&color); +#endif /*MODEST_HAVE_HILDON0_WIDGETS*/ + + if (!gray_color_markup) + gray_color_markup = g_strdup ("#BBBBBB"); + return gray_color_markup; } @@ -1682,7 +1688,7 @@ create_details_widget (GtkWidget *styled_widget, TnyAccount *account) TnyAccount *account = TNY_ACCOUNT(folder_store); time_t last_updated; - gchar *last_updated_string; + const gchar *last_updated_string; /* Get last updated from configuration */ last_updated = modest_account_mgr_get_last_updated (modest_runtime_get_account_mgr (), tny_account_get_id (account)); @@ -1697,7 +1703,6 @@ create_details_widget (GtkWidget *styled_widget, TnyAccount *account) label_w = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label_w), label); gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0); - g_free (last_updated_string); g_free (label); } @@ -2014,12 +2019,12 @@ set_toolbar_mode (ModestMainWindow *self, gtk_action_set_visible (refresh_action, FALSE); if (cancel_action) gtk_action_set_visible (cancel_action, TRUE); + if (priv->progress_bar) + gtk_widget_show (priv->progress_bar); if (priv->progress_toolitem) { gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), TRUE); gtk_widget_show (priv->progress_toolitem); } - if (priv->progress_bar) - gtk_widget_show (priv->progress_bar); /* Show toolbar if it's hiden (optimized view ) */ if (priv->optimized_view) @@ -2281,15 +2286,20 @@ set_at_least_one_account_visible(ModestMainWindow *self) } const gchar *active_server_account_name = - modest_folder_view_get_account_id_of_visible_server_account (priv->folder_view); + modest_folder_view_get_account_id_of_visible_server_account (priv->folder_view); + if (!active_server_account_name || !modest_account_mgr_account_exists (account_mgr, active_server_account_name, TRUE)) { gchar* first_modest_name = modest_account_mgr_get_first_account_name (account_mgr); - if (first_modest_name) { + gchar* default_modest_name = modest_account_mgr_get_default_account (account_mgr); + if (default_modest_name) { + set_account_visible (self, default_modest_name); + } else if (first_modest_name) { set_account_visible (self, first_modest_name); - g_free (first_modest_name); } + g_free (first_modest_name); + g_free (default_modest_name); } } @@ -2308,9 +2318,15 @@ static void refresh_account (const gchar *account_name) { ModestWindow *win; - - win = MODEST_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ())); - + + /* win must already exists here, obviously */ + win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), + FALSE); + if (!win) { + g_warning ("%s: BUG: no main window!", __FUNCTION__); + return; + } + /* If account_name == NULL, we must update all (option All) */ if (!account_name) modest_ui_actions_do_send_receive_all (win); @@ -2344,9 +2360,7 @@ on_zoom_minus_plus_not_implemented (ModestWindow *window) } static gboolean -on_folder_view_focus_in (GtkWidget *widget, - GdkEventFocus *event, - gpointer userdata) +on_folder_view_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer userdata) { ModestMainWindow *main_window = NULL; @@ -2365,11 +2379,10 @@ on_header_view_focus_in (GtkWidget *widget, gpointer userdata) { ModestMainWindow *main_window = NULL; - ModestMainWindowPrivate *priv = NULL; g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (userdata), FALSE); + main_window = MODEST_MAIN_WINDOW (userdata); - priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window); /* Update toolbar dimming state */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window)); @@ -2378,10 +2391,10 @@ on_header_view_focus_in (GtkWidget *widget, } static void -modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, - TnyFolderStore *folder_store, - gboolean selected, - ModestMainWindow *main_window) +on_folder_selection_changed (ModestFolderView *folder_view, + TnyFolderStore *folder_store, + gboolean selected, + ModestMainWindow *main_window) { ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (main_window); GtkAction *action = NULL; @@ -2411,6 +2424,9 @@ modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, show_clipboard = show_delete = show_cancel_send = TRUE; show_reply = show_forward = FALSE; break; + case TNY_FOLDER_TYPE_INVALID: + g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__); + break; default: show_reply = show_forward = show_clipboard = show_delete = TRUE; show_cancel_send = FALSE; @@ -2475,9 +2491,15 @@ show_updating_banner (gpointer user_data) priv = MODEST_MAIN_WINDOW_GET_PRIVATE (user_data); - priv->updating_banner = - modest_platform_animation_banner (GTK_WIDGET (user_data), NULL, - _CS ("ckdg_pb_updating")); + if (priv->updating_banner == NULL) { + + /* We're outside the main lock */ + gdk_threads_enter (); + priv->updating_banner = + modest_platform_animation_banner (GTK_WIDGET (user_data), NULL, + _CS ("ckdg_pb_updating")); + gdk_threads_leave (); + } /* Remove timeout */ priv->updating_banner_timeout = 0; @@ -2500,7 +2522,7 @@ on_updating_msg_list (ModestHeaderView *header_view, ModestMainWindowPrivate *priv = NULL; priv = MODEST_MAIN_WINDOW_GET_PRIVATE (user_data); - + /* Remove old timeout */ if (priv->updating_banner_timeout > 0) { g_source_remove (priv->updating_banner_timeout);