# HG changeset patch
# Node ID bbc5c6cc19a8
# Parent  2e1bb0e3962a
diff --git a/finch/plugins/gntgf/gntgf.c b/finch/plugins/gntgf/gntgf.c
--- a/finch/plugins/gntgf/gntgf.c
+++ b/finch/plugins/gntgf/gntgf.c
@@ -18,18 +18,17 @@
 
 #include NCURSES_HEADER
 
-#define PREFS_PREFIX          "/plugins/gnt/gntgf"
-#define PREFS_EVENT           PREFS_PREFIX "/events"
-#define PREFS_EVENT_SIGNONF   PREFS_EVENT "/signonf"
-#define PREFS_EVENT_IM_MSG    PREFS_EVENT "/immsg"
-#define PREFS_EVENT_CHAT_MSG  PREFS_EVENT "/chatmsg"
-#define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick"
-#define PREFS_BEEP            PREFS_PREFIX "/beep"
+#define PREFS_SCHEMA "im.pidgin.Finch.plugin.GntGf"
+#define PREFS_EVENT_SIGN_ON_OFF "event-sign-on-off"
+#define PREFS_EVENT_IM_MSG "event-im-message"
+#define PREFS_EVENT_CHAT_MSG "event-chat-message"
+#define PREFS_EVENT_CHAT_NICK "event-chat-nick"
+#define PREFS_BEEP "beep"
 
 #define MAX_COLS	3
 
 #ifdef HAVE_X11
-#define PREFS_URGENT          PREFS_PREFIX "/urgent"
+#define PREFS_URGENT "urgent"
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -148,21 +147,31 @@ notify(PurpleConversation *conv, const c
 	char *str;
 	int h, w, i;
 	va_list args;
+	GSettings *settings = NULL;
 
-	if (purple_prefs_get_bool(PREFS_BEEP))
+	settings = g_settings_new_with_backend(PREFS_SCHEMA,
+	                                       purple_core_get_settings_backend());
+
+	if(g_settings_get_boolean(settings, PREFS_BEEP)) {
 		beep();
+	}
 
 	if (conv != NULL) {
 		FinchConv *fc = FINCH_CONV(conv);
-		if (gnt_widget_has_focus(fc->window))
+		if (gnt_widget_has_focus(fc->window)) {
+			g_object_unref(settings);
 			return;
+		}
 	}
 
 #ifdef HAVE_X11
-	if (purple_prefs_get_bool(PREFS_URGENT))
+	if(g_settings_get_boolean(settings, PREFS_URGENT)) {
 		urgent();
+	}
 #endif
 
+	g_clear_object(&settings);
+
 	window = gnt_vbox_new(FALSE);
 	gnt_widget_set_transient(window, TRUE);
 	gnt_widget_set_has_border(window, TRUE);
@@ -213,23 +222,47 @@ notify(PurpleConversation *conv, const c
 static void
 buddy_signed_on(PurpleBuddy *buddy, gpointer null)
 {
-	if (purple_prefs_get_bool(PREFS_EVENT_SIGNONF))
+	GSettings *settings = NULL;
+
+	settings = g_settings_new_with_backend(PREFS_SCHEMA,
+	                                       purple_core_get_settings_backend());
+
+	if(g_settings_get_boolean(settings, PREFS_EVENT_SIGN_ON_OFF)) {
 		notify(NULL, _("%s just signed on"), purple_buddy_get_alias(buddy));
+	}
+
+	g_object_unref(settings);
 }
 
 static void
 buddy_signed_off(PurpleBuddy *buddy, gpointer null)
 {
-	if (purple_prefs_get_bool(PREFS_EVENT_SIGNONF))
+	GSettings *settings = NULL;
+
+	settings = g_settings_new_with_backend(PREFS_SCHEMA,
+	                                       purple_core_get_settings_backend());
+
+	if(g_settings_get_boolean(settings, PREFS_EVENT_SIGN_ON_OFF)) {
 		notify(NULL, _("%s just signed off"), purple_buddy_get_alias(buddy));
+	}
+
+	g_object_unref(settings);
 }
 
 static void
 received_im_msg(PurpleAccount *account, const char *sender, const char *msg,
 		PurpleIMConversation *im, PurpleMessageFlags flags, gpointer null)
 {
-	if (purple_prefs_get_bool(PREFS_EVENT_IM_MSG))
+	GSettings *settings = NULL;
+
+	settings = g_settings_new_with_backend(PREFS_SCHEMA,
+	                                       purple_core_get_settings_backend());
+
+	if(g_settings_get_boolean(settings, PREFS_EVENT_IM_MSG)) {
 		notify(PURPLE_CONVERSATION(im), _("%s sent you a message"), sender);
+	}
+
+	g_object_unref(settings);
 }
 
 static void
@@ -238,17 +271,27 @@ received_chat_msg(PurpleAccount *account
 {
 	const char *nick;
 	PurpleConversation *conv = PURPLE_CONVERSATION(chat);
+	GSettings *settings = NULL;
 
 	nick = purple_chat_conversation_get_nick(chat);
 
-	if (g_utf8_collate(sender, nick) == 0)
+	if (g_utf8_collate(sender, nick) == 0) {
 		return;
+	}
+
+	settings = g_settings_new_with_backend(PREFS_SCHEMA,
+	                                       purple_core_get_settings_backend());
 
-	if (purple_prefs_get_bool(PREFS_EVENT_CHAT_NICK) &&
-			(purple_utf8_has_word(msg, nick)))
-		notify(conv, _("%s said your nick in %s"), sender, purple_conversation_get_name(conv));
-	else if (purple_prefs_get_bool(PREFS_EVENT_CHAT_MSG))
-		notify(conv, _("%s sent a message in %s"), sender, purple_conversation_get_name(conv));
+	if(g_settings_get_boolean(settings, PREFS_EVENT_CHAT_NICK) &&
+			purple_utf8_has_word(msg, nick)) {
+		notify(conv, _("%s said your nick in %s"), sender,
+		       purple_conversation_get_name(conv));
+	} else if(g_settings_get_boolean(settings, PREFS_EVENT_CHAT_MSG)) {
+		notify(conv, _("%s sent a message in %s"), sender,
+		       purple_conversation_get_name(conv));
+	}
+
+	g_object_unref(settings);
 }
 
 static struct
@@ -257,7 +300,7 @@ static struct
 	char *display;
 } prefs[] =
 {
-	{PREFS_EVENT_SIGNONF, N_("Buddy signs on/off")},
+	{PREFS_EVENT_SIGN_ON_OFF, N_("Buddy signs on/off")},
 	{PREFS_EVENT_IM_MSG, N_("You receive an IM")},
 	{PREFS_EVENT_CHAT_MSG, N_("Someone speaks in a chat")},
 	{PREFS_EVENT_CHAT_NICK, N_("Someone says your name in a chat")},
@@ -344,22 +387,6 @@ gnt_gf_query(GError **error)
 
 static gboolean
 gnt_gf_load(GPluginPlugin *plugin, GError **error) {
-	purple_prefs_add_none("/plugins");
-	purple_prefs_add_none("/plugins/gnt");
-
-	purple_prefs_add_none("/plugins/gnt/gntgf");
-	purple_prefs_add_none(PREFS_EVENT);
-
-	purple_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE);
-	purple_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE);
-	purple_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE);
-	purple_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE);
-
-	purple_prefs_add_bool(PREFS_BEEP, TRUE);
-#ifdef HAVE_X11
-	purple_prefs_add_bool(PREFS_URGENT, FALSE);
-#endif
-
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", plugin,
 			G_CALLBACK(buddy_signed_on), NULL);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", plugin,
