Mercurial > pidgin.yaz
changeset 11709:cae2fb7e8594
[gaim-migrate @ 14000]
This is a patch from Casey Harkins to significantly overhaul the docklet plugin. I'm pretty happy about this because it enables us to remove a win32 GTK+ dependency on the core and all the prpls.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 22 Oct 2005 01:18:08 +0000 |
parents | 69602de55fe9 |
children | c9bd6decdec4 |
files | plugins/docklet/Makefile.am plugins/docklet/Makefile.mingw plugins/docklet/MinimizeToTray.c plugins/docklet/MinimizeToTray.h plugins/docklet/docklet-win32.c plugins/docklet/docklet-x11.c plugins/docklet/docklet.c plugins/docklet/docklet.h plugins/win32/winprefs/winprefs.c src/Makefile.am src/Makefile.mingw src/gtkblist.c src/gtkblist.h src/gtkdialogs.h src/gtkprefs.c src/server.c src/win32/MinimizeToTray.c src/win32/MinimizeToTray.h src/win32/global.mak src/win32/win32dep.c src/win32/win32dep.h |
diffstat | 21 files changed, 543 insertions(+), 642 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/docklet/Makefile.am Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/Makefile.am Sat Oct 22 01:18:08 2005 +0000 @@ -1,6 +1,8 @@ EXTRA_DIST = \ - Makefile.mingw \ - docklet-win32.c + Makefile.mingw \ + docklet-win32.c \ + MinimizeToTray.c \ + MinimizeToTray.h plugindir = $(libdir)/gaim
--- a/plugins/docklet/Makefile.mingw Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/Makefile.mingw Sat Oct 22 01:18:08 2005 +0000 @@ -56,8 +56,9 @@ ## SOURCES, OBJECTS ## -C_SRC = docklet.c \ - docklet-win32.c +C_SRC = docklet.c \ + docklet-win32.c \ + MinimizeToTray.c OBJECTS = $(C_SRC:%.c=%.o)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/docklet/MinimizeToTray.c Sat Oct 22 01:18:08 2005 +0000 @@ -0,0 +1,135 @@ +/* MinimizeToTray + * + * A couple of routines to show how to make it produce a custom caption + * animation to make it look like we are minimizing to and maximizing + * from the system tray + * + * These routines are public domain, but it would be nice if you dropped + * me a line if you use them! + * + * 1.0 29.06.2000 Initial version + * 1.1 01.07.2000 The window retains it's place in the Z-order of windows + * when minimized/hidden. This means that when restored/shown, it doesn't + * always appear as the foreground window unless we call SetForegroundWindow + * + * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> + */ +#include "stdafx.h" + +#ifndef IDANI_OPEN +#define IDANI_OPEN 1 +#endif +#ifndef IDANI_CLOSE +#define IDANI_CLOSE 2 +#endif +#ifndef IDANI_CAPTION +#define IDANI_CAPTION 3 +#endif + +#define DEFAULT_RECT_WIDTH 150 +#define DEFAULT_RECT_HEIGHT 30 + +static void GetTrayWndRect(LPRECT lpTrayRect) +{ + APPBARDATA appBarData; + HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); + + if(hShellTrayWnd) + { + HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL); + if(hTrayNotifyWnd) + { + GetWindowRect(hTrayNotifyWnd,lpTrayRect); + return; + } + } + + appBarData.cbSize=sizeof(appBarData); + if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) + { + switch(appBarData.uEdge) + { + case ABE_LEFT: + case ABE_RIGHT: + lpTrayRect->top=appBarData.rc.bottom-100; + lpTrayRect->bottom=appBarData.rc.bottom-16; + lpTrayRect->left=appBarData.rc.left; + lpTrayRect->right=appBarData.rc.right; + break; + + case ABE_TOP: + case ABE_BOTTOM: + lpTrayRect->top=appBarData.rc.top; + lpTrayRect->bottom=appBarData.rc.bottom; + lpTrayRect->left=appBarData.rc.right-100; + lpTrayRect->right=appBarData.rc.right-16; + break; + } + + return; + } + + hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); + if(hShellTrayWnd) + { + GetWindowRect(hShellTrayWnd,lpTrayRect); + if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH) + lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; + if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT) + lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; + + return; + } + + SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0); + lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; + lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; +} + +static int GetDoAnimateMinimize(void) +{ + ANIMATIONINFO ai; + + ai.cbSize=sizeof(ai); + SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); + + return ai.iMinAnimate?TRUE:FALSE; +} + +void MinimizeWndToTray(HWND hWnd) +{ + if(!IsWindowVisible(hWnd)) + return; + if(GetDoAnimateMinimize()) + { + RECT rcFrom,rcTo; + + GetWindowRect(hWnd,&rcFrom); + GetTrayWndRect(&rcTo); + + DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); + } + + ShowWindow(hWnd,SW_HIDE); +} + +void RestoreWndFromTray(HWND hWnd) +{ + if(IsWindowVisible(hWnd)) + return; + if(GetDoAnimateMinimize()) + { + RECT rcFrom,rcTo; + GetTrayWndRect(&rcFrom); + GetWindowRect(hWnd,&rcTo); + + DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); + } + + ShowWindow(hWnd,SW_SHOW); + SetActiveWindow(hWnd); + SetForegroundWindow(hWnd); +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/docklet/MinimizeToTray.h Sat Oct 22 01:18:08 2005 +0000 @@ -0,0 +1,7 @@ +#ifndef _MINIMIZE_TO_TRAY_H_ +#define _MINIMIZE_TO_TRAY_H_ + +void MinimizeWndToTray(HWND hWnd); +void RestoreWndFromTray(HWND hWnd); + +#endif /* _MINIMIZE_TO_TRAY_H_ */
--- a/plugins/docklet/docklet-win32.c Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/docklet-win32.c Sat Oct 22 01:18:08 2005 +0000 @@ -114,7 +114,7 @@ wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = 0; + wcex.style = 0; wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; @@ -152,11 +152,11 @@ static void systray_change_icon(HICON icon, char* text) { char *locenc=NULL; wgaim_nid.hIcon = icon; - if(text) { - locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL); - lstrcpy(wgaim_nid.szTip, locenc); - g_free(locenc); - } + if (text) { + locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL); + lstrcpy(wgaim_nid.szTip, locenc); + g_free(locenc); + } Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid); } @@ -164,31 +164,30 @@ Shell_NotifyIcon(NIM_DELETE,&wgaim_nid); } -static void wgaim_tray_update_icon(enum docklet_status icon) { +static void wgaim_tray_update_icon(DockletStatus icon) { switch (icon) { - case offline: + case DOCKLET_STATUS_OFFLINE: systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT); break; - case offline_connecting: - case online_connecting: + case DOCKLET_STATUS_CONNECTING: break; - case online: + case DOCKLET_STATUS_ONLINE: systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT); break; - case online_pending: + case DOCKLET_STATUS_ONLINE_PENDING: systray_change_icon(sysicon_pend, GAIM_SYSTRAY_HINT); break; - case away: + case DOCKLET_STATUS_AWAY: systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT); break; - case away_pending: + case DOCKLET_STATUS_AWAY_PENDING: systray_change_icon(sysicon_awypend, GAIM_SYSTRAY_AWAY_HINT); break; } } static void wgaim_tray_blank_icon() { - systray_change_icon(sysicon_blank, NULL); + systray_change_icon(sysicon_blank, NULL); } static void wgaim_tray_create() { @@ -230,12 +229,22 @@ docklet_remove(TRUE); } +void wgaim_tray_minimize(GtkWidget *window) { + MinimizeWndToTray(GDK_WINDOW_HWND(window->window)); +} + +void wgaim_tray_maximize(GtkWidget *window) { + RestoreWndFromTray(GDK_WINDOW_HWND(window->window)); +} + static struct docklet_ui_ops wgaim_tray_ops = { wgaim_tray_create, wgaim_tray_destroy, wgaim_tray_update_icon, wgaim_tray_blank_icon, + wgaim_tray_minimize, + wgaim_tray_maximize, NULL };
--- a/plugins/docklet/docklet-x11.c Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/docklet-x11.c Sat Oct 22 01:18:08 2005 +0000 @@ -84,30 +84,29 @@ } static void -docklet_x11_update_icon(enum docklet_status icon) +docklet_x11_update_icon(DockletStatus icon) { const gchar *icon_name = NULL; g_return_if_fail(image != NULL); switch (icon) { - case offline: + case DOCKLET_STATUS_OFFLINE: icon_name = GAIM_STOCK_ICON_OFFLINE; break; - case offline_connecting: - case online_connecting: + case DOCKLET_STATUS_CONNECTING: icon_name = GAIM_STOCK_ICON_CONNECT; break; - case online: + case DOCKLET_STATUS_ONLINE: icon_name = GAIM_STOCK_ICON_ONLINE; break; - case online_pending: + case DOCKLET_STATUS_ONLINE_PENDING: icon_name = GAIM_STOCK_ICON_ONLINE_MSG; break; - case away: + case DOCKLET_STATUS_AWAY: icon_name = GAIM_STOCK_ICON_AWAY; break; - case away_pending: + case DOCKLET_STATUS_AWAY_PENDING: icon_name = GAIM_STOCK_ICON_AWAY_MSG; break; } @@ -258,6 +257,8 @@ docklet_x11_destroy, docklet_x11_update_icon, docklet_x11_blank_icon, + NULL, + NULL, #if GTK_CHECK_VERSION(2,2,0) docklet_x11_position_menu #else
--- a/plugins/docklet/docklet.c Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/docklet.c Sat Oct 22 01:18:08 2005 +0000 @@ -21,19 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ - -/* TODO (in order of importance): - * - unify the queue so we can have a global away without the dialog - * - handle and update tooltips to show your current accounts/queued messages? - * - show a count of queued messages in the unified queue - * - dernyi's account status menu in the right click - * - optional pop up notices when GNOME2's system-tray-applet supports it - */ - #include "internal.h" #include "gtkgaim.h" #include "core.h" +#include "conversation.h" #include "debug.h" #include "prefs.h" #include "signals.h" @@ -42,6 +34,7 @@ #include "gtkaccount.h" #include "gtkblist.h" +#include "gtkconv.h" #include "gtkft.h" #include "gtkplugin.h" #include "gtkprefs.h" @@ -53,61 +46,319 @@ #include "gaim.h" #include "gtkdialogs.h" +#define DOCKLET_PLUGIN_ID "gtk-docklet" + /* globals */ - GaimPlugin *handle = NULL; static struct docklet_ui_ops *ui_ops = NULL; -static enum docklet_status status = offline; -gboolean online_account_supports_chat = FALSE; -#if 0 /* XXX CUI */ -#ifdef _WIN32 -__declspec(dllimport) GSList *unread_message_queue; -__declspec(dllimport) GSList *away_messages; -__declspec(dllimport) struct away_message *awaymessage; -__declspec(dllimport) GSList *message_queue; -#endif -#endif +static DockletStatus status = DOCKLET_STATUS_OFFLINE; +static gulong gtkblist_delete_cb_id = 0; +static gboolean enable_join_chat = FALSE; + +/************************************************************************** + * docklet status and utility functions + **************************************************************************/ +static gboolean +docklet_blink_icon() +{ + static gboolean blinked = FALSE; + gboolean ret = FALSE; /* by default, don't keep blinking */ + + blinked = !blinked; + + switch (status) { + case DOCKLET_STATUS_ONLINE_PENDING: + case DOCKLET_STATUS_AWAY_PENDING: + if (blinked) { + if (ui_ops && ui_ops->blank_icon) + ui_ops->blank_icon(); + } else { + if (ui_ops && ui_ops->update_icon) + ui_ops->update_icon(status); + } + ret = TRUE; /* keep blinking */ + break; + default: + blinked = FALSE; + break; + } + + return ret; +} + +static gboolean +docklet_update_status() +{ + GList *l; + DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; + gboolean pending = FALSE; + + /* determine if any ims have unseen messages */ + for(l = gaim_get_ims(); l!=NULL; l=l->next) { + GaimConversation *conv = (GaimConversation*)l->data; + if(GAIM_IS_GTK_CONVERSATION(conv)) { + if(GAIM_GTK_CONVERSATION(conv)->unseen_state!=GAIM_UNSEEN_NONE) { + pending = TRUE; + break; + } + } + } + + /* iterate through all accounts and determine which + * status to show in the tray icon based on the following + * ranks (highest encountered rank will be used): + * + * 1) OFFLINE + * 2) ONLINE + * 3) ONLINE_PENDING + * 4) AWAY + * 5) AWAY_PENDING + * 6) CONNECTING + */ + for(l = gaim_accounts_get_all(); l!=NULL; l=l->next) { + DockletStatus tmpstatus = DOCKLET_STATUS_OFFLINE; + + GaimAccount *account = (GaimAccount*)l->data; + GaimStatus *account_status; + + if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) + continue; + + if(gaim_account_is_disconnected(account)) + continue; + + account_status = gaim_account_get_active_status(account); + + if(gaim_account_is_connecting(account)) { + tmpstatus = DOCKLET_STATUS_CONNECTING; + } + else if(gaim_status_is_online(account_status)) { + if(!gaim_status_is_available(account_status)) { + if(pending) + tmpstatus = DOCKLET_STATUS_AWAY_PENDING; + else + tmpstatus = DOCKLET_STATUS_AWAY; + } + else { + if(pending) + tmpstatus = DOCKLET_STATUS_ONLINE_PENDING; + else + tmpstatus = DOCKLET_STATUS_ONLINE; + } + } + + if(tmpstatus>newstatus) newstatus=tmpstatus; + } + + /* update the icon if we changed status */ + if (status != newstatus) { + status = newstatus; + + if (ui_ops && ui_ops->update_icon) + ui_ops->update_icon(status); + + /* and schedule the blinker function if messages are pending */ + if (status == DOCKLET_STATUS_ONLINE_PENDING + || status == DOCKLET_STATUS_AWAY_PENDING) { + g_timeout_add(500, docklet_blink_icon, &handle); + } + } + + return FALSE; /* for when we're called by the glib idle handler */ +} + +static gboolean +online_account_supports_chat() +{ + GList *c = NULL; + c = gaim_connections_get_all(); + + while(c!=NULL) { + GaimConnection *gc = c->data; + if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) + return TRUE; + } + + return FALSE; +} -/* private functions */ +static gboolean +focus_first_unseen_conv() +{ + GList *l; + GaimConversation *conv; + GaimGtkConversation *gtkconv; + + /* find first im with unseen messages */ + for(l = gaim_get_ims(); l!=NULL; l=l->next) { + conv = (GaimConversation*)l->data; + if(GAIM_IS_GTK_CONVERSATION(conv)) { + gtkconv=GAIM_GTK_CONVERSATION(conv); + if(gtkconv->unseen_state!=GAIM_UNSEEN_NONE) { + gtkconv->active_conv=conv; + gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); + gaim_gtk_conv_window_raise(gtkconv->win); + gtk_window_present(GTK_WINDOW(gtkconv->win->window)); + return TRUE; + } + } + } + + return FALSE; +} + +/************************************************************************** + * minimize to and unminimize from the tray icon + **************************************************************************/ +static void +minimize_to_tray() +{ + GaimGtkBuddyList *blist = gaim_gtk_blist_get_default_gtk_blist(); + + if(!blist || !blist->window) + return; + + if (ui_ops && ui_ops->minimize) + ui_ops->minimize(blist->window); + + gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", FALSE); + gtk_widget_hide(blist->window); + + docklet_update_status(); +} + +static void +unminimize_from_tray() +{ + GaimGtkBuddyList *blist = gaim_gtk_blist_get_default_gtk_blist(); + + if(!blist || !blist->window) + return; + + if (ui_ops && ui_ops->maximize) + ui_ops->maximize(blist->window); + + gaim_blist_set_visible(TRUE); + + docklet_update_status(); +} + +static void +docklet_toggle_blist() +{ + if(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) + minimize_to_tray(); + else + unminimize_from_tray(); +} +/************************************************************************** + * callbacks and signal handlers + **************************************************************************/ +/* catch delete events on gtkblist and hide it instead */ +static gboolean +gtkblist_delete_cb(GtkWidget *widget) { + gaim_debug(GAIM_DEBUG_INFO, "docklet", "hiding buddy list\n"); + minimize_to_tray(widget); + return TRUE; +} + +/* connect to delete signal when gtkblist is created */ +static void +gtkblist_created_cb(GaimBuddyList *list) +{ + if(list!=NULL && GAIM_IS_GTK_BLIST(list) && + GAIM_GTK_BLIST(list)->window!=NULL && + gtkblist_delete_cb_id==0) { + + gtkblist_delete_cb_id = g_signal_connect(G_OBJECT(GAIM_GTK_BLIST(list)->window), + "delete_event", G_CALLBACK(gtkblist_delete_cb), NULL); + } +} + +static void +gaim_quit_cb() +{ + /* TODO: confirm quit while pending */ +} + +static void +docklet_update_status_cb(void *data, ...) +{ + /* The odd function arguments allow this callback to be used for + * any signal which has a pointer as the first callback parameter. + * Although ugly, it allows this single callback to be used instead + * of multiple functions with different signatures that do the same + * thing. + */ + docklet_update_status(); +} + +static void +docklet_conv_updated_cb(GaimConversation *conv, GaimConvUpdateType type) +{ + if(type==GAIM_CONV_UPDATE_UNSEEN) + docklet_update_status(); +} + +static void +docklet_signed_on_cb(GaimConnection *gc) +{ + if(!enable_join_chat) { + if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) + enable_join_chat = TRUE; + } + docklet_update_status(); +} + +static void +docklet_signed_off_cb(GaimConnection *gc) +{ + if(enable_join_chat) { + if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) + enable_join_chat = online_account_supports_chat(); + } + docklet_update_status(); +} + +/************************************************************************** + * docklet pop-up menu + **************************************************************************/ static void docklet_toggle_mute(GtkWidget *toggle, void *data) { gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active); } -static void -docklet_set_bool(GtkWidget *widget, const char *key) -{ - gaim_prefs_set_bool(key, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); -} - #ifdef _WIN32 /* This is a workaround for a bug in windows GTK+. Clicking outside of the menu does not get rid of it, so instead we get rid of it as soon as the pointer leaves the menu. */ -static gboolean hide_docklet_menu(gpointer data) +static gboolean +hide_docklet_menu(gpointer data) { if (data != NULL) { gtk_menu_popdown(GTK_MENU(data)); } return FALSE; } + static gboolean docklet_menu_leave_enter(GtkWidget *menu, GdkEventCrossing *event, void *data) { static guint hide_docklet_timer = 0; if (event->type == GDK_LEAVE_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "menu leave-notify-event\n"); + gaim_debug(GAIM_DEBUG_INFO, "docklet", "menu leave-notify-event\n"); /* Add some slop so that the menu doesn't annoyingly disappear when mousing around */ if (hide_docklet_timer == 0) { hide_docklet_timer = gaim_timeout_add(500, hide_docklet_menu, menu); } } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "menu enter-notify-event\n"); + gaim_debug(GAIM_DEBUG_INFO, "docklet", "menu enter-notify-event\n"); if (hide_docklet_timer != 0) { /* Cancel the hiding if we reenter */ + gaim_timeout_remove(hide_docklet_timer); hide_docklet_timer = 0; } @@ -116,7 +367,8 @@ } #endif -static void docklet_menu() { +static void +docklet_menu() { static GtkWidget *menu = NULL; GtkWidget *entry; GtkWidget *menuitem; @@ -127,66 +379,21 @@ menu = gtk_menu_new(); - switch (status) { - case offline: - case offline_connecting: - /* No special menu items right now */ - break; - default: - gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL); - menuitem = gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(gaim_gtk_blist_joinchat_show), NULL, 0, 0, NULL); - gtk_widget_set_sensitive(menuitem, online_account_supports_chat); - - gaim_separator(menu); - break; - } + entry = gtk_check_menu_item_new_with_label(_("Show Buddy List")); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); + g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); - switch (status) { - case offline: - case offline_connecting: - break; - case online: - case online_connecting: - case online_pending: { -#if 0 /* XXX NEW STATUS */ - GtkWidget *docklet_awaymenu; - GSList *awy = NULL; - struct away_message *a = NULL; - - docklet_awaymenu = gtk_menu_new(); - awy = away_messages; + gaim_separator(menu); - while (awy) { - a = (struct away_message *)awy->data; - - entry = gtk_menu_item_new_with_label(a->name); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_away_message), a); - gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry); - - awy = g_slist_next(awy); - } - - if (away_messages) - gaim_separator(docklet_awaymenu); + menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL); + if(status == DOCKLET_STATUS_OFFLINE) + gtk_widget_set_sensitive(menuitem, FALSE); - entry = gtk_menu_item_new_with_label(_("New...")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry); + menuitem = gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(gaim_gtk_blist_joinchat_show), NULL, 0, 0, NULL); + gtk_widget_set_sensitive(menuitem, enable_join_chat); - entry = gtk_menu_item_new_with_label(_("Away")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); -#endif - } break; - case away: - case away_pending: -#if 0 /* XXX NEW STATUS */ - entry = gtk_menu_item_new_with_label(_("Back")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); -#endif - break; - } + gaim_separator(menu); entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), gaim_prefs_get_bool("/gaim/gtk/sound/mute")); @@ -201,6 +408,10 @@ gaim_separator(menu); + /* TODO: need a submenu to change status, this needs to "link" + * to the status in the buddy list gtkstatusbox + */ + gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(gaim_core_quit), NULL, 0, 0, NULL); #ifdef _WIN32 @@ -213,136 +424,19 @@ NULL, 0, gtk_get_current_event_time()); } -static gboolean -docklet_blink_icon() -{ - static gboolean blinked = FALSE; - gboolean ret = FALSE; /* by default, don't keep blinking */ - - blinked = !blinked; - - switch (status) { - case online_pending: - case away_pending: - if (blinked) { - if (ui_ops && ui_ops->blank_icon) - ui_ops->blank_icon(); - } else { - if (ui_ops && ui_ops->update_icon) - ui_ops->update_icon(status); - } - ret = TRUE; /* keep blinking */ - break; - case offline: - case offline_connecting: - case online: - case online_connecting: - case away: - blinked = FALSE; - break; - } - - return ret; -} - -static gboolean -docklet_update_status() -{ - GList *c; - enum docklet_status oldstatus; - - oldstatus = status; - - if ((c = gaim_connections_get_all())) { -#if 0 /* XXX NEW STATUS */ - if (unread_message_queue) { - status = online_pending; - } else if (awaymessage) { - if (message_queue) { - status = away_pending; - } else { - status = away; - } - } else if (gaim_connections_get_connecting()) { -#else - if (gaim_connections_get_connecting()) { -#endif - status = online_connecting; - } else { - status = online; - } - /* Check if any online accounts support chats */ - while (c != NULL) { - GaimConnection *gc = c->data; - if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) { - online_account_supports_chat = TRUE; - break; - } - c = c->next; - } - } else { - if (gaim_connections_get_connecting()) { - status = offline_connecting; - } else { - status = offline; - } - } - - /* update the icon if we changed status */ - if (status != oldstatus) { - if (ui_ops && ui_ops->update_icon) - ui_ops->update_icon(status); - - /* and schedule the blinker function if messages are pending */ - if (status == online_pending || status == away_pending) { - g_timeout_add(500, docklet_blink_icon, &handle); - } - } - - return FALSE; /* for when we're called by the glib idle handler */ -} - -#if 0 /* XXX CUI */ -static void -docklet_flush_queue() -{ - if (unread_message_queue) { - purge_away_queue(&unread_message_queue); - } -} -#endif - -static void -docklet_remove_callbacks() -{ - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "removing callbacks"); - - while (g_source_remove_by_user_data(&handle)) { - gaim_debug(GAIM_DEBUG_INFO, NULL, "."); - } - - gaim_debug(GAIM_DEBUG_INFO, NULL, "\n"); -} - -/* public code */ - +/************************************************************************** + * public api for ui_ops + **************************************************************************/ void docklet_clicked(int button_type) { switch (button_type) { case 1: -#if 0 /* XXX CUI */ - if (unread_message_queue) { - docklet_flush_queue(); - } else { -#endif - gaim_gtk_blist_docklet_toggle(); -#if 0 /* XXX CUI */ - } -#endif - break; - case 2: - /* Don't do anything for middle click */ + if(status==DOCKLET_STATUS_ONLINE_PENDING + || status==DOCKLET_STATUS_AWAY_PENDING) + focus_first_unseen_conv(); + else + docklet_toggle_blist(); break; case 3: docklet_menu(); @@ -353,8 +447,6 @@ void docklet_embedded() { - gaim_gtk_blist_docklet_add(); - docklet_update_status(); if (ui_ops && ui_ops->update_icon) ui_ops->update_icon(status); @@ -363,12 +455,7 @@ void docklet_remove(gboolean visible) { - if (visible) - gaim_gtk_blist_docklet_remove(); - -#if 0 /* XXX CUI */ - docklet_flush_queue(); -#endif + unminimize_from_tray(); } void @@ -383,86 +470,9 @@ ui_ops = ops; } -/* callbacks */ - -static void -gaim_login(GaimConnection *gc, void *data) -{ - docklet_update_status(); -} - -static void -gaim_logout(GaimConnection *gc, void *data) -{ - /* do this when idle so that if the prpl was connecting - and was cancelled, we register that connecting_count - has returned to 0 */ - /* no longer necessary because Chip decided that us plugins - didn't need to know if an account was connecting or not - g_idle_add(docklet_update_status, &docklet); */ - docklet_update_status(); -} - -static void -gaim_connecting(GaimAccount *account, void *data) -{ - docklet_update_status(); -} - -static void -gaim_away(GaimAccount *account, char *state, char *message, void *data) -{ - /* we only support global away. this is the way it is, ok? */ - docklet_update_status(); -} - -static gboolean -gaim_conv_im_recv(GaimAccount *account, char *sender, char *message, - GaimConversation *conv, int flags, void *data) -{ - /* if message queuing while away is enabled, this event could be the first - message so we need to see if the status (and hence icon) needs changing. - do this when idle so that all message processing is completed, queuing - etc, before we run. */ - g_idle_add(docklet_update_status, &handle); - - return FALSE; -} - -static void -gaim_new_conversation(GaimConversation *conv, void *data) -{ - /* queue a callback here so if the queue is being - flushed, we stop flashing. thanks javabsp. */ - g_idle_add(docklet_update_status, &handle); -} - -/* We need this because the blist purge_away_queue cb won't be called before the - plugin is unloaded, when quitting */ -static void gaim_quit_cb() { - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "dealing with queued messages on exit\n"); -#if 0 /* XXX CUI */ - docklet_flush_queue(); -#endif -} - - -/* static void gaim_buddy_signon(GaimConnection *gc, char *who, void *data) { -} - -static void gaim_buddy_signoff(GaimConnection *gc, char *who, void *data) { -} - -static void gaim_buddy_away(GaimConnection *gc, char *who, void *data) { -} - -static void gaim_buddy_back(GaimConnection *gc, char *who, void *data) { -} */ - -/* plugin glue */ - -#define DOCKLET_PLUGIN_ID "gtk-docklet" - +/************************************************************************** + * plugin glue + **************************************************************************/ static gboolean plugin_load(GaimPlugin *plugin) { @@ -471,7 +481,7 @@ void *accounts_handle = gaim_accounts_get_handle(); void *core_handle = gaim_get_core(); - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin loaded\n"); + gaim_debug(GAIM_DEBUG_INFO, "docklet", "plugin loaded\n"); handle = plugin; @@ -480,24 +490,31 @@ ui_ops->create(); gaim_signal_connect(conn_handle, "signed-on", - plugin, GAIM_CALLBACK(gaim_login), NULL); + plugin, GAIM_CALLBACK(docklet_signed_on_cb), NULL); gaim_signal_connect(conn_handle, "signed-off", - plugin, GAIM_CALLBACK(gaim_logout), NULL); + plugin, GAIM_CALLBACK(docklet_signed_off_cb), NULL); gaim_signal_connect(accounts_handle, "account-connecting", - plugin, GAIM_CALLBACK(gaim_connecting), NULL); + plugin, GAIM_CALLBACK(docklet_update_status_cb), NULL); gaim_signal_connect(accounts_handle, "account-away", - plugin, GAIM_CALLBACK(gaim_away), NULL); + plugin, GAIM_CALLBACK(docklet_update_status_cb), NULL); gaim_signal_connect(conv_handle, "received-im-msg", - plugin, GAIM_CALLBACK(gaim_conv_im_recv), NULL); + plugin, GAIM_CALLBACK(docklet_update_status_cb), NULL); gaim_signal_connect(conv_handle, "conversation-created", - plugin, GAIM_CALLBACK(gaim_new_conversation), NULL); + plugin, GAIM_CALLBACK(docklet_update_status_cb), NULL); + gaim_signal_connect(conv_handle, "conversation-updated", + plugin, GAIM_CALLBACK(docklet_conv_updated_cb), NULL); + + gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-created", + plugin, GAIM_CALLBACK(gtkblist_created_cb), NULL); + gtkblist_created_cb(gaim_get_blist()); gaim_signal_connect(core_handle, "quitting", plugin, GAIM_CALLBACK(gaim_quit_cb), NULL); -/* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); - gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); - gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); - gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); */ + + enable_join_chat = online_account_supports_chat(); + + if(!gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) + minimize_to_tray(); return TRUE; } @@ -505,45 +522,23 @@ static gboolean plugin_unload(GaimPlugin *plugin) { + GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); + if (ui_ops && ui_ops->destroy) ui_ops->destroy(); - docklet_remove_callbacks(); + /* remove callbacks */ + gaim_signals_disconnect_by_handle(handle); + if(gtkblist_delete_cb_id!=0) + g_signal_handler_disconnect(G_OBJECT(gtkblist->window), gtkblist_delete_cb_id); - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin unloaded\n"); + unminimize_from_tray(); + + gaim_debug(GAIM_DEBUG_INFO, "docklet", "plugin unloaded\n"); return TRUE; } -static GtkWidget * -plugin_config_frame(GaimPlugin *plugin) -{ - GtkWidget *frame; - GtkWidget *vbox, *hbox; - GtkWidget *toggle; - static const char *qmpref = "/plugins/gtk/docklet/queue_messages"; - - frame = gtk_vbox_new(FALSE, 18); - gtk_container_set_border_width(GTK_CONTAINER(frame), 12); - - vbox = gaim_gtk_make_frame(frame, _("Tray Icon Configuration")); - hbox = gtk_hbox_new(FALSE, 18); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until tray icon is clicked")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), gaim_prefs_get_bool(qmpref)); - g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_set_bool), (void *)qmpref); - gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); - - gtk_widget_show_all(frame); - return frame; -} - -static GaimGtkPluginUiInfo ui_info = -{ - plugin_config_frame -}; - static GaimPluginInfo info = { GAIM_PLUGIN_MAGIC, @@ -573,7 +568,7 @@ plugin_unload, /**< unload */ NULL, /**< destroy */ - &ui_info, /**< ui_info */ + NULL, /**< ui_info */ NULL, /**< extra_info */ NULL, NULL @@ -582,6 +577,7 @@ static void plugin_init(GaimPlugin *plugin) { + /* TODO: these will be removed once queuing is working in the ui */ gaim_prefs_add_none("/plugins/gtk/docklet"); gaim_prefs_add_bool("/plugins/gtk/docklet/queue_messages", FALSE); }
--- a/plugins/docklet/docklet.h Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/docklet/docklet.h Sat Oct 22 01:18:08 2005 +0000 @@ -25,23 +25,24 @@ #ifndef _DOCKLET_H_ #define _DOCKLET_H_ -enum docklet_status +typedef enum { - offline, - offline_connecting, - online, - online_connecting, - online_pending, - away, - away_pending -}; + DOCKLET_STATUS_OFFLINE, + DOCKLET_STATUS_ONLINE, + DOCKLET_STATUS_ONLINE_PENDING, + DOCKLET_STATUS_AWAY, + DOCKLET_STATUS_AWAY_PENDING, + DOCKLET_STATUS_CONNECTING +} DockletStatus; struct docklet_ui_ops { void (*create)(); void (*destroy)(); - void (*update_icon)(enum docklet_status); + void (*update_icon)(DockletStatus); void (*blank_icon)(); + void (*minimize)(GtkWidget *); + void (*maximize)(GtkWidget *); GtkMenuPositionFunc position_menu; };
--- a/plugins/win32/winprefs/winprefs.c Sat Oct 22 01:03:18 2005 +0000 +++ b/plugins/win32/winprefs/winprefs.c Sat Oct 22 01:18:08 2005 +0000 @@ -20,7 +20,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - +#include <gtk/gtk.h> #include <gdk/gdkwin32.h> #include "internal.h"
--- a/src/Makefile.am Sat Oct 22 01:03:18 2005 +0000 +++ b/src/Makefile.am Sat Oct 22 01:18:08 2005 +0000 @@ -7,8 +7,6 @@ win32/IdleTracker/Makefile.mingw \ win32/IdleTracker/idletrack.c \ win32/IdleTracker/idletrack.h \ - win32/MinimizeToTray.c \ - win32/MinimizeToTray.h \ win32/gaimrc.rc \ win32/global.mak \ win32/libc_interface.c \
--- a/src/Makefile.mingw Sat Oct 22 01:03:18 2005 +0000 +++ b/src/Makefile.mingw Sat Oct 22 01:18:08 2005 +0000 @@ -156,7 +156,6 @@ xmlnode.c \ whiteboard.c \ win32/win32dep.c \ - win32/MinimizeToTray.c \ win32/libc_interface.c \ win32/wspell.c \ win32/untar.c
--- a/src/gtkblist.c Sat Oct 22 01:03:18 2005 +0000 +++ b/src/gtkblist.c Sat Oct 22 01:18:08 2005 +0000 @@ -155,10 +155,7 @@ static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) { - if (docklet_count) - gaim_blist_set_visible(FALSE); - else - gaim_core_quit(); + gaim_core_quit(); /* we handle everything, event should not propogate further */ return TRUE; @@ -3157,7 +3154,7 @@ {"application/x-im-contact", 0, DRAG_BUDDY}, {"text/x-vcard", 0, DRAG_VCARD }}; if (gtkblist && gtkblist->window) { - if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible") || docklet_count == 0) + if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) gtk_widget_show(gtkblist->window); return; } @@ -3172,7 +3169,7 @@ gtk_widget_show(gtkblist->vbox); gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); - g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); + g_signal_connect_after(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); g_signal_connect(G_OBJECT(gtkblist->window), "configure_event", G_CALLBACK(gtk_blist_configure_cb), NULL); g_signal_connect(G_OBJECT(gtkblist->window), "visibility_notify_event", G_CALLBACK(gtk_blist_visibility_cb), NULL); gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); @@ -3308,7 +3305,7 @@ gaim_gtk_blist_update_plugin_actions(); /* OK... let's show this bad boy. */ - if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible") || docklet_count == 0) { + if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) { gaim_gtk_blist_refresh(list); gaim_gtk_blist_restore_position(); gtk_widget_show(gtkblist->window); @@ -3853,14 +3850,7 @@ gaim_gtk_blist_restore_position(); gtk_window_present(GTK_WINDOW(gtkblist->window)); } else { - if (!gaim_connections_get_all() || docklet_count) { -#ifdef _WIN32 - wgaim_systray_minimize(gtkblist->window); -#endif - gtk_widget_hide(gtkblist->window); - } else { - gtk_window_iconify(GTK_WINDOW(gtkblist->window)); - } + gtk_window_iconify(GTK_WINDOW(gtkblist->window)); } } @@ -4477,41 +4467,6 @@ _("Cancel"), NULL, NULL); } -void gaim_gtk_blist_docklet_toggle() { - /* Useful for the docklet plugin and also for the win32 tray icon*/ - /* This is called when one of those is clicked--it will show/hide the - buddy list/login window--depending on which is active */ - if (gtkblist && gtkblist->window) { - if (GTK_WIDGET_VISIBLE(gtkblist->window)) { - gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gaim_gtk_blist_obscured); - } else { -#if _WIN32 - wgaim_systray_maximize(gtkblist->window); -#endif - gaim_blist_set_visible(TRUE); - } - } else { - /* we're logging in or something... do nothing */ - /* or should I make the blist? */ - gaim_debug_warning("gtkblist", - "docklet_toggle called with gaim_connections_get_all() " - "but no blist!\n"); - } -} - -void gaim_gtk_blist_docklet_add() -{ - docklet_count++; -} - -void gaim_gtk_blist_docklet_remove() -{ - docklet_count--; - if (!docklet_count) { - gaim_blist_set_visible(TRUE); - } -} - static GaimBlistUiOps blist_ui_ops = { gaim_gtk_blist_new_list,
--- a/src/gtkblist.h Sat Oct 22 01:03:18 2005 +0000 +++ b/src/gtkblist.h Sat Oct 22 01:18:08 2005 +0000 @@ -167,14 +167,6 @@ */ void gaim_gtk_blist_update_toolbar(); -/** - * Useful for the docklet plugin and also for the win32 tray icon - * This is called when one of those is clicked--it will show/hide the - * buddy list/login window--depending on which is active - */ -void gaim_gtk_blist_docklet_toggle(); -void gaim_gtk_blist_docklet_add(); -void gaim_gtk_blist_docklet_remove(); void gaim_gtk_blist_update_columns(); void gaim_gtk_blist_update_refresh_timeout();
--- a/src/gtkdialogs.h Sat Oct 22 01:03:18 2005 +0000 +++ b/src/gtkdialogs.h Sat Oct 22 01:18:08 2005 +0000 @@ -67,9 +67,6 @@ GaimMessageFlags flags; }; -/* Globals in gtkmain.c */ -extern int docklet_count; - /* Functions in session.c */ extern void session_init(gchar *, gchar *, gchar *); extern void session_end();
--- a/src/gtkprefs.c Sat Oct 22 01:03:18 2005 +0000 +++ b/src/gtkprefs.c Sat Oct 22 01:18:08 2005 +0000 @@ -2246,10 +2246,6 @@ gaim_prefs_add_none("/gaim/gtk"); gaim_prefs_add_none("/plugins/gtk"); - /* XXX Move this! HACK! :( Aww... */ - gaim_prefs_add_none("/plugins/gtk/docklet"); - gaim_prefs_add_bool("/plugins/gtk/docklet/queue_messages", FALSE); - /* Away Queueing */ gaim_prefs_add_none("/gaim/gtk/away"); gaim_prefs_add_bool("/gaim/gtk/away/queue_messages", FALSE);
--- a/src/server.c Sat Oct 22 01:03:18 2005 +0000 +++ b/src/server.c Sat Oct 22 01:18:08 2005 +0000 @@ -35,9 +35,7 @@ #include "util.h" /* XXX UI Stuff */ -#include "gtkdialogs.h" #include "gaim.h" -#include "gtkimhtml.h" #include "gtkutils.h" #define SECS_BEFORE_RESENDING_AUTORESPONSE 600 @@ -748,37 +746,10 @@ * then display it. Easy. */ - /* XXX UGLY HACK OF THE YEAR - * Robot101 will fix this after his exams. honest. - * I guess he didn't specify WHICH exams, exactly... - */ -/* XXX CORE/UI */ -#if 0 - if (docklet_count && - gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages") && - !gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account)) { - /* - * We're gonna queue it up and wait for the user to ask for - * it... probably by clicking the docklet or windows tray icon. - */ - struct queued_message *qm; - qm = g_new0(struct queued_message, 1); - g_snprintf(qm->name, sizeof(qm->name), "%s", name); - qm->message = g_strdup(message); - qm->account = gc->account; - qm->tm = mtime; - qm->flags = msgflags; - unread_message_queue = g_slist_append(unread_message_queue, qm); - } - else { -#endif - if (cnv == NULL) - cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, name); + if (cnv == NULL) + cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, name); - gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); -#if 0 - } -#endif + gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); } g_free(name); @@ -788,7 +759,7 @@ void serv_got_typing(GaimConnection *gc, const char *name, int timeout, GaimTypingState state) { GaimConversation *conv; - GaimConvIm *im; + GaimConvIm *im = NULL; conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account); if (conv != NULL) {
--- a/src/win32/MinimizeToTray.c Sat Oct 22 01:03:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* MinimizeToTray - * - * A couple of routines to show how to make it produce a custom caption - * animation to make it look like we are minimizing to and maximizing - * from the system tray - * - * These routines are public domain, but it would be nice if you dropped - * me a line if you use them! - * - * 1.0 29.06.2000 Initial version - * 1.1 01.07.2000 The window retains it's place in the Z-order of windows - * when minimized/hidden. This means that when restored/shown, it doesn't - * always appear as the foreground window unless we call SetForegroundWindow - * - * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> - */ -#include "stdafx.h" - -#ifndef IDANI_OPEN -#define IDANI_OPEN 1 -#endif -#ifndef IDANI_CLOSE -#define IDANI_CLOSE 2 -#endif -#ifndef IDANI_CAPTION -#define IDANI_CAPTION 3 -#endif - -#define DEFAULT_RECT_WIDTH 150 -#define DEFAULT_RECT_HEIGHT 30 - -static void GetTrayWndRect(LPRECT lpTrayRect) -{ - APPBARDATA appBarData; - HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); - - if(hShellTrayWnd) - { - HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL); - if(hTrayNotifyWnd) - { - GetWindowRect(hTrayNotifyWnd,lpTrayRect); - return; - } - } - - appBarData.cbSize=sizeof(appBarData); - if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) - { - switch(appBarData.uEdge) - { - case ABE_LEFT: - case ABE_RIGHT: - lpTrayRect->top=appBarData.rc.bottom-100; - lpTrayRect->bottom=appBarData.rc.bottom-16; - lpTrayRect->left=appBarData.rc.left; - lpTrayRect->right=appBarData.rc.right; - break; - - case ABE_TOP: - case ABE_BOTTOM: - lpTrayRect->top=appBarData.rc.top; - lpTrayRect->bottom=appBarData.rc.bottom; - lpTrayRect->left=appBarData.rc.right-100; - lpTrayRect->right=appBarData.rc.right-16; - break; - } - - return; - } - - hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); - if(hShellTrayWnd) - { - GetWindowRect(hShellTrayWnd,lpTrayRect); - if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH) - lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; - if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT) - lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; - - return; - } - - SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0); - lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; - lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; -} - -static int GetDoAnimateMinimize(void) -{ - ANIMATIONINFO ai; - - ai.cbSize=sizeof(ai); - SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); - - return ai.iMinAnimate?TRUE:FALSE; -} - -void MinimizeWndToTray(HWND hWnd) -{ - if(!IsWindowVisible(hWnd)) - return; - if(GetDoAnimateMinimize()) - { - RECT rcFrom,rcTo; - - GetWindowRect(hWnd,&rcFrom); - GetTrayWndRect(&rcTo); - - DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); - } - - ShowWindow(hWnd,SW_HIDE); -} - -void RestoreWndFromTray(HWND hWnd) -{ - if(IsWindowVisible(hWnd)) - return; - if(GetDoAnimateMinimize()) - { - RECT rcFrom,rcTo; - GetTrayWndRect(&rcFrom); - GetWindowRect(hWnd,&rcTo); - - DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); - } - - ShowWindow(hWnd,SW_SHOW); - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); -} - - -
--- a/src/win32/MinimizeToTray.h Sat Oct 22 01:03:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef _MINIMIZE_TO_TRAY_H_ -#define _MINIMIZE_TO_TRAY_H_ - -void MinimizeWndToTray(HWND hWnd); -void RestoreWndFromTray(HWND hWnd); - -#endif /* _MINIMIZE_TO_TRAY_H_ */
--- a/src/win32/global.mak Sat Oct 22 01:03:18 2005 +0000 +++ b/src/win32/global.mak Sat Oct 22 01:18:08 2005 +0000 @@ -10,7 +10,7 @@ # Use -g flag when building debug version of Gaim (including plugins). # Use -fnative-struct instead of -mms-bitfields when using mingw 1.1 # (gcc 2.95) -CFLAGS += -O2 -Wall -mno-cygwin -mms-bitfields +CFLAGS += -O2 -Wall -Wdeclaration-after-statement -pipe -mno-cygwin -mms-bitfields -g # If not specified, dlls are built with the default base address of 0x10000000. # When loaded into a process address space a dll will be rebased if its base
--- a/src/win32/win32dep.c Sat Oct 22 01:03:18 2005 +0000 +++ b/src/win32/win32dep.c Sat Oct 22 01:18:08 2005 +0000 @@ -28,10 +28,8 @@ #include <stdio.h> #include <winuser.h> -#include <gtk/gtk.h> #include <glib.h> #include <glib/gstdio.h> -#include <gdk/gdkwin32.h> #include "gaim.h" #include "debug.h" @@ -39,7 +37,6 @@ #include "stdafx.h" #include "resource.h" -#include "MinimizeToTray.h" #include "idletrack.h" #include "zlib.h" #include "untar.h" @@ -366,15 +363,6 @@ } } -/* Moved over from old systray.c */ -void wgaim_systray_minimize( GtkWidget *window ) { - MinimizeWndToTray(GDK_WINDOW_HWND(window->window)); -} - -void wgaim_systray_maximize( GtkWidget *window ) { - RestoreWndFromTray(GDK_WINDOW_HWND(window->window)); -} - void wgaim_notify_uri(const char *uri) { SHELLEXECUTEINFO sinfo;
--- a/src/win32/win32dep.h Sat Oct 22 01:03:18 2005 +0000 +++ b/src/win32/win32dep.h Sat Oct 22 01:18:08 2005 +0000 @@ -25,8 +25,6 @@ #include <shlobj.h> #include <winsock2.h> #include <process.h> -#include <gtk/gtk.h> -#include <gdk/gdkevents.h> #include "wgaimerror.h" #include "libc_interface.h" @@ -51,9 +49,6 @@ /* Utility */ extern int wgaim_gz_decompress(const char* in, const char* out); extern int wgaim_gz_untar(const char* filename, const char* destdir); -/* Docklet */ -extern void wgaim_systray_minimize( GtkWidget* ); -extern void wgaim_systray_maximize( GtkWidget* ); /* Misc */ extern void wgaim_notify_uri(const char *uri); /* init / cleanup */