annotate finch/gntmenuutil.c @ 32745:9cb109dbaa21

Russian translation updated (§¡§ß§ä§à§ß §³§Ñ§Þ§à§ç§Ó§Ñ§Ý§à§Ó) Fixes #14814
author Mark Doliner <mark@kingant.net>
date Mon, 12 Mar 2012 09:21:23 +0000
parents 30a92ba1c39f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32497
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /**
30a92ba1c39f 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
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 * @ingroup finch
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 */
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
5
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 /* finch
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 *
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
10 * source distribution.
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 *
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
16 *
30a92ba1c39f 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,
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f 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.
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21 *
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f 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
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
25 */
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
27 #include <internal.h>
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
28 #include "finch.h"
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
29
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
30 #include "gnt.h"
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
31 #include "gntmenu.h"
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
32 #include "gntmenuitem.h"
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
33 #include "gntmenuutil.h"
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
34
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
35 static void
30a92ba1c39f 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)
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
37 {
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
38 PurpleMenuAction *action = data;
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
39 if (action) {
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
40 void (*callback)(gpointer, gpointer);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
41 callback = (void (*)(gpointer, gpointer))
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
42 purple_menu_action_get_callback(action);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
43 if (callback) {
30a92ba1c39f 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");
30a92ba1c39f 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));
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
46 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
47 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
48 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
49
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
50 void
30a92ba1c39f 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)
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
52 {
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
53 GList *list;
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
54 GntMenuItem *item;
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
55
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
56 if (action == NULL)
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
57 return;
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
58
30a92ba1c39f 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));
30a92ba1c39f 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)) {
30a92ba1c39f 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);
30a92ba1c39f 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);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
63 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
64 gnt_menu_add_item(menu, item);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
65
30a92ba1c39f 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);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
67
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68 if (list) {
30a92ba1c39f 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);
30a92ba1c39f 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));
30a92ba1c39f 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))
30a92ba1c39f 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);
30a92ba1c39f 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);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
74 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
75
30a92ba1c39f 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",
30a92ba1c39f 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);
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
78 }
30a92ba1c39f I should probably add these files, too...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
79