diff finch/gntprefs.c @ 15852:c5487dd19e61

merge of '31ed92ba1b530f050510b4958686e3013ba4176c' and '41f65a78d919384ad599d73c656a367d92292a41'
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 20 Mar 2007 14:37:22 +0000
parents 32c366eeeb99
children 66dff3dfdea6
line wrap: on
line diff
--- a/finch/gntprefs.c	Tue Mar 20 14:37:16 2007 +0000
+++ b/finch/gntprefs.c	Tue Mar 20 14:37:22 2007 +0000
@@ -2,9 +2,9 @@
  * @file gntprefs.c GNT Preferences API
  * @ingroup gntui
  *
- * gaim
+ * purple
  *
- * Gaim is the legal property of its developers, whose names are too numerous
+ * Purple 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.
  *
@@ -25,7 +25,7 @@
 #include <prefs.h>
 #include <savedstatuses.h>
 
-#include "gntgaim.h"
+#include "finch.h"
 #include "gntprefs.h"
 #include "gntrequest.h"
 
@@ -35,20 +35,20 @@
 
 void finch_prefs_init()
 {
-	gaim_prefs_add_none("/gaim");
-	gaim_prefs_add_none("/gaim/gnt");
+	purple_prefs_add_none("/purple");
+	purple_prefs_add_none("/purple/gnt");
 
-	gaim_prefs_add_none("/gaim/gnt/plugins");
-	gaim_prefs_add_path_list("/gaim/gnt/plugins/loaded", NULL);
+	purple_prefs_add_none("/purple/gnt/plugins");
+	purple_prefs_add_path_list("/purple/gnt/plugins/loaded", NULL);
 
-	gaim_prefs_add_none("/gaim/gnt/conversations");
-	gaim_prefs_add_bool("/gaim/gnt/conversations/timestamps", TRUE);
-	gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */
+	purple_prefs_add_none("/purple/gnt/conversations");
+	purple_prefs_add_bool("/purple/gnt/conversations/timestamps", TRUE);
+	purple_prefs_add_bool("/purple/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */
 }
 
 typedef struct
 {
-	GaimPrefType type;
+	PurplePrefType type;
 	const char *pref;
 	const char *label;
 	GList *(*lv)();   /* If the value is to be selected from a number of choices */
@@ -57,7 +57,7 @@
 static GList *
 get_log_options()
 {
-	return gaim_log_logger_get_options();
+	return purple_log_logger_get_options();
 }
 
 static GList *
@@ -67,7 +67,7 @@
 	list = g_list_append(list, "Based on keyboard use"); /* XXX: string freeze */
 	list = g_list_append(list, "system");
 	list = g_list_append(list, (char*)_("From last sent message"));
-	list = g_list_append(list, "gaim");
+	list = g_list_append(list, "purple");
 	list = g_list_append(list, (char*)_("Never"));
 	list = g_list_append(list, "never");
 	return list;
@@ -78,38 +78,38 @@
 {
 	GList *list = NULL;
 	const GList *iter;
-	for (iter = gaim_savedstatuses_get_all(); iter; iter = iter->next) {
+	for (iter = purple_savedstatuses_get_all(); iter; iter = iter->next) {
 		char *str;
-		if (gaim_savedstatus_is_transient(iter->data))
+		if (purple_savedstatus_is_transient(iter->data))
 			continue;
-		str = g_strdup_printf("%ld", gaim_savedstatus_get_creation_time(iter->data));
-		list = g_list_append(list, (char*)gaim_savedstatus_get_title(iter->data));
+		str = g_strdup_printf("%ld", purple_savedstatus_get_creation_time(iter->data));
+		list = g_list_append(list, (char*)purple_savedstatus_get_title(iter->data));
 		list = g_list_append(list, str);
 		freestrings = g_list_prepend(freestrings, str);
 	}
 	return list;
 }
 
-static GaimRequestField *
+static PurpleRequestField *
 get_pref_field(Prefs *prefs)
 {
-	GaimRequestField *field = NULL;
+	PurpleRequestField *field = NULL;
 
 	if (prefs->lv == NULL)
 	{
 		switch (prefs->type)
 		{
-			case GAIM_PREF_BOOLEAN:
-				field = gaim_request_field_bool_new(prefs->pref, _(prefs->label),
-						gaim_prefs_get_bool(prefs->pref));
+			case PURPLE_PREF_BOOLEAN:
+				field = purple_request_field_bool_new(prefs->pref, _(prefs->label),
+						purple_prefs_get_bool(prefs->pref));
 				break;
-			case GAIM_PREF_INT:
-				field = gaim_request_field_int_new(prefs->pref, _(prefs->label),
-						gaim_prefs_get_int(prefs->pref));
+			case PURPLE_PREF_INT:
+				field = purple_request_field_int_new(prefs->pref, _(prefs->label),
+						purple_prefs_get_int(prefs->pref));
 				break;
-			case GAIM_PREF_STRING:
-				field = gaim_request_field_string_new(prefs->pref, _(prefs->label),
-						gaim_prefs_get_string(prefs->pref), FALSE);
+			case PURPLE_PREF_STRING:
+				field = purple_request_field_string_new(prefs->pref, _(prefs->label),
+						purple_prefs_get_string(prefs->pref), FALSE);
 				break;
 			default:
 				break;
@@ -119,7 +119,7 @@
 	{
 		GList *list = prefs->lv(), *iter;
 		if (list)
-			field = gaim_request_field_list_new(prefs->pref, _(prefs->label));
+			field = purple_request_field_list_new(prefs->pref, _(prefs->label));
 		for (iter = list; iter; iter = iter->next)
 		{
 			gboolean select = FALSE;
@@ -128,26 +128,26 @@
 			iter = iter->next;
 			switch (prefs->type)
 			{
-				case GAIM_PREF_BOOLEAN:
+				case PURPLE_PREF_BOOLEAN:
 					sscanf(iter->data, "%d", &idata);
-					if (gaim_prefs_get_bool(prefs->pref) == idata)
+					if (purple_prefs_get_bool(prefs->pref) == idata)
 						select = TRUE;
 					break;
-				case GAIM_PREF_INT:
+				case PURPLE_PREF_INT:
 					sscanf(iter->data, "%d", &idata);
-					if (gaim_prefs_get_int(prefs->pref) == idata)
+					if (purple_prefs_get_int(prefs->pref) == idata)
 						select = TRUE;
 					break;
-				case GAIM_PREF_STRING:
-					if (strcmp(gaim_prefs_get_string(prefs->pref), iter->data) == 0)
+				case PURPLE_PREF_STRING:
+					if (strcmp(purple_prefs_get_string(prefs->pref), iter->data) == 0)
 						select = TRUE;
 					break;
 				default:
 					break;
 			}
-			gaim_request_field_list_add(field, data, iter->data);
+			purple_request_field_list_add(field, data, iter->data);
 			if (select)
-				gaim_request_field_list_add_selected(field, data);
+				purple_request_field_list_add_selected(field, data);
 		}
 		g_list_free(list);
 	}
@@ -156,35 +156,35 @@
 
 static Prefs blist[] = 
 {
-	{GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/idletime", N_("Show Idle Time"), NULL},
-	{GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/showoffline", N_("Show Offline Buddies"), NULL},
-	{GAIM_PREF_NONE, NULL, NULL, NULL}
+	{PURPLE_PREF_BOOLEAN, "/purple/gnt/blist/idletime", N_("Show Idle Time"), NULL},
+	{PURPLE_PREF_BOOLEAN, "/purple/gnt/blist/showoffline", N_("Show Offline Buddies"), NULL},
+	{PURPLE_PREF_NONE, NULL, NULL, NULL}
 };
 
 static Prefs convs[] = 
 {
-	{GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/timestamps", N_("Show Timestamps"), NULL},
-	{GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL},
-	{GAIM_PREF_NONE, NULL, NULL, NULL}
+	{PURPLE_PREF_BOOLEAN, "/purple/gnt/conversations/timestamps", N_("Show Timestamps"), NULL},
+	{PURPLE_PREF_BOOLEAN, "/purple/gnt/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL},
+	{PURPLE_PREF_NONE, NULL, NULL, NULL}
 };
 
 static Prefs logging[] = 
 {
-	{GAIM_PREF_STRING, "/core/logging/format", N_("Log format"), get_log_options},
-	{GAIM_PREF_BOOLEAN, "/core/logging/log_ims", N_("Log IMs"), NULL},
-	{GAIM_PREF_BOOLEAN, "/core/logging/log_chats", N_("Log chats"), NULL},
-	{GAIM_PREF_BOOLEAN, "/core/logging/log_system", N_("Log status change events"), NULL},
-	{GAIM_PREF_NONE, NULL, NULL, NULL},
+	{PURPLE_PREF_STRING, "/core/logging/format", N_("Log format"), get_log_options},
+	{PURPLE_PREF_BOOLEAN, "/core/logging/log_ims", N_("Log IMs"), NULL},
+	{PURPLE_PREF_BOOLEAN, "/core/logging/log_chats", N_("Log chats"), NULL},
+	{PURPLE_PREF_BOOLEAN, "/core/logging/log_system", N_("Log status change events"), NULL},
+	{PURPLE_PREF_NONE, NULL, NULL, NULL},
 };
 
 /* XXX: Translate after the freeze */
 static Prefs idle[] =
 {
-	{GAIM_PREF_STRING, "/core/away/idle_reporting", "Report Idle time", get_idle_options},
-	{GAIM_PREF_BOOLEAN, "/core/away/away_when_idle", "Change status when idle", NULL},
-	{GAIM_PREF_INT, "/core/away/mins_before_away", "Minutes before changing status", NULL},
-	{GAIM_PREF_INT, "/core/savedstatus/idleaway", "Change status to", get_status_titles},
-	{GAIM_PREF_NONE, NULL, NULL, NULL},
+	{PURPLE_PREF_STRING, "/core/away/idle_reporting", "Report Idle time", get_idle_options},
+	{PURPLE_PREF_BOOLEAN, "/core/away/away_when_idle", "Change status when idle", NULL},
+	{PURPLE_PREF_INT, "/core/away/mins_before_away", "Minutes before changing status", NULL},
+	{PURPLE_PREF_INT, "/core/savedstatus/idleaway", "Change status to", get_status_titles},
+	{PURPLE_PREF_NONE, NULL, NULL, NULL},
 };
 
 static void
@@ -196,53 +196,53 @@
 }
 
 static void
-save_cb(void *data, GaimRequestFields *allfields)
+save_cb(void *data, PurpleRequestFields *allfields)
 {
 	GList *list;
-	for (list = gaim_request_fields_get_groups(allfields); list; list = list->next)
+	for (list = purple_request_fields_get_groups(allfields); list; list = list->next)
 	{
-		GaimRequestFieldGroup *group = list->data;
-		GList *fields = gaim_request_field_group_get_fields(group);
+		PurpleRequestFieldGroup *group = list->data;
+		GList *fields = purple_request_field_group_get_fields(group);
 		
 		for (; fields ; fields = fields->next)
 		{
-			GaimRequestField *field = fields->data;
-			GaimRequestFieldType type = gaim_request_field_get_type(field);
-			GaimPrefType pt;
+			PurpleRequestField *field = fields->data;
+			PurpleRequestFieldType type = purple_request_field_get_type(field);
+			PurplePrefType pt;
 			gpointer val = NULL;
-			const char *id = gaim_request_field_get_id(field);
+			const char *id = purple_request_field_get_id(field);
 
 			switch (type)
 			{
-				case GAIM_REQUEST_FIELD_LIST:
-					val = gaim_request_field_list_get_selected(field)->data;
+				case PURPLE_REQUEST_FIELD_LIST:
+					val = purple_request_field_list_get_selected(field)->data;
 					break;
-				case GAIM_REQUEST_FIELD_BOOLEAN:
-					val = GINT_TO_POINTER(gaim_request_field_bool_get_value(field));
+				case PURPLE_REQUEST_FIELD_BOOLEAN:
+					val = GINT_TO_POINTER(purple_request_field_bool_get_value(field));
 					break;
-				case GAIM_REQUEST_FIELD_INTEGER:
-					val = GINT_TO_POINTER(gaim_request_field_int_get_value(field));
+				case PURPLE_REQUEST_FIELD_INTEGER:
+					val = GINT_TO_POINTER(purple_request_field_int_get_value(field));
 					break;
-				case GAIM_REQUEST_FIELD_STRING:
-					val = (gpointer)gaim_request_field_string_get_value(field);
+				case PURPLE_REQUEST_FIELD_STRING:
+					val = (gpointer)purple_request_field_string_get_value(field);
 					break;
 				default:
 					break;
 			}
 
-			pt = gaim_prefs_get_type(id);
+			pt = purple_prefs_get_type(id);
 			switch (pt)
 			{
-				case GAIM_PREF_INT:
-					if (type == GAIM_REQUEST_FIELD_LIST) /* Lists always return string */
+				case PURPLE_PREF_INT:
+					if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */
 						sscanf(val, "%ld", (long int *)&val);
-					gaim_prefs_set_int(id, GPOINTER_TO_INT(val));
+					purple_prefs_set_int(id, GPOINTER_TO_INT(val));
 					break;
-				case GAIM_PREF_BOOLEAN:
-					gaim_prefs_set_bool(id, GPOINTER_TO_INT(val));
+				case PURPLE_PREF_BOOLEAN:
+					purple_prefs_set_bool(id, GPOINTER_TO_INT(val));
 					break;
-				case GAIM_PREF_STRING:
-					gaim_prefs_set_string(id, val);
+				case PURPLE_PREF_STRING:
+					purple_prefs_set_string(id, val);
 					break;
 				default:
 					break;
@@ -253,34 +253,34 @@
 }
 
 static void
-add_pref_group(GaimRequestFields *fields, const char *title, Prefs *prefs)
+add_pref_group(PurpleRequestFields *fields, const char *title, Prefs *prefs)
 {
-	GaimRequestField *field;
-	GaimRequestFieldGroup *group;
+	PurpleRequestField *field;
+	PurpleRequestFieldGroup *group;
 	int i;
 
-	group = gaim_request_field_group_new(title);
-	gaim_request_fields_add_group(fields, group);
+	group = purple_request_field_group_new(title);
+	purple_request_fields_add_group(fields, group);
 	for (i = 0; prefs[i].pref; i++)
 	{
 		field = get_pref_field(prefs + i);
 		if (field)
-			gaim_request_field_group_add_field(group, field);
+			purple_request_field_group_add_field(group, field);
 	}
 }
 
 void finch_prefs_show_all()
 {
-	GaimRequestFields *fields;
+	PurpleRequestFields *fields;
 
-	fields = gaim_request_fields_new();
+	fields = purple_request_fields_new();
 
 	add_pref_group(fields, _("Buddy List"), blist);
 	add_pref_group(fields, _("Conversations"), convs);
 	add_pref_group(fields, _("Logging"), logging);
 	add_pref_group(fields, _("Idle"), idle);
 
-	gaim_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
+	purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
 			_("Save"), G_CALLBACK(save_cb), _("Cancel"), free_strings, NULL);
 }