finch/gntmenuutil.c

Thu, 13 Feb 2014 20:11:13 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Thu, 13 Feb 2014 20:11:13 +0100
changeset 35559
061c2ae3679c
parent 35494
e631108a5464
child 35918
3f84738fbc15
permissions
-rw-r--r--

Fix the build again

32850
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /* finch
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
2 *
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 * 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
4 * 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
5 * source distribution.
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 *
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * (at your option) any later version.
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 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
13 * 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
14 * 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
15 * 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
16 *
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 * 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
18 * 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
19 * 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
20 */
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 #include <internal.h>
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
23 #include "finch.h"
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
24
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
25 #include "gnt.h"
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26 #include "gntmenu.h"
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
27 #include "gntmenuitem.h"
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
28 #include "gntmenuutil.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 static void
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
31 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
32 {
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
33 PurpleMenuAction *action = data;
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
34 if (action) {
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
35 void (*callback)(gpointer, gpointer);
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
36 callback = (void (*)(gpointer, gpointer))
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
37 purple_menu_action_get_callback(action);
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
38 if (callback) {
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
39 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
40 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
41 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
42 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
43 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
44
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
45 void
35494
e631108a5464 Fix namespace issues in libgnt and finch.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
46 finch_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx)
32850
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 GList *list;
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
49 GntMenuItem *item;
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
50
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
51 if (action == NULL)
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
52 return;
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
53
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
54 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
55 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
56 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
57 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
58 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
59 gnt_menu_add_item(menu, item);
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
60
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
61 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
62
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
63 if (list) {
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
64 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
65 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
66 for (; list; list = g_list_delete_link(list, list))
35494
e631108a5464 Fix namespace issues in libgnt and finch.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
67 finch_append_menu_action(GNT_MENU(sub), list->data, action);
32850
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68 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
69 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
70
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
71 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
72 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
73 }
79912ff55187 I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
74

mercurial