| 120 GtkWidget *icon_check; |
120 GtkWidget *icon_check; |
| 121 GtkWidget *icon_entry; |
121 GtkWidget *icon_entry; |
| 122 GtkWidget *icon_filesel; |
122 GtkWidget *icon_filesel; |
| 123 GtkWidget *icon_preview; |
123 GtkWidget *icon_preview; |
| 124 GtkWidget *icon_text; |
124 GtkWidget *icon_text; |
| 125 char *cached_icon_path; |
125 PurpleStoredImage *icon_img; |
| 126 char *icon_path; |
|
| 127 |
126 |
| 128 /* Protocol Options */ |
127 /* Protocol Options */ |
| 129 GtkWidget *protocol_frame; |
128 GtkWidget *protocol_frame; |
| 130 |
129 |
| 131 /* Proxy Options */ |
130 /* Proxy Options */ |
| 193 |
192 |
| 194 return hbox; |
193 return hbox; |
| 195 } |
194 } |
| 196 |
195 |
| 197 static void |
196 static void |
| 198 set_dialog_icon(AccountPrefsDialog *dialog, gchar *new_cached_icon_path, gchar *new_icon_path) |
197 set_dialog_icon(AccountPrefsDialog *dialog, gpointer *data, size_t len, gchar *new_icon_path) |
| 199 { |
198 { |
| 200 char *filename; |
|
| 201 GdkPixbuf *pixbuf = NULL; |
199 GdkPixbuf *pixbuf = NULL; |
| 202 |
200 |
| 203 g_free(dialog->cached_icon_path); |
201 purple_imgstore_unref(dialog->icon_img); |
| 204 g_free(dialog->icon_path); |
202 if (data != NULL && len > 0) |
| 205 dialog->cached_icon_path = new_cached_icon_path; |
203 dialog->icon_img = purple_imgstore_add(data, len, new_icon_path); |
| 206 dialog->icon_path = new_icon_path; |
204 g_free(data); |
| 207 |
205 |
| 208 filename = purple_buddy_icons_get_full_path(dialog->cached_icon_path); |
206 if (dialog->icon_img != NULL) { |
| 209 if (filename != NULL) { |
207 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
| 210 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
208 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(dialog->icon_img), |
| 211 g_free(filename); |
209 purple_imgstore_get_size(dialog->icon_img), NULL); |
| |
210 gdk_pixbuf_loader_close(loader, NULL); |
| |
211 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
| 212 } |
212 } |
| 213 |
213 |
| 214 if (pixbuf && dialog->prpl_info && |
214 if (pixbuf && dialog->prpl_info && |
| 215 (dialog->prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_DISPLAY)) |
215 (dialog->prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_DISPLAY)) |
| 216 { |
216 { |
| 296 } |
296 } |
| 297 |
297 |
| 298 static void |
298 static void |
| 299 icon_filesel_choose_cb(const char *filename, gpointer data) |
299 icon_filesel_choose_cb(const char *filename, gpointer data) |
| 300 { |
300 { |
| 301 AccountPrefsDialog *dialog; |
301 AccountPrefsDialog *dialog = data; |
| 302 |
302 |
| 303 dialog = data; |
|
| 304 |
|
| 305 #if 0 |
|
| 306 if (filename != NULL) |
303 if (filename != NULL) |
| 307 set_dialog_icon(dialog, pidgin_convert_buddy_icon(dialog->plugin, filename), g_strdup(filename)); |
304 { |
| 308 #endif |
305 size_t len; |
| |
306 gpointer data = pidgin_convert_buddy_icon(dialog->plugin, filename, &len); |
| |
307 set_dialog_icon(dialog, data, len, g_strdup(filename)); |
| |
308 } |
| 309 |
309 |
| 310 dialog->icon_filesel = NULL; |
310 dialog->icon_filesel = NULL; |
| 311 } |
311 } |
| 312 |
312 |
| 313 static void |
313 static void |
| 318 } |
318 } |
| 319 |
319 |
| 320 static void |
320 static void |
| 321 icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) |
321 icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) |
| 322 { |
322 { |
| 323 set_dialog_icon(dialog, NULL, NULL); |
323 set_dialog_icon(dialog, NULL, 0, NULL); |
| 324 } |
324 } |
| 325 |
325 |
| 326 static void |
326 static void |
| 327 account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
327 account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
| 328 GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog) |
328 GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog) |
| 333 /* Well, it looks like the drag event was cool. |
333 /* Well, it looks like the drag event was cool. |
| 334 * Let's do something with it */ |
334 * Let's do something with it */ |
| 335 if (!g_ascii_strncasecmp(name, "file://", 7)) { |
335 if (!g_ascii_strncasecmp(name, "file://", 7)) { |
| 336 GError *converr = NULL; |
336 GError *converr = NULL; |
| 337 gchar *tmp, *rtmp; |
337 gchar *tmp, *rtmp; |
| |
338 gpointer data; |
| |
339 size_t len; |
| |
340 |
| 338 /* It looks like we're dealing with a local file. */ |
341 /* It looks like we're dealing with a local file. */ |
| 339 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { |
342 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { |
| 340 purple_debug(PURPLE_DEBUG_ERROR, "buddyicon", "%s\n", |
343 purple_debug(PURPLE_DEBUG_ERROR, "buddyicon", "%s\n", |
| 341 (converr ? converr->message : |
344 (converr ? converr->message : |
| 342 "g_filename_from_uri error")); |
345 "g_filename_from_uri error")); |
| 343 return; |
346 return; |
| 344 } |
347 } |
| 345 if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) |
348 if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) |
| 346 *rtmp = '\0'; |
349 *rtmp = '\0'; |
| 347 #if 0 |
350 |
| 348 set_dialog_icon(dialog, pidgin_convert_buddy_icon(dialog->plugin, tmp), g_strdup(tmp)); |
351 data = pidgin_convert_buddy_icon(dialog->plugin, tmp, &len); |
| 349 #endif |
352 /* This takes ownership of tmp */ |
| 350 g_free(tmp); |
353 set_dialog_icon(dialog, data, len, tmp); |
| 351 } |
354 } |
| 352 gtk_drag_finish(dc, TRUE, FALSE, t); |
355 gtk_drag_finish(dc, TRUE, FALSE, t); |
| 353 } |
356 } |
| 354 gtk_drag_finish(dc, FALSE, FALSE, t); |
357 gtk_drag_finish(dc, FALSE, FALSE, t); |
| 355 } |
358 } |
| 593 dialog->icon_entry = gtk_image_new(); |
596 dialog->icon_entry = gtk_image_new(); |
| 594 gtk_container_add(GTK_CONTAINER(button), dialog->icon_entry); |
597 gtk_container_add(GTK_CONTAINER(button), dialog->icon_entry); |
| 595 gtk_widget_show(dialog->icon_entry); |
598 gtk_widget_show(dialog->icon_entry); |
| 596 /* TODO: Uh, isn't this next line pretty useless? */ |
599 /* TODO: Uh, isn't this next line pretty useless? */ |
| 597 pidgin_set_accessible_label (dialog->icon_entry, label); |
600 pidgin_set_accessible_label (dialog->icon_entry, label); |
| 598 dialog->cached_icon_path = NULL; |
601 purple_imgstore_unref(dialog->icon_img); |
| 599 dialog->icon_path = NULL; |
602 dialog->icon_img = NULL; |
| 600 |
603 |
| 601 vbox2 = gtk_vbox_new(FALSE, 0); |
604 vbox2 = gtk_vbox_new(FALSE, 0); |
| 602 gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); |
605 gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); |
| 603 gtk_widget_show(vbox2); |
606 gtk_widget_show(vbox2); |
| 604 |
607 |
| 619 if (dialog->prpl_info->icon_spec.format == NULL) |
622 if (dialog->prpl_info->icon_spec.format == NULL) |
| 620 gtk_widget_hide(dialog->icon_hbox); |
623 gtk_widget_hide(dialog->icon_hbox); |
| 621 } |
624 } |
| 622 |
625 |
| 623 if (dialog->account != NULL) { |
626 if (dialog->account != NULL) { |
| |
627 PurpleStoredImage *img; |
| |
628 gpointer data = NULL; |
| |
629 size_t len = 0; |
| |
630 |
| 624 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->new_mail_check), |
631 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->new_mail_check), |
| 625 purple_account_get_check_mail(dialog->account)); |
632 purple_account_get_check_mail(dialog->account)); |
| 626 |
633 |
| 627 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check), |
634 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check), |
| 628 !purple_account_get_bool(dialog->account, "use-global-buddyicon", |
635 !purple_account_get_bool(dialog->account, "use-global-buddyicon", |
| 629 TRUE)); |
636 TRUE)); |
| 630 set_dialog_icon(dialog, |
637 |
| 631 g_strdup(purple_account_get_ui_string(dialog->account, |
638 img = purple_buddy_icons_find_account_icon(dialog->account); |
| 632 PIDGIN_UI, "non-global-buddyicon-cached-path", NULL)), |
639 if (img) |
| 633 g_strdup(purple_account_get_ui_string(dialog->account, |
640 { |
| 634 PIDGIN_UI, "non-global-buddyicon-path", NULL))); |
641 len = purple_imgstore_get_size(img); |
| |
642 data = g_memdup(purple_imgstore_get_data(img), len); |
| |
643 } |
| |
644 set_dialog_icon(dialog, data, len, |
| |
645 g_strdup(purple_account_get_buddy_icon_path(dialog->account))); |
| 635 } else { |
646 } else { |
| 636 set_dialog_icon(dialog, NULL, NULL); |
647 set_dialog_icon(dialog, NULL, 0, NULL); |
| 637 } |
648 } |
| 638 |
649 |
| 639 if (!dialog->prpl_info || |
650 if (!dialog->prpl_info || |
| 640 (!(dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) && |
651 (!(dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) && |
| 641 (dialog->prpl_info->icon_spec.format == NULL))) { |
652 (dialog->prpl_info->icon_spec.format == NULL))) { |
| 1074 |
1085 |
| 1075 g_list_free(dialog->user_split_entries); |
1086 g_list_free(dialog->user_split_entries); |
| 1076 g_list_free(dialog->protocol_opt_entries); |
1087 g_list_free(dialog->protocol_opt_entries); |
| 1077 g_free(dialog->protocol_id); |
1088 g_free(dialog->protocol_id); |
| 1078 |
1089 |
| 1079 if (dialog->cached_icon_path != NULL) |
1090 purple_imgstore_unref(dialog->icon_img); |
| 1080 { |
|
| 1081 const char *icon = purple_account_get_ui_string(dialog->account, PIDGIN_UI, "non-global-buddyicon-cached-path", NULL); |
|
| 1082 if (dialog->cached_icon_path != NULL && (icon == NULL || strcmp(dialog->cached_icon_path, icon))) |
|
| 1083 { |
|
| 1084 /* The user set an icon, which would've been cached by convert_buddy_icon, |
|
| 1085 * but didn't save the changes. Delete the cache file. */ |
|
| 1086 char *filename = g_build_filename(purple_buddy_icons_get_cache_dir(), dialog->cached_icon_path, NULL); |
|
| 1087 g_unlink(filename); |
|
| 1088 g_free(filename); |
|
| 1089 } |
|
| 1090 |
|
| 1091 g_free(dialog->cached_icon_path); |
|
| 1092 } |
|
| 1093 |
|
| 1094 g_free(dialog->icon_path); |
|
| 1095 |
1091 |
| 1096 if (dialog->icon_filesel) |
1092 if (dialog->icon_filesel) |
| 1097 gtk_widget_destroy(dialog->icon_filesel); |
1093 gtk_widget_destroy(dialog->icon_filesel); |
| 1098 |
1094 |
| 1099 purple_signals_disconnect_by_handle(dialog); |
1095 purple_signals_disconnect_by_handle(dialog); |
| 1145 |
1141 |
| 1146 /* Buddy Icon */ |
1142 /* Buddy Icon */ |
| 1147 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(dialog->plugin); |
1143 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(dialog->plugin); |
| 1148 if (prpl_info != NULL && prpl_info->icon_spec.format != NULL) |
1144 if (prpl_info != NULL && prpl_info->icon_spec.format != NULL) |
| 1149 { |
1145 { |
| |
1146 const char *filename; |
| |
1147 |
| 1150 if (new || purple_account_get_bool(account, "use-global-buddyicon", TRUE) == |
1148 if (new || purple_account_get_bool(account, "use-global-buddyicon", TRUE) == |
| 1151 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
1149 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
| 1152 { |
1150 { |
| 1153 icon_change = TRUE; |
1151 icon_change = TRUE; |
| 1154 } |
1152 } |
| 1155 purple_account_set_bool(account, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); |
1153 purple_account_set_bool(account, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); |
| 1156 purple_account_set_ui_string(account, PIDGIN_UI, "non-global-buddyicon-cached-path", dialog->cached_icon_path); |
1154 |
| 1157 purple_account_set_ui_string(account, PIDGIN_UI, "non-global-buddyicon-path", dialog->icon_path); |
|
| 1158 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
1155 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
| 1159 { |
1156 { |
| 1160 purple_account_set_buddy_icon_path(account, dialog->icon_path); |
1157 if (dialog->icon_img) |
| 1161 purple_account_set_buddy_icon(account, dialog->cached_icon_path); |
1158 { |
| |
1159 size_t len = purple_imgstore_get_size(dialog->icon_img); |
| |
1160 purple_buddy_icons_set_account_icon(account, |
| |
1161 g_memdup(purple_imgstore_get_data(dialog->icon_img), len), |
| |
1162 len); |
| |
1163 purple_account_set_buddy_icon_path(account, purple_imgstore_get_filename(dialog->icon_img)); |
| |
1164 } |
| |
1165 else |
| |
1166 { |
| |
1167 purple_buddy_icons_set_account_icon(account, NULL, 0); |
| |
1168 purple_account_set_buddy_icon_path(account, NULL); |
| |
1169 } |
| 1162 } |
1170 } |
| 1163 else if (purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon") && icon_change) |
1171 else if ((filename = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon")) && icon_change) |
| 1164 { |
1172 { |
| 1165 const char *filename = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
1173 size_t len; |
| 1166 #if 0 |
1174 gpointer data = pidgin_convert_buddy_icon(dialog->plugin, filename, &len); |
| 1167 char *icon = pidgin_convert_buddy_icon(dialog->plugin, filename); |
|
| 1168 purple_account_set_buddy_icon_path(account, filename); |
1175 purple_account_set_buddy_icon_path(account, filename); |
| 1169 purple_account_set_buddy_icon(account, icon); |
1176 purple_buddy_icons_set_account_icon(account, data, len); |
| 1170 g_free(icon); |
|
| 1171 #endif |
|
| 1172 } |
1177 } |
| 1173 } |
1178 } |
| 1174 |
1179 |
| 1175 |
1180 |
| 1176 /* Remember Password */ |
1181 /* Remember Password */ |
| 1979 |
1984 |
| 1980 static void |
1985 static void |
| 1981 set_account(GtkListStore *store, GtkTreeIter *iter, PurpleAccount *account, GdkPixbuf *global_buddyicon) |
1986 set_account(GtkListStore *store, GtkTreeIter *iter, PurpleAccount *account, GdkPixbuf *global_buddyicon) |
| 1982 { |
1987 { |
| 1983 GdkPixbuf *pixbuf, *buddyicon = NULL; |
1988 GdkPixbuf *pixbuf, *buddyicon = NULL; |
| 1984 const char *path = NULL; |
1989 PurpleStoredImage *img = NULL; |
| 1985 |
1990 |
| 1986 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM); |
1991 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM); |
| 1987 if ((pixbuf != NULL) && purple_account_is_disconnected(account)) |
1992 if ((pixbuf != NULL) && purple_account_is_disconnected(account)) |
| 1988 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
1993 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
| 1989 |
1994 |
| 1990 if (purple_account_get_bool(account, "use-global-buddyicon", TRUE)) { |
1995 if (purple_account_get_bool(account, "use-global-buddyicon", TRUE)) { |
| 1991 if (global_buddyicon != NULL) |
1996 if (global_buddyicon != NULL) |
| 1992 buddyicon = g_object_ref(G_OBJECT(global_buddyicon)); |
1997 buddyicon = g_object_ref(G_OBJECT(global_buddyicon)); |
| 1993 /* This is for when set_account() is called for a single account */ |
1998 /* This is for when set_account() is called for a single account */ |
| 1994 else |
1999 else |
| 1995 path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
2000 img = purple_buddy_icons_find_account_icon(account); |
| 1996 } else |
2001 } else { |
| 1997 path = purple_account_get_ui_string(account, PIDGIN_UI, "non-global-buddyicon-path", NULL); |
2002 img = purple_buddy_icons_find_account_icon(account); |
| 1998 |
2003 } |
| 1999 if (path != NULL) { |
2004 |
| 2000 GdkPixbuf *buddyicon_pixbuf = gdk_pixbuf_new_from_file(path, NULL); |
2005 if (img != NULL) { |
| |
2006 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
| |
2007 GdkPixbuf *buddyicon_pixbuf; |
| |
2008 |
| |
2009 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(img), |
| |
2010 purple_imgstore_get_size(img), NULL); |
| |
2011 gdk_pixbuf_loader_close(loader, NULL); |
| |
2012 buddyicon_pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
| |
2013 |
| |
2014 purple_imgstore_unref(img); |
| |
2015 |
| 2001 if (buddyicon_pixbuf != NULL) { |
2016 if (buddyicon_pixbuf != NULL) { |
| 2002 buddyicon = gdk_pixbuf_scale_simple(buddyicon_pixbuf, 22, 22, GDK_INTERP_HYPER); |
2017 buddyicon = gdk_pixbuf_scale_simple(buddyicon_pixbuf, 22, 22, GDK_INTERP_HYPER); |
| 2003 g_object_unref(G_OBJECT(buddyicon_pixbuf)); |
2018 g_object_unref(G_OBJECT(buddyicon_pixbuf)); |
| 2004 } |
2019 } |
| 2005 } |
2020 } |