pidgin/prefs/pidginappearanceprefs.c

Wed, 14 May 2025 01:54:28 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 14 May 2025 01:54:28 -0500
changeset 43253
0cc00d7d6215
parent 43249
ae9ab6159a80
permissions
-rw-r--r--

Create purple_core_new_settings

This is a helper around g_settings_new_with_backend using the settings backend
that the core is using.

Testing Done:
Called in the turtles and connected a few accounts in a devenv without issue.

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

43249
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include <adwaita.h>
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include "pidginappearanceprefs.h"
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 #include "pidgincore.h"
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 struct _PidginAppearancePrefs {
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 AdwPreferencesPage parent;
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 GtkWidget *show_formatting;
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 };
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 G_DEFINE_FINAL_TYPE(PidginAppearancePrefs, pidgin_appearance_prefs,
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 ADW_TYPE_PREFERENCES_PAGE)
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 /******************************************************************************
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 * GObject Implementation
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 *****************************************************************************/
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 static void
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 pidgin_appearance_prefs_class_init(PidginAppearancePrefsClass *klass) {
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 gtk_widget_class_set_template_from_resource(widget_class,
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 "/im/pidgin/Pidgin3/Prefs/appearance.ui");
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 gtk_widget_class_bind_template_child(widget_class, PidginAppearancePrefs,
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 show_formatting);
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 }
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 static void
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 pidgin_appearance_prefs_init(PidginAppearancePrefs *prefs) {
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GSettings *settings = NULL;
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 gtk_widget_init_template(GTK_WIDGET(prefs));
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
43253
0cc00d7d6215 Create purple_core_new_settings
Gary Kramlich <grim@reaperworld.com>
parents: 43249
diff changeset
61 settings = purple_core_new_settings("im.pidgin.Pidgin3.Appearance");
43249
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_settings_bind(settings, "show-formatting",
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 prefs->show_formatting, "active", G_SETTINGS_BIND_DEFAULT);
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 g_clear_object(&settings);
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 }
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 /******************************************************************************
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 * API
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 *****************************************************************************/
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 GtkWidget *
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 pidgin_appearance_prefs_new(void) {
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 return g_object_new(PIDGIN_TYPE_APPEARANCE_PREFS, NULL);
ae9ab6159a80 Start of the appearance preferences
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }

mercurial