Mercurial > pidgin
comparison src/gtkutils.c @ 5649:84221116b28e
[gaim-migrate @ 6063]
Our protocol menu is now very happy. It took me all day to do this. I'm so
pathetic.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 02 Jun 2003 05:08:02 +0000 |
parents | 6e551616d051 |
children | dae79aefac8d |
comparison
equal
deleted
inserted
replaced
5648:0cc2d99b7c44 | 5649:84221116b28e |
---|---|
546 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, | 546 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, |
547 gpointer user_data) | 547 gpointer user_data) |
548 { | 548 { |
549 GaimPluginProtocolInfo *prpl_info; | 549 GaimPluginProtocolInfo *prpl_info; |
550 GaimPlugin *plugin; | 550 GaimPlugin *plugin; |
551 GtkWidget *hbox; | |
552 GtkWidget *label; | |
551 GtkWidget *optmenu; | 553 GtkWidget *optmenu; |
552 GtkWidget *menu; | 554 GtkWidget *menu; |
553 GtkWidget *item; | 555 GtkWidget *item; |
554 GtkWidget *image; | 556 GtkWidget *image; |
555 GdkPixbuf *pixbuf; | 557 GdkPixbuf *pixbuf; |
556 GdkPixbuf *scale; | 558 GdkPixbuf *scale; |
557 GList *p; | 559 GList *p; |
560 GtkSizeGroup *sg; | |
558 char *filename; | 561 char *filename; |
559 const char *proto_name; | 562 const char *proto_name; |
560 char buf[256]; | 563 char buf[256]; |
561 int i, selected_index = -1; | 564 int i, selected_index = -1; |
562 | 565 |
569 gtk_widget_show(menu); | 572 gtk_widget_show(menu); |
570 | 573 |
571 g_signal_connect(G_OBJECT(optmenu), "changed", | 574 g_signal_connect(G_OBJECT(optmenu), "changed", |
572 G_CALLBACK(__protocol_menu_cb), cb); | 575 G_CALLBACK(__protocol_menu_cb), cb); |
573 | 576 |
577 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
578 | |
574 for (p = gaim_plugins_get_protocols(), i = 0; | 579 for (p = gaim_plugins_get_protocols(), i = 0; |
575 p != NULL; | 580 p != NULL; |
576 p = p->next, i++) { | 581 p = p->next, i++) { |
577 | 582 |
578 plugin = (GaimPlugin *)p->data; | 583 plugin = (GaimPlugin *)p->data; |
579 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | 584 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
580 | 585 |
581 /* Create the item. */ | 586 /* Create the item. */ |
582 item = gtk_image_menu_item_new_with_label(plugin->info->name); | 587 item = gtk_menu_item_new(); |
588 | |
589 /* Create the hbox. */ | |
590 hbox = gtk_hbox_new(FALSE, 4); | |
591 gtk_container_add(GTK_CONTAINER(item), hbox); | |
592 gtk_widget_show(hbox); | |
583 | 593 |
584 /* Load the image. */ | 594 /* Load the image. */ |
585 proto_name = prpl_info->list_icon(NULL, NULL); | 595 proto_name = prpl_info->list_icon(NULL, NULL); |
586 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); | 596 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
587 | 597 |
593 if (pixbuf != NULL) { | 603 if (pixbuf != NULL) { |
594 /* Scale and insert the image */ | 604 /* Scale and insert the image */ |
595 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | 605 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
596 GDK_INTERP_BILINEAR); | 606 GDK_INTERP_BILINEAR); |
597 image = gtk_image_new_from_pixbuf(scale); | 607 image = gtk_image_new_from_pixbuf(scale); |
608 | |
598 g_object_unref(G_OBJECT(pixbuf)); | 609 g_object_unref(G_OBJECT(pixbuf)); |
599 g_object_unref(G_OBJECT(scale)); | 610 g_object_unref(G_OBJECT(scale)); |
600 gtk_widget_show(image); | |
601 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); | |
602 } | 611 } |
612 else | |
613 image = gtk_image_new(); | |
614 | |
615 gtk_size_group_add_widget(sg, image); | |
616 | |
617 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
618 gtk_widget_show(image); | |
619 | |
620 /* Create the label. */ | |
621 label = gtk_label_new(plugin->info->name); | |
622 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
623 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
624 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
625 gtk_widget_show(label); | |
603 | 626 |
604 g_object_set_data(G_OBJECT(item), "protocol", | 627 g_object_set_data(G_OBJECT(item), "protocol", |
605 GINT_TO_POINTER(prpl_info->protocol)); | 628 GINT_TO_POINTER(prpl_info->protocol)); |
606 | 629 |
607 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 630 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
614 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); | 637 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
615 | 638 |
616 if (selected_index != -1) | 639 if (selected_index != -1) |
617 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); | 640 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
618 | 641 |
642 g_object_unref(sg); | |
643 | |
619 return optmenu; | 644 return optmenu; |
620 } | 645 } |