comparison src/gtkaccount.c @ 9312:317b5b7af25c

[gaim-migrate @ 10120] Fixed a bug Tim discovered, changed "Buddy icon file:" to "Buddy icon:" and made the icon preview disappear when reset, not turn into an X. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 19 Jun 2004 15:16:01 +0000
parents ade6b9c0dc8a
children 74728ac40475
comparison
equal deleted inserted replaced
9311:c5fdff22b252 9312:317b5b7af25c
274 274
275 if (dialog->buddy_icon_path) 275 if (dialog->buddy_icon_path)
276 g_free(dialog->buddy_icon_path); 276 g_free(dialog->buddy_icon_path);
277 dialog->buddy_icon_path = g_strdup(filename); 277 dialog->buddy_icon_path = g_strdup(filename);
278 gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), filename); 278 gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), filename);
279 gtk_widget_show(dialog->buddy_icon_entry);
279 gtk_widget_destroy(dialog->buddy_icon_filesel); 280 gtk_widget_destroy(dialog->buddy_icon_filesel);
280 } 281 }
281 282
282 static void 283 static void
283 buddy_icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog) 284 buddy_icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog)
366 "clicked", 367 "clicked",
367 G_CALLBACK(buddy_icon_filesel_choose), dialog); 368 G_CALLBACK(buddy_icon_filesel_choose), dialog);
368 369
369 gtk_widget_show_all(GTK_WIDGET(dialog->buddy_icon_filesel)); 370 gtk_widget_show_all(GTK_WIDGET(dialog->buddy_icon_filesel));
370 371
372 /*
373 The user doesn't know where his buddy icon is located anymore
371 if (dialog->account && 374 if (dialog->account &&
372 (gaim_account_get_buddy_icon(dialog->account) != NULL)) 375 (gaim_account_get_buddy_icon(dialog->account) != NULL))
373 { 376 {
374 gtk_file_selection_set_filename( 377 gtk_file_selection_set_filename(
375 GTK_FILE_SELECTION(dialog->buddy_icon_filesel), 378 GTK_FILE_SELECTION(dialog->buddy_icon_filesel),
376 gaim_account_get_buddy_icon(dialog->account)); 379 gaim_account_get_buddy_icon(dialog->account));
377 380
378 buddy_icon_preview_change_cb(NULL, dialog); 381 buddy_icon_preview_change_cb(NULL, dialog);
379 } 382 }
380 383 */
381 } 384 }
382 385
383 static void 386 static void
384 buddy_icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) 387 buddy_icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog)
385 { 388 {
386 if (dialog->buddy_icon_path) 389 if (dialog->buddy_icon_path)
387 g_free(dialog->buddy_icon_path); 390 g_free(dialog->buddy_icon_path);
388 dialog->buddy_icon_path = NULL; 391 dialog->buddy_icon_path = NULL;
389 gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), ""); 392 gtk_widget_hide(dialog->buddy_icon_entry);
393 /*gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), "");*/
390 } 394 }
391 395
392 #if GTK_CHECK_VERSION(2,4,0) 396 #if GTK_CHECK_VERSION(2,4,0)
393 gboolean str_array_match(char **a, char **b) 397 gboolean str_array_match(char **a, char **b)
394 { 398 {
404 static void 408 static void
405 convert_and_set_buddy_icon(GaimAccount *account, const char *path) 409 convert_and_set_buddy_icon(GaimAccount *account, const char *path)
406 { 410 {
407 #if GTK_CHECK_VERSION(2,4,0) 411 #if GTK_CHECK_VERSION(2,4,0)
408 int width, height; 412 int width, height;
409 char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0);
410 char **pixbuf_formats; 413 char **pixbuf_formats;
411 GdkPixbufFormat *format; 414 GdkPixbufFormat *format;
412 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(account->protocol_id)); 415 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(account->protocol_id));
413 416 char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0);
417
414 format = gdk_pixbuf_get_file_info (path, &width, &height); 418 format = gdk_pixbuf_get_file_info (path, &width, &height);
415 pixbuf_formats = gdk_pixbuf_format_get_extensions(format); 419 pixbuf_formats = gdk_pixbuf_format_get_extensions(format);
416 420
417 if (str_array_match(pixbuf_formats, prpl_formats)) { 421 if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */
422 ((prpl_info->icon_spec.width > 0 && prpl_info->icon_spec.height > 0) || /* The prpl doesn't care about size OR*/
423 (prpl_info->icon_spec.width == width && prpl_info->icon_spec.height == height))) { /* The icon is the correct size */
418 #endif 424 #endif
419 gaim_account_set_buddy_icon(account, path); 425 gaim_account_set_buddy_icon(account, path);
420 #if GTK_CHECK_VERSION(2,4,0) 426 #if GTK_CHECK_VERSION(2,4,0)
421 } else { 427 } else {
422 int i; 428 int i;
646 /* Buddy icon */ 652 /* Buddy icon */
647 dialog->buddy_icon_hbox = hbox = gtk_hbox_new(FALSE, 6); 653 dialog->buddy_icon_hbox = hbox = gtk_hbox_new(FALSE, 6);
648 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 654 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
649 gtk_widget_show(hbox); 655 gtk_widget_show(hbox);
650 656
651 label = gtk_label_new(_("Buddy icon file:")); 657 label = gtk_label_new(_("Buddy icon:"));
652 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 658 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
653 gtk_widget_show(label); 659 gtk_widget_show(label);
654 660
655 dialog->buddy_icon_entry = gtk_image_new(); 661 dialog->buddy_icon_entry = gtk_image_new();
656 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0); 662 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0);
1175 /* Buddy Icon */ 1181 /* Buddy Icon */
1176 value = dialog->buddy_icon_path; 1182 value = dialog->buddy_icon_path;
1177 1183
1178 if (dialog->prpl_info && 1184 if (dialog->prpl_info &&
1179 (dialog->prpl_info->icon_spec.format) && 1185 (dialog->prpl_info->icon_spec.format) &&
1180 *value != '\0') { 1186 value != NULL) {
1181 convert_and_set_buddy_icon(dialog->account, value); 1187 convert_and_set_buddy_icon(dialog->account, value);
1182 } else { 1188 } else {
1183 gaim_account_set_buddy_icon(dialog->account, NULL); 1189 gaim_account_set_buddy_icon(dialog->account, NULL);
1184 } 1190 }
1185 /* Remember Password */ 1191 /* Remember Password */