Create a Privacy preference page with the send typing notification preference

Tue, 13 May 2025 14:29:06 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 13 May 2025 14:29:06 -0500
changeset 43251
8bd7eee2f178
parent 43250
9ddd095b0a0b
child 43252
7be870f03030

Create a Privacy preference page with the send typing notification preference

This only controls whether or not the conversation window will send typing
notifications, plugins can still do this on their own.

Testing Done:
Used ngrep to verify if the irc typing messages were being sent or not. Also manually modified the settings file and verified the ui update and vice versa.

Bugs closed: PIDGIN-17450

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

libpurple/data/im.pidgin.Purple.gschema.xml file | annotate | diff | comparison | revisions
pidgin/data/gschema/im.pidgin.Pidgin3.Preferences.gschema.xml file | annotate | diff | comparison | revisions
pidgin/meson.build file | annotate | diff | comparison | revisions
pidgin/pidginconversation.c file | annotate | diff | comparison | revisions
pidgin/prefs/pidginprivacyprefs.c file | annotate | diff | comparison | revisions
pidgin/prefs/pidginprivacyprefs.h file | annotate | diff | comparison | revisions
pidgin/resources/Prefs/prefs.ui file | annotate | diff | comparison | revisions
pidgin/resources/Prefs/privacy.ui file | annotate | diff | comparison | revisions
pidgin/resources/pidgin.gresource.xml file | annotate | diff | comparison | revisions
po/POTFILES.in file | annotate | diff | comparison | revisions
--- a/libpurple/data/im.pidgin.Purple.gschema.xml	Tue May 13 00:56:10 2025 -0500
+++ b/libpurple/data/im.pidgin.Purple.gschema.xml	Tue May 13 14:29:06 2025 -0500
@@ -15,17 +15,6 @@
     </key>
   </schema>
 
-  <schema path="/purple/conversations/" id="im.pidgin.Purple.Conversations">
-    <key name="send-typing-notifications" type="b">
-      <default>true</default>
-      <summary>Send typing notifications</summary>
-      <description>
-        Send a notification when you are typing to any conversation that
-        supports it.
-      </description>
-    </key>
-  </schema>
-
   <schema path="/purple/credentials/" id="im.pidgin.Purple.Credentials">
     <key name="active-provider" type="s">
       <default>"noop-provider"</default>
--- a/pidgin/data/gschema/im.pidgin.Pidgin3.Preferences.gschema.xml	Tue May 13 00:56:10 2025 -0500
+++ b/pidgin/data/gschema/im.pidgin.Pidgin3.Preferences.gschema.xml	Tue May 13 14:29:06 2025 -0500
@@ -9,4 +9,13 @@
       </description>
     </key>
   </schema>
+  <schema path="/pidgin3/privacy/" id="im.pidgin.Pidgin3.Privacy">
+    <key name="send-typing-notifications" type="b">
+      <default>true</default>
+      <summary>Send typing notifications</summary>
+      <description>
+        Whether or not typing notifications will be sent.
+      </description>
+    </key>
+  </schema>
 </schemalist>
--- a/pidgin/meson.build	Tue May 13 00:56:10 2025 -0500
+++ b/pidgin/meson.build	Tue May 13 14:29:06 2025 -0500
@@ -46,12 +46,13 @@
 	'pidginprotocolchooser.c',
 	'pidgintypinglabel.c',
 	'pidginui.c',
-	'prefs/pidginprefs.c',
 	'prefs/pidginappearanceprefs.c',
 	'prefs/pidginawayprefs.c',
 	'prefs/pidgincredentialproviderrow.c',
 	'prefs/pidgincredentialprefs.c',
 	'prefs/pidginnetworkprefs.c',
+	'prefs/pidginprefs.c',
+	'prefs/pidginprivacyprefs.c',
 	'prefs/pidginproxyprefs.c',
 ]
 
@@ -103,12 +104,13 @@
 ]
 
 libpidgin_prefs_headers = [
-	'prefs/pidginprefs.h',
 	'prefs/pidginappearanceprefs.h',
 	'prefs/pidginawayprefs.h',
 	'prefs/pidgincredentialproviderrow.h',
 	'prefs/pidgincredentialprefs.h',
 	'prefs/pidginnetworkprefs.h',
+	'prefs/pidginprefs.h',
+	'prefs/pidginprivacyprefs.h',
 	'prefs/pidginproxyprefs.h',
 ]
 
