Replace functions which called once with their bodies
[pidgin-git.git] / pidgin / plugins / transparency.c
blob388072ed314b262d8fd08ba60ef4e4d71fafde9a
1 /*
2 * Pidgin - Transparency plugin
4 * Copyright (C) 1998-2002, Rob Flynn <rob@marko.net>
5 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
6 * Copyright (C) 2005, Daniel Atallah <daniel_atallah@yahoo.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02111-1301, USA.
24 #include "internal.h"
26 #include "core.h"
27 #include "prefs.h"
28 #include "debug.h"
30 #include "gtkconv.h"
31 #include "gtkplugin.h"
32 #include "gtkprefs.h"
33 #include "gtkblist.h"
34 #include "gtkutils.h"
35 #include "signals.h"
36 #include "version.h"
39 * MACROS & DEFINES
41 /* The plugin name is left unchanged from its WinAPI days in order to keep it
42 * loading for users who were using it. */
43 #define WINTRANS_PLUGIN_ID "gtk-win-trans"
45 #define blist (purple_get_blist() \
46 ? (PIDGIN_BLIST(purple_get_blist()) \
47 ? ((PIDGIN_BLIST(purple_get_blist()))->window) \
48 : NULL) \
49 : NULL)
52 * DATA STRUCTS
54 typedef struct {
55 GtkWidget *win;
56 GtkWidget *slider;
57 } slider_win;
60 * LOCALS
62 static const char *OPT_WINTRANS_IM_ENABLED= "/plugins/gtk/transparency/im_enabled";
63 static const char *OPT_WINTRANS_IM_ALPHA = "/plugins/gtk/transparency/im_alpha";
64 static const char *OPT_WINTRANS_IM_SLIDER = "/plugins/gtk/transparency/im_slider";
65 static const char *OPT_WINTRANS_IM_ONFOCUS= "/plugins/gtk/transparency/im_solid_onfocus";
66 static const char *OPT_WINTRANS_IM_ONTOP = "/plugins/gtk/transparency/im_always_on_top";
67 static const char *OPT_WINTRANS_BL_ENABLED= "/plugins/gtk/transparency/bl_enabled";
68 static const char *OPT_WINTRANS_BL_ALPHA = "/plugins/gtk/transparency/bl_alpha";
69 static const char *OPT_WINTRANS_BL_ONFOCUS= "/plugins/gtk/transparency/bl_solid_onfocus";
70 static const char *OPT_WINTRANS_BL_ONTOP = "/plugins/gtk/transparency/bl_always_on_top";
71 static GSList *window_list = NULL;
74 * CODE
77 /* Set window transparency level */
78 static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled,
79 gboolean always_on_top) {
80 if (enabled) {
81 gdk_window_set_opacity(window->window, alpha / 255.0);
82 gdk_window_set_keep_above(window->window, always_on_top);
83 } else {
84 gdk_window_set_opacity(window->window, 1);
85 gdk_window_set_keep_above(window->window, 0);
89 /* When a conv window is focused, if we're only transparent when unfocused,
90 * deal with transparency */
91 static gboolean focus_conv_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) {
92 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)
93 && purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS)) {
94 GtkWidget *window = (GtkWidget *) d;
95 if (e->in) { /* Focused */
96 set_wintrans(window, 0, FALSE,
97 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
98 } else {
99 set_wintrans(window,
100 purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
101 TRUE,
102 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
105 return FALSE;
108 /* When buddy list window is focused,
109 * if we're only transparent when unfocused, deal with transparency */
110 static gboolean focus_blist_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) {
111 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)
112 && purple_prefs_get_bool(OPT_WINTRANS_BL_ONFOCUS)) {
113 GtkWidget *window = (GtkWidget *) d;
114 if (e->in) { /* Focused */
115 set_wintrans(window, 0, FALSE,
116 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
117 } else {
118 set_wintrans(window,
119 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
120 TRUE,
121 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
124 return FALSE;
127 static void change_alpha(GtkWidget *w, gpointer data) {
128 int alpha = gtk_range_get_value(GTK_RANGE(w));
129 purple_prefs_set_int(OPT_WINTRANS_IM_ALPHA, alpha);
131 /* If we're in no-transparency on focus mode,
132 * don't take effect immediately */
133 if (!purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS))
134 set_wintrans(GTK_WIDGET(data), alpha, TRUE,
135 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
139 static GtkWidget *wintrans_slider(GtkWidget *win) {
140 GtkWidget *hbox;
141 GtkWidget *label, *slider;
142 GtkWidget *frame;
144 int imalpha = purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA);
146 frame = gtk_frame_new(NULL);
147 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
148 gtk_widget_show(frame);
150 hbox = gtk_hbox_new(FALSE, 5);
151 gtk_container_add(GTK_CONTAINER(frame), hbox);
153 label = gtk_label_new(_("Opacity:"));
154 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
155 gtk_widget_show(hbox);
157 slider = gtk_hscale_new_with_range(50, 255, 1);
158 gtk_range_set_value(GTK_RANGE(slider), imalpha);
159 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
161 /* On slider val change, update window's transparency level */
162 g_signal_connect(GTK_OBJECT(slider), "value-changed",
163 G_CALLBACK(change_alpha), win);
165 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
167 /* Set the initial transparency level */
168 set_wintrans(win, imalpha, TRUE,
169 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
171 gtk_widget_show_all(hbox);
173 return frame;
176 static slider_win* find_slidwin(GtkWidget *win) {
177 GSList *tmp = window_list;
179 while (tmp) {
180 if (((slider_win*) (tmp->data))->win == win)
181 return (slider_win*) tmp->data;
182 tmp = tmp->next;
184 return NULL;
187 /* Clean up transparency stuff for the conv window */
188 static void cleanup_conv_window(PidginWindow *win) {
189 GtkWidget *window = win->window;
190 slider_win *slidwin = NULL;
192 /* Remove window from the window list */
193 purple_debug_info(WINTRANS_PLUGIN_ID,
194 "Conv window destroyed... removing from list\n");
196 if ((slidwin = find_slidwin(window))) {
197 window_list = g_slist_remove(window_list, slidwin);
198 g_free(slidwin);
201 /* Remove the focus cbs */
202 g_signal_handlers_disconnect_by_func(G_OBJECT(window),
203 G_CALLBACK(focus_conv_win_cb), window);
206 static void
207 conversation_delete_cb(PurpleConversation *conv) {
208 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
209 /* If it is the last conversation in the window, cleanup */
210 if (win != NULL && pidgin_conv_window_get_gtkconv_count(win) == 1)
211 cleanup_conv_window(win);
214 static void set_blist_trans(GtkWidget *w, const char *pref) {
215 gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
216 purple_prefs_set_bool(pref, enabled);
217 if (blist) {
218 set_wintrans(blist, purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
219 purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED),
220 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
224 static void add_slider(GtkWidget *win) {
225 GList *wl, *wl1;
226 GtkWidget *vbox = NULL;
228 /* Look up this window to see if it already has a slider */
229 if (!find_slidwin(win)) {
230 GtkWidget *slider_box = NULL;
231 slider_win *slidwin = NULL;
232 GtkRequisition slidereq;
233 gint width, height;
235 /* Get top vbox */
236 for (wl1 = wl = gtk_container_get_children(
237 GTK_CONTAINER(win));
238 wl != NULL;
239 wl = wl->next) {
240 if (GTK_IS_VBOX(GTK_OBJECT(wl->data)))
241 vbox = GTK_WIDGET(wl->data);
242 else {
243 purple_debug_error(WINTRANS_PLUGIN_ID,
244 "no vbox found\n");
245 return;
248 g_list_free(wl1);
250 slider_box = wintrans_slider(win);
251 /* Figure out how tall the slider wants to be */
252 gtk_widget_size_request(slider_box, &slidereq);
253 gtk_window_get_size(GTK_WINDOW(win), &width, &height);
254 gtk_box_pack_start(GTK_BOX(vbox),
255 slider_box, FALSE, FALSE, 0);
256 /* Add window to list, to track that it has a slider */
257 slidwin = g_new0(slider_win, 1);
258 slidwin->win = win;
259 slidwin->slider = slider_box;
260 window_list = g_slist_append(window_list, slidwin);
264 static void remove_sliders() {
265 if (window_list) {
266 GSList *tmp = window_list;
267 while (tmp) {
268 slider_win *slidwin = (slider_win*) tmp->data;
269 if (slidwin != NULL &&
270 GTK_IS_WINDOW(slidwin->win)) {
271 gtk_widget_destroy(slidwin->slider);
273 g_free(slidwin);
274 tmp = tmp->next;
276 g_slist_free(window_list);
277 window_list = NULL;
281 /* Remove all transparency related aspects from conversation windows */
282 static void remove_convs_wintrans(gboolean remove_signal) {
283 GList *wins;
285 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
286 PidginWindow *win = wins->data;
287 GtkWidget *window = win->window;
289 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED))
290 set_wintrans(window, 0, FALSE, FALSE);
292 /* Remove the focus cbs */
293 if (remove_signal)
294 g_signal_handlers_disconnect_by_func(G_OBJECT(window),
295 G_CALLBACK(focus_conv_win_cb), window);
298 remove_sliders();
301 static void set_conv_window_trans(PidginWindow *oldwin, PidginWindow *newwin) {
302 GtkWidget *win = newwin->window;
304 /* check prefs to see if we want trans */
305 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
306 set_wintrans(win, purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
307 TRUE, purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
309 if (purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) {
310 add_slider(win);
314 /* If we're moving from one window to another,
315 * add the focus listeners to the new window if not already there */
316 if (oldwin != NULL && oldwin != newwin) {
317 if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) {
318 g_signal_connect(G_OBJECT(win), "focus_in_event",
319 G_CALLBACK(focus_conv_win_cb), win);
320 g_signal_connect(G_OBJECT(win), "focus_out_event",
321 G_CALLBACK(focus_conv_win_cb), win);
324 /* If we've moved the last conversation, cleanup the window */
325 if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1)
326 cleanup_conv_window(oldwin);
330 static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) {
331 purple_prefs_set_bool(pref, gtk_toggle_button_get_active(
332 GTK_TOGGLE_BUTTON(toggle_btn)));
334 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
335 GList *wins;
337 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
338 PidginWindow *win = wins->data;
339 set_conv_window_trans(NULL, win);
342 if (!purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER))
343 remove_sliders();
345 else
346 remove_convs_wintrans(FALSE);
349 static void
350 conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) {
351 PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
352 PidginWindow *win = pidgin_conv_get_window(pconv);
354 if (type == PURPLE_CONV_UPDATE_UNSEEN && !pidgin_conv_is_hidden(pconv)
355 && pconv->unseen_state == PIDGIN_UNSEEN_NONE
356 && pidgin_conv_window_get_gtkconv_count(win) == 1) {
357 GtkWidget *window = win->window;
358 gboolean has_focus;
360 g_object_get(G_OBJECT(window), "has-toplevel-focus", &has_focus, NULL);
362 if (!has_focus || !purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS))
363 set_conv_window_trans(NULL, win);
365 if (g_signal_handler_find(G_OBJECT(window), G_SIGNAL_MATCH_FUNC,
366 0, 0, NULL, G_CALLBACK(focus_conv_win_cb), NULL) == 0) {
367 g_signal_connect(G_OBJECT(window), "focus_in_event",
368 G_CALLBACK(focus_conv_win_cb), window);
369 g_signal_connect(G_OBJECT(window), "focus_out_event",
370 G_CALLBACK(focus_conv_win_cb), window);
375 static void
376 new_conversation_cb(PurpleConversation *conv) {
377 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
379 /* If it is the first conversation in the window,
380 * add the sliders, and set transparency */
381 if (!pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv)) && pidgin_conv_window_get_gtkconv_count(win) == 1) {
382 GtkWidget *window = win->window;
384 set_conv_window_trans(NULL, win);
386 g_signal_connect(G_OBJECT(window), "focus_in_event",
387 G_CALLBACK(focus_conv_win_cb), window);
388 g_signal_connect(G_OBJECT(window), "focus_out_event",
389 G_CALLBACK(focus_conv_win_cb), window);
393 static void
394 blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) {
395 if (blist) {
396 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) {
397 set_wintrans(blist,
398 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
399 TRUE,
400 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
403 g_signal_connect(G_OBJECT(blist), "focus_in_event",
404 G_CALLBACK(focus_blist_win_cb), blist);
405 g_signal_connect(G_OBJECT(blist), "focus_out_event",
406 G_CALLBACK(focus_blist_win_cb), blist);
410 static void alpha_change(GtkWidget *w, gpointer data) {
411 GList *wins;
412 int imalpha = gtk_range_get_value(GTK_RANGE(w));
414 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
415 PidginWindow *win = wins->data;
416 set_wintrans(win->window, imalpha, TRUE,
417 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
421 static void alpha_pref_set_int (GtkWidget *w, GdkEventFocus *e, const char *pref)
423 int alpha = gtk_range_get_value(GTK_RANGE(w));
424 purple_prefs_set_int(pref, alpha);
427 static void bl_alpha_change(GtkWidget *w, gpointer data) {
428 if (blist)
429 change_alpha(w, blist);
432 static void update_existing_convs() {
433 GList *wins;
435 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
436 PidginWindow *win = wins->data;
437 GtkWidget *window = win->window;
439 set_conv_window_trans(NULL, win);
441 g_signal_connect(G_OBJECT(window), "focus_in_event",
442 G_CALLBACK(focus_conv_win_cb), window);
443 g_signal_connect(G_OBJECT(window), "focus_out_event",
444 G_CALLBACK(focus_conv_win_cb), window);
449 * EXPORTED FUNCTIONS
451 static gboolean plugin_load(PurplePlugin *plugin) {
453 purple_signal_connect(purple_conversations_get_handle(),
454 "conversation-created", plugin,
455 PURPLE_CALLBACK(new_conversation_cb), NULL);
457 /* Set callback to remove window from the list, if the window is destroyed */
458 purple_signal_connect(purple_conversations_get_handle(),
459 "deleting-conversation", plugin,
460 PURPLE_CALLBACK(conversation_delete_cb), NULL);
462 purple_signal_connect(pidgin_conversations_get_handle(),
463 "conversation-dragging", plugin,
464 PURPLE_CALLBACK(set_conv_window_trans), NULL);
466 purple_signal_connect(purple_conversations_get_handle(),
467 "conversation-updated", plugin,
468 PURPLE_CALLBACK(conv_updated_cb), NULL);
470 update_existing_convs();
472 if (blist)
473 blist_created_cb(NULL, NULL);
474 else
475 purple_signal_connect(pidgin_blist_get_handle(),
476 "gtkblist-created", plugin,
477 PURPLE_CALLBACK(blist_created_cb), NULL);
480 return TRUE;
483 static gboolean plugin_unload(PurplePlugin *plugin) {
484 purple_debug_info(WINTRANS_PLUGIN_ID, "Unloading transparency plugin\n");
486 remove_convs_wintrans(TRUE);
488 if (blist) {
489 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED))
490 set_wintrans(blist, 0, FALSE, FALSE);
492 /* Remove the focus cbs */
493 g_signal_handlers_disconnect_by_func(G_OBJECT(blist),
494 G_CALLBACK(focus_blist_win_cb), blist);
497 return TRUE;
500 static GtkWidget *get_config_frame(PurplePlugin *plugin) {
501 GtkWidget *ret;
502 GtkWidget *imtransbox, *bltransbox;
503 GtkWidget *hbox;
504 GtkWidget *label, *slider;
505 GtkWidget *button;
506 GtkWidget *trans_box;
508 ret = gtk_vbox_new(FALSE, 18);
509 gtk_container_set_border_width(GTK_CONTAINER (ret), 12);
511 /* IM Convo trans options */
512 imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows"));
513 button = pidgin_prefs_checkbox(_("_IM window transparency"),
514 OPT_WINTRANS_IM_ENABLED, imtransbox);
515 g_signal_connect(GTK_OBJECT(button), "clicked",
516 G_CALLBACK(update_convs_wintrans),
517 (gpointer) OPT_WINTRANS_IM_ENABLED);
519 trans_box = gtk_vbox_new(FALSE, 18);
520 gtk_widget_show(trans_box);
521 g_object_bind_property(button, "active", trans_box, "sensitive",
522 G_BINDING_SYNC_CREATE);
524 button = pidgin_prefs_checkbox(_("_Show slider bar in IM window"),
525 OPT_WINTRANS_IM_SLIDER, trans_box);
526 g_signal_connect(GTK_OBJECT(button), "clicked",
527 G_CALLBACK(update_convs_wintrans),
528 (gpointer) OPT_WINTRANS_IM_SLIDER);
530 button = pidgin_prefs_checkbox(
531 _("Remove IM window transparency on focus"),
532 OPT_WINTRANS_IM_ONFOCUS, trans_box);
534 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_IM_ONTOP,
535 trans_box);
536 g_signal_connect(GTK_OBJECT(button), "clicked",
537 G_CALLBACK(update_convs_wintrans),
538 (gpointer) OPT_WINTRANS_IM_ONTOP);
540 gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5);
542 /* IM transparency slider */
543 hbox = gtk_hbox_new(FALSE, 5);
545 label = gtk_label_new(_("Opacity:"));
546 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
548 slider = gtk_hscale_new_with_range(50, 255, 1);
549 gtk_range_set_value(GTK_RANGE(slider),
550 purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA));
551 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
553 g_signal_connect(GTK_OBJECT(slider), "value-changed",
554 G_CALLBACK(alpha_change), NULL);
555 g_signal_connect(GTK_OBJECT(slider), "focus-out-event",
556 G_CALLBACK(alpha_pref_set_int),
557 (gpointer) OPT_WINTRANS_IM_ALPHA);
559 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
561 gtk_widget_show_all(hbox);
563 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5);
565 /* Buddy List trans options */
566 bltransbox = pidgin_make_frame (ret, _("Buddy List Window"));
567 button = pidgin_prefs_checkbox(_("_Buddy List window transparency"),
568 OPT_WINTRANS_BL_ENABLED, bltransbox);
569 g_signal_connect(GTK_OBJECT(button), "clicked",
570 G_CALLBACK(set_blist_trans),
571 (gpointer) OPT_WINTRANS_BL_ENABLED);
573 trans_box = gtk_vbox_new(FALSE, 18);
574 gtk_widget_show(trans_box);
575 g_object_bind_property(button, "active", trans_box, "sensitive",
576 G_BINDING_SYNC_CREATE);
577 button = pidgin_prefs_checkbox(
578 _("Remove Buddy List window transparency on focus"),
579 OPT_WINTRANS_BL_ONFOCUS, trans_box);
580 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_BL_ONTOP,
581 trans_box);
582 g_signal_connect(GTK_OBJECT(button), "clicked",
583 G_CALLBACK(set_blist_trans),
584 (gpointer) OPT_WINTRANS_BL_ONTOP);
585 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5);
587 /* IM transparency slider */
588 hbox = gtk_hbox_new(FALSE, 5);
590 label = gtk_label_new(_("Opacity:"));
591 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
593 slider = gtk_hscale_new_with_range(50, 255, 1);
594 gtk_range_set_value(GTK_RANGE(slider),
595 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA));
597 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
599 g_signal_connect(GTK_OBJECT(slider), "value-changed",
600 G_CALLBACK(bl_alpha_change), NULL);
601 g_signal_connect(GTK_OBJECT(slider), "focus-out-event",
602 G_CALLBACK(alpha_pref_set_int),
603 (gpointer) OPT_WINTRANS_BL_ALPHA);
605 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
607 gtk_widget_show_all(hbox);
609 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5);
611 gtk_widget_show_all(ret);
612 return ret;
615 static PidginPluginUiInfo ui_info =
617 get_config_frame,
618 0, /* page_num (Reserved) */
620 /* padding */
621 NULL,
622 NULL,
623 NULL,
624 NULL
627 static PurplePluginInfo info =
629 PURPLE_PLUGIN_MAGIC,
630 PURPLE_MAJOR_VERSION,
631 PURPLE_MINOR_VERSION,
632 PURPLE_PLUGIN_STANDARD, /**< type */
633 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
634 0, /**< flags */
635 NULL, /**< dependencies */
636 PURPLE_PRIORITY_DEFAULT, /**< priority */
637 WINTRANS_PLUGIN_ID, /**< id */
638 N_("Transparency"), /**< name */
639 DISPLAY_VERSION, /**< version */
640 /** summary */
641 N_("Variable Transparency for the buddy list and conversations."),
642 /** description */
643 N_("This plugin enables variable alpha transparency on conversation windows and the buddy list."),
644 "Herman Bloggs <hermanator12002@yahoo.com>", /**< author */
645 PURPLE_WEBSITE, /**< homepage */
646 plugin_load, /**< load */
647 plugin_unload, /**< unload */
648 NULL, /**< destroy */
649 &ui_info, /**< ui_info */
650 NULL, /**< extra_info */
651 NULL, /**< prefs_info */
652 NULL, /**< actions */
654 /* padding */
655 NULL,
656 NULL,
657 NULL,
658 NULL
661 static void
662 init_plugin(PurplePlugin *plugin)
664 purple_prefs_add_none("/plugins/gtk");
665 purple_prefs_add_none("/plugins/gtk/transparency");
666 purple_prefs_add_bool(OPT_WINTRANS_IM_ENABLED, FALSE);
667 purple_prefs_add_int(OPT_WINTRANS_IM_ALPHA, 255);
668 purple_prefs_add_bool(OPT_WINTRANS_IM_SLIDER, FALSE);
669 purple_prefs_add_bool(OPT_WINTRANS_IM_ONFOCUS, FALSE);
670 purple_prefs_add_bool(OPT_WINTRANS_IM_ONTOP, FALSE);
671 purple_prefs_add_bool(OPT_WINTRANS_BL_ENABLED, FALSE);
672 purple_prefs_add_int(OPT_WINTRANS_BL_ALPHA, 255);
673 purple_prefs_add_bool(OPT_WINTRANS_BL_ONFOCUS, FALSE);
674 purple_prefs_add_bool(OPT_WINTRANS_BL_ONTOP, FALSE);
675 purple_prefs_rename("/plugins/gtk/win32/wintrans", "/plugins/gtk/transparency");
678 PURPLE_INIT_PLUGIN(wintrans, init_plugin, info)