Mercurial > pidgin
changeset 5569:5d2911d6d38e
[gaim-migrate @ 5971]
The accounts dialog is getting there..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 30 May 2003 19:59:27 +0000 |
parents | fb4f7bd7525c |
children | dc90686acedd |
files | src/gtkaccount.c src/prefs.c |
diffstat | 2 files changed, 200 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkaccount.c Fri May 30 19:29:49 2003 +0000 +++ b/src/gtkaccount.c Fri May 30 19:59:27 2003 +0000 @@ -24,15 +24,37 @@ #include "account.h" #include "prefs.h" #include "stock.h" +#include "gtkblist.h" + +enum +{ + COLUMN_ICON, + COLUMN_SCREENNAME, + COLUMN_ONLINE, + COLUMN_AUTOLOGIN, + COLUMN_PROTOCOL, + COLUMN_DATA, + NUM_COLUMNS +}; typedef struct { GtkWidget *window; + GtkListStore *model; + } AccountsDialog; static AccountsDialog *accounts_dialog = NULL; +static char * +proto_name(int proto) +{ + GaimPlugin *p = gaim_find_prpl(proto); + + return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); +} + static gint __window_destroy_cb(GtkWidget *w, GdkEvent *event, void *unused) { @@ -53,10 +75,168 @@ return FALSE; } +static void +__add_account_cb(GtkWidget *w, AccountsDialog *dialog) +{ + +} + +static void +__modify_account_cb(GtkWidget *w, AccountsDialog *dialog) +{ + +} + +static void +__delete_account_cb(GtkWidget *w, AccountsDialog *dialog) +{ + +} + +static void +__close_accounts_cb(GtkWidget *w, AccountsDialog *dialog) +{ + +} + +static void +__online_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data) +{ + +} + +static void +__autologin_cb(GtkCellRendererToggle *renderer, gchar *path_str, + gpointer data) +{ + +} + +static void +__add_columns(GtkWidget *treeview, AccountsDialog *dialog) +{ + GtkCellRenderer *renderer; + + /* Protocol Icon */ + renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), + -1, "", + renderer, + "pixbuf", COLUMN_ICON, + NULL); + + /* Screennames */ + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), + -1, _("Screenname"), + renderer, + "text", COLUMN_SCREENNAME, + NULL); + + /* Online? */ + renderer = gtk_cell_renderer_toggle_new(); + + g_signal_connect(G_OBJECT(renderer), "toggled", + G_CALLBACK(__online_cb), dialog); + + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), + -1, _("Online"), + renderer, + "text", COLUMN_ONLINE, + NULL); + + + /* Auto-login? */ + renderer = gtk_cell_renderer_toggle_new(); + + g_signal_connect(G_OBJECT(renderer), "toggled", + G_CALLBACK(__autologin_cb), dialog); + + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), + -1, _("Auto-login"), + renderer, + "text", COLUMN_AUTOLOGIN, + NULL); + + + /* Protocol description */ + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), + -1, _("Protocol"), + renderer, + "text", COLUMN_PROTOCOL, + NULL); +} + +static void +__populate_accounts_list(AccountsDialog *dialog) +{ + GList *l; + GaimAccount *account; + GtkTreeIter iter; + GdkPixbuf *pixbuf; + GdkPixbuf *scale; + + gtk_list_store_clear(dialog->model); + + for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { + account = l->data; + + pixbuf = create_prpl_icon(account); + scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); + + gtk_list_store_append(dialog->model, &iter); + gtk_list_store_set(dialog->model, &iter, + COLUMN_ICON, scale, + COLUMN_SCREENNAME, gaim_account_get_username(account), + COLUMN_ONLINE, gaim_account_is_connected(account), + COLUMN_AUTOLOGIN, FALSE, + COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), + COLUMN_DATA, account, + -1); + + g_object_unref(G_OBJECT(pixbuf)); + g_object_unref(G_OBJECT(scale)); + } +} + static GtkWidget * -__create_accounts_list(void) +__create_accounts_list(AccountsDialog *dialog) { - return NULL; + GtkWidget *sw; + GtkWidget *treeview; + + /* Create the scrolled window. */ + sw = gtk_scrolled_window_new(0, 0); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_ALWAYS); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), + GTK_SHADOW_IN); + gtk_widget_show(sw); + + /* Create the list model. */ + dialog->model = gtk_list_store_new(NUM_COLUMNS, G_TYPE_POINTER, + G_TYPE_STRING, G_TYPE_BOOLEAN, + G_TYPE_BOOLEAN, G_TYPE_STRING, + G_TYPE_POINTER); + + /* And now the actual treeview */ + treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); + gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), TRUE); + gtk_tree_selection_set_mode( + gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), + GTK_SELECTION_MULTIPLE); + + __add_columns(treeview, dialog); + + gtk_container_add(GTK_CONTAINER(sw), treeview); + gtk_widget_show(treeview); + + __populate_accounts_list(dialog); + + return sw; } void @@ -74,12 +254,12 @@ if (accounts_dialog != NULL) return; - dialog = g_new0(AccountsDialog, 1); + accounts_dialog = dialog = g_new0(AccountsDialog, 1); width = gaim_prefs_get_int("/gaim/gtk/accounts/dialog/width"); height = gaim_prefs_get_int("/gaim/gtk/accounts/dialog/height"); - win = accounts_dialog->window; + win = dialog->window; GAIM_DIALOG(win); gtk_window_set_default_size(GTK_WINDOW(win), width, height); @@ -98,11 +278,9 @@ gtk_widget_show(vbox); /* Setup the scrolled window that will contain the list of accounts. */ -#if 0 - sw = __create_accounts_list(); + sw = __create_accounts_list(dialog); gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); gtk_widget_show(sw); -#endif /* Separator... */ sep = gtk_hseparator_new(); @@ -114,28 +292,40 @@ gtk_box_set_spacing(GTK_BOX(bbox), 6); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); - gtk_widget_show(vbox); + gtk_widget_show(bbox); /* Add button */ button = gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(__add_account_cb), dialog); + /* Modify button */ button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(__modify_account_cb), dialog); + /* Delete button */ button = gtk_button_new_from_stock(GTK_STOCK_DELETE); - gtk_box_pack_start(GTK_BOX(button), button, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(__delete_account_cb), dialog); + /* Close button */ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - gtk_box_pack_start(GTK_BOX(button), button, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(__close_accounts_cb), dialog); + gtk_widget_show(win); }
--- a/src/prefs.c Fri May 30 19:29:49 2003 +0000 +++ b/src/prefs.c Fri May 30 19:59:27 2003 +0000 @@ -440,7 +440,6 @@ gboolean gaim_prefs_get_bool(const char *name) { struct gaim_pref *pref = find_pref(name); - printf("bool name = '%s'\n", name); g_return_val_if_fail(pref != NULL, FALSE); g_return_val_if_fail(pref->type == GAIM_PREF_BOOLEAN, FALSE);