--- a/pidgin/pidginconversation.c	Tue May 13 00:56:10 2025 -0500
+++ b/pidgin/pidginconversation.c	Tue May 13 14:29:06 2025 -0500
@@ -52,6 +52,8 @@
 
 	PurpleConversation *conversation;
 
+	GSettings *privacy_settings;
+
 	GtkWidget *info_pane;
 	GtkWidget *history;
 	GtkAdjustment *history_adjustment;
@@ -297,8 +299,12 @@
 {
 	PidginConversation *conversation = data;
 
-	purple_conversation_set_typing_state(conversation->conversation,
-	                                     PURPLE_TYPING_STATE_TYPING);
+	if(g_settings_get_boolean(conversation->privacy_settings,
+	                          "send-typing-notifications"))
+	{
+		purple_conversation_set_typing_state(conversation->conversation,
+		                                     PURPLE_TYPING_STATE_TYPING);
+	}
 }
 
 static void
@@ -310,8 +316,12 @@
 	PidginConversation *conversation = data;
 
 	if(gtk_text_buffer_get_char_count(buffer) == 0) {
-		purple_conversation_set_typing_state(conversation->conversation,
-		                                     PURPLE_TYPING_STATE_NONE);
+		if(g_settings_get_boolean(conversation->privacy_settings,
+		                          "send-typing-notifications"))
+		{
+			purple_conversation_set_typing_state(conversation->conversation,
+			                                     PURPLE_TYPING_STATE_NONE);
+		}
 	}
 }
 
@@ -456,7 +466,6 @@
                               G_IMPLEMENT_INTERFACE(PIDGIN_TYPE_NOTIFIABLE,
                                                     pidgin_conversation_notifiable_init))
 
-
 static void
 pidgin_conversation_dispose(GObject *obj) {
 	PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
@@ -469,6 +478,15 @@
 }
 
 static void
