Mercurial > pidgin.yaz
comparison pidgin/plugins/win32/transparency/win2ktrans.c @ 18461:d2b6ae715eae
Fix transparency not being applied when showing a hidden conversation.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 09 Jul 2007 02:01:25 +0000 |
parents | 072e10e53037 |
children | 874b727d8fa0 |
comparison
equal
deleted
inserted
replaced
18460:b91a29987d71 | 18461:d2b6ae715eae |
---|---|
74 static BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) = NULL; | 74 static BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) = NULL; |
75 | 75 |
76 /* | 76 /* |
77 * CODE | 77 * CODE |
78 */ | 78 */ |
79 static GtkWidget *wpurple_button(const char *text, const char *pref, GtkWidget *page) { | |
80 GtkWidget *button; | |
81 button = gtk_check_button_new_with_mnemonic(text); | |
82 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), | |
83 purple_prefs_get_bool(pref)); | |
84 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); | |
85 gtk_widget_show(button); | |
86 return button; | |
87 } | |
88 | 79 |
89 /* Set window transparency level */ | 80 /* Set window transparency level */ |
90 static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, | 81 static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, |
91 gboolean always_on_top) { | 82 gboolean always_on_top) { |
92 if (MySetLayeredWindowAttributes) { | 83 if (MySetLayeredWindowAttributes) { |
231 /* Remove the focus cbs */ | 222 /* Remove the focus cbs */ |
232 g_signal_handlers_disconnect_by_func(G_OBJECT(window), | 223 g_signal_handlers_disconnect_by_func(G_OBJECT(window), |
233 G_CALLBACK(focus_conv_win_cb), window); | 224 G_CALLBACK(focus_conv_win_cb), window); |
234 } | 225 } |
235 | 226 |
236 static void purple_conversation_delete(PurpleConversation *conv) { | 227 static void |
228 conversation_delete_cb(PurpleConversation *conv) { | |
237 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); | 229 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); |
238 /* If it is the last conversation in the window, cleanup */ | 230 /* If it is the last conversation in the window, cleanup */ |
239 if (pidgin_conv_window_get_gtkconv_count(win) == 1) | 231 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
240 cleanup_conv_window(win); | 232 cleanup_conv_window(win); |
241 } | 233 } |
389 } | 381 } |
390 else | 382 else |
391 remove_convs_wintrans(FALSE); | 383 remove_convs_wintrans(FALSE); |
392 } | 384 } |
393 | 385 |
394 static void purple_new_conversation(PurpleConversation *conv) { | 386 static void |
387 conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) { | |
388 PidginConversation *pconv = PIDGIN_CONVERSATION(conv); | |
389 PidginWindow *win = pidgin_conv_get_window(pconv); | |
390 | |
391 if (type == PURPLE_CONV_UPDATE_UNSEEN && !pidgin_conv_is_hidden(pconv) | |
392 && pconv->unseen_state == PIDGIN_UNSEEN_NONE | |
393 && pidgin_conv_window_get_gtkconv_count(win) == 1) { | |
394 GtkWidget *window = win->window; | |
395 | |
396 set_conv_window_trans(NULL, win); | |
397 | |
398 if (g_signal_handler_find(G_OBJECT(window), G_SIGNAL_MATCH_FUNC, | |
399 0, 0, NULL, G_CALLBACK(focus_conv_win_cb), NULL) == 0) { | |
400 g_signal_connect(G_OBJECT(window), "focus_in_event", | |
401 G_CALLBACK(focus_conv_win_cb), window); | |
402 g_signal_connect(G_OBJECT(window), "focus_out_event", | |
403 G_CALLBACK(focus_conv_win_cb), window); | |
404 } | |
405 } | |
406 } | |
407 | |
408 static void | |
409 new_conversation_cb(PurpleConversation *conv) { | |
395 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); | 410 PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); |
396 | 411 |
397 /* If it is the first conversation in the window, | 412 /* If it is the first conversation in the window, |
398 * add the sliders, and set transparency */ | 413 * add the sliders, and set transparency */ |
399 if (pidgin_conv_window_get_gtkconv_count(win) == 1) { | 414 if (!pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv)) && pidgin_conv_window_get_gtkconv_count(win) == 1) { |
400 GtkWidget *window = win->window; | 415 GtkWidget *window = win->window; |
401 | 416 |
402 set_conv_window_trans(NULL, win); | 417 set_conv_window_trans(NULL, win); |
403 | 418 |
404 g_signal_connect(G_OBJECT(window), "focus_in_event", | 419 g_signal_connect(G_OBJECT(window), "focus_in_event", |
406 g_signal_connect(G_OBJECT(window), "focus_out_event", | 421 g_signal_connect(G_OBJECT(window), "focus_out_event", |
407 G_CALLBACK(focus_conv_win_cb), window); | 422 G_CALLBACK(focus_conv_win_cb), window); |
408 } | 423 } |
409 } | 424 } |
410 | 425 |
411 static void blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) { | 426 static void |
427 blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) { | |
412 if (blist) { | 428 if (blist) { |
413 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) { | 429 if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) { |
414 set_wintrans(blist, | 430 set_wintrans(blist, |
415 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA), | 431 purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA), |
416 TRUE, | 432 TRUE, |
475 return FALSE; | 491 return FALSE; |
476 } | 492 } |
477 | 493 |
478 purple_signal_connect(purple_conversations_get_handle(), | 494 purple_signal_connect(purple_conversations_get_handle(), |
479 "conversation-created", plugin, | 495 "conversation-created", plugin, |
480 PURPLE_CALLBACK(purple_new_conversation), NULL); | 496 PURPLE_CALLBACK(new_conversation_cb), NULL); |
481 | 497 |
482 /* Set callback to remove window from the list, if the window is destroyed */ | 498 /* Set callback to remove window from the list, if the window is destroyed */ |
483 purple_signal_connect(purple_conversations_get_handle(), | 499 purple_signal_connect(purple_conversations_get_handle(), |
484 "deleting-conversation", plugin, | 500 "deleting-conversation", plugin, |
485 PURPLE_CALLBACK(purple_conversation_delete), NULL); | 501 PURPLE_CALLBACK(conversation_delete_cb), NULL); |
486 | 502 |
487 purple_signal_connect(pidgin_conversations_get_handle(), | 503 purple_signal_connect(pidgin_conversations_get_handle(), |
488 "conversation-dragging", plugin, | 504 "conversation-dragging", plugin, |
489 PURPLE_CALLBACK(set_conv_window_trans), NULL); | 505 PURPLE_CALLBACK(set_conv_window_trans), NULL); |
506 | |
507 purple_signal_connect(purple_conversations_get_handle(), | |
508 "conversation-updated", plugin, | |
509 PURPLE_CALLBACK(conv_updated_cb), NULL); | |
490 | 510 |
491 update_existing_convs(); | 511 update_existing_convs(); |
492 | 512 |
493 if (blist) | 513 if (blist) |
494 blist_created_cb(NULL, NULL); | 514 blist_created_cb(NULL, NULL); |
529 ret = gtk_vbox_new(FALSE, 18); | 549 ret = gtk_vbox_new(FALSE, 18); |
530 gtk_container_set_border_width(GTK_CONTAINER (ret), 12); | 550 gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
531 | 551 |
532 /* IM Convo trans options */ | 552 /* IM Convo trans options */ |
533 imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows")); | 553 imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows")); |
534 button = wpurple_button(_("_IM window transparency"), | 554 button = pidgin_prefs_checkbox(_("_IM window transparency"), |
535 OPT_WINTRANS_IM_ENABLED, imtransbox); | 555 OPT_WINTRANS_IM_ENABLED, imtransbox); |
536 g_signal_connect(GTK_OBJECT(button), "clicked", | 556 g_signal_connect(GTK_OBJECT(button), "clicked", |
537 GTK_SIGNAL_FUNC(update_convs_wintrans), | 557 GTK_SIGNAL_FUNC(update_convs_wintrans), |
538 (gpointer) OPT_WINTRANS_IM_ENABLED); | 558 (gpointer) OPT_WINTRANS_IM_ENABLED); |
539 | 559 |
543 gtk_widget_show(trans_box); | 563 gtk_widget_show(trans_box); |
544 | 564 |
545 g_signal_connect(GTK_OBJECT(button), "clicked", | 565 g_signal_connect(GTK_OBJECT(button), "clicked", |
546 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); | 566 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); |
547 | 567 |
548 button = wpurple_button(_("_Show slider bar in IM window"), | 568 button = pidgin_prefs_checkbox(_("_Show slider bar in IM window"), |
549 OPT_WINTRANS_IM_SLIDER, trans_box); | 569 OPT_WINTRANS_IM_SLIDER, trans_box); |
550 g_signal_connect(GTK_OBJECT(button), "clicked", | 570 g_signal_connect(GTK_OBJECT(button), "clicked", |
551 GTK_SIGNAL_FUNC(update_convs_wintrans), | 571 GTK_SIGNAL_FUNC(update_convs_wintrans), |
552 (gpointer) OPT_WINTRANS_IM_SLIDER); | 572 (gpointer) OPT_WINTRANS_IM_SLIDER); |
553 | 573 |
554 button = pidgin_prefs_checkbox( | 574 button = pidgin_prefs_checkbox( |
555 _("Remove IM window transparency on focus"), | 575 _("Remove IM window transparency on focus"), |
556 OPT_WINTRANS_IM_ONFOCUS, trans_box); | 576 OPT_WINTRANS_IM_ONFOCUS, trans_box); |
557 | 577 |
558 button = wpurple_button(_("Always on top"), OPT_WINTRANS_IM_ONTOP, | 578 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_IM_ONTOP, |
559 trans_box); | 579 trans_box); |
560 g_signal_connect(GTK_OBJECT(button), "clicked", | 580 g_signal_connect(GTK_OBJECT(button), "clicked", |
561 GTK_SIGNAL_FUNC(update_convs_wintrans), | 581 GTK_SIGNAL_FUNC(update_convs_wintrans), |
562 (gpointer) OPT_WINTRANS_IM_ONTOP); | 582 (gpointer) OPT_WINTRANS_IM_ONTOP); |
563 | 583 |
586 | 606 |
587 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); | 607 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); |
588 | 608 |
589 /* Buddy List trans options */ | 609 /* Buddy List trans options */ |
590 bltransbox = pidgin_make_frame (ret, _("Buddy List Window")); | 610 bltransbox = pidgin_make_frame (ret, _("Buddy List Window")); |
591 button = wpurple_button(_("_Buddy List window transparency"), | 611 button = pidgin_prefs_checkbox(_("_Buddy List window transparency"), |
592 OPT_WINTRANS_BL_ENABLED, bltransbox); | 612 OPT_WINTRANS_BL_ENABLED, bltransbox); |
593 g_signal_connect(GTK_OBJECT(button), "clicked", | 613 g_signal_connect(GTK_OBJECT(button), "clicked", |
594 GTK_SIGNAL_FUNC(set_blist_trans), | 614 GTK_SIGNAL_FUNC(set_blist_trans), |
595 (gpointer) OPT_WINTRANS_BL_ENABLED); | 615 (gpointer) OPT_WINTRANS_BL_ENABLED); |
596 | 616 |
601 g_signal_connect(GTK_OBJECT(button), "clicked", | 621 g_signal_connect(GTK_OBJECT(button), "clicked", |
602 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); | 622 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); |
603 button = pidgin_prefs_checkbox( | 623 button = pidgin_prefs_checkbox( |
604 _("Remove Buddy List window transparency on focus"), | 624 _("Remove Buddy List window transparency on focus"), |
605 OPT_WINTRANS_BL_ONFOCUS, trans_box); | 625 OPT_WINTRANS_BL_ONFOCUS, trans_box); |
606 button = wpurple_button(_("Always on top"), OPT_WINTRANS_BL_ONTOP, | 626 button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_BL_ONTOP, |
607 trans_box); | 627 trans_box); |
608 g_signal_connect(GTK_OBJECT(button), "clicked", | 628 g_signal_connect(GTK_OBJECT(button), "clicked", |
609 GTK_SIGNAL_FUNC(set_blist_trans), | 629 GTK_SIGNAL_FUNC(set_blist_trans), |
610 (gpointer) OPT_WINTRANS_BL_ONTOP); | 630 (gpointer) OPT_WINTRANS_BL_ONTOP); |
611 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); | 631 gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); |