pidgin/gtkroomlist.c

Thu, 23 Mar 2023 23:11:59 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Thu, 23 Mar 2023 23:11:59 -0500
changeset 42184
4e1bf25f5575
parent 42175
4185b4043214
child 42202
2273647d24b0
permissions
-rw-r--r--

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/

20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
1 /* pidgin
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
8146
4961c9c5fd61 [gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents: 8143
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
4961c9c5fd61 [gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents: 8143
diff changeset
5 * source distribution.
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
6 *
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 *
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 *
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18122
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 */
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
22 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
23
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24 #include <gtk/gtk.h>
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
26 #include <purple.h>
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
27
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
28 #include "gtkroomlist.h"
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
29
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
30 #include "pidginaccountchooser.h"
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21741
diff changeset
31
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
32 #define PIDGIN_TYPE_ROOMLIST_DIALOG (pidgin_roomlist_dialog_get_type())
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
33 G_DECLARE_FINAL_TYPE(PidginRoomlistDialog, pidgin_roomlist_dialog, PIDGIN,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
34 ROOMLIST_DIALOG, GtkDialog)
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
35
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
36 #define PIDGIN_ROOMLIST_UI_DATA "pidgin-ui"
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
37
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
38 enum {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
39 RESPONSE_STOP = 0,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
40 RESPONSE_LIST,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
41 RESPONSE_ADD,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
42 RESPONSE_JOIN,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
43 };
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
44
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
45 struct _PidginRoomlistDialog {
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
46 GtkDialog parent;
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
47
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
48 GtkWidget *account_widget;
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
49 GtkWidget *progress;
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
50 GtkWidget *view;
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
51 GtkSingleSelection *selection;
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
52 GtkFilterListModel *filter;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
53
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
54 GtkWidget *stop_button;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
55 GtkWidget *list_button;
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
56 GtkWidget *add_button;
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
57 GtkWidget *join_button;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
58 GtkWidget *close_button;
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
59
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
60 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
61 PurpleRoomlist *roomlist;
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
62
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
63 gboolean pg_needs_pulse;
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
64 guint pg_update_to;
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
65 };
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
66
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
67 G_DEFINE_TYPE(PidginRoomlistDialog, pidgin_roomlist_dialog, GTK_TYPE_DIALOG)
14649
38e6b75e6769 [gaim-migrate @ 17311]
Etan Reisner <deryni@pidgin.im>
parents: 14253
diff changeset
68
39556
622bf98df0ac Remove unnecessary struct tags.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38707
diff changeset
69 typedef struct {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
70 PidginRoomlistDialog *dialog;
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
71 GListStore *model;
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
72 } PidginRoomlist;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
73
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
74 /******************************************************************************
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
75 * Helpers
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
76 *****************************************************************************/
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
77 static void
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
78 pidgin_roomlist_close(PidginRoomlistDialog *dialog)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
79 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
80 if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist))
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
81 purple_roomlist_cancel_get_list(dialog->roomlist);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
82
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
83 if (dialog->roomlist) {
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
84 PidginRoomlist *rl = NULL;
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
85
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
86 rl = g_object_get_data(G_OBJECT(dialog->roomlist),
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
87 PIDGIN_ROOMLIST_UI_DATA);
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
88
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
89 if (dialog->pg_update_to > 0)
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
90 /* yes, that's right, unref it twice. */
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
91 g_object_unref(dialog->roomlist);
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
92
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
93 if (rl)
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
94 rl->dialog = NULL;
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
95 g_object_unref(dialog->roomlist);
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
96 }
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
97
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42036
diff changeset
98 g_clear_handle_id(&dialog->pg_update_to, g_source_remove);
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42036
diff changeset
99
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
100 dialog->progress = NULL;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
101 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
102
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
103 static void
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
104 pidgin_roomlist_start_listing(PidginRoomlistDialog *dialog)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
105 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
106 PurpleConnection *gc;
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
107 PidginRoomlist *rl;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
108
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
109 gc = purple_account_get_connection(dialog->account);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
110 if (!gc)
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
111 return;
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
112
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
113 if (dialog->roomlist != NULL) {
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
114 rl = g_object_get_data(G_OBJECT(dialog->roomlist),
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
115 PIDGIN_ROOMLIST_UI_DATA);
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
116
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
117 g_clear_object(&rl->model);
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
118 g_object_unref(dialog->roomlist);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
119 }
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
120
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
121 dialog->roomlist = purple_roomlist_get_list(gc);
9159
53c79c8258ee [gaim-migrate @ 9943]
Tim Ringenbach <marv@pidgin.im>
parents: 9067
diff changeset
122 if (!dialog->roomlist)
53c79c8258ee [gaim-migrate @ 9943]
Tim Ringenbach <marv@pidgin.im>
parents: 9067
diff changeset
123 return;
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
124 g_object_ref(dialog->roomlist);
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
125
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
126 rl = g_object_get_data(G_OBJECT(dialog->roomlist),
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
127 PIDGIN_ROOMLIST_UI_DATA);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
128 rl->dialog = dialog;
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
129
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
130 gtk_widget_set_sensitive(dialog->account_widget, FALSE);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
131
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
132 gtk_filter_list_model_set_model(dialog->filter, G_LIST_MODEL(rl->model));
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
133
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
134 /* some protocols (not bundled with libpurple) finish getting their
15350
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
135 * room list immediately */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
136 if(purple_roomlist_get_in_progress(dialog->roomlist)) {
15350
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
137 gtk_widget_set_sensitive(dialog->stop_button, TRUE);
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
138 gtk_widget_set_sensitive(dialog->list_button, FALSE);
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
139 } else {
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
140 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
141 gtk_widget_set_sensitive(dialog->list_button, TRUE);
9bf3d19afa95 [gaim-migrate @ 18078]
Nathan Walp <nwalp@pidgin.im>
parents: 15185
diff changeset
142 }
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
143 gtk_widget_set_sensitive(dialog->add_button, FALSE);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
144 gtk_widget_set_sensitive(dialog->join_button, FALSE);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
145 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
146
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
147 static void
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
148 pidgin_roomlist_stop_listing(PidginRoomlistDialog *dialog)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
149 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
150 purple_roomlist_cancel_get_list(dialog->roomlist);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
151
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
152 gtk_widget_set_sensitive(dialog->account_widget, TRUE);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
153
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
154 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
155 gtk_widget_set_sensitive(dialog->list_button, TRUE);
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
156 gtk_widget_set_sensitive(dialog->add_button, FALSE);
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
157 gtk_widget_set_sensitive(dialog->join_button, FALSE);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
158 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
159
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
160 static void
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
161 pidgin_roomlist_add_to_blist(PidginRoomlistDialog *dialog)
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
162 {
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
163 char *name = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
164 PurpleAccount *account = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
165 PurpleConnection *gc = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
166 PurpleProtocol *protocol = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
167 PurpleRoomlistRoom *room = NULL;
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
168
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
169 account = purple_roomlist_get_account(dialog->roomlist);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
170 gc = purple_account_get_connection(account);
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
171
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
172 room = gtk_single_selection_get_selected_item(dialog->selection);
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
173 g_return_if_fail(PURPLE_IS_ROOMLIST_ROOM(room));
15185
74b689a74430 [gaim-migrate @ 17909]
Nathan Walp <nwalp@pidgin.im>
parents: 14649
diff changeset
174
41028
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
175 if(gc != NULL) {
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36606
diff changeset
176 protocol = purple_connection_get_protocol(gc);
41028
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
177 }
15185
74b689a74430 [gaim-migrate @ 17909]
Nathan Walp <nwalp@pidgin.im>
parents: 14649
diff changeset
178
41028
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
179 if(protocol != NULL && PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST, room_serialize)) {
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
180 name = purple_protocol_roomlist_room_serialize(PURPLE_PROTOCOL_ROOMLIST(protocol),
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
181 room);
41028
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
182 } else {
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
183 name = g_strdup(purple_roomlist_room_get_name(room));
41028
943b2cb45314 Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents: 41012
diff changeset
184 }
15185
74b689a74430 [gaim-migrate @ 17909]
Nathan Walp <nwalp@pidgin.im>
parents: 14649
diff changeset
185
32218
f27b05250351 Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents: 31321
diff changeset
186 purple_blist_request_add_chat(account, NULL, NULL, name);
15185
74b689a74430 [gaim-migrate @ 17909]
Nathan Walp <nwalp@pidgin.im>
parents: 14649
diff changeset
187
74b689a74430 [gaim-migrate @ 17909]
Nathan Walp <nwalp@pidgin.im>
parents: 14649
diff changeset
188 g_free(name);
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
189 }
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
190
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
191 static void
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
192 pidgin_roomlist_join(PidginRoomlistDialog *dialog)
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
193 {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
194 PurpleRoomlistRoom *room = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
195
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
196 room = gtk_single_selection_get_selected_item(dialog->selection);
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
197 if(PURPLE_IS_ROOMLIST_ROOM(room)) {
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
198 purple_roomlist_join_room(dialog->roomlist, room);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
199 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
200 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
201
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
202 /******************************************************************************
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
203 * Actions
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
204 *****************************************************************************/
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
205 static void
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
206 pidgin_roomlist_add_to_blist_cb(G_GNUC_UNUSED GSimpleAction *action,
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
207 G_GNUC_UNUSED GVariant *parameter,
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
208 gpointer data)
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
209 {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
210 pidgin_roomlist_add_to_blist(data);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
211 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
212
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
213
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
214 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
215 pidgin_roomlist_join_cb(G_GNUC_UNUSED GSimpleAction *action,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
216 G_GNUC_UNUSED GVariant *parameter,
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
217 gpointer data)
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
218 {
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
219 pidgin_roomlist_join(data);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
220 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
221
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
222 static GActionEntry actions[] = {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
223 {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
224 .name = "add",
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
225 .activate = pidgin_roomlist_add_to_blist_cb,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
226 }, {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
227 .name = "join",
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
228 .activate = pidgin_roomlist_join_cb,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
229 },
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
230 };
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
231
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
232 /******************************************************************************
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
233 * Callbacks
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
234 *****************************************************************************/
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
235 static void
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
236 pidgin_roomlist_response_cb(GtkDialog *gtk_dialog, gint response_id,
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
237 G_GNUC_UNUSED gpointer data)
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
238 {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
239 PidginRoomlistDialog *dialog = PIDGIN_ROOMLIST_DIALOG(gtk_dialog);
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
240
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
241 switch(response_id) {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
242 case RESPONSE_STOP:
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
243 pidgin_roomlist_stop_listing(dialog);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
244 break;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
245 case RESPONSE_LIST:
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
246 pidgin_roomlist_start_listing(dialog);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
247 break;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
248 case RESPONSE_ADD:
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
249 pidgin_roomlist_add_to_blist(dialog);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
250 break;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
251 case RESPONSE_JOIN:
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
252 pidgin_roomlist_join(dialog);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
253 break;
41599
450080e4726a Fix up the roomlist to work in GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41554
diff changeset
254 case GTK_RESPONSE_CLOSE:
450080e4726a Fix up the roomlist to work in GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41554
diff changeset
255 case GTK_RESPONSE_DELETE_EVENT:
450080e4726a Fix up the roomlist to work in GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41554
diff changeset
256 gtk_window_destroy(GTK_WINDOW(gtk_dialog));
450080e4726a Fix up the roomlist to work in GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41554
diff changeset
257 break;
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
258 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
259 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
260
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
261 static gboolean
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
262 close_request_cb(GtkWidget *w, G_GNUC_UNUSED gpointer d)
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
263 {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
264 pidgin_roomlist_close(PIDGIN_ROOMLIST_DIALOG(w));
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
265
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
266 gtk_window_destroy(GTK_WINDOW(w));
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
267
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
268 return TRUE;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
269 }
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
270
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
271 static void
41854
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41840
diff changeset
272 dialog_select_account_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41840
diff changeset
273 gpointer data)
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41840
diff changeset
274 {
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41840
diff changeset
275 PidginRoomlistDialog *dialog = data;
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41840
diff changeset
276 PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(obj);
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
277 PurpleAccount *account = pidgin_account_chooser_get_selected(chooser);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
278 gboolean change = (account != dialog->account);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
279 dialog->account = account;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
280
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
281 if (change && dialog->roomlist) {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
282 PidginRoomlist *rl = NULL;
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
283
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
284 rl = g_object_get_data(G_OBJECT(dialog->roomlist),
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
285 PIDGIN_ROOMLIST_UI_DATA);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
286
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
287 g_clear_object(&rl->model);
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
288 g_clear_object(&dialog->roomlist);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
289 }
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
290 }
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
291
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
292 static void
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
293 selection_changed_cb(GtkSelectionModel *self, G_GNUC_UNUSED guint position,
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
294 G_GNUC_UNUSED guint n_items, gpointer data)
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
295 {
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
296 PidginRoomlistDialog *dialog = data;
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
297 guint index = GTK_INVALID_LIST_POSITION;
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
298 gboolean found = FALSE;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
299
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
300 /* The passed in position and n_items gives the *range* of selections that
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
301 * have changed, so just re-query it exactly since GtkSingleSelection has
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
302 * only one. */
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
303 index = gtk_single_selection_get_selected(GTK_SINGLE_SELECTION(self));
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
304 found = index != GTK_INVALID_LIST_POSITION;
12896
d368037a2bb7 [gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents: 12600
diff changeset
305
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
306 gtk_widget_set_sensitive(dialog->add_button, found);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
307 gtk_widget_set_sensitive(dialog->join_button, found);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
308 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
309
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
310 static void
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
311 row_activated_cb(GtkColumnView *self, guint position, gpointer data)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
312 {
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
313 PidginRoomlistDialog *dialog = data;
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
314 PurpleRoomlistRoom *room = NULL;
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
315 GtkSelectionModel *model = NULL;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
316
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
317 model = gtk_column_view_get_model(self);
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
318 room = g_list_model_get_item(G_LIST_MODEL(model), position);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
319
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
320 if(PURPLE_IS_ROOMLIST_ROOM(room)) {
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
321 purple_roomlist_join_room(dialog->roomlist, room);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
322 }
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
323
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
324 g_clear_object(&room);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
325 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
326
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
327 static gboolean
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
328 account_filter_func(gpointer item, G_GNUC_UNUSED gpointer data) {
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36424
diff changeset
329 PurpleProtocol *protocol = NULL;
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
330
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
331 if(PURPLE_IS_ACCOUNT(item)) {
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
332 PurpleAccount *account = PURPLE_ACCOUNT(item);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
333 PurpleConnection *conn = purple_account_get_connection(account);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
334 if(conn && PURPLE_CONNECTION_IS_CONNECTED(conn)) {
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
335 protocol = purple_connection_get_protocol(conn);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
336 }
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
337 }
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
338
39759
ea1401483849 Rename *_GET_*_IFACE to more standard *_GET_IFACE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39556
diff changeset
339 return (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST, get_list));
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
340 }
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
341
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
342 gboolean
41840
fe350460fb1c Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
343 pidgin_roomlist_is_showable(void)
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
344 {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
345 GList *c;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
346 PurpleConnection *gc;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
347
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
348 for (c = purple_connections_get_all(); c != NULL; c = c->next) {
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
349 gc = c->data;
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
350
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
351 if(account_filter_func(purple_connection_get_account(gc), NULL)) {
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
352 return TRUE;
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
353 }
8939
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
354 }
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
355
ec2ecc652447 [gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents: 8937
diff changeset
356 return FALSE;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
357 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
358
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
359 static void
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
360 pidgin_roomlist_dialog_class_init(PidginRoomlistDialogClass *klass)
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
361 {
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
362 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
363
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
364 gtk_widget_class_set_template_from_resource(
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 41028
diff changeset
365 widget_class, "/im/pidgin/Pidgin3/Roomlist/roomlist.ui");
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
366
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
367 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
368 account_widget);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
369 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
370 view);
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
371 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
372 selection);
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
373 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
374 filter);
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
375 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
376 add_button);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
377 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
378 close_button);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
379 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
380 join_button);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
381 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
382 list_button);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
383 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
384 progress);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
385 gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
386 stop_button);
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
387
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
388 gtk_widget_class_bind_template_callback(widget_class, close_request_cb);
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
389 gtk_widget_class_bind_template_callback(widget_class, row_activated_cb);
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
390 gtk_widget_class_bind_template_callback(widget_class,
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
391 dialog_select_account_cb);
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
392 gtk_widget_class_bind_template_callback(widget_class,
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
393 selection_changed_cb);
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
394 gtk_widget_class_bind_template_callback(widget_class,
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
395 pidgin_roomlist_response_cb);
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
396 }
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
397
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
398 static void
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
399 pidgin_roomlist_dialog_init(PidginRoomlistDialog *self)
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
400 {
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
401 GSimpleActionGroup *group = NULL;
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
402 GtkCustomFilter *filter = NULL;
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
403
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
404 gtk_widget_init_template(GTK_WIDGET(self));
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
405
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
406 filter = gtk_custom_filter_new(account_filter_func, NULL, NULL);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
407 pidgin_account_chooser_set_filter(
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
408 PIDGIN_ACCOUNT_CHOOSER(self->account_widget),
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
409 GTK_FILTER(filter));
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
410 g_object_unref(filter);
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
411
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
412 /* Now setup our actions. */
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
413 group = g_simple_action_group_new();
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
414 g_action_map_add_action_entries(G_ACTION_MAP(group), actions,
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
415 G_N_ELEMENTS(actions), self);
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
416 gtk_widget_insert_action_group(GTK_WIDGET(self), "roomlist",
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
417 G_ACTION_GROUP(group));
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
418 }
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
419
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
420 static PidginRoomlistDialog *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
421 pidgin_roomlist_dialog_new_with_account(PurpleAccount *account)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
422 {
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
423 PidginRoomlistDialog *dialog = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
424 PidginAccountChooser *chooser = NULL;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
425
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
426 dialog = g_object_new(PIDGIN_TYPE_ROOMLIST_DIALOG, NULL);
8937
b436e9cbd701 [gaim-migrate @ 9707]
Mark Doliner <markdoliner@pidgin.im>
parents: 8584
diff changeset
427 dialog->account = account;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
428
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
429 chooser = PIDGIN_ACCOUNT_CHOOSER(dialog->account_widget);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
430
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
431 if (!account) {
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
432 /* This is normally NULL, and we normally don't care what the
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
433 * first selected item is */
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
434 dialog->account = pidgin_account_chooser_get_selected(chooser);
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
435 } else {
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
436 pidgin_account_chooser_set_selected(chooser, account);
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
437 }
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
438
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
439 /* show the dialog window and return the dialog */
40250
19acef70137d Convert PidginRoomlistDialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40197
diff changeset
440 gtk_widget_show(GTK_WIDGET(dialog));
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
441
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
442 return dialog;
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
443 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
444
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
445 void pidgin_roomlist_dialog_show_with_account(PurpleAccount *account)
8352
cf7ca701b213 [gaim-migrate @ 9076]
Tim Ringenbach <marv@pidgin.im>
parents: 8287
diff changeset
446 {
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
447 PidginRoomlistDialog *dialog = pidgin_roomlist_dialog_new_with_account(account);
8352
cf7ca701b213 [gaim-migrate @ 9076]
Tim Ringenbach <marv@pidgin.im>
parents: 8287
diff changeset
448
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
449 pidgin_roomlist_start_listing(dialog);
8352
cf7ca701b213 [gaim-migrate @ 9076]
Tim Ringenbach <marv@pidgin.im>
parents: 8287
diff changeset
450 }
cf7ca701b213 [gaim-migrate @ 9076]
Tim Ringenbach <marv@pidgin.im>
parents: 8287
diff changeset
451
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
452 void pidgin_roomlist_dialog_show(void)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
453 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
454 pidgin_roomlist_dialog_new_with_account(NULL);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
455 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
456
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
457 static gboolean pidgin_progress_bar_pulse(gpointer data)
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
458 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
459 PurpleRoomlist *list = data;
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
460 PidginRoomlist *rl = NULL;
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
461
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
462 rl = g_object_get_data(G_OBJECT(list), PIDGIN_ROOMLIST_UI_DATA);
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
463 if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) {
13448
27832a91b988 [gaim-migrate @ 15822]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12896
diff changeset
464 if (rl && rl->dialog)
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
465 rl->dialog->pg_update_to = 0;
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
466 g_object_unref(list);
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
467 return FALSE;
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
468 }
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
469
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
470 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
471 rl->dialog->pg_needs_pulse = FALSE;
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
472 return TRUE;
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
473 }
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
474
41349
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
475 static void
15aeaa1e84ec Rework the way roomlists work so we can more easily port them to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
476 pidgin_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) {
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
477 PidginRoomlist *rl = NULL;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
478
40898
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
479 rl = g_object_get_data(G_OBJECT(list), PIDGIN_ROOMLIST_UI_DATA);
06e5a2a8f49a Replace purple_roomlist_[gs]et_ui_data with g_object_[gs]et_data
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
480
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
481 if (rl->dialog) {
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
482 if (rl->dialog->pg_update_to == 0) {
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 33271
diff changeset
483 g_object_ref(list);
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
484 rl->dialog->pg_update_to = g_timeout_add(100, pidgin_progress_bar_pulse, list);
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
485 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
486 } else
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
487 rl->dialog->pg_needs_pulse = TRUE;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
488 }
23918
ae3c8eb64659 Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents: 22131
diff changeset
489
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
490 g_list_store_append(rl->model, room);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
491 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
492
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
493 static void
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
494 pidgin_roomlist_in_progress(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
495 gpointer data)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
496 {
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
497 PurpleRoomlist *list = PURPLE_ROOMLIST(obj);
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
498 PidginRoomlist *rl = data;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
499
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
500 if (purple_roomlist_get_in_progress(list)) {
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
501 if (rl->dialog->account_widget) {
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
502 gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
503 }
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
504 gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE);
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
505 gtk_widget_set_sensitive(rl->dialog->list_button, FALSE);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
506 } else {
8230
0241cfde5c03 [gaim-migrate @ 8953]
Tim Ringenbach <marv@pidgin.im>
parents: 8199
diff changeset
507 rl->dialog->pg_needs_pulse = FALSE;
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
508 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
509 if (rl->dialog->account_widget) {
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
510 gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
511 }
8199
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
512 gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE);
43d585355720 [gaim-migrate @ 8922]
Tim Ringenbach <marv@pidgin.im>
parents: 8146
diff changeset
513 gtk_widget_set_sensitive(rl->dialog->list_button, TRUE);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
514 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
515 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
516
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
517 static void
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
518 pidgin_roomlist_new(PurpleRoomlist *list)
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
519 {
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
520 PidginRoomlist *rl = g_new0(PidginRoomlist, 1);
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
521
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
522 g_object_set_data_full(G_OBJECT(list), PIDGIN_ROOMLIST_UI_DATA, rl,
41554
49216e79a56b Port PidginRoomlistDialog to GTK4
Belgin Știrbu <belginstirbu@hotmail.com>
parents: 41349
diff changeset
523 (GDestroyNotify)g_free);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
524
42036
941734e74261 Port the room list from GtkTreeView to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
525 rl->model = g_list_store_new(PURPLE_TYPE_ROOMLIST_ROOM);
40977
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
526
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
527 g_signal_connect(list, "notify::in-progress",
dd0f04c5d212 Cleanup RoomList UI ops
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40956
diff changeset
528 G_CALLBACK(pidgin_roomlist_in_progress), rl);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
529 }
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
530
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
531 static PurpleRoomlistUiOps ops = {
41720
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41599
diff changeset
532 .show_with_account = pidgin_roomlist_dialog_show_with_account,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41599
diff changeset
533 .create = pidgin_roomlist_new,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41599
diff changeset
534 .add_room = pidgin_roomlist_add_room,
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
535 };
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
536
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
537
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
538 void pidgin_roomlist_init(void)
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
539 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
540 purple_roomlist_set_ui_ops(&ops);
8113
6a2ffc66c022 [gaim-migrate @ 8817]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
541 }

mercurial