+pidgin_conversation_finalize(GObject *obj) {
+	PidginConversation *conversation = PIDGIN_CONVERSATION(obj);
+
+	g_clear_object(&conversation->privacy_settings);
+
+	G_OBJECT_CLASS(pidgin_conversation_parent_class)->finalize(obj);
+}
+
+static void
 pidgin_conversation_get_property(GObject *obj, guint param_id, GValue *value,
                                  GParamSpec *pspec)
 {
@@ -518,6 +536,10 @@
 
 	gtk_widget_init_template(GTK_WIDGET(conversation));
 
+	conversation->privacy_settings =
+		g_settings_new_with_backend("im.pidgin.Pidgin3.Privacy",
+	                                purple_core_get_settings_backend());
+
 	gtk_custom_sorter_set_sort_func(conversation->member_list_sorter,
 	                                pidgin_conversation_member_list_sort,
 	                                NULL, NULL);
@@ -551,6 +573,7 @@
 	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
 
 	obj_class->dispose = pidgin_conversation_dispose;
+	obj_class->finalize = pidgin_conversation_finalize;
 	obj_class->get_property = pidgin_conversation_get_property;
 	obj_class->set_property = pidgin_conversation_set_property;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/prefs/pidginprivacyprefs.c	Tue May 13 14:29:06 2025 -0500
@@ -0,0 +1,75 @@
+/*
+ * 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 "pidginprivacyprefs.h"
+#include "pidgincore.h"
+
+struct _PidginPrivacyPrefs {
+	AdwPreferencesPage parent;
+
+	GtkWidget *send_typing_notifications;
+};
+
+G_DEFINE_FINAL_TYPE(PidginPrivacyPrefs, pidgin_privacy_prefs,
+                    ADW_TYPE_PREFERENCES_PAGE)
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+pidgin_privacy_prefs_class_init(PidginPrivacyPrefsClass *klass) {
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+	gtk_widget_class_set_template_from_resource(widget_class,
+	                                            "/im/pidgin/Pidgin3/Prefs/privacy.ui");
+
+	gtk_widget_class_bind_template_child(widget_class, PidginPrivacyPrefs,
+	                                     send_typing_notifications);
+}
+
+static void
+pidgin_privacy_prefs_init(PidginPrivacyPrefs *prefs) {
+	GSettings *settings = NULL;
+
+	gtk_widget_init_template(GTK_WIDGET(prefs));
+
+	settings = g_settings_new_with_backend("im.pidgin.Pidgin3.Privacy",
+	                                       purple_core_get_settings_backend());
+	g_settings_bind(settings, "send-typing-notifications",
+	                prefs->send_typing_notifications, "active",
+	                G_SETTINGS_BIND_DEFAULT);
+	g_clear_object(&settings);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GtkWidget *
+pidgin_privacy_prefs_new(void) {
+	return g_object_new(PIDGIN_TYPE_PRIVACY_PREFS, NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/prefs/pidginprivacyprefs.h	Tue May 13 14:29:06 2025 -0500
@@ -0,0 +1,67 @@
+/*
+ * 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/>.
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only <pidgin.h> may be included directly"
+#endif
+
+#ifndef PIDGIN_PRIVACY_PREFS_H
+#define PIDGIN_PRIVACY_PREFS_H
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+#include <adwaita.h>
+
+#include "pidginversion.h"
+
+G_BEGIN_DECLS
+
+/**
+ * PidginPrivacyPrefs:
+ *
+ * A widget for the preferences window to let users choose and configure their
+ * privacy settings.
+ *
+ * Since: 3.0
+ */
+#define PIDGIN_TYPE_PRIVACY_PREFS (pidgin_privacy_prefs_get_type())
+
+PIDGIN_AVAILABLE_IN_3_0
+G_DECLARE_FINAL_TYPE(PidginPrivacyPrefs, pidgin_privacy_prefs,
+                     PIDGIN, PRIVACY_PREFS, AdwPreferencesPage)
+
+/**
+ * pidgin_privacy_prefs_new:
+ *
+ * Creates a new privacy preferences instance.
+ *
+ * Returns: (transfer full) (type PidginPrivacyPrefs): The new instance.
+ *
+ * Since: 3.0
+ */
+PIDGIN_AVAILABLE_IN_3_0
+GtkWidget *pidgin_privacy_prefs_new(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_PRIVACY_PREFS_H */
--- a/pidgin/resources/Prefs/prefs.ui	Tue May 13 00:56:10 2025 -0500
+++ b/pidgin/resources/Prefs/prefs.ui	Tue May 13 14:29:06 2025 -0500
@@ -34,6 +34,9 @@
       <object class="PidginAppearancePrefs"/>
     </child>
     <child>
+      <object class="PidginPrivacyPrefs"/>
+    </child>
+    <child>
       <object class="PidginNetworkPrefs"/>
     </child>
     <child>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Prefs/privacy.ui	Tue May 13 14:29:06 2025 -0500
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+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/>.
+-->
+<interface>
+  <requires lib="gtk" version="4.0"/>
+  <requires lib="Adw" version="1.0"/>
+  <!-- interface-license-type gplv2 -->
+  <!-- interface-name Pidgin -->
+  <!-- interface-description Internet Messenger -->
+  <!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
+  <template class="PidginPrivacyPrefs" parent="AdwPreferencesPage">
+    <property name="icon-name">preferences-system-privacy-symbolic</property>
+    <property name="title" translatable="yes">Privacy</property>
+    <child>
+      <object class="AdwPreferencesGroup">
+        <property name="title" translatable="yes">Activity</property>
+        <child>
+          <object class="AdwSwitchRow" id="send_typing_notifications">
+            <property name="title" translatable="yes">Send _Typing Notifications</property>
+            <property name="use-underline">true</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml	Tue May 13 00:56:10 2025 -0500
+++ b/pidgin/resources/pidgin.gresource.xml	Tue May 13 14:29:06 2025 -0500
@@ -20,6 +20,7 @@
     <file compressed="true" preprocess="xml-stripblanks">Prefs/credentialprovider.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">Prefs/network.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">Prefs/prefs.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">Prefs/privacy.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">Prefs/proxy.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">Prefs/vv.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">Protocols/chooser.ui</file>
--- a/po/POTFILES.in	Tue May 13 00:56:10 2025 -0500
+++ b/po/POTFILES.in	Tue May 13 14:29:06 2025 -0500
@@ -120,6 +120,7 @@
 pidgin/prefs/pidgincredentialproviderrow.c
 pidgin/prefs/pidginnetworkprefs.c
 pidgin/prefs/pidginprefs.c
+pidgin/prefs/pidginprivacy.c
 pidgin/prefs/pidginproxyprefs.c
 pidgin/prefs/pidginvvprefs.c
 pidgin/resources/About/about.ui
@@ -141,6 +142,7 @@
 pidgin/resources/Prefs/credentials.ui
 pidgin/resources/Prefs/network.ui
 pidgin/resources/Prefs/prefs.ui
+pidgin/resources/Prefs/privacy.ui
 pidgin/resources/Prefs/proxy.ui
 pidgin/resources/Prefs/vv.ui
 pidgin/resources/Protocols/chooser.ui

mercurial