--- xchat-systray-2.4.5.orig/src/systray.c
+++ xchat-systray-2.4.5/src/systray.c
@@ -1,90 +1,9 @@
 #include "systray.h"
 
-#ifdef _WIN32_
-
-#define SYSTRAY_MSG WM_APP
-
-LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{ 
- switch (message) 
- {
-	case SYSTRAY_MSG:
-
-		switch (lParam) 
-		{
-        		case WM_RBUTTONDOWN:
-				tray_menu();
-				break;
-        		case WM_LBUTTONDBLCLK: 
-				if (status) 
-				{
-					xchat_command(ph,"gui hide");
-					status=0;
-				}
-				else 
-				{ 
-					xchat_command(ph,"gui show");
-					select_event_tab(TRUE);
-					status=1;
-				}
-				break;
-			case WM_MBUTTONDOWN: 
-				if (status) 
-				{
-					xchat_command(ph,"gui hide");
-					status=0;
-				}
-				else 
-				{ 
-					xchat_command(ph,"gui show");
-					status=1;
-				}
-				break;
-			case WM_LBUTTONDOWN:
-				select_event_tab(FALSE);
-				break;
-			 
-			default:
-				return 1;
-		}
-		break;
-		
-	default:
-		return DefWindowProc(hwnd, message, wParam, lParam); 
- }
-}
-#endif
-
 void update_tray(MYICON newicon, char* newtooltip) 
 {
 	if (newicon!=NULL || newtooltip!="")
 	{
-#ifdef _WIN32_
-		ZeroMemory(&tray_icon,sizeof(tray_icon));
-		tray_icon.cbSize=sizeof(NOTIFYICONDATA);
-		tray_icon.hWnd=hidden_win;
-		tray_icon.uID=0;
-		tray_icon.uFlags=0;
-		tray_icon.uCallbackMessage = SYSTRAY_MSG;
-	
-		if (newicon!=NULL) 
-		{
-			tray_icon.hIcon=newicon;
-			tray_icon.uFlags |= NIF_ICON;
-		}
-		
-        	if (newtooltip!="") 
-		{
-			lstrcpy(tray_icon.szTip, newtooltip);
-			g_free(newtooltip);
-			newtooltip=NULL;
-			tray_icon.uFlags |= NIF_TIP;
-		}
-		
-		Shell_NotifyIcon(NIM_MODIFY,&tray_icon);
-
-		
-#else
 		if ( newicon!=NULL ) 
 		{
 			gtk_image_set_from_pixbuf(GTK_IMAGE(tray_icon_image), newicon);
@@ -96,7 +15,6 @@
 			gtk_tooltips_set_tip (tray_icon_tooltip, GTK_WIDGET (tray_icon), newtooltip , NULL);
 			newtooltip=NULL;
 		}
-#endif
 	}
 
 }
@@ -108,18 +26,16 @@
 	flash_id=0;
 	status=1;
 	onExit=1;
-#ifndef _WIN32_
 	KDE=FALSE;
-#endif
-	flash_interval=500;
-	global_away=FALSE;
-	global_away_temp=FALSE;
-	edit=TRUE;
-	go_change=TRUE;
-	go_identify=TRUE;
-	strcpy(imagepath,xchat_get_info(ph, "xchatdir"));
-
+	flash_interval = 500;
+	global_away = FALSE;
+	global_away_temp = FALSE;
+	edit = TRUE;
+	go_change = TRUE;
+	go_identify = TRUE;
+	strcpy(imagepath, xchat_get_info(ph, "xchatdir"));
 }
+
 // events handling
  void tray_init_xchat(void)
 {
@@ -149,15 +65,11 @@
 	xchat_printf(ph, "Patrizio Bassi - hetfield666@virgilio.it - http://www.blight.tk");
 
 	//set apps variables, only on start
-	get_info( TRUE,TRUE );
+	xchat_systray_get_info( TRUE,TRUE );
 	servers_names = g_hash_table_new( NULL,NULL );
-#ifndef _WIN32_
 	window_manager_modified=KDE;
-#endif
-
 }
 
