?? win2ktrans.c
字號:
if (purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) { add_slider(win); } } /* If we're moving from one window to another, * add the focus listeners to the new window if not already there */ if (oldwin != NULL && oldwin != newwin) { if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) { g_signal_connect(G_OBJECT(win), "focus_in_event", G_CALLBACK(focus_conv_win_cb), win); g_signal_connect(G_OBJECT(win), "focus_out_event", G_CALLBACK(focus_conv_win_cb), win); } /* If we've moved the last conversation, cleanup the window */ if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1) cleanup_conv_window(oldwin); }}static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) { purple_prefs_set_bool(pref, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggle_btn))); if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) { GList *wins; for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) { PidginWindow *win = wins->data; set_conv_window_trans(NULL, win); } if (!purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) remove_sliders(); } else remove_convs_wintrans(FALSE);}static void purple_new_conversation(PurpleConversation *conv) { PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); /* If it is the first conversation in the window, * add the sliders, and set transparency */ if (pidgin_conv_window_get_gtkconv_count(win) == 1) { GtkWidget *window = win->window; set_conv_window_trans(NULL, win); g_signal_connect(G_OBJECT(window), "focus_in_event", G_CALLBACK(focus_conv_win_cb), window); g_signal_connect(G_OBJECT(window), "focus_out_event", G_CALLBACK(focus_conv_win_cb), window); }}static void blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) { if (blist) { if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) { set_wintrans(blist, purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA), TRUE, purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP)); } g_signal_connect(G_OBJECT(blist), "focus_in_event", G_CALLBACK(focus_blist_win_cb), blist); g_signal_connect(G_OBJECT(blist), "focus_out_event", G_CALLBACK(focus_blist_win_cb), blist); }}static void alpha_change(GtkWidget *w, gpointer data) { GList *wins; int imalpha = gtk_range_get_value(GTK_RANGE(w)); for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) { PidginWindow *win = wins->data; set_wintrans(win->window, imalpha, TRUE, purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); }}static void alpha_pref_set_int (GtkWidget *w, GdkEventFocus *e, const char *pref){ int alpha = gtk_range_get_value(GTK_RANGE(w)); purple_prefs_set_int(pref, alpha);}static void bl_alpha_change(GtkWidget *w, gpointer data) { if (blist) change_alpha(w, blist);}static void update_existing_convs() { GList *wins; for (wins = pidgin_conv_windows_get_list(); wins; wins = wins->next) { PidginWindow *win = wins->data; GtkWidget *window = win->window; set_conv_window_trans(NULL, win); g_signal_connect(G_OBJECT(window), "focus_in_event", G_CALLBACK(focus_conv_win_cb), window); g_signal_connect(G_OBJECT(window), "focus_out_event", G_CALLBACK(focus_conv_win_cb), window); }}/* * EXPORTED FUNCTIONS */static gboolean plugin_load(PurplePlugin *plugin) { MySetLayeredWindowAttributes = (void*) wpurple_find_and_loadproc( "user32.dll", "SetLayeredWindowAttributes"); if (!MySetLayeredWindowAttributes) { purple_debug_error(WINTRANS_PLUGIN_ID, "SetLayeredWindowAttributes API not found (Required W2K+)\n"); return FALSE; } purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin, PURPLE_CALLBACK(purple_new_conversation), NULL); /* Set callback to remove window from the list, if the window is destroyed */ purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(purple_conversation_delete), NULL); purple_signal_connect(pidgin_conversations_get_handle(), "conversation-dragging", plugin, PURPLE_CALLBACK(set_conv_window_trans), NULL); update_existing_convs(); if (blist) blist_created_cb(NULL, NULL); else purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, PURPLE_CALLBACK(blist_created_cb), NULL); return TRUE;}static gboolean plugin_unload(PurplePlugin *plugin) { purple_debug_info(WINTRANS_PLUGIN_ID, "Unloading win2ktrans plugin\n"); remove_convs_wintrans(TRUE); if (blist) { if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) set_wintrans(blist, 0, FALSE, FALSE); /* Remove the focus cbs */ g_signal_handlers_disconnect_by_func(G_OBJECT(blist), G_CALLBACK(focus_blist_win_cb), blist); } return TRUE;}static GtkWidget *get_config_frame(PurplePlugin *plugin) { GtkWidget *ret; GtkWidget *imtransbox, *bltransbox; GtkWidget *hbox; GtkWidget *label, *slider; GtkWidget *button; GtkWidget *trans_box; ret = gtk_vbox_new(FALSE, 18); gtk_container_set_border_width(GTK_CONTAINER (ret), 12); /* IM Convo trans options */ imtransbox = pidgin_make_frame(ret, _("IM Conversation Windows")); button = wpurple_button(_("_IM window transparency"), OPT_WINTRANS_IM_ENABLED, imtransbox); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_ENABLED); trans_box = gtk_vbox_new(FALSE, 18); if (!purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); gtk_widget_show(trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); button = wpurple_button(_("_Show slider bar in IM window"), OPT_WINTRANS_IM_SLIDER, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_SLIDER); button = pidgin_prefs_checkbox( _("Remove IM window transparency on focus"), OPT_WINTRANS_IM_ONFOCUS, trans_box); button = wpurple_button(_("Always on top"), OPT_WINTRANS_IM_ONTOP, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_ONTOP); gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5); /* IM transparency slider */ hbox = gtk_hbox_new(FALSE, 5); label = gtk_label_new(_("Opacity:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); slider = gtk_hscale_new_with_range(50, 255, 1); gtk_range_set_value(GTK_RANGE(slider), purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA)); gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); g_signal_connect(GTK_OBJECT(slider), "value-changed", GTK_SIGNAL_FUNC(alpha_change), NULL); g_signal_connect(GTK_OBJECT(slider), "focus-out-event", GTK_SIGNAL_FUNC(alpha_pref_set_int), (gpointer) OPT_WINTRANS_IM_ALPHA); gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); gtk_widget_show_all(hbox); gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); /* Buddy List trans options */ bltransbox = pidgin_make_frame (ret, _("Buddy List Window")); button = wpurple_button(_("_Buddy List window transparency"), OPT_WINTRANS_BL_ENABLED, bltransbox); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_blist_trans), (gpointer) OPT_WINTRANS_BL_ENABLED); trans_box = gtk_vbox_new(FALSE, 18); if (!purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); gtk_widget_show(trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); button = pidgin_prefs_checkbox( _("Remove Buddy List window transparency on focus"), OPT_WINTRANS_BL_ONFOCUS, trans_box); button = wpurple_button(_("Always on top"), OPT_WINTRANS_BL_ONTOP, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_blist_trans), (gpointer) OPT_WINTRANS_BL_ONTOP); gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); /* IM transparency slider */ hbox = gtk_hbox_new(FALSE, 5); label = gtk_label_new(_("Opacity:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); slider = gtk_hscale_new_with_range(50, 255, 1); gtk_range_set_value(GTK_RANGE(slider), purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA)); gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); g_signal_connect(GTK_OBJECT(slider), "value-changed", GTK_SIGNAL_FUNC(bl_alpha_change), NULL); g_signal_connect(GTK_OBJECT(slider), "focus-out-event", GTK_SIGNAL_FUNC(alpha_pref_set_int), (gpointer) OPT_WINTRANS_BL_ALPHA); gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); gtk_widget_show_all(hbox); gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); gtk_widget_show_all(ret); return ret;}static PidginPluginUiInfo ui_info ={ get_config_frame, 0, /* page_num (Reserved) */ /* padding */ NULL, NULL, NULL, NULL};static PurplePluginInfo info ={ PURPLE_PLUGIN_MAGIC, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_PLUGIN_STANDARD, /**< type */ PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */ NULL, /**< dependencies */ PURPLE_PRIORITY_DEFAULT, /**< priority */ WINTRANS_PLUGIN_ID, /**< id */ N_("Transparency"), /**< name */ VERSION, /**< version */ /** summary */ N_("Variable Transparency for the buddy list and conversations."), /** description */ N_("This plugin enables variable alpha transparency on conversation windows and the buddy list.\n\n" "* Note: This plugin requires Win2000 or greater."), "Herman Bloggs <hermanator12002@yahoo.com>", /**< author */ PURPLE_WEBSITE, /**< homepage */ plugin_load, /**< load */ plugin_unload, /**< unload */ NULL, /**< destroy */ &ui_info, /**< ui_info */ NULL, /**< extra_info */ NULL, /**< prefs_info */ NULL, /**< actions */ /* padding */ NULL, NULL, NULL, NULL};static voidinit_plugin(PurplePlugin *plugin){ purple_prefs_add_none("/plugins/gtk/win32"); purple_prefs_add_none("/plugins/gtk/win32/wintrans"); purple_prefs_add_bool(OPT_WINTRANS_IM_ENABLED, FALSE); purple_prefs_add_int(OPT_WINTRANS_IM_ALPHA, 255); purple_prefs_add_bool(OPT_WINTRANS_IM_SLIDER, FALSE); purple_prefs_add_bool(OPT_WINTRANS_IM_ONFOCUS, FALSE); purple_prefs_add_bool(OPT_WINTRANS_IM_ONTOP, FALSE); purple_prefs_add_bool(OPT_WINTRANS_BL_ENABLED, FALSE); purple_prefs_add_int(OPT_WINTRANS_BL_ALPHA, 255); purple_prefs_add_bool(OPT_WINTRANS_BL_ONFOCUS, FALSE); purple_prefs_add_bool(OPT_WINTRANS_BL_ONTOP, FALSE);}PURPLE_INIT_PLUGIN(wintrans, init_plugin, info)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -