pidgin/pidginaccountsenabledmenu.c

Fri, 27 May 2022 03:05:57 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 27 May 2022 03:05:57 -0500
changeset 41411
c2969c67490e
parent 41403
0186ae21071f
child 41457
f0e7534a555d
permissions
-rw-r--r--

Remove a bunch of unused stuff in the gtkblist and set some sane defaults

Testing Done:
Ran and verified that the buddylist displayed all options by default now.

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

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
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
25 #include <gtk/gtk.h>
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
26
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #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
28
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #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
30
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 * Helpers
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 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
36 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 {
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
38 GApplication *application = g_application_get_default();
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 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
40
41392
b5c84f55d5d2 Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents: 41304
diff changeset
41 if(purple_account_get_enabled(account)) {
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
42 PurpleConnection *connection = purple_account_get_connection(account);
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 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
44 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
45 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
46 const gchar *protocol_name = purple_account_get_protocol_name(account);
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
47 const gchar *account_id = purple_account_get_id(account);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
48 const gchar *connection_id = NULL;
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
50 submenu = gtk_application_get_menu_by_id(GTK_APPLICATION(application),
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
51 "enabled-account");
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
52
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
53 if(PURPLE_IS_CONNECTION(connection)) {
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
54 connection_id = purple_connection_get_id(connection);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
55 }
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
56
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
57 purple_menu_populate_dynamic_targets(submenu,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
58 "account", account_id,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
59 "connection", connection_id,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
60 NULL);
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 /* 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
63 * 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
64 * account.
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 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
67
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 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
69
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 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
71 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
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 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 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
76 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
77
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 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
79
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 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
81 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
82 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
83 menu);
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 /******************************************************************************
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 * Callbacks
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 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
91 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 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
94 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 static void
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 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
98 gpointer data)
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 {
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 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
101 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 static void
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
104 pidgin_accounts_enabled_menu_connected_cb(G_GNUC_UNUSED PurpleAccount *account,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
105 gpointer data)
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
106 {
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
107 pidgin_accounts_enabled_menu_refresh(data);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
108 }
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
109
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
110 static void
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
111 pidgin_accounts_enabled_menu_disconnected_cb(G_GNUC_UNUSED PurpleAccount *account,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
112 gpointer data)
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
113 {
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
114 pidgin_accounts_enabled_menu_refresh(data);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
115 }
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
116
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
117 static void
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 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
119 GObject *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 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
122 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123
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 * Public API
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 *****************************************************************************/
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 GMenu *
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 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
129 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
130 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
131
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 /* 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
133 * 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
134 */
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 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
136 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
137 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
138
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 /* 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
140 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
141
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 /* 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
143 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
144 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
145 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
146 menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 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
148 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
149 menu);
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
151 /* For the account actions, we also need to know when an account is online
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
152 * or offline.
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
153 */
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
154 purple_signal_connect(handle, "account-signed-on", menu,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
155 G_CALLBACK(pidgin_accounts_enabled_menu_connected_cb),
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
156 menu);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
157 purple_signal_connect(handle, "account-signed-off", menu,
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
158 G_CALLBACK(pidgin_accounts_enabled_menu_disconnected_cb),
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
159 menu);
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
160
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 return menu;
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 }

mercurial