X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-account-view.c;h=4efea80c24bc970af39ed49c98943273f320fc71;hb=de3a049cc864aafde18e98d8b4b4d9277a92f938;hp=037fd7f44e6659bed9053cb15dfcb5073e744eb6;hpb=9ad90e9053e1e0cc87885f714f513061ac734632;p=modest diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index 037fd7f..4efea80 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -27,8 +27,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include "modest-account-view.h" -/* include other impl specific header files */ +#include +#include +#include +#include /* 'private'/'protected' functions */ static void modest_account_view_class_init (ModestAccountViewClass *klass); @@ -101,13 +105,6 @@ modest_account_view_class_init (ModestAccountViewClass *klass) gobject_class->finalize = modest_account_view_finalize; g_type_class_add_private (gobject_class, sizeof(ModestAccountViewPrivate)); - - /* signal definitions go here, e.g.: */ -/* signals[MY_SIGNAL_1] = */ -/* g_signal_new ("my_signal_1",....); */ -/* signals[MY_SIGNAL_2] = */ -/* g_signal_new ("my_signal_2",....); */ -/* etc. */ } static void @@ -156,32 +153,38 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) while (cursor) { gchar *proto = NULL; - gchar *store, *account_name; + gchar *store, *account_name, *display_name; gboolean enabled; account_name = (gchar*)cursor->data; - store = modest_account_mgr_get_string (account_mgr, + display_name = modest_account_mgr_get_string (account_mgr, account_name, - MODEST_ACCOUNT_STORE_ACCOUNT, + MODEST_ACCOUNT_DISPLAY_NAME, FALSE, NULL); + /* don't display accounts without stores */ if (store) { - - proto = modest_account_mgr_get_string (account_mgr, - store, - MODEST_ACCOUNT_PROTO, - TRUE, NULL); - g_free(store); - } - - enabled = modest_account_mgr_account_get_enabled (account_mgr, account_name); - gtk_list_store_insert_with_values ( - model, NULL, 0, - ENABLED_COLUMN, enabled, - NAME_COLUMN, account_name, - PROTO_COLUMN, proto, - -1); + store = modest_account_mgr_get_string (account_mgr, + account_name, + MODEST_ACCOUNT_STORE_ACCOUNT, + FALSE, NULL); + if (store) { + proto = modest_account_mgr_get_string (account_mgr, + store, + MODEST_ACCOUNT_PROTO, + TRUE, NULL); + g_free(store); + } + enabled = modest_account_mgr_account_get_enabled (account_mgr, account_name); + gtk_list_store_insert_with_values ( + model, NULL, 0, + ENABLED_COLUMN, enabled, + NAME_COLUMN, display_name, + PROTO_COLUMN, proto, + -1); + } + g_free (display_name); g_free (account_name); g_free (proto); @@ -238,12 +241,10 @@ on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, g_free (account_name); } - static void init_view (ModestAccountView *self) { ModestAccountViewPrivate *priv; - GtkTreeSelection *sel; GtkCellRenderer *renderer; GtkListStore *model; @@ -278,8 +279,6 @@ init_view (ModestAccountView *self) gtk_cell_renderer_text_new (), "text", PROTO_COLUMN, NULL)); - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(self)); - priv->sig1 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_removed", G_CALLBACK(on_account_removed), self); @@ -310,3 +309,22 @@ modest_account_view_new (ModestAccountMgr *account_mgr) return MODEST_ACCOUNT_VIEW(obj); } +const gchar * +modest_account_view_get_selected_account (ModestAccountView *self) +{ + const gchar *account_name = NULL; + GtkTreeSelection *sel; + GtkTreeModel *model; + GtkTreeIter iter; + + g_return_val_if_fail (MODEST_IS_ACCOUNT_VIEW (self), NULL); + + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self)); + if (gtk_tree_selection_get_selected (sel, &model, &iter)) { + gtk_tree_model_get (model, &iter, + NAME_COLUMN, &account_name, + -1); + } + + return account_name; +}