4 * Finch is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
28 #include "gntmenuitem.h"
29 #include "gntmenuutil.h"
32 context_menu_callback(GntMenuItem
*item
, gpointer data
)
34 PurpleActionMenu
*action
= data
;
36 void (*callback
)(gpointer
, gpointer
);
37 callback
= (void (*)(gpointer
, gpointer
))
38 purple_action_menu_get_callback(action
);
40 gpointer ctx
= g_object_get_data(G_OBJECT(item
), "menuctx");
41 callback(ctx
, purple_action_menu_get_data(action
));
47 finch_append_menu_action(GntMenu
*menu
, PurpleActionMenu
*action
, gpointer ctx
)
52 gchar
*clean_label
= NULL
;
56 label
= purple_action_menu_get_label(action
);
58 if (strchr(label
, '_') != NULL
) {
59 clean_label
= g_strdup(label
);
60 purple_str_strip_char(clean_label
, '_');
63 item
= gnt_menuitem_new(label
);
66 if (purple_action_menu_get_callback(action
)) {
67 gnt_menuitem_set_callback(item
, context_menu_callback
, action
);
68 g_object_set_data(G_OBJECT(item
), "menuctx", ctx
);
70 gnt_menu_add_item(menu
, item
);
72 list
= purple_action_menu_get_children(action
);
75 GntWidget
*sub
= gnt_menu_new(GNT_MENU_POPUP
);
76 gnt_menuitem_set_submenu(item
, GNT_MENU(sub
));
77 for (; list
; list
= g_list_delete_link(list
, list
))
78 finch_append_menu_action(GNT_MENU(sub
), list
->data
, action
);
79 purple_action_menu_set_children(action
, NULL
);
82 g_signal_connect_swapped(G_OBJECT(menu
), "destroy",
83 G_CALLBACK(purple_action_menu_free
), action
);