pidgin/pidgindisplayitem.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 42050
5ac6db2b8c2d
child 42575
580339aa47cc
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/

42050
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidgindisplayitem.h"
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PidginDisplayItem {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GObject parent;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 GtkWidget *widget;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 char *id;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 char *title;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 char *icon_name;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 gboolean needs_attention;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 guint badge_number;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GListModel *children;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 };
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 enum {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_0,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_WIDGET,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PROP_ID,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PROP_TITLE,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PROP_ICON_NAME,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_NEEDS_ATTENTION,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PROP_BADGE_NUMBER,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 PROP_CHILDREN,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 N_PROPERTIES,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 };
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static GParamSpec *properties[N_PROPERTIES] = {NULL,};
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 G_DEFINE_TYPE(PidginDisplayItem, pidgin_display_item, G_TYPE_OBJECT)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 /******************************************************************************
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 * Helpers
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 *****************************************************************************/
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 pidgin_display_item_set_widget(PidginDisplayItem *item, GtkWidget *widget) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 if(g_set_object(&item->widget, widget)) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_WIDGET]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 pidgin_display_item_set_id(PidginDisplayItem *item, const char *id) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 g_return_if_fail(id != NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 if(item->id == id) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 return;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 g_free(item->id);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 item->id = g_strdup(id);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ID]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 /******************************************************************************
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 * GObject Implementation
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 *****************************************************************************/
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 pidgin_display_item_dispose(GObject *obj) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 PidginDisplayItem *item = PIDGIN_DISPLAY_ITEM(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 g_clear_object(&item->widget);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_clear_object(&item->children);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 G_OBJECT_CLASS(pidgin_display_item_parent_class)->dispose(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 pidgin_display_item_finalize(GObject *obj) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 PidginDisplayItem *item = PIDGIN_DISPLAY_ITEM(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_clear_pointer(&item->id, g_free);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 g_clear_pointer(&item->title, g_free);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 g_clear_pointer(&item->icon_name, g_free);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 G_OBJECT_CLASS(pidgin_display_item_parent_class)->finalize(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 pidgin_display_item_get_property(GObject *obj, guint param_id, GValue *value,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 GParamSpec *pspec)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 PidginDisplayItem *item = PIDGIN_DISPLAY_ITEM(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 switch(param_id) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 case PROP_WIDGET:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_value_set_object(value, pidgin_display_item_get_widget(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 case PROP_ID:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 g_value_set_string(value, pidgin_display_item_get_id(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 case PROP_TITLE:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 g_value_set_string(value, pidgin_display_item_get_title(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 case PROP_ICON_NAME:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_value_set_string(value, pidgin_display_item_get_icon_name(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 case PROP_NEEDS_ATTENTION:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 g_value_set_boolean(value,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 pidgin_display_item_get_needs_attention(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 case PROP_BADGE_NUMBER:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 g_value_set_uint(value,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 pidgin_display_item_get_badge_number(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 case PROP_CHILDREN:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 g_value_set_object(value, pidgin_display_item_get_children(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 default:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 pidgin_display_item_set_property(GObject *obj, guint param_id,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 const GValue *value, GParamSpec *pspec)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 PidginDisplayItem *item = PIDGIN_DISPLAY_ITEM(obj);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 switch(param_id) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 case PROP_WIDGET:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 pidgin_display_item_set_widget(item, g_value_get_object(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 case PROP_ID:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 pidgin_display_item_set_id(item, g_value_get_string(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 case PROP_TITLE:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 pidgin_display_item_set_title(item, g_value_get_string(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 case PROP_ICON_NAME:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 pidgin_display_item_set_icon_name(item, g_value_get_string(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 case PROP_NEEDS_ATTENTION:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 pidgin_display_item_set_needs_attention(item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 g_value_get_boolean(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 case PROP_BADGE_NUMBER:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 pidgin_display_item_set_badge_number(item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 g_value_get_uint(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 case PROP_CHILDREN:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 pidgin_display_item_set_children(item, g_value_get_object(value));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 default:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 break;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 pidgin_display_item_init(G_GNUC_UNUSED PidginDisplayItem *window) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 static void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 pidgin_display_item_class_init(PidginDisplayItemClass *klass) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 obj_class->dispose = pidgin_display_item_dispose;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 obj_class->finalize = pidgin_display_item_finalize;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 obj_class->get_property = pidgin_display_item_get_property;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 obj_class->set_property = pidgin_display_item_set_property;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 * PidginDisplayItem:widget:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 * The [class@Gtk.Widget] that this item is for.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 properties[PROP_WIDGET] = g_param_spec_object(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 "widget", "widget",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 "The widget for this item",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 GTK_TYPE_WIDGET,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 * PidginDisplayItem:id:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 * A unique identifier for this item. This is used for things like
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 * remembering positions and selections.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 properties[PROP_ID] = g_param_spec_string(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 "id", "id",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 "A unique identifier for the item",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 NULL,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 * PidginDisplayItem:title:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 * The title that should be displayed for this item.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 properties[PROP_TITLE] = g_param_spec_string(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 "title", "title",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 "The title for the item",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 NULL,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 * PidginDisplayItem:icon-name:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 * The icon name to use for this item.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 properties[PROP_ICON_NAME] = g_param_spec_string(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 "icon-name", "icon-name",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 "The icon-name to use for this item",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 NULL,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 * PidginDisplayItem:needs-attention:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 * Determines whether the item should show that it needs attention or not.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 properties[PROP_NEEDS_ATTENTION] = g_param_spec_boolean(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 "needs-attention", "needs-attention",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 "Whether or not the item needs attention",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 FALSE,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 * PidginDisplayItem:badge-number:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 * The number that should be shown in the badge. Typically this is an
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 * unread count. If this is 0 it should not be displayed.
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 properties[PROP_BADGE_NUMBER] = g_param_spec_uint(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 "badge-number", "badge-number",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 "The number to show in the badge",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 0, G_MAXUINT, 0,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 /**
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 * PidginDisplayItem:children:
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 * A [iface@Gio.ListModel] of child items. The type of the model needs to
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 * be [class@Pidgin.DisplayItem].
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 * Since: 3.0.0
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 */
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 properties[PROP_CHILDREN] = g_param_spec_object(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 "children", "children",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 "A GListModel of child items",
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 G_TYPE_LIST_MODEL,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 /******************************************************************************
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 * API
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 *****************************************************************************/
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 PidginDisplayItem *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 pidgin_display_item_new(GtkWidget *widget, const char *id) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 g_return_val_if_fail(id != NULL, NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 return g_object_new(
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 PIDGIN_TYPE_DISPLAY_ITEM,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 "widget", widget,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 "id", id,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 GtkWidget *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 pidgin_display_item_get_widget(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 return item->widget;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 const char *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 pidgin_display_item_get_id(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 return item->id;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 const char *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 pidgin_display_item_get_title(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 return item->title;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 pidgin_display_item_set_title(PidginDisplayItem *item, const char *title) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 if(item->title == title) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 return;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 g_free(item->title);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 item->title = g_strdup(title);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_TITLE]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 const char *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 pidgin_display_item_get_icon_name(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 return item->icon_name;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 pidgin_display_item_set_icon_name(PidginDisplayItem *item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 const char *icon_name)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 if(item->icon_name == icon_name) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 return;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 g_free(item->icon_name);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 item->icon_name = g_strdup(icon_name);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ICON_NAME]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 gboolean
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 pidgin_display_item_get_needs_attention(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), FALSE);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 return item->needs_attention;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 pidgin_display_item_set_needs_attention(PidginDisplayItem *item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 gboolean needs_attention)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 if(item->needs_attention != needs_attention) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 item->needs_attention = needs_attention;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 g_object_notify_by_pspec(G_OBJECT(item),
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 properties[PROP_NEEDS_ATTENTION]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 guint
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 pidgin_display_item_get_badge_number(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), 0);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 return item->badge_number;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 pidgin_display_item_set_badge_number(PidginDisplayItem *item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 guint badge_number)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 if(item->badge_number != badge_number) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 item->badge_number = badge_number;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 g_object_notify_by_pspec(G_OBJECT(item),
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 properties[PROP_BADGE_NUMBER]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 GListModel *
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 pidgin_display_item_get_children(PidginDisplayItem *item) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 g_return_val_if_fail(PIDGIN_IS_DISPLAY_ITEM(item), NULL);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 return item->children;
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 void
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 pidgin_display_item_set_children(PidginDisplayItem *item,
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 GListModel *children)
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 if(g_set_object(&item->children, children)) {
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419 g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_CHILDREN]);
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 }
5ac6db2b8c2d Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 }

mercurial