Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv11041/src Modified Files: GUISettingsDlg.cpp MainDlg.cpp Makefile.am SysTray.cpp SysTray.h defines.h Added Files: TrayCoreEngine.c TrayCoreEngine.h Log Message: Hetfields systray (Patch #845694) --- NEW FILE: TrayCoreEngine.c --- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* eggtrayicon.c * Copyright (C) 2002 Anders Carlsson <and...@gn...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ [...1506 lines suppressed...] } gdk_error_trap_pop (); return stamp; } void egg_tray_icon_cancel_message (EggTrayIcon *icon, guint id) { g_return_if_fail (EGG_IS_TRAY_ICON (icon)); g_return_if_fail (id > 0); egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, (Window)gtk_plug_xembed_get_id (GTK_PLUG_XEMBED (icon)), id, 0, 0); /*egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, (Window)gtk_plug_get_id (GTK_PLUG (icon)), id, 0, 0);*/ } --- NEW FILE: TrayCoreEngine.h --- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* eggtrayicon.h * Copyright (C) 2002 Anders Carlsson <and...@gn...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* THIS FILE IS A MERGE OF EGGTRAYICON AND GTKPLUGEXEMBED FROM XMULE THESE FILES WERE MODIFIED BY TIKU i've merged it for more integration and for compressing it. Hetfield aka Patrizio Bassi <he...@em...> */ #ifndef __EGG_TRAY_ICON_H__ #define __EGG_TRAY_ICON_H__ #include <gtk/gtkplug.h> #include <gdk/gdkx.h> #include <gtk/gtk.h> #include <gtk/gtkprivate.h> #include <gdk/gdkkeysyms.h> #include <string.h> #include <gdk/gdkx.h> #include <gdk/gdk.h> #include <gtk/gtksocket.h> #include <stdarg.h> #include <gtk/gtkwindow.h> typedef struct _tagSIZE { int cx,cy;} SIZE; typedef unsigned int UINT; typedef UINT* UINT_PTR; typedef char* LPCSTR; typedef unsigned char BYTE; typedef unsigned long DWORD; typedef unsigned long BOOL; typedef signed long LONG; typedef unsigned long ULONG; typedef unsigned long long ULONGLONG; typedef BYTE* LPBYTE; typedef int INT; typedef unsigned short WORD; typedef unsigned char* LPCTSTR; typedef DWORD COLORREF; typedef void VOID; typedef void* LPVOID; typedef void* PVOID; typedef struct _POINT { UINT x,y; } POINT; typedef struct _RECT1 { UINT left,top,right,bottom; } RECT1; //typedef RECT1* LPRECT1; typedef struct _WINDOWPLACEMENT { UINT length; UINT flags; UINT showCmd; POINT ptMinPosition; POINT ptMaxPosition; RECT1 rcNormalPosition; } WINDOWPLACEMENT; #define min(a,b) ((a)<(b)?(a):(b)) #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #define GTK_TYPE_PLUG_XEMBED (gtk_plug_xembed_get_type ()) #define GTK_PLUG_XEMBED(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbed)) #define GTK_PLUG_XEMBED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbedClass)) #define GTK_IS_PLUG_XEMBED(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_PLUG_XEMBED)) #define GTK_IS_PLUG_XEMBED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PLUG_XEMBED)) #define GTK_PLUG_XEMBED_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbedClass)) typedef struct _GtkPlugXEmbed GtkPlugXEmbed; typedef struct _GtkPlugXEmbedClass GtkPlugXEmbedClass; typedef guint32 GtkPlugXEmbedNativeWindow; struct _GtkPlugXEmbed { GtkWindow window; GdkWindow *socket_window; #ifdef PORT_COMPLETE GtkWidget *modality_window; GtkWindowGroup *modality_group; #endif GHashTable *grabbed_keys; guint same_app : 1; }; struct _GtkPlugXEmbedClass { GtkWindowClass parent_class; void (*embedded) (GtkPlugXEmbed *plug); /* Padding for future expansion */ void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); void (*_gtk_reserved3) (void); void (*_gtk_reserved4) (void); }; GtkType gtk_plug_xembed_get_type (void) G_GNUC_CONST; void gtk_plug_xembed_construct (GtkPlugXEmbed *plug, GtkPlugXEmbedNativeWindow socket_id); GtkWidget* gtk_plug_xembed_new (GtkPlugXEmbedNativeWindow socket_id); GtkPlugXEmbedNativeWindow gtk_plug_xembed_get_id (GtkPlugXEmbed *plug); void _gtk_plug_xembed_add_to_socket (GtkPlugXEmbed *plug, GtkSocket *socket); void _gtk_plug_xembed_remove_from_socket (GtkPlugXEmbed *plug, GtkSocket *socket); #define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ()) #define EGG_TRAY_ICON(obj) (GTK_CHECK_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon)) #define EGG_TRAY_ICON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) #define EGG_IS_TRAY_ICON(obj) (GTK_CHECK_TYPE ((obj), EGG_TYPE_TRAY_ICON)) #define EGG_IS_TRAY_ICON_CLASS(klass) (GTK_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON)) #define EGG_TRAY_ICON_GET_CLASS(obj) (GTK_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) typedef struct _EggTrayIcon EggTrayIcon; typedef struct _EggTrayIconClass EggTrayIconClass; struct _EggTrayIcon { GtkPlugXEmbed parent_instance; // GtkPlug parent_instance; guint stamp; Atom selection_atom; Atom manager_atom; Atom system_tray_opcode_atom; Window manager_window; }; struct _EggTrayIconClass { GtkPlugXEmbedClass parent_class; //GtkPlugClass parent_class; }; GtkType egg_tray_icon_get_type (void); EggTrayIcon * egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name); #if EGG_TRAY_ENABLE_MULTIHEAD EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen, const gchar *name); #endif EggTrayIcon *egg_tray_icon_new (const gchar *name); guint egg_tray_icon_send_message (EggTrayIcon *icon, gint timeout, const char *message, gint len); void egg_tray_icon_cancel_message (EggTrayIcon *icon, guint id); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __EGG_TRAY_ICON_H__ */ Index: GUISettingsDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/GUISettingsDlg.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- GUISettingsDlg.cpp 18 Dec 2003 04:25:36 -0000 1.27 +++ GUISettingsDlg.cpp 19 Dec 2003 03:01:14 -0000 1.28 @@ -255,7 +255,9 @@ icon.CopyFromBitmap(img->GetImage(wxT("mule"))); mainframe->SetIcon(icon); #ifdef wxHAS_TASK_BAR_ICON + #ifdef __WXMSW__ systray->SetIcon(icon); + #endif #endif } } Index: MainDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- MainDlg.cpp 18 Dec 2003 04:25:36 -0000 1.27 +++ MainDlg.cpp 19 Dec 2003 03:01:14 -0000 1.28 @@ -240,7 +240,9 @@ } #ifdef wxHAS_TASK_BAR_ICON - systray->RemoveIcon(); + #ifdef __WXMSW__ + systray->RemoveIcon(); + #endif delete systray; #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 18 Dec 2003 04:25:36 -0000 1.4 +++ Makefile.am 19 Dec 2003 03:01:14 -0000 1.5 @@ -22,11 +22,31 @@ TransferWnd.o \ UploadListCtrl.o \ wxInterface.o \ - wxInterface_wdr.o \ + wxInterface_wdr.o\ $(RES) \ all: $(PROGRAM) +.c.o: + @echo -e -n "$(ACTIONCOLOR)Compiling $(INPUTCOLOR)$<$(ACTIONCOLOR) to " + @echo -e -n "$(OUTPUTCOLOR)$@$(ACTIONCOLOR) @PRINT_CPP_FLAGS@: $(ATTENTIONCOLOR)" + @if cc @CFLAGS@ @CPP_FLAGS@ @INCLUDE@ -c -o $@ $< 2>.err; then \ + if test -s .err; then \ + echo -e "$(WARNINGCOLOR)ok, but warnings:"; \ + cat .err; \ + rm -f .err; \ + echo -e "$(DEFAULTCOLOR)"; \ + else \ + echo -e "$(WELLCOLOR)ok.$(ACTIONCOLOR)"; \ + fi; \ + else \ + echo -e "failed:"; \ + cat .err; \ + rm -f .err; \ + echo -e "$(DEFAULTCOLOR)"; \ + false; \ + fi; + .cpp.o : @echo -e -n "$(ACTIONCOLOR)Compiling $(INPUTCOLOR)$<$(ACTIONCOLOR) to " @echo -e -n "$(OUTPUTCOLOR)$@$(ACTIONCOLOR)@PRINT_CPP_FLAGS@: $(ATTENTIONCOLOR)" @@ -56,11 +76,11 @@ false; \ fi; -wxInterface: $(WXINTERFACE_OBJECTS) - @echo -e -n "$(ACTIONCOLOR)Linking $(INPUTCOLOR)$(WXINTERFACE_OBJECTS)" +wxInterface: $(WXINTERFACE_OBJECTS) @TRAY_OBJECTS@ + @echo -e -n "$(ACTIONCOLOR)Linking $(INPUTCOLOR)$(WXINTERFACE_OBJECTS)@TRAY_OBJECTS@ " @echo -e -n "$(ACTIONCOLOR)to $(OUTPUTCOLOR)$@$(ACTIONCOLOR)@PRINT_LINK_FLAGS@: " @echo -e -n "$(ATTENTIONCOLOR)" - @if @CXX@ -o $(PROGRAM) $(WXINTERFACE_OBJECTS) @LIBS@ 2>.err; then \ + @if @CXX@ -o $(PROGRAM) $(WXINTERFACE_OBJECTS) @TRAY_OBJECTS@ @LIBS@ 2>.err; then \ echo -e "$(WELLCOLOR)ok."; \ echo -e -n "$(DEFAULTCOLOR)"; \ echo -e -n "$(WELLCOLOR)Successfully compiled "; \ Index: SysTray.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/SysTray.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- SysTray.cpp 27 Nov 2003 08:23:12 -0000 1.11 +++ SysTray.cpp 19 Dec 2003 03:01:14 -0000 1.12 @@ -30,7 +30,8 @@ #include "SysTray.h" -#ifdef wxHAS_TASK_BAR_ICON + /* On wxMSW, we use wxWindows wxTaskBarIcon implementation */ +#if defined (__WXMSW__) BEGIN_EVENT_TABLE(CSysTray,wxTaskBarIcon) EVT_TASKBAR_RIGHT_DOWN(CSysTray::ShowContextMenu) @@ -107,5 +108,826 @@ HideShowGUI(); } +/* On wxGTK, we use GTK systray */ +#elif defined(__WXGTK__) + +//**************************************************** +//HERE STARTS THE UNIX&MAC SYSTRAY INTEGRATION CLASS +//**************************************************** + +/*************************************************************** +This tray has been taken from Tiku's xmule implementation, +changing events handling and adding some features. + +Hetfield aka Patrizio Bassi <het...@us...> +****************************************************************/ + +#include <sys/ioctl.h> +#include <net/if.h> +#include <arpa/inet.h> +#include <glib.h> +//icon +#include "images/default/mule.xpm" +//speed definition +#define UNLIMITED 0xFFFF + +//i have to patch it to mac it work with mac and freebsd. +gchar* getIP() +{ + + gchar* ip="Not Found"; + wxString interface; + int index; + index=0; + int sfd; + struct ifreq ifr; + struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; + + memset(&ifr, 0, sizeof ifr); + sfd = socket(AF_INET, SOCK_STREAM, 0); + + strcpy(ifr.ifr_name, "ppp0"); + sin->sin_family = AF_INET; + if (0 == ioctl(sfd, SIOCGIFADDR, &ifr)) { + ip=inet_ntoa(sin->sin_addr); + return ip; + } + else { + +// printf("Not connected at network with ppp0 direct connection\n"); + do + { + interface="eth"+wxString::Format("%d", index); + strcpy(ifr.ifr_name, interface); + sin->sin_family = AF_INET; + if (0 == ioctl(sfd, SIOCGIFADDR, &ifr)) { + ip=inet_ntoa(sin->sin_addr); + index++; + } +// else printf(wxString("Not connected at network with ")+interface); + + } while (0 == ioctl(sfd, SIOCGIFADDR, &ifr)) ; +} + return ip; + +} + + +//same check of the connection tab. +void speed_check(){ + + /*if (theApp.glob_prefs->GetMaxGraphDownloadRate() < theApp.glob_prefs->GetMaxDownload()) theApp.glob_prefs->SetDownloadlimit(UNLIMITED); + if (theApp.glob_prefs->GetMaxGraphUploadRate() < theApp.glob_prefs->GetMaxUpload()) theApp.glob_prefs->SetUploadlimit(UNLIMITED); + + if( theApp.glob_prefs->GetMaxUpload() != UNLIMITED ){ + if( theApp.glob_prefs->GetMaxUpload() < 4 && ( theApp.glob_prefs->GetMaxUpload()*3 < theApp.glob_prefs->GetMaxDownload() ) ) + theApp.glob_prefs->SetDownloadlimit((theApp.glob_prefs->GetMaxUpload()*3)); + + if( theApp.glob_prefs->GetMaxUpload() < 10 && ( theApp.glob_prefs->GetMaxUpload()*4 < theApp.glob_prefs->GetMaxDownload() ) ) + theApp.glob_prefs->SetDownloadlimit((theApp.glob_prefs->GetMaxUpload()*4)) ; + }*/ +} + + +//set download and upload speed to max +void set_all_max() { + +/*theApp.glob_prefs->SetUploadlimit(theApp.glob_prefs->GetMaxGraphUploadRate()); +theApp.glob_prefs->SetDownloadlimit(theApp.glob_prefs->GetMaxGraphDownloadRate()); +*/ +} + +//set download and upload speed to min +void set_all_min() { +/* +theApp.glob_prefs->SetUploadlimit(2); +theApp.glob_prefs->SetDownloadlimit(2);*/ +speed_check(); +} + +//connect to a server +void connect_any_server() { +/* +if (theApp.serverconnect->IsConnected()) theApp.serverconnect->Disconnect(); +theApp.xmuledlg->AddLogLine(true, GetResString(IDS_CONNECTING)); +theApp.serverconnect->ConnectToAnyServer(); +theApp.xmuledlg->ShowConnectionState(false); +*/ +} + +//disconnect +void disconnect(){ +/*if (theApp.serverconnect->IsConnected()) {theApp.serverconnect->Disconnect();} +else printf("Already disconnected!\n");*/ +} + +//set download speed +void set_dl_speed(GtkWidget *widget, GdkEventButton *event, gpointer data) { + +/*int temp; +temp = atoi(g_strdup_printf("%s", gtk_object_get_data (GTK_OBJECT(widget), "label") )); +if (temp==0) theApp.glob_prefs->SetDownloadlimit(UNLIMITED); +else theApp.glob_prefs->SetDownloadlimit(temp);*/ +speed_check(); +} + +//set upload speed +void set_up_speed(GtkWidget *widget, GdkEventButton *event, gpointer data) { +/* +int temp; +temp = atoi(g_strdup_printf("%s", gtk_object_get_data (GTK_OBJECT(widget), "label") )); +if (temp==0) theApp.glob_prefs->SetUploadlimit(UNLIMITED); +else theApp.glob_prefs->SetUploadlimit(temp);*/ +speed_check(); +} + +//************* +void help_sharedaemon() { + + //ADD HELP PAGE WHEN READY + +} + +void gui_settings_sharedaemon() { + CGUISettingsDlg *guisettings = new CGUISettingsDlg( + NULL, -1, _("User Interface Settings"), + wxDefaultPosition, wxDefaultSize + ); + guisettings->ShowModal(); + delete guisettings; +} + +void close_sharedaemon() { + +// printf("Shutting down ShareDaemon...\n"); + if (mainframe!=NULL) delete mainframe; +// printf("Shutting down completed with success!\n"); + +} + +void hide_sharedaemon() { + + if (mainframe!=NULL){ + if (mainframe->IsShown()) {mainframe->Iconize(TRUE); mainframe->Show(FALSE);} + else printf("ShareDaemon is already hidden\n"); + } + +} + +void show_sharedaemon() { + + if (mainframe!=NULL){ + if (!mainframe->IsShown()) mainframe->Show(TRUE); + else printf("ShareDaemon is already shown\n"); + } +} + +void showgui(){ + + if (mainframe!=NULL){ + if (mainframe->IsShown()) {mainframe->Iconize(TRUE); mainframe->Show(FALSE);} + else mainframe->Show(TRUE); + } + + +} + +void CSysTray::Quit() { + + close_sharedaemon(); +} + +CSysTray::~CSysTray() { + +//when destroying the Systray you need to destroy GTK objects +gtk_widget_destroy(GTK_WIDGET(status_docklet)); +gtk_widget_destroy(GTK_WIDGET(status_image)); +gtk_widget_destroy(GTK_WIDGET(status_tooltips)); + +} + +//create menu linked to the tray icon +static gboolean +tray_menu (GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + //sets gtk objects + GtkWidget *status_menu,*item,*down_speed,*dl_item,*up_speed,*up_item,*info_menu,*info_item; + wxString label; + wxString upl_speed,dl_speed; + gchar* temp,*tempstring; + int tempspeed; + int max_dl_speed=100; //temp settings change it! + int max_up_speed=10; + int actual_dl_speed=0; + int actual_up_speed=10; + + speed_check(); + + wxString version= "ShareDaemon CVS"; +/* + actual_up_speed=theApp.glob_prefs->GetMaxUpload(); + actual_dl_speed=theApp.glob_prefs->GetMaxDownload(); + max_up_speed=theApp.glob_prefs->GetMaxGraphUploadRate(); + max_dl_speed=theApp.glob_prefs->GetMaxGraphDownloadRate(); +*/ + + //what will be shown, very nice! + if (actual_dl_speed==UNLIMITED || actual_dl_speed==0) dl_speed="Unlimited"; + else { temp = g_strdup_printf("%d", actual_dl_speed ); dl_speed=temp;} + if (actual_up_speed==UNLIMITED || actual_up_speed==0) upl_speed="Unlimited"; + else { temp = g_strdup_printf("%d", actual_up_speed ); upl_speed=temp;} + + if (max_dl_speed==UNLIMITED || max_dl_speed==0) max_dl_speed=100; + if (max_up_speed==UNLIMITED || max_up_speed==0) max_up_speed=100; + + label="ShareDaemon "+wxString(version)+"\nActual Speed Limits:\nDL: "+dl_speed+" kb/s "+"UP: "+upl_speed+" kb/s"; + + //info menu + info_menu=gtk_menu_new(); + gtk_menu_set_title(GTK_MENU(info_menu),"ShareDaemon Tray Menu Info"); + + /*if (theApp.glob_prefs->GetUserNick()!=NULL) + info_item=gtk_menu_item_new_with_label(wxString("Nick: ")+theApp.glob_prefs->GetUserNick()); + else*/ + info_item=gtk_menu_item_new_with_label("Nick: Not Ready"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + + /*if (theApp.glob_prefs->GetUserHash()){ + CString hash; + hash=EncodeBase16((const unsigned char*)theApp.glob_prefs->GetUserHash(),16); + info_item=gtk_menu_item_new_with_label(wxString("Hash: ")+hash.GetBuffer()); + } + else*/ + info_item=gtk_menu_item_new_with_label("Hash: Not Ready"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.serverconnect->IsConnected()) { + info_item=gtk_menu_item_new_with_label(wxString("ClientID: ")+wxString::Format("%.0f",(float)theApp.serverconnect->GetClientID())); + } + else*/ + info_item=gtk_menu_item_new_with_label("ID: Not Connected"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + + + tempstring=getIP(); + info_item=gtk_menu_item_new_with_label(wxString("IP: ")+tempstring); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.glob_prefs->GetPort()) { + tempstring = g_strdup_printf("%d", theApp.glob_prefs->GetPort() ); + info_item=gtk_menu_item_new_with_label(wxString("TCP Port: ")+tempstring); + } + else*/ + info_item=gtk_menu_item_new_with_label("TCP Port: Not Ready"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.glob_prefs->GetUDPPort()) { + tempstring = g_strdup_printf("%d", theApp.glob_prefs->GetUDPPort() ); + info_item=gtk_menu_item_new_with_label(wxString("UDP Port: ")+tempstring); + } + else*/ + info_item=gtk_menu_item_new_with_label("UDP Port: Not Ready"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.glob_prefs->IsOnlineSignatureEnabled()) info_item=gtk_menu_item_new_with_label("Online Signature: Enabled"); + else*/ + info_item=gtk_menu_item_new_with_label("Online Signature: Disabled"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.Start_time>0) { + DWORD running; + running=(GetTickCount()-theApp.Start_time)/1000; + tempstring=g_strdup_printf("%s", CastSecondsToHM(running).GetData() ); + info_item=gtk_menu_item_new_with_label(wxString("Uptime: ")+tempstring); + } + else*/ + info_item=gtk_menu_item_new_with_label("Uptime: None"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + /*if (theApp.serverconnect->GetCurrentServer()!=NULL) { + + info_item=gtk_menu_item_new_with_label(wxString("ServerName: ")+(theApp.serverconnect->GetCurrentServer()->GetListName())); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + tempstring = g_strdup_printf("%d", theApp.serverconnect->GetCurrentServer()->GetPort() ); + info_item=gtk_menu_item_new_with_label(wxString("ServerIP: ")+(theApp.serverconnect->GetCurrentServer()->GetFullIP())+wxString(" : ")+tempstring ); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + } + else*/ + { + info_item=gtk_menu_item_new_with_label("ServerName: Not Connected"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + info_item=gtk_menu_item_new_with_label("ServerIP: Not Connected"); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + } + + //tempstring = g_strdup_printf("%d", theApp.sharedfiles->GetCount() ); + info_item=gtk_menu_item_new_with_label(wxString("Shared Files: ")+tempstring); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + //tempstring = g_strdup_printf("%d", theApp.uploadqueue->GetWaitingUserCount() ); + info_item=gtk_menu_item_new_with_label(wxString("Queued Clients: ")+tempstring); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + //tempstring = g_strdup_printf("%.2f", ((float)(theApp.stat_sessionReceivedBytes+theApp.glob_prefs->GetTotalDownloaded()) / 1073741824) ); + info_item=gtk_menu_item_new_with_label(wxString("Total DL: ")+tempstring+wxString(" GB")); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + //tempstring = g_strdup_printf("%.2f", ((float)(theApp.stat_sessionSentBytes+theApp.glob_prefs->GetTotalUploaded()) / 1073741824)); + info_item=gtk_menu_item_new_with_label(wxString("Total UP: ")+tempstring+wxString(" GB")); + gtk_container_add (GTK_CONTAINER (info_menu), info_item); + + + //main menu + status_menu = gtk_menu_new(); + gtk_menu_set_title(GTK_MENU(status_menu),"Sharedaemon Tray Menu"); + + //first item, not linked, only to show version and speed + item=gtk_menu_item_new_with_label(label); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //download speed submenu + down_speed=gtk_menu_new(); + + temp="Unlimited"; + dl_item=gtk_menu_item_new_with_label(temp); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", 0 , NULL); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + tempspeed=max_dl_speed; + temp = g_strdup_printf("%d", tempspeed ); + dl_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", temp , NULL); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + tempspeed=(max_dl_speed/5)*4; + temp = g_strdup_printf("%d", tempspeed ); + dl_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + tempspeed=(max_dl_speed/5)*3; + temp = g_strdup_printf("%d", tempspeed ); + dl_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + tempspeed=(max_dl_speed/5)*2; + temp = g_strdup_printf("%d", tempspeed ); + dl_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + tempspeed=(max_dl_speed/5); + temp = g_strdup_printf("%d", tempspeed ); + dl_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (down_speed), dl_item); + gtk_object_set_data_full(GTK_OBJECT(dl_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(dl_item), "activate",GTK_SIGNAL_FUNC (set_dl_speed),dl_item); + + + //upload speed submenu + up_speed=gtk_menu_new(); + + temp="Unlimited"; + up_item=gtk_menu_item_new_with_label(temp); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", 0 , NULL); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + tempspeed=max_up_speed; + temp = g_strdup_printf("%d", tempspeed ); + up_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", temp, NULL); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + tempspeed=(max_up_speed/5)*4; + temp = g_strdup_printf("%d", tempspeed ); + up_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + tempspeed=(max_up_speed/5)*3; + temp = g_strdup_printf("%d", tempspeed ); + up_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + tempspeed=(max_up_speed/5)*2; + temp = g_strdup_printf("%d", tempspeed ); + up_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + tempspeed=(max_up_speed/5); + temp = g_strdup_printf("%d", tempspeed ); + up_item=gtk_menu_item_new_with_label(wxString(temp)+" kb/s"); + gtk_container_add (GTK_CONTAINER (up_speed), up_item); + gtk_object_set_data_full(GTK_OBJECT(up_item), "label", temp, NULL); + gtk_signal_connect (GTK_OBJECT(up_item), "activate",GTK_SIGNAL_FUNC (set_up_speed),up_item); + + + //Help item + item=gtk_menu_item_new_with_label(_("Help")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (help_sharedaemon),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //gui settings item + item=gtk_menu_item_new_with_label(_("Gui Settings")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (gui_settings_sharedaemon),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //personal infos item, not linked, only to show them + item=gtk_menu_item_new_with_label("Personal Infos"); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),info_menu); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //show item + item=gtk_menu_item_new_with_label(_("Show")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (show_sharedaemon),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //hide item + item=gtk_menu_item_new_with_label(_("Hide")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (hide_sharedaemon),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //sets max speed + item=gtk_menu_item_new_with_label(_("All To Max Speed")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (set_all_max),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //sets min speed + item=gtk_menu_item_new_with_label(_("All To Min Speed")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (set_all_min),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //Download Speed item + item=gtk_menu_item_new_with_label(_("Download Limit")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),down_speed); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //Upload Speed item + item=gtk_menu_item_new_with_label(_("Upload Limit")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),up_speed); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //Connect item + item=gtk_menu_item_new_with_label(_("Connect to any server")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (connect_any_server),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //Disconnection Speed item + item=gtk_menu_item_new_with_label(_("Disconnect from server")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (disconnect),NULL); + + //separator + item=gtk_menu_item_new(); + gtk_container_add (GTK_CONTAINER (status_menu), item); + + //Exit item + item=gtk_menu_item_new_with_label(_("Exit")); + gtk_container_add (GTK_CONTAINER (status_menu), item); + gtk_signal_connect (GTK_OBJECT (item), "activate",GTK_SIGNAL_FUNC (close_sharedaemon),NULL); + + + //when the menu is popped-down, you need to destroy it + gtk_signal_connect (GTK_OBJECT (status_menu), "selection-done", + GTK_SIGNAL_FUNC (gtk_widget_destroy), &status_menu); + + //finalization + gtk_widget_show_all (status_menu); + gtk_menu_popup (GTK_MENU(status_menu), NULL, NULL,NULL, NULL,event->button, event->time); + + return TRUE; +} + +static gboolean tray_clicked (GtkWidget *event_box, GdkEventButton *event, gpointer data) { + + //mouse wheel or middle click + left double click + if ( (event->button == 1 && event->type == GDK_2BUTTON_PRESS) ||event->button == 2) { + showgui(); + return TRUE; + } + + //mouse right click + if (event->button == 3) { + return tray_menu (event_box, event, data); + } + + return FALSE; + +} + + +CSysTray::CSysTray(int mode) +{ + + GtkWidget *eventbox; + + gdk_rgb_init(); + + m_sDimensions.cx=16; + m_sDimensions.cy=16; + m_nSpacingWidth=1; + m_nNumBars=1; + m_nMaxVal=100; + m_pLimits=NULL; + m_pColors=NULL; + + desktopMode=mode; + + // not wanted, so don't show it. + if(desktopMode==4) return; + + bool use_legacy=false; + + // case 2 and 3 are KDE/other legacy system + if(desktopMode==2 || desktopMode==3) { + use_legacy=true; + } + + if(use_legacy) { + status_docklet=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(status_docklet), "ShareDaemon"); + gtk_window_set_wmclass(GTK_WINDOW(status_docklet),"sharedaemon_StatusDocklet","ShareDaemon"); + gtk_widget_set_usize(status_docklet,22,22); + } else { + status_docklet=GTK_WIDGET(egg_tray_icon_new(_("ShareDaemon"))); + if(status_docklet==NULL) { + printf("**** WARNING: Can't create status docklet. Systray will not be created.\n"); + desktopMode=4; + return; + } + } + gtk_widget_realize(status_docklet); + + gtk_signal_connect(GTK_OBJECT(status_docklet),"destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed),&status_docklet); + + // set image + GdkBitmap* mask=NULL; + GdkPixmap* img=gdk_pixmap_create_from_xpm_d(status_docklet->window,&mask,NULL,mule_xpm); + status_image=gtk_pixmap_new(img,mask); + + eventbox = gtk_event_box_new (); + gtk_widget_show (eventbox); + gtk_container_add (GTK_CONTAINER (eventbox), status_image); + gtk_container_add (GTK_CONTAINER (status_docklet), eventbox); + gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",GTK_SIGNAL_FUNC (tray_clicked), NULL ); + gtk_signal_connect (GTK_OBJECT(status_image),"destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed),&status_image); + + // set tooltips + status_tooltips=gtk_tooltips_new(); + gtk_tooltips_enable(status_tooltips); + gtk_tooltips_set_tip(status_tooltips,status_docklet,(_("ShareDaemon wxInterface")),"blind text"); + + // finalization + gtk_widget_show(status_image); + if(use_legacy) { + setupProperties(); + } + gtk_widget_show(GTK_WIDGET(status_docklet)); + gtk_widget_show_all (GTK_WIDGET (status_docklet)); + +} + + +void CSysTray::setupProperties() +{ + + GdkWindow* window=status_docklet->window; + + glong data[1]; + + GdkAtom kwm_dockwindow_atom; + GdkAtom kde_net_system_tray_window_for_atom; + + kwm_dockwindow_atom = gdk_atom_intern("KWM_DOCKWINDOW", FALSE); + kde_net_system_tray_window_for_atom = gdk_atom_intern("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", FALSE); + + /* This is the old KDE 1.0 and GNOME 1.2 way... */ + data[0] = TRUE; + gdk_property_change(window, kwm_dockwindow_atom, + kwm_dockwindow_atom, 32, + GDK_PROP_MODE_REPLACE, (guchar *)&data, 1); + + /* This is needed to support KDE 2.0 */ + /* can be set to zero or the root win I think */ + data[0] = 0; + gdk_property_change(window, kde_net_system_tray_window_for_atom, + (GdkAtom)XA_WINDOW, 32, + GDK_PROP_MODE_REPLACE, (guchar *)&data, 1); + + + +} + +void CSysTray::Show(const wxChar* caption,int nMsgType,DWORD dwTimeToShow,DWORD dwTimeToStay,DWORD dwTimeTOHide) +{ + + if(desktopMode==4) + return; + + if(status_docklet==NULL) + return; + + /* this isn't exactly true. notifier must be a widget */ + gtk_tooltips_set_tip(status_tooltips,status_docklet,caption,NULL); + +} + +void CSysTray::TraySetToolTip(char* data) +{ + + if(desktopMode==4) + return; + + if(status_docklet==NULL) + return; + + gtk_tooltips_set_tip(status_tooltips,status_docklet,data,NULL); + +} + +COLORREF CSysTray::GetMeterColor(int nLevel) +// it the nLevel is greater than the values defined in m_pLimits the last value in the array is used +{ + +// begin GetMeterColor + for(int i = 0;i < m_nEntries;i++) + { + if(nLevel <= m_pLimits[i]) + { + return m_pColors[i]; + } + } + // default to the last entry + return m_pColors[m_nEntries-1]; + +}// end GetMeterColor + +void CSysTray::DrawIconMeter(GdkPixmap* pix,GdkBitmap* mask,int nLevel,int nPos) +{ + + GdkGC* gc=gdk_gc_new(pix); + + gdk_rgb_gc_set_background(gc,0); + // border color is black :) + gdk_rgb_gc_set_foreground(gc,GetMeterColor(nLevel)); + gdk_draw_rectangle(pix,gc,1,((m_sDimensions.cx-1)/m_nNumBars)*nPos+m_nSpacingWidth,m_sDimensions.cy-((nLevel*(m_sDimensions.cy-1)/m_nMaxVal)+1),((m_sDimensions.cx-1)/m_nNumBars)*(nPos+1)+1,m_sDimensions.cy); + // then draw to mask (look! it must be initialised even if it is not used!) + GdkGC* newgc=gdk_gc_new(mask); + gdk_rgb_gc_set_foreground(newgc,0x0); + gdk_draw_rectangle(mask,newgc,TRUE,0,0,22,22); + + if(nLevel>0) { + gdk_rgb_gc_set_foreground(newgc,0xffffff); + gdk_draw_rectangle(mask,newgc,1,m_sDimensions.cx-2,m_sDimensions.cy-((nLevel*(m_sDimensions.cy-1)/m_nMaxVal)+1), + m_sDimensions.cx,m_sDimensions.cy); + } + gdk_gc_unref(newgc); + gdk_gc_unref(gc); + +} + +void CSysTray::drawMeters(GdkPixmap* pix,GdkBitmap* mask,int* pBarData) +{ + + if(pBarData==NULL) + return; + + for(int i=0;i<m_nNumBars;i++) { + DrawIconMeter(pix,mask,pBarData[i],i); + } + +} + +void CSysTray::TraySetIcon(char** data,bool what,int* pVals) +{ + + if(desktopMode==4) + return; + + if(status_image==NULL) + return; // nothing you can do.. + GdkPixmap* oldpix,*oldbit; + GdkPixmap* newpix,*newbit; + + /* set new */ + gtk_pixmap_get(GTK_PIXMAP(status_image),&oldpix,&oldbit); + newpix=gdk_pixmap_create_from_xpm_d(status_docklet->window,&newbit,NULL,data); + /* create pixmap for meters */ + GdkPixmap *meterpix=gdk_pixmap_new(status_docklet->window,22,22,-1); + GdkBitmap* meterbit=gdk_pixmap_new(status_docklet->window,22,22,1); + /* draw meters */ + drawMeters(meterpix,meterbit,pVals); + /* then draw meters onto main pix */ + GdkGC* mygc=gdk_gc_new(newpix); + gdk_gc_set_clip_mask(mygc,meterbit); + gdk_draw_pixmap(newpix,mygc,meterpix,0,0,0,0,22,22); + gdk_gc_set_clip_mask(mygc,NULL); + gdk_gc_unref(mygc); + /* finally combine masks */ + mygc=gdk_gc_new(newbit); + gdk_gc_set_function(mygc,GDK_OR); + gdk_draw_pixmap(newbit,mygc,meterbit,0,0,0,0,22,22); + gdk_gc_unref(mygc); + gdk_pixmap_unref(meterpix); + gdk_bitmap_unref(meterbit); + gtk_pixmap_set(GTK_PIXMAP(status_image),newpix,newbit); + + /* free old */ + gdk_pixmap_unref(oldpix); + gdk_bitmap_unref(oldbit); + /* and force repaint */ + gtk_widget_draw(status_docklet,NULL); + +} + +bool CSysTray::SetColorLevels(int *pLimits, COLORREF *pColors,int nEntries) +// pLimits is an array of int that contain the upper limit for the corresponding color +{ + +// begin SetColorLevels + // free exsisting memory + if(m_pLimits) + delete []m_pLimits; + if(m_pColors) + delete []m_pColors; + // allocate new memory + m_pLimits = new int[nEntries]; + m_pColors = new COLORREF[nEntries]; + // copy values + for(int i = 0;i < nEntries;i++) + {// begin copy + m_pLimits[i] = pLimits[i]; + m_pColors[i] = pColors[i]; + }// end copy + m_nEntries = nEntries; + return true; + +}// end SetColorLevels + +#else /* not __WXMSW__ and not __WXGTK__ */ + #warning No native systray implemented for your port. #endif + Index: SysTray.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/SysTray.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SysTray.h 20 Nov 2003 12:02:20 -0000 1.5 +++ SysTray.h 19 Dec 2003 03:01:14 -0000 1.6 @@ -31,7 +31,7 @@ #include "defines.h" #include "MainDlg.h" -#ifdef wxHAS_TASK_BAR_ICON +#ifdef __WXMSW__ class CSysTray: public wxTaskBarIcon { public: @@ -49,6 +49,97 @@ }; -#endif +#elif defined(__WXGTK__) + +//**************************************************** +//HERE STARTS THE UNIX&MAC SYSTRAY INTEGRATION CLASS +//**************************************************** + +/*************************************************************** +This tray has been taken from Tiku's xmule implementation, +changing events handling and adding some features. + +Hetfield aka Patrizio Bassi <het...@us...> +****************************************************************/ + +//WxWindows function +#include "wx/window.h" +//GTK Core functions +#include <gtk/gtk.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <X11/Xatom.h> +//GTK Tray personalized from Tiku's one +#include "TrayCoreEngine.h" +//Value definition +#define GetRValue(rgb) (((rgb)>>16)&0xff) +#define GetGValue(rgb) (((rgb)>>8)&0xff) +#define GetBValue(rgb) ((rgb)&0xff) + +// SysTray Integration Class, provided for Unix&Mac Systems +class CSysTray { + +public: + + //Core functions + //Constructor + CSysTray(int=3); + //Distructor + ~CSysTray(); + + //Graphics functions + + //Show Tray, initialization. + void Show(const wxChar* caption,int nMsgType,DWORD dwTimeToShow=500,DWORD dwTimeToStay=4000,DWORD dwTimeTOHide=200); + //Sets Tray tooltips + void TraySetToolTip(char* data); + //Sets Tray icons + void TraySetIcon(char** data,bool what=false,int* pVals=NULL); + //Sets Colors + bool SetColorLevels(int* pLimits,COLORREF* pColors, int nEntries); + + +private: + + //these functions are provided for your convenience. Not used anymore. + void ShowContextMenu(); + void HideShowGUI(); + void ChangeGUISettings(); + void ChangeCoreSettings(); + void ShowHelp(); + void Quit(); + + //gtk functions for graphics + + //Sets the right values for differents Window Manager + void setupProperties(); + + //Draw speed bar + void drawMeters(GdkPixmap* pix,GdkBitmap* mask,int* pBarData); + void DrawIconMeter(GdkPixmap* pix,GdkBitmap* mask,int pBarData,int x); + + //private variables + + //Window Manager choice + int desktopMode; + + //GTK objects + GtkWidget* status_docklet; + GtkWidget* status_image; + GtkTooltips* status_tooltips; + + //Gtk Variables provided for graphics + COLORREF GetMeterColor(int level); + SIZE m_sDimensions; + int m_nSpacingWidth; + int m_nNumBars; + int m_nMaxVal; + int *m_pLimits; + COLORREF *m_pColors; + int m_nEntries; + +}; + +#endif /* __WXGTK__ */ #endif Index: defines.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/defines.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- defines.h 18 Dec 2003 04:25:36 -0000 1.42 +++ defines.h 19 Dec 2003 03:01:14 -0000 1.43 @@ -41,7 +41,7 @@ * wxWindows 2.4.2 does not define wxHAS_TASK_BAR_ICON even if it is * supported, so we define it here. */ -#ifdef __WXMSW__ +#if defined(__WXMSW__) || (defined(__WXGTK__) && defined(__HAS_GTK_CONFIG__)) #define wxHAS_TASK_BAR_ICON #endif |