annotate console/gntprefs.c @ 14511:f309a5b3f184

[gaim-migrate @ 17231] Switched from using libdbi to using sqlite3. Results in easier configuration (no need to setup database server/create database/add tables). Also Gtk Gaim no longer needs to link against libdbi. This should make the plugin more easily distributable and thus hopefully it can be included in binary releases of Gaim (fingers crossed). committer: Tailor Script <tailor@pidgin.im>
author Geoff Foster <g-off_>
date Mon, 11 Sep 2006 00:28:35 +0000
parents 28baa42b5ac2
children 81650a27f253
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include <prefs.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
3 #include "gntgaim.h"
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include "gntprefs.h"
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
5 #include "gntrequest.h"
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
6
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
7 #include <string.h>
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 void gg_prefs_init()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 gaim_prefs_add_none("/gaim");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 gaim_prefs_add_none("/gaim/gnt");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 gaim_prefs_add_none("/gaim/gnt/plugins");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 gaim_prefs_add_string_list("/gaim/gnt/plugins/loaded", NULL);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
16
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
17 gaim_prefs_add_none("/gaim/gnt/conversations");
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
18 gaim_prefs_add_bool("/gaim/gnt/conversations/timestamps", TRUE);
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
19 gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
20 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
21
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
22 typedef struct
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
23 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
24 GaimPrefType type;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
25 const char *pref;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
26 const char *label;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
27 GList *(*lv)(); /* If the value is to be selected from a number of choices */
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
28 } Prefs;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
29
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
30 static GList *
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
31 get_log_options()
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
32 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
33 return gaim_log_logger_get_options();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
34 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
35
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
36 static GaimRequestField *
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
37 get_pref_field(Prefs *prefs)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
38 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
39 GaimRequestField *field = NULL;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
40
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
41 if (prefs->lv == NULL)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
42 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
43 switch (prefs->type)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
44 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
45 case GAIM_PREF_BOOLEAN:
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
46 field = gaim_request_field_bool_new(prefs->pref, _(prefs->label),
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
47 gaim_prefs_get_bool(prefs->pref));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
48 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
49 case GAIM_PREF_INT:
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
50 field = gaim_request_field_int_new(prefs->pref, _(prefs->label),
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
51 gaim_prefs_get_int(prefs->pref));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
52 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
53 case GAIM_PREF_STRING:
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
54 field = gaim_request_field_string_new(prefs->pref, _(prefs->label),
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
55 gaim_prefs_get_string(prefs->pref), FALSE);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
56 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
57 default:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
58 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
59 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
60 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
61 else
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
62 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
63 GList *list = prefs->lv(), *iter;
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
64 field = gaim_request_field_list_new(prefs->pref, _(prefs->label));
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
65 for (iter = list; iter; iter = iter->next)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
66 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
67 gboolean select = FALSE;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
68 const char *data = iter->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
69 iter = iter->next;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
70 switch (prefs->type)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
71 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
72 case GAIM_PREF_BOOLEAN:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
73 if (gaim_prefs_get_bool(prefs->pref) == GPOINTER_TO_INT(iter->data))
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
74 select = TRUE;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
75 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
76 case GAIM_PREF_INT:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
77 if (gaim_prefs_get_int(prefs->pref) == GPOINTER_TO_INT(iter->data))
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
78 select = TRUE;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
79 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
80 case GAIM_PREF_STRING:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
81 if (strcmp(gaim_prefs_get_string(prefs->pref), iter->data) == 0)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
82 select = TRUE;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
83 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
84 default:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
85 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
86 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
87 gaim_request_field_list_add(field, data, iter->data);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
88 if (select)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
89 gaim_request_field_list_add_selected(field, data);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
90 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
91 g_list_free(list);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
92 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
93 return field;
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
96 static Prefs blist[] =
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
97 {
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
98 {GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/idletime", N_("Show Idle Time"), NULL},
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14198
diff changeset
99 {GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/showoffline", N_("Show Offline Buddies"), NULL},
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
100 {GAIM_PREF_NONE, NULL, NULL, NULL}
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
101 };
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
102
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
103 static Prefs convs[] =
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
104 {
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
105 {GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/timestamps", N_("Show Timestamps"), NULL},
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
106 {GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL},
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
107 {GAIM_PREF_NONE, NULL, NULL, NULL}
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
108 };
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
109
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
110 static Prefs logging[] =
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
111 {
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
112 {GAIM_PREF_STRING, "/core/logging/format", N_("Log format"), get_log_options},
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
113 {GAIM_PREF_BOOLEAN, "/core/logging/log_ims", N_("Log IMs"), NULL},
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
114 {GAIM_PREF_BOOLEAN, "/core/logging/log_chats", N_("Log chats"), NULL},
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
115 {GAIM_PREF_BOOLEAN, "/core/logging/log_system", N_("Log status change events"), NULL},
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
116 {GAIM_PREF_NONE, NULL, NULL, NULL},
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
117 };
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
118
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
119 static void
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
120 save_cb(void *data, GaimRequestFields *allfields)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
121 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
122 GList *list;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
123 for (list = gaim_request_fields_get_groups(allfields); list; list = list->next)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
124 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
125 GaimRequestFieldGroup *group = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
126 GList *fields = gaim_request_field_group_get_fields(group);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
127
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
128 for (; fields ; fields = fields->next)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
129 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
130 GaimRequestField *field = fields->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
131 GaimRequestFieldType type = gaim_request_field_get_type(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
132 GaimPrefType pt;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
133 gpointer val = NULL;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
134 const char *id = gaim_request_field_get_id(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
135
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
136 switch (type)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
137 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
138 case GAIM_REQUEST_FIELD_LIST:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
139 val = gaim_request_field_list_get_selected(field)->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
140 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
141 case GAIM_REQUEST_FIELD_BOOLEAN:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
142 val = GINT_TO_POINTER(gaim_request_field_bool_get_value(field));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
143 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
144 case GAIM_REQUEST_FIELD_INTEGER:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
145 val = GINT_TO_POINTER(gaim_request_field_int_get_value(field));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
146 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
147 case GAIM_REQUEST_FIELD_STRING:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
148 val = (gpointer)gaim_request_field_string_get_value(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
149 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
150 default:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
151 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
152 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
153
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
154 pt = gaim_prefs_get_type(id);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
155 switch (pt)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
156 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
157 case GAIM_PREF_INT:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
158 gaim_prefs_set_int(id, GPOINTER_TO_INT(val));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
159 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
160 case GAIM_PREF_BOOLEAN:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
161 gaim_prefs_set_bool(id, GPOINTER_TO_INT(val));
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
162 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
163 case GAIM_PREF_STRING:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
164 gaim_prefs_set_string(id, val);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
165 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
166 default:
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
167 break;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
168 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
169 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
170 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
171 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
172
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
173 static void
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
174 add_pref_group(GaimRequestFields *fields, const char *title, Prefs *prefs)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
175 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
176 GaimRequestField *field;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
177 GaimRequestFieldGroup *group;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
178 int i;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
179
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
180 group = gaim_request_field_group_new(title);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
181 gaim_request_fields_add_group(fields, group);
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
182 for (i = 0; prefs[i].pref; i++)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
183 {
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
184 field = get_pref_field(prefs + i);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
185 gaim_request_field_group_add_field(group, field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
186 }
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
187 }
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
188
14065
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
189 void gg_prefs_show_all()
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
190 {
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
191 GaimRequestFields *fields;
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
192
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
193 fields = gaim_request_fields_new();
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
194
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
195 add_pref_group(fields, _("Buddy List"), blist);
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
196 add_pref_group(fields, _("Conversations"), convs);
8ef994bacf3d [gaim-migrate @ 16686]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
197 add_pref_group(fields, _("Logging"), logging);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
198
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
199 gaim_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
200 _("Save"), G_CALLBACK(save_cb), _("Cancel"), NULL, NULL);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
201 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
202