Mercurial > pidgin.yaz
comparison pidgin/gtkutils.c @ 16966:825f0fe66304
Add Google Talk to the account editor. I'm sure this will be controversial.
If you select "Google Talk (XMPP)", you get "XMPP".
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 09 May 2007 02:45:35 +0000 |
parents | b668951121d8 |
children | a728447e4e72 |
comparison
equal
deleted
inserted
replaced
16964:ab45289d2c36 | 16966:825f0fe66304 |
---|---|
440 | 440 |
441 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | 441 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
442 item = gtk_menu_get_active(GTK_MENU(menu)); | 442 item = gtk_menu_get_active(GTK_MENU(menu)); |
443 | 443 |
444 protocol = g_object_get_data(G_OBJECT(item), "protocol"); | 444 protocol = g_object_get_data(G_OBJECT(item), "protocol"); |
445 | |
446 if (!strcmp(protocol, "prpl-fake")) | |
447 { | |
448 guint index = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(item), "real_index")); | |
449 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), index); | |
450 return; | |
451 } | |
452 | |
445 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); | 453 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
446 | 454 |
447 if (cb != NULL) | 455 if (cb != NULL) |
448 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, | 456 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, |
449 user_data); | 457 user_data); |
450 } | 458 } |
451 | 459 |
460 static GtkWidget * | |
461 pidgin_protocol_option_menu_item(GtkWidget *menu, GtkSizeGroup *sg, GtkWidget *image, | |
462 const char *name, const char *id) | |
463 { | |
464 GtkWidget *item; | |
465 GtkWidget *hbox; | |
466 GtkWidget *label; | |
467 | |
468 /* Create the item. */ | |
469 item = gtk_menu_item_new(); | |
470 | |
471 /* Create the hbox. */ | |
472 hbox = gtk_hbox_new(FALSE, 4); | |
473 gtk_container_add(GTK_CONTAINER(item), hbox); | |
474 gtk_widget_show(hbox); | |
475 | |
476 gtk_size_group_add_widget(sg, image); | |
477 | |
478 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
479 gtk_widget_show(image); | |
480 | |
481 /* Create the label. */ | |
482 label = gtk_label_new(name); | |
483 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
484 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
485 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
486 gtk_widget_show(label); | |
487 | |
488 g_object_set_data(G_OBJECT(item), "protocol", (gpointer)id); | |
489 | |
490 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
491 gtk_widget_show(item); | |
492 pidgin_set_accessible_label (item, label); | |
493 | |
494 return item; | |
495 } | |
496 | |
452 GtkWidget * | 497 GtkWidget * |
453 pidgin_protocol_option_menu_new(const char *id, GCallback cb, | 498 pidgin_protocol_option_menu_new(const char *id, GCallback cb, |
454 gpointer user_data) | 499 gpointer user_data) |
455 { | 500 { |
456 PurplePluginProtocolInfo *prpl_info; | 501 PurplePluginProtocolInfo *prpl_info; |
457 PurplePlugin *plugin; | 502 PurplePlugin *plugin; |
458 GtkWidget *hbox; | |
459 GtkWidget *label; | |
460 GtkWidget *optmenu; | 503 GtkWidget *optmenu; |
461 GtkWidget *menu; | 504 GtkWidget *menu; |
462 GtkWidget *item; | 505 GdkPixbuf *pixbuf; |
463 GtkWidget *image; | 506 GtkWidget *image; |
464 GdkPixbuf *pixbuf; | |
465 GList *p; | 507 GList *p; |
466 GtkSizeGroup *sg; | 508 GtkSizeGroup *sg; |
467 char *filename; | 509 char *filename; |
468 const char *proto_name; | 510 const char *proto_name; |
469 char buf[256]; | 511 char buf[256]; |
484 p = p->next, i++) { | 526 p = p->next, i++) { |
485 | 527 |
486 plugin = (PurplePlugin *)p->data; | 528 plugin = (PurplePlugin *)p->data; |
487 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); | 529 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
488 | 530 |
489 /* Create the item. */ | |
490 item = gtk_menu_item_new(); | |
491 | |
492 /* Create the hbox. */ | |
493 hbox = gtk_hbox_new(FALSE, 4); | |
494 gtk_container_add(GTK_CONTAINER(item), hbox); | |
495 gtk_widget_show(hbox); | |
496 | |
497 /* Load the image. */ | 531 /* Load the image. */ |
498 proto_name = prpl_info->list_icon(NULL, NULL); | 532 proto_name = prpl_info->list_icon(NULL, NULL); |
499 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); | 533 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
500 | 534 |
501 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", | 535 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
502 "16", buf, NULL); | 536 "16", buf, NULL); |
503 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 537 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
504 g_free(filename); | 538 g_free(filename); |
505 | 539 |
506 if (pixbuf) { | 540 if (pixbuf) |
507 image = gtk_image_new_from_pixbuf(pixbuf); | 541 image = gtk_image_new_from_pixbuf(pixbuf); |
508 | |
509 g_object_unref(G_OBJECT(pixbuf)); | |
510 } | |
511 else | 542 else |
512 image = gtk_image_new(); | 543 image = gtk_image_new(); |
513 | 544 |
514 gtk_size_group_add_widget(sg, image); | 545 pidgin_protocol_option_menu_item(menu, sg, image, plugin->info->name, plugin->info->id); |
515 | |
516 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
517 gtk_widget_show(image); | |
518 | |
519 /* Create the label. */ | |
520 label = gtk_label_new(plugin->info->name); | |
521 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
522 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
523 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
524 gtk_widget_show(label); | |
525 | |
526 g_object_set_data(G_OBJECT(item), "protocol", plugin->info->id); | |
527 | |
528 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
529 gtk_widget_show(item); | |
530 pidgin_set_accessible_label (item, label); | |
531 | 546 |
532 if (id != NULL && !strcmp(plugin->info->id, id)) | 547 if (id != NULL && !strcmp(plugin->info->id, id)) |
533 selected_index = i; | 548 selected_index = i; |
549 | |
550 if (!strcmp(plugin->info->id, "prpl-jabber")) | |
551 { | |
552 GtkWidget *gtalk_item; | |
553 if (pixbuf) | |
554 image = gtk_image_new_from_pixbuf(pixbuf); | |
555 else | |
556 image = gtk_image_new(); | |
557 | |
558 gtalk_item = pidgin_protocol_option_menu_item(menu, sg, image, _("Google Talk (XMPP)"), "prpl-fake"); | |
559 g_object_set_data(G_OBJECT(gtalk_item), "real_index", GUINT_TO_POINTER(i)); | |
560 i++; | |
561 } | |
562 | |
563 if (pixbuf) | |
564 g_object_unref(G_OBJECT(pixbuf)); | |
534 } | 565 } |
535 | 566 |
536 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); | 567 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
537 | 568 |
538 if (selected_index != -1) | 569 if (selected_index != -1) |