Listing configured accounts in the preferences menu
This commit is contained in:
parent
dd058085f8
commit
7df68d3123
@ -62,6 +62,7 @@ Account * account_new(char const * type, char const * name)
|
|||||||
}
|
}
|
||||||
free(filename);
|
free(filename);
|
||||||
account->title = strdup(name);
|
account->title = strdup(name);
|
||||||
|
account->enabled = 1;
|
||||||
account->identity = NULL;
|
account->identity = NULL;
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
@ -95,6 +96,23 @@ int account_set_title(Account * account, char const * title)
|
|||||||
|
|
||||||
|
|
||||||
/* useful */
|
/* useful */
|
||||||
|
/* account_disable */
|
||||||
|
int account_disable(Account * account)
|
||||||
|
{
|
||||||
|
account->enabled = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* account_enable */
|
||||||
|
int account_enable(Account * account)
|
||||||
|
{
|
||||||
|
account->enabled = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* account_folders */
|
||||||
AccountFolder ** account_folders(Account * account)
|
AccountFolder ** account_folders(Account * account)
|
||||||
{
|
{
|
||||||
return account->plugin->folders();
|
return account->plugin->folders();
|
||||||
|
@ -69,6 +69,7 @@ typedef struct _Account
|
|||||||
{
|
{
|
||||||
char * name;
|
char * name;
|
||||||
char * title;
|
char * title;
|
||||||
|
int enabled;
|
||||||
AccountIdentity * identity;
|
AccountIdentity * identity;
|
||||||
void * handle;
|
void * handle;
|
||||||
AccountPlugin * plugin;
|
AccountPlugin * plugin;
|
||||||
@ -83,6 +84,8 @@ void account_delete(Account * account);
|
|||||||
int account_set_title(Account * account, char const * title);
|
int account_set_title(Account * account, char const * title);
|
||||||
|
|
||||||
/* useful */
|
/* useful */
|
||||||
|
int account_disable(Account * account);
|
||||||
|
int account_enable(Account * account);
|
||||||
/* FIXME wrong we just need receive, then it calls callbacks */
|
/* FIXME wrong we just need receive, then it calls callbacks */
|
||||||
AccountFolder ** account_folders(Account * account);
|
AccountFolder ** account_folders(Account * account);
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ static char const _copyright[] =
|
|||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
static char const * _authors[] =
|
static char const * _authors[] =
|
||||||
@ -82,6 +84,7 @@ void on_file_quit(GtkWidget * widget, gpointer data)
|
|||||||
typedef enum _AccountColumn
|
typedef enum _AccountColumn
|
||||||
{
|
{
|
||||||
AC_DATA,
|
AC_DATA,
|
||||||
|
AC_ACTIVE,
|
||||||
AC_ENABLED,
|
AC_ENABLED,
|
||||||
AC_TITLE,
|
AC_TITLE,
|
||||||
AC_TYPE
|
AC_TYPE
|
||||||
@ -100,6 +103,8 @@ void on_edit_preferences(GtkWidget * widget, gpointer data)
|
|||||||
GtkWidget * vbox3;
|
GtkWidget * vbox3;
|
||||||
GtkSizeGroup * group;
|
GtkSizeGroup * group;
|
||||||
GtkListStore * store;
|
GtkListStore * store;
|
||||||
|
unsigned int i;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
if(mailer->pr_window != NULL)
|
if(mailer->pr_window != NULL)
|
||||||
{
|
{
|
||||||
@ -126,8 +131,15 @@ void on_edit_preferences(GtkWidget * widget, gpointer data)
|
|||||||
GTK_SHADOW_IN);
|
GTK_SHADOW_IN);
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
||||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
store = gtk_list_store_new(AC_LAST+1, G_TYPE_POINTER, G_TYPE_BOOLEAN,
|
store = gtk_list_store_new(AC_LAST + 1, G_TYPE_POINTER, G_TYPE_BOOLEAN,
|
||||||
G_TYPE_STRING, G_TYPE_STRING);
|
G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
|
||||||
|
for(i = 0; i < mailer->account_cnt; i++)
|
||||||
|
gtk_list_store_insert_with_values(store, &iter, -1,
|
||||||
|
AC_DATA, mailer->account[i],
|
||||||
|
AC_ACTIVE, TRUE,
|
||||||
|
AC_ENABLED, mailer->account[i]->enabled,
|
||||||
|
AC_TITLE, mailer->account[i]->title,
|
||||||
|
AC_TYPE, mailer->account[i]->plugin->type, -1);
|
||||||
mailer->pr_accounts = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
mailer->pr_accounts = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||||
store));
|
store));
|
||||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mailer->pr_accounts),
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mailer->pr_accounts),
|
||||||
@ -301,26 +313,39 @@ void on_print(GtkWidget * widget, gpointer data)
|
|||||||
void on_preferences_ok(GtkWidget * widget, gpointer data)
|
void on_preferences_ok(GtkWidget * widget, gpointer data)
|
||||||
{
|
{
|
||||||
Mailer * mailer = data;
|
Mailer * mailer = data;
|
||||||
Account * account;
|
|
||||||
GtkTreeModel * model;
|
GtkTreeModel * model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeModel * view_model;
|
GtkTreeModel * view_model;
|
||||||
GtkTreeIter view_iter;
|
Account * account;
|
||||||
|
gboolean active;
|
||||||
|
gboolean enabled;
|
||||||
|
|
||||||
gtk_widget_hide(mailer->pr_window);
|
gtk_widget_hide(mailer->pr_window);
|
||||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(mailer->pr_accounts));
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(mailer->pr_accounts));
|
||||||
view_model = gtk_tree_view_get_model(GTK_TREE_VIEW(
|
view_model = gtk_tree_view_get_model(GTK_TREE_VIEW(
|
||||||
mailer->view_folders));
|
mailer->view_folders));
|
||||||
if(gtk_tree_model_get_iter_first(model, &iter) != FALSE)
|
if(gtk_tree_model_get_iter_first(model, &iter) == FALSE)
|
||||||
do
|
return;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
gtk_tree_model_get(model, &iter, AC_DATA, &account,
|
||||||
|
AC_ACTIVE, &active, AC_ENABLED, &enabled, -1);
|
||||||
|
if(active)
|
||||||
{
|
{
|
||||||
/* FIXME check if already present, update if needed */
|
if(enabled)
|
||||||
/* else add account with full information */
|
continue;
|
||||||
gtk_tree_model_get(model, &iter, AC_DATA, &account, -1);
|
if(mailer_account_disable(mailer, account) == 0)
|
||||||
mailer_account_add(mailer, account);
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter,
|
||||||
|
AC_ACTIVE, FALSE, -1);
|
||||||
}
|
}
|
||||||
while(gtk_tree_model_iter_next(model, &iter) == TRUE);
|
else if(enabled)
|
||||||
/* FIXME remove remaining accounts */
|
{
|
||||||
|
if(mailer_account_add(mailer, account) == 0)
|
||||||
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter,
|
||||||
|
AC_ACTIVE, TRUE, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(gtk_tree_model_iter_next(model, &iter) == TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,5 +66,9 @@ void mailer_delete(Mailer * mailer);
|
|||||||
int mailer_error(Mailer * mailer, char const * message, int ret);
|
int mailer_error(Mailer * mailer, char const * message, int ret);
|
||||||
|
|
||||||
int mailer_account_add(Mailer * mailer, Account * account);
|
int mailer_account_add(Mailer * mailer, Account * account);
|
||||||
|
int mailer_account_disable(Mailer * mailer, Account * account);
|
||||||
|
int mailer_account_enable(Mailer * mailer, Account * account);
|
||||||
|
/* FIXME implement
|
||||||
|
int mailer_account_remove(Mailer * mailer, Account * account); */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user