pidgin/pidginaccountsenabledmenu.c

Sat, 13 Apr 2024 23:52:51 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 13 Apr 2024 23:52:51 -0500
changeset 42723
3761ba966eed
parent 42575
580339aa47cc
child 42804
be8c8b5471ca
permissions
-rw-r--r--

Stop using PurpleBuddy in Pidgin

PurpleBuddy was replaced by PurpleContactInfo a long time ago, and this stuff
just hadn't been updated yet.

Testing Done:
Let the turtles do their thing and verified that the avatars still show up for the demo protocol plugin.

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

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
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
29 #include "pidginapplication.h"
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
30
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
31 struct _PidginAccountsEnabledMenu {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
32 GMenuModel parent;
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
33
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
34 GQueue *accounts;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
35 };
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
42575
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42262
diff changeset
37 G_DEFINE_FINAL_TYPE(PidginAccountsEnabledMenu, pidgin_accounts_enabled_menu,
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42262
diff changeset
38 G_TYPE_MENU_MODEL)
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 /******************************************************************************
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
41 * Helpers
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
42 *****************************************************************************/
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
43 static void
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
44 pidgin_accounts_enabled_menu_update(PidginAccountsEnabledMenu *menu,
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
45 PurpleAccount *account)
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
46 {
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
47 PurpleProtocol *protocol = NULL;
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
48 gint index = -1;
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
49
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
50 index = g_queue_index(menu->accounts, account);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
51 if(index >= 0) {
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
52 /* Tell the model that the account needs to be updated. */
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
53 g_menu_model_items_changed(G_MENU_MODEL(menu), index, 0, 0);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
54 }
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
55
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
56 /* If the protocol has actions add them to the application windows. */
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
57 protocol = purple_account_get_protocol(account);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
58 if(PURPLE_IS_PROTOCOL_ACTIONS(protocol)) {
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
59 PurpleProtocolActions *actions = PURPLE_PROTOCOL_ACTIONS(protocol);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
60 PurpleConnection *connection = NULL;
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
61 GActionGroup *action_group = NULL;
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
62
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
63 connection = purple_account_get_connection(account);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
64 action_group = purple_protocol_actions_get_action_group(actions,
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
65 connection);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
66 if(G_IS_ACTION_GROUP(action_group)) {
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
67 GApplication *application = g_application_get_default();
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
68 const gchar *prefix = purple_protocol_actions_get_prefix(actions);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
69
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
70 pidgin_application_add_action_group(PIDGIN_APPLICATION(application),
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
71 prefix, action_group);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
72 g_object_unref(action_group);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
73 }
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
74 }
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
75 }
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
76
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
77 /******************************************************************************
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 * Callbacks
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 static void
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
81 pidgin_accounts_enabled_menu_changed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
82 PurpleAccount *account,
41946
0fb3b0e7122f Add a setting-changed signal to PurpleAccount and propagate it from PurpleAccountManager
Gary Kramlich <grim@reaperworld.com>
parents: 41891
diff changeset
83 G_GNUC_UNUSED GParamSpec *pspec,
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
84 gpointer data)
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
85 {
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
86 PidginAccountsEnabledMenu *menu = data;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
87
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
88 if(purple_account_get_enabled(account)) {
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
89 /* Add the account to the start of the list. */
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
90 g_queue_push_head(menu->accounts, g_object_ref(account));
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
91
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
92 /* Tell everyone our model added a new item at position 0. */
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
93 g_menu_model_items_changed(G_MENU_MODEL(menu), 0, 0, 1);
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
94 } else {
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
95 gint index = g_queue_index(menu->accounts, account);
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
96
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
97 if(index >= 0) {
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
98 g_queue_pop_nth(menu->accounts, index);
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
99
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
100 /* Tell the model that we removed one item at the given index. */
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
101 g_menu_model_items_changed(G_MENU_MODEL(menu), index, 1, 0);
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
102
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
103 /* Remove the reference to the account that we were holding. */
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
104 g_object_unref(account);
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
105 }
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
106 }
41304
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
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 static void
42262
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
110 pidgin_accounts_enabled_menu_account_connected_cb(G_GNUC_UNUSED PurpleAccountManager *m,
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
111 PurpleAccount *account,
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
112 gpointer data)
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 {
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
114 pidgin_accounts_enabled_menu_update(data, account);
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 static void
42262
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
118 pidgin_accounts_enabled_menu_account_disconnected_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
119 PurpleAccount *account,
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
120 gpointer data)
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
121 {
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
122 PidginAccountsEnabledMenu *menu = data;
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
123 PurpleProtocol *protocol = NULL;
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
124 gint index = -1;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
125
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
126 index = g_queue_index(menu->accounts, account);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
127 if(index >= 0) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
128 /* Tell the model that the account needs to be updated. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
129 g_menu_model_items_changed(G_MENU_MODEL(menu), index, 0, 0);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
130 }
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
131
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
132 /* Figure out if this is the last connected account for this protocol, and
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
133 * if so, remove the action group from the application windows.
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
134 */
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
135 protocol = purple_account_get_protocol(account);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
136 if(PURPLE_IS_PROTOCOL_ACTIONS(protocol)) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
137 PurpleAccountManager *manager = NULL;
41460
fccbea158b51 Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents: 41458
diff changeset
138 PurpleProtocolActions *actions = PURPLE_PROTOCOL_ACTIONS(protocol);
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
139 GList *enabled_accounts = NULL;
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
140 gboolean found = FALSE;
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
141
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
142 manager = purple_account_manager_get_default();
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
143 enabled_accounts = purple_account_manager_get_enabled(manager);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
144
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
145 while(enabled_accounts != NULL) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
146 PurpleAccount *account2 = PURPLE_ACCOUNT(enabled_accounts->data);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
147 PurpleProtocol *protocol2 = purple_account_get_protocol(account2);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
148
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
149 if(!found && protocol2 == protocol) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
150 found = TRUE;
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
151 }
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
152
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
153 enabled_accounts = g_list_delete_link(enabled_accounts,
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
154 enabled_accounts);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
155 }
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
156
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
157 if(!found) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
158 GApplication *application = g_application_get_default();
41460
fccbea158b51 Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents: 41458
diff changeset
159 const gchar *prefix = purple_protocol_actions_get_prefix(actions);
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
160
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
161 pidgin_application_add_action_group(PIDGIN_APPLICATION(application),
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
162 prefix, NULL);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
163 }
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
164 }
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
165 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
166
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
167 static void
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
168 pidgin_accounts_enabled_menu_actions_changed_cb(G_GNUC_UNUSED PurpleProtocolManager *manager,
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
169 G_GNUC_UNUSED PurpleProtocol *protocol,
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
170 PurpleAccount *account,
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
171 gpointer data)
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
172 {
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
173 pidgin_accounts_enabled_menu_update(data, account);
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
174 }
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
175
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
176 /******************************************************************************
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
177 * GMenuModel Implementation
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
178 *****************************************************************************/
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
179 static gboolean
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41946
diff changeset
180 pidgin_accounts_enabled_menu_is_mutable(G_GNUC_UNUSED GMenuModel *model) {
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
181 return TRUE;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
182 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
183
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
184 static gint
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
185 pidgin_accounts_enabled_menu_get_n_items(GMenuModel *model) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
186 PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(model);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
187
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
188 return g_queue_get_length(menu->accounts);
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
189 }
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
190
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
191 static void
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
192 pidgin_accounts_enabled_menu_get_item_attributes(GMenuModel *model, gint index,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
193 GHashTable **attributes)
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
194 {
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
195 PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(model);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
196 PurpleAccount *account = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
197 PurpleProtocol *protocol = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
198 GVariant *value = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
199 gchar *label = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
200 const gchar *account_name = NULL, *protocol_name = NULL, *icon_name = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
201
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
202 /* Create our hash table of attributes to return. This must always be
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
203 * populated.
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
204 */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
205 *attributes = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
206 (GDestroyNotify)g_variant_unref);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
207
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
208 /* Get the account the caller is interested in. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
209 account = g_queue_peek_nth(menu->accounts, index);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
210 if(!PURPLE_IS_ACCOUNT(account)) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
211 return;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
212 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
213
41962
f802660eaef2 Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
214 account_name = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account));
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
215
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
216 /* Get the protocol from the account. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
217 protocol = purple_account_get_protocol(account);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
218 if(PURPLE_IS_PROTOCOL(protocol)) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
219 protocol_name = purple_protocol_get_name(protocol);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
220 icon_name = purple_protocol_get_icon_name(protocol);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
221 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
222
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
223 /* Add the label. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
224
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
225 /* translators: This format string is intended to contain the account
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
226 * name followed by the protocol name to uniquely identify a specific
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
227 * account.
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
228 */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
229 label = g_strdup_printf(_("%s (%s)"), account_name, protocol_name);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
230 value = g_variant_new_string(label);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
231 g_free(label);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
232 g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_LABEL,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
233 g_variant_ref_sink(value));
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
234
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
235 /* Add the icon if we have one. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
236 if(icon_name != NULL) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
237 value = g_variant_new_string(icon_name);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
238 g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ICON,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
239 g_variant_ref_sink(value));
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
240 }
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
241 }
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
242
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
243 static void
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
244 pidgin_accounts_enabled_menu_get_item_links(GMenuModel *model, gint index,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
245 GHashTable **links)
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 {
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
247 PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(model);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
248 PurpleAccount *account = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
249 PurpleConnection *connection = NULL;
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
250 PurpleProtocol *protocol = NULL;
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
251 GApplication *application = g_application_get_default();
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
252 GMenu *submenu = NULL, *template = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
253 const gchar *account_id = NULL, *connection_id = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
254
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
255 /* Create our hash table for links, this must always be populated. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
256 *links = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
257 g_object_unref);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
258
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
259 account = g_queue_peek_nth(menu->accounts, index);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
260 if(!PURPLE_IS_ACCOUNT(account)) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
261 return;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
262 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
263
41962
f802660eaef2 Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
264 account_id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(account));
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
265
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
266 connection = purple_account_get_connection(account);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
267 if(PURPLE_IS_CONNECTION(connection)) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
268 connection_id = purple_connection_get_id(connection);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
269 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
270
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
271 /* Create a copy of our template menu. */
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
272 template = gtk_application_get_menu_by_id(GTK_APPLICATION(application),
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
273 "enabled-account");
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
274 submenu = purple_menu_copy(G_MENU_MODEL(template));
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
275
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
276 /* Add the account actions if we have any. */
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
277 protocol = purple_account_get_protocol(account);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
278 if(PURPLE_IS_PROTOCOL_ACTIONS(protocol)) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
279 PurpleProtocolActions *actions = PURPLE_PROTOCOL_ACTIONS(protocol);
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
280 GMenu *protocol_menu = NULL;
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
281
42004
620d1adf91f2 Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents: 41962
diff changeset
282 protocol_menu = purple_protocol_actions_get_menu(actions, connection);
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
283 if(G_IS_MENU(protocol_menu)) {
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
284 g_menu_insert_section(submenu, 1, NULL,
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
285 G_MENU_MODEL(protocol_menu));
42103
33ed4a2a7593 Fix leaks in dynamic menus
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42009
diff changeset
286 g_object_unref(protocol_menu);
41458
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
287 }
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
288 }
90276efac79d Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41457
diff changeset
289
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
290 purple_menu_populate_dynamic_targets(submenu,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
291 "account", account_id,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
292 "connection", connection_id,
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
293 NULL);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
294
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
295 g_hash_table_insert(*links, G_MENU_LINK_SUBMENU, submenu);
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 }
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 /******************************************************************************
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
299 * GObject Implementation
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 *****************************************************************************/
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
301 static void
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
302 pidgin_accounts_enabled_menu_dispose(GObject *obj) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
303 PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(obj);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
304
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
305 if(menu->accounts != NULL) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
306 g_queue_free_full(menu->accounts, g_object_unref);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
307 menu->accounts = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
308 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
309
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
310 G_OBJECT_CLASS(pidgin_accounts_enabled_menu_parent_class)->dispose(obj);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
311
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
312 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
313
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
314 static void
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
315 pidgin_accounts_enabled_menu_constructed(GObject *obj) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
316 PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(obj);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
317 PurpleAccountManager *manager = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
318 GList *enabled = NULL, *l = NULL;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
319 gint count = 0;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
320
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
321 G_OBJECT_CLASS(pidgin_accounts_enabled_menu_parent_class)->constructed(obj);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
322
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
323 manager = purple_account_manager_get_default();
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
324 enabled = purple_account_manager_get_enabled(manager);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
325
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
326 for(l = enabled; l != NULL; l = l->next) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
327 g_queue_push_head(menu->accounts, g_object_ref(l->data));
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
328 count++;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
329 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
330 g_list_free(enabled);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
331
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
332 g_menu_model_items_changed(G_MENU_MODEL(obj), 0, 0, count);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
333 }
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
334
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
335 static void
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
336 pidgin_accounts_enabled_menu_init(PidginAccountsEnabledMenu *menu) {
42262
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
337 PurpleAccountManager *account_manager = NULL;
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
338 PurpleProtocolManager *protocol_manager = NULL;
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
340 menu->accounts = g_queue_new();
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341
42262
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
342 account_manager = purple_account_manager_get_default();
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
343 g_signal_connect_object(account_manager, "account-changed::enabled",
41891
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
344 G_CALLBACK(pidgin_accounts_enabled_menu_changed_cb),
a45d6db4f857 Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents: 41460
diff changeset
345 menu, 0);
42262
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
346 g_signal_connect_object(account_manager, "account-connected",
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
347 G_CALLBACK(pidgin_accounts_enabled_menu_account_connected_cb),
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
348 menu, 0);
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
349 g_signal_connect_object(account_manager, "account-disconnected",
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
350 G_CALLBACK(pidgin_accounts_enabled_menu_account_disconnected_cb),
5f218efc3c7b Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents: 42103
diff changeset
351 menu, 0);
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
352
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
353 /* We also need to know when the protocol actions have changed. */
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
354 protocol_manager = purple_protocol_manager_get_default();
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
355 g_signal_connect_object(protocol_manager, "account-actions-changed",
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
356 G_CALLBACK(pidgin_accounts_enabled_menu_actions_changed_cb),
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 42004
diff changeset
357 menu, 0);
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
358 }
41403
0186ae21071f Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents: 41392
diff changeset
359
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
360 static void
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
361 pidgin_accounts_enabled_menu_class_init(PidginAccountsEnabledMenuClass *klass) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
362 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
363 GMenuModelClass *model_class = G_MENU_MODEL_CLASS(klass);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
364
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
365 obj_class->constructed = pidgin_accounts_enabled_menu_constructed;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
366 obj_class->dispose = pidgin_accounts_enabled_menu_dispose;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
367
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
368 model_class->is_mutable = pidgin_accounts_enabled_menu_is_mutable;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
369 model_class->get_n_items = pidgin_accounts_enabled_menu_get_n_items;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
370 model_class->get_item_attributes = pidgin_accounts_enabled_menu_get_item_attributes;
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
371 model_class->get_item_links = pidgin_accounts_enabled_menu_get_item_links;
41304
25830cad9bfc Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
41457
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
373
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
374 /******************************************************************************
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
375 * Public API
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
376 *****************************************************************************/
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
377 GMenuModel *
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
378 pidgin_accounts_enabled_menu_new(void) {
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
379 return g_object_new(PIDGIN_TYPE_ACCOUNTS_ENABLED_MENU, NULL);
f0e7534a555d Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents: 41403
diff changeset
380 }

mercurial