Mercurial > pidgin.yaz
annotate plugins/contact_priority.c @ 9930:45a49b01dc03
[gaim-migrate @ 10822]
i didn't mean to commit this
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 01 Sep 2004 02:03:09 +0000 |
parents | a09ffb82aef1 |
children | a9fb4493ae22 |
rev | line source |
---|---|
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" | |
26 | |
27 #define CONTACT_PRIORITY_PLUGIN_ID "gtk-contact-priority" | |
28 | |
29 static void | |
30 select_account(GtkWidget *widget, GaimAccount *account, gpointer data) | |
31 { | |
32 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data), | |
33 (gdouble)gaim_account_get_int(account, "score", 0)); | |
34 } | |
35 | |
36 static void | |
37 account_update(GtkWidget *widget, GtkOptionMenu *optmenu) | |
38 { | |
39 GaimAccount *account = NULL; | |
40 | |
41 account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(optmenu)))), "account"); | |
42 gaim_account_set_int(account, "score", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget))); | |
43 } | |
44 | |
45 static void | |
46 pref_update(GtkWidget *widget, gpointer data) | |
47 { | |
48 gchar pref[256]; | |
49 | |
50 g_snprintf(pref, sizeof(pref), "/core/contact/%s", (gchar *)data); | |
51 | |
52 if (gaim_prefs_get_type(pref) == GAIM_PREF_INT) | |
53 gaim_prefs_set_int(pref, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget))); | |
54 if (gaim_prefs_get_type(pref) == GAIM_PREF_BOOLEAN) | |
55 gaim_prefs_set_bool(pref, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); | |
56 } | |
57 | |
58 static GtkWidget * | |
59 get_config_frame(GaimPlugin *plugin) | |
60 { | |
61 GtkWidget *ret = NULL, *hbox = NULL, *frame = NULL, *vbox = NULL; | |
62 GtkWidget *label = NULL, *spin = NULL, *check = NULL; | |
63 GtkWidget *optmenu = NULL; | |
64 GtkObject *adj = NULL; | |
65 GtkSizeGroup *sg = NULL; | |
66 GaimAccount *account = NULL; | |
67 /* | |
68 GList *accounts = NULL; | |
69 */ | |
70 int offline = gaim_prefs_get_int("/core/contact/offline_score"); | |
71 int away = gaim_prefs_get_int("/core/contact/away_score"); | |
72 int idle = gaim_prefs_get_int("/core/contact/idle_score"); | |
73 /* | |
74 int score; | |
75 */ | |
76 gboolean last_match = gaim_prefs_get_bool("/core/contact/last_match"); | |
77 | |
78 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
79 | |
80 ret = gtk_vbox_new(FALSE, 18); | |
81 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
82 | |
83 frame = gaim_gtk_make_frame(ret, _("Point values to use when...")); | |
84 | |
85 vbox = gtk_vbox_new(FALSE, 5); | |
86 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
87 | |
88 /* Offline */ | |
89 hbox = gtk_hbox_new(FALSE, 5); | |
90 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
91 | |
92 label = gtk_label_new_with_mnemonic(_("Buddy is offline:")); | |
93 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
94 gtk_size_group_add_widget(sg, label); | |
7439 | 95 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
7421 | 96 |
97 adj = gtk_adjustment_new(offline, -20, 20, 1, 1, 1); | |
98 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); | |
99 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "offline_score"); | |
100 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); | |
101 | |
102 /* Away */ | |
103 hbox = gtk_hbox_new(FALSE, 5); | |
104 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
105 | |
106 label = gtk_label_new_with_mnemonic(_("Buddy is away:")); | |
107 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
108 gtk_size_group_add_widget(sg, label); | |
7439 | 109 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
7421 | 110 |
111 adj = gtk_adjustment_new(away, -20, 20, 1, 1, 1); | |
112 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); | |
113 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "away_score"); | |
114 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); | |
115 | |
116 /* Idle */ | |
117 hbox = gtk_hbox_new(FALSE, 5); | |
118 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
119 | |
120 label = gtk_label_new_with_mnemonic(_("Buddy is idle:")); | |
121 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
122 gtk_size_group_add_widget(sg, label); | |
7439 | 123 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
7421 | 124 |
125 adj = gtk_adjustment_new(idle, -20, 20, 1, 1, 1); | |
126 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); | |
127 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), "idle_score"); | |
128 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); | |
129 | |
130 /* Last match */ | |
131 hbox = gtk_hbox_new(FALSE, 5); | |
132 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
133 | |
134 check = gtk_check_button_new_with_label(_("Use last matching buddy")); | |
135 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), last_match); | |
136 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(pref_update), "last_match"); | |
137 gtk_box_pack_start(GTK_BOX(hbox), check, FALSE, FALSE, 0); | |
138 | |
139 /* Explanation */ | |
140 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)\nwill use what used to be the built-in order active->idle->away->away+idle->offline.")); | |
141 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
142 | |
143 frame = gaim_gtk_make_frame(ret, _("Point values to use for Account...")); | |
144 | |
145 vbox = gtk_vbox_new(FALSE, 5); | |
146 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
147 | |
148 /* Account */ | |
149 hbox = gtk_hbox_new(FALSE, 5); | |
150 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
151 | |
152 /* make this here so I can use it in the option menu callback, we'll | |
153 * actually set it up later */ | |
154 adj = gtk_adjustment_new(0, -20, 20, 1, 1, 1); | |
155 spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); | |
156 | |
157 optmenu = gaim_gtk_account_option_menu_new(NULL, TRUE, | |
158 G_CALLBACK(select_account), | |
159 NULL, spin); | |
160 gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0); | |
161 | |
162 /* this is where we set up the spin button we made above */ | |
163 account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))))), | |
164 "account"); | |
165 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), | |
166 (gdouble)gaim_account_get_int(account, "score", 0)); | |
167 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(spin), GTK_ADJUSTMENT(adj)); | |
168 g_signal_connect(G_OBJECT(spin), "value-changed", | |
169 G_CALLBACK(account_update), optmenu); | |
170 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); | |
171 | |
172 gtk_widget_show_all(ret); | |
173 | |
174 return ret; | |
175 } | |
176 | |
177 static GaimGtkPluginUiInfo ui_info = | |
178 { | |
179 get_config_frame | |
180 }; | |
181 | |
182 static GaimPluginInfo info = | |
183 { | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
7439
diff
changeset
|
184 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
7421 | 185 GAIM_PLUGIN_STANDARD, /**< type */ |
186 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ | |
187 0, /**< flags */ | |
188 NULL, /**< dependencies */ | |
189 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
190 | |
191 CONTACT_PRIORITY_PLUGIN_ID, /**< id */ | |
192 N_("Contact Priority"), /**< name */ | |
193 VERSION, /**< version */ | |
194 /**< summary */ | |
195 N_("Allows for controlling the values associated with different buddy states."), | |
196 /**< description */ | |
197 N_("Allows for changing the point values of idle/away/offline states for buddies in contact priority computations."), | |
198 "Etan Reisner <deryni@eden.rutgers.edu>", /**< author */ | |
199 GAIM_WEBSITE, /**< homepage */ | |
200 | |
201 NULL, /**< load */ | |
202 NULL, /**< unload */ | |
203 NULL, /**< destroy */ | |
204 &ui_info, /**< ui_info */ | |
205 NULL /**< extra_info */ | |
206 }; | |
207 | |
208 static void | |
209 init_plugin(GaimPlugin *plugin) | |
210 { | |
211 } | |
212 | |
213 GAIM_INIT_PLUGIN(contactpriority, init_plugin, info) |