Thu, 17 Aug 2023 22:40:33 -0500
Some additional cleanups for libpidgin.c
Testing Done:
Compiled and ran the unit tests.
Reviewed at https://reviews.imfreedom.org/r/2571/
| 39223 | 1 | /* pidgin |
| 2 | * | |
| 3 | * Pidgin is the legal property of its developers, whose names are too numerous | |
| 4 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
| 20 | * | |
| 21 | */ | |
| 22 | ||
| 23 | #include <pidgin/pidgintalkatu.h> | |
| 24 | ||
| 25 | GtkWidget * | |
| 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 | 28 | |
| 29 | g_return_val_if_fail(pc != NULL, NULL); | |
| 30 | ||
| 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 | 33 | |
| 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 | 36 | pidgin_talkatu_buffer_new_for_connection(pc) |
| 37 | ); | |
| 38 | ||
| 39 | return editor; | |
| 40 | } | |
| 41 | ||
| 42 | GtkTextBuffer * | |
| 43 | pidgin_talkatu_buffer_new_for_connection(PurpleConnection *pc) { | |
| 44 | PurpleConnectionFlags flags = 0; | |
| 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 | 48 | |
| 49 | g_return_val_if_fail(pc != NULL, NULL); | |
| 50 | ||
| 51 | flags = purple_connection_get_flags(pc); | |
| 52 | ||
| 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 | 59 | } |
| 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 | 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 | } |