pidgin/prefs/pidginconversationprefs.c

changeset 41371
fe57d9ddc7ce
child 41551
865be7af93d6
equal deleted inserted replaced
41370:0ae2dfa4a5cf 41371:fe57d9ddc7ce
1 /*
2 * Pidgin - Internet Messenger
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
4 *
5 * Pidgin is the legal property of its developers, whose names are too numerous
6 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * source distribution.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23 #include <glib/gi18n-lib.h>
24
25 #include <purple.h>
26
27 #include <handy.h>
28 #include <talkatu.h>
29
30 #include "pidginconversationprefs.h"
31 #include "pidgincore.h"
32 #include "pidginprefsinternal.h"
33
34 struct _PidginConversationPrefs {
35 HdyPreferencesPage parent;
36
37 GtkWidget *show_incoming_formatting;
38 struct {
39 GtkWidget *send_typing;
40 } im;
41 GtkWidget *use_smooth_scrolling;
42 struct {
43 GtkWidget *blink_im;
44 } win32;
45 GtkWidget *minimum_entry_lines;
46 GtkTextBuffer *format_buffer;
47 GtkWidget *format_view;
48 };
49
50 G_DEFINE_TYPE(PidginConversationPrefs, pidgin_conversation_prefs,
51 HDY_TYPE_PREFERENCES_PAGE)
52
53 /******************************************************************************
54 * Helpers
55 *****************************************************************************/
56 static void
57 formatting_toggle_cb(TalkatuActionGroup *ag, GAction *action, const gchar *name, gpointer data)
58 {
59 gboolean activated = talkatu_action_group_get_action_activated(ag, name);
60 if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_BOLD, name) != 0) {
61 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold",
62 activated);
63 } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_ITALIC, name) != 0) {
64 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic",
65 activated);
66 } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_UNDERLINE, name) != 0) {
67 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline",
68 activated);
69 } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_STRIKETHROUGH, name) != 0) {
70 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike",
71 activated);
72 }
73 }
74
75 /******************************************************************************
76 * GObject Implementation
77 *****************************************************************************/
78 static void
79 pidgin_conversation_prefs_class_init(PidginConversationPrefsClass *klass)
80 {
81 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
82
83 gtk_widget_class_set_template_from_resource(
84 widget_class,
85 "/im/pidgin/Pidgin3/Prefs/conversation.ui"
86 );
87
88 gtk_widget_class_bind_template_child(
89 widget_class, PidginConversationPrefs,
90 show_incoming_formatting);
91 gtk_widget_class_bind_template_child(
92 widget_class, PidginConversationPrefs,
93 im.send_typing);
94 gtk_widget_class_bind_template_child(
95 widget_class, PidginConversationPrefs,
96 use_smooth_scrolling);
97 gtk_widget_class_bind_template_child(
98 widget_class, PidginConversationPrefs,
99 win32.blink_im);
100 gtk_widget_class_bind_template_child(
101 widget_class, PidginConversationPrefs,
102 minimum_entry_lines);
103 gtk_widget_class_bind_template_child(
104 widget_class, PidginConversationPrefs,
105 format_buffer);
106 gtk_widget_class_bind_template_child(
107 widget_class, PidginConversationPrefs,
108 format_view);
109 }
110
111 static void
112 pidgin_conversation_prefs_init(PidginConversationPrefs *prefs)
113 {
114 GSimpleActionGroup *ag = NULL;
115
116 gtk_widget_init_template(GTK_WIDGET(prefs));
117
118 pidgin_prefs_bind_checkbox(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting",
119 prefs->show_incoming_formatting);
120
121 pidgin_prefs_bind_checkbox("/purple/conversations/im/send_typing",
122 prefs->im.send_typing);
123
124 pidgin_prefs_bind_checkbox(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling",
125 prefs->use_smooth_scrolling);
126
127 #ifdef _WIN32
128 pidgin_prefs_bind_checkbox(PIDGIN_PREFS_ROOT "/win32/blink_im",
129 prefs->win32.blink_im);
130 #else
131 gtk_widget_hide(prefs->win32.blink_im);
132 #endif
133
134 pidgin_prefs_bind_spin_button(
135 PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
136 prefs->minimum_entry_lines);
137
138 ag = talkatu_buffer_get_action_group(TALKATU_BUFFER(prefs->format_buffer));
139 g_signal_connect_after(G_OBJECT(ag), "action-activated",
140 G_CALLBACK(formatting_toggle_cb), NULL);
141 }
142
143 /******************************************************************************
144 * API
145 *****************************************************************************/
146 GtkWidget *
147 pidgin_conversation_prefs_new(void) {
148 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CONVERSATION_PREFS, NULL));
149 }

mercurial