Sat, 09 Aug 2025 18:12:31 +0800
Add builtin library dependency for introspection
Without specifying, gir defaults to the system pidgin/purple libraries by default,
which fails the build when new symbols were added and gir failed to link for them.
|
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 | |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
27 | #include <birb.h> |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
28 | |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #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
|
30 | |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
31 | #include "pidginapplication.h" |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
32 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
33 | struct _PidginAccountsEnabledMenu { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
34 | GMenuModel parent; |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
35 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
36 | GListModel *accounts; |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
37 | }; |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | /****************************************************************************** |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
40 | * Helpers |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
41 | *****************************************************************************/ |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
42 | static void |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
43 | pidgin_accounts_enabled_menu_foreach_add_action_groups(const char *prefix, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
44 | GActionGroup *group, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
45 | gpointer data) |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
46 | { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
47 | PidginApplication *application = data; |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
48 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
49 | pidgin_application_add_action_group(application, prefix, group); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
50 | } |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
51 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
52 | static void |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
53 | pidgin_accounts_enabled_menu_foreach_remove_action_groups(const char *prefix, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
54 | G_GNUC_UNUSED GActionGroup *group, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
55 | gpointer data) |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
56 | { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
57 | PidginApplication *application = data; |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
58 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
59 | pidgin_application_add_action_group(application, prefix, NULL); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
60 | } |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
61 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
62 | static void |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
63 | 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
|
64 | 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
|
65 | { |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
66 | PurpleProtocol *protocol = NULL; |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
67 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
68 | for(guint index = 0; index < g_list_model_get_n_items(menu->accounts); index++) { |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
69 | PurpleAccount *account2 = g_list_model_get_item(menu->accounts, index); |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
70 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
71 | if(account == account2) { |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
72 | /* Tell the model that the account needs to be updated. */ |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
73 | g_menu_model_items_changed(G_MENU_MODEL(menu), index, 1, 1); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
74 | g_clear_object(&account2); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
75 | break; |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
76 | } |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
77 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
78 | g_clear_object(&account2); |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
79 | } |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
80 | |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
81 | /* 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
|
82 | protocol = purple_account_get_protocol(account); |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
83 | if(PURPLE_IS_PROTOCOL(protocol)) { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
84 | BirbActionMenu *action_menu = 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
|
85 | |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
86 | action_menu = purple_protocol_get_action_menu(protocol, account); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
87 | if(BIRB_IS_ACTION_MENU(action_menu)) { |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
88 | 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
|
89 | |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
90 | birb_action_menu_foreach_action_group(action_menu, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
91 | pidgin_accounts_enabled_menu_foreach_add_action_groups, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
92 | application); |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
93 | } |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
94 | g_clear_object(&action_menu); |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
95 | } |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
96 | } |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
97 | |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
98 | /****************************************************************************** |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | * Callbacks |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | *****************************************************************************/ |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | static void |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
102 | pidgin_accounts_enabled_menu_items_changed_cb(G_GNUC_UNUSED GListModel *model, |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
103 | guint position, |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
104 | guint removed, |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
105 | guint added, |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
106 | gpointer data) |
|
41891
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
107 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
108 | PidginAccountsEnabledMenu *menu = data; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
109 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
110 | g_menu_model_items_changed(G_MENU_MODEL(menu), position, removed, added); |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | } |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | static void |
|
42262
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
114 | 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
|
115 | PurpleAccount *account, |
|
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
116 | 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
|
117 | { |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
118 | 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
|
119 | } |
|
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 | static void |
|
42262
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
122 | 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
|
123 | PurpleAccount *account, |
|
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
124 | gpointer data) |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
125 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
126 | PidginAccountsEnabledMenu *menu = data; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
127 | PurpleProtocol *protocol = NULL; |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
128 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
129 | for(guint index = 0; index < g_list_model_get_n_items(menu->accounts); index++) { |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
130 | PurpleAccount *account2 = g_list_model_get_item(menu->accounts, index); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
131 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
132 | if(account == account2) { |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
133 | /* Tell the model that the account needs to be updated. */ |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
134 | g_menu_model_items_changed(G_MENU_MODEL(menu), index, 1, 1); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
135 | g_clear_object(&account2); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
136 | break; |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
137 | } |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
138 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
139 | g_clear_object(&account2); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
140 | } |
|
41458
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 | /* 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
|
143 | * 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
|
144 | */ |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
145 | protocol = purple_account_get_protocol(account); |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
146 | if(PURPLE_IS_PROTOCOL(protocol)) { |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
147 | gboolean found = FALSE; |
|
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 | 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
|
150 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
151 | for(guint i = 0; i < g_list_model_get_n_items(menu->accounts); i++) { |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
152 | PurpleAccount *account2 = g_list_model_get_item(menu->accounts, i); |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
153 | 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
|
154 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
155 | if(!found && protocol2 == protocol) { |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
156 | found = TRUE; |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
157 | g_clear_object(&account2); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
158 | break; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
159 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
160 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
161 | g_clear_object(&account2); |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
162 | } |
|
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 | if(!found) { |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
165 | GApplication *application = g_application_get_default(); |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
166 | BirbActionMenu *action_menu = NULL; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
167 | |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
168 | action_menu = purple_protocol_get_action_menu(protocol, account); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
169 | birb_action_menu_foreach_action_group(action_menu, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
170 | pidgin_accounts_enabled_menu_foreach_remove_action_groups, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
171 | application); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
172 | g_clear_object(&action_menu); |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
173 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
174 | } |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
175 | } |
|
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 | /****************************************************************************** |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
178 | * GMenuModel Implementation |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
179 | *****************************************************************************/ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
180 | 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
|
181 | 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
|
182 | return TRUE; |
|
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 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
185 | static gint |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
186 | 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
|
187 | 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
|
188 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
189 | return g_list_model_get_n_items(menu->accounts); |
|
41403
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 | |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
192 | static void |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
193 | 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
|
194 | GHashTable **attributes) |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
195 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
196 | 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
|
197 | PurpleAccount *account = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
198 | PurpleProtocol *protocol = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
199 | GVariant *value = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
200 | gchar *label = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
201 | 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
|
202 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
203 | /* 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
|
204 | * populated. |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
205 | */ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
206 | *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
|
207 | (GDestroyNotify)g_variant_unref); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
208 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
209 | /* Get the account the caller is interested in. */ |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
210 | account = g_list_model_get_item(menu->accounts, index); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
211 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
212 | return; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
213 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
214 | |
|
42804
be8c8b5471ca
Update pidgin to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
215 | account_name = purple_account_get_username(account); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
216 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
217 | /* 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
|
218 | 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
|
219 | if(PURPLE_IS_PROTOCOL(protocol)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
220 | 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
|
221 | 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
|
222 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
223 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
224 | /* Add the label. */ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
225 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
226 | /* 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
|
227 | * 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
|
228 | * account. |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
229 | */ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
230 | 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
|
231 | 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
|
232 | g_free(label); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
233 | 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
|
234 | g_variant_ref_sink(value)); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
235 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
236 | /* 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
|
237 | if(icon_name != NULL) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
238 | 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
|
239 | 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
|
240 | g_variant_ref_sink(value)); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
241 | } |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
242 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
243 | g_clear_object(&account); |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
244 | } |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
245 | |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
246 | static void |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
247 | 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
|
248 | 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
|
249 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
250 | 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
|
251 | PurpleAccount *account = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
252 | PurpleConnection *connection = NULL; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
253 | PurpleProtocol *protocol = NULL; |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
254 | 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
|
255 | GMenu *submenu = NULL, *template = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
256 | 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
|
257 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
258 | /* 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
|
259 | *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
|
260 | g_object_unref); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
261 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
262 | account = g_list_model_get_item(menu->accounts, index); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
263 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
264 | return; |
|
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 | |
|
42804
be8c8b5471ca
Update pidgin to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
267 | account_id = purple_account_get_id(account); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
268 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
269 | 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
|
270 | if(PURPLE_IS_CONNECTION(connection)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
271 | 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
|
272 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
273 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
274 | /* 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
|
275 | 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
|
276 | "enabled-account"); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
277 | 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
|
278 | |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
279 | /* 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
|
280 | protocol = purple_account_get_protocol(account); |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
281 | if(PURPLE_IS_PROTOCOL(protocol)) { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
282 | BirbActionMenu *action_menu = NULL; |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
283 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
284 | action_menu = purple_protocol_get_action_menu(protocol, account); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
285 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
286 | if(BIRB_IS_ACTION_MENU(action_menu)) { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
287 | GMenu *protocol_menu = NULL; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
288 | |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
289 | protocol_menu = birb_action_menu_get_menu(action_menu); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
290 | if(G_IS_MENU(protocol_menu)) { |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
291 | g_menu_insert_section(submenu, 1, NULL, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
292 | G_MENU_MODEL(protocol_menu)); |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
293 | } |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
294 | |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
295 | g_clear_object(&action_menu); |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
296 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
297 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
298 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
299 | 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
|
300 | "account", account_id, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
301 | "connection", connection_id, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
302 | NULL); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
303 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
304 | g_hash_table_insert(*links, G_MENU_LINK_SUBMENU, submenu); |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
305 | |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
306 | g_clear_object(&account); |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | } |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | /****************************************************************************** |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
310 | * 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
|
311 | *****************************************************************************/ |
|
42880
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
312 | G_DEFINE_FINAL_TYPE(PidginAccountsEnabledMenu, pidgin_accounts_enabled_menu, |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
313 | G_TYPE_MENU_MODEL) |
|
6df94d23bdea
Update Pidgin.AccountsEnabledMenu to use Purple.Protocol.get_action_menu
Gary Kramlich <grim@reaperworld.com>
parents:
42804
diff
changeset
|
314 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
315 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
316 | 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
|
317 | PidginAccountsEnabledMenu *menu = PIDGIN_ACCOUNTS_ENABLED_MENU(obj); |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
318 | guint count = 0; |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
319 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
320 | 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
|
321 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
322 | count = g_list_model_get_n_items(menu->accounts); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
323 | 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
|
324 | } |
|
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 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
327 | 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
|
328 | PurpleAccountManager *account_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
|
329 | |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
330 | account_manager = purple_account_manager_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
|
331 | |
|
43222
e0cc9323ffed
Remove GList versions of purple_account_manager_get_{disabled,enabled}
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43221
diff
changeset
|
332 | menu->accounts = purple_account_manager_get_enabled(account_manager); |
|
43221
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
333 | g_signal_connect_object(menu->accounts, "items-changed", |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
334 | G_CALLBACK(pidgin_accounts_enabled_menu_items_changed_cb), |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
335 | menu, G_CONNECT_DEFAULT); |
|
44fffd2f5564
Convert PidginAccountsEnabledMenu to the list model
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42882
diff
changeset
|
336 | |
|
42262
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
337 | 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
|
338 | 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
|
339 | menu, 0); |
|
5f218efc3c7b
Port PidginAccountsEnabledMenu to the AccountManager propagated signals
Gary Kramlich <grim@reaperworld.com>
parents:
42103
diff
changeset
|
340 | 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
|
341 | 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
|
342 | menu, 0); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
343 | } |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
344 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
345 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
346 | 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
|
347 | 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
|
348 | 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
|
349 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
350 | 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
|
351 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
352 | 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
|
353 | 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
|
354 | 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
|
355 | 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
|
356 | } |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
357 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
358 | /****************************************************************************** |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
359 | * Public API |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
360 | *****************************************************************************/ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
361 | GMenuModel * |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
362 | 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
|
363 | 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
|
364 | } |