Mercurial > pidgin.yaz
comparison gtk/gtkstatusbox.c @ 15018:40364ce5d6e3
[gaim-migrate @ 17799]
The global buddy icon is now removable (via a right-click popup menu).
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 21 Nov 2006 04:34:38 +0000 |
parents | 1a8aa1ff4c62 |
children | af2debe897c8 |
comparison
equal
deleted
inserted
replaced
15017:6e7184096615 | 15018:40364ce5d6e3 |
---|---|
228 update_to_reflect_account_status(status_box, account, newstatus); | 228 update_to_reflect_account_status(status_box, account, newstatus); |
229 else if (status_box->token_status_account == account) | 229 else if (status_box->token_status_account == account) |
230 status_menu_refresh_iter(status_box); | 230 status_menu_refresh_iter(status_box); |
231 } | 231 } |
232 | 232 |
233 static void | |
234 remove_buddy_icon_cb(GtkWidget *w, GtkGaimStatusBox *box) | |
235 { | |
236 /* The pref-connect callback does the actual work */ | |
237 gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", NULL); | |
238 | |
239 gtk_widget_destroy(box->icon_box_menu); | |
240 box->icon_box_menu = NULL; | |
241 } | |
242 | |
233 static gboolean | 243 static gboolean |
234 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) | 244 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) |
235 { | 245 { |
236 if (box->buddy_icon_sel) { | 246 if (event->button == 3) { |
237 gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); | 247 GtkWidget *menu_item; |
238 return FALSE; | 248 |
239 } | 249 if (box->icon_box_menu) |
240 | 250 gtk_widget_destroy(box->icon_box_menu); |
241 box->buddy_icon_sel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); | 251 |
242 gtk_widget_show_all(box->buddy_icon_sel); | 252 box->icon_box_menu = gtk_menu_new(); |
253 | |
254 menu_item = gaim_new_item_from_stock(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE, | |
255 G_CALLBACK(remove_buddy_icon_cb), | |
256 box, 0, 0, NULL); | |
257 if (gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon") == NULL) | |
258 gtk_widget_set_sensitive(menu_item, FALSE); | |
259 | |
260 gtk_menu_popup(GTK_MENU(box->icon_box_menu), NULL, NULL, NULL, NULL, | |
261 event->button, event->time); | |
262 | |
263 } else { | |
264 if (box->buddy_icon_sel) { | |
265 gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); | |
266 return FALSE; | |
267 } | |
268 | |
269 box->buddy_icon_sel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); | |
270 gtk_widget_show_all(box->buddy_icon_sel); | |
271 } | |
243 return FALSE; | 272 return FALSE; |
244 } | 273 } |
245 | 274 |
246 static void | 275 static void |
247 icon_box_dnd_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, | 276 icon_box_dnd_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
352 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); | 381 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
353 | 382 |
354 if (statusbox->buddy_icon_sel) | 383 if (statusbox->buddy_icon_sel) |
355 gtk_widget_destroy(statusbox->buddy_icon_sel); | 384 gtk_widget_destroy(statusbox->buddy_icon_sel); |
356 | 385 |
386 if (statusbox->icon_box_menu) | |
387 gtk_widget_destroy(statusbox->icon_box_menu); | |
388 | |
357 g_free(statusbox->buddy_icon_path); | 389 g_free(statusbox->buddy_icon_path); |
358 | 390 |
359 statusbox->icon = NULL; | 391 statusbox->icon = NULL; |
360 statusbox->icon_box = NULL; | 392 statusbox->icon_box = NULL; |
393 statusbox->icon_box_menu = NULL; | |
361 statusbox->buddy_icon_path = NULL; | 394 statusbox->buddy_icon_path = NULL; |
362 statusbox->buddy_icon = NULL; | 395 statusbox->buddy_icon = NULL; |
363 statusbox->buddy_icon_hover = NULL; | 396 statusbox->buddy_icon_hover = NULL; |
364 statusbox->hand_cursor = NULL; | 397 statusbox->hand_cursor = NULL; |
365 statusbox->arrow_cursor = NULL; | 398 statusbox->arrow_cursor = NULL; |
1196 { | 1229 { |
1197 GtkGaimStatusBox *box; | 1230 GtkGaimStatusBox *box; |
1198 | 1231 |
1199 box = data; | 1232 box = data; |
1200 | 1233 |
1201 if (filename) { | 1234 if (box->account) { |
1235 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(box->account)); | |
1236 if (plug) { | |
1237 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); | |
1238 if (prplinfo && prplinfo->icon_spec.format) { | |
1239 char *icon = NULL; | |
1240 if (filename) | |
1241 icon = gaim_gtk_convert_buddy_icon(plug, filename); | |
1242 gaim_account_set_ui_bool(box->account, GAIM_GTK_UI, "use-global-buddyicon", (filename != NULL)); | |
1243 gaim_account_set_ui_string(box->account, GAIM_GTK_UI, "non-global-buddyicon", icon); | |
1244 gaim_account_set_buddy_icon(box->account, icon); | |
1245 g_free(icon); | |
1246 } | |
1247 } | |
1248 } else { | |
1202 GList *accounts; | 1249 GList *accounts; |
1203 | 1250 for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
1204 if (box->account) { | 1251 GaimAccount *account = accounts->data; |
1205 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(box->account)); | 1252 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
1206 if (plug) { | 1253 if (plug) { |
1207 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); | 1254 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); |
1208 if (prplinfo && prplinfo->icon_spec.format) { | 1255 if (prplinfo != NULL && |
1209 char *icon = gaim_gtk_convert_buddy_icon(plug, filename); | 1256 gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", TRUE) && |
1210 gaim_account_set_buddy_icon(box->account, icon); | 1257 prplinfo->icon_spec.format) { |
1211 gaim_account_set_ui_bool(box->account, GAIM_GTK_UI, "use-global-buddyicon", FALSE); | 1258 char *icon = NULL; |
1212 gaim_account_set_ui_string(box->account, GAIM_GTK_UI, "non-global-buddyicon", icon); | 1259 if (filename) |
1260 icon = gaim_gtk_convert_buddy_icon(plug, filename); | |
1261 gaim_account_set_buddy_icon(account, icon); | |
1213 g_free(icon); | 1262 g_free(icon); |
1214 } | 1263 } |
1215 } | 1264 } |
1216 } else { | 1265 } |
1217 for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { | 1266 } |
1218 GaimAccount *account = accounts->data; | 1267 gtk_gaim_status_box_set_buddy_icon(box, filename); |
1219 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
1220 if (plug) { | |
1221 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); | |
1222 if (prplinfo != NULL && | |
1223 gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", TRUE) && | |
1224 prplinfo->icon_spec.format) { | |
1225 char *icon = gaim_gtk_convert_buddy_icon(plug, filename); | |
1226 gaim_account_set_buddy_icon(account, icon); | |
1227 g_free(icon); | |
1228 } | |
1229 } | |
1230 } | |
1231 } | |
1232 gtk_gaim_status_box_set_buddy_icon(box, filename); | |
1233 } | |
1234 } | 1268 } |
1235 | 1269 |
1236 static void | 1270 static void |
1237 icon_choose_cb(const char *filename, gpointer data) | 1271 icon_choose_cb(const char *filename, gpointer data) |
1238 { | 1272 { |
1239 GtkGaimStatusBox *box = data; | 1273 GtkGaimStatusBox *box = data; |
1240 if (box->account == NULL && filename) | 1274 if (filename) { |
1241 /* The pref-connect callback does the actual work */ | 1275 if (box->account == NULL) |
1242 gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); | 1276 /* The pref-connect callback does the actual work */ |
1243 else | 1277 gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); |
1244 buddy_icon_set_cb(filename, data); | 1278 else |
1279 buddy_icon_set_cb(filename, data); | |
1280 } | |
1245 | 1281 |
1246 box->buddy_icon_sel = NULL; | 1282 box->buddy_icon_sel = NULL; |
1247 } | 1283 } |
1248 | 1284 |
1249 static void | 1285 static void |