comparison gtk/gtkaccount.c @ 14609:36ededd6e064

[gaim-migrate @ 17337] Show the placeholder icon in the account editor. I didn't make it clickable, though. Can someone please do that for me? Pretty please with corn syrup on top? I'll be your best friend! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 22 Sep 2006 06:45:01 +0000
parents 98776da658d1
children bee0bdd63b1f
comparison
equal deleted inserted replaced
14608:98776da658d1 14609:36ededd6e064
187 187
188 return hbox; 188 return hbox;
189 } 189 }
190 190
191 static void 191 static void
192 set_dialog_icon(AccountPrefsDialog *dialog) 192 set_dialog_icon(AccountPrefsDialog *dialog, gchar *new_icon_path)
193 { 193 {
194 char *filename = gaim_buddy_icons_get_full_path(dialog->icon_path); 194 char *filename;
195 GdkPixbuf *pixbuf = NULL; 195 GdkPixbuf *pixbuf = NULL;
196 if (filename) 196
197 g_free(dialog->icon_path);
198 dialog->icon_path = new_icon_path;
199
200 filename = gaim_buddy_icons_get_full_path(dialog->icon_path);
201 if (filename != NULL) {
197 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); 202 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
203 g_free(filename);
204 }
198 205
199 if (pixbuf && dialog->prpl_info && 206 if (pixbuf && dialog->prpl_info &&
200 (dialog->prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_DISPLAY)) 207 (dialog->prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_DISPLAY))
201 { 208 {
209 /* Scale the icon to something reasonable */
202 int width, height; 210 int width, height;
203 GdkPixbuf *scale; 211 GdkPixbuf *scale;
204 212
205 gaim_gtk_buddy_icon_get_scale_size(pixbuf, 213 gaim_gtk_buddy_icon_get_scale_size(pixbuf,
206 &dialog->prpl_info->icon_spec, &width, &height); 214 &dialog->prpl_info->icon_spec, &width, &height);
208 216
209 g_object_unref(G_OBJECT(pixbuf)); 217 g_object_unref(G_OBJECT(pixbuf));
210 pixbuf = scale; 218 pixbuf = scale;
211 } 219 }
212 220
221 if (pixbuf == NULL)
222 {
223 /* Show a placeholder icon */
224 gchar *filename;
225 filename = g_build_filename(DATADIR, "pixmaps",
226 "gaim", "insert-image.png", NULL);
227 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
228 g_free(filename);
229 }
230
213 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_entry), pixbuf); 231 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_entry), pixbuf);
214 if (pixbuf != NULL) 232 if (pixbuf != NULL)
215 g_object_unref(G_OBJECT(pixbuf)); 233 g_object_unref(G_OBJECT(pixbuf));
216 g_free(filename);
217 } 234 }
218 235
219 static void 236 static void
220 set_account_protocol_cb(GtkWidget *item, const char *id, 237 set_account_protocol_cb(GtkWidget *item, const char *id,
221 AccountPrefsDialog *dialog) 238 AccountPrefsDialog *dialog)
277 { 294 {
278 AccountPrefsDialog *dialog; 295 AccountPrefsDialog *dialog;
279 296
280 dialog = data; 297 dialog = data;
281 298
282 if (filename) { 299 set_dialog_icon(dialog, gaim_gtk_convert_buddy_icon(dialog->plugin, filename));
283 g_free(dialog->icon_path);
284 dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, filename);
285 set_dialog_icon(dialog);
286 gtk_widget_show(dialog->icon_entry);
287 }
288 300
289 dialog->icon_filesel = NULL; 301 dialog->icon_filesel = NULL;
290 } 302 }
291 303
292 static void 304 static void
297 } 309 }
298 310
299 static void 311 static void
300 icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) 312 icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog)
301 { 313 {
302 g_free(dialog->icon_path); 314 set_dialog_icon(dialog, NULL);
303 dialog->icon_path = NULL; 315 }
304
305 gtk_widget_hide(dialog->icon_entry);
306 }
307
308 316
309 static void 317 static void
310 account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, 318 account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
311 GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog) 319 GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog)
312 { 320 {
326 "g_filename_from_uri error")); 334 "g_filename_from_uri error"));
327 return; 335 return;
328 } 336 }
329 if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) 337 if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n')))
330 *rtmp = '\0'; 338 *rtmp = '\0';
331 g_free(dialog->icon_path); 339 set_dialog_icon(dialog, gaim_gtk_convert_buddy_icon(dialog->plugin, tmp));
332
333 dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, tmp);
334 set_dialog_icon(dialog);
335 gtk_widget_show(dialog->icon_entry);
336 g_free(tmp); 340 g_free(tmp);
337 } 341 }
338 gtk_drag_finish(dc, TRUE, FALSE, t); 342 gtk_drag_finish(dc, TRUE, FALSE, t);
339 } 343 }
340 gtk_drag_finish(dc, FALSE, FALSE, t); 344 gtk_drag_finish(dc, FALSE, FALSE, t);
610 614
611 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check), 615 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check),
612 !gaim_account_get_ui_bool(dialog->account, GAIM_GTK_UI, "use-global-buddyicon", 616 !gaim_account_get_ui_bool(dialog->account, GAIM_GTK_UI, "use-global-buddyicon",
613 TRUE)); 617 TRUE));
614 618
615 dialog->icon_path = g_strdup(gaim_account_get_ui_string(dialog->account, GAIM_GTK_UI, "non-global-buddyicon", NULL)); 619 set_dialog_icon(dialog,
616 set_dialog_icon(dialog); 620 g_strdup(gaim_account_get_ui_string(dialog->account,
621 GAIM_GTK_UI, "non-global-buddyicon", NULL)));
617 } 622 }
618 623
619 if (!dialog->prpl_info || 624 if (!dialog->prpl_info ||
620 (!(dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) && 625 (!(dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) &&
621 (dialog->prpl_info->icon_spec.format == NULL))) { 626 (dialog->prpl_info->icon_spec.format == NULL))) {