From 55bbe88449ceaa2cd7ac644c6c37518a6b211a84 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Fri, 12 Dec 2008 12:07:59 +0000 Subject: [PATCH] Move to folder * Moved the creation of the folder view to the platforms * Moved some hildon2 specific code to the platform pmo-drop-split-view-r6803 --- src/gnome/modest-platform.c | 12 ++++++++---- src/hildon2/modest-platform.c | 31 ++++++++++++++++++++++++++----- src/maemo/modest-platform.c | 14 +++++++++----- src/modest-platform.h | 2 +- src/modest-ui-actions.c | 31 ++++++------------------------- 5 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 400dbfc..bda9c2c 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -555,9 +555,9 @@ modest_platform_run_header_details_dialog (GtkWindow *parent_window, GtkWidget* modest_platform_create_move_to_dialog (GtkWindow *parent_window, - GtkWidget **folder_view_container) + GtkWidget **folder_view) { - GtkWidget *dialog; + GtkWidget *dialog, *folder_view_container; dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"), GTK_WINDOW (parent_window), @@ -568,12 +568,16 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL, NULL); + /* Create folder view */ + *folder_view = modest_platform_create_folder_view (NULL); + /* Create pannable and add it to the dialog */ - *folder_view_container = gtk_scrolled_window_new (NULL, NULL); + folder_view_container = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (*folder_view_container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), *folder_view_container); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container); + gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300); diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index ddb53dd..fc5ab97 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -2161,12 +2161,23 @@ _modest_platform_play_email_tone (void) g_free (active_profile); } -GtkWidget* +static void +on_move_to_dialog_folder_activated (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column, + gpointer user_data) +{ + gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_OK); +} + +GtkWidget * modest_platform_create_move_to_dialog (GtkWindow *parent_window, - GtkWidget **folder_view_container) + GtkWidget **folder_view) { - GtkWidget *dialog; + GtkWidget *dialog, *folder_view_container; + /* Create dialog. We cannot use a touch selector because we + need to use here the folder view widget directly */ dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"), GTK_WINDOW (parent_window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | @@ -2174,9 +2185,19 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, _("mcen_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER, NULL); + /* Create folder view */ + *folder_view = modest_platform_create_folder_view (NULL); + + /* Simulate the behaviour of a HildonPickerDialog by emitting + a response when a folder is selected */ + g_signal_connect (*folder_view, "row-activated", + G_CALLBACK (on_move_to_dialog_folder_activated), + dialog); + /* Create pannable and add it to the dialog */ - *folder_view_container = hildon_pannable_area_new (); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), *folder_view_container); + folder_view_container = hildon_pannable_area_new (); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container); + gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300); diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index d309b2c..2710b40 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -2161,9 +2161,9 @@ modest_platform_get_osso_context (void) GtkWidget* modest_platform_create_move_to_dialog (GtkWindow *parent_window, - GtkWidget **folder_view_container) + GtkWidget **folder_view) { - GtkWidget *dialog; + GtkWidget *dialog, *folder_view_container; dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"), GTK_WINDOW (parent_window), @@ -2174,12 +2174,16 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL, NULL); + /* Create folder view */ + *folder_view = modest_platform_create_folder_view (NULL); + /* Create pannable and add it to the dialog */ - *folder_view_container = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (*folder_view_container), + folder_view_container = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (folder_view_container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), *folder_view_container); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container); + gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300); diff --git a/src/modest-platform.h b/src/modest-platform.h index 0370907..7386753 100644 --- a/src/modest-platform.h +++ b/src/modest-platform.h @@ -546,7 +546,7 @@ osso_context_t *modest_platform_get_osso_context (void); GtkWidget* modest_platform_create_move_to_dialog (GtkWindow *parent_window, - GtkWidget **folder_view_container); + GtkWidget **folder_view); G_END_DECLS diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 8fce06b..dcba9b4 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -4523,16 +4523,7 @@ modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window modest_msg_edit_window_check_names (window, FALSE); } -#ifdef MODEST_TOOLKIT_HILDON2 -static void -on_move_to_dialog_folder_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer user_data) -{ - gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_OK); -} -#else +#ifndef MODEST_TOOLKIT_HILDON2 /* * This function is used to track changes in the selection of the * folder view that is inside the "move to" dialog to enable/disable @@ -4727,19 +4718,11 @@ static GtkWidget* create_move_to_dialog (GtkWindow *win, GtkWidget *folder_view) { - GtkWidget *dialog, *folder_view_container, *tree_view; - - dialog = modest_platform_create_move_to_dialog (win, &folder_view_container); + GtkWidget *dialog, *tree_view = NULL; - /* Create folder view */ - tree_view = modest_platform_create_folder_view (NULL); + dialog = modest_platform_create_move_to_dialog (win, &tree_view); -#ifdef MODEST_TOOLKIT_HILDON2 - /* We return OK on activation */ - g_signal_connect (tree_view, "row-activated", - G_CALLBACK (on_move_to_dialog_folder_activated), - dialog); -#else +#ifndef MODEST_TOOLKIT_HILDON2 /* Track changes in the selection to * disable the OK button whenever "Move to" is not possible * disbale NEW button whenever New is not possible */ @@ -4802,12 +4785,10 @@ create_move_to_dialog (GtkWindow *win, /* Hide special folders */ modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (tree_view), FALSE); +#ifndef MODEST_TOOLKIT_HILDON2 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view)); +#endif - /* Add the tree view to its container */ - gtk_container_add (GTK_CONTAINER (folder_view_container), tree_view); - - gtk_widget_show (GTK_WIDGET (folder_view_container)); gtk_widget_show (GTK_WIDGET (tree_view)); return dialog; -- 1.7.9.5