pidgin/pidginconversation.c

Fri, 21 Feb 2025 00:03:24 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 21 Feb 2025 00:03:24 -0600
changeset 43186
f869ebb47d88
parent 43173
399e2538f319
child 43192
e690274aee75
permissions
-rw-r--r--

Add basic support for libspelling

This does the bare minimum to implement libspelling to get things going.

Testing Done:
Built locally as well as the flatpak and verified that my horrible typing skills were pointed out.

Bugs closed: PIDGIN-18054

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

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"
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 #define PIDGIN_CONVERSATION_DATA ("pidgin-conversation")
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 enum {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_0,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 N_PROPERTIES,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 };
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42575
diff changeset
44 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 struct _PidginConversation {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 GtkBox parent;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PurpleConversation *conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 GtkWidget *info_pane;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 GtkWidget *history;
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
53 GtkAdjustment *history_adjustment;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
54
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
55 GtkWidget *member_list_search_entry;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
56 GtkCustomFilter *member_list_filter;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
57 GtkCustomSorter *member_list_sorter;
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
58
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
59 GtkWidget *input;
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
60 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
61
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
62 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
63 GtkWidget *status_label;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 };
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
42575
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42531
diff changeset
66 G_DEFINE_FINAL_TYPE(PidginConversation, pidgin_conversation, GTK_TYPE_BOX)
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 * Helpers
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 pidgin_conversation_set_conversation(PidginConversation *conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 PurpleConversation *purple_conversation)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 if(g_set_object(&conversation->conversation, purple_conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 if(PURPLE_IS_CONVERSATION(purple_conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 g_object_set_data(G_OBJECT(purple_conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 PIDGIN_CONVERSATION_DATA, conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_object_notify_by_pspec(G_OBJECT(conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 properties[PROP_CONVERSATION]);
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 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
42784
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
86 /* 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
87 * 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
88 */
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
89 static char *
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
90 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
91 const char *topic,
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
92 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
93 {
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
94 if(topic == NULL) {
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
95 return g_strdup("");
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
96 }
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
97
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
98 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
99 }
909476a9e569 Escape the topic and its tooltip using g_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents: 42783
diff changeset
100
43129
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
101 static char *
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
102 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
103 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
104 {
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
105 /* 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
106 * conversation.
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
107 */
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
108 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
109 "%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
110
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
111 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
112 }
c72c9ce63177 Add a count of the members above the member list in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 43100
diff changeset
113
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
114 /**
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
115 * pidgin_conversation_send_message:
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
116 * @conversation: The instance.
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
117 *
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
118 * 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
119 * sends it.
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
120 *
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
121 * Since: 3.0
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
122 */
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
123 static void
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
124 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
125 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
126 PurpleContactInfo *info = NULL;
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
127 PurpleMessage *message = NULL;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
128 GtkTextBuffer *buffer = NULL;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
129 GtkTextIter start;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
130 GtkTextIter end;
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
131 char *contents = NULL;
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
132 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
133
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
134 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
135
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
136 /* 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
137 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
138 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
139 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
140
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
141 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
142
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
143 if(contents != NULL && contents[0] == '/') {
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
144 PurpleCommandManager *manager = NULL;
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
145
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
146 manager = purple_command_manager_get_default();
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
147 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
148 conversation->conversation,
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
149 contents + 1);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
150 }
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
151
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
152 if(!command_executed) {
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
153 PurpleConversationMember *author = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
154
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
155 /* Create the message. */
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
156 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
157 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
158 info, FALSE, NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43099
diff changeset
159 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
160
43058
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
161 /* 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
162 * 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
163 */
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
164 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
165 NULL, NULL, NULL);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
166
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
167 g_clear_object(&message);
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
168 }
7b3b26faf6ed Add very basic command support to Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42905
diff changeset
169
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
170 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
171
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
172 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
173 }
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
174
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 * Callbacks
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 *****************************************************************************/
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
178 static char *
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
179 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
180 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
181 {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
182 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
183
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
184 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
185 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
186 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
187
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
188 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
189 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
190 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
191
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
192 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
193 message = "";
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
194 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
195
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
196 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
197 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
198
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
199 static GtkWidget *
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
200 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
201 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
202 {
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
203 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
204 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
205 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
206
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
207 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
208 }
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
209
42885
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
210 static void
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
211 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
212 G_GNUC_UNUSED const GtkTextIter *iter,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
213 G_GNUC_UNUSED char *text,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
214 G_GNUC_UNUSED int length,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
215 gpointer data)
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
216 {
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
217 PidginConversation *conversation = data;
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
218
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
219 purple_conversation_set_typing_state(conversation->conversation,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
220 PURPLE_TYPING_STATE_TYPING);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
221 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
222
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
223 static void
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
224 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
225 G_GNUC_UNUSED const GtkTextIter *start,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
226 G_GNUC_UNUSED const GtkTextIter *end,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
227 gpointer data)
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
228 {
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
229 PidginConversation *conversation = data;
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
230
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
231 if(gtk_text_buffer_get_char_count(buffer) == 0) {
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
232 purple_conversation_set_typing_state(conversation->conversation,
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
233 PURPLE_TYPING_STATE_NONE);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
234 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
235 }
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
236
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
237 static gboolean
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
238 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
239 guint keyval,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
240 G_GNUC_UNUSED guint keycode,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
241 GdkModifierType state,
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
242 gpointer data)
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
243 {
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 PidginConversation *conversation = data;
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
245 gboolean handled = TRUE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
246
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
247 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
248 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
249 return FALSE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
250 }
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251
42812
4d48abf72b94 Update Pidgin.Conversation to use Purple.Conversation.send_message_async
Gary Kramlich <grim@reaperworld.com>
parents: 42801
diff changeset
252 pidgin_conversation_send_message(conversation);
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
253 } 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
254 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
255 } 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
256 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
257 } else {
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
258 handled = FALSE;
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
259 }
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
42447
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
261 return handled;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 pidgin_conversation_detach(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 if(PURPLE_IS_CONVERSATION(conversation->conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 gpointer us = NULL;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 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
270 PIDGIN_CONVERSATION_DATA);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 if(conversation == us) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 g_object_set_data(G_OBJECT(conversation->conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 PIDGIN_CONVERSATION_DATA, NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
279 static void
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
280 pidgin_conversation_members_search_changed_cb(GtkSearchEntry *self,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
281 gpointer data)
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
282 {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
283 PidginConversation *conversation = data;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
284
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
285 gtk_filter_changed(GTK_FILTER(conversation->member_list_filter),
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
286 GTK_FILTER_CHANGE_DIFFERENT);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
287
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
288 /* 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
289 * 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
290 */
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
291 if(!gtk_widget_has_focus(GTK_WIDGET(self))) {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
292 gtk_widget_grab_focus(GTK_WIDGET(self));
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
293 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
294 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
295
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
296 static int
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
297 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
298 G_GNUC_UNUSED gpointer data)
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
299 {
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
300 PurpleConversationMember *member_a = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
301 PurpleConversationMember *member_b = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
302 PurpleContactInfo *info_a = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
303 PurpleContactInfo *info_b = NULL;
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
304
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
305 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
306 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
307
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
308 info_a = purple_conversation_member_get_contact_info(member_a);
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
309 info_b = purple_conversation_member_get_contact_info(member_b);
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
310
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
311 return purple_contact_info_compare(info_a, info_b);
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
312 }
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
313
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
314 static gboolean
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
315 pidgin_conversation_member_list_filter(GObject *item, gpointer data) {
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
316 PidginConversation *conversation = data;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
317 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(item);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
318 const char *needle = NULL;
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
319
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
320 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
321
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
322 return purple_conversation_member_matches(member, needle);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
323 }
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
324
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
325 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
326 pidgin_conversation_message_setup(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
327 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
328 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
329 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
330 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
331 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
332
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
333 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
334 pidgin_conversation_message_bind(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
335 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
336 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
337 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
338 PurpleMessage *purple_message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
339 GtkListItem *item = GTK_LIST_ITEM(object);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
340 GtkWidget *pidgin_message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
341
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
342 purple_message = gtk_list_item_get_item(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
343 pidgin_message = gtk_list_item_get_child(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
344
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
345 pidgin_message_set_message(PIDGIN_MESSAGE(pidgin_message), purple_message);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
346 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
347
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
348 static void
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
349 pidgin_conversation_message_unbind(G_GNUC_UNUSED GtkSignalListItemFactory *self,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
350 GObject *object,
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
351 G_GNUC_UNUSED gpointer data)
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
352 {
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
353 GtkListItem *item = GTK_LIST_ITEM(object);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
354 GtkWidget *message = NULL;
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
355
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
356 message = gtk_list_item_get_child(item);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
357
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
358 pidgin_message_set_message(PIDGIN_MESSAGE(message), NULL);
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
359 }
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
360
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 * GObject Implementation
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 pidgin_conversation_dispose(GObject *obj) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
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 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 g_clear_object(&conversation->conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 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
373 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 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
377 GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 g_value_set_object(value,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 pidgin_conversation_get_conversation(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 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
388 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 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
394 const GValue *value, GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 pidgin_conversation_set_conversation(conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 g_value_get_object(value));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 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
405 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 pidgin_conversation_init(PidginConversation *conversation) {
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
411 SpellingChecker *checker = NULL;
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
412 SpellingTextBufferAdapter *adapter = NULL;
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
413 GMenuModel *menu = NULL;
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
414
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 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
416
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
417 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
418 pidgin_conversation_member_list_sort,
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
419 NULL, NULL);
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
420
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
421 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
422 (GtkCustomFilterFunc)pidgin_conversation_member_list_filter,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
423 conversation, NULL);
43186
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
424
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
425 /* Create the spell checking adapter. */
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
426 checker = spelling_checker_get_default();
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
427 adapter = spelling_text_buffer_adapter_new(conversation->input_buffer,
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
428 checker);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
429
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
430 /* Add the spell checking menu items and actions. */
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
431 menu = spelling_text_buffer_adapter_get_menu_model(adapter);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
432 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
433 gtk_widget_insert_action_group(conversation->input, "spelling",
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
434 G_ACTION_GROUP(adapter));
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
435 spelling_text_buffer_adapter_set_enabled(adapter, TRUE);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
436
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
437 g_clear_object(&adapter);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 pidgin_conversation_class_init(PidginConversationClass *klass) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445 obj_class->dispose = pidgin_conversation_dispose;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 obj_class->get_property = pidgin_conversation_get_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 obj_class->set_property = pidgin_conversation_set_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 /**
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 * PidginConversation:conversation:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 * 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
453 *
42620
72178a341eb8 Remove minor versions from Since tags in Pidgin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42584
diff changeset
454 * Since: 3.0
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455 */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 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
457 "conversation", NULL, NULL,
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 PURPLE_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 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
460
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 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
462
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 /* Template stuff. */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 gtk_widget_class_set_template_from_resource(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 widget_class,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 "/im/pidgin/Pidgin3/Conversations/conversation.ui"
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 );
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 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
470 info_pane);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 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
472 history);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
473 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
474 history_adjustment);
3f1004d7772a Replace TalkatuEditor in PidginConversation with a basic GtkTextView
Gary Kramlich <grim@reaperworld.com>
parents: 42380
diff changeset
475 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
476 member_list_search_entry);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
477 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
478 member_list_filter);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
479 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
480 member_list_sorter);
42783
e61721a750e9 Add support for sorting the memberlist in conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42620
diff changeset
481 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
482 input);
43099
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
483 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
484 input_buffer);
f869ebb47d88 Add basic support for libspelling
Gary Kramlich <grim@reaperworld.com>
parents: 43173
diff changeset
485 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
486 typing_label);
60174e318ecc Add a status label to conversations to show online and error status
Gary Kramlich <grim@reaperworld.com>
parents: 43094
diff changeset
487 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
488 status_label);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
490 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
491 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
492 gtk_widget_class_bind_template_callback(widget_class,
43173
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
493 pidgin_conversation_members_search_changed_cb);
399e2538f319 Implement searching the conversation members
Gary Kramlich <grim@reaperworld.com>
parents: 43163
diff changeset
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501 pidgin_conversation_input_insert_text_cb);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
502 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
503 pidgin_conversation_input_delete_range_cb);
9b0cae94f406 Set Purple.Conversation:typing when appropriate in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42838
diff changeset
504 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
505 pidgin_conversation_input_key_pressed_cb);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
506 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
507 pidgin_conversation_message_setup);
42380
165c0b7f3860 Escape message content in Pidgin before displaying it
Gary Kramlich <grim@reaperworld.com>
parents: 42350
diff changeset
508 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
509 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
510 gtk_widget_class_bind_template_callback(widget_class,
43093
27f816a512af Add a PidginMessage widget
Gary Kramlich <grim@reaperworld.com>
parents: 43072
diff changeset
511 pidgin_conversation_message_unbind);
42301
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 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
515 * API
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
516 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518 pidgin_conversation_new(PurpleConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519 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
520
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521 return g_object_new(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 PIDGIN_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523 "conversation", conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
524 NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 pidgin_conversation_from_purple_conversation(PurpleConversation *conversation)
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 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
531
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
532 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
533 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535 PurpleConversation *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536 pidgin_conversation_get_conversation(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537 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
538
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539 return conversation->conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
542 void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
543 pidgin_conversation_close(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 g_return_if_fail(PIDGIN_IS_CONVERSATION(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
547 }

mercurial