pidgin/pidginconversation.c

Thu, 12 Oct 2023 22:31:22 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Thu, 12 Oct 2023 22:31:22 -0500
changeset 42352
1c53950f9052
parent 42350
0d5319e4b836
child 42380
165c0b7f3860
permissions
-rw-r--r--

Migrate from GtkFileChooserNative to GtkFileDialog

Testing Done:
Compiled, and opened a few dialogs from the demo protocol.

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

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
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
27 #include <talkatu.h>
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
28
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
29 #include "pidgincolor.h"
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
30 #include "pidginconversation.h"
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
31 #include "pidgininfopane.h"
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 #define PIDGIN_CONVERSATION_DATA ("pidgin-conversation")
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 enum {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PROP_0,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PROP_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 N_PROPERTIES,
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 static GParamSpec *properties[N_PROPERTIES] = {NULL,};
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 struct _PidginConversation {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 GtkBox parent;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PurpleConversation *conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 GtkWidget *info_pane;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GtkWidget *editor;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 GtkWidget *history;
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
50 GtkNoSelection *history_selection;
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 };
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 G_DEFINE_TYPE(PidginConversation, pidgin_conversation, GTK_TYPE_BOX)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 * Helpers
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 pidgin_conversation_set_conversation(PidginConversation *conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PurpleConversation *purple_conversation)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 if(g_set_object(&conversation->conversation, purple_conversation)) {
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
63 GListModel *model = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
64
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 if(PURPLE_IS_CONVERSATION(purple_conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 g_object_set_data(G_OBJECT(purple_conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PIDGIN_CONVERSATION_DATA, conversation);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
68 model = purple_conversation_get_messages(purple_conversation);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
71 gtk_no_selection_set_model(conversation->history_selection, model);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
72
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 pidgin_info_pane_set_conversation(PIDGIN_INFO_PANE(conversation->info_pane),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 purple_conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 g_object_notify_by_pspec(G_OBJECT(conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 properties[PROP_CONVERSATION]);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
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
42350
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
81 /**
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
82 * pidgin_conversation_set_tooltip_for_timestamp: (skip)
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
83 * @tooltip: The tooltip to update.
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
84 * @timestamp: The timestamp to set.
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
85 *
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
86 * Updates @tooltip to display @timestamp. This is meant to be called from
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
87 * a GtkWidget::query-tooltip signal and its return value should be returned
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
88 * from that handler.
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
89 *
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
90 * Returns: %TRUE if a tooltip was set, otherwise %FALSE.
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
91 *
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
92 * Since: 3.0.0
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
93 */
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
94 static gboolean
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
95 pidgin_conversation_set_tooltip_for_timestamp(GtkTooltip *tooltip,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
96 GDateTime *timestamp)
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
97 {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
98 GDateTime *local = NULL;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
99 char *text = NULL;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
100
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
101 if(timestamp == NULL) {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
102 return FALSE;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
103 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
104
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
105 local = g_date_time_to_local(timestamp);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
106 text = g_date_time_format(local, "%c");
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
107 g_clear_pointer(&local, g_date_time_unref);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
108
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
109 gtk_tooltip_set_text(tooltip, text);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
110 g_clear_pointer(&text, g_free);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
111
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
112 return TRUE;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
113 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
114
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 * Callbacks
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 pidgin_conversation_send_message_cb(TalkatuInput *input, gpointer data) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 PidginConversation *conversation = data;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 const char *contents = NULL;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 contents = talkatu_message_get_contents(TALKATU_MESSAGE(input));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 purple_conversation_send(conversation->conversation, contents);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 talkatu_message_set_contents(TALKATU_MESSAGE(input), "");
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 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 pidgin_conversation_detach(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 if(PURPLE_IS_CONVERSATION(conversation->conversation)) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 gpointer us = NULL;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 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
136 PIDGIN_CONVERSATION_DATA);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 if(conversation == us) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 g_object_set_data(G_OBJECT(conversation->conversation),
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 PIDGIN_CONVERSATION_DATA, NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
145 static PangoAttrList *
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
146 pidgin_conversation_get_author_attributes(G_GNUC_UNUSED GObject *self,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
147 PurpleMessage *message,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
148 G_GNUC_UNUSED gpointer data)
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
149 {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
150 const char *author = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
151 const char *custom_color = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
152 GdkRGBA rgba;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
153 PangoAttrList *attrs = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
154 gboolean color_valid = FALSE;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
155
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
156 if(!PURPLE_IS_MESSAGE(message)) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
157 return NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
158 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
159
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
160 author = purple_message_get_author_alias(message);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
161 if(purple_strempty(author)) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
162 author = purple_message_get_author(message);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
163 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
164
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
165 custom_color = purple_message_get_author_name_color(message);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
166 if(!purple_strempty(custom_color)) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
167 color_valid = gdk_rgba_parse(&rgba, custom_color);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
168 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
169
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
170 if(!color_valid) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
171 pidgin_color_calculate_for_text(author, &rgba);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
172 color_valid = TRUE;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
173 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
174
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
175 attrs = pango_attr_list_new();
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
176
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
177 if(color_valid) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
178 PangoAttribute *attr = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
179
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
180 attr = pango_attr_foreground_new(0xFFFF * rgba.red,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
181 0xFFFF * rgba.green,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
182 0xFFFF * rgba.blue);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
183 pango_attr_list_insert(attrs, attr);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
184 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
185
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
186 return attrs;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
187 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
188
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
189 static char *
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
190 pidgin_converation_get_timestamp_string(G_GNUC_UNUSED GObject *self,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
191 PurpleMessage *message,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
192 G_GNUC_UNUSED gpointer data)
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
193 {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
194 GDateTime *timestamp = NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
195
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
196 if(!PURPLE_IS_MESSAGE(message)) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
197 return NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
198 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
199
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
200 timestamp = purple_message_get_timestamp(message);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
201 if(timestamp != NULL) {
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
202 return g_date_time_format(timestamp, "%I:%M %p");
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
203 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
204
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
205 return NULL;
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
206 }
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
207
42350
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
208 static gboolean
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
209 pidgin_conversation_query_tooltip_timestamp_cb(G_GNUC_UNUSED GtkWidget *self,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
210 G_GNUC_UNUSED gint x,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
211 G_GNUC_UNUSED gint y,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
212 G_GNUC_UNUSED gboolean keyboard_mode,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
213 GtkTooltip *tooltip,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
214 gpointer data)
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
215 {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
216
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
217 PurpleMessage *message = gtk_list_item_get_item(data);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
218 GDateTime *timestamp = NULL;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
219
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
220 if(!PURPLE_IS_MESSAGE(message)) {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
221 return FALSE;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
222 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
223
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
224 timestamp = purple_message_get_timestamp(message);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
225
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
226 return pidgin_conversation_set_tooltip_for_timestamp(tooltip, timestamp);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
227 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
228
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
229 static gboolean
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
230 pidgin_conversation_query_tooltip_edited_cb(G_GNUC_UNUSED GtkWidget *self,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
231 G_GNUC_UNUSED gint x,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
232 G_GNUC_UNUSED gint y,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
233 G_GNUC_UNUSED gboolean keyboard_mode,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
234 GtkTooltip *tooltip,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
235 gpointer data)
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
236 {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
237 PurpleMessage *message = gtk_list_item_get_item(data);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
238 GDateTime *timestamp = NULL;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
239
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
240 if(!PURPLE_IS_MESSAGE(message)) {
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
241 return FALSE;
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
242 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
243
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
244 timestamp = purple_message_get_edited_at(message);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
245
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
246 return pidgin_conversation_set_tooltip_for_timestamp(tooltip, timestamp);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
247 }
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
248
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 /******************************************************************************
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 * GObject Implementation
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 pidgin_conversation_dispose(GObject *obj) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 g_clear_object(&conversation->conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 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
261 }
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 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 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
265 GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
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 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 g_value_set_object(value,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 pidgin_conversation_get_conversation(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 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
276 break;
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 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 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
282 const GValue *value, GParamSpec *pspec)
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 switch(param_id) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 case PROP_CONVERSATION:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 pidgin_conversation_set_conversation(conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 g_value_get_object(value));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 default:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 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
293 break;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 pidgin_conversation_init(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 gtk_widget_init_template(GTK_WIDGET(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 static void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 pidgin_conversation_class_init(PidginConversationClass *klass) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 obj_class->dispose = pidgin_conversation_dispose;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 obj_class->get_property = pidgin_conversation_get_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 obj_class->set_property = pidgin_conversation_set_property;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 /**
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 * PidginConversation:conversation:
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 * 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
315 *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 * Since: 3.0.0
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 properties[PROP_CONVERSATION] = g_param_spec_object(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 "conversation", "conversation",
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 "The purple conversation this widget is for.",
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 PURPLE_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 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
323
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 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
325
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 /* Template stuff. */
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 gtk_widget_class_set_template_from_resource(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 widget_class,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 "/im/pidgin/Pidgin3/Conversations/conversation.ui"
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 );
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 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
333 info_pane);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 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
335 editor);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 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
337 history);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
338 gtk_widget_class_bind_template_child(widget_class, PidginConversation,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
339 history_selection);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 gtk_widget_class_bind_template_callback(widget_class,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 pidgin_conversation_send_message_cb);
42346
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
343 gtk_widget_class_bind_template_callback(widget_class,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
344 pidgin_conversation_get_author_attributes);
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
345 gtk_widget_class_bind_template_callback(widget_class,
45d2756d2a14 Replace TalkatuHistory with our own implementation
Gary Kramlich <grim@reaperworld.com>
parents: 42301
diff changeset
346 pidgin_converation_get_timestamp_string);
42350
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
347 gtk_widget_class_bind_template_callback(widget_class,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
348 pidgin_conversation_query_tooltip_timestamp_cb);
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
349 gtk_widget_class_bind_template_callback(widget_class,
0d5319e4b836 Add tooltips to timestamps in PidginConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42346
diff changeset
350 pidgin_conversation_query_tooltip_edited_cb);
42301
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352
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 * API
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 *****************************************************************************/
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 pidgin_conversation_new(PurpleConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 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
359
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 return g_object_new(
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 PIDGIN_TYPE_CONVERSATION,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 "conversation", conversation,
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 NULL);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 }
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 GtkWidget *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 pidgin_conversation_from_purple_conversation(PurpleConversation *conversation)
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 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
370
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 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
372 }
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 PurpleConversation *
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 pidgin_conversation_get_conversation(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 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
377
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 return conversation->conversation;
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 }
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 void
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 pidgin_conversation_close(PidginConversation *conversation) {
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 g_return_if_fail(PIDGIN_IS_CONVERSATION(conversation));
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 pidgin_conversation_detach(conversation);
d3930fe5505c The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 }

mercurial