summaryrefslogtreecommitdiff
path: root/pidgin/prefs/pidginconversationprefs.c
blob: 24a009d60836237c98d1458c9c6b0272dd01dda7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Pidgin - Internet Messenger
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * Pidgin is the legal property of its developers, whose names are too numerous
 * to list here.  Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#include <glib/gi18n-lib.h>

#include <purple.h>

#include <adwaita.h>

#include "pidginconversationprefs.h"
#include "pidgincore.h"
#include "pidginprefsinternal.h"

struct _PidginConversationPrefs {
	AdwPreferencesPage parent;

	GtkWidget *show_incoming_formatting;
	struct {
		GtkWidget *send_typing;
	} im;
	struct {
		GtkWidget *blink_im_row;
		GtkWidget *blink_im;
	} win32;
	GtkWidget *minimum_entry_lines;
};

G_DEFINE_TYPE(PidginConversationPrefs, pidgin_conversation_prefs,
              ADW_TYPE_PREFERENCES_PAGE)

/******************************************************************************
 * GObject Implementation
 *****************************************************************************/
static void
pidgin_conversation_prefs_class_init(PidginConversationPrefsClass *klass)
{
	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);

	gtk_widget_class_set_template_from_resource(
		widget_class,
		"/im/pidgin/Pidgin3/Prefs/conversation.ui"
	);

	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			show_incoming_formatting);
	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			im.send_typing);
	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			win32.blink_im_row);
	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			win32.blink_im);
	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			minimum_entry_lines);
}

static void
pidgin_conversation_prefs_init(PidginConversationPrefs *prefs)
{
	gtk_widget_init_template(GTK_WIDGET(prefs));

	pidgin_prefs_bind_switch(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting",
	                         prefs->show_incoming_formatting);

	pidgin_prefs_bind_switch("/purple/conversations/im/send_typing",
	                         prefs->im.send_typing);

#ifdef _WIN32
	pidgin_prefs_bind_switch(PIDGIN_PREFS_ROOT "/win32/blink_im",
	                         prefs->win32.blink_im);
#else
	gtk_widget_set_visible(prefs->win32.blink_im_row, FALSE);
#endif

	pidgin_prefs_bind_spin_button(
		PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
		prefs->minimum_entry_lines);
}

/******************************************************************************
 * API
 *****************************************************************************/
GtkWidget *
pidgin_conversation_prefs_new(void) {
	return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CONVERSATION_PREFS, NULL));
}