pidgin/pidgintalkatu.c

Thu, 17 Aug 2023 22:40:33 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 17 Aug 2023 22:40:33 -0500
changeset 42283
885e1f4f98b3
parent 42094
2707c81648a0
child 42339
66b84a5e957d
permissions
-rw-r--r--

Some additional cleanups for libpidgin.c

Testing Done:
Compiled and ran the unit tests.

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

39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /* pidgin
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * source distribution.
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * (at your option) any later version.
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * GNU General Public License for more details.
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <pidgin/pidgintalkatu.h>
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 GtkWidget *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 pidgin_talkatu_editor_new_for_connection(PurpleConnection *pc) {
40484
7df95db772d8 Update a a few things that were changed in talkatu
Gary Kramlich <grim@reaperworld.com>
parents: 39223
diff changeset
27 GtkWidget *editor = NULL, *input = NULL;
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 g_return_val_if_fail(pc != NULL, NULL);
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 editor = talkatu_editor_new();
40484
7df95db772d8 Update a a few things that were changed in talkatu
Gary Kramlich <grim@reaperworld.com>
parents: 39223
diff changeset
32 input = talkatu_editor_get_input(TALKATU_EDITOR(editor));
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 gtk_text_view_set_buffer(
40484
7df95db772d8 Update a a few things that were changed in talkatu
Gary Kramlich <grim@reaperworld.com>
parents: 39223
diff changeset
35 GTK_TEXT_VIEW(input),
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 pidgin_talkatu_buffer_new_for_connection(pc)
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 );
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 return editor;
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 }
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GtkTextBuffer *
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 pidgin_talkatu_buffer_new_for_connection(PurpleConnection *pc) {
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PurpleConnectionFlags flags = 0;
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 GtkTextBuffer *buffer = NULL;
42094
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
46 GSimpleActionGroup *ag = NULL;
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
47 TalkatuBufferStyle style = TALKATU_BUFFER_STYLE_RICH;
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 g_return_val_if_fail(pc != NULL, NULL);
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 flags = purple_connection_get_flags(pc);
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 if(flags & PURPLE_CONNECTION_FLAG_HTML) {
42094
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
54 ag = talkatu_action_group_new(TALKATU_FORMAT_HTML);
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
55 }
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
56
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
57 if(flags & PURPLE_CONNECTION_FLAG_FORMATTING_WBFO) {
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
58 style = TALKATU_BUFFER_STYLE_WHOLE;
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 }
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
42094
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
61 buffer = g_object_new(TALKATU_TYPE_BUFFER,
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
62 "action-group", ag,
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
63 "style", style,
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
64 NULL);
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
65 if(TALKATU_IS_ACTION_GROUP(ag)) {
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
66 talkatu_action_group_set_buffer(TALKATU_ACTION_GROUP(ag), buffer);
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
67 }
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
68 g_clear_object(&ag);
2707c81648a0 Update to talkatu 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 40484
diff changeset
69
39223
7016ec26cd75 Move GtkPounce to Talkatu
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 return buffer;
40484
7df95db772d8 Update a a few things that were changed in talkatu
Gary Kramlich <grim@reaperworld.com>
parents: 39223
diff changeset
71 }

mercurial