-#ifndef _WIN32_
 //used for set different options for kde like win manager
 //prevents errors, destroy events etc...
 void desktopSetup()
@@ -180,83 +92,23 @@
 	gdk_property_change(window, kde_net_system_tray_window_for_atom, (GdkAtom)XA_WINDOW, 32, GDK_PROP_MODE_REPLACE, (guchar *)&data, 1);
 
 }
-#endif
 
 
 
-MYICON loadicons(char* filename,char* type) 
+MYICON loadicons(char* filename, char* type) 
 {
 	MYICON tempbuffer=NULL;
 	char temp[200];
-	if (filename && type) 
-	{
-		if (imagepath) sprintf(temp,"%s/%s/%s", imagepath ,type,filename);
-		else sprintf(temp,"%s/%s/%s", xchat_get_info(ph, "xchatdir"),type,filename);
-#ifdef _WIN32_			
-		tempbuffer= ((HICON)LoadImage( tray_inst, temp, IMAGE_ICON, 16, 16, LR_LOADFROMFILE ));
-#else	
-		tempbuffer= gdk_pixbuf_new_from_file(temp,NULL);
-#endif
-		return tempbuffer;
+	if (filename && type) {
+	  sprintf(temp,"/usr/share/xchat-systray/%s/%s", type, filename);
+//		else sprintf(temp,"%s/%s/%s", xchat_get_info(ph, "xchatdir"),type,filename);
+	  tempbuffer= gdk_pixbuf_new_from_file(temp,NULL);
+	  return tempbuffer;
 	}
 	else return NULL;
 
 }
 
-#ifdef _WIN32_
-void tray_init_gui_win32() 
-{
-	WNDCLASSEX winclassex;
-	
-	winclassex.cbSize 		= sizeof(WNDCLASSEX);
-	winclassex.style	        = 0;
-	winclassex.lpfnWndProc 		= wndProc;
-	winclassex.cbClsExtra		= 0;
-	winclassex.cbWndExtra		= 0;
-	winclassex.hInstance		= tray_inst;
-	winclassex.hIcon		= pix_xchat;
-	winclassex.hCursor		= NULL,
-	winclassex.hbrBackground	= NULL;
-	winclassex.lpszMenuName		= NULL;
-	winclassex.lpszClassName	= "SysTrayWinClass";
-	winclassex.hIconSm		= pix_xchat;
-		
-	RegisterClassEx(&winclassex);
-	
-	// Create the hidden window
-	hidden_win=CreateWindow("SysTrayWinClass", "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, tray_inst, 0);
-	
-	pix_xchat=loadicons("xchat.ico","Win32Tray");
-	pix_xchat_red = loadicons("xchatred.ico","Win32Tray");
-	pix_xchat_blue = loadicons("xchatblue.ico","Win32Tray");
-	pix_xchat_dcc = loadicons("dccalert.ico","Win32Tray");
-	pix_xchat_disc = loadicons("disconnected.ico","Win32Tray");
-	pix_xchat_inv = loadicons("invited.ico","Win32Tray");
-	pix_xchat_notin = loadicons("notifyin.ico","Win32Tray");
-	pix_xchat_notout = loadicons("notifyout.ico","Win32Tray");
-	pix_xchat_away = loadicons("goaway.ico","Win32Tray");
-	
-	if (pix_xchat) icontype = pix_xchat;
-	
-	if (!pix_xchat || !pix_xchat_red || !pix_xchat_blue || !pix_xchat_dcc || !pix_xchat_disc ||!pix_xchat_inv
-	|| !pix_xchat_notin ||!pix_xchat_notout ||!pix_xchat_away ||!icontype ) 
-	{
-		xchat_printf(ph,"Icon load failed. Please enter the right path in the setting tab, check if filenames are not wrong and reload plugin");
-	}
-	
-	ZeroMemory(&tray_icon,sizeof(tray_icon));
-	tray_icon.cbSize=sizeof(NOTIFYICONDATA);
-	tray_icon.hWnd=hidden_win;
-	tray_icon.uID=0;
-	tray_icon.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
-	tray_icon.uCallbackMessage = SYSTRAY_MSG;
-	tray_icon.hIcon=pix_xchat;
-	
-	strcpy(tray_icon.szTip, "XChat2 - Nothing Particular");
-	Shell_NotifyIcon(NIM_ADD,&tray_icon);
-
-}
-#else
 // gui start and icon setting
 void tray_init_gui_gtk (void)
 {
@@ -321,25 +173,18 @@
 	gtk_tooltips_set_delay ( tray_icon_tooltip, 1000 );
 
 }
-#endif
 
 //start gui and plugin
 void tray_init(void)
 {
-#ifndef _WIN32_
 	//fix seg. fault on xchat-text, the XChat version without GTK
     	if ( !gdk_display ) 
 	{
 		xchat_printf( ph,"SysTray Integration Plugin Version %s NOT loaded!\nYou are not using a GUI version of XChat2.\n",version );
               return;
 	}
-#endif
 	tray_init_xchat();
-#ifndef _WIN32_
 	tray_init_gui_gtk();
-#else
-	tray_init_gui_win32();
-#endif
 }
 
 void clean_up()
@@ -350,8 +195,6 @@
 		servers_names=NULL;
 	}
 	
-#ifndef _WIN32_
-
 	if (tray_icon) 
 	{
 		gtk_widget_destroy (GTK_WIDGET (tray_icon));
@@ -370,70 +213,11 @@
 	
 	if (tray_icon_tooltip) tray_icon_tooltip=NULL;
 
-#else
-
-	Shell_NotifyIcon( NIM_DELETE, &tray_icon );
-	if ( hidden_win ) 
-	{
-		DestroyWindow( hidden_win );
-		hidden_win=NULL;
-	}
-	if ( tray_inst )  tray_inst = NULL;
-	if ( pix_xchat ) 
-	{
-		DestroyIcon( pix_xchat );
-		pix_xchat=NULL;
-	}
-	if ( pix_xchat_red ) 
-	{
-		DestroyIcon( pix_xchat_red );
-		pix_xchat_red=NULL;
-	}
-	if ( pix_xchat_blue ) 
-	{
-		DestroyIcon( pix_xchat_blue );
-		pix_xchat_blue=NULL;
-	}
-	if ( pix_xchat_dcc ) 
-	{
-		DestroyIcon( pix_xchat_dcc );
-		pix_xchat_dcc=NULL;
-	}
-	if ( pix_xchat_disc ) 
-	{
-		DestroyIcon( pix_xchat_disc );
-		pix_xchat_disc=NULL;
-	}	
-	if ( pix_xchat_inv ) 
-	{
-		DestroyIcon( pix_xchat_inv );
-		pix_xchat_inv=NULL;
-	}
-	if ( pix_xchat_notin ) 
-	{
-		DestroyIcon( pix_xchat_notin );
-		pix_xchat_notin=NULL;
-	}
-	if ( pix_xchat_notout ) 
-	{
-		DestroyIcon( pix_xchat_notout );
-		pix_xchat_notout=NULL;
-	}
-	if ( pix_xchat_away ) 
-	{
-		DestroyIcon( pix_xchat_away );
-		pix_xchat_away=NULL;
-	}
-	UnregisterClass("SysTrayWinClass", NULL);
-#endif
-
 }
 
 //unloading function
 int xchat_plugin_deinit(xchat_plugin *plugin_handle)
 {
-#ifndef _WIN32_
-
 	if( gdk_display )
 	{
 		if ( onExit==1 ) 
@@ -443,15 +227,6 @@
 		}
 	}
 
-#else
-
-	if ( onExit == 1 )
-	{
-		clean_up();
-		xchat_print( ph, "SysTray Integration Plugin unloaded\n" );
-	}
-
-#endif
 	return 1;
 }
 
