[evolution/webkit: 179/196] Port moving between unread messages using the 'magical spacebar'



commit bbd3f5296d0f0ffed188ecf600910d333f72a686
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Mar 2 19:17:02 2012 +0100

    Port moving between unread messages using the 'magical spacebar'

 modules/mail/e-mail-shell-view-actions.c |   96 ++++++++++++++++++------------
 modules/mail/e-mail-shell-view-private.c |   73 ----------------------
 2 files changed, 57 insertions(+), 112 deletions(-)
---
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index e37e0db..15ab8ae 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -900,6 +900,7 @@ action_mail_smart_backward_cb (GtkAction *action,
 	EMailDisplay *display;
 	gboolean caret_mode;
 	gboolean magic_spacebar;
+        gdouble value;
 
 	/* This implements the so-called "Magic Backspace". */
 
@@ -929,31 +930,38 @@ action_mail_smart_backward_cb (GtkAction *action,
                 return;
 
         adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window));
-        gtk_adjustment_set_value (adj,
-                gtk_adjustment_get_value(adj) - gtk_adjustment_get_page_increment(adj));
+        value = gtk_adjustment_get_value (adj);
+        if (value == 0) {
 
+                if (caret_mode || !magic_spacebar)
+                        return;
 
-	if (caret_mode || !magic_spacebar)
-		return;
+                /* XXX Are two separate calls really necessary? */
 
-	/* XXX Are two separate calls really necessary? */
+                if (message_list_select (
+                    MESSAGE_LIST (message_list),
+                    MESSAGE_LIST_SELECT_PREVIOUS,
+                    0, CAMEL_MESSAGE_SEEN))
+                        return;
 
-	if (message_list_select (
-		MESSAGE_LIST (message_list),
-		MESSAGE_LIST_SELECT_PREVIOUS,
-		0, CAMEL_MESSAGE_SEEN))
-		return;
+                if (message_list_select (
+                    MESSAGE_LIST (message_list),
+                    MESSAGE_LIST_SELECT_PREVIOUS |
+                    MESSAGE_LIST_SELECT_WRAP,
+                    0, CAMEL_MESSAGE_SEEN))
+                        return;
 
-	if (message_list_select (
-		MESSAGE_LIST (message_list),
-		MESSAGE_LIST_SELECT_PREVIOUS |
-		MESSAGE_LIST_SELECT_WRAP, 0,
-		CAMEL_MESSAGE_SEEN))
-		return;
+                em_folder_tree_select_next_path (folder_tree, TRUE);
+
+                gtk_widget_grab_focus (message_list);
 
-	em_folder_tree_select_prev_path (folder_tree, TRUE);
+        } else {
 
-	gtk_widget_grab_focus (message_list);
+                gtk_adjustment_set_value (adj,
+                        value - gtk_adjustment_get_page_increment (adj));
+
+                return;
+        }
 }
 
 static void
@@ -976,6 +984,8 @@ action_mail_smart_forward_cb (GtkAction *action,
 	EMailDisplay *display;
 	gboolean caret_mode;
 	gboolean magic_spacebar;
+        gdouble value;
+        gdouble upper;
 
 	/* This implements the so-called "Magic Spacebar". */
 
@@ -1003,33 +1013,41 @@ action_mail_smart_forward_cb (GtkAction *action,
         window = gtk_widget_get_parent (GTK_WIDGET (display));
         if (!GTK_IS_SCROLLED_WINDOW (window))
                 return;
-        
+
         adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window));
