Thu, 23 Mar 2023 23:11:59 -0500
Fix several leaks in tests
All of these are specific to tests, not the library code.
For the moment, `protocol_xfer` still leaks connections (and anything they hold on to) because it is very difficult to disentangle them from the connection manager in the partially implemented state they are in.
This fixes leaks of options in the account option test (these two leaks occur for every test since they all leak the option):
```
61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 133 of 276
at 0x4848464: calloc (vg_replace_malloc.c:1340)
by 0x49F75F0: g_malloc0 (gmem.c:163)
by 0x48C3B2E: purple_account_option_new (purpleaccountoption.c:78)
by 0x4014AF: test_purple_account_option_copy_int (test_account_option.c:67)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401721: main (test_account_option.c:157)
61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 134 of 276
at 0x4848464: calloc (vg_replace_malloc.c:1340)
by 0x49F75F0: g_malloc0 (gmem.c:163)
by 0x48C3BC7: purple_account_option_copy (purpleaccountoption.c:93)
by 0x4014BF: test_purple_account_option_copy_int (test_account_option.c:68)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401721: main (test_account_option.c:157)
```
leaks in the credential manager test (times 3 for read/write/cancel tests):
```
69 (16 direct, 53 indirect) bytes in 1 blocks are definitely lost in loss record 2,427 of 3,503
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4A58168: g_malloc (gmem.c:130)
by 0x4A6FAB5: g_slice_alloc (gslice.c:1074)
by 0x4A700EC: g_slice_alloc0 (gslice.c:1100)
by 0x4A3BECB: g_error_allocate (gerror.c:710)
by 0x4A3C93F: UnknownInlinedFun (gerror.c:724)
by 0x4A3C93F: g_error_new_valist (gerror.c:766)
by 0x4BEE558: g_task_return_new_error (gtask.c:1941)
by 0x48D82C0: purple_credential_manager_read_password_async (purplecredentialmanager.c:492)
by 0x403634: test_purple_credential_manager_no_provider_read_password_idle (test_credential_manager.c:329)
by 0x4A4ECB1: g_idle_dispatch (gmain.c:6124)
by 0x4A4FCBE: UnknownInlinedFun (gmain.c:3444)
by 0x4A4FCBE: g_main_context_dispatch (gmain.c:4162)
by 0x4AA5597: g_main_context_iterate.constprop.0 (gmain.c:4238)
by 0x4A4F28E: g_main_loop_run (gmain.c:4438)
by 0x40369F: test_purple_credential_manager_no_provider_read_password_async (test_credential_manager.c:345)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x4048F6: main (test_credential_manager.c:695)
```
a leak in the image test:
```
161 bytes in 1 blocks are definitely lost in loss record 260 of 274
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4A55363: g_try_malloc (gmem.c:286)
by 0x4A3D630: UnknownInlinedFun (gfileutils.c:819)
by 0x4A3D630: UnknownInlinedFun (gfileutils.c:924)
by 0x4A3D630: g_file_get_contents (gfileutils.c:1027)
by 0x401890: test_image_new_from_file (test_image.c:144)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x40195D: main (test_image.c:172)
```
a leak in queued output stream test:
```
72 (40 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 219 of 396
at 0x49D51EF: g_type_create_instance (gtype.c:1909)
by 0x49BAC1F: g_object_new_internal (gobject.c:2228)
by 0x49BC247: g_object_new_with_properties (gobject.c:2391)
by 0x49BCFF0: g_object_new (gobject.c:2037)
by 0x402003: test_queued_output_stream_push_bytes_async_error (test_queued_output_stream.c:219)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x402429: main (test_queued_output_stream.c:280)
```
and protocol xfer tests (times 3 for each test that creates a test protocol object):
```
112 (48 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 3,430 of 3,698
at 0x49D51EF: g_type_create_instance (gtype.c:1909)
by 0x49BAC1F: g_object_new_internal (gobject.c:2228)
by 0x49BC247: g_object_new_with_properties (gobject.c:2391)
by 0x49BCFF0: g_object_new (gobject.c:2037)
by 0x40291C: test_purple_protocol_xfer_send_file_func (test_protocol_xfer.c:146)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x402B64: main (test_protocol_xfer.c:195)
```
and util tests (times 3 for each call to `purple_text_strip_mnemonic` in the test):
```
5 bytes in 1 blocks are definitely lost in loss record 5 of 247
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x49F7168: g_malloc (gmem.c:130)
by 0x491975B: purple_text_strip_mnemonic (util.c:895)
by 0x4015B0: test_util_text_strip_mnemonic (test_util.c:49)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401901: main (test_util.c:224)
```
and these leaks in any test that initializes the test UI:
```
4,104 bytes in 1 blocks are possibly lost in loss record 3,451 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5249A8B: UnknownInlinedFun (sqlite3.c:53675)
by 0x5249A8B: allocateTempSpace (sqlite3.c:70848)
by 0x52625A6: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:93857)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x529B324: sqlite3_exec (sqlite3.c:131002)
by 0x48FD558: purple_sqlite3_run_migration (purplesqlite3.c:37)
by 0x48FDBB4: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:195)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
4,368 bytes in 1 blocks are possibly lost in loss record 3,453 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5240077: UnknownInlinedFun (sqlite3.c:53634)
by 0x5240077: pcache1FetchStage2 (sqlite3.c:54104)
by 0x5243E9C: UnknownInlinedFun (sqlite3.c:52671)
by 0x5243E9C: getPageNormal.lto_priv.0 (sqlite3.c:60628)
by 0x524A510: UnknownInlinedFun (sqlite3.c:60805)
by 0x524A510: btreeGetPage.lto_priv.0 (sqlite3.c:70289)
by 0x524C2F6: UnknownInlinedFun (sqlite3.c:71257)
by 0x524C2F6: sqlite3BtreeBeginTrans.lto_priv.0 (sqlite3.c:71647)
by 0x5266B3A: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:93532)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x48FD715: purple_sqlite3_get_schema_version (purplesqlite3.c:79)
by 0x48FD9DD: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:146)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
4,368 bytes in 1 blocks are possibly lost in loss record 3,454 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5240077: UnknownInlinedFun (sqlite3.c:53634)
by 0x5240077: pcache1FetchStage2 (sqlite3.c:54104)
by 0x5243E9C: UnknownInlinedFun (sqlite3.c:52671)
by 0x5243E9C: getPageNormal.lto_priv.0 (sqlite3.c:60628)
by 0x52499BC: UnknownInlinedFun (sqlite3.c:60805)
by 0x52499BC: UnknownInlinedFun (sqlite3.c:70289)
by 0x52499BC: btreeGetUnusedPage (sqlite3.c:70432)
by 0x524F504: allocateBtreePage.lto_priv.0 (sqlite3.c:74604)
by 0x5256209: btreeCreateTable.lto_priv.0 (sqlite3.c:77830)
by 0x5265EB2: UnknownInlinedFun (sqlite3.c:77849)
by 0x5265EB2: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:96382)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x529B324: sqlite3_exec (sqlite3.c:131002)
by 0x48FD558: purple_sqlite3_run_migration (purplesqlite3.c:37)
by 0x48FDBB4: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:195)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
```
Testing Done:
Ran tests in valgrind, and all above leaks were gone except for noted `protocol_xfer` issues, and a bunch of leaks of the `PurpleBuddy`-`PurpleContact` compatibility bindings, which will go away in their entirety eventually.
Reviewed at https://reviews.imfreedom.org/r/2385/
|
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 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
37 | G_DEFINE_TYPE(PidginAccountsEnabledMenu, pidgin_accounts_enabled_menu, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
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 |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
110 | pidgin_accounts_enabled_menu_connected_cb(PurpleAccount *account, 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
|
111 | { |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
112 | 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
|
113 | } |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | static void |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
116 | pidgin_accounts_enabled_menu_disconnected_cb(PurpleAccount *account, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
117 | gpointer data) |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
118 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
119 | PidginAccountsEnabledMenu *menu = data; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
120 | PurpleProtocol *protocol = NULL; |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
121 | gint index = -1; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
122 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
123 | 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
|
124 | if(index >= 0) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
125 | /* 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
|
126 | 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
|
127 | } |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
128 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
129 | /* 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
|
130 | * 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
|
131 | */ |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
132 | 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
|
133 | 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
|
134 | PurpleAccountManager *manager = NULL; |
|
41460
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41458
diff
changeset
|
135 | 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
|
136 | GList *enabled_accounts = NULL; |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
137 | gboolean found = FALSE; |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
138 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
139 | 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
|
140 | 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
|
141 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
142 | while(enabled_accounts != NULL) { |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
143 | 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
|
144 | 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
|
145 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
146 | if(!found && protocol2 == protocol) { |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
147 | found = TRUE; |
|
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 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
150 | 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
|
151 | enabled_accounts); |
|
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 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
154 | if(!found) { |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
155 | 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
|
156 | 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
|
157 | |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
158 | 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
|
159 | prefix, NULL); |
|
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 | } |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
162 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
163 | |
|
42009
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | { |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
170 | 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
|
171 | } |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
172 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
173 | /****************************************************************************** |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
174 | * GMenuModel Implementation |
|
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 | 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
|
177 | 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
|
178 | return TRUE; |
|
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 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
181 | static gint |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
182 | 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
|
183 | 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
|
184 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
185 | 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
|
186 | } |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
187 | |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
188 | static void |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
189 | 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
|
190 | GHashTable **attributes) |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
191 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
192 | 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
|
193 | PurpleAccount *account = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
194 | PurpleProtocol *protocol = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
195 | GVariant *value = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
196 | gchar *label = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
197 | 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
|
198 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
199 | /* 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
|
200 | * populated. |
|
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 | *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
|
203 | (GDestroyNotify)g_variant_unref); |
|
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 | /* 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
|
206 | 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
|
207 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
208 | return; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
209 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
210 | |
|
41962
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
211 | 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
|
212 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
213 | /* 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
|
214 | 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
|
215 | if(PURPLE_IS_PROTOCOL(protocol)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
216 | 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
|
217 | 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
|
218 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
219 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
220 | /* Add the label. */ |
|
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 | /* 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
|
223 | * 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
|
224 | * account. |
|
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 | 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
|
227 | 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
|
228 | g_free(label); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
229 | 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
|
230 | g_variant_ref_sink(value)); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
231 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
232 | /* 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
|
233 | if(icon_name != NULL) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
234 | 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
|
235 | 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
|
236 | g_variant_ref_sink(value)); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
237 | } |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
238 | } |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
239 | |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
240 | static void |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
241 | 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
|
242 | 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
|
243 | { |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
244 | 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
|
245 | PurpleAccount *account = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
246 | PurpleConnection *connection = NULL; |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
247 | PurpleProtocol *protocol = NULL; |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
248 | 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
|
249 | GMenu *submenu = NULL, *template = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
250 | 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
|
251 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
252 | /* 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
|
253 | *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
|
254 | g_object_unref); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
255 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
256 | 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
|
257 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
258 | return; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
259 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
260 | |
|
41962
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
261 | 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
|
262 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
263 | 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
|
264 | if(PURPLE_IS_CONNECTION(connection)) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
265 | 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
|
266 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
267 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
268 | /* 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
|
269 | 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
|
270 | "enabled-account"); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
271 | 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
|
272 | |
|
41458
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
273 | /* 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
|
274 | 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
|
275 | 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
|
276 | 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
|
277 | GMenu *protocol_menu = NULL; |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
278 | |
|
42004
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
279 | 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
|
280 | 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
|
281 | 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
|
282 | G_MENU_MODEL(protocol_menu)); |
|
42103
33ed4a2a7593
Fix leaks in dynamic menus
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42009
diff
changeset
|
283 | 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
|
284 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
285 | } |
|
90276efac79d
Add protocol actions to Pidgin account menu
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41457
diff
changeset
|
286 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
287 | 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
|
288 | "account", account_id, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
289 | "connection", connection_id, |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
290 | NULL); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
291 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
292 | 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
|
293 | } |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | /****************************************************************************** |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
296 | * 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
|
297 | *****************************************************************************/ |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
298 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
299 | 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
|
300 | 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
|
301 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
302 | if(menu->accounts != NULL) { |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
303 | 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
|
304 | menu->accounts = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
305 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
306 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
307 | 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
|
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 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
311 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
312 | 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
|
313 | 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
|
314 | PurpleAccountManager *manager = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
315 | GList *enabled = NULL, *l = NULL; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
316 | gint count = 0; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
317 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
318 | 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
|
319 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
320 | 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
|
321 | 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
|
322 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
323 | 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
|
324 | 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
|
325 | count++; |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
326 | } |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
327 | g_list_free(enabled); |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
328 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
329 | 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
|
330 | } |
|
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 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
333 | pidgin_accounts_enabled_menu_init(PidginAccountsEnabledMenu *menu) { |
|
41891
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
334 | PurpleAccountManager *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
|
335 | 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
|
336 | gpointer handle = NULL; |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
338 | 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
|
339 | |
|
41891
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
340 | manager = purple_account_manager_get_default(); |
|
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
341 | g_signal_connect_object(manager, "account-changed::enabled", |
|
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
342 | 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
|
343 | menu, 0); |
|
a45d6db4f857
Propagate the PurpleAccount::notify signal via PurpleAccountManager::account-changed
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
344 | |
|
41304
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | /* Wire up the purple signals we care about. */ |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | handle = purple_accounts_get_handle(); |
|
25830cad9bfc
Add a menu controller for the accounts enabled section of the accounts menu
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
348 | /* For the account actions, we also need to know when an account is online |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
349 | * or offline. |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
350 | */ |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
351 | purple_signal_connect(handle, "account-signed-on", menu, |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
352 | G_CALLBACK(pidgin_accounts_enabled_menu_connected_cb), |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
353 | menu); |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
354 | purple_signal_connect(handle, "account-signed-off", menu, |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
355 | G_CALLBACK(pidgin_accounts_enabled_menu_disconnected_cb), |
|
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
356 | 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
|
357 | |
|
fb172b78a9ee
Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents:
42004
diff
changeset
|
358 | /* 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
|
359 | 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
|
360 | 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
|
361 | 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
|
362 | menu, 0); |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
363 | } |
|
41403
0186ae21071f
Add purple_menu_populate_dynamic_targets to dynamically update GMenu's
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
364 | |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
365 | static void |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
370 | 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
|
371 | 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
|
372 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
373 | 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
|
374 | 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
|
375 | 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
|
376 | 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
|
377 | } |
|
41457
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
378 | |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
379 | /****************************************************************************** |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
380 | * Public API |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
381 | *****************************************************************************/ |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
382 | GMenuModel * |
|
f0e7534a555d
Convert PidginAccountsEnabledMenu from a menu controller to a GMenuModel
Gary Kramlich <grim@reaperworld.com>
parents:
41403
diff
changeset
|
383 | 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
|
384 | 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
|
385 | } |