Fri, 13 Sep 2013 18:54:07 +0530
Backed out changeset 2961685df856
|
32850
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
2 | * @file gntmenuutil.c GNT Menu Utility Functions |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
3 | * @ingroup finch |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
4 | */ |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
5 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
6 | /* finch |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
8 | * Finch is the legal property of its developers, whose names are too numerous |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
10 | * source distribution. |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
11 | * |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
12 | * This program is free software; you can redistribute it and/or modify |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
14 | * the Free Software Foundation; either version 2 of the License, or |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
15 | * (at your option) any later version. |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
16 | * |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
17 | * This program is distributed in the hope that it will be useful, |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
20 | * GNU General Public License for more details. |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
21 | * |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
22 | * You should have received a copy of the GNU General Public License |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
23 | * along with this program; if not, write to the Free Software |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
25 | */ |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
26 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
27 | #include <internal.h> |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
28 | #include "finch.h" |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
29 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
30 | #include "gnt.h" |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
31 | #include "gntmenu.h" |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
32 | #include "gntmenuitem.h" |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
33 | #include "gntmenuutil.h" |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
34 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
35 | static void |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
36 | context_menu_callback(GntMenuItem *item, gpointer data) |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
37 | { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
38 | PurpleMenuAction *action = data; |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
39 | if (action) { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
40 | void (*callback)(gpointer, gpointer); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
41 | callback = (void (*)(gpointer, gpointer)) |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
42 | purple_menu_action_get_callback(action); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
43 | if (callback) { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
44 | gpointer ctx = g_object_get_data(G_OBJECT(item), "menuctx"); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
45 | callback(ctx, purple_menu_action_get_data(action)); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
46 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
47 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
48 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
49 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
50 | void |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
51 | gnt_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx) |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
52 | { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
53 | GList *list; |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
54 | GntMenuItem *item; |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
55 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
56 | if (action == NULL) |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
57 | return; |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
58 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
59 | item = gnt_menuitem_new(purple_menu_action_get_label(action)); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
60 | if (purple_menu_action_get_callback(action)) { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
61 | gnt_menuitem_set_callback(item, context_menu_callback, action); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
62 | g_object_set_data(G_OBJECT(item), "menuctx", ctx); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
63 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
64 | gnt_menu_add_item(menu, item); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
65 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
66 | list = purple_menu_action_get_children(action); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
67 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
68 | if (list) { |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
69 | GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
70 | gnt_menuitem_set_submenu(item, GNT_MENU(sub)); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
71 | for (; list; list = g_list_delete_link(list, list)) |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
72 | gnt_append_menu_action(GNT_MENU(sub), list->data, action); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
73 | purple_menu_action_set_children(action, NULL); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
74 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
75 | |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
76 | g_signal_connect_swapped(G_OBJECT(menu), "destroy", |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
77 | G_CALLBACK(purple_menu_action_free), action); |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
78 | } |
|
79912ff55187
I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
79 |