Mercurial > pidgin
comparison src/gtkutils.c @ 12919:248b8b39c671
[gaim-migrate @ 15272]
Replace GaimBlistNodeAction with the more generic GaimMenuAction, this is in
preparation for letting the chat room user list have extensible menus like the
blist entries do. (I know it's not exactly the prettiest, and the callback
isn't exactly type-safe, when we eventually gobjectify everything we can get
some safety back by using (GObject, gpointer) but that's for later.)
I'm planning to look into merging GaimPluginActions into GaimMenuActions as
well.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Tue, 17 Jan 2006 23:22:19 +0000 |
parents | ee0c8c446eef |
children | 1dc109c12ef5 |
comparison
equal
deleted
inserted
replaced
12918:a05fbd9dcc31 | 12919:248b8b39c671 |
---|---|
1621 g_object_unref(emblem); | 1621 g_object_unref(emblem); |
1622 } | 1622 } |
1623 return scale; | 1623 return scale; |
1624 } | 1624 } |
1625 | 1625 |
1626 static void | |
1627 menu_action_cb(GtkMenuItem *item, gpointer object) | |
1628 { | |
1629 gpointer data; | |
1630 void (*callback)(gpointer, gpointer); | |
1631 | |
1632 callback = g_object_get_data(G_OBJECT(item), "gaimcallback"); | |
1633 data = g_object_get_data(G_OBJECT(item), "gaimcallbackdata"); | |
1634 | |
1635 if (callback) | |
1636 callback(object, data); | |
1637 } | |
1638 | |
1639 void | |
1640 gaim_gtk_append_menu_action(GtkWidget *menu, GaimMenuAction *act, | |
1641 gpointer object) | |
1642 { | |
1643 if (act == NULL) { | |
1644 gaim_separator(menu); | |
1645 } else { | |
1646 GtkWidget *menuitem, *label; | |
1647 | |
1648 if (act->children == NULL) { | |
1649 menuitem = gtk_menu_item_new(); | |
1650 label = gtk_label_new(""); | |
1651 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
1652 gtk_label_set_pattern(GTK_LABEL(label), "_"); | |
1653 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), | |
1654 act->label); | |
1655 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
1656 | |
1657 if (act->callback != NULL) { | |
1658 g_object_set_data(G_OBJECT(menuitem), | |
1659 "gaimcallback", | |
1660 act->callback); | |
1661 g_object_set_data(G_OBJECT(menuitem), | |
1662 "gaimcallbackdata", | |
1663 act->data); | |
1664 g_signal_connect(G_OBJECT(menuitem), "activate", | |
1665 G_CALLBACK(menu_action_cb), | |
1666 object); | |
1667 } else { | |
1668 gtk_widget_set_sensitive(menuitem, FALSE); | |
1669 } | |
1670 | |
1671 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
1672 } else { | |
1673 GList *l = NULL; | |
1674 GtkWidget *submenu = NULL; | |
1675 | |
1676 menuitem = gtk_menu_item_new_with_mnemonic(act->label); | |
1677 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
1678 | |
1679 submenu = gtk_menu_new(); | |
1680 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1681 | |
1682 for (l = act->children; l; l = l->next) { | |
1683 GaimMenuAction *act = (GaimMenuAction *)l->data; | |
1684 | |
1685 gaim_gtk_append_menu_action(submenu, act, object); | |
1686 } | |
1687 g_list_free(act->children); | |
1688 act->children = NULL; | |
1689 } | |
1690 g_free(act); | |
1691 } | |
1692 } |