changeset 3972:f9e961773058

[gaim-migrate @ 4156] systray now uses docklet_toggle committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Sat, 16 Nov 2002 01:15:49 +0000
parents 15b0d5b2de4d
children d9287e87ba56
files src/win32/systray.c src/win32/systray.h
diffstat 2 files changed, 40 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/win32/systray.c	Sat Nov 16 01:12:30 2002 +0000
+++ b/src/win32/systray.c	Sat Nov 16 01:15:49 2002 +0000
@@ -22,14 +22,6 @@
 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
 #define MAX_AWY_MESSAGES 50
 
-enum _GAIM_WIN {
-	GAIM_LOGIN_WIN,
-	GAIM_BUDDY_WIN,
-	GAIM_BACK_WIN,
-	GAIM_WIN_COUNT
-};
-typedef enum _GAIM_WIN GAIM_WIN;
-
 enum _SYSTRAY_STATE {
 	SYSTRAY_STATE_CONN,
 	SYSTRAY_STATE_CONNECTING,
@@ -60,7 +52,6 @@
 static HICON sysicon_conn=0;
 static HICON sysicon_away=0;
 static NOTIFYICONDATA wgaim_nid;
-static HWND gaim_windows[GAIM_WIN_COUNT];
 static SYSTRAY_STATE st_state=SYSTRAY_STATE_DISCONN;
 static HMENU systray_menu=0;
 static HMENU systray_away_menu=0;
@@ -68,6 +59,7 @@
 /*
  *  GLOBALS
  */
+extern GtkWidget *imaway;
 
 /*
  *  PRIVATE CODE
@@ -240,16 +232,17 @@
 	case WM_TRAYMESSAGE:
 	{
 		if( lparam == WM_LBUTTONDBLCLK ) {
-			/* If Gaim main win is hidden.. restore it */
-			if( st_state == SYSTRAY_STATE_DISCONN ) {
-				RestoreWndFromTray(gaim_windows[GAIM_LOGIN_WIN]);
-			}
-			else if( st_state == SYSTRAY_STATE_AWAY ) {
-				RestoreWndFromTray(gaim_windows[GAIM_BACK_WIN]);
-				RestoreWndFromTray(gaim_windows[GAIM_BUDDY_WIN]);
-			}
-			else if( st_state == SYSTRAY_STATE_CONN ) {
-				RestoreWndFromTray(gaim_windows[GAIM_BUDDY_WIN]);
+			/* Either hide or show current window (login or buddy) */
+			docklet_toggle();
+			/* if away.. hide/show I'm back win too */
+			if(st_state == SYSTRAY_STATE_AWAY) {
+				if(GTK_WIDGET_VISIBLE(blist) && !GTK_WIDGET_VISIBLE(imaway)) {
+					RestoreWndFromTray(GDK_WINDOW_HWND(GTK_WIDGET(imaway)->window));
+					gtk_window_present(GTK_WINDOW(imaway));
+				} else if(!GTK_WIDGET_VISIBLE(blist) && GTK_WIDGET_VISIBLE(imaway)) {
+					wgaim_systray_minimize(imaway);
+					gtk_widget_hide(imaway);
+				}
 			}
 			debug_printf("Systray got double click\n");
 		}
@@ -337,10 +330,6 @@
 	Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
 }
 
