pidgin/pidginconversation.c

Mon, 30 Jun 2025 23:04:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 30 Jun 2025 23:04:59 -0500
changeset 43273
b2e7a32950ae
parent 43251
8bd7eee2f178
child 43291
a14a8ae209a9
permissions
-rw-r--r--

Update metainfo.xml for the release

And prepare for the next release right away.

Testing Done:
Ran `meson dist`

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

42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
25 #include <libspelling.h>
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
26
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
27 #include <gtksourceview/gtksourceview.h>
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
28
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include <purple.h>
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
31 #include "pidginautoadjustment.h"
42527
1954265c38f0 Implement the member list in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42519
diff changeset
32 #include "pidgincontactinfomenu.h"
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
33 #include "pidginconversation.h"
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
34 #include "pidgininfopane.h"
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
35 #include "pidginmessage.h"
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
36 #include "pidginnotifiable.h"
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 #define PIDGIN_CONVERSATION_DATA ("pidgin-conversation")
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 enum {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_0,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 N_PROPERTIES,
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
44 /* Overrides */
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
45 PROP_NEEDS_ATTENTION = N_PROPERTIES,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
46 PROP_NOTIFICATION_COUNT,
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 };
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42575
diff changeset
48 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 struct _PidginConversation {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 GtkBox parent;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 PurpleConversation *conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
55 GSettings *privacy_settings;
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
56
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GtkWidget *info_pane;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 GtkWidget *history;
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
59 GtkAdjustment *history_adjustment;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
60
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
61 GtkWidget *member_list_search_entry;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
62 GtkCustomFilter *member_list_filter;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
63 GtkCustomSorter *member_list_sorter;
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
64
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
65 GtkWidget *input;
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
66 GtkSourceBuffer *input_buffer;
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
67
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
68 GtkWidget *typing_label;
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
69 GtkWidget *status_label;
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
70
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
71 /* This is a temporary work around to get new message notifications working
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
72 * until we implement Purple.History properly.
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
73 * -- gk 2025-03-11
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
74 */
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
75 guint notification_count;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 };
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
78 static void
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
79 pidgin_conversation_messages_changed_cb(GListModel *model, guint position,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
80 guint removed, guint added,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
81 gpointer data);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 * Helpers
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 static void
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
87 pidgin_conversation_set_notification_count(PidginConversation *conversation,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
88 guint notification_count)
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
89 {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
90 if(conversation->notification_count != notification_count) {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
91 GObject *obj = G_OBJECT(conversation);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
92
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
93 conversation->notification_count = notification_count;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
94
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
95 g_object_freeze_notify(obj);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
96 g_object_notify(obj, "needs-attention");
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
97 g_object_notify(obj, "notification-count");
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
98 g_object_thaw_notify(obj);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
99 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
100 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
101
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
102 static void
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 pidgin_conversation_set_conversation(PidginConversation *conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 PurpleConversation *purple_conversation)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 {
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
106 /* Disconnect our old signal. */
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
107 if(PURPLE_IS_CONVERSATION(conversation->conversation)) {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
108 GListModel *model = NULL;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
109
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
110 model = purple_conversation_get_messages(conversation->conversation);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
111 g_signal_handlers_disconnect_by_func(model,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
112 G_CALLBACK(pidgin_conversation_messages_changed_cb),
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
113 conversation);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
114 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
115
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 if(g_set_object(&conversation->conversation, purple_conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 if(PURPLE_IS_CONVERSATION(purple_conversation)) {
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
118 GListModel *model = NULL;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
119
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 g_object_set_data(G_OBJECT(purple_conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PIDGIN_CONVERSATION_DATA, conversation);
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
122
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
123 model = purple_conversation_get_messages(conversation->conversation);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
124
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
125 g_signal_connect_object(model, "items-changed",
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
126 G_CALLBACK(pidgin_conversation_messages_changed_cb),
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
127 conversation, G_CONNECT_DEFAULT);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 g_object_notify_by_pspec(G_OBJECT(conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 properties[PROP_CONVERSATION]);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
42784
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
135 /* This is used to call g_markup_escape_text for the topic before displaying it
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
136 * in its normal label and the tool tip for that label.
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
137 */
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
138 static char *
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
139 pidgin_conversation_escape_topic(G_GNUC_UNUSED GObject *self,
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
140 const char *topic,
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
141 G_GNUC_UNUSED gpointer data)
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
142 {
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
143 if(topic == NULL) {
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
144 return g_strdup("");
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
145 }
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
146
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
147 return g_markup_escape_text(topic, -1);
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
148 }
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
149
43129
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
150 static char *
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
151 pidgin_conversation_conversation_members_items_changed(G_GNUC_UNUSED PidginConversation *self,
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
152 guint n_members)
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
153 {
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
154 /* TRANSLATORS: This is a label for how many participants are in a
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
155 * conversation.
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
156 */
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
157 const char *format = g_dngettext(GETTEXT_PACKAGE, "%u Member",
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
158 "%u Members", n_members);
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
159
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
160 return g_strdup_printf(format, n_members);
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
161 }
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
162
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
163 /**
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
164 * pidgin_conversation_send_message:
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
165 * @conversation: The instance.
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
166 *
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
167 * Creates a [class@Purple.Message] from the input widgets of @conversation and
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
168 * sends it.
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
169 *
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
170 * Since: 3.0
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
171 */
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
172 static void
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
173 pidgin_conversation_send_message(PidginConversation *conversation) {
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
174 PurpleAccount *account = NULL;
42838
010bd75895d9 Use purple_message_new instead of purple_message_new_outgoing in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42826
diff changeset
175 PurpleContactInfo *info = NULL;
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
176 PurpleMessage *message = NULL;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
177 GtkTextBuffer *buffer = NULL;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
178 GtkTextIter start;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
179 GtkTextIter end;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
180 char *contents = NULL;
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
181 gboolean command_executed = FALSE;
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
182
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
183 account = purple_conversation_get_account(conversation->conversation);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
184
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
185 /* Get the contents from the buffer. */
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
186 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(conversation->input));
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
187 gtk_text_buffer_get_start_iter(buffer, &start);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
188 gtk_text_buffer_get_end_iter(buffer, &end);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
189
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
190 contents = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
191
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
192 if(contents != NULL && contents[0] == '/') {
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
193 PurpleCommandManager *manager = NULL;
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
194
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
195 manager = purple_command_manager_get_default();
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
196 command_executed = purple_command_manager_find_and_execute(manager,
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
197 conversation->conversation,
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
198 contents + 1);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
199 }
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
200
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
201 if(!command_executed) {
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
202 PurpleConversationMember *author = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
203
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
204 /* Create the message. */
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
205 info = purple_account_get_contact_info(account);
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
206 author = purple_conversation_find_or_add_member(conversation->conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
207 info, FALSE, NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
208 message = purple_message_new(author, contents);
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
209
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
210 /* Send the message and clean up. We don't worry about the callback as we
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
211 * don't have anything to do in it right now.
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
212 */
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
213 purple_conversation_send_message_async(conversation->conversation, message,
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
214 NULL, NULL, NULL);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
215
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
216 g_clear_object(&message);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
217 }
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
218
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
219 g_clear_pointer(&contents, g_free);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
220
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
221 gtk_text_buffer_set_text(buffer, "", -1);
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
222 }
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
223
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
224 static gboolean
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
225 pidgin_conversation_get_needs_attention(PidginConversation *conversation)
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
226 {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
227 return conversation->notification_count > 0;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
228 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
229
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
230 static guint
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
231 pidgin_conversation_get_notification_count(PidginConversation *conversation) {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
232 return conversation->notification_count;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
233 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
234
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 * Callbacks
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 *****************************************************************************/
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
238 static void
43193
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
239 pidgin_conversation_messages_changed_cb(GListModel *model,
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
240 guint position,
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
241 G_GNUC_UNUSED guint removed,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
242 guint added,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
243 gpointer data)
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
244 {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
245 PidginConversation *conversation = data;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
246 guint current = conversation->notification_count;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
247
43193
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
248 for(guint i = position; i < position + added; i++) {
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
249 PurpleMessage *message = NULL;
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
250
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
251 message = g_list_model_get_item(model, i);
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
252 if(!purple_message_get_event(message)) {
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
253 current += 1;
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
254 }
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
255 g_clear_object(&message);
02f50223f45a Make the message notifications ignore events
Gary Kramlich <grim@reaperworld.com>
parents: 43192
diff changeset
256 }
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
257
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
258 pidgin_conversation_set_notification_count(conversation, current);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
259 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
260
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
261 static char *
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
262 pidgin_conversation_get_status_label(G_GNUC_UNUSED PidginConversation *conversation,
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
263 GError *error, gboolean online)
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
264 {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
265 const char *message = NULL;
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
266
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
267 if(error != NULL) {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
268 message = error->message;
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
269 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
270
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
271 if(purple_strempty(message) && !online) {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
272 message = _("Conversation offline");
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
273 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
274
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
275 if(purple_strempty(message)) {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
276 message = "";
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
277 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
278
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
279 return g_strdup(message);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
280 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
281
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
282 static GtkWidget *
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
283 pidgin_conversation_get_status_page(PidginConversation *conversation,
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
284 GError *error, gboolean online)
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
285 {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
286 if(error != NULL || !online) {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
287 return g_object_ref(conversation->status_label);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
288 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
289
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
290 return g_object_ref(conversation->typing_label);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
291 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
292
42885
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
293 static void
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
294 pidgin_conversation_input_insert_text_cb(G_GNUC_UNUSED GtkTextBuffer *buffer,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
295 G_GNUC_UNUSED const GtkTextIter *iter,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
296 G_GNUC_UNUSED char *text,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
297 G_GNUC_UNUSED int length,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
298 gpointer data)
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
299 {
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
300 PidginConversation *conversation = data;
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
301
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
302 if(g_settings_get_boolean(conversation->privacy_settings,
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
303 "send-typing-notifications"))
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
304 {
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
305 purple_conversation_set_typing_state(conversation->conversation,
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
306 PURPLE_TYPING_STATE_TYPING);
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
307 }
42885
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
308 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
309
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
310 static void
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
311 pidgin_conversation_input_delete_range_cb(GtkTextBuffer *buffer,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
312 G_GNUC_UNUSED const GtkTextIter *start,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
313 G_GNUC_UNUSED const GtkTextIter *end,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
314 gpointer data)
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
315 {
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
316 PidginConversation *conversation = data;
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
317
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
318 if(gtk_text_buffer_get_char_count(buffer) == 0) {
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
319 if(g_settings_get_boolean(conversation->privacy_settings,
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
320 "send-typing-notifications"))
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
321 {
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
322 purple_conversation_set_typing_state(conversation->conversation,
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
323 PURPLE_TYPING_STATE_NONE);
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
324 }
42885
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
325 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
326 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
327
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
328 static gboolean
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
329 pidgin_conversation_input_key_pressed_cb(G_GNUC_UNUSED GtkEventControllerKey *self,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
330 guint keyval,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
331 G_GNUC_UNUSED guint keycode,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
332 GdkModifierType state,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
333 gpointer data)
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
334 {
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 PidginConversation *conversation = data;
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
336 gboolean handled = TRUE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
337
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
338 if(keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter) {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
339 if(state == GDK_SHIFT_MASK || state == GDK_CONTROL_MASK) {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
340 return FALSE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
341 }
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
343 pidgin_conversation_send_message(conversation);
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
344 } else if(keyval == GDK_KEY_Page_Up) {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
345 pidgin_auto_adjustment_decrement(PIDGIN_AUTO_ADJUSTMENT(conversation->history_adjustment));
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
346 } else if(keyval == GDK_KEY_Page_Down) {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
347 pidgin_auto_adjustment_increment(PIDGIN_AUTO_ADJUSTMENT(conversation->history_adjustment));
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
348 } else {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
349 handled = FALSE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
350 }
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
352 return handled;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 pidgin_conversation_detach(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 if(PURPLE_IS_CONVERSATION(conversation->conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 gpointer us = NULL;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 us = g_object_get_data(G_OBJECT(conversation->conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 PIDGIN_CONVERSATION_DATA);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 if(conversation == us) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 g_object_set_data(G_OBJECT(conversation->conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 PIDGIN_CONVERSATION_DATA, NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
370 static void
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
371 pidgin_conversation_members_search_changed_cb(GtkSearchEntry *self,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
372 gpointer data)
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
373 {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
374 PidginConversation *conversation = data;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
375
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
376 gtk_filter_changed(GTK_FILTER(conversation->member_list_filter),
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
377 GTK_FILTER_CHANGE_DIFFERENT);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
378
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
379 /* Make sure the search widget has focus, this allows the user to clear a
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
380 * search that has filtered out every item in the list via their keyboard.
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
381 */
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
382 if(!gtk_widget_has_focus(GTK_WIDGET(self))) {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
383 gtk_widget_grab_focus(GTK_WIDGET(self));
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
384 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
385 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
386
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
387 static int
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
388 pidgin_conversation_member_list_sort(gconstpointer a, gconstpointer b,
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
389 G_GNUC_UNUSED gpointer data)
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
390 {
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
391 PurpleConversationMember *member_a = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
392 PurpleConversationMember *member_b = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
393
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
394 member_a = PURPLE_CONVERSATION_MEMBER((gpointer)a);
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
395 member_b = PURPLE_CONVERSATION_MEMBER((gpointer)b);
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
396
43201
1889c68bc5a0 Some minor clean up in Pidgin.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 43193
diff changeset
397 return purple_conversation_member_compare(member_a, member_b);
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
398 }
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
399
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
400 static gboolean
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
401 pidgin_conversation_member_list_filter(GObject *item, gpointer data) {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
402 PidginConversation *conversation = data;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
403 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(item);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
404 const char *needle = NULL;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
405
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
406 needle = gtk_editable_get_text(GTK_EDITABLE(conversation->member_list_search_entry));
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
407
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
408 return purple_conversation_member_matches(member, needle);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
409 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
410
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
411 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
412 pidgin_conversation_message_setup(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
413 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
414 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
415 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
416 gtk_list_item_set_child(GTK_LIST_ITEM(object), pidgin_message_new(NULL));
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
417 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
418
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
419 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
420 pidgin_conversation_message_bind(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
421 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
422 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
423 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
424 PurpleMessage *purple_message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
425 GtkListItem *item = GTK_LIST_ITEM(object);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
426 GtkWidget *pidgin_message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
427
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
428 purple_message = gtk_list_item_get_item(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
429 pidgin_message = gtk_list_item_get_child(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
430
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
431 pidgin_message_set_message(PIDGIN_MESSAGE(pidgin_message), purple_message);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
432 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
433
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
434 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
435 pidgin_conversation_message_unbind(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
436 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
437 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
438 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
439 GtkListItem *item = GTK_LIST_ITEM(object);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
440 GtkWidget *message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
441
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
442 message = gtk_list_item_get_child(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
443
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
444 pidgin_message_set_message(PIDGIN_MESSAGE(message), NULL);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
445 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
446
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
447 static void
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
448 pidgin_conversation_map_cb(GtkWidget *self, G_GNUC_UNUSED gpointer data) {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
449 pidgin_conversation_set_notification_count(PIDGIN_CONVERSATION(self), 0);
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
450 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
451
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
452 /******************************************************************************
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
453 * PidginNotifiable Implementation
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
454 *****************************************************************************/
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
455 static void
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
456 pidgin_conversation_notifiable_init(G_GNUC_UNUSED PidginNotifiableInterface *iface)
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
457 {
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
458 }
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
459
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 * GObject Implementation
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 *****************************************************************************/
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
463 G_DEFINE_FINAL_TYPE_WITH_CODE(PidginConversation,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
464 pidgin_conversation,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
465 GTK_TYPE_BOX,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
466 G_IMPLEMENT_INTERFACE(PIDGIN_TYPE_NOTIFIABLE,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
467 pidgin_conversation_notifiable_init))
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
468
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 pidgin_conversation_dispose(GObject *obj) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
472
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 g_clear_object(&conversation->conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 G_OBJECT_CLASS(pidgin_conversation_parent_class)->dispose(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 static void
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
481 pidgin_conversation_finalize(GObject *obj) {
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
482 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
483
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
484 g_clear_object(&conversation->privacy_settings);
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
485
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
486 G_OBJECT_CLASS(pidgin_conversation_parent_class)->finalize(obj);
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
487 }
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
488
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
489 static void
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
490 pidgin_conversation_get_property(GObject *obj, guint param_id, GValue *value,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
494
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
495 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
496 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497 g_value_set_object(value,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 pidgin_conversation_get_conversation(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
499 break;
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
500 case PROP_NEEDS_ATTENTION:
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
501 g_value_set_boolean(value,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
502 pidgin_conversation_get_needs_attention(conversation));
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
503 break;
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
504 case PROP_NOTIFICATION_COUNT:
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
505 g_value_set_uint(value,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
506 pidgin_conversation_get_notification_count(conversation));
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
507 break;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
512 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
515 pidgin_conversation_set_property(GObject *obj, guint param_id,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
516 const GValue *value, GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
520 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 pidgin_conversation_set_conversation(conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523 g_value_get_object(value));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
524 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
529 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
532 pidgin_conversation_init(PidginConversation *conversation) {
43201
1889c68bc5a0 Some minor clean up in Pidgin.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 43193
diff changeset
533 GMenuModel *menu = NULL;
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
534 SpellingChecker *checker = NULL;
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
535 SpellingTextBufferAdapter *adapter = NULL;
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
536
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537 gtk_widget_init_template(GTK_WIDGET(conversation));
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
538
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
539 conversation->privacy_settings =
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
540 g_settings_new_with_backend("im.pidgin.Pidgin3.Privacy",
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
541 purple_core_get_settings_backend());
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
542
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
543 gtk_custom_sorter_set_sort_func(conversation->member_list_sorter,
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
544 pidgin_conversation_member_list_sort,
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
545 NULL, NULL);
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
546
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
547 gtk_custom_filter_set_filter_func(conversation->member_list_filter,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
548 (GtkCustomFilterFunc)pidgin_conversation_member_list_filter,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
549 conversation, NULL);
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
550
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
551 /* Create the spell checking adapter. */
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
552 checker = spelling_checker_get_default();
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
553 adapter = spelling_text_buffer_adapter_new(conversation->input_buffer,
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
554 checker);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
555
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
556 /* Add the spell checking menu items and actions. */
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
557 menu = spelling_text_buffer_adapter_get_menu_model(adapter);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
558 gtk_text_view_set_extra_menu(GTK_TEXT_VIEW(conversation->input), menu);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
559 gtk_widget_insert_action_group(conversation->input, "spelling",
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
560 G_ACTION_GROUP(adapter));
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
561 spelling_text_buffer_adapter_set_enabled(adapter, TRUE);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
562
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
563 g_clear_object(&adapter);
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
564
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
565 /* Connect to our map signal to reset the notification-count property. */
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
566 g_signal_connect(conversation, "map",
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
567 G_CALLBACK(pidgin_conversation_map_cb), NULL);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
569
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
571 pidgin_conversation_class_init(PidginConversationClass *klass) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 obj_class->dispose = pidgin_conversation_dispose;
43251
8bd7eee2f178 Create a Privacy preference page with the send typing notification preference
Gary Kramlich <grim@reaperworld.com>
parents: 43201
diff changeset
576 obj_class->finalize = pidgin_conversation_finalize;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577 obj_class->get_property = pidgin_conversation_get_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 obj_class->set_property = pidgin_conversation_set_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580 /**
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 * PidginConversation:conversation:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583 * The [class@Purple.Conversation] that this conversation is displaying.
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 *
42620
72178a341eb8 Remove minor versions from Since tags in Pidgin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42584
diff changeset
585 * Since: 3.0
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586 */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587 properties[PROP_CONVERSATION] = g_param_spec_object(
43072
a59a119b74f5 Remove nick and blurb from Pidgin properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 43058
diff changeset
588 "conversation", NULL, NULL,
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
589 PURPLE_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
590 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593
43192
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
594 g_object_class_override_property(obj_class, PROP_NEEDS_ATTENTION,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
595 "needs-attention");
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
596 g_object_class_override_property(obj_class, PROP_NOTIFICATION_COUNT,
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
597 "notification-count");
e690274aee75 Implement message notifications is a hacky way
Gary Kramlich <grim@reaperworld.com>
parents: 43186
diff changeset
598
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
599 /* Template stuff. */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
600 gtk_widget_class_set_template_from_resource(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 widget_class,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
602 "/im/pidgin/Pidgin3/Conversations/conversation.ui"
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
603 );
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
604
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
605 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606 info_pane);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
607 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
608 history);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
609 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
610 history_adjustment);
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
611 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
612 member_list_search_entry);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
613 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
614 member_list_filter);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
615 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
616 member_list_sorter);
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
617 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
618 input);
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
619 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
620 input_buffer);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
621 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
622 typing_label);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
623 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
624 status_label);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
625
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626 gtk_widget_class_bind_template_callback(widget_class,
42784
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
627 pidgin_conversation_escape_topic);
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
628 gtk_widget_class_bind_template_callback(widget_class,
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
629 pidgin_conversation_members_search_changed_cb);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
630 gtk_widget_class_bind_template_callback(widget_class,
43129
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
631 pidgin_conversation_conversation_members_items_changed);
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
632 gtk_widget_class_bind_template_callback(widget_class,
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
633 pidgin_conversation_get_status_label);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
634 gtk_widget_class_bind_template_callback(widget_class,
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
635 pidgin_conversation_get_status_page);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
636 gtk_widget_class_bind_template_callback(widget_class,
42885
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
637 pidgin_conversation_input_insert_text_cb);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
638 gtk_widget_class_bind_template_callback(widget_class,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
639 pidgin_conversation_input_delete_range_cb);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
640 gtk_widget_class_bind_template_callback(widget_class,
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
641 pidgin_conversation_input_key_pressed_cb);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
642 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
643 pidgin_conversation_message_setup);
42380
165c0b7f3860 Escape message content in Pidgin before displaying it
Gary Kramlich <grim@reaperworld.com>
parents: 42350
diff changeset
644 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
645 pidgin_conversation_message_bind);
42531
82fffff36df6 If a message is an action format it with italics
Gary Kramlich <grim@reaperworld.com>
parents: 42527
diff changeset
646 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
647 pidgin_conversation_message_unbind);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
649
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
650 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
651 * API
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
652 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
653 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
654 pidgin_conversation_new(PurpleConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
655 g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
656
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
657 return g_object_new(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
658 PIDGIN_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
659 "conversation", conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
660 NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
661 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
663 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
664 pidgin_conversation_from_purple_conversation(PurpleConversation *conversation)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
665 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
666 g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
667
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
668 return g_object_get_data(G_OBJECT(conversation), PIDGIN_CONVERSATION_DATA);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
670
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
671 PurpleConversation *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
672 pidgin_conversation_get_conversation(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
673 g_return_val_if_fail(PIDGIN_IS_CONVERSATION(conversation), NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
674
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
675 return conversation->conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
676 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
677
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
678 void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
679 pidgin_conversation_close(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
680 g_return_if_fail(PIDGIN_IS_CONVERSATION(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
681
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
682 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
683 }

mercurial