changeset 21487:f2e42e09e635

Allow turning on logging when enabling the gnthistory plugin. (this doesn't add new strings)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 14 Nov 2007 05:27:47 +0000
parents c8cdf0bcc8e3
children 228bd30a56f2
files finch/plugins/gnthistory.c
diffstat 1 files changed, 45 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/finch/plugins/gnthistory.c	Wed Nov 14 00:23:21 2007 +0000
+++ b/finch/plugins/gnthistory.c	Wed Nov 14 05:27:47 2007 +0000
@@ -25,13 +25,14 @@
 #include "conversation.h"
 #include "debug.h"
 #include "log.h"
-#include "notify.h"
+#include "request.h"
 #include "prefs.h"
 #include "signals.h"
 #include "util.h"
 #include "version.h"
 
 #include "gntplugin.h"
+#include "gntrequest.h"
 
 #define HISTORY_PLUGIN_ID "gnt-history"
 
@@ -135,10 +136,51 @@
 	if (!purple_prefs_get_bool("/purple/logging/log_ims") &&
 	    !purple_prefs_get_bool("/purple/logging/log_chats"))
 	{
-		purple_notify_warning(plugin, NULL, _("History Plugin Requires Logging"),
+		PurpleRequestFields *fields = purple_request_fields_new();
+		PurpleRequestFieldGroup *group;
+		PurpleRequestField *field;
+		struct {
+			const char *pref;
+			const char *label;
+		} prefs[] = {
+			{"/purple/logging/log_ims", N_("Log IMs")},
+			{"/purple/logging/log_chats", N_("Log chats")},
+			{NULL, NULL}
+		};
+		int iter;
+		GList *list = purple_log_logger_get_options();
+		const char *system = purple_prefs_get_string("/purple/logging/format");
+
+		group = purple_request_field_group_new(_("Logging"));
+
+		field = purple_request_field_list_new("/purple/logging/format", _("Log format"));
+		while (list) {
+			const char *label = _(list->data);
+			list = g_list_delete_link(list, list);
+			purple_request_field_list_add(field, label, list->data);
+			if (system && strcmp(system, list->data) == 0)
+				purple_request_field_list_add_selected(field, label);
+			list = g_list_delete_link(list, list);
+		}
+		purple_request_field_group_add_field(group, field);
+
+		for (iter = 0; prefs[iter].pref; iter++) {
+			field = purple_request_field_bool_new(prefs[iter].pref, _(prefs[iter].label),
+						purple_prefs_get_bool(prefs[iter].pref));
+			purple_request_field_group_add_field(group, field);
+		}
+
+		purple_request_fields_add_group(fields, group);
+
+		purple_request_fields_with_hint(plugin, NULL, _("History Plugin Requires Logging"),
 							_("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
 							  "Enabling logs for instant messages and/or chats will activate "
-							  "history for the same conversation type(s)."));
+							  "history for the same conversation type(s)."),
+							fields,
+							_("OK"), G_CALLBACK(finch_request_save_in_prefs),
+							_("Cancel"), NULL,
+							NULL, NULL, NULL,
+							"42. That's your hint. Take it, or leave it.", plugin);
 	}
 }