void e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) { EMailShellViewPrivate *priv = mail_shell_view->priv; EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EShell *shell; EShellView *shell_view; EShellBackend *shell_backend; EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellTaskbar *shell_taskbar; EShellWindow *shell_window; EShellSearchbar *searchbar; EMFolderTree *folder_tree; EActionComboBox *combo_box; ERuleContext *context; EFilterRule *rule = NULL; GtkTreeSelection *selection; GtkUIManager *ui_manager; GtkWidget *message_list; GSettings *settings; EMailLabelListStore *label_store; EMailBackend *backend; EMailSession *session; EMailReader *reader; EMailView *mail_view; EMailDisplay *display; const gchar *source; guint merge_id; gint ii = 0; shell_view = E_SHELL_VIEW (mail_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); shell_taskbar = e_shell_view_get_shell_taskbar (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); ui_manager = e_shell_window_get_ui_manager (shell_window); shell = e_shell_window_get_shell (shell_window); backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); label_store = e_mail_ui_session_get_label_store ( E_MAIL_UI_SESSION (session)); e_shell_window_add_action_group (shell_window, "mail"); e_shell_window_add_action_group (shell_window, "mail-filter"); e_shell_window_add_action_group (shell_window, "mail-label"); e_shell_window_add_action_group (shell_window, "search-folders"); merge_id = gtk_ui_manager_new_merge_id (ui_manager); priv->label_merge_id = merge_id; /* Cache these to avoid lots of awkward casting. */ priv->mail_shell_backend = g_object_ref (shell_backend); priv->mail_shell_content = g_object_ref (shell_content); priv->mail_shell_sidebar = g_object_ref (shell_sidebar); mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (shell_sidebar); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content); mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); combo_box = e_shell_searchbar_get_scope_combo_box (searchbar); reader = E_MAIL_READER (shell_content); display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); em_folder_tree_set_selectable_widget (folder_tree, message_list); /* The folder tree and scope combo box are both insensitive * when searching beyond the currently selected folder. */ e_binding_bind_property ( folder_tree, "sensitive", combo_box, "sensitive", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); g_signal_connect_object ( combo_box, "changed", G_CALLBACK (mail_shell_view_search_filter_changed_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( folder_tree, "folder-selected", G_CALLBACK (mail_shell_view_folder_tree_selected_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( folder_tree, "key-press-event", G_CALLBACK (mail_shell_view_folder_tree_key_press_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( folder_tree, "popup-event", G_CALLBACK (mail_shell_view_folder_tree_popup_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( message_list, "key-press", G_CALLBACK (mail_shell_view_message_list_key_press_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( message_list, "popup-menu", G_CALLBACK (mail_shell_view_message_list_popup_menu_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( message_list, "right-click", G_CALLBACK (mail_shell_view_message_list_right_click_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( reader, "changed", G_CALLBACK (mail_shell_view_reader_changed_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( mail_view, "update-actions", G_CALLBACK (mail_shell_view_reader_update_actions_cb), mail_shell_view, 0); g_signal_connect_object ( reader, "folder-loaded", G_CALLBACK (e_mail_view_update_view_instance), mail_view, G_CONNECT_SWAPPED); /* Use the same callback as "changed". */ g_signal_connect_object ( reader, "folder-loaded", G_CALLBACK (mail_shell_view_reader_changed_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( reader, "folder-loaded", G_CALLBACK (e_mail_shell_view_restore_state), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( label_store, "changed", G_CALLBACK (e_mail_shell_view_update_search_filter), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( display, "key-press-event", G_CALLBACK (mail_shell_view_key_press_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( display, "popup-event", G_CALLBACK (mail_shell_view_popup_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( display, "status-message", G_CALLBACK (e_shell_taskbar_set_message), shell_taskbar, G_CONNECT_SWAPPED); g_signal_connect_object ( mail_shell_view, "toggled", G_CALLBACK (e_mail_shell_view_update_send_receive_menus), mail_shell_view, G_CONNECT_AFTER | G_CONNECT_SWAPPED); /* Need to keep the handler ID so we can disconnect it in * dispose(). The shell outlives us and we don't want it * invoking callbacks on finalized shell views. */ priv->prepare_for_quit_handler_id = g_signal_connect_object ( shell, "prepare-for-quit", G_CALLBACK (mail_shell_view_prepare_for_quit_cb), mail_shell_view, G_CONNECT_SWAPPED); e_mail_reader_init (reader, TRUE, FALSE); e_mail_shell_view_actions_init (mail_shell_view); e_mail_shell_view_update_search_filter (mail_shell_view); /* This binding must come after e_mail_reader_init(). */ e_binding_bind_property ( shell_content, "group-by-threads", mail_view, "group-by-threads", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); settings = e_util_ref_settings ("org.gnome.evolution.mail"); g_settings_bind ( settings, "vfolder-allow-expunge", mail_shell_view, "vfolder-allow-expunge", G_SETTINGS_BIND_GET); g_clear_object (&settings); /* Populate built-in rules for search entry popup menu. * Keep the assertions, please. If the conditions aren't * met we're going to crash anyway, just more mysteriously. */ context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context; source = E_FILTER_SOURCE_DEMAND; while ((rule = e_rule_context_next_rule (context, rule, source))) { if (!rule->system) continue; g_return_if_fail (ii < MAIL_NUM_SEARCH_RULES); priv->search_rules[ii++] = g_object_ref (rule); } g_return_if_fail (ii == MAIL_NUM_SEARCH_RULES); /* Now that we're all set up, simulate selecting a folder. */ g_signal_emit_by_name (selection, "changed"); }
static void mail_browser_constructed (GObject *object) { EMailBrowser *browser; EMailReader *reader; EMailBackend *backend; EMailSession *session; EShellBackend *shell_backend; EShell *shell; EFocusTracker *focus_tracker; GtkAccelGroup *accel_group; GtkActionGroup *action_group; GtkAction *action; GtkUIManager *ui_manager; GtkWidget *container; GtkWidget *display; GtkWidget *widget; const gchar *domain; const gchar *id; guint merge_id; /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_mail_browser_parent_class)->constructed (object); browser = E_MAIL_BROWSER (object); reader = E_MAIL_READER (object); backend = e_mail_reader_get_backend (reader); session = e_mail_backend_get_session (backend); shell_backend = E_SHELL_BACKEND (backend); shell = e_shell_backend_get_shell (shell_backend); ui_manager = gtk_ui_manager_new (); browser->priv->ui_manager = ui_manager; domain = GETTEXT_PACKAGE; gtk_application_add_window ( GTK_APPLICATION (shell), GTK_WINDOW (object)); /* The message list is a widget, but it is not shown in the browser. * Unfortunately, the widget is inseparable from its model, and the * model is all we need. */ browser->priv->message_list = message_list_new (session); g_object_ref_sink (browser->priv->message_list); g_signal_connect_swapped ( browser->priv->message_list, "message-selected", G_CALLBACK (mail_browser_message_selected_cb), object); g_signal_connect_swapped ( browser->priv->message_list, "message-list-built", G_CALLBACK (mail_browser_message_list_built_cb), object); display = e_mail_display_new (e_mail_backend_get_remote_content (backend)); e_mail_display_set_mode ( E_MAIL_DISPLAY (display), browser->priv->display_mode); g_signal_connect_swapped ( display, "popup-event", G_CALLBACK (mail_browser_popup_event_cb), object); g_signal_connect_swapped ( display, "status-message", G_CALLBACK (mail_browser_status_message_cb), object); widget = e_preview_pane_new (E_WEB_VIEW (display)); browser->priv->preview_pane = g_object_ref (widget); gtk_widget_show (widget); action_group = gtk_action_group_new (ACTION_GROUP_STANDARD); gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_add_actions ( action_group, mail_browser_entries, G_N_ELEMENTS (mail_browser_entries), object); e_action_group_add_popup_actions ( action_group, mail_browser_popup_entries, G_N_ELEMENTS (mail_browser_popup_entries)); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* For easy access. Takes ownership of the reference. */ g_object_set_data_full ( object, ACTION_GROUP_STANDARD, action_group, (GDestroyNotify) g_object_unref); action_group = gtk_action_group_new (ACTION_GROUP_SEARCH_FOLDERS); gtk_action_group_set_translation_domain (action_group, domain); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* For easy access. Takes ownership of the reference. */ g_object_set_data_full ( object, ACTION_GROUP_SEARCH_FOLDERS, action_group, (GDestroyNotify) g_object_unref); e_mail_reader_init (reader, TRUE, TRUE); e_load_ui_manager_definition (ui_manager, E_MAIL_READER_UI_DEFINITION); gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL); merge_id = gtk_ui_manager_new_merge_id (ui_manager); e_mail_reader_create_charset_menu (reader, ui_manager, merge_id); accel_group = gtk_ui_manager_get_accel_group (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (object), accel_group); g_signal_connect_swapped ( ui_manager, "connect-proxy", G_CALLBACK (mail_browser_connect_proxy_cb), object); e_mail_reader_connect_remote_content (reader); /* Configure an EFocusTracker to manage selection actions. */ focus_tracker = e_focus_tracker_new (GTK_WINDOW (object)); action = e_mail_reader_get_action (reader, "cut-clipboard"); e_focus_tracker_set_cut_clipboard_action (focus_tracker, action); action = e_mail_reader_get_action (reader, "copy-clipboard"); e_focus_tracker_set_copy_clipboard_action (focus_tracker, action); action = e_mail_reader_get_action (reader, "paste-clipboard"); e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); action = e_mail_reader_get_action (reader, "select-all"); e_focus_tracker_set_select_all_action (focus_tracker, action); browser->priv->focus_tracker = focus_tracker; /* Construct window widgets. */ widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (object), widget); gtk_widget_show (widget); container = widget; widget = gtk_statusbar_new (); gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0); browser->priv->statusbar = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_ui_manager_get_widget (ui_manager, "/main-menu"); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); browser->priv->main_menu = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar"); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); browser->priv->main_toolbar = g_object_ref (widget); gtk_widget_show (widget); gtk_style_context_add_class ( gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_PRIMARY_TOOLBAR); gtk_box_pack_start ( GTK_BOX (container), browser->priv->preview_pane, TRUE, TRUE, 0); id = "org.gnome.evolution.mail.browser"; e_plugin_ui_register_manager (ui_manager, id, object); e_plugin_ui_enable_manager (ui_manager, id); e_extensible_load_extensions (E_EXTENSIBLE (object)); }