7421
|
1 /*
|
|
2 * Contact priority settings plugin.
|
|
3 *
|
|
4 * Copyright (C) 2003 Etan Reisner, <deryni9@users.sourceforge.net>.
|
|
5 *
|
|
6 * This program is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU General Public License as
|
|
8 * published by the Free Software Foundation; either version 2 of the
|
|
9 * License, or (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
19 */
|
|
20
|
9821
|
21 #include "internal.h"
|
|
22 #include "gtkgaim.h"
|
7421
|
23 #include "gtkplugin.h"
|
|
24 #include "gtkutils.h"
|
|
25 #include "prefs.h"
|
9954
|
26 #include "version.h"
|
7421
|
27
|
|
28 #define CONTACT_PRIORITY_PLUGIN_ID "gtk-contact-priority"
|
|
29
|
|
30 static void
|
|
31 select_account(GtkWidget *widget, GaimAccount *account, gpointer data)
|
|
32 {
|
|
33 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data),
|
|
34 (gdouble)gaim_account_get_int(account, "score", 0));
|
|
35 }
|
|
36
|
|
37 static void
|
|
38 account_update(GtkWidget *widget, GtkOptionMenu *optmenu)
|
|
39 {
|
|
40 GaimAccount *account = NULL;
|
|
41
|
|
42 account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(optmenu)))), "account");
|
|
43 gaim_account_set_int(account, "score", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)));
|
|
44 }
|
|
45
|
|
46 static void
|
|
47 pref_update(GtkWidget *widget, gpointer data)
|
|
48 {
|
|
49 gchar pref[256];
|
|
50
|
|
51 g_snprintf(pref, sizeof(pref), "/core/contact/%s", (gchar *)data);
|
|
52
|
|
53 if (gaim_prefs_get_type(pref) == GAIM_PREF_INT)
|
|
54 gaim_prefs_set_int(pref, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)));
|
|
55 if (gaim_prefs_get_type(pref) == GAIM_PREF_BOOLEAN)
|
|
56 gaim_prefs_set_bool(pref, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
|
|
57 }
|
|
58
|
|
59 static GtkWidget *
|
|
60 get_config_frame(GaimPlugin *plugin)
|
|
61 {
|
|
62 GtkWidget *ret = NULL, *hbox = NULL, *frame = NULL, *vbox = NULL;
|
|
63 GtkWidget *label = NULL, *spin = NULL, *check = NULL;
|
|
64 GtkWidget *optmenu = NULL;
|
|
65 GtkObject *adj = NULL;
|
|
66 GtkSizeGroup *sg = NULL;
|
|
67 GaimAccount *account = NULL;
|
|
68 /*
|
|
69 GList *accounts = NULL;
|
|
70 */
|
|
71 int offline = gaim_prefs_get_int("/core/contact/offline_score");
|
|
72 int away = gaim_prefs_get_int("/core/contact/away_score");
|
|
73 int idle = gaim_prefs_get_int("/core/contact/idle_score");
|
|
74 /*
|
|
75 int score;
|
|
76 */
|
|
77 gboolean last_match = gaim_prefs_get_bool("/core/contact/last_match");
|
|
78
|
|
79 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
|
80
|
|
81 ret = gtk_vbox_new(FALSE, 18);
|
|
82 gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
|
|
83
|
|
84 frame = gaim_gtk_make_frame(ret, _("Point values to use when..."));
|
|
85
|
|
86 vbox = gtk_vbox_new(FALSE, 5);
|
|
87 gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
88
|
|
89 /* Offline */
|
|
90 hbox = gtk_hbox_new(FALSE, 5);
|
|
91 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
92
|
|
93 label = gtk_label_new_with_mnemonic(_("Buddy is offline:"));
|
|
94 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
95 gtk_size_group_add_widget(sg, label);
|
7439
|
96 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
7421
|
97
|
|
98 adj = gtk_adjustment_new(offline, -20, 20, 1, 1, 1);
|
|
99 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);
|
|
100 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "offline_score");
|
|
101 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);
|
|
102
|
|
103 /* Away */
|
|
104 hbox = gtk_hbox_new(FALSE, 5);
|
|
105 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
106
|
|
107 label = gtk_label_new_with_mnemonic(_("Buddy is away:"));
|
|
108 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
109 gtk_size_group_add_widget(sg, label);
|
7439
|
110 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
7421
|
111
|
|
112 adj = gtk_adjustment_new(away, -20, 20, 1, 1, 1);
|
|
113 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);
|
|
114 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "away_score");
|
|
115 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);
|
|
116
|
|
117 /* Idle */
|
|
118 hbox = gtk_hbox_new(FALSE, 5);
|
|
119 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
120
|
|
121 label = gtk_label_new_with_mnemonic(_("Buddy is idle:"));
|
|
122 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
123 gtk_size_group_add_widget(sg, label);
|
7439
|
124 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
7421
|
125
|
|
126 adj = gtk_adjustment_new(idle, -20, 20, 1, 1, 1);
|
|
127 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);
|
|
128 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "idle_score");
|
|
129 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);
|
|
130
|
|
131 /* Last match */
|
|
132 hbox = gtk_hbox_new(FALSE, 5);
|
|
133 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
134
|
|
135 check = gtk_check_button_new_with_label(_("Use last matching buddy"));
|
|
136 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), last_match);
|
|
137 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(pref_update), "last_match");
|
|
138 gtk_box_pack_start(GTK_BOX(hbox), check, FALSE, FALSE, 0);
|
|
139
|
|
140 /* Explanation */
|
10729
|
141 label = gtk_label_new(_("The buddy with the lowest score is the buddy who will have priority in the contact.\nThe default values (offline = 4, away = 2, and idle = 1) will use what used to be\nthe built-in order: active, idle, away, away + idle, offline."));
|
7421
|
142 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
143
|
10729
|
144 frame = gaim_gtk_make_frame(ret, _("Point values to use for account..."));
|
7421
|
145
|
|
146 vbox = gtk_vbox_new(FALSE, 5);
|
|
147 gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
148
|
|
149 /* Account */
|
|
150 hbox = gtk_hbox_new(FALSE, 5);
|
|
151 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
152
|
|
153 /* make this here so I can use it in the option menu callback, we'll
|
|
154 * actually set it up later */
|
|
155 adj = gtk_adjustment_new(0, -20, 20, 1, 1, 1);
|
|
156 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);
|
|
157
|
|
158 optmenu = gaim_gtk_account_option_menu_new(NULL, TRUE,
|
|
159 G_CALLBACK(select_account),
|
|
160 NULL, spin);
|
|
161 gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
|
|
162
|
|
163 /* this is where we set up the spin button we made above */
|
|
164 account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))))),
|
|
165 "account");
|
|
166 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
|
|
167 (gdouble)gaim_account_get_int(account, "score", 0));
|
|
168 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(spin), GTK_ADJUSTMENT(adj));
|
|
169 g_signal_connect(G_OBJECT(spin), "value-changed",
|
|
170 G_CALLBACK(account_update), optmenu);
|
|
171 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);
|
|
172
|
|
173 gtk_widget_show_all(ret);
|
|
174
|
|
175 return ret;
|
|
176 }
|
|
177
|
|
178 static GaimGtkPluginUiInfo ui_info =
|
|
179 {
|
|
180 get_config_frame
|
|
181 };
|
|
182
|
|
183 static GaimPluginInfo info =
|
|
184 {
|
9954
|
185 GAIM_PLUGIN_MAGIC,
|
|
186 GAIM_MAJOR_VERSION,
|
|
187 GAIM_MINOR_VERSION,
|
7421
|
188 GAIM_PLUGIN_STANDARD, /**< type */
|
|
189 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
|
|
190 0, /**< flags */
|
|
191 NULL, /**< dependencies */
|
|
192 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
193
|
|
194 CONTACT_PRIORITY_PLUGIN_ID, /**< id */
|
|
195 N_("Contact Priority"), /**< name */
|
|
196 VERSION, /**< version */
|
|
197 /**< summary */
|
|
198 N_("Allows for controlling the values associated with different buddy states."),
|
|
199 /**< description */
|
|
200 N_("Allows for changing the point values of idle/away/offline states for buddies in contact priority computations."),
|
|
201 "Etan Reisner <deryni@eden.rutgers.edu>", /**< author */
|
|
202 GAIM_WEBSITE, /**< homepage */
|
|
203
|
|
204 NULL, /**< load */
|
|
205 NULL, /**< unload */
|
|
206 NULL, /**< destroy */
|
|
207 &ui_info, /**< ui_info */
|
|
208 NULL /**< extra_info */
|
|
209 };
|
|
210
|
|
211 static void
|
|
212 init_plugin(GaimPlugin *plugin)
|
|
213 {
|
|
214 }
|
|
215
|
|
216 GAIM_INIT_PLUGIN(contactpriority, init_plugin, info)
|