Mercurial > pidgin.yaz
comparison finch/gntblist.c @ 32466:3b2ceeb8883b
Hide-a-PurpleMenuAction.
author | masca@cpw.pidgin.im |
---|---|
date | Thu, 01 Sep 2011 04:23:42 +0000 |
parents | 49a33bd1baf1 |
children | cd1d9e04c587 |
comparison
equal
deleted
inserted
replaced
32465:39d69f5bf146 | 32466:3b2ceeb8883b |
---|---|
1076 { | 1076 { |
1077 PurpleMenuAction *action = data; | 1077 PurpleMenuAction *action = data; |
1078 PurpleBlistNode *node = ggblist->cnode; | 1078 PurpleBlistNode *node = ggblist->cnode; |
1079 if (action) { | 1079 if (action) { |
1080 void (*callback)(PurpleBlistNode *, gpointer); | 1080 void (*callback)(PurpleBlistNode *, gpointer); |
1081 callback = (void (*)(PurpleBlistNode *, gpointer))action->callback; | 1081 callback = (void (*)(PurpleBlistNode *, gpointer)) |
1082 purple_menu_action_get_callback(action); | |
1082 if (callback) | 1083 if (callback) |
1083 callback(node, action->data); | 1084 callback(node, purple_menu_action_get_data(action)); |
1084 else | 1085 else |
1085 return; | 1086 return; |
1086 } | 1087 } |
1087 } | 1088 } |
1088 | 1089 |
1093 GntMenuItem *item; | 1094 GntMenuItem *item; |
1094 | 1095 |
1095 if (action == NULL) | 1096 if (action == NULL) |
1096 return; | 1097 return; |
1097 | 1098 |
1098 item = gnt_menuitem_new(action->label); | 1099 item = gnt_menuitem_new(purple_menu_action_get_label(action)); |
1099 if (action->callback) | 1100 if (purple_menu_action_get_callback(action)) |
1100 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), context_menu_callback, action); | 1101 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), context_menu_callback, action); |
1101 gnt_menu_add_item(menu, GNT_MENU_ITEM(item)); | 1102 gnt_menu_add_item(menu, GNT_MENU_ITEM(item)); |
1102 | 1103 |
1103 if (action->children) { | 1104 list = purple_menu_action_get_children(action); |
1105 | |
1106 if (list) { | |
1104 GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); | 1107 GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); |
1105 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | 1108 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); |
1106 for (list = action->children; list; list = list->next) | 1109 for (; list; list = list->next) |
1107 gnt_append_menu_action(GNT_MENU(sub), list->data, action); | 1110 gnt_append_menu_action(GNT_MENU(sub), list->data, action); |
1108 } | 1111 } |
1109 } | 1112 } |
1110 | 1113 |
1111 static void | 1114 static void |
1121 list = g_list_delete_link(list, list)) | 1124 list = g_list_delete_link(list, list)) |
1122 { | 1125 { |
1123 PurpleMenuAction *act = (PurpleMenuAction *) list->data; | 1126 PurpleMenuAction *act = (PurpleMenuAction *) list->data; |
1124 if (!act) | 1127 if (!act) |
1125 continue; | 1128 continue; |
1126 act->data = node; | 1129 purple_menu_action_set_data(act, node); |
1127 gnt_append_menu_action(menu, act, NULL); | 1130 gnt_append_menu_action(menu, act, NULL); |
1128 g_signal_connect_swapped(G_OBJECT(menu), "destroy", | 1131 g_signal_connect_swapped(G_OBJECT(menu), "destroy", |
1129 G_CALLBACK(purple_menu_action_free), act); | 1132 G_CALLBACK(purple_menu_action_free), act); |
1130 } | 1133 } |
1131 } | 1134 } |
1214 | 1217 |
1215 static void | 1218 static void |
1216 autojoin_toggled(GntMenuItem *item, gpointer data) | 1219 autojoin_toggled(GntMenuItem *item, gpointer data) |
1217 { | 1220 { |
1218 PurpleMenuAction *action = data; | 1221 PurpleMenuAction *action = data; |
1219 purple_blist_node_set_bool(action->data, "gnt-autojoin", | 1222 purple_blist_node_set_bool(purple_menu_action_get_data(action), "gnt-autojoin", |
1220 gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item))); | 1223 gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item))); |
1221 } | 1224 } |
1222 | 1225 |
1223 static void | 1226 static void |
1224 create_chat_menu(GntMenu *menu, PurpleChat *chat) | 1227 create_chat_menu(GntMenu *menu, PurpleChat *chat) |
1225 { | 1228 { |
1226 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); | 1229 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); |
1227 GntMenuItem *check = gnt_menuitem_check_new(action->label); | 1230 GntMenuItem *check = gnt_menuitem_check_new( |
1231 purple_menu_action_get_label(action)); | |
1228 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), | 1232 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), |
1229 purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin")); | 1233 purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin")); |
1230 gnt_menu_add_item(menu, check); | 1234 gnt_menu_add_item(menu, check); |
1231 gnt_menuitem_set_callback(check, autojoin_toggled, action); | 1235 gnt_menuitem_set_callback(check, autojoin_toggled, action); |
1232 g_signal_connect_swapped(G_OBJECT(menu), "destroy", | 1236 g_signal_connect_swapped(G_OBJECT(menu), "destroy", |