-        gtk_adjustment_set_value (adj,
-                gtk_adjustment_get_value(adj) + gtk_adjustment_get_page_increment(adj));
-        
-        
-	if (caret_mode || !magic_spacebar)
-		return;
+        value = gtk_adjustment_get_value (adj);
+        upper = gtk_adjustment_get_upper (adj);
+        if (value + gtk_adjustment_get_page_size (adj) >= upper) {
 
-	/* XXX Are two separate calls really necessary? */
+                if (caret_mode || !magic_spacebar)
+                        return;
 
-	if (message_list_select (
-		MESSAGE_LIST (message_list),
-		MESSAGE_LIST_SELECT_NEXT,
-		0, CAMEL_MESSAGE_SEEN))
-		return;
+                /* XXX Are two separate calls really necessary? */
 
-	if (message_list_select (
-		MESSAGE_LIST (message_list),
-		MESSAGE_LIST_SELECT_NEXT |
-		MESSAGE_LIST_SELECT_WRAP,
-		0, CAMEL_MESSAGE_SEEN))
-		return;
+                if (message_list_select (
+                    MESSAGE_LIST (message_list),
+                    MESSAGE_LIST_SELECT_NEXT,
+                    0, CAMEL_MESSAGE_SEEN))
+                        return;
+
+                if (message_list_select (
+                    MESSAGE_LIST (message_list),
+                    MESSAGE_LIST_SELECT_NEXT |
+                    MESSAGE_LIST_SELECT_WRAP,
+                    0, CAMEL_MESSAGE_SEEN))
+                        return;
+
+                em_folder_tree_select_next_path (folder_tree, TRUE);
 
-	em_folder_tree_select_next_path (folder_tree, TRUE);
+                gtk_widget_grab_focus (message_list);
 
-	gtk_widget_grab_focus (message_list);
+        } else {
+
+                gtk_adjustment_set_value (adj,
+                        value + gtk_adjustment_get_page_increment (adj));
+
+                return;
+        }
 }
 
 static void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 0335d51..9a58f9d 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -366,61 +366,6 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
 }
 
 static void
-mail_shell_view_scroll_cb (EMailShellView *mail_shell_view,
-                           GtkOrientation orientation,
-                           GtkScrollType scroll_type,
-                           gfloat position,
-                           GtkHTML *html)
-{
-	EShell *shell;
-	EShellView *shell_view;
-	EShellWindow *shell_window;
-	EShellSettings *shell_settings;
-	EMailShellContent *mail_shell_content;
-	EMailReader *reader;
-	EMailView *mail_view;
-	EWebView *web_view;
-	GtkWidget *message_list;
-	gboolean magic_spacebar;
-
-	web_view = E_WEB_VIEW (html);
-
-	if (html->binding_handled || e_web_view_get_caret_mode (web_view))
-		return;
-
-	if (orientation != GTK_ORIENTATION_VERTICAL)
-		return;
-
-	shell_view = E_SHELL_VIEW (mail_shell_view);
-	shell_window = e_shell_view_get_shell_window (shell_view);
-	shell = e_shell_window_get_shell (shell_window);
-	shell_settings = e_shell_get_shell_settings (shell);
-
-	magic_spacebar = e_shell_settings_get_boolean (
-		shell_settings, "mail-magic-spacebar");
-
-	if (!magic_spacebar)
-		return;
-
-	mail_shell_content = mail_shell_view->priv->mail_shell_content;
-	mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
-
-	reader = E_MAIL_READER (mail_view);
-	message_list = e_mail_reader_get_message_list (reader);
-
-	if (scroll_type == GTK_SCROLL_PAGE_FORWARD)
-		message_list_select (
-			MESSAGE_LIST (message_list),
-			MESSAGE_LIST_SELECT_NEXT,
-			0, CAMEL_MESSAGE_SEEN);
-	else
-		message_list_select (
-			MESSAGE_LIST (message_list),
-			MESSAGE_LIST_SELECT_PREVIOUS,
-			0, CAMEL_MESSAGE_SEEN);
-}
-
-static void
 mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view,
                                    EMailReader *reader)
 {
@@ -469,15 +414,6 @@ mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view,
 		G_CALLBACK (mail_shell_view_popup_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
-        /* FIXME WEBKIT: Not sure if this event has ever worked
-         *      (GtkHTML does not seem to emit the signal at all)
-	g_signal_connect_object (
-                display, "scroll",
-		G_CALLBACK (mail_shell_view_scroll_cb),
-		mail_shell_view,
-                G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-        */
-
 	g_signal_connect_object (
 		display, "status-message",
 		G_CALLBACK (e_shell_taskbar_set_message),
@@ -789,15 +725,6 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 		G_CALLBACK (mail_shell_view_popup_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
-        /* FIXME WEBKIT: Not sure if this event has ever worked
-         *      (GtkHTML does not seem to emit the signal at all)
-	g_signal_connect_object (
-		display, "scroll",
-		G_CALLBACK (mail_shell_view_scroll_cb),
-		mail_shell_view,
-		G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-	*/
-
 	g_signal_connect_object (
 		display, "status-message",
 		G_CALLBACK (e_shell_taskbar_set_message),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]