pidgin/pidginaccountsenabledmenu.c

Fri, 20 May 2022 01:34:32 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 20 May 2022 01:34:32 -0500
changeset 41392
b5c84f55d5d2
parent 41304
25830cad9bfc
child 41403
0186ae21071f
permissions
-rw-r--r--

Remove the ui parameter from purple_account_[gs]et_enabled

Testing Done:
Enabled and disabled the demo account a bunch of times, including restarts, and the like.

Reviewed at https://reviews.imfreedom.org/r/1458/

41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n.h>
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidginaccountsenabledmenu.h"
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgincore.h"
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 /******************************************************************************
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 * Helpers
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 static GMenu *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 pidgin_accounts_enabled_menu_build_submenu(PurpleAccount *account) {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GMenu *menu = NULL, *section = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 gchar *action_id = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 const gchar *account_id = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 menu = g_menu_new();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 account_id = purple_account_get_id(account);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 /* Add the "Edit Account" section. */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 section = g_menu_new();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 action_id = g_strdup_printf("app.edit-account::%s", account_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 g_menu_append(section, _("Edit Account"), action_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 g_free(action_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 /* Add the "Disable Account" section. */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 section = g_menu_new();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 action_id = g_strdup_printf("app.disable-account::%s", account_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 g_menu_append(section, _("Disable"), action_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 g_free(action_id);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 return menu;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 pidgin_accounts_enabled_menu_refresh_helper(PurpleAccount *account,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 GMenu *menu = data;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
41392
b5c84f55d5d2 Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents: 41304
diff changeset
66 if(purple_account_get_enabled(account)) {
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 GMenu *submenu = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 gchar *label = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 const gchar *account_name = purple_account_get_username(account);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 const gchar *protocol_name = purple_account_get_protocol_name(account);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 submenu = pidgin_accounts_enabled_menu_build_submenu(account);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 /* translators: This format string is intended to contain the account
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 * name followed by the protocol name to uniquely identify a specific
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 * account.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 label = g_strdup_printf(_("%s (%s)"), account_name, protocol_name);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 g_menu_append_submenu(menu, label, G_MENU_MODEL(submenu));
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_free(label);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 pidgin_accounts_enabled_menu_refresh(GMenu *menu) {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 PurpleAccountManager *manager = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 g_menu_remove_all(menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 manager = purple_account_manager_get_default();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 purple_account_manager_foreach(manager,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 pidgin_accounts_enabled_menu_refresh_helper,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 /******************************************************************************
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 * Callbacks
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 pidgin_accounts_enabled_menu_enabled_cb(G_GNUC_UNUSED PurpleAccount *account,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 pidgin_accounts_enabled_menu_refresh(data);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 pidgin_accounts_enabled_menu_disabled_cb(G_GNUC_UNUSED PurpleAccount *account,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 pidgin_accounts_enabled_menu_refresh(data);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 pidgin_accounts_enabled_menu_weak_notify_cb(G_GNUC_UNUSED gpointer data,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 GObject *obj)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 purple_signals_disconnect_by_handle(obj);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 /******************************************************************************
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 * Public API
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 GMenu *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 pidgin_accounts_enabled_menu_new(void) {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 GMenu *menu = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 gpointer handle = NULL;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 /* Create the menu and set our instance as data on it so it'll be freed
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 * when the menu is destroyed.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 menu = g_menu_new();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 g_object_weak_ref(G_OBJECT(menu),
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 pidgin_accounts_enabled_menu_weak_notify_cb, NULL);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 /* Populate ourselves with any accounts that are already enabled. */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 pidgin_accounts_enabled_menu_refresh(menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 /* Wire up the purple signals we care about. */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 handle = purple_accounts_get_handle();
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 purple_signal_connect(handle, "account-enabled", menu,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 G_CALLBACK(pidgin_accounts_enabled_menu_enabled_cb),
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 purple_signal_connect(handle, "account-disabled", menu,
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 G_CALLBACK(pidgin_accounts_enabled_menu_disabled_cb),
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 return menu;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 }

mercurial