diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-10 05:52:37 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-14 20:08:47 +0800 |
commit | bf1b8a45c5a45f96679a9a82589393c20631f6a8 (patch) | |
tree | 3d13ba2c6276ae2da6e38b9e835770e11e2afa2e /mail/e-mail-sidebar.c | |
parent | f0f1b9c4bb8ea1d2bfb3ca54aa9494c2f38c8820 (diff) | |
download | gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar.gz gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar.bz2 gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar.lz gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar.xz gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.tar.zst gsoc2013-evolution-bf1b8a45c5a45f96679a9a82589393c20631f6a8.zip |
EMFolderTree: Clean up initialization logic.
Some things are getting initialized too early. Not causing any bugs at
present, but it's bad form. Defer non-trivial initialization steps to
the constructed() method.
Diffstat (limited to 'mail/e-mail-sidebar.c')
-rw-r--r-- | mail/e-mail-sidebar.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c index 36136619e5..d2179057a5 100644 --- a/mail/e-mail-sidebar.c +++ b/mail/e-mail-sidebar.c @@ -198,6 +198,32 @@ mail_sidebar_get_property (GObject *object, } static void +mail_sidebar_constructed (GObject *object) +{ + GtkTreeSelection *selection; + GtkTreeView *tree_view; + GtkTreeModel *model; + + /* Chain up to parent's constructed() property. */ + G_OBJECT_CLASS (e_mail_sidebar_parent_class)->constructed (object); + + tree_view = GTK_TREE_VIEW (object); + model = gtk_tree_view_get_model (tree_view); + selection = gtk_tree_view_get_selection (tree_view); + + em_folder_tree_model_set_selection ( + EM_FOLDER_TREE_MODEL (model), selection); + + g_signal_connect ( + model, "loaded-row", + G_CALLBACK (mail_sidebar_model_loaded_row_cb), object); + + g_signal_connect ( + selection, "changed", + G_CALLBACK (mail_sidebar_selection_changed_cb), object); +} + +static void mail_sidebar_row_expanded (GtkTreeView *tree_view, GtkTreeIter *unused, GtkTreePath *path) @@ -397,6 +423,7 @@ e_mail_sidebar_class_init (EMailSidebarClass *class) object_class = G_OBJECT_CLASS (class); object_class->set_property = mail_sidebar_set_property; object_class->get_property = mail_sidebar_get_property; + object_class->constructed = mail_sidebar_constructed; tree_view_class = GTK_TREE_VIEW_CLASS (class); tree_view_class->row_expanded = mail_sidebar_row_expanded; @@ -426,9 +453,6 @@ e_mail_sidebar_class_init (EMailSidebarClass *class) static void e_mail_sidebar_init (EMailSidebar *sidebar) { - GtkTreeModel *model; - GtkTreeView *tree_view; - GtkTreeSelection *selection; EMFolderTree *folder_tree; sidebar->priv = E_MAIL_SIDEBAR_GET_PRIVATE (sidebar); @@ -436,34 +460,24 @@ e_mail_sidebar_init (EMailSidebar *sidebar) folder_tree = EM_FOLDER_TREE (sidebar); em_folder_tree_set_excluded (folder_tree, 0); em_folder_tree_enable_drag_and_drop (folder_tree); - - tree_view = GTK_TREE_VIEW (sidebar); - model = gtk_tree_view_get_model (tree_view); - selection = gtk_tree_view_get_selection (tree_view); - - em_folder_tree_model_set_selection ( - EM_FOLDER_TREE_MODEL (model), selection); - - g_signal_connect ( - model, "loaded-row", - G_CALLBACK (mail_sidebar_model_loaded_row_cb), sidebar); - - g_signal_connect ( - selection, "changed", - G_CALLBACK (mail_sidebar_selection_changed_cb), sidebar); } GtkWidget * e_mail_sidebar_new (EMailBackend *backend, EAlertSink *alert_sink) { + EMFolderTreeModel *model; + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL); + model = em_folder_tree_model_get_default (); + return g_object_new ( E_TYPE_MAIL_SIDEBAR, "alert-sink", alert_sink, - "backend", backend, NULL); + "backend", backend, + "model", model, NULL); } GKeyFile * |