#include <tny-simple-list.h>
#include <tny-list.h>
#include <tny-iterator.h>
-#include <tny-maemo-conic-device.h>
#include <tny-error.h>
#include "modest-hildon-includes.h"
#include "modest-defs.h"
compare_display_names (ModestAccountSettings *a,
ModestAccountSettings *b)
{
- switch (strcmp (modest_account_settings_get_display_name (a),
- modest_account_settings_get_display_name (b))) {
- case -1:
- return 1;
- case 0:
- return 0;
- case 1:
- return -1;
- default:
- g_return_val_if_reached (0);
- }
+ return g_utf8_collate (modest_account_settings_get_display_name (a),
+ modest_account_settings_get_display_name (b));
+
}
/* We use this function to prevent the send&receive CSM to be shown
gtk_widget_show_all(GTK_WIDGET(self));
modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self));
} else {
- GSList *accounts;
- GtkAction *send_receive_all;
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
- 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) > 0);
- modest_account_mgr_free_account_names (accounts);
update_menus (MODEST_MAIN_WINDOW (self));
}
ModestWindowPrivate *parent_priv;
GtkAction *action;
gboolean active;
-
+ GtkTreeSelection *sel;
+ GList *rows, *list;
+
g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
}
+ /* We need to store the selection because it's lost when the
+ widget is reparented */
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+ rows = gtk_tree_selection_get_selected_rows (sel, NULL);
+
priv->style = style;
switch (style) {
case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
break;
default:
+ g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (rows);
g_return_if_reached ();
}
+ /* Reselect the previously selected folders. We disable the
+ dimming rules execution during that time because there is
+ no need to work out it again and it could take a lot of
+ time if all the headers are selected */
+ list = rows;
+ modest_window_disable_dimming (MODEST_WINDOW (self));
+ while (list) {
+ gtk_tree_selection_select_path (sel, (GtkTreePath *) list->data);
+ list = g_list_next (list);
+ }
+ modest_window_enable_dimming (MODEST_WINDOW (self));
+
+ /* Free */
+ g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (rows);
+
/* Let header view grab the focus if it's being shown */
- if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
+ if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) {
gtk_widget_grab_focus (GTK_WIDGET (priv->header_view));
- else
- gtk_widget_grab_focus (GTK_WIDGET (priv->contents_widget));
+ } else {
+ if (priv->style == MODEST_MAIN_WINDOW_STYLE_SPLIT)
+ gtk_widget_grab_focus (GTK_WIDGET (priv->folder_view));
+ else
+ gtk_widget_grab_focus (GTK_WIDGET (priv->contents_widget));
+ }
+
+ /* Check dimming rules */
+ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self));
+ modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
/* Show changes */
gtk_widget_show_all (GTK_WIDGET (priv->main_vbox));
}
}
}
- } else if (MODEST_IS_FOLDER_VIEW (widget) && event->keyval == GDK_Right)
+ } else if (MODEST_IS_FOLDER_VIEW (widget) && (event->keyval == GDK_Right || event->keyval == GDK_Left)) {
+#if GTK_CHECK_VERSION(2, 8, 0) /* TODO: gtk_tree_view_get_visible_range() is only available in GTK+ 2.8 */
+ GtkTreePath *selected_path = NULL;
+ GtkTreePath *start_path = NULL;
+ GtkTreePath *end_path = NULL;
+ GList *selected;
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+ selected = gtk_tree_selection_get_selected_rows (selection, NULL);
+ if (selected != NULL) {
+ selected_path = (GtkTreePath *) selected->data;
+ if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->header_view),
+ &start_path,
+ &end_path)) {
+
+ if ((gtk_tree_path_compare (start_path, selected_path) != -1) ||
+ (gtk_tree_path_compare (end_path, selected_path) != 1)) {
+
+ /* Scroll to first path */
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->header_view),
+ selected_path,
+ NULL,
+ TRUE,
+ 0.5,
+ 0.0);
+ }
+ }
+ if (start_path)
+ gtk_tree_path_free (start_path);
+ if (end_path)
+ gtk_tree_path_free (end_path);
+ g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (selected);
+ }
+#endif /* GTK_CHECK_VERSION */
+ /* fix scroll */
gtk_widget_grab_focus (GTK_WIDGET (priv->header_view));
+ }
return FALSE;
}
wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->header_view));
modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
TRUE);
+ if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE)
+ gtk_widget_grab_focus (GTK_WIDGET (priv->header_view));
break;
case MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS:
{
modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
FALSE);
}
+ if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE)
+ gtk_widget_grab_focus (GTK_WIDGET (priv->details_widget));
break;
}
case MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY:
wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->empty_view));
modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
FALSE);
+ if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE)
+ gtk_widget_grab_focus (GTK_WIDGET (priv->empty_view));
break;
default:
g_return_if_reached ();
return TRUE;
}
+static void
+updating_banner_destroyed (gpointer data,
+ GObject *where_the_object_was)
+{
+ ModestMainWindowPrivate *priv = NULL;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data);
+
+ priv->updating_banner = NULL;
+}
+
static gboolean
show_updating_banner (gpointer user_data)
{
priv->updating_banner =
modest_platform_animation_banner (GTK_WIDGET (user_data), NULL,
_CS ("ckdg_pb_updating"));
+
+ /* We need this because banners in Maemo could be
+ destroyed by dialogs so we need to properly update
+ our reference to it */
+ g_object_weak_ref (G_OBJECT (priv->updating_banner),
+ updating_banner_destroyed,
+ user_data);
gdk_threads_leave ();
}
remove_banners (MODEST_MAIN_WINDOW (widget));
}
+static void
+retrieving_banner_destroyed (gpointer data,
+ GObject *where_the_object_was)
+{
+ ModestMainWindowPrivate *priv = NULL;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data);
+
+ priv->retrieving_banner = NULL;
+}
+
static gboolean
show_retrieving_banner (gpointer user_data)
{
priv->retrieving_banner =
modest_platform_animation_banner (GTK_WIDGET (user_data), NULL,
_("mcen_ib_getting_items"));
+
+ /* We need this because banners in Maemo could be
+ destroyed by dialogs so we need to properly update
+ our reference to it */
+ g_object_weak_ref (G_OBJECT (priv->retrieving_banner),
+ retrieving_banner_destroyed,
+ user_data);
gdk_threads_leave ();
}