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