-static void systray_minimize_win(HWND hWnd) {
-	MinimizeWndToTray(hWnd);
-}
-
 static void systray_update_icon() {
 	switch(st_state) {
 	case SYSTRAY_STATE_CONN:
@@ -391,18 +380,12 @@
 	switch( msg->message ) {
 	case WM_SYSCOMMAND:
 		if( msg->wParam == SC_MINIMIZE ) {
-			systray_minimize_win(msg->hwnd);
-			/* Also minimize I'm back window */
-			if(st_state == SYSTRAY_STATE_AWAY)
-				systray_minimize_win(gaim_windows[GAIM_BACK_WIN]);
+			hide_buddy_list();
 			return GDK_FILTER_REMOVE;
 		}
 		break;
 	case WM_CLOSE:
-		systray_minimize_win(msg->hwnd);
-		/* Also minimize I'm back window */
-		if(st_state == SYSTRAY_STATE_AWAY)
-			systray_minimize_win(gaim_windows[GAIM_BACK_WIN]);
+		hide_buddy_list();
 		return GDK_FILTER_REMOVE;
 	}
 
@@ -414,7 +397,8 @@
 
 	switch( msg->message ) {
 	case WM_CLOSE:
-		systray_minimize_win(msg->hwnd);
+		wgaim_systray_minimize(mainwindow);
+		gtk_widget_hide(mainwindow);
 		return GDK_FILTER_REMOVE;
 	}
 
@@ -427,7 +411,10 @@
 	switch( msg->message ) {
 	case WM_SYSCOMMAND:
 		if( msg->wParam == SC_MINIMIZE ) {
-			systray_minimize_win(msg->hwnd);
+			if(imaway) {
+				wgaim_systray_minimize(imaway);
+				gtk_widget_hide(imaway);
+			}
 			return GDK_FILTER_REMOVE;
 		}
 		break;
@@ -455,6 +442,10 @@
 	systray_update_status();
 }
 
+static void st_im_recieve(struct gaim_connection *gc, void *data) {
+	
+}
+
 /*
  *  PUBLIC CODE
  */
@@ -462,6 +453,8 @@
 /* Create a hidden window and associate it with the systray icon.
    We use this hidden window to proccess WM_TRAYMESSAGE msgs. */
 void wgaim_systray_init(void) {
+	docklet_add();
+
 	/* dummy window to process systray messages */
 	systray_hwnd = systray_create_hiddenwin();
 
@@ -485,6 +478,7 @@
 }
 
 void wgaim_systray_cleanup(void) {
+	docklet_remove();
 	systray_remove_nid();
 	DestroyMenu(systray_menu);
 	DestroyWindow(systray_hwnd);
@@ -495,7 +489,6 @@
 	gdk_window_add_filter (GTK_WIDGET(blist)->window,
 			       st_buddywin_filter,
 			       NULL);
-	gaim_windows[GAIM_BUDDY_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(blist)->window);
 }
 
 /* This function is called after the login window has been created */
@@ -503,12 +496,18 @@
 	gdk_window_add_filter (GTK_WIDGET(loginwin)->window,
 			       st_loginwin_filter,
 			       NULL);
-	gaim_windows[GAIM_LOGIN_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(loginwin)->window);
 }
 
 void wgaim_created_backwin( GtkWidget *backwin ) {
 	gdk_window_add_filter (GTK_WIDGET(backwin)->window,
 			       st_backwin_filter,
 			       NULL);
-	gaim_windows[GAIM_BACK_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(backwin)->window);
+}
+
+void wgaim_systray_minimize( GtkWidget *window ) {
+	MinimizeWndToTray(GDK_WINDOW_HWND(window->window));
 }
+
+void wgaim_systray_maximize( GtkWidget *window ) {
+	RestoreWndFromTray(GDK_WINDOW_HWND(window->window));
+}
--- a/src/win32/systray.h	Sat Nov 16 01:12:30 2002 +0000
+++ b/src/win32/systray.h	Sat Nov 16 01:15:49 2002 +0000
@@ -10,9 +10,10 @@
 #define _SYSTRAY_H_
 
 extern void wgaim_systray_init(void);
-extern void wgaim_created_blistwin( GtkWidget *blist );
-extern void wgaim_created_loginwin( GtkWidget *loginwin );
-extern void wgaim_created_backwin( GtkWidget *backwin );
+extern void wgaim_created_blistwin( GtkWidget* );
+extern void wgaim_created_loginwin( GtkWidget* );
+extern void wgaim_created_backwin( GtkWidget* );
 extern void wgaim_systray_cleanup(void);
-
+extern void wgaim_systray_minimize( GtkWidget* );
+extern void wgaim_systray_maximize( GtkWidget* );
 #endif /* _SYSTRAY_H_ */