pidgin/plugins/transparency.c

Thu, 16 Nov 2017 01:44:46 +0100

author
Daniel Kamil Kozar <dkk089@gmail.com>
date
Thu, 16 Nov 2017 01:44:46 +0100
branch
gtk-transparency-2
changeset 38775
138239f698a9
child 38776
6c859ab87e6c
permissions
-rw-r--r--

Port transparency plugin from WinAPI to GTK. Fixes #3124

38775
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
1 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
2 * Pidgin - Transparency plugin
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
3 *
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
4 * Copyright (C) 1998-2002, Rob Flynn <rob@marko.net>
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2005, Daniel Atallah <daniel_atallah@yahoo.com>
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
7 *
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation; either version 2 of the
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
12 *
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
17 *
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
21 * 02111-1301, USA.
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
22 *
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
23 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
24 #include "internal.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
25
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
26 #include "core.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
27 #include "prefs.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
28 #include "debug.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
29
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
30 #include "gtkconv.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
31 #include "gtkplugin.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
32 #include "gtkprefs.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
33 #include "gtkblist.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
34 #include "gtkutils.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
35 #include "signals.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
36 #include "version.h"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
37
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
38 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
39 * MACROS & DEFINES
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
40 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
41 #define WINTRANS_PLUGIN_ID "gtk-win-trans"
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
42
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
43 #define blist (purple_get_blist() \
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
44 ? (PIDGIN_BLIST(purple_get_blist()) \
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
45 ? ((PIDGIN_BLIST(purple_get_blist()))->window) \
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
46 : NULL) \
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
47 : NULL)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
48
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
49 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
50 * DATA STRUCTS
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
51 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
52 typedef struct {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
53 GtkWidget *win;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
54 GtkWidget *slider;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
55 } slider_win;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
56
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
57 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
58 * LOCALS
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
59 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
60 static const char *OPT_WINTRANS_IM_ENABLED= "/plugins/gtk/transparency/im_enabled";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
61 static const char *OPT_WINTRANS_IM_ALPHA = "/plugins/gtk/transparency/im_alpha";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
62 static const char *OPT_WINTRANS_IM_SLIDER = "/plugins/gtk/transparency/im_slider";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
63 static const char *OPT_WINTRANS_IM_ONFOCUS= "/plugins/gtk/transparency/im_solid_onfocus";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
64 static const char *OPT_WINTRANS_IM_ONTOP = "/plugins/gtk/transparency/im_always_on_top";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
65 static const char *OPT_WINTRANS_BL_ENABLED= "/plugins/gtk/transparency/bl_enabled";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
66 static const char *OPT_WINTRANS_BL_ALPHA = "/plugins/gtk/transparency/bl_alpha";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
67 static const char *OPT_WINTRANS_BL_ONFOCUS= "/plugins/gtk/transparency/bl_solid_onfocus";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
68 static const char *OPT_WINTRANS_BL_ONTOP = "/plugins/gtk/transparency/bl_always_on_top";
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
69 static GSList *window_list = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
70
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
71 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
72 * CODE
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
73 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
74
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
75 /* Set window transparency level */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
76 static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
77 gboolean always_on_top) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
78 if (enabled) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
79 gdk_window_set_opacity(window->window, alpha / 255.0);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
80 gdk_window_set_keep_above(window->window, always_on_top);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
81 } else {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
82 gdk_window_set_opacity(window->window, 1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
83 gdk_window_set_keep_above(window->window, 0);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
84 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
85 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
86
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
87 /* When a conv window is focused, if we're only transparent when unfocused,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
88 * deal with transparency */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
89 static gboolean focus_conv_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
90 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
91 && purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
92 GtkWidget *window = (GtkWidget *) d;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
93 if (e->in) { /* Focused */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
94 set_wintrans(window, 0, FALSE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
95 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
96 } else {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
97 set_wintrans(window,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
98 purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
99 TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
100 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
101 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
102 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
103 return FALSE;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
104 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
105
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
106 /* When buddy list window is focused,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
107 * if we're only transparent when unfocused, deal with transparency */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
108 static gboolean focus_blist_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
109 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
110 && purple_prefs_get_bool(OPT_WINTRANS_BL_ONFOCUS)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
111 GtkWidget *window = (GtkWidget *) d;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
112 if (e->in) { /* Focused */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
113 set_wintrans(window, 0, FALSE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
114 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
115 } else {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
116 set_wintrans(window,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
117 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
118 TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
119 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
120 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
121 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
122 return FALSE;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
123 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
124
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
125 static void change_alpha(GtkWidget *w, gpointer data) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
126 int alpha = gtk_range_get_value(GTK_RANGE(w));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
127 purple_prefs_set_int(OPT_WINTRANS_IM_ALPHA, alpha);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
128
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
129 /* If we're in no-transparency on focus mode,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
130 * don't take effect immediately */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
131 if (!purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
132 set_wintrans(GTK_WIDGET(data), alpha, TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
133 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
134 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
135
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
136
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
137 static GtkWidget *wintrans_slider(GtkWidget *win) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
138 GtkWidget *hbox;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
139 GtkWidget *label, *slider;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
140 GtkWidget *frame;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
141
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
142 int imalpha = purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
143
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
144 frame = gtk_frame_new(NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
145 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
146 gtk_widget_show(frame);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
147
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
148 hbox = gtk_hbox_new(FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
149 gtk_container_add(GTK_CONTAINER(frame), hbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
150
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
151 label = gtk_label_new(_("Opacity:"));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
152 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
153 gtk_widget_show(hbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
154
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
155 slider = gtk_hscale_new_with_range(50, 255, 1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
156 gtk_range_set_value(GTK_RANGE(slider), imalpha);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
157 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
158
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
159 /* On slider val change, update window's transparency level */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
160 g_signal_connect(GTK_OBJECT(slider), "value-changed",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
161 G_CALLBACK(change_alpha), win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
162
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
163 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
164
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
165 /* Set the initial transparency level */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
166 set_wintrans(win, imalpha, TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
167 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
168
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
169 gtk_widget_show_all(hbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
170
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
171 return frame;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
172 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
173
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
174 static slider_win* find_slidwin(GtkWidget *win) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
175 GSList *tmp = window_list;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
176
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
177 while (tmp) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
178 if (((slider_win*) (tmp->data))->win == win)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
179 return (slider_win*) tmp->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
180 tmp = tmp->next;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
181 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
182 return NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
183 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
184
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
185 /* Clean up transparency stuff for the conv window */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
186 static void cleanup_conv_window(PidginWindow *win) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
187 GtkWidget *window = win->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
188 slider_win *slidwin = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
189
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
190 /* Remove window from the window list */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
191 purple_debug_info(WINTRANS_PLUGIN_ID,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
192 "Conv window destroyed... removing from list\n");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
193
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
194 if ((slidwin = find_slidwin(window))) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
195 window_list = g_slist_remove(window_list, slidwin);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
196 g_free(slidwin);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
197 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
198
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
199 /* Remove the focus cbs */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
200 g_signal_handlers_disconnect_by_func(G_OBJECT(window),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
201 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
202 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
203
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
204 static void
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
205 conversation_delete_cb(PurpleConversation *conv) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
206 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
207 /* If it is the last conversation in the window, cleanup */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
208 if (win != NULL && pidgin_conv_window_get_gtkconv_count(win) == 1)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
209 cleanup_conv_window(win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
210 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
211
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
212 static void set_blist_trans(GtkWidget *w, const char *pref) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
213 gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
214 purple_prefs_set_bool(pref, enabled);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
215 if (blist) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
216 set_wintrans(blist, purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
217 purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
218 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
219 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
220 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
221
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
222 static void add_slider(GtkWidget *win) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
223 GList *wl, *wl1;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
224 GtkWidget *vbox = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
225
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
226 /* Look up this window to see if it already has a slider */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
227 if (!find_slidwin(win)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
228 GtkWidget *slider_box = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
229 slider_win *slidwin = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
230 GtkRequisition slidereq;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
231 gint width, height;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
232
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
233 /* Get top vbox */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
234 for (wl1 = wl = gtk_container_get_children(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
235 GTK_CONTAINER(win));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
236 wl != NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
237 wl = wl->next) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
238 if (GTK_IS_VBOX(GTK_OBJECT(wl->data)))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
239 vbox = GTK_WIDGET(wl->data);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
240 else {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
241 purple_debug_error(WINTRANS_PLUGIN_ID,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
242 "no vbox found\n");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
243 return;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
244 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
245 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
246 g_list_free(wl1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
247
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
248 slider_box = wintrans_slider(win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
249 /* Figure out how tall the slider wants to be */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
250 gtk_widget_size_request(slider_box, &slidereq);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
251 gtk_window_get_size(GTK_WINDOW(win), &width, &height);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
252 gtk_box_pack_start(GTK_BOX(vbox),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
253 slider_box, FALSE, FALSE, 0);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
254 #if 0 /*Now that we save window sizes, don't resize it or else it causes windows to grow*/
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
255 /* Make window taller so we don't slowly collapse its message area */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
256 gtk_window_resize(GTK_WINDOW(win), width,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
257 (height + slidereq.height));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
258 #endif
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
259 /* Add window to list, to track that it has a slider */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
260 slidwin = g_new0(slider_win, 1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
261 slidwin->win = win;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
262 slidwin->slider = slider_box;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
263 window_list = g_slist_append(window_list, slidwin);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
264 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
265 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
266
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
267 static void remove_sliders() {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
268 if (window_list) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
269 GSList *tmp = window_list;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
270 while (tmp) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
271 slider_win *slidwin = (slider_win*) tmp->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
272 if (slidwin != NULL &&
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
273 GTK_IS_WINDOW(slidwin->win)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
274 #if 0
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
275 GtkRequisition slidereq;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
276 gint width, height;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
277 /* Figure out how tall the slider was */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
278 gtk_widget_size_request(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
279 slidwin->slider, &slidereq);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
280 gtk_window_get_size(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
281 GTK_WINDOW(slidwin->win),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
282 &width, &height);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
283 #endif
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
284 gtk_widget_destroy(slidwin->slider);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
285 #if 0
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
286 gtk_window_resize(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
287 GTK_WINDOW(slidwin->win),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
288 width, (height - slidereq.height));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
289 #endif
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
290 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
291 g_free(slidwin);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
292 tmp = tmp->next;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
293 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
294 g_slist_free(window_list);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
295 window_list = NULL;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
296 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
297 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
298
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
299 /* Remove all transparency related aspects from conversation windows */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
300 static void remove_convs_wintrans(gboolean remove_signal) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
301 GList *wins;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
302
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
303 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
304 PidginWindow *win = wins->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
305 GtkWidget *window = win->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
306
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
307 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
308 set_wintrans(window, 0, FALSE, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
309
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
310 /* Remove the focus cbs */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
311 if (remove_signal)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
312 g_signal_handlers_disconnect_by_func(G_OBJECT(window),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
313 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
314 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
315
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
316 remove_sliders();
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
317 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
318
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
319 static void set_conv_window_trans(PidginWindow *oldwin, PidginWindow *newwin) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
320 GtkWidget *win = newwin->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
321
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
322 /* check prefs to see if we want trans */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
323 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
324 set_wintrans(win, purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
325 TRUE, purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
326
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
327 if (purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
328 add_slider(win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
329 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
330 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
331
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
332 /* If we're moving from one window to another,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
333 * add the focus listeners to the new window if not already there */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
334 if (oldwin != NULL && oldwin != newwin) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
335 if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
336 g_signal_connect(G_OBJECT(win), "focus_in_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
337 G_CALLBACK(focus_conv_win_cb), win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
338 g_signal_connect(G_OBJECT(win), "focus_out_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
339 G_CALLBACK(focus_conv_win_cb), win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
340 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
341
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
342 /* If we've moved the last conversation, cleanup the window */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
343 if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
344 cleanup_conv_window(oldwin);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
345 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
346 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
347
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
348 static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
349 purple_prefs_set_bool(pref, gtk_toggle_button_get_active(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
350 GTK_TOGGLE_BUTTON(toggle_btn)));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
351
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
352 if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
353 GList *wins;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
354
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
355 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
356 PidginWindow *win = wins->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
357 set_conv_window_trans(NULL, win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
358 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
359
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
360 if (!purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
361 remove_sliders();
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
362 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
363 else
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
364 remove_convs_wintrans(FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
365 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
366
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
367 static void
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
368 conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
369 PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
370 PidginWindow *win = pidgin_conv_get_window(pconv);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
371
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
372 if (type == PURPLE_CONV_UPDATE_UNSEEN && !pidgin_conv_is_hidden(pconv)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
373 && pconv->unseen_state == PIDGIN_UNSEEN_NONE
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
374 && pidgin_conv_window_get_gtkconv_count(win) == 1) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
375 GtkWidget *window = win->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
376 gboolean has_focus;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
377
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
378 g_object_get(G_OBJECT(window), "has-toplevel-focus", &has_focus, NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
379
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
380 if (!has_focus || !purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
381 set_conv_window_trans(NULL, win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
382
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
383 if (g_signal_handler_find(G_OBJECT(window), G_SIGNAL_MATCH_FUNC,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
384 0, 0, NULL, G_CALLBACK(focus_conv_win_cb), NULL) == 0) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
385 g_signal_connect(G_OBJECT(window), "focus_in_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
386 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
387 g_signal_connect(G_OBJECT(window), "focus_out_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
388 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
389 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
390 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
391 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
392
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
393 static void
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
394 new_conversation_cb(PurpleConversation *conv) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
395 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
396
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
397 /* If it is the first conversation in the window,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
398 * add the sliders, and set transparency */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
399 if (!pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv)) && pidgin_conv_window_get_gtkconv_count(win) == 1) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
400 GtkWidget *window = win->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
401
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
402 set_conv_window_trans(NULL, win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
403
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
404 g_signal_connect(G_OBJECT(window), "focus_in_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
405 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
406 g_signal_connect(G_OBJECT(window), "focus_out_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
407 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
408 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
409 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
410
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
411 static void
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
412 blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
413 if (blist) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
414 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
415 set_wintrans(blist,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
416 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
417 TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
418 purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
419 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
420
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
421 g_signal_connect(G_OBJECT(blist), "focus_in_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
422 G_CALLBACK(focus_blist_win_cb), blist);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
423 g_signal_connect(G_OBJECT(blist), "focus_out_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
424 G_CALLBACK(focus_blist_win_cb), blist);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
425 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
426 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
427
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
428 static void alpha_change(GtkWidget *w, gpointer data) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
429 GList *wins;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
430 int imalpha = gtk_range_get_value(GTK_RANGE(w));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
431
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
432 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
433 PidginWindow *win = wins->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
434 set_wintrans(win->window, imalpha, TRUE,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
435 purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
436 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
437 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
438
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
439 static void alpha_pref_set_int (GtkWidget *w, GdkEventFocus *e, const char *pref)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
440 {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
441 int alpha = gtk_range_get_value(GTK_RANGE(w));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
442 purple_prefs_set_int(pref, alpha);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
443 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
444
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
445 static void bl_alpha_change(GtkWidget *w, gpointer data) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
446 if (blist)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
447 change_alpha(w, blist);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
448 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
449
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
450 static void update_existing_convs() {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
451 GList *wins;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
452
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
453 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
454 PidginWindow *win = wins->data;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
455 GtkWidget *window = win->window;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
456
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
457 set_conv_window_trans(NULL, win);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
458
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
459 g_signal_connect(G_OBJECT(window), "focus_in_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
460 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
461 g_signal_connect(G_OBJECT(window), "focus_out_event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
462 G_CALLBACK(focus_conv_win_cb), window);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
463 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
464 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
465
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
466 /*
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
467 * EXPORTED FUNCTIONS
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
468 */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
469 static gboolean plugin_load(PurplePlugin *plugin) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
470
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
471 purple_signal_connect(purple_conversations_get_handle(),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
472 "conversation-created", plugin,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
473 PURPLE_CALLBACK(new_conversation_cb), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
474
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
475 /* Set callback to remove window from the list, if the window is destroyed */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
476 purple_signal_connect(purple_conversations_get_handle(),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
477 "deleting-conversation", plugin,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
478 PURPLE_CALLBACK(conversation_delete_cb), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
479
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
480 purple_signal_connect(pidgin_conversations_get_handle(),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
481 "conversation-dragging", plugin,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
482 PURPLE_CALLBACK(set_conv_window_trans), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
483
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
484 purple_signal_connect(purple_conversations_get_handle(),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
485 "conversation-updated", plugin,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
486 PURPLE_CALLBACK(conv_updated_cb), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
487
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
488 update_existing_convs();
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
489
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
490 if (blist)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
491 blist_created_cb(NULL, NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
492 else
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
493 purple_signal_connect(pidgin_blist_get_handle(),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
494 "gtkblist-created", plugin,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
495 PURPLE_CALLBACK(blist_created_cb), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
496
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
497
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
498 return TRUE;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
499 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
500
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
501 static gboolean plugin_unload(PurplePlugin *plugin) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
502 purple_debug_info(WINTRANS_PLUGIN_ID, "Unloading transparency plugin\n");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
503
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
504 remove_convs_wintrans(TRUE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
505
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
506 if (blist) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
507 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
508 set_wintrans(blist, 0, FALSE, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
509
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
510 /* Remove the focus cbs */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
511 g_signal_handlers_disconnect_by_func(G_OBJECT(blist),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
512 G_CALLBACK(focus_blist_win_cb), blist);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
513 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
514
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
515 return TRUE;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
516 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
517
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
518 static GtkWidget *get_config_frame(PurplePlugin *plugin) {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
519 GtkWidget *ret;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
520 GtkWidget *imtransbox, *bltransbox;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
521 GtkWidget *hbox;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
522 GtkWidget *label, *slider;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
523 GtkWidget *button;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
524 GtkWidget *trans_box;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
525
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
526 ret = gtk_vbox_new(FALSE, 18);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
527 gtk_container_set_border_width(GTK_CONTAINER (ret), 12);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
528
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
529 /* IM Convo trans options */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
530 imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows"));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
531 button = pidgin_prefs_checkbox(_("_IM window transparency"),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
532 OPT_WINTRANS_IM_ENABLED, imtransbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
533 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
534 G_CALLBACK(update_convs_wintrans),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
535 (gpointer) OPT_WINTRANS_IM_ENABLED);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
536
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
537 trans_box = gtk_vbox_new(FALSE, 18);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
538 if (!purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
539 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
540 gtk_widget_show(trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
541
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
542 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
543 G_CALLBACK(pidgin_toggle_sensitive), trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
544
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
545 button = pidgin_prefs_checkbox(_("_Show slider bar in IM window"),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
546 OPT_WINTRANS_IM_SLIDER, trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
547 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
548 G_CALLBACK(update_convs_wintrans),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
549 (gpointer) OPT_WINTRANS_IM_SLIDER);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
550
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
551 button = pidgin_prefs_checkbox(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
552 _("Remove IM window transparency on focus"),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
553 OPT_WINTRANS_IM_ONFOCUS, trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
554
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
555 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_IM_ONTOP,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
556 trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
557 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
558 G_CALLBACK(update_convs_wintrans),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
559 (gpointer) OPT_WINTRANS_IM_ONTOP);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
560
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
561 gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
562
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
563 /* IM transparency slider */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
564 hbox = gtk_hbox_new(FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
565
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
566 label = gtk_label_new(_("Opacity:"));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
567 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
568
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
569 slider = gtk_hscale_new_with_range(50, 255, 1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
570 gtk_range_set_value(GTK_RANGE(slider),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
571 purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
572 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
573
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
574 g_signal_connect(GTK_OBJECT(slider), "value-changed",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
575 G_CALLBACK(alpha_change), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
576 g_signal_connect(GTK_OBJECT(slider), "focus-out-event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
577 G_CALLBACK(alpha_pref_set_int),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
578 (gpointer) OPT_WINTRANS_IM_ALPHA);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
579
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
580 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
581
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
582 gtk_widget_show_all(hbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
583
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
584 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
585
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
586 /* Buddy List trans options */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
587 bltransbox = pidgin_make_frame (ret, _("Buddy List Window"));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
588 button = pidgin_prefs_checkbox(_("_Buddy List window transparency"),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
589 OPT_WINTRANS_BL_ENABLED, bltransbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
590 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
591 G_CALLBACK(set_blist_trans),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
592 (gpointer) OPT_WINTRANS_BL_ENABLED);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
593
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
594 trans_box = gtk_vbox_new(FALSE, 18);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
595 if (!purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED))
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
596 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
597 gtk_widget_show(trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
598 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
599 G_CALLBACK(pidgin_toggle_sensitive), trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
600 button = pidgin_prefs_checkbox(
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
601 _("Remove Buddy List window transparency on focus"),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
602 OPT_WINTRANS_BL_ONFOCUS, trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
603 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_BL_ONTOP,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
604 trans_box);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
605 g_signal_connect(GTK_OBJECT(button), "clicked",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
606 G_CALLBACK(set_blist_trans),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
607 (gpointer) OPT_WINTRANS_BL_ONTOP);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
608 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
609
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
610 /* IM transparency slider */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
611 hbox = gtk_hbox_new(FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
612
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
613 label = gtk_label_new(_("Opacity:"));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
614 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
615
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
616 slider = gtk_hscale_new_with_range(50, 255, 1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
617 gtk_range_set_value(GTK_RANGE(slider),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
618 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA));
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
619
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
620 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
621
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
622 g_signal_connect(GTK_OBJECT(slider), "value-changed",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
623 G_CALLBACK(bl_alpha_change), NULL);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
624 g_signal_connect(GTK_OBJECT(slider), "focus-out-event",
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
625 G_CALLBACK(alpha_pref_set_int),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
626 (gpointer) OPT_WINTRANS_BL_ALPHA);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
627
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
628 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
629
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
630 gtk_widget_show_all(hbox);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
631
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
632 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
633
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
634 gtk_widget_show_all(ret);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
635 return ret;
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
636 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
637
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
638 static PidginPluginUiInfo ui_info =
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
639 {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
640 get_config_frame,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
641 0, /* page_num (Reserved) */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
642
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
643 /* padding */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
644 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
645 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
646 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
647 NULL
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
648 };
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
649
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
650 static PurplePluginInfo info =
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
651 {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
652 PURPLE_PLUGIN_MAGIC,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
653 PURPLE_MAJOR_VERSION,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
654 PURPLE_MINOR_VERSION,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
655 PURPLE_PLUGIN_STANDARD, /**< type */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
656 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
657 0, /**< flags */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
658 NULL, /**< dependencies */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
659 PURPLE_PRIORITY_DEFAULT, /**< priority */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
660 WINTRANS_PLUGIN_ID, /**< id */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
661 N_("Transparency"), /**< name */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
662 DISPLAY_VERSION, /**< version */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
663 /** summary */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
664 N_("Variable Transparency for the buddy list and conversations."),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
665 /** description */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
666 N_("This plugin enables variable alpha transparency on conversation windows and the buddy list."),
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
667 "Herman Bloggs <hermanator12002@yahoo.com>", /**< author */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
668 PURPLE_WEBSITE, /**< homepage */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
669 plugin_load, /**< load */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
670 plugin_unload, /**< unload */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
671 NULL, /**< destroy */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
672 &ui_info, /**< ui_info */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
673 NULL, /**< extra_info */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
674 NULL, /**< prefs_info */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
675 NULL, /**< actions */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
676
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
677 /* padding */
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
678 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
679 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
680 NULL,
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
681 NULL
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
682 };
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
683
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
684 static void
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
685 init_plugin(PurplePlugin *plugin)
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
686 {
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
687 purple_prefs_add_none("/plugins/gtk");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
688 purple_prefs_add_none("/plugins/gtk/transparency");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
689 purple_prefs_add_bool(OPT_WINTRANS_IM_ENABLED, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
690 purple_prefs_add_int(OPT_WINTRANS_IM_ALPHA, 255);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
691 purple_prefs_add_bool(OPT_WINTRANS_IM_SLIDER, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
692 purple_prefs_add_bool(OPT_WINTRANS_IM_ONFOCUS, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
693 purple_prefs_add_bool(OPT_WINTRANS_IM_ONTOP, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
694 purple_prefs_add_bool(OPT_WINTRANS_BL_ENABLED, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
695 purple_prefs_add_int(OPT_WINTRANS_BL_ALPHA, 255);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
696 purple_prefs_add_bool(OPT_WINTRANS_BL_ONFOCUS, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
697 purple_prefs_add_bool(OPT_WINTRANS_BL_ONTOP, FALSE);
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
698 purple_prefs_rename("/plugins/gtk/win32/wintrans", "/plugins/gtk/transparency");
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
699 }
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
700
138239f698a9 Port transparency plugin from WinAPI to GTK. Fixes #3124
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
diff changeset
701 PURPLE_INIT_PLUGIN(wintrans, init_plugin, info)

mercurial