Add a boolean setting for toggling developer mode

Mon, 04 Nov 2024 23:42:22 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 04 Nov 2024 23:42:22 -0600
changeset 43054
ccd071e7cd83
parent 43053
f2f944ac775c
child 43055
917386321169

Add a boolean setting for toggling developer mode

This just gives a simple API method for checking the setting.

Testing Done:
Added a temporary `g_warning` to the end of `Pidgin.Application.startup` to verify the setting after modifying the file by hand.

Bugs closed: PIDGIN-17993

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

libpurple/core.c file | annotate | diff | comparison | revisions
libpurple/core.h file | annotate | diff | comparison | revisions
libpurple/data/im.pidgin.Purple.gschema.xml file | annotate | diff | comparison | revisions
--- a/libpurple/core.c	Mon Nov 04 20:12:42 2024 -0600
+++ b/libpurple/core.c	Mon Nov 04 23:42:22 2024 -0600
@@ -260,6 +260,19 @@
 	return _core;
 }
 
+gboolean
+purple_core_get_developer_mode(void) {
+	GSettings *settings = NULL;
+	gboolean developer_mode = FALSE;
+
+	settings = g_settings_new_with_backend("im.pidgin.Purple.Core",
+	                                       settings_backend);
+
+	developer_mode = g_settings_get_boolean(settings, "developer-mode");
+
+	return developer_mode;
+}
+
 gpointer
 purple_core_get_settings_backend(void) {
 	return settings_backend;
--- a/libpurple/core.h	Mon Nov 04 20:12:42 2024 -0600
+++ b/libpurple/core.h	Mon Nov 04 23:42:22 2024 -0600
@@ -97,6 +97,21 @@
 PurpleCore *purple_get_core(void);
 
 /**
+ * purple_core_get_developer_mode:
+ *
+ * Gets whether or not developer mode is turned on.
+ *
+ * Developer mode doesn't do anything itself. It is just a hint to other parts
+ * of the code base to present things that are useful for developers.
+ *
+ * Returns: %TRUE if developer mode is on, otherwise %FALSE.
+ *
+ * Since: 3.0
+ */
+PURPLE_AVAILABLE_IN_3_0
+gboolean purple_core_get_developer_mode(void);
+
+/**
  * purple_core_get_settings_backend:
  *
  * Gets the settings backend to use when saving/loading settings.
--- a/libpurple/data/im.pidgin.Purple.gschema.xml	Mon Nov 04 20:12:42 2024 -0600
+++ b/libpurple/data/im.pidgin.Purple.gschema.xml	Mon Nov 04 23:42:22 2024 -0600
@@ -4,6 +4,17 @@
     <child name="credentials" schema="im.pidgin.Purple.Credentials"/>
   </schema>
 
+  <schema path="/purple/core/" id="im.pidgin.Purple.Core">
+    <key name="developer-mode" type="b">
+      <default>false</default>
+      <summary>Enables developer mode</summary>
+      <description>
+        Developer mode is a hint to other features to tell them to show options
+        and information that is useful to developers but not normal users.
+      </description>
+    </key>
+  </schema>
+
   <schema path="/purple/conversations/" id="im.pidgin.Purple.Conversations">
     <key name="send-typing-notifications" type="b">
       <default>true</default>

mercurial