pidgin/plugins/win32/transparency/win2ktrans.c

changeset 15562
8c8249fe5e3c
parent 15435
4b933b06d75e
child 15563
9eea2b8c2846
equal deleted inserted replaced
15561:bdb019a1f485 15562:8c8249fe5e3c
42 * MACROS & DEFINES 42 * MACROS & DEFINES
43 */ 43 */
44 #define WINTRANS_PLUGIN_ID "gtk-win-trans" 44 #define WINTRANS_PLUGIN_ID "gtk-win-trans"
45 45
46 #define blist (gaim_get_blist() \ 46 #define blist (gaim_get_blist() \
47 ? (GAIM_GTK_BLIST(gaim_get_blist()) \ 47 ? (PIDGIN_BLIST(gaim_get_blist()) \
48 ? ((GAIM_GTK_BLIST(gaim_get_blist()))->window) \ 48 ? ((PIDGIN_BLIST(gaim_get_blist()))->window) \
49 : NULL) \ 49 : NULL) \
50 : NULL) 50 : NULL)
51 51
52 /* 52 /*
53 * DATA STRUCTS 53 * DATA STRUCTS
213 } 213 }
214 return NULL; 214 return NULL;
215 } 215 }
216 216
217 /* Clean up transparency stuff for the conv window */ 217 /* Clean up transparency stuff for the conv window */
218 static void cleanup_conv_window(GaimGtkWindow *win) { 218 static void cleanup_conv_window(PidginWindow *win) {
219 GtkWidget *window = win->window; 219 GtkWidget *window = win->window;
220 slider_win *slidwin = NULL; 220 slider_win *slidwin = NULL;
221 221
222 /* Remove window from the window list */ 222 /* Remove window from the window list */
223 gaim_debug_info(WINTRANS_PLUGIN_ID, 223 gaim_debug_info(WINTRANS_PLUGIN_ID,
232 g_signal_handlers_disconnect_by_func(G_OBJECT(window), 232 g_signal_handlers_disconnect_by_func(G_OBJECT(window),
233 G_CALLBACK(focus_conv_win_cb), window); 233 G_CALLBACK(focus_conv_win_cb), window);
234 } 234 }
235 235
236 static void gaim_conversation_delete(GaimConversation *conv) { 236 static void gaim_conversation_delete(GaimConversation *conv) {
237 GaimGtkWindow *win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); 237 PidginWindow *win = pidginconv_get_window(PIDGIN_CONVERSATION(conv));
238 /* If it is the last conversation in the window, cleanup */ 238 /* If it is the last conversation in the window, cleanup */
239 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) 239 if (pidgin_conv_window_get_gtkconv_count(win) == 1)
240 cleanup_conv_window(win); 240 cleanup_conv_window(win);
241 } 241 }
242 242
243 static void set_blist_trans(GtkWidget *w, const char *pref) { 243 static void set_blist_trans(GtkWidget *w, const char *pref) {
244 gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); 244 gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
325 325
326 /* Remove all transparency related aspects from conversation windows */ 326 /* Remove all transparency related aspects from conversation windows */
327 static void remove_convs_wintrans(gboolean remove_signal) { 327 static void remove_convs_wintrans(gboolean remove_signal) {
328 GList *wins; 328 GList *wins;
329 329
330 for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { 330 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
331 GaimGtkWindow *win = wins->data; 331 PidginWindow *win = wins->data;
332 GtkWidget *window = win->window; 332 GtkWidget *window = win->window;
333 333
334 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) 334 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED))
335 set_wintrans(window, 0, FALSE, FALSE); 335 set_wintrans(window, 0, FALSE, FALSE);
336 336
341 } 341 }
342 342
343 remove_sliders(); 343 remove_sliders();
344 } 344 }
345 345
346 static void set_conv_window_trans(GaimGtkWindow *oldwin, GaimGtkWindow *newwin) { 346 static void set_conv_window_trans(PidginWindow *oldwin, PidginWindow *newwin) {
347 GtkWidget *win = newwin->window; 347 GtkWidget *win = newwin->window;
348 348
349 /* check prefs to see if we want trans */ 349 /* check prefs to see if we want trans */
350 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) { 350 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
351 set_wintrans(win, gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA), 351 set_wintrans(win, gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
357 } 357 }
358 358
359 /* If we're moving from one window to another, 359 /* If we're moving from one window to another,
360 * add the focus listeners to the new window if not already there */ 360 * add the focus listeners to the new window if not already there */
361 if (oldwin != NULL && oldwin != newwin) { 361 if (oldwin != NULL && oldwin != newwin) {
362 if (gaim_gtk_conv_window_get_gtkconv_count(newwin) == 0) { 362 if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) {
363 g_signal_connect(G_OBJECT(win), "focus_in_event", 363 g_signal_connect(G_OBJECT(win), "focus_in_event",
364 G_CALLBACK(focus_conv_win_cb), win); 364 G_CALLBACK(focus_conv_win_cb), win);
365 g_signal_connect(G_OBJECT(win), "focus_out_event", 365 g_signal_connect(G_OBJECT(win), "focus_out_event",
366 G_CALLBACK(focus_conv_win_cb), win); 366 G_CALLBACK(focus_conv_win_cb), win);
367 } 367 }
368 368
369 /* If we've moved the last conversation, cleanup the window */ 369 /* If we've moved the last conversation, cleanup the window */
370 if (gaim_gtk_conv_window_get_gtkconv_count(oldwin) == 1) 370 if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1)
371 cleanup_conv_window(oldwin); 371 cleanup_conv_window(oldwin);
372 } 372 }
373 } 373 }
374 374
375 static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) { 375 static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) {
377 GTK_TOGGLE_BUTTON(toggle_btn))); 377 GTK_TOGGLE_BUTTON(toggle_btn)));
378 378
379 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) { 379 if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
380 GList *wins; 380 GList *wins;
381 381
382 for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { 382 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
383 GaimGtkWindow *win = wins->data; 383 PidginWindow *win = wins->data;
384 set_conv_window_trans(NULL, win); 384 set_conv_window_trans(NULL, win);
385 } 385 }
386 386
387 if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) 387 if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_SLIDER))
388 remove_sliders(); 388 remove_sliders();
390 else 390 else
391 remove_convs_wintrans(FALSE); 391 remove_convs_wintrans(FALSE);
392 } 392 }
393 393
394 static void gaim_new_conversation(GaimConversation *conv) { 394 static void gaim_new_conversation(GaimConversation *conv) {
395 GaimGtkWindow *win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); 395 PidginWindow *win = pidginconv_get_window(PIDGIN_CONVERSATION(conv));
396 396
397 /* If it is the first conversation in the window, 397 /* If it is the first conversation in the window,
398 * add the sliders, and set transparency */ 398 * add the sliders, and set transparency */
399 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { 399 if (pidgin_conv_window_get_gtkconv_count(win) == 1) {
400 GtkWidget *window = win->window; 400 GtkWidget *window = win->window;
401 401
402 set_conv_window_trans(NULL, win); 402 set_conv_window_trans(NULL, win);
403 403
404 g_signal_connect(G_OBJECT(window), "focus_in_event", 404 g_signal_connect(G_OBJECT(window), "focus_in_event",
426 426
427 static void alpha_change(GtkWidget *w, gpointer data) { 427 static void alpha_change(GtkWidget *w, gpointer data) {
428 GList *wins; 428 GList *wins;
429 int imalpha = gtk_range_get_value(GTK_RANGE(w)); 429 int imalpha = gtk_range_get_value(GTK_RANGE(w));
430 430
431 for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { 431 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
432 GaimGtkWindow *win = wins->data; 432 PidginWindow *win = wins->data;
433 set_wintrans(win->window, imalpha, TRUE, 433 set_wintrans(win->window, imalpha, TRUE,
434 gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); 434 gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
435 } 435 }
436 } 436 }
437 437
447 } 447 }
448 448
449 static void update_existing_convs() { 449 static void update_existing_convs() {
450 GList *wins; 450 GList *wins;
451 451
452 for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { 452 for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) {
453 GaimGtkWindow *win = wins->data; 453 PidginWindow *win = wins->data;
454 GtkWidget *window = win->window; 454 GtkWidget *window = win->window;
455 455
456 set_conv_window_trans(NULL, win); 456 set_conv_window_trans(NULL, win);
457 457
458 g_signal_connect(G_OBJECT(window), "focus_in_event", 458 g_signal_connect(G_OBJECT(window), "focus_in_event",
482 /* Set callback to remove window from the list, if the window is destroyed */ 482 /* Set callback to remove window from the list, if the window is destroyed */
483 gaim_signal_connect(gaim_conversations_get_handle(), 483 gaim_signal_connect(gaim_conversations_get_handle(),
484 "deleting-conversation", plugin, 484 "deleting-conversation", plugin,
485 GAIM_CALLBACK(gaim_conversation_delete), NULL); 485 GAIM_CALLBACK(gaim_conversation_delete), NULL);
486 486
487 gaim_signal_connect(gaim_gtk_conversations_get_handle(), 487 gaim_signal_connect(pidgin_conversations_get_handle(),
488 "conversation-dragging", plugin, 488 "conversation-dragging", plugin,
489 GAIM_CALLBACK(set_conv_window_trans), NULL); 489 GAIM_CALLBACK(set_conv_window_trans), NULL);
490 490
491 update_existing_convs(); 491 update_existing_convs();
492 492
493 if (blist) 493 if (blist)
494 blist_created_cb(NULL, NULL); 494 blist_created_cb(NULL, NULL);
495 else 495 else
496 gaim_signal_connect(gaim_gtk_blist_get_handle(), 496 gaim_signal_connect(pidgin_blist_get_handle(),
497 "gtkblist-created", plugin, 497 "gtkblist-created", plugin,
498 GAIM_CALLBACK(blist_created_cb), NULL); 498 GAIM_CALLBACK(blist_created_cb), NULL);
499 499
500 500
501 return TRUE; 501 return TRUE;
528 528
529 ret = gtk_vbox_new(FALSE, 18); 529 ret = gtk_vbox_new(FALSE, 18);
530 gtk_container_set_border_width(GTK_CONTAINER (ret), 12); 530 gtk_container_set_border_width(GTK_CONTAINER (ret), 12);
531 531
532 /* IM Convo trans options */ 532 /* IM Convo trans options */
533 imtransbox = gaim_gtk_make_frame(ret, _("IM Conversation Windows")); 533 imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows"));
534 button = wgaim_button(_("_IM window transparency"), 534 button = wgaim_button(_("_IM window transparency"),
535 OPT_WINTRANS_IM_ENABLED, imtransbox); 535 OPT_WINTRANS_IM_ENABLED, imtransbox);
536 g_signal_connect(GTK_OBJECT(button), "clicked", 536 g_signal_connect(GTK_OBJECT(button), "clicked",
537 GTK_SIGNAL_FUNC(update_convs_wintrans), 537 GTK_SIGNAL_FUNC(update_convs_wintrans),
538 (gpointer) OPT_WINTRANS_IM_ENABLED); 538 (gpointer) OPT_WINTRANS_IM_ENABLED);
541 if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) 541 if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED))
542 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); 542 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
543 gtk_widget_show(trans_box); 543 gtk_widget_show(trans_box);
544 544
545 g_signal_connect(GTK_OBJECT(button), "clicked", 545 g_signal_connect(GTK_OBJECT(button), "clicked",
546 GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box); 546 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box);
547 547
548 button = wgaim_button(_("_Show slider bar in IM window"), 548 button = wgaim_button(_("_Show slider bar in IM window"),
549 OPT_WINTRANS_IM_SLIDER, trans_box); 549 OPT_WINTRANS_IM_SLIDER, trans_box);
550 g_signal_connect(GTK_OBJECT(button), "clicked", 550 g_signal_connect(GTK_OBJECT(button), "clicked",
551 GTK_SIGNAL_FUNC(update_convs_wintrans), 551 GTK_SIGNAL_FUNC(update_convs_wintrans),
552 (gpointer) OPT_WINTRANS_IM_SLIDER); 552 (gpointer) OPT_WINTRANS_IM_SLIDER);
553 553
554 button = gaim_gtk_prefs_checkbox( 554 button = pidgin_prefs_checkbox(
555 _("Remove IM window transparency on focus"), 555 _("Remove IM window transparency on focus"),
556 OPT_WINTRANS_IM_ONFOCUS, trans_box); 556 OPT_WINTRANS_IM_ONFOCUS, trans_box);
557 557
558 button = wgaim_button(_("Always on top"), OPT_WINTRANS_IM_ONTOP, 558 button = wgaim_button(_("Always on top"), OPT_WINTRANS_IM_ONTOP,
559 trans_box); 559 trans_box);
585 gtk_widget_show_all(hbox); 585 gtk_widget_show_all(hbox);
586 586
587 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); 587 gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5);
588 588
589 /* Buddy List trans options */ 589 /* Buddy List trans options */
590 bltransbox = gaim_gtk_make_frame (ret, _("Buddy List Window")); 590 bltransbox = pidgin_make_frame (ret, _("Buddy List Window"));
591 button = wgaim_button(_("_Buddy List window transparency"), 591 button = wgaim_button(_("_Buddy List window transparency"),
592 OPT_WINTRANS_BL_ENABLED, bltransbox); 592 OPT_WINTRANS_BL_ENABLED, bltransbox);
593 g_signal_connect(GTK_OBJECT(button), "clicked", 593 g_signal_connect(GTK_OBJECT(button), "clicked",
594 GTK_SIGNAL_FUNC(set_blist_trans), 594 GTK_SIGNAL_FUNC(set_blist_trans),
595 (gpointer) OPT_WINTRANS_BL_ENABLED); 595 (gpointer) OPT_WINTRANS_BL_ENABLED);
597 trans_box = gtk_vbox_new(FALSE, 18); 597 trans_box = gtk_vbox_new(FALSE, 18);
598 if (!gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) 598 if (!gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED))
599 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); 599 gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE);
600 gtk_widget_show(trans_box); 600 gtk_widget_show(trans_box);
601 g_signal_connect(GTK_OBJECT(button), "clicked", 601 g_signal_connect(GTK_OBJECT(button), "clicked",
602 GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box); 602 GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box);
603 button = gaim_gtk_prefs_checkbox( 603 button = pidgin_prefs_checkbox(
604 _("Remove Buddy List window transparency on focus"), 604 _("Remove Buddy List window transparency on focus"),
605 OPT_WINTRANS_BL_ONFOCUS, trans_box); 605 OPT_WINTRANS_BL_ONFOCUS, trans_box);
606 button = wgaim_button(_("Always on top"), OPT_WINTRANS_BL_ONTOP, 606 button = wgaim_button(_("Always on top"), OPT_WINTRANS_BL_ONTOP,
607 trans_box); 607 trans_box);
608 g_signal_connect(GTK_OBJECT(button), "clicked", 608 g_signal_connect(GTK_OBJECT(button), "clicked",
636 636
637 gtk_widget_show_all(ret); 637 gtk_widget_show_all(ret);
638 return ret; 638 return ret;
639 } 639 }
640 640
641 static GaimGtkPluginUiInfo ui_info = 641 static PidginPluginUiInfo ui_info =
642 { 642 {
643 get_config_frame, 643 get_config_frame,
644 0 /* page_num (Reserved) */ 644 0 /* page_num (Reserved) */
645 }; 645 };
646 646
648 { 648 {
649 GAIM_PLUGIN_MAGIC, 649 GAIM_PLUGIN_MAGIC,
650 GAIM_MAJOR_VERSION, 650 GAIM_MAJOR_VERSION,
651 GAIM_MINOR_VERSION, 651 GAIM_MINOR_VERSION,
652 GAIM_PLUGIN_STANDARD, /**< type */ 652 GAIM_PLUGIN_STANDARD, /**< type */
653 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 653 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
654 0, /**< flags */ 654 0, /**< flags */
655 NULL, /**< dependencies */ 655 NULL, /**< dependencies */
656 GAIM_PRIORITY_DEFAULT, /**< priority */ 656 GAIM_PRIORITY_DEFAULT, /**< priority */
657 WINTRANS_PLUGIN_ID, /**< id */ 657 WINTRANS_PLUGIN_ID, /**< id */
658 N_("Transparency"), /**< name */ 658 N_("Transparency"), /**< name */

mercurial