comparison plugins/win32/transparency/win2ktrans.c @ 4400:6c38239ff612

[gaim-migrate @ 4669] Fixed to work with new conversation api committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Thu, 23 Jan 2003 01:00:12 +0000
parents e92d7712b8ba
children d629e7989a8a
comparison
equal deleted inserted replaced
4399:ce8d35b435de 4400:6c38239ff612
48 #define OPT_WGAIM_BUDDYWIN_ONTOP 0x00000008 48 #define OPT_WGAIM_BUDDYWIN_ONTOP 0x00000008
49 49
50 /* 50 /*
51 * GLOBALS 51 * GLOBALS
52 */ 52 */
53 G_MODULE_IMPORT guint im_options;
54 G_MODULE_IMPORT GtkWidget *all_convos;
55 G_MODULE_IMPORT GtkWidget *blist; 53 G_MODULE_IMPORT GtkWidget *blist;
56 54
57 /* 55 /*
58 * LOCALS 56 * LOCALS
59 */ 57 */
60 static GtkWidget *slider_box=NULL;
61 static int imalpha = 255; 58 static int imalpha = 255;
62 static int blalpha = 255; 59 static int blalpha = 255;
63 guint trans_options=0; 60 guint trans_options = 0;
61 GList *window_list = NULL;
64 62
65 /* 63 /*
66 * PROTOS 64 * PROTOS
67 */ 65 */
68 BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)=NULL; 66 BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)=NULL;
130 gtk_widget_show_all(hbox); 128 gtk_widget_show_all(hbox);
131 129
132 return frame; 130 return frame;
133 } 131 }
134 132
135 static void gaim_del_conversation(char *who) { 133 gboolean win_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
136 if(!all_convos) 134 /* Remove window from the window list */
137 slider_box = NULL; 135 debug_printf("win2ktrans.dll: Conv window destoyed.. removing from list\n");
136 window_list = g_list_remove(window_list, (gpointer)widget);
137 return FALSE;
138 } 138 }
139 139
140 static void gaim_new_conversation(char *who) { 140 static void gaim_new_conversation(char *who) {
141 GList *wl, *wl1; 141 GList *wl, *wl1;
142 GtkWidget *vbox=NULL; 142 GtkWidget *vbox=NULL;
143 143 GtkWidget *win=NULL;
144 struct conversation *c = find_conversation(who); 144 struct gaim_gtk_window *gaimwin;
145 145 struct gaim_conversation *c;
146 /* Single convo window */ 146
147 if((im_options & OPT_IM_ONE_WINDOW)) { 147 c = gaim_find_conversation(who);
148 /* check prefs to see if we want trans */ 148 gaimwin = GAIM_GTK_WINDOW(c->window);
149 if ((trans_options & OPT_WGAIM_IMTRANS) && 149 win = gaimwin->window;
150 (trans_options & OPT_WGAIM_SHOW_IMTRANS)) { 150
151 if(!slider_box) { 151 /* check prefs to see if we want trans */
152 /* Get vbox which to add slider to.. */ 152 if ((trans_options & OPT_WGAIM_IMTRANS) &&
153 for ( wl1 = wl = gtk_container_children(GTK_CONTAINER(c->window)); 153 (trans_options & OPT_WGAIM_SHOW_IMTRANS)) {
154 wl != NULL; 154 /* Look up this window to see if it already has a scroller */
155 wl = wl->next ) { 155 if(!g_list_find(window_list, (gpointer)win)) {
156 if ( GTK_IS_VBOX(GTK_OBJECT(wl->data)) ) 156 GtkWidget *slider_box=NULL;
157 vbox = GTK_WIDGET(wl->data); 157
158 else 158 /* Get top vbox */
159 debug_printf("no vbox found\n"); 159 for ( wl1 = wl = gtk_container_get_children(GTK_CONTAINER(win));
160 wl != NULL;
161 wl = wl->next ) {
162 if ( GTK_IS_VBOX(GTK_OBJECT(wl->data)) )
163 vbox = GTK_WIDGET(wl->data);
164 else {
165 debug_printf("no vbox found\n");
166 return;
160 } 167 }
161 g_list_free(wl1);
162
163 slider_box = wintrans_slider(c->window);
164 gtk_box_pack_start(GTK_BOX(vbox),
165 slider_box,
166 FALSE, FALSE, 0);
167 } 168 }
169 g_list_free(wl1);
170
171 slider_box = wintrans_slider(win);
172 gtk_box_pack_start(GTK_BOX(vbox),
173 slider_box,
174 FALSE, FALSE, 0);
175 /* Add window to list, to track that it has a scroller */
176 window_list = g_list_append(window_list, (gpointer)win);
177 /* Set callback to remove window from the list, if the window is destroyed */
178 g_signal_connect(GTK_OBJECT(win), "destroy_event", G_CALLBACK(win_destroy_cb), NULL);
168 } 179 }
169 } 180 else
170 /* One window per convo */ 181 return;
171 else { 182 }
172 if ((trans_options & OPT_WGAIM_IMTRANS) && 183
173 (trans_options & OPT_WGAIM_SHOW_IMTRANS)) {
174 GtkWidget *paned;
175
176 /* Get container which to add slider to.. */
177 wl = gtk_container_children(GTK_CONTAINER(c->window));
178 paned = GTK_WIDGET(wl->data);
179 g_list_free(wl);
180 wl = gtk_container_children(GTK_CONTAINER(paned));
181 /* 2nd child */
182 vbox = GTK_WIDGET((wl->next)->data);
183 g_list_free(wl);
184
185 if(!GTK_IS_VBOX(vbox))
186 debug_printf("vbox isn't a vbox widget\n");
187
188 gtk_box_pack_start(GTK_BOX(vbox),
189 wintrans_slider(c->window),
190 FALSE, FALSE, 0);
191 }
192 }
193
194 if((trans_options & OPT_WGAIM_IMTRANS) && 184 if((trans_options & OPT_WGAIM_IMTRANS) &&
195 !(trans_options & OPT_WGAIM_SHOW_IMTRANS)) { 185 !(trans_options & OPT_WGAIM_SHOW_IMTRANS)) {
196 set_wintrans(c->window, imalpha); 186 set_wintrans(win, imalpha);
197 } 187 }
198 } 188 }
199 189
200 static void blist_created() { 190 static void blist_created() {
201 if(blist) { 191 if(blist) {
326 * EXPORTED FUNCTIONS 316 * EXPORTED FUNCTIONS
327 */ 317 */
328 318
329 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) { 319 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) {
330 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); 320 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL);
331 gaim_signal_connect(handle, event_del_conversation, gaim_del_conversation, NULL);
332 gaim_signal_connect(handle, event_signon, blist_created, NULL); 321 gaim_signal_connect(handle, event_signon, blist_created, NULL);
333 MySetLayeredWindowAttributes = (void*)wgaim_find_and_loadproc("user32.dll", "SetLayeredWindowAttributes" ); 322 MySetLayeredWindowAttributes = (void*)wgaim_find_and_loadproc("user32.dll", "SetLayeredWindowAttributes" );
334 load_trans_prefs(); 323 load_trans_prefs();
335 324
336 return NULL; 325 return NULL;
337 } 326 }
338 327
339 G_MODULE_EXPORT void gaim_plugin_remove() { 328 G_MODULE_EXPORT void gaim_plugin_remove() {
329 debug_printf("Removing win2ktrans.dll plugin\n");
330 if(window_list) {
331 g_list_free(window_list);
332 window_list = NULL;
333 }
340 } 334 }
341 335
342 struct gaim_plugin_description desc; 336 struct gaim_plugin_description desc;
343 337
344 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() { 338 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() {
378 trans_box = gtk_vbox_new(FALSE, 18); 372 trans_box = gtk_vbox_new(FALSE, 18);
379 if (!(trans_options & OPT_WGAIM_IMTRANS)) 373 if (!(trans_options & OPT_WGAIM_IMTRANS))
380 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); 374 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
381 gtk_widget_show(trans_box); 375 gtk_widget_show(trans_box);
382 376
383 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), trans_box); 377 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box);
384 378
385 button = gaim_button(_("_Show slider bar in IM window"), &trans_options, OPT_WGAIM_SHOW_IMTRANS, trans_box); 379 button = gaim_button(_("_Show slider bar in IM window"), &trans_options, OPT_WGAIM_SHOW_IMTRANS, trans_box);
386 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_trans_option), (int *)OPT_WGAIM_SHOW_IMTRANS); 380 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_trans_option), (int *)OPT_WGAIM_SHOW_IMTRANS);
387 381
388 gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5); 382 gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5);
416 410
417 trans_box = gtk_vbox_new(FALSE, 18); 411 trans_box = gtk_vbox_new(FALSE, 18);
418 if (!(trans_options & OPT_WGAIM_BLTRANS)) 412 if (!(trans_options & OPT_WGAIM_BLTRANS))
419 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); 413 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
420 gtk_widget_show(trans_box); 414 gtk_widget_show(trans_box);
421 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), trans_box); 415 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box);
422 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); 416 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5);
423 417
424 /* IM transparency slider */ 418 /* IM transparency slider */
425 hbox = gtk_hbox_new(FALSE, 5); 419 hbox = gtk_hbox_new(FALSE, 5);
426 420