pidgin/pidgincontactlist.c

Mon, 07 Aug 2023 22:18:34 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 07 Aug 2023 22:18:34 -0500
changeset 42262
5f218efc3c7b
parent 42237
57c9deea59c8
child 42304
51a419226147
permissions
-rw-r--r--

Port PidginAccountsEnabledMenu to the AccountManager propagated signals

Testing Done:
Connected the demo account and verified that its menu items worked.

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

42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgin/pidgincontactlist.h"
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PidginContactList {
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
30 GtkBox parent;
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
32 GtkFilterListModel *filter_model;
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
33 GtkCustomFilter *account_connected_filter;
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
34 GtkCustomFilter *search_filter;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
35
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
36 GtkWidget *search_entry;
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 GtkWidget *view;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
40 G_DEFINE_TYPE(PidginContactList, pidgin_contact_list, GTK_TYPE_BOX)
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
41
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
42 /******************************************************************************
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
43 * Helpers
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
44 *****************************************************************************/
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
45 static gboolean
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
46 pidgin_contact_list_account_connected_filter(GObject *item,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
47 G_GNUC_UNUSED gpointer data)
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
48 {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
49 PurplePerson *person = PURPLE_PERSON(item);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
50 PurpleContactInfo *info = NULL;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
51
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
52 info = purple_person_get_priority_contact_info(person);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
53 if(!PURPLE_IS_CONTACT_INFO(info)) {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
54 return FALSE;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
55 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
56
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
57 /* This should always be a PurpleContact as it's in the contact manager,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
58 * but it doesn't hurt to check.
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
59 */
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
60 if(PURPLE_IS_CONTACT(info)) {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
61 PurpleConnection *connection = NULL;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
62 PurpleContact *contact = PURPLE_CONTACT(info);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
63 PurpleAccount *account = NULL;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
64
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
65 account = purple_contact_get_account(contact);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
66 connection = purple_account_get_connection(account);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
67
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
68 if(PURPLE_IS_CONNECTION(connection)) {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
69 PurpleConnectionState state = PURPLE_CONNECTION_STATE_DISCONNECTED;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
70
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
71 state = purple_connection_get_state(connection);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
72
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
73 return (state == PURPLE_CONNECTION_STATE_CONNECTED);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
74 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
75
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
76 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
77
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
78 return FALSE;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
79 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
80
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
81 static void
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
82 pidgin_contact_list_account_connected_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
83 G_GNUC_UNUSED PurpleAccount *account,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
84 gpointer data)
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
85 {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
86 PidginContactList *list = data;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
87
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
88 gtk_filter_changed(GTK_FILTER(list->account_connected_filter),
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
89 GTK_FILTER_CHANGE_LESS_STRICT);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
90 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
91
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
92 static void
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
93 pidgin_contact_list_account_disconnected_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
94 G_GNUC_UNUSED PurpleAccount *account,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
95 gpointer data)
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
96 {
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
97 PidginContactList *list = data;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
98
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
99 gtk_filter_changed(GTK_FILTER(list->account_connected_filter),
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
100 GTK_FILTER_CHANGE_MORE_STRICT);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
101 }
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
102
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
103 static gboolean
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
104 pidgin_contact_list_search_filter(GObject *item, gpointer data) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
105 PidginContactList *list = data;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
106 PurplePerson *person = PURPLE_PERSON(item);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
107 const char *needle = NULL;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
108
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
109 needle = gtk_editable_get_text(GTK_EDITABLE(list->search_entry));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
110
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
111 return purple_person_matches(person, needle);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
112 }
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 /******************************************************************************
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 * Callbacks
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 *****************************************************************************/
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
117 static void
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
118 pidgin_contact_list_search_changed_cb(G_GNUC_UNUSED GtkSearchEntry *self,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
119 gpointer data)
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
120 {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
121 PidginContactList *list = data;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
122
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
123 gtk_filter_changed(GTK_FILTER(list->search_filter),
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
124 GTK_FILTER_CHANGE_DIFFERENT);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
125 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
126
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 static GdkTexture *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 pidgin_contact_list_avatar_cb(G_GNUC_UNUSED GObject *self,
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 PurplePerson *person,
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 G_GNUC_UNUSED gpointer data)
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 {
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 PurpleContactInfo *info = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 PurpleContact *contact = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 PurpleBuddyIcon *icon = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 GdkTexture *texture = NULL;
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
136 GdkPixbuf *pixbuf = NULL;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
137
42065
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
138 /* When filtering we get called for rows that have been filtered out. We
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
139 * also get called during finalization. I'm not sure why either of these
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
140 * cases happen, but they do.
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
141 */
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
142 if(!PURPLE_IS_PERSON(person)) {
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
143 return NULL;
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
144 }
b9dc817fbb3f Clean up the null checking in pidgin_contact_list_avatar_cb
Gary Kramlich <grim@reaperworld.com>
parents: 42062
diff changeset
145
42200
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42185
diff changeset
146 info = purple_person_get_priority_contact_info(person);
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42185
diff changeset
147 if(!PURPLE_IS_CONTACT_INFO(info)) {
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42185
diff changeset
148 return NULL;
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42185
diff changeset
149 }
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42185
diff changeset
150
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
151 pixbuf = purple_person_get_avatar_for_display(person);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
152 if(GDK_IS_PIXBUF(pixbuf)) {
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
153 return gdk_texture_new_for_pixbuf(pixbuf);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42052
diff changeset
154 }
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 /* All of the contact info in the manager are PurpleContact's so this cast
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 * is fine.
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 */
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 contact = PURPLE_CONTACT(info);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 icon = purple_buddy_icons_find(purple_contact_get_account(contact),
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 purple_contact_info_get_username(info));
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 if(icon != NULL) {
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 GBytes *bytes = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 GError *error = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 gsize size;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 gconstpointer data = NULL;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 data = purple_buddy_icon_get_data(icon, &size);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 bytes = g_bytes_new(data, size);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 texture = gdk_texture_new_from_bytes(bytes, &error);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 g_bytes_unref(bytes);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 if(error != NULL) {
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 g_warning("Failed to create texture: %s", error->message);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 g_clear_error(&error);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 }
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 return texture;
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 }
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
42025
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
186 static void
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
187 pidgin_contact_list_activate_cb(GtkListView *self, guint position,
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
188 G_GNUC_UNUSED gpointer data)
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
189 {
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
190 PurpleAccount *account = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
191 PurpleContactInfo *info = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
192 PurpleConversation *conversation = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
193 PurpleConversationManager *manager = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
194 PurplePerson *person = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
195 GtkSelectionModel *model = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
196 const char *name = NULL;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
197
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
198 model = gtk_list_view_get_model(self);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
199
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
200 person = g_list_model_get_item(G_LIST_MODEL(model), position);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
201 if(!PURPLE_IS_PERSON(person)) {
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
202 g_warning("we seem to have activated a zombie.. RUN!!!!!!");
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
203
42179
b8bb444799a4 Fix leaks from g_list_model_get_item
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42178
diff changeset
204 g_clear_object(&person);
42025
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
205 return;
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
206 }
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
207
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
208 info = purple_person_get_priority_contact_info(person);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
209 account = purple_contact_get_account(PURPLE_CONTACT(info));
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
210 name = purple_contact_info_get_username(info);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
211
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
212 manager = purple_conversation_manager_get_default();
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
213 conversation = purple_conversation_manager_find_im(manager, account, name);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
214
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
215 if(!PURPLE_IS_CONVERSATION(conversation)) {
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
216 conversation = purple_im_conversation_new(account, name);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
217 purple_conversation_manager_register(manager, conversation);
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
218 }
42179
b8bb444799a4 Fix leaks from g_list_model_get_item
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42178
diff changeset
219
b8bb444799a4 Fix leaks from g_list_model_get_item
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42178
diff changeset
220 g_clear_object(&person);
42025
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
221 }
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
222
42052
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
223 static gboolean
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
224 pidgin_contact_list_message_visible_cb(G_GNUC_UNUSED GtkListItem *item,
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
225 const char *message)
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
226 {
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
227 /* If we have a message, return TRUE because this is bound to the label's
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
228 * visibility.
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
229 */
42178
e795355c3165 Use the new status api in the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42065
diff changeset
230 return !purple_strempty(message);
42052
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
231 }
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
232
42185
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
233 static char *
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
234 pidgin_contact_list_get_primitive_as_string(G_GNUC_UNUSED GObject *self,
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
235 PurplePresence *presence,
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
236 G_GNUC_UNUSED gpointer data)
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
237 {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
238 PurplePresencePrimitive primitive;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
239 GDateTime *idle = NULL;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
240 GString *str = g_string_new(NULL);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
241 const char *tmp = NULL;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
242
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
243 if(!PURPLE_IS_PRESENCE(presence)) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
244 return g_string_free(str, FALSE);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
245 }
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
246
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
247 primitive = purple_presence_get_primitive(presence);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
248 tmp = purple_presence_primitive_to_string(primitive);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
249 if(tmp != NULL) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
250 g_string_append_printf(str, " - %s", tmp);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
251 }
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
252
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
253 idle = purple_presence_get_idle_time(presence);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
254 if(idle != NULL) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
255 GDateTime *now = NULL;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
256 GTimeSpan duration;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
257 guint days;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
258 guint hours;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
259 guint minutes;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
260
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
261 now = g_date_time_new_now_utc();
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
262 duration = g_date_time_difference(now, idle);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
263 g_date_time_unref(now);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
264
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
265 days = duration / G_TIME_SPAN_DAY;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
266 duration %= G_TIME_SPAN_DAY;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
267 hours = duration / G_TIME_SPAN_HOUR;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
268 duration %= G_TIME_SPAN_HOUR;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
269 minutes = duration / G_TIME_SPAN_MINUTE;
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
270
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
271 if(days > 0) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
272 g_string_append_printf(str, _(" Idle %dd %dh %02dm"), days, hours,
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
273 minutes);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
274 } else if(hours > 0) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
275 g_string_append_printf(str, _(" Idle %dh %02dm"), hours, minutes);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
276 } else if(minutes > 0) {
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
277 g_string_append_printf(str, _(" Idle %02dm"), minutes);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
278 }
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
279 }
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
280
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
281 return g_string_free(str, FALSE);
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
282 }
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
283
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 /******************************************************************************
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 * GObject Implementation
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 *****************************************************************************/
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 static void
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 pidgin_contact_list_init(PidginContactList *list) {
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
289 PurpleAccountManager *account_manager = NULL;
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
290 PurpleContactManager *contact_manager = NULL;
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 gtk_widget_init_template(GTK_WIDGET(list));
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
294 contact_manager = purple_contact_manager_get_default();
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
295 gtk_filter_list_model_set_model(list->filter_model,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
296 G_LIST_MODEL(contact_manager));
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
297
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
299 /* Setup the filter connected accounts. */
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
300 account_manager = purple_account_manager_get_default();
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
301 gtk_custom_filter_set_filter_func(list->account_connected_filter,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
302 (GtkCustomFilterFunc)pidgin_contact_list_account_connected_filter,
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
303 list, NULL);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
304 g_signal_connect_object(account_manager, "account-connected",
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
305 G_CALLBACK(pidgin_contact_list_account_connected_cb),
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
306 list, 0);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
307 g_signal_connect_object(account_manager, "account-disconnected",
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
308 G_CALLBACK(pidgin_contact_list_account_disconnected_cb),
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
309 list, 0);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
310
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
311 /* Setup the search filter. */
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
312 gtk_custom_filter_set_filter_func(list->search_filter,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
313 (GtkCustomFilterFunc)pidgin_contact_list_search_filter,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
314 list, NULL);
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 }
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 static void
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 pidgin_contact_list_class_init(PidginContactListClass *klass) {
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 gtk_widget_class_set_template_from_resource(
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 widget_class,
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 "/im/pidgin/Pidgin3/ContactList/widget.ui"
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 );
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
327 filter_model);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
328 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
42237
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
329 account_connected_filter);
57c9deea59c8 Add a custom filter to PidginContactList to filter out disconnected accounts
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
330 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
331 search_filter);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
332
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
333 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
334 search_entry);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
335 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 view);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 gtk_widget_class_bind_template_callback(widget_class,
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
339 pidgin_contact_list_search_changed_cb);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
340 gtk_widget_class_bind_template_callback(widget_class,
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 pidgin_contact_list_avatar_cb);
42025
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
342 gtk_widget_class_bind_template_callback(widget_class,
f37c11d0200a Create new conversation when activating users in the new contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42011
diff changeset
343 pidgin_contact_list_activate_cb);
42052
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
344 gtk_widget_class_bind_template_callback(widget_class,
e575534f450d Add status-messages to PidginContactList
Gary Kramlich <grim@reaperworld.com>
parents: 42025
diff changeset
345 pidgin_contact_list_message_visible_cb);
42185
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
346 gtk_widget_class_bind_template_callback(widget_class,
91d0671d4778 Add the presence primitive and idle time to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
347 pidgin_contact_list_get_primitive_as_string);
42011
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 }
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 /******************************************************************************
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 * API
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 *****************************************************************************/
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 GtkWidget *
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 pidgin_contact_list_new(void) {
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 return g_object_new(PIDGIN_TYPE_CONTACT_LIST, NULL);
bb38b9441073 Create a new PidginContactList widget that shows the PurplePersons that PurpleContactManager is tracking
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 }

mercurial