pidgin/prefs/pidginconversationprefs.c

Wed, 01 Jan 2025 15:37:20 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 01 Jan 2025 15:37:20 -0600
changeset 43121
3d448c75d39a
parent 43013
26d30c0db9a5
permissions
-rw-r--r--

Added tag v2.90.1 for changeset a7fd7e06c486

/*
 * 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"

struct _PidginConversationPrefs {
	AdwPreferencesPage parent;

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

G_DEFINE_FINAL_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);
	gtk_widget_class_bind_template_child(
			widget_class, PidginConversationPrefs,
			minimum_entry_lines);
}

static void
pidgin_conversation_prefs_init(PidginConversationPrefs *prefs)
{
	GSettings *settings = NULL;

	gtk_widget_init_template(GTK_WIDGET(prefs));

	settings = g_settings_new_with_backend("im.pidgin.Purple.Conversations",
	                                       purple_core_get_settings_backend());
	g_settings_bind(settings, "send-typing-notifications",
	                prefs->im.send_typing, "active", G_SETTINGS_BIND_DEFAULT);
	g_clear_object(&settings);

#if 0
	/* TODO: Decide on whether to keep these preferences, and then port those
	 * to GSettings. */
	pidgin_prefs_bind_switch(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting",
	                         prefs->show_incoming_formatting);

#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, FALSE);
#endif

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

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

mercurial