diff options
author | Srinivasa Ragavan <sragavan@gnome.org> | 2010-08-12 13:30:03 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@gnome.org> | 2010-08-12 13:35:47 +0800 |
commit | a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911 (patch) | |
tree | 1591085b776bbfff8063818d5f44397109384203 /mail | |
parent | 7dbd643c722a1c7b0ca1c95b571aab3bb7b7ff60 (diff) | |
download | gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar.gz gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar.bz2 gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar.lz gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar.xz gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.tar.zst gsoc2013-evolution-a6c40f7e8f52c44446d8e9b6ba8cbd6a7cfc3911.zip |
Add keybindings to tab.
Control Up - Go to parent folder.
Control Shift Up/Down - prev/next tab
Control Shift w - close tab.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-message-pane.c | 8 | ||||
-rw-r--r-- | mail/e-mail-message-pane.h | 1 | ||||
-rw-r--r-- | mail/e-mail-notebook-view.c | 119 | ||||
-rw-r--r-- | mail/e-mail-paned-view.c | 19 | ||||
-rw-r--r-- | mail/e-mail-paned-view.h | 3 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 184 | ||||
-rw-r--r-- | mail/e-mail-reader.h | 4 |
7 files changed, 334 insertions, 4 deletions
diff --git a/mail/e-mail-message-pane.c b/mail/e-mail-message-pane.c index 8df46a1a39..21f8264c84 100644 --- a/mail/e-mail-message-pane.c +++ b/mail/e-mail-message-pane.c @@ -90,9 +90,15 @@ e_mail_message_pane_init (EMailMessagePane *browser) EMailView * e_mail_message_pane_new (EShellView *shell_view) { + EMailView *widget; + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return g_object_new ( + widget = g_object_new ( E_TYPE_MAIL_MESSAGE_PANE, "shell-view", shell_view, NULL); + + e_mail_paned_view_set_enable_show_folder (E_MAIL_PANED_VIEW(widget), TRUE); + + return widget; } diff --git a/mail/e-mail-message-pane.h b/mail/e-mail-message-pane.h index 82cee3a13d..22d61a6416 100644 --- a/mail/e-mail-message-pane.h +++ b/mail/e-mail-message-pane.h @@ -52,6 +52,7 @@ typedef struct _EMailMessagePanePrivate EMailMessagePanePrivate; struct _EMailMessagePane { EMailPanedView parent; EMailMessagePanePrivate *priv; + EMailView *parent_folder_view; }; struct _EMailMessagePaneClass { diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c index 24dfb5e4fe..864d78ace1 100644 --- a/mail/e-mail-notebook-view.c +++ b/mail/e-mail-notebook-view.c @@ -376,6 +376,8 @@ create_tab_label (EMailNotebookView *view, gtk_widget_show_all (widget); gtk_box_pack_end (GTK_BOX(container), widget, FALSE, FALSE, 0); g_object_set_data ((GObject *)widget, "page", page); + g_object_set_data ((GObject *)page, "close-button", widget); + g_signal_connect ( widget, "clicked", G_CALLBACK (tab_remove_gtk_cb), view); @@ -864,6 +866,7 @@ mail_netbook_view_open_mail (EMailView *view, pos = emnv_get_page_num (nview, GTK_WIDGET (priv->current_view)); pane = e_mail_message_pane_new (shell_view); pane->prev = priv->current_view; + E_MAIL_MESSAGE_PANE(pane)->parent_folder_view = priv->current_view; priv->current_view = pane; gtk_widget_show (GTK_WIDGET (pane)); @@ -893,6 +896,8 @@ mail_netbook_view_open_mail (EMailView *view, #if HAVE_CLUTTER tab = (EMailTab *)e_mail_tab_new_full (camel_message_info_subject(info), NULL, 1); g_object_set_data ((GObject *)tab, "page", pane); + g_object_set_data ((GObject *)pane, "tab", tab); + clutter_actor_show((ClutterActor *)tab); clone = e_mail_tab_new_full (camel_message_info_subject(info), NULL, 200); @@ -932,7 +937,8 @@ mail_netbook_view_open_mail (EMailView *view, e_mail_reader_set_group_by_threads ( E_MAIL_READER (pane), e_mail_reader_get_group_by_threads (E_MAIL_READER(view))); - + + e_mail_reader_enable_show_folder (E_MAIL_READER(pane)); e_mail_reader_set_message (E_MAIL_READER (pane), uid); camel_message_info_free (info); } @@ -1105,8 +1111,10 @@ mail_notebook_view_set_folder (EMailReader *reader, tab = (EMailTab *)e_mail_tab_new_full (camel_folder_get_full_name(folder), NULL, 1); g_object_set_data ((GObject *)tab, "page", priv->current_view); g_object_set_data ((GObject *)priv->current_view, "page", tab); + g_object_set_data ((GObject *)priv->current_view, "tab", tab); + clutter_actor_show((ClutterActor *)tab); - + clone = build_histogram ((GtkWidget *)reader, folder); clutter_actor_set_reactive (clone, FALSE); clutter_actor_show (clone); @@ -1142,6 +1150,7 @@ mail_notebook_view_set_folder (EMailReader *reader, e_mail_tab_picker_get_current_tab (priv->tab_picker)); g_object_set_data ((GObject *)tab, "page", priv->current_view); g_object_set_data ((GObject *)priv->current_view, "page", tab); + g_object_set_data ((GObject *)priv->current_view, "tab", tab); e_mail_tab_set_text (tab, camel_folder_get_full_name(folder)); clone = build_histogram ((GtkWidget *)reader, folder); @@ -1189,6 +1198,17 @@ mail_notebook_view_show_search_bar (EMailReader *reader) e_mail_reader_show_search_bar (reader); } +static gboolean +mail_notebook_view_enable_show_folder (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return FALSE; + + return e_mail_reader_get_enable_show_folder (E_MAIL_READER(priv->current_view)); +} + static guint mail_notebook_view_open_selected_mail (EMailReader *reader) { @@ -1248,6 +1268,7 @@ e_mail_notebook_view_reader_init (EMailReaderIface *iface) iface->set_folder = mail_notebook_view_set_folder; iface->show_search_bar = mail_notebook_view_show_search_bar; iface->open_selected_mail = mail_notebook_view_open_selected_mail; + iface->enable_show_folder = mail_notebook_view_enable_show_folder; } static void @@ -1259,12 +1280,104 @@ e_mail_notebook_view_init (EMailNotebookView *view) view->priv->views = g_hash_table_new (g_str_hash, g_str_equal); } +static void +emnv_show_folder (EMailNotebookView *view, gpointer not_used) +{ + int pos; + EMailNotebookViewPrivate *priv = view->priv; + + pos = emnv_get_page_num (view, (GtkWidget *)E_MAIL_MESSAGE_PANE(priv->current_view)->parent_folder_view); + +#if HAVE_CLUTTER + e_mail_tab_picker_set_current_tab (priv->tab_picker, pos); + mnv_set_current_tab (E_MAIL_NOTEBOOK_VIEW(view), pos); +#else + gtk_notebook_set_current_page (priv->book, pos); +#endif + + +} + +static void +emnv_show_prevtab (EMailNotebookView *view, gpointer not_used) +{ + int pos; + EMailNotebookViewPrivate *priv = view->priv; + + pos = emnv_get_page_num (view, (GtkWidget *)E_MAIL_MESSAGE_PANE(priv->current_view)->parent_folder_view); + +#if HAVE_CLUTTER + pos = e_mail_tab_picker_get_current_tab (priv->tab_picker); + if (pos > 0) { + e_mail_tab_picker_set_current_tab (priv->tab_picker, pos-1); + mnv_set_current_tab (E_MAIL_NOTEBOOK_VIEW(view), pos-1); + } +#else + pos = gtk_notebook_get_current_page (priv->book); + if (pos > 0 ) + gtk_notebook_set_current_page (priv->book, pos-1); +#endif + + +} + +static void +emnv_show_nexttab (EMailNotebookView *view, gpointer not_used) +{ + int pos; + EMailNotebookViewPrivate *priv = view->priv; + + +#if HAVE_CLUTTER + pos = e_mail_tab_picker_get_current_tab (priv->tab_picker); + + if (pos < (gtk_notebook_get_n_pages (priv->book)-1)) { + e_mail_tab_picker_set_current_tab (priv->tab_picker, pos+1); + mnv_set_current_tab (E_MAIL_NOTEBOOK_VIEW(view), pos+1); + } +#else + pos = gtk_notebook_get_current_page (priv->book); + if (pos < (gtk_notebook_get_n_pages (priv->book)-1)) + gtk_notebook_set_current_page (priv->book, pos+1); +#endif + + +} + +static void +emnv_close_tab (EMailNotebookView *view, gpointer not_used) +{ + EMailNotebookViewPrivate *priv = view->priv; + +#if HAVE_CLUTTER + mnv_tab_closed (g_object_get_data((GObject *)priv->current_view, "tab"), + view); +#else + tab_remove_gtk_cb (g_object_get_data((GObject *)priv->current_view, "close-button"), + view); +#endif + + +} + GtkWidget * e_mail_notebook_view_new (EShellView *shell_view) { + GtkWidget *widget; + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return g_object_new ( + widget = g_object_new ( E_TYPE_MAIL_NOTEBOOK_VIEW, "shell-view", shell_view, NULL); + g_signal_connect (widget, "show-folder", + G_CALLBACK (emnv_show_folder), widget); + g_signal_connect (widget, "show-next-tab", + G_CALLBACK (emnv_show_nexttab), widget); + g_signal_connect (widget, "show-previous-tab", + G_CALLBACK (emnv_show_prevtab), widget); + g_signal_connect (widget, "close-tab", + G_CALLBACK (emnv_close_tab), widget); + + return widget; } diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index 2195f8740f..747147032c 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -71,6 +71,7 @@ struct _EMailPanedViewPrivate { /* Signal handler IDs */ guint message_list_built_id; + guint enable_show_folder : 1; }; enum { @@ -520,6 +521,16 @@ mail_paned_view_reader_open_selected_mail (EMailReader *reader) open_selected_mail (E_MAIL_PANED_VIEW (reader)); } +static gboolean +mail_paned_view_enable_show_folder (EMailReader *reader) +{ + EMailPanedViewPrivate *priv; + + priv = E_MAIL_PANED_VIEW (reader)->priv; + + return priv->enable_show_folder ? TRUE : FALSE; +} + static void mail_paned_view_constructed (GObject *object) { @@ -892,12 +903,14 @@ e_mail_paned_view_reader_init (EMailReaderIface *iface) iface->set_folder = mail_paned_view_set_folder; iface->show_search_bar = mail_paned_view_show_search_bar; iface->open_selected_mail = mail_paned_view_reader_open_selected_mail; + iface->enable_show_folder = mail_paned_view_enable_show_folder; } static void e_mail_paned_view_init (EMailPanedView *view) { view->priv = E_MAIL_PANED_VIEW_GET_PRIVATE (view); + view->priv->enable_show_folder = FALSE; g_signal_connect ( view, "notify::group-by-threads", @@ -934,3 +947,9 @@ e_mail_paned_view_get_preview (EMailPanedView *view) return view->priv->preview; } + +void +e_mail_paned_view_set_enable_show_folder (EMailPanedView *view, gboolean set) +{ + view->priv->enable_show_folder = set ? 1 : 0; +} diff --git a/mail/e-mail-paned-view.h b/mail/e-mail-paned-view.h index 9be60a854f..4869a9bb48 100644 --- a/mail/e-mail-paned-view.h +++ b/mail/e-mail-paned-view.h @@ -72,6 +72,9 @@ void e_mail_paned_view_hide_message_list_pane (EMailPanedView *view, gboolean visible); GtkWidget * e_mail_paned_view_get_preview (EMailPanedView *view); +void e_mail_paned_view_set_enable_show_folder + (EMailPanedView *view, + gboolean set); G_END_DECLS diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 63cbba1cf5..0cb67ce3b1 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -93,6 +93,10 @@ enum { FOLDER_LOADED, SHOW_SEARCH_BAR, UPDATE_ACTIONS, + SHOW_FOLDER, + SHOW_PREVTAB, + SHOW_NEXTTAB, + CLOSE_TAB, LAST_SIGNAL }; @@ -671,6 +675,34 @@ exit: } static void +action_mail_folder_cb (GtkAction *action, + EMailReader *reader) +{ + g_signal_emit (reader, signals[SHOW_FOLDER], 0); +} + +static void +action_mail_nexttab_cb (GtkAction *action, + EMailReader *reader) +{ + g_signal_emit (reader, signals[SHOW_NEXTTAB], 0); +} + +static void +action_mail_prevtab_cb (GtkAction *action, + EMailReader *reader) +{ + g_signal_emit (reader, signals[SHOW_PREVTAB], 0); +} + +static void +action_mail_closetab_cb (GtkAction *action, + EMailReader *reader) +{ + g_signal_emit (reader, signals[CLOSE_TAB], 0); +} + +static void action_mail_next_cb (GtkAction *action, EMailReader *reader) { @@ -1614,6 +1646,34 @@ static GtkActionEntry mail_reader_entries[] = { N_("Move selected messages to another folder"), G_CALLBACK (action_mail_move_cb) }, + { "mail-goto-folder", + NULL, + N_("_Switch to Folder"), + "<Control>Up", + N_("Display the parent folder"), + G_CALLBACK (action_mail_folder_cb) }, + + { "mail-goto-nexttab", + NULL, + N_("Switch to _next tab"), + "<Shift><Control>Down", + N_("Switch to the next tab"), + G_CALLBACK (action_mail_nexttab_cb) }, + + { "mail-goto-prevtab", + NULL, + N_("Switch to _previous tab"), + "<Shift><Control>Up", + N_("Switch to the previous tab"), + G_CALLBACK (action_mail_prevtab_cb) }, + + { "mail-close-tab", + NULL, + N_("Cl_ose current tab"), + "<Shift><Control>w", + N_("Close current tab"), + G_CALLBACK (action_mail_closetab_cb) }, + { "mail-next", GTK_STOCK_GO_FORWARD, N_("_Next Message"), @@ -2338,6 +2398,12 @@ mail_reader_get_folder_uri (EMailReader *reader) return MESSAGE_LIST (message_list)->folder_uri; } +static gboolean +mail_reader_get_enable_show_folder (EMailReader *reader) +{ + return FALSE; +} + static void mail_reader_set_folder (EMailReader *reader, CamelFolder *folder, @@ -2401,6 +2467,7 @@ mail_reader_update_actions (EMailReader *reader, GtkAction *action; const gchar *action_name; gboolean sensitive; + EMailReaderPrivate *priv; /* Be descriptive. */ gboolean any_messages_selected; @@ -2421,6 +2488,8 @@ mail_reader_update_actions (EMailReader *reader, gboolean selection_is_mailing_list; gboolean single_message_selected; + priv = E_MAIL_READER_GET_PRIVATE (reader); + shell_backend = e_mail_reader_get_shell_backend (reader); shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); @@ -2619,6 +2688,26 @@ mail_reader_update_actions (EMailReader *reader, action = e_mail_reader_get_action (reader, action_name); gtk_action_set_sensitive (action, sensitive); + action_name = "mail-goto-folder"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", e_mail_reader_get_enable_show_folder (reader), NULL); + gtk_action_set_sensitive (action, e_mail_reader_get_enable_show_folder (reader)); + + action_name = "mail-goto-nexttab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + + action_name = "mail-goto-prevtab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + + action_name = "mail-close-tab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + action_name = "mail-move"; sensitive = any_messages_selected; action = e_mail_reader_get_action (reader, action_name); @@ -2768,6 +2857,7 @@ mail_reader_class_init (EMailReaderIface *iface) iface->get_selected_uids = mail_reader_get_selected_uids; iface->get_folder = mail_reader_get_folder; iface->get_folder_uri = mail_reader_get_folder_uri; + iface->enable_show_folder = mail_reader_get_enable_show_folder; iface->set_folder = mail_reader_set_folder; iface->set_message = mail_reader_set_message; iface->open_selected_mail = e_mail_reader_open_selected; @@ -2807,6 +2897,42 @@ mail_reader_class_init (EMailReaderIface *iface) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[SHOW_FOLDER] = g_signal_new ( + "show-folder", + G_OBJECT_CLASS_TYPE (iface), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[SHOW_NEXTTAB] = g_signal_new ( + "show-next-tab", + G_OBJECT_CLASS_TYPE (iface), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[SHOW_PREVTAB] = g_signal_new ( + "show-previous-tab", + G_OBJECT_CLASS_TYPE (iface), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[CLOSE_TAB] = g_signal_new ( + "close-tab", + G_OBJECT_CLASS_TYPE (iface), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + signals[UPDATE_ACTIONS] = g_signal_new ( "update-actions", G_OBJECT_CLASS_TYPE (iface), @@ -2953,6 +3079,26 @@ e_mail_reader_init (EMailReader *reader) action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "is-important", TRUE, NULL); + action_name = "mail-goto-folder"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, e_mail_reader_get_enable_show_folder (reader)); + + action_name = "mail-goto-nexttab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + + action_name = "mail-goto-prevtab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + + action_name = "mail-close-tab"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", FALSE, NULL); + gtk_action_set_sensitive (action, TRUE); + action_name = "mail-next"; action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "short-label", _("Next"), NULL); @@ -3566,3 +3712,41 @@ e_mail_reader_show_search_bar (EMailReader *reader) g_signal_emit (reader, signals[SHOW_SEARCH_BAR], 0); } + +void +e_mail_reader_enable_show_folder (EMailReader *reader) +{ + GtkAction *action; + const gchar *action_name; + EMailReaderPrivate *priv; + CamelFolder *folder; + char *label; + + g_return_if_fail (E_IS_MAIL_READER (reader)); + + priv = E_MAIL_READER_GET_PRIVATE (reader); + folder = e_mail_reader_get_folder (reader); + + label = g_strdup_printf (_("Folder '%s'"), camel_folder_get_full_name(folder)); + + action_name = "mail-goto-folder"; + action = e_mail_reader_get_action (reader, action_name); + g_object_set (action, "visible", TRUE, + "label", label, NULL); + gtk_action_set_sensitive (action, e_mail_reader_get_enable_show_folder (reader)); + + g_free (label); +} + +gboolean +e_mail_reader_get_enable_show_folder (EMailReader *reader) +{ + EMailReaderIface *iface; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE); + + iface = E_MAIL_READER_GET_IFACE (reader); + g_return_val_if_fail (iface->enable_show_folder != NULL, FALSE); + + return iface->enable_show_folder (reader); +} diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index 11df448b18..187d7a4399 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -100,6 +100,7 @@ struct _EMailReaderIface { void (*set_message) (EMailReader *reader, const gchar *uid); guint (*open_selected_mail) (EMailReader *reader); + gboolean (*enable_show_folder) (EMailReader *reader); /* Signals */ void (*show_search_bar) (EMailReader *reader); @@ -145,6 +146,9 @@ void e_mail_reader_create_charset_menu GtkUIManager *ui_manager, guint merge_id); void e_mail_reader_show_search_bar (EMailReader *reader); +gboolean e_mail_reader_get_enable_show_folder + (EMailReader *reader); +void e_mail_reader_enable_show_folder(EMailReader *reader); G_END_DECLS |