@@ -385,4 +412,4 @@ gnt_gf_unload(GPluginPlugin *plugin, gbo
 	return TRUE;
 }
 
-GPLUGIN_NATIVE_PLUGIN_DECLARE(gnt_gf)
\ No newline at end of file
+GPLUGIN_NATIVE_PLUGIN_DECLARE(gnt_gf)
diff --git a/finch/plugins/gntgf/im.pidgin.Finch.plugin.GntGf.gschema.xml b/finch/plugins/gntgf/im.pidgin.Finch.plugin.GntGf.gschema.xml
new file mode 100644
--- /dev/null
+++ b/finch/plugins/gntgf/im.pidgin.Finch.plugin.GntGf.gschema.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<schemalist>
+
+  <schema path="/finch/plugins/gntgf/" id="im.pidgin.Finch.plugin.GntGf">
+    <key name="event-sign-on-off" type="b">
+      <default>true</default>
+      <summary>Notify buddy sign on/off</summary>
+      <description>
+        Notify with a toaster when a buddy signs on/off.
+      </description>
+    </key>
+
+    <key name="event-im-message" type="b">
+      <default>true</default>
+      <summary>Notify IM message</summary>
+      <description>
+        Notify with a toaster when you receive an IM.
+      </description>
+    </key>
+
+    <key name="event-chat-message" type="b">
+      <default>true</default>
+      <summary>Notify chat message</summary>
+      <description>
+        Notify with a toaster when someone speaks in a chat.
+      </description>
+    </key>
+
+    <key name="event-chat-nick" type="b">
+      <default>true</default>
+      <summary>Notify your nick in chat</summary>
+      <description>
+        Notify with a toaster when someone says your name in a chat.
+      </description>
+    </key>
+
+    <key name="beep" type="b">
+      <default>true</default>
+      <summary>Beep</summary>
+      <description>
+        Also beep when notifying.
+      </description>
+    </key>
+
+    <key name="urgent" type="b">
+      <default>false</default>
+      <summary>Set URGENT flag</summary>
+      <description>
+        Set URGENT flag for the terminal window if X11 is supported.
+      </description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/finch/plugins/gntgf/meson.build b/finch/plugins/gntgf/meson.build
--- a/finch/plugins/gntgf/meson.build
+++ b/finch/plugins/gntgf/meson.build
@@ -10,4 +10,14 @@ if x11.found()
 	    install : true, install_dir : FINCH_PLUGINDIR)
 endif
 
+settings_schemas = [
+  'im.pidgin.Finch.plugin.GntGf.gschema.xml',
+]
+
+install_data(settings_schemas, install_dir: schemas_dir)
+gnome.post_install(glib_compile_schemas: true)
+
+# Compile the schemas in the current directory; this is only useful for testing
+gnome.compile_schemas(depend_files: files(settings_schemas))
+
 devenv.append('FINCH_PLUGIN_PATH', meson.current_build_dir())
