Mercurial > pidgin.yaz
comparison src/gtkaccount.c @ 5698:81d7b4239815
[gaim-migrate @ 6119]
The new accounts show up in the account editor. Saving is almost done.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 03 Jun 2003 09:21:18 +0000 |
parents | fc659d75fcf7 |
children | 3bac8b558577 |
comparison
equal
deleted
inserted
replaced
5697:fc659d75fcf7 | 5698:81d7b4239815 |
---|---|
71 | 71 |
72 typedef struct | 72 typedef struct |
73 { | 73 { |
74 AccountPrefsDialogType type; | 74 AccountPrefsDialogType type; |
75 | 75 |
76 AccountsDialog *accounts_dialog; | |
77 | |
76 GaimAccount *account; | 78 GaimAccount *account; |
77 GaimProtocol protocol; | 79 GaimProtocol protocol; |
78 GaimPlugin *plugin; | 80 GaimPlugin *plugin; |
79 GaimPluginProtocolInfo *prpl_info; | 81 GaimPluginProtocolInfo *prpl_info; |
80 | 82 |
122 } AccountPrefsDialog; | 124 } AccountPrefsDialog; |
123 | 125 |
124 | 126 |
125 static AccountsDialog *accounts_dialog = NULL; | 127 static AccountsDialog *accounts_dialog = NULL; |
126 | 128 |
129 static void __add_account(AccountsDialog *dialog, GaimAccount *account); | |
130 static void __set_account(GtkListStore *store, GtkTreeIter *iter, | |
131 GaimAccount *account); | |
127 | 132 |
128 static char * | 133 static char * |
129 proto_name(int proto) | 134 proto_name(int proto) |
130 { | 135 { |
131 GaimPlugin *p = gaim_find_prpl(proto); | 136 GaimPlugin *p = gaim_find_prpl(proto); |
695 if ((int_val = gaim_proxy_info_get_port(proxy_info)) != 0) { | 700 if ((int_val = gaim_proxy_info_get_port(proxy_info)) != 0) { |
696 char buf[32]; | 701 char buf[32]; |
697 | 702 |
698 g_snprintf(buf, sizeof(buf), "%d", int_val); | 703 g_snprintf(buf, sizeof(buf), "%d", int_val); |
699 | 704 |
700 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_host_entry), buf); | 705 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_port_entry), buf); |
701 } | 706 } |
702 | 707 |
703 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL) | 708 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL) |
704 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_user_entry), value); | 709 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_user_entry), value); |
705 | 710 |
742 GaimProxyInfo *proxy_info = NULL; | 747 GaimProxyInfo *proxy_info = NULL; |
743 GList *l, *l2; | 748 GList *l, *l2; |
744 const char *value; | 749 const char *value; |
745 char *username; | 750 char *username; |
746 char *tmp; | 751 char *tmp; |
752 size_t index; | |
753 GtkTreeIter iter; | |
747 | 754 |
748 if (dialog->account == NULL) { | 755 if (dialog->account == NULL) { |
749 const char *screenname; | 756 const char *screenname; |
750 | 757 |
751 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry)); | 758 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry)); |
888 | 895 |
889 gaim_proxy_info_set_password(proxy_info, | 896 gaim_proxy_info_set_password(proxy_info, |
890 gtk_entry_get_text(GTK_ENTRY(dialog->proxy_pass_entry))); | 897 gtk_entry_get_text(GTK_ENTRY(dialog->proxy_pass_entry))); |
891 } | 898 } |
892 | 899 |
900 /* Adds the account to the list, or modify the existing entry. */ | |
901 index = g_list_index(gaim_accounts_get_all(), dialog->account); | |
902 | |
903 if (index != -1 && | |
904 (gtk_tree_model_iter_nth_child( | |
905 GTK_TREE_MODEL(dialog->accounts_dialog->model), &iter, | |
906 NULL, index))) { | |
907 | |
908 __set_account(dialog->accounts_dialog->model, &iter, dialog->account); | |
909 } | |
910 else | |
911 __add_account(dialog->accounts_dialog, dialog->account); | |
912 | |
893 gtk_widget_destroy(dialog->window); | 913 gtk_widget_destroy(dialog->window); |
894 | 914 |
895 __account_win_destroy_cb(NULL, NULL, dialog); | 915 __account_win_destroy_cb(NULL, NULL, dialog); |
896 } | 916 } |
897 | 917 |
898 static void | 918 static void |
899 __show_account_prefs(AccountPrefsDialogType type, GaimAccount *account) | 919 __show_account_prefs(AccountPrefsDialogType type, |
920 AccountsDialog *accounts_dialog, | |
921 GaimAccount *account) | |
900 { | 922 { |
901 AccountPrefsDialog *dialog; | 923 AccountPrefsDialog *dialog; |
902 GtkWidget *win; | 924 GtkWidget *win; |
903 GtkWidget *main_vbox; | 925 GtkWidget *main_vbox; |
904 GtkWidget *vbox; | 926 GtkWidget *vbox; |
908 GtkWidget *sep; | 930 GtkWidget *sep; |
909 GtkWidget *button; | 931 GtkWidget *button; |
910 | 932 |
911 dialog = g_new0(AccountPrefsDialog, 1); | 933 dialog = g_new0(AccountPrefsDialog, 1); |
912 | 934 |
935 dialog->accounts_dialog = accounts_dialog; | |
913 dialog->account = account; | 936 dialog->account = account; |
914 dialog->type = type; | 937 dialog->type = type; |
915 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 938 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
916 | 939 |
917 if (dialog->account == NULL) | 940 if (dialog->account == NULL) |
1179 } | 1202 } |
1180 | 1203 |
1181 static void | 1204 static void |
1182 __add_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1205 __add_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1183 { | 1206 { |
1184 __show_account_prefs(ADD_ACCOUNT_DIALOG, NULL); | 1207 __show_account_prefs(ADD_ACCOUNT_DIALOG, dialog, NULL); |
1185 } | 1208 } |
1186 | 1209 |
1187 static void | 1210 static void |
1188 __modify_account_sel(GtkTreeModel *model, GtkTreePath *path, | 1211 __modify_account_sel(GtkTreeModel *model, GtkTreePath *path, |
1189 GtkTreeIter *iter, gpointer data) | 1212 GtkTreeIter *iter, gpointer data) |
1191 GaimAccount *account; | 1214 GaimAccount *account; |
1192 | 1215 |
1193 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); | 1216 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); |
1194 | 1217 |
1195 if (account != NULL) | 1218 if (account != NULL) |
1196 __show_account_prefs(MODIFY_ACCOUNT_DIALOG, account); | 1219 __show_account_prefs(MODIFY_ACCOUNT_DIALOG, data, account); |
1197 } | 1220 } |
1198 | 1221 |
1199 static void | 1222 static void |
1200 __modify_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1223 __modify_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1201 { | 1224 { |
1202 GtkTreeSelection *selection; | 1225 GtkTreeSelection *selection; |
1203 | 1226 |
1204 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | 1227 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); |
1205 | 1228 |
1206 gtk_tree_selection_selected_foreach(selection, __modify_account_sel, NULL); | 1229 gtk_tree_selection_selected_foreach(selection, __modify_account_sel, |
1230 dialog); | |
1207 } | 1231 } |
1208 | 1232 |
1209 static void | 1233 static void |
1210 __delete_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1234 __delete_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1211 { | 1235 { |
1229 GtkTreeIter iter; | 1253 GtkTreeIter iter; |
1230 gboolean online; | 1254 gboolean online; |
1231 | 1255 |
1232 gtk_tree_model_get_iter_from_string(model, &iter, path_str); | 1256 gtk_tree_model_get_iter_from_string(model, &iter, path_str); |
1233 gtk_tree_model_get(model, &iter, COLUMN_DATA, &account, | 1257 gtk_tree_model_get(model, &iter, COLUMN_DATA, &account, |
1234 COLUMN_ONLINE, &online, -1); | 1258 COLUMN_ONLINE, &online, -1); |
1235 | 1259 |
1236 if (online) | 1260 if (online) |
1237 gaim_account_disconnect(account); | 1261 gaim_account_disconnect(account); |
1238 else | 1262 else |
1239 gaim_account_connect(account); | 1263 gaim_account_connect(account); |
1304 | 1328 |
1305 | 1329 |
1306 } | 1330 } |
1307 | 1331 |
1308 static void | 1332 static void |
1309 __populate_accounts_list(AccountsDialog *dialog) | 1333 __set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account) |
1310 { | 1334 { |
1311 GList *l; | |
1312 GaimAccount *account; | |
1313 GtkTreeIter iter; | |
1314 GdkPixbuf *pixbuf; | 1335 GdkPixbuf *pixbuf; |
1315 GdkPixbuf *scale; | 1336 GdkPixbuf *scale; |
1316 | 1337 |
1338 scale = NULL; | |
1339 | |
1340 pixbuf = create_prpl_icon(account); | |
1341 | |
1342 if (pixbuf != NULL) | |
1343 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); | |
1344 | |
1345 gtk_list_store_set(store, iter, | |
1346 COLUMN_ICON, scale, | |
1347 COLUMN_SCREENNAME, gaim_account_get_username(account), | |
1348 COLUMN_ONLINE, gaim_account_is_connected(account), | |
1349 COLUMN_AUTOLOGIN, FALSE, | |
1350 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), | |
1351 COLUMN_DATA, account, | |
1352 COLUMN_FILLER, FALSE, | |
1353 -1); | |
1354 | |
1355 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
1356 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | |
1357 } | |
1358 | |
1359 static void | |
1360 __add_account(AccountsDialog *dialog, GaimAccount *account) | |
1361 { | |
1362 GtkTreeIter iter; | |
1363 | |
1364 gtk_list_store_append(dialog->model, &iter); | |
1365 | |
1366 __set_account(dialog->model, &iter, account); | |
1367 } | |
1368 | |
1369 static void | |
1370 __populate_accounts_list(AccountsDialog *dialog) | |
1371 { | |
1372 GList *l; | |
1373 | |
1317 gtk_list_store_clear(dialog->model); | 1374 gtk_list_store_clear(dialog->model); |
1318 | 1375 |
1319 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | 1376 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) |
1320 account = l->data; | 1377 __add_account(dialog, (GaimAccount *)l->data); |
1321 | |
1322 scale = NULL; | |
1323 | |
1324 pixbuf = create_prpl_icon(account); | |
1325 | |
1326 if (pixbuf != NULL) | |
1327 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
1328 GDK_INTERP_BILINEAR); | |
1329 | |
1330 gtk_list_store_append(dialog->model, &iter); | |
1331 gtk_list_store_set(dialog->model, &iter, | |
1332 COLUMN_ICON, scale, | |
1333 COLUMN_SCREENNAME, gaim_account_get_username(account), | |
1334 COLUMN_ONLINE, gaim_account_is_connected(account), | |
1335 COLUMN_AUTOLOGIN, FALSE, | |
1336 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), | |
1337 COLUMN_DATA, account, | |
1338 COLUMN_FILLER, FALSE, | |
1339 -1); | |
1340 | |
1341 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
1342 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | |
1343 } | |
1344 } | 1378 } |
1345 | 1379 |
1346 static GtkWidget * | 1380 static GtkWidget * |
1347 __create_accounts_list(AccountsDialog *dialog) | 1381 __create_accounts_list(AccountsDialog *dialog) |
1348 { | 1382 { |