Mercurial > pidgin
comparison src/gtkaccount.c @ 6751:35b01b371785
[gaim-migrate @ 7283]
The accounts window now shows offline accounts as greyed out, and online
accounts as colored, providing a better indication of what is online and
what is not. We'll see what people think of this, but it's been useful for
qpe-gaim.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 05 Sep 2003 07:11:01 +0000 |
parents | c49f232b6bd0 |
children | a14200b24371 |
comparison
equal
deleted
inserted
replaced
6750:e152a0283692 | 6751:35b01b371785 |
---|---|
107 GtkWidget *buddy_icon_hbox; | 107 GtkWidget *buddy_icon_hbox; |
108 GtkWidget *buddy_icon_entry; | 108 GtkWidget *buddy_icon_entry; |
109 GtkWidget *buddy_icon_filesel; | 109 GtkWidget *buddy_icon_filesel; |
110 GtkWidget *buddy_icon_preview; | 110 GtkWidget *buddy_icon_preview; |
111 GtkWidget *buddy_icon_text; | 111 GtkWidget *buddy_icon_text; |
112 | 112 |
113 /* Protocol Options */ | 113 /* Protocol Options */ |
114 GtkWidget *protocol_frame; | 114 GtkWidget *protocol_frame; |
115 | 115 |
116 /* Proxy Options */ | 116 /* Proxy Options */ |
117 GtkWidget *proxy_frame; | 117 GtkWidget *proxy_frame; |
206 gtk_widget_set_sensitive(dialog->register_button, | 206 gtk_widget_set_sensitive(dialog->register_button, |
207 *gtk_entry_get_text(entry) != '\0'); | 207 *gtk_entry_get_text(entry) != '\0'); |
208 | 208 |
209 } | 209 } |
210 | 210 |
211 static void buddy_icon_filesel_delete_cb (GtkWidget *w, AccountPrefsDialog *dialog) | 211 static void |
212 buddy_icon_filesel_delete_cb(GtkWidget *w, AccountPrefsDialog *dialog) | |
212 { | 213 { |
213 if (dialog->buddy_icon_filesel != NULL) | 214 if (dialog->buddy_icon_filesel != NULL) |
214 gtk_widget_destroy(dialog->buddy_icon_filesel); | 215 gtk_widget_destroy(dialog->buddy_icon_filesel); |
216 | |
215 dialog->buddy_icon_filesel = NULL; | 217 dialog->buddy_icon_filesel = NULL; |
216 } | 218 } |
217 | 219 |
218 static void buddy_icon_filesel_choose (GtkWidget *w, AccountPrefsDialog *dialog) | 220 static void |
219 { | 221 buddy_icon_filesel_choose(GtkWidget *w, AccountPrefsDialog *dialog) |
220 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->buddy_icon_filesel)); | 222 { |
223 const char *filename; | |
224 | |
225 filename = gtk_file_selection_get_filename( | |
226 GTK_FILE_SELECTION(dialog->buddy_icon_filesel)); | |
221 | 227 |
222 /* If they typed in a directory, change there */ | 228 /* If they typed in a directory, change there */ |
223 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(dialog->buddy_icon_filesel))) | 229 if (gaim_gtk_check_if_dir(filename, |
230 GTK_FILE_SELECTION(dialog->buddy_icon_filesel))) | |
231 { | |
224 return; | 232 return; |
225 | 233 } |
226 if (dialog->account) | 234 |
235 if (dialog->account != NULL) | |
227 gaim_account_set_buddy_icon(dialog->account, filename); | 236 gaim_account_set_buddy_icon(dialog->account, filename); |
228 | 237 |
229 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_icon_entry), filename); | 238 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_icon_entry), filename); |
230 gtk_widget_destroy(dialog->buddy_icon_filesel); | 239 gtk_widget_destroy(dialog->buddy_icon_filesel); |
231 } | 240 } |
232 | 241 |
233 static void buddy_icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog) | 242 static void |
243 buddy_icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog) | |
234 { | 244 { |
235 GdkPixbuf *pixbuf, *scale; | 245 GdkPixbuf *pixbuf, *scale; |
236 int height, width; | 246 int height, width; |
237 char *basename, *markup, *size; | 247 char *basename, *markup, *size; |
238 struct stat st; | 248 struct stat st; |
239 | 249 const char *filename; |
240 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->buddy_icon_filesel)); | 250 |
251 filename = gtk_file_selection_get_filename( | |
252 GTK_FILE_SELECTION(dialog->buddy_icon_filesel)); | |
253 | |
241 if (!filename || stat(filename, &st)) | 254 if (!filename || stat(filename, &st)) |
242 return; | 255 return; |
243 | 256 |
244 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 257 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
245 if (!pixbuf) { | 258 if (!pixbuf) { |
246 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->buddy_icon_preview), NULL); | 259 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->buddy_icon_preview), NULL); |
247 gtk_label_set_markup(GTK_LABEL(dialog->buddy_icon_text), ""); | 260 gtk_label_set_markup(GTK_LABEL(dialog->buddy_icon_text), ""); |
248 return; | 261 return; |
249 } | 262 } |
250 | 263 |
251 width = gdk_pixbuf_get_width(pixbuf); | 264 width = gdk_pixbuf_get_width(pixbuf); |
252 height = gdk_pixbuf_get_height(pixbuf); | 265 height = gdk_pixbuf_get_height(pixbuf); |
253 basename = g_path_get_basename(filename); | 266 basename = g_path_get_basename(filename); |
254 size = gaim_get_size_string(st.st_size); | 267 size = gaim_get_size_string(st.st_size); |
255 markup = g_strdup_printf(_("<b>File:</b> %s\n<b>File size:</b> %s\n<b>Image size:</b> %dx%d"), | 268 markup = g_strdup_printf(_("<b>File:</b> %s\n" |
256 basename, size, width, height); | 269 "<b>File size:</b> %s\n" |
257 scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, 50, GDK_INTERP_BILINEAR); | 270 "<b>Image size:</b> %dx%d"), |
271 basename, size, width, height); | |
272 | |
273 scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, | |
274 50, GDK_INTERP_BILINEAR); | |
258 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->buddy_icon_preview), scale); | 275 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->buddy_icon_preview), scale); |
259 gtk_label_set_markup(GTK_LABEL(dialog->buddy_icon_text), markup); | 276 gtk_label_set_markup(GTK_LABEL(dialog->buddy_icon_text), markup); |
260 | 277 |
261 g_object_unref(G_OBJECT(pixbuf)); | 278 g_object_unref(G_OBJECT(pixbuf)); |
262 g_object_unref(G_OBJECT(scale)); | 279 g_object_unref(G_OBJECT(scale)); |
263 g_free(basename); | 280 g_free(basename); |
264 g_free(size); | 281 g_free(size); |
265 g_free(markup); | 282 g_free(markup); |
266 } | 283 } |
267 | 284 |
268 static void buddy_icon_select_cb(GtkWidget *button, AccountPrefsDialog *dialog) | 285 static void |
286 buddy_icon_select_cb(GtkWidget *button, AccountPrefsDialog *dialog) | |
269 { | 287 { |
270 GtkWidget *hbox; | 288 GtkWidget *hbox; |
271 GtkWidget *tv; | 289 GtkWidget *tv; |
272 GtkTreeSelection *sel; | 290 GtkTreeSelection *sel; |
273 | 291 |
274 if (dialog->buddy_icon_filesel) { | 292 if (dialog->buddy_icon_filesel) |
293 { | |
275 gtk_widget_show(GTK_WIDGET(dialog->buddy_icon_filesel)); | 294 gtk_widget_show(GTK_WIDGET(dialog->buddy_icon_filesel)); |
276 gdk_window_raise(GDK_WINDOW(dialog->buddy_icon_filesel->window)); | 295 gdk_window_raise(GDK_WINDOW(dialog->buddy_icon_filesel->window)); |
277 return; | 296 return; |
278 } | 297 } |
279 | 298 |
297 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog->buddy_icon_filesel)->ok_button), "clicked", G_CALLBACK(buddy_icon_filesel_choose), | 316 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog->buddy_icon_filesel)->ok_button), "clicked", G_CALLBACK(buddy_icon_filesel_choose), |
298 dialog); | 317 dialog); |
299 | 318 |
300 gtk_widget_show_all(GTK_WIDGET(dialog->buddy_icon_filesel)); | 319 gtk_widget_show_all(GTK_WIDGET(dialog->buddy_icon_filesel)); |
301 if (dialog->account && (gaim_account_get_buddy_icon(dialog->account) != NULL)) { | 320 if (dialog->account && (gaim_account_get_buddy_icon(dialog->account) != NULL)) { |
302 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->buddy_icon_filesel), | 321 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->buddy_icon_filesel), |
303 gaim_account_get_buddy_icon(dialog->account)); | 322 gaim_account_get_buddy_icon(dialog->account)); |
304 buddy_icon_preview_change_cb(NULL, dialog); | 323 buddy_icon_preview_change_cb(NULL, dialog); |
305 } | 324 } |
306 | 325 |
307 } | 326 } |
308 | 327 |
309 static void buddy_icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) | 328 static void |
329 buddy_icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) | |
310 { | 330 { |
311 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_icon_entry), ""); | 331 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_icon_entry), ""); |
312 if (dialog->account) | 332 if (dialog->account) |
313 gaim_account_set_buddy_icon(dialog->account, NULL); | 333 gaim_account_set_buddy_icon(dialog->account, NULL); |
314 } | 334 } |
346 | 366 |
347 add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); | 367 add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); |
348 | 368 |
349 /* Screen Name */ | 369 /* Screen Name */ |
350 dialog->screenname_entry = gtk_entry_new(); | 370 dialog->screenname_entry = gtk_entry_new(); |
351 | 371 |
352 add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); | 372 add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); |
353 | 373 |
354 g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", | 374 g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", |
355 G_CALLBACK(screenname_changed_cb), dialog); | 375 G_CALLBACK(screenname_changed_cb), dialog); |
356 | 376 |
357 /* Do the user split thang */ | 377 /* Do the user split thang */ |
358 if (dialog->plugin == NULL) /* Yeah right. */ | 378 if (dialog->plugin == NULL) /* Yeah right. */ |
516 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0); | 536 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0); |
517 gtk_widget_show(dialog->buddy_icon_entry); | 537 gtk_widget_show(dialog->buddy_icon_entry); |
518 | 538 |
519 button = gtk_button_new_with_mnemonic(_("_Browse")); | 539 button = gtk_button_new_with_mnemonic(_("_Browse")); |
520 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 540 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
521 g_signal_connect(G_OBJECT(button), "clicked", | 541 g_signal_connect(G_OBJECT(button), "clicked", |
522 G_CALLBACK(buddy_icon_select_cb), dialog); | 542 G_CALLBACK(buddy_icon_select_cb), dialog); |
523 gtk_widget_show(button); | 543 gtk_widget_show(button); |
524 | 544 |
525 button = gtk_button_new_with_mnemonic(_("_Reset")); | 545 button = gtk_button_new_with_mnemonic(_("_Reset")); |
526 g_signal_connect(G_OBJECT(button), "clicked", | 546 g_signal_connect(G_OBJECT(button), "clicked", |
527 G_CALLBACK(buddy_icon_reset_cb), dialog); | 547 G_CALLBACK(buddy_icon_reset_cb), dialog); |
1266 signed_on_off_cb(GaimConnection *gc, AccountsWindow *dialog) | 1286 signed_on_off_cb(GaimConnection *gc, AccountsWindow *dialog) |
1267 { | 1287 { |
1268 GaimAccount *account = gaim_connection_get_account(gc); | 1288 GaimAccount *account = gaim_connection_get_account(gc); |
1269 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); | 1289 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); |
1270 GtkTreeIter iter; | 1290 GtkTreeIter iter; |
1291 GdkPixbuf *pixbuf, *scale = NULL; | |
1271 size_t index = g_list_index(gaim_accounts_get_all(), account); | 1292 size_t index = g_list_index(gaim_accounts_get_all(), account); |
1272 | 1293 |
1273 if (gtk_tree_model_iter_nth_child(model, &iter, NULL, index)) { | 1294 if (gtk_tree_model_iter_nth_child(model, &iter, NULL, index)) |
1295 { | |
1296 pixbuf = create_prpl_icon(account); | |
1297 | |
1298 if (pixbuf != NULL) | |
1299 { | |
1300 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
1301 GDK_INTERP_BILINEAR); | |
1302 | |
1303 if (!gaim_account_is_connected(account)) | |
1304 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
1305 } | |
1306 | |
1274 gtk_list_store_set(dialog->model, &iter, | 1307 gtk_list_store_set(dialog->model, &iter, |
1308 COLUMN_ICON, scale, | |
1275 COLUMN_ONLINE, gaim_account_is_connected(account), | 1309 COLUMN_ONLINE, gaim_account_is_connected(account), |
1276 -1); | 1310 -1); |
1311 | |
1312 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
1313 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | |
1277 } | 1314 } |
1278 } | 1315 } |
1279 | 1316 |
1280 static void | 1317 static void |
1281 drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, | 1318 drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, |
1599 /* Online? */ | 1636 /* Online? */ |
1600 renderer = gtk_cell_renderer_toggle_new(); | 1637 renderer = gtk_cell_renderer_toggle_new(); |
1601 | 1638 |
1602 g_signal_connect(G_OBJECT(renderer), "toggled", | 1639 g_signal_connect(G_OBJECT(renderer), "toggled", |
1603 G_CALLBACK(online_cb), dialog); | 1640 G_CALLBACK(online_cb), dialog); |
1604 | 1641 |
1605 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 1642 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), |
1606 -1, _("Online"), | 1643 -1, _("Online"), |
1607 renderer, | 1644 renderer, |
1608 "active", COLUMN_ONLINE, | 1645 "active", COLUMN_ONLINE, |
1609 NULL); | 1646 NULL); |
1639 scale = NULL; | 1676 scale = NULL; |
1640 | 1677 |
1641 pixbuf = create_prpl_icon(account); | 1678 pixbuf = create_prpl_icon(account); |
1642 | 1679 |
1643 if (pixbuf != NULL) | 1680 if (pixbuf != NULL) |
1681 { | |
1644 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); | 1682 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
1683 | |
1684 if (!gaim_account_is_connected(account)) | |
1685 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
1686 } | |
1645 | 1687 |
1646 gtk_list_store_set(store, iter, | 1688 gtk_list_store_set(store, iter, |
1647 COLUMN_ICON, scale, | 1689 COLUMN_ICON, scale, |
1648 COLUMN_SCREENNAME, gaim_account_get_username(account), | 1690 COLUMN_SCREENNAME, gaim_account_get_username(account), |
1649 COLUMN_ONLINE, gaim_account_is_connected(account), | 1691 COLUMN_ONLINE, gaim_account_is_connected(account), |