comparison src/util.c @ 3668:5b82f99d028d

[gaim-migrate @ 3798] Just getting some things set up committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 13 Oct 2002 23:06:22 +0000
parents f09193608fd3
children 507eb0a2c7b2
comparison
equal deleted inserted replaced
3667:11ab2a5f6677 3668:5b82f99d028d
1448 1448
1449 g_free(filename); 1449 g_free(filename);
1450 1450
1451 return pixbuf; 1451 return pixbuf;
1452 } 1452 }
1453
1454 GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
1455 {
1456 GtkWidget *menuitem;
1457 GtkWidget *hbox;
1458 GtkWidget *label;
1459 GtkWidget *image;
1460
1461 if (icon == NULL)
1462 menuitem = gtk_menu_item_new_with_mnemonic(_(str));
1463 else
1464 menuitem = gtk_image_menu_item_new_with_mnemonic(_(str));
1465
1466 if (menu)
1467 gtk_menu_append(GTK_MENU(menu), menuitem);
1468
1469 if (sf)
1470 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
1471
1472 if (icon != NULL) {
1473 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
1474 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
1475 }
1476
1477 if (mod) {
1478 label = gtk_label_new(mod);
1479 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
1480 gtk_widget_show(label);
1481 }
1482 /*
1483 if (accel_key) {
1484 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
1485 accel_mods, GTK_ACCEL_LOCKED);
1486 }
1487 */
1488
1489 gtk_widget_show_all(menuitem);
1490
1491 return menuitem;
1492 }
1493
1494 GtkWidget *gaim_new_item_from_pixbuf(GtkWidget *menu, const char *str, char *iconname, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
1495 {
1496 GtkWidget *menuitem;
1497 GtkWidget *hbox;
1498 GtkWidget *label;
1499 GtkWidget *image;
1500
1501 if (iconname == NULL)
1502 menuitem = gtk_menu_item_new_with_mnemonic(_(str));
1503 else
1504 menuitem = gtk_image_menu_item_new_with_mnemonic(_(str));
1505
1506 if (menu)
1507 gtk_menu_append(GTK_MENU(menu), menuitem);
1508
1509 if (sf)
1510 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
1511
1512 if (iconname != NULL) {
1513 char *filename;
1514
1515 filename = g_build_filename (DATADIR, "pixmaps", "gaim", "menus", iconname, NULL);
1516 debug_printf("Loading: %s\n", filename);
1517 image = gtk_image_new_from_file(filename);
1518 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
1519 g_free(filename);
1520 }
1521
1522 if (mod) {
1523 label = gtk_label_new(mod);
1524 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
1525 gtk_widget_show(label);
1526 }
1527 /*
1528 if (accel_key) {
1529 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
1530 accel_mods, GTK_ACCEL_LOCKED);
1531 }
1532 */
1533
1534 gtk_widget_show_all(menuitem);
1535
1536 return menuitem;
1537 }
1538
1539
1540 GtkWidget *gaim_new_item_with_pixmap(GtkWidget *menu, const char *str, char **xpm, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
1541 {
1542 GtkWidget *menuitem;
1543 GtkWidget *hbox;
1544 GtkWidget *label;
1545 GtkWidget *pixmap;
1546 GdkPixmap *pm;
1547 GdkBitmap *mask;
1548
1549 menuitem = gtk_menu_item_new();
1550 if (menu)
1551 gtk_menu_append(GTK_MENU(menu), menuitem);
1552 if (sf)
1553 /* passing 1 is necessary so if we sign off closing the account editor doesn't exit */
1554 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
1555 gtk_widget_show(menuitem);
1556
1557 /* Create our container */
1558 hbox = gtk_hbox_new(FALSE, 2);
1559 gtk_container_add(GTK_CONTAINER(menuitem), hbox);
1560 gtk_widget_show(hbox);
1561
1562 /* Create our pixmap and pack it */
1563 gtk_widget_realize(menu->parent);
1564 pm = gdk_pixmap_create_from_xpm_d(menu->parent->window, &mask, NULL, xpm);
1565 pixmap = gtk_pixmap_new(pm, mask);
1566 gtk_widget_show(pixmap);
1567 gdk_pixmap_unref(pm);
1568 gdk_bitmap_unref(mask);
1569 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 2);
1570
1571 /* Create our label and pack it */
1572 label = gtk_label_new(str);
1573 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
1574 gtk_widget_show(label);
1575
1576 if (mod) {
1577 label = gtk_label_new(mod);
1578 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
1579 gtk_widget_show(label);
1580 }
1581 /*
1582 if (accel_key) {
1583 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
1584 accel_mods, GTK_ACCEL_LOCKED);
1585 }
1586 */
1587 return menuitem;
1588 }
1589