Mercurial > pidgin
changeset 3729:a8f0c169e529
[gaim-migrate @ 3867]
ok
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 17 Oct 2002 21:23:09 +0000 |
parents | 73e06ba29015 |
children | a20bf3d247ff |
files | plugins/Makefile.mingw plugins/win32/transparency/Makefile.mingw plugins/win32/transparency/win2ktrans.c plugins/win32/transparency/wintransparency.c plugins/win32/transparency/wintransparency.def plugins/win32/transparency/wintransparency.h |
diffstat | 6 files changed, 330 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/Makefile.mingw Thu Oct 17 20:03:42 2002 +0000 +++ b/plugins/Makefile.mingw Thu Oct 17 21:23:09 2002 +0000 @@ -14,6 +14,7 @@ OSCAR_ROOT := ../src/protocols/oscar GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir TICKER := ./ticker +TRANSPARENCY := ./win32/transparency ## ## VARIABLE DEFINITIONS @@ -73,10 +74,12 @@ all: plugins $(MAKE) -C $(TICKER) -f Makefile.mingw + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw install: cp $(GAIM_PLUGINS)/*.dll $(GAIM_PLUGINS)/*.pl $(GAIM_INSTALL_DIR)/plugins $(MAKE) -C $(TICKER) -f Makefile.mingw install + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw install # # BUILD Plugin @@ -101,3 +104,4 @@ rm -rf *.o rm -rf *.dll $(MAKE) -C $(TICKER) -f Makefile.mingw clean + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw clean
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/win32/transparency/Makefile.mingw Thu Oct 17 21:23:09 2002 +0000 @@ -0,0 +1,142 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32trans plugin. +# + +# +# PATHS +# + +INCLUDE_DIR := . + +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +TRANSPARENCY_ROOT := . +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins + +## +## VARIABLE DEFINITIONS +## + +TARGET = win2ktrans + +VERSION := $(shell cat $(GAIM_TOP)/VERSION) + +# Compiler Options + +CC = gcc.exe + +CFLAGS = -O2 -Werror -Wall -mno-cygwin -fnative-struct + +DEFINES = -DGTK_ENABLE_BROKEN -DVERSION=\"$(VERSION)\" + + +## +## INCLUDE MAKEFILES +## + + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += -I$(TRANSPARENCY_ROOT) \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(GAIM_TOP)/src \ + -I$(GAIM_TOP)/src/win32 \ + -I$(GAIM_TOP) + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(GAIM_TOP)/src \ + -L$(TRANSPARENCY_ROOT) + + +## +## SOURCES, OBJECTS +## + +C_SRC = win2ktrans.c \ + wintransparency.c + + +OBJECTS = $(C_SRC:%.c=%.o) + + +## +## LIBRARIES +## + +LIBS = -lgtk-win32-2.0 -lglib-2.0 -lgdk-win32-2.0 -lgmodule-2.0 -lgobject-2.0 -lws2_32 -lintl -lgaim -llibwintransparency + + +## +## RULES +## + +# How to make a C file + +%.o: %.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@ -c $< + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: libwintransparency.lib $(TARGET).dll + +install: + cp $(TRANSPARENCY_ROOT)/$(TARGET).dll $(DLL_INSTALL_DIR) + + +## +## BUILD Dependencies +## + +$(GAIM_TOP)/src/gaim.lib: + $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib + +## +## BUILD DLL +## + +$(TARGET).def: $(OBJECTS) + dlltool --dllname $(TARGET).dll -z $(TARGET).def \ + $(OBJECTS) + +$(TARGET).base: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib + gcc -mdll -o junk.tmp -Wl,--base-file,$@ $(OBJECTS) $(LIB_PATHS) $(LIBS) + rm -rf junk.tmp + +$(TARGET).exp: $(TARGET).def $(TARGET).base + dlltool --dllname $(TARGET).dll --base-file $(TARGET).base \ + --output-exp $(TARGET).exp --def $(TARGET).def + rm -rf $(TARGET).base + +$(TARGET).dll: $(OBJECTS) $(TARGET).exp $(GAIM_TOP)/src/gaim.lib + gcc -mdll -o $(TARGET).dll $(OBJECTS) -Wl,$(TARGET).exp $(LIB_PATHS) $(LIBS) + rm -rf $(TARGET).exp + +libwintransparency.lib: $(OBJECTS) + dlltool -k -l liblibwintransparency.a -d wintransparency.def + + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf $(TARGET).dll + rm -rf $(TARGET).def + rm -rf libwintransparency.a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/win32/transparency/win2ktrans.c Thu Oct 17 21:23:09 2002 +0000 @@ -0,0 +1,95 @@ +/* + * win2ktrans + * + * copyright (c) 1998-2002, rob flynn <rob@marko.net> + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license as published by + * the free software foundation; either version 2 of the license, or + * (at your option) any later version. + * + * this program is distributed in the hope that it will be useful, + * but without any warranty; without even the implied warranty of + * merchantability or fitness for a particular purpose. see the + * gnu general public license for more details. + * + * you should have received a copy of the gnu general public license + * along with this program; if not, write to the free software + * foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa + * + */ +#define GAIM_PLUGINS + +#include <gtk/gtk.h> +#include "wintransparency.h" +#include "gaim.h" + +int alpha = 255; + +static void gaim_new_conversation(char *who) { + struct conversation *c = find_conversation(who); + + if (!c) + return; + + gdk_window_add_filter (GTK_WIDGET(c->window)->window, wgaim_window_filter, c); +} + + +G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) { + + + gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); + + return NULL; +} + +G_MODULE_EXPORT void gaim_plugin_remove() { +} + +struct gaim_plugin_description desc; + +G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup(_("Transparency")); + desc.version = g_strdup(VERSION); + desc.description = g_strdup(_("This plugin enables variable alpha transparency on conversation windows.\n\n* Note: This plugin requires Win2000 or WinXP.")); + desc.authors = g_strdup(_("Rob Flynn <rob@marko.net>")); + desc.url = g_strdup(WEBSITE); + return &desc; +} + +G_MODULE_EXPORT char *name() { + return _("Transparency"); +} + +G_MODULE_EXPORT char *description() { + return _("This plugin enables variable alpha transparency on conversation windows.\n\n* Note: This plugin requires Win2000 or WinXP."); +} + +void alpha_value_changed(GtkWidget *w, gpointer data) +{ + alpha = gtk_range_get_value(GTK_RANGE(w)); +} + +G_MODULE_EXPORT GtkWidget *gaim_plugin_config_gtk() { + GtkWidget *hbox; + GtkWidget *label, *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), 255); + gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); + + gtk_signal_connect(GTK_OBJECT(slider), "value-changed", GTK_SIGNAL_FUNC(alpha_value_changed), NULL); + + gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); + + gtk_widget_show_all(hbox); + + return hbox; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/win32/transparency/wintransparency.c Thu Oct 17 21:23:09 2002 +0000 @@ -0,0 +1,50 @@ +/* + * win2ktrans + * + * Copyright (C) 1998-2002, Rob Flynn <rob@marko.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <windows.h> +#include <shellapi.h> +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> +#include "gaim.h" +#include "wintransparency.h" + +int alpha; + +static void SetWindowTransparency(HWND hWnd, int trans) +{ + SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE) | WS_EX_LAYERED); + + SetLayeredWindowAttributes(hWnd,0,trans,LWA_ALPHA); +} + +GdkFilterReturn wgaim_window_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) +{ + MSG *msg = (MSG*)xevent; + struct conversation *c = (struct conversation *)data; + + gdk_window_remove_filter(GTK_WIDGET(c->window)->window, wgaim_window_filter, c); + + SetWindowTransparency(msg->hwnd, alpha); + + return GDK_FILTER_REMOVE; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/win32/transparency/wintransparency.def Thu Oct 17 21:23:09 2002 +0000 @@ -0,0 +1,3 @@ +LIBRARY "USER32.dll" +EXPORTS +SetLayeredWindowAttributes@16
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/win32/transparency/wintransparency.h Thu Oct 17 21:23:09 2002 +0000 @@ -0,0 +1,36 @@ +/* + * wintransparency.h + */ + +#ifndef _WINTRANSPARENCY_H_ +#define _WINTRANSPARENCY_H_ +#include <gdk/gdkevents.h> + +extern int alpha; + +/* These defines aren't found in the current version of mingw */ +#ifndef LWA_ALPHA +#define LWA_ALPHA 0x00000002 +#endif + +#ifndef WS_EX_LAYERED +#define WS_EX_LAYERED 0x00080000 +#endif + + +extern GdkFilterReturn wgaim_window_filter(GdkXEvent *xevent, + GdkEvent *event, + gpointer data); + +/* Needed for accessing global variables outside the current module */ + +extern void wgaim_init(void); + +#define unlink _unlink +#define bzero( dest, size ) memset( ## dest ##, 0, ## size ## ) +#define sleep(x) Sleep((x)*1000) +#define snprintf _snprintf +#define vsnprintf _vsnprintf + +#endif /* _WINTRANSPARENCY_H_ */ +