comparison src/gtkaccount.c @ 10400:6a043ae92db6

[gaim-migrate @ 11631] I'm about to go home for the holidays, so I figured I'd commit this before I left so someone else could pick up on it while I'm gone. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 19 Dec 2004 20:32:32 +0000
parents deec4b58d516
children ce098e226486
comparison
equal deleted inserted replaced
10399:aab0c9508318 10400:6a043ae92db6
47 47
48 enum 48 enum
49 { 49 {
50 COLUMN_ICON, 50 COLUMN_ICON,
51 COLUMN_SCREENNAME, 51 COLUMN_SCREENNAME,
52 COLUMN_ONLINE, 52 COLUMN_ENABLED,
53 COLUMN_AUTOLOGIN,
54 COLUMN_PROTOCOL, 53 COLUMN_PROTOCOL,
55 COLUMN_DATA, 54 COLUMN_DATA,
56 COLUMN_PULSE_DATA, 55 COLUMN_PULSE_DATA,
57 NUM_COLUMNS 56 NUM_COLUMNS
58 }; 57 };
110 GtkWidget *password_box; 109 GtkWidget *password_box;
111 GtkWidget *screenname_entry; 110 GtkWidget *screenname_entry;
112 GtkWidget *password_entry; 111 GtkWidget *password_entry;
113 GtkWidget *alias_entry; 112 GtkWidget *alias_entry;
114 GtkWidget *remember_pass_check; 113 GtkWidget *remember_pass_check;
115 GtkWidget *auto_login_check;
116 114
117 /* User Options */ 115 /* User Options */
118 GtkWidget *user_frame; 116 GtkWidget *user_frame;
119 GtkWidget *new_mail_check; 117 GtkWidget *new_mail_check;
120 GtkWidget *icon_hbox; 118 GtkWidget *icon_hbox;
731 FALSE); 729 FALSE);
732 gtk_box_pack_start(GTK_BOX(vbox), dialog->remember_pass_check, 730 gtk_box_pack_start(GTK_BOX(vbox), dialog->remember_pass_check,
733 FALSE, FALSE, 0); 731 FALSE, FALSE, 0);
734 gtk_widget_show(dialog->remember_pass_check); 732 gtk_widget_show(dialog->remember_pass_check);
735 733
736 /* Auto log in */
737 dialog->auto_login_check =
738 gtk_check_button_new_with_label(_("Auto log in"));
739 gtk_box_pack_start(GTK_BOX(vbox), dialog->auto_login_check,
740 FALSE, FALSE, 0);
741 gtk_widget_show(dialog->auto_login_check);
742
743 /* Set the fields. */ 734 /* Set the fields. */
744 if (dialog->account != NULL) { 735 if (dialog->account != NULL) {
745 if (gaim_account_get_password(dialog->account)) 736 if (gaim_account_get_password(dialog->account))
746 gtk_entry_set_text(GTK_ENTRY(dialog->password_entry), 737 gtk_entry_set_text(GTK_ENTRY(dialog->password_entry),
747 gaim_account_get_password(dialog->account)); 738 gaim_account_get_password(dialog->account));
751 gaim_account_get_alias(dialog->account)); 742 gaim_account_get_alias(dialog->account));
752 743
753 gtk_toggle_button_set_active( 744 gtk_toggle_button_set_active(
754 GTK_TOGGLE_BUTTON(dialog->remember_pass_check), 745 GTK_TOGGLE_BUTTON(dialog->remember_pass_check),
755 gaim_account_get_remember_password(dialog->account)); 746 gaim_account_get_remember_password(dialog->account));
756
757 gtk_toggle_button_set_active(
758 GTK_TOGGLE_BUTTON(dialog->auto_login_check),
759 gaim_account_get_auto_login(dialog->account, GAIM_GTK_UI));
760 } 747 }
761 748
762 if (dialog->prpl_info != NULL && 749 if (dialog->prpl_info != NULL &&
763 (dialog->prpl_info->options & OPT_PROTO_NO_PASSWORD)) { 750 (dialog->prpl_info->options & OPT_PROTO_NO_PASSWORD)) {
764 751
1352 if (dialog->prpl_info && dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) 1339 if (dialog->prpl_info && dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK)
1353 gaim_account_set_check_mail(dialog->account, 1340 gaim_account_set_check_mail(dialog->account,
1354 gtk_toggle_button_get_active( 1341 gtk_toggle_button_get_active(
1355 GTK_TOGGLE_BUTTON(dialog->new_mail_check))); 1342 GTK_TOGGLE_BUTTON(dialog->new_mail_check)));
1356 1343
1357 /* Auto Login */
1358 gaim_account_set_auto_login(dialog->account, GAIM_GTK_UI,
1359 gtk_toggle_button_get_active(
1360 GTK_TOGGLE_BUTTON(dialog->auto_login_check)));
1361
1362 /* Password */ 1344 /* Password */
1363 value = gtk_entry_get_text(GTK_ENTRY(dialog->password_entry)); 1345 value = gtk_entry_get_text(GTK_ENTRY(dialog->password_entry));
1364 1346
1365 if (gaim_account_get_remember_password(dialog->account) && *value != '\0') 1347 if (gaim_account_get_remember_password(dialog->account) && *value != '\0')
1366 gaim_account_set_password(dialog->account, value); 1348 gaim_account_set_password(dialog->account, value);
1760 GDK_INTERP_BILINEAR); 1742 GDK_INTERP_BILINEAR);
1761 1743
1762 if (!gaim_account_is_connected(account)) 1744 if (!gaim_account_is_connected(account))
1763 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); 1745 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
1764 } 1746 }
1765
1766 gtk_list_store_set(dialog->model, &iter, 1747 gtk_list_store_set(dialog->model, &iter,
1767 COLUMN_ICON, scale, 1748 COLUMN_ICON, scale,
1768 COLUMN_ONLINE, gaim_account_is_connected(account), 1749 COLUMN_PULSE_DATA, NULL,
1769 COLUMN_PULSE_DATA, NULL, 1750 -1);
1770 -1); 1751
1771 1752
1772 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); 1753 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
1773 if (scale != NULL) g_object_unref(G_OBJECT(scale)); 1754 if (scale != NULL) g_object_unref(G_OBJECT(scale));
1774 } 1755 }
1775 } 1756 }
2033 gtk_widget_destroy(dialog->window); 2014 gtk_widget_destroy(dialog->window);
2034 2015
2035 gaim_gtk_accounts_window_hide(); 2016 gaim_gtk_accounts_window_hide();
2036 } 2017 }
2037 2018
2038 static void 2019
2039 online_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data) 2020 static void
2021 enabled_cb(GtkCellRendererToggle *renderer, gchar *path_str,
2022 gpointer data)
2040 { 2023 {
2041 AccountsWindow *dialog = (AccountsWindow *)data; 2024 AccountsWindow *dialog = (AccountsWindow *)data;
2042 GaimAccount *account; 2025 GaimAccount *account;
2043 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); 2026 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model);
2044 GtkTreeIter iter; 2027 GtkTreeIter iter;
2045 GaimGtkPulseData *pulse_data; 2028 gboolean enabled;
2046 gboolean online;
2047 2029
2048 gtk_tree_model_get_iter_from_string(model, &iter, path_str); 2030 gtk_tree_model_get_iter_from_string(model, &iter, path_str);
2049 gtk_tree_model_get(model, &iter, 2031 gtk_tree_model_get(model, &iter,
2050 COLUMN_DATA, &account, 2032 COLUMN_DATA, &account,
2051 COLUMN_ONLINE, &online, 2033 COLUMN_ENABLED, &enabled,
2052 -1); 2034 -1);
2053 2035
2054 if (online) 2036 gaim_account_set_enabled(account, GAIM_GTK_UI, !enabled);
2055 {
2056 account->gc->wants_to_die = TRUE;
2057 gaim_account_disconnect(account);
2058 }
2059 else
2060 {
2061 GdkPixbuf *pixbuf;
2062
2063 pulse_data = g_new0(GaimGtkPulseData, 1);
2064 pulse_data->pulse_to_grey = TRUE;
2065 pulse_data->pulse_value = 0;
2066 pulse_data->account = account;
2067 pulse_data->model = model;
2068
2069 pixbuf = create_prpl_icon(account);
2070
2071 if (pixbuf != NULL)
2072 {
2073 pulse_data->online_pixbuf =
2074 gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
2075
2076 g_object_unref(G_OBJECT(pixbuf));
2077 }
2078
2079 if (pulse_data->online_pixbuf == NULL)
2080 {
2081 g_free(pulse_data);
2082 }
2083 else
2084 {
2085 pulse_data->timeout = g_timeout_add(100,
2086 (GSourceFunc)account_pulse_update, pulse_data);
2087
2088 gtk_list_store_set(GTK_LIST_STORE(model), &iter,
2089 COLUMN_PULSE_DATA, pulse_data, -1);
2090 }
2091
2092 gaim_account_connect(account);
2093 }
2094 }
2095
2096 static void
2097 autologin_cb(GtkCellRendererToggle *renderer, gchar *path_str,
2098 gpointer data)
2099 {
2100 AccountsWindow *dialog = (AccountsWindow *)data;
2101 GaimAccount *account;
2102 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model);
2103 GtkTreeIter iter;
2104 gboolean autologin;
2105
2106 gtk_tree_model_get_iter_from_string(model, &iter, path_str);
2107 gtk_tree_model_get(model, &iter,
2108 COLUMN_DATA, &account,
2109 COLUMN_AUTOLOGIN, &autologin,
2110 -1);
2111
2112 gaim_account_set_auto_login(account, GAIM_GTK_UI, !autologin);
2113 2037
2114 gtk_list_store_set(dialog->model, &iter, 2038 gtk_list_store_set(dialog->model, &iter,
2115 COLUMN_AUTOLOGIN, !autologin, 2039 COLUMN_ENABLED, !enabled,
2116 -1); 2040 -1);
2117 } 2041 }
2118 2042
2119 static void 2043 static void
2120 add_columns(GtkWidget *treeview, AccountsWindow *dialog) 2044 add_columns(GtkWidget *treeview, AccountsWindow *dialog)
2139 gtk_tree_view_column_pack_start(column, renderer, TRUE); 2063 gtk_tree_view_column_pack_start(column, renderer, TRUE);
2140 gtk_tree_view_column_add_attribute(column, renderer, 2064 gtk_tree_view_column_add_attribute(column, renderer,
2141 "text", COLUMN_SCREENNAME); 2065 "text", COLUMN_SCREENNAME);
2142 dialog->screenname_col = column; 2066 dialog->screenname_col = column;
2143 2067
2144 /* Online? */ 2068 /* Enabled */
2145 renderer = gtk_cell_renderer_toggle_new(); 2069 renderer = gtk_cell_renderer_toggle_new();
2146 2070
2147 g_signal_connect(G_OBJECT(renderer), "toggled", 2071 g_signal_connect(G_OBJECT(renderer), "toggled",
2148 G_CALLBACK(online_cb), dialog); 2072 G_CALLBACK(enabled_cb), dialog);
2149 2073
2150 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), 2074 column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
2151 -1, _("Online"), 2075 renderer, "active", COLUMN_ENABLED, NULL);
2152 renderer,
2153 "active", COLUMN_ONLINE,
2154 NULL);
2155 column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 1);
2156 gtk_tree_view_column_set_resizable(column, TRUE);
2157
2158 /* Auto Log In? */
2159 renderer = gtk_cell_renderer_toggle_new();
2160
2161 g_signal_connect(G_OBJECT(renderer), "toggled",
2162 G_CALLBACK(autologin_cb), dialog);
2163
2164 column = gtk_tree_view_column_new_with_attributes(_("Auto Log In"),
2165 renderer, "active", COLUMN_AUTOLOGIN, NULL);
2166 2076
2167 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); 2077 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
2168 gtk_tree_view_column_set_resizable(column, TRUE); 2078 gtk_tree_view_column_set_resizable(column, TRUE);
2169 2079
2170 /* Protocol name */ 2080 /* Protocol name */
2198 } 2108 }
2199 2109
2200 gtk_list_store_set(store, iter, 2110 gtk_list_store_set(store, iter,
2201 COLUMN_ICON, scale, 2111 COLUMN_ICON, scale,
2202 COLUMN_SCREENNAME, gaim_account_get_username(account), 2112 COLUMN_SCREENNAME, gaim_account_get_username(account),
2203 COLUMN_ONLINE, gaim_account_is_connected(account), 2113 COLUMN_ENABLED, gaim_account_get_enabled(account, GAIM_GTK_UI),
2204 COLUMN_AUTOLOGIN, gaim_account_get_auto_login(account, GAIM_GTK_UI),
2205 COLUMN_PROTOCOL, gaim_account_get_protocol_name(account), 2114 COLUMN_PROTOCOL, gaim_account_get_protocol_name(account),
2206 COLUMN_DATA, account, 2115 COLUMN_DATA, account,
2207 -1); 2116 -1);
2208 2117
2209 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); 2118 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
2273 gtk_widget_show(sw); 2182 gtk_widget_show(sw);
2274 2183
2275 /* Create the list model. */ 2184 /* Create the list model. */
2276 dialog->model = gtk_list_store_new(NUM_COLUMNS, 2185 dialog->model = gtk_list_store_new(NUM_COLUMNS,
2277 GDK_TYPE_PIXBUF, G_TYPE_STRING, 2186 GDK_TYPE_PIXBUF, G_TYPE_STRING,
2278 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, 2187 G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER,
2279 G_TYPE_STRING, G_TYPE_POINTER,
2280 G_TYPE_POINTER); 2188 G_TYPE_POINTER);
2281 2189
2282 /* And now the actual treeview */ 2190 /* And now the actual treeview */
2283 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); 2191 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
2284 dialog->treeview = treeview; 2192 dialog->treeview = treeview;