Mercurial > pidgin.yaz
comparison pidgin/plugins/convcolors.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | cebfc6af3eb5 |
children | 3d41d0d7fb9b |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
29 /* System headers */ | 29 /* System headers */ |
30 #include <gdk/gdk.h> | 30 #include <gdk/gdk.h> |
31 #include <glib.h> | 31 #include <glib.h> |
32 #include <gtk/gtk.h> | 32 #include <gtk/gtk.h> |
33 | 33 |
34 /* Gaim headers */ | 34 /* Purple headers */ |
35 #include <gtkplugin.h> | 35 #include <gtkplugin.h> |
36 #include <version.h> | 36 #include <version.h> |
37 | 37 |
38 #include <conversation.h> | 38 #include <conversation.h> |
39 #include <gtkconv.h> | 39 #include <gtkconv.h> |
72 FONT_UNDERLINE = 1 << 2 | 72 FONT_UNDERLINE = 1 << 2 |
73 }; | 73 }; |
74 | 74 |
75 struct | 75 struct |
76 { | 76 { |
77 GaimMessageFlags flag; | 77 PurpleMessageFlags flag; |
78 char *prefix; | 78 char *prefix; |
79 const char *text; | 79 const char *text; |
80 } formats[] = | 80 } formats[] = |
81 { | 81 { |
82 {GAIM_MESSAGE_ERROR, PREF_ERROR, N_("Error Messages")}, | 82 {PURPLE_MESSAGE_ERROR, PREF_ERROR, N_("Error Messages")}, |
83 {GAIM_MESSAGE_NICK, PREF_NICK, N_("Highlighted Messages")}, | 83 {PURPLE_MESSAGE_NICK, PREF_NICK, N_("Highlighted Messages")}, |
84 {GAIM_MESSAGE_SYSTEM, PREF_SYSTEM, N_("System Messages")}, | 84 {PURPLE_MESSAGE_SYSTEM, PREF_SYSTEM, N_("System Messages")}, |
85 {GAIM_MESSAGE_SEND, PREF_SEND, N_("Sent Messages")}, | 85 {PURPLE_MESSAGE_SEND, PREF_SEND, N_("Sent Messages")}, |
86 {GAIM_MESSAGE_RECV, PREF_RECV, N_("Received Messages")}, | 86 {PURPLE_MESSAGE_RECV, PREF_RECV, N_("Received Messages")}, |
87 {0, NULL, NULL} | 87 {0, NULL, NULL} |
88 }; | 88 }; |
89 | 89 |
90 static gboolean | 90 static gboolean |
91 displaying_msg(GaimAccount *account, const char *who, char **displaying, | 91 displaying_msg(PurpleAccount *account, const char *who, char **displaying, |
92 GaimConversation *conv, GaimMessageFlags flags) | 92 PurpleConversation *conv, PurpleMessageFlags flags) |
93 { | 93 { |
94 int i; | 94 int i; |
95 char tmp[128], *t; | 95 char tmp[128], *t; |
96 gboolean bold, italic, underline; | 96 gboolean bold, italic, underline; |
97 int f; | 97 int f; |
102 break; | 102 break; |
103 | 103 |
104 if (!formats[i].prefix) | 104 if (!formats[i].prefix) |
105 return FALSE; | 105 return FALSE; |
106 | 106 |
107 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && | 107 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM && |
108 !gaim_prefs_get_bool(PREF_IMS)) || | 108 !purple_prefs_get_bool(PREF_IMS)) || |
109 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && | 109 (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && |
110 !gaim_prefs_get_bool(PREF_CHATS))) | 110 !purple_prefs_get_bool(PREF_CHATS))) |
111 return FALSE; | 111 return FALSE; |
112 | 112 |
113 g_snprintf(tmp, sizeof(tmp), "%s/color", formats[i].prefix); | 113 g_snprintf(tmp, sizeof(tmp), "%s/color", formats[i].prefix); |
114 color = gaim_prefs_get_string(tmp); | 114 color = purple_prefs_get_string(tmp); |
115 | 115 |
116 g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); | 116 g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); |
117 f = gaim_prefs_get_int(tmp); | 117 f = purple_prefs_get_int(tmp); |
118 bold = (f & FONT_BOLD); | 118 bold = (f & FONT_BOLD); |
119 italic = (f & FONT_ITALIC); | 119 italic = (f & FONT_ITALIC); |
120 underline = (f & FONT_UNDERLINE); | 120 underline = (f & FONT_UNDERLINE); |
121 | 121 |
122 if (gaim_prefs_get_bool(PREF_IGNORE)) | 122 if (purple_prefs_get_bool(PREF_IGNORE)) |
123 { | 123 { |
124 t = *displaying; | 124 t = *displaying; |
125 *displaying = gaim_markup_strip_html(t); | 125 *displaying = purple_markup_strip_html(t); |
126 g_free(t); | 126 g_free(t); |
127 | 127 |
128 t = *displaying; | 128 t = *displaying; |
129 *displaying = g_markup_escape_text(t, -1); | 129 *displaying = g_markup_escape_text(t, -1); |
130 g_free(t); | 130 g_free(t); |
131 | 131 |
132 /* Restore the links */ | 132 /* Restore the links */ |
133 t = *displaying; | 133 t = *displaying; |
134 *displaying = gaim_markup_linkify(t); | 134 *displaying = purple_markup_linkify(t); |
135 g_free(t); | 135 g_free(t); |
136 } | 136 } |
137 | 137 |
138 if (color && *color) | 138 if (color && *color) |
139 { | 139 { |
156 | 156 |
157 return FALSE; | 157 return FALSE; |
158 } | 158 } |
159 | 159 |
160 static gboolean | 160 static gboolean |
161 plugin_load(GaimPlugin *plugin) | 161 plugin_load(PurplePlugin *plugin) |
162 { | 162 { |
163 gaim_signal_connect(pidgin_conversations_get_handle(), | 163 purple_signal_connect(pidgin_conversations_get_handle(), |
164 "displaying-im-msg", plugin, | 164 "displaying-im-msg", plugin, |
165 GAIM_CALLBACK(displaying_msg), NULL); | 165 PURPLE_CALLBACK(displaying_msg), NULL); |
166 gaim_signal_connect(pidgin_conversations_get_handle(), | 166 purple_signal_connect(pidgin_conversations_get_handle(), |
167 "displaying-chat-msg", plugin, | 167 "displaying-chat-msg", plugin, |
168 GAIM_CALLBACK(displaying_msg), NULL); | 168 PURPLE_CALLBACK(displaying_msg), NULL); |
169 return TRUE; | 169 return TRUE; |
170 } | 170 } |
171 | 171 |
172 static gboolean | 172 static gboolean |
173 plugin_unload(GaimPlugin *plugin) | 173 plugin_unload(PurplePlugin *plugin) |
174 { | 174 { |
175 return TRUE; | 175 return TRUE; |
176 } | 176 } |
177 | 177 |
178 /* Ripped from GaimRC */ | 178 /* Ripped from PurpleRC */ |
179 static void | 179 static void |
180 color_response(GtkDialog *color_dialog, gint response, const char *data) | 180 color_response(GtkDialog *color_dialog, gint response, const char *data) |
181 { | 181 { |
182 if (response == GTK_RESPONSE_OK) | 182 if (response == GTK_RESPONSE_OK) |
183 { | 183 { |
191 g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | 191 g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", |
192 color.red/256, color.green/256, color.blue/256); | 192 color.red/256, color.green/256, color.blue/256); |
193 | 193 |
194 g_snprintf(tmp, sizeof(tmp), "%s/color", data); | 194 g_snprintf(tmp, sizeof(tmp), "%s/color", data); |
195 | 195 |
196 gaim_prefs_set_string(tmp, colorstr); | 196 purple_prefs_set_string(tmp, colorstr); |
197 } | 197 } |
198 | 198 |
199 gtk_widget_destroy(GTK_WIDGET(color_dialog)); | 199 gtk_widget_destroy(GTK_WIDGET(color_dialog)); |
200 } | 200 } |
201 | 201 |
211 color_dialog = gtk_color_selection_dialog_new(title); | 211 color_dialog = gtk_color_selection_dialog_new(title); |
212 g_signal_connect(G_OBJECT(color_dialog), "response", | 212 g_signal_connect(G_OBJECT(color_dialog), "response", |
213 G_CALLBACK(color_response), (gpointer)data); | 213 G_CALLBACK(color_response), (gpointer)data); |
214 | 214 |
215 g_snprintf(tmp, sizeof(tmp), "%s/color", data); | 215 g_snprintf(tmp, sizeof(tmp), "%s/color", data); |
216 if (gdk_color_parse(gaim_prefs_get_string(tmp), &color)) | 216 if (gdk_color_parse(purple_prefs_get_string(tmp), &color)) |
217 { | 217 { |
218 gtk_color_selection_set_current_color( | 218 gtk_color_selection_set_current_color( |
219 GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); | 219 GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); |
220 } | 220 } |
221 | 221 |
227 { | 227 { |
228 int f; | 228 int f; |
229 char tmp[128]; | 229 char tmp[128]; |
230 | 230 |
231 g_snprintf(tmp, sizeof(tmp), "%s/format", prefix); | 231 g_snprintf(tmp, sizeof(tmp), "%s/format", prefix); |
232 f = gaim_prefs_get_int(tmp); | 232 f = purple_prefs_get_int(tmp); |
233 f ^= format; | 233 f ^= format; |
234 gaim_prefs_set_int(tmp, f); | 234 purple_prefs_set_int(tmp, f); |
235 } | 235 } |
236 | 236 |
237 static void | 237 static void |
238 toggle_bold(GtkWidget *widget, gpointer data) | 238 toggle_bold(GtkWidget *widget, gpointer data) |
239 { | 239 { |
251 { | 251 { |
252 toggle_something(data, FONT_UNDERLINE); | 252 toggle_something(data, FONT_UNDERLINE); |
253 } | 253 } |
254 | 254 |
255 static GtkWidget * | 255 static GtkWidget * |
256 get_config_frame(GaimPlugin *plugin) | 256 get_config_frame(PurplePlugin *plugin) |
257 { | 257 { |
258 GtkWidget *ret; | 258 GtkWidget *ret; |
259 GtkWidget *frame; | 259 GtkWidget *frame; |
260 int i; | 260 int i; |
261 | 261 |
267 char tmp[128]; | 267 char tmp[128]; |
268 int f; | 268 int f; |
269 GtkWidget *vbox, *hbox, *button; | 269 GtkWidget *vbox, *hbox, *button; |
270 | 270 |
271 g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); | 271 g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); |
272 f = gaim_prefs_get_int(tmp); | 272 f = purple_prefs_get_int(tmp); |
273 | 273 |
274 frame = pidgin_make_frame(ret, _(formats[i].text)); | 274 frame = pidgin_make_frame(ret, _(formats[i].text)); |
275 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | 275 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
276 gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); | 276 gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); |
277 | 277 |
319 { | 319 { |
320 get_config_frame, | 320 get_config_frame, |
321 0, | 321 0, |
322 }; | 322 }; |
323 | 323 |
324 static GaimPluginInfo info = | 324 static PurplePluginInfo info = |
325 { | 325 { |
326 GAIM_PLUGIN_MAGIC, /* Magic */ | 326 PURPLE_PLUGIN_MAGIC, /* Magic */ |
327 GAIM_MAJOR_VERSION, /* Gaim Major Version */ | 327 PURPLE_MAJOR_VERSION, /* Purple Major Version */ |
328 GAIM_MINOR_VERSION, /* Gaim Minor Version */ | 328 PURPLE_MINOR_VERSION, /* Purple Minor Version */ |
329 GAIM_PLUGIN_STANDARD, /* plugin type */ | 329 PURPLE_PLUGIN_STANDARD, /* plugin type */ |
330 PIDGIN_PLUGIN_TYPE, /* ui requirement */ | 330 PIDGIN_PLUGIN_TYPE, /* ui requirement */ |
331 0, /* flags */ | 331 0, /* flags */ |
332 NULL, /* dependencies */ | 332 NULL, /* dependencies */ |
333 GAIM_PRIORITY_DEFAULT, /* priority */ | 333 PURPLE_PRIORITY_DEFAULT, /* priority */ |
334 | 334 |
335 PLUGIN_ID, /* plugin id */ | 335 PLUGIN_ID, /* plugin id */ |
336 PLUGIN_NAME, /* name */ | 336 PLUGIN_NAME, /* name */ |
337 VERSION, /* version */ | 337 VERSION, /* version */ |
338 PLUGIN_SUMMARY, /* summary */ | 338 PLUGIN_SUMMARY, /* summary */ |
339 PLUGIN_DESCRIPTION, /* description */ | 339 PLUGIN_DESCRIPTION, /* description */ |
340 PLUGIN_AUTHOR, /* author */ | 340 PLUGIN_AUTHOR, /* author */ |
341 GAIM_WEBSITE, /* website */ | 341 PURPLE_WEBSITE, /* website */ |
342 | 342 |
343 plugin_load, /* load */ | 343 plugin_load, /* load */ |
344 plugin_unload, /* unload */ | 344 plugin_unload, /* unload */ |
345 NULL, /* destroy */ | 345 NULL, /* destroy */ |
346 | 346 |
349 NULL, /* prefs_info */ | 349 NULL, /* prefs_info */ |
350 NULL /* actions */ | 350 NULL /* actions */ |
351 }; | 351 }; |
352 | 352 |
353 static void | 353 static void |
354 init_plugin(GaimPlugin *plugin) | 354 init_plugin(PurplePlugin *plugin) |
355 { | 355 { |
356 gaim_prefs_add_none(PREF_PREFIX); | 356 purple_prefs_add_none(PREF_PREFIX); |
357 | 357 |
358 gaim_prefs_add_bool(PREF_IGNORE, TRUE); | 358 purple_prefs_add_bool(PREF_IGNORE, TRUE); |
359 gaim_prefs_add_bool(PREF_CHATS, TRUE); | 359 purple_prefs_add_bool(PREF_CHATS, TRUE); |
360 gaim_prefs_add_bool(PREF_IMS, TRUE); | 360 purple_prefs_add_bool(PREF_IMS, TRUE); |
361 | 361 |
362 gaim_prefs_add_none(PREF_SEND); | 362 purple_prefs_add_none(PREF_SEND); |
363 gaim_prefs_add_none(PREF_RECV); | 363 purple_prefs_add_none(PREF_RECV); |
364 gaim_prefs_add_none(PREF_SYSTEM); | 364 purple_prefs_add_none(PREF_SYSTEM); |
365 gaim_prefs_add_none(PREF_ERROR); | 365 purple_prefs_add_none(PREF_ERROR); |
366 gaim_prefs_add_none(PREF_NICK); | 366 purple_prefs_add_none(PREF_NICK); |
367 | 367 |
368 gaim_prefs_add_string(PREF_SEND_C, "#909090"); | 368 purple_prefs_add_string(PREF_SEND_C, "#909090"); |
369 gaim_prefs_add_string(PREF_RECV_C, "#000000"); | 369 purple_prefs_add_string(PREF_RECV_C, "#000000"); |
370 gaim_prefs_add_string(PREF_SYSTEM_C, "#50a050"); | 370 purple_prefs_add_string(PREF_SYSTEM_C, "#50a050"); |
371 gaim_prefs_add_string(PREF_ERROR_C, "#ff0000"); | 371 purple_prefs_add_string(PREF_ERROR_C, "#ff0000"); |
372 gaim_prefs_add_string(PREF_NICK_C, "#0000dd"); | 372 purple_prefs_add_string(PREF_NICK_C, "#0000dd"); |
373 | 373 |
374 gaim_prefs_add_int(PREF_SEND_F, 0); | 374 purple_prefs_add_int(PREF_SEND_F, 0); |
375 gaim_prefs_add_int(PREF_RECV_F, 0); | 375 purple_prefs_add_int(PREF_RECV_F, 0); |
376 gaim_prefs_add_int(PREF_SYSTEM_F, FONT_ITALIC); | 376 purple_prefs_add_int(PREF_SYSTEM_F, FONT_ITALIC); |
377 gaim_prefs_add_int(PREF_ERROR_F, FONT_BOLD | FONT_UNDERLINE); | 377 purple_prefs_add_int(PREF_ERROR_F, FONT_BOLD | FONT_UNDERLINE); |
378 gaim_prefs_add_int(PREF_NICK_F, FONT_BOLD); | 378 purple_prefs_add_int(PREF_NICK_F, FONT_BOLD); |
379 } | 379 } |
380 | 380 |
381 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) | 381 PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) |