Mercurial > pidgin.yaz
changeset 14700:7fb8a8583c73
[gaim-migrate @ 17452]
Depluginize the wingaim conv. flashing.
IM window flashing is now always on, chat window flashing is a pref in the wingaim options plugin.
Fix some callbacks where 'int' was used instead of 'GaimMessageFlags'
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 09 Oct 2006 03:02:32 +0000 |
parents | cd1ddfa8868c |
children | f063e0bc1f20 |
files | gtk/gtkconv.c gtk/gtkmain.c gtk/gtksound.c gtk/plugins/win32/winprefs/winprefs.c gtk/win32/gtkwin32dep.c gtk/win32/gtkwin32dep.h libgaim/plugins/signals-test.c |
diffstat | 7 files changed, 134 insertions(+), 172 deletions(-) [+] |
line wrap: on
line diff
--- a/gtk/gtkconv.c Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/gtkconv.c Mon Oct 09 03:02:32 2006 +0000 @@ -215,7 +215,7 @@ if (gtkconv->auto_resize) { return FALSE; } - + /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see * if there is only one conversation in the window. This way we'll be setting new windows to the @@ -2263,7 +2263,7 @@ } } -/* This gets added as an idle handler when doing something that +/* This gets added as an idle handler when doing something that * redraws the icon. It sets the auto_resize gboolean to TRUE. * This way, when the size_allocate callback gets triggered, it notices * that this is an autoresize, and after the main loop iterates, it @@ -2296,7 +2296,7 @@ gtkconv->auto_resize = TRUE; g_idle_add(reset_auto_resize_cb, gtkconv); - + gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); @@ -3329,7 +3329,7 @@ gboolean is_buddy; gchar *alias_key, *name, *alias; int flags; - + alias = cb->alias; name = cb->name; flags = GPOINTER_TO_INT(cb->flags); @@ -3357,10 +3357,10 @@ { GdkColor send_color; gdk_color_parse(SEND_COLOR, &send_color); - -#if GTK_CHECK_VERSION(2,6,0) + +#if GTK_CHECK_VERSION(2,6,0) gtk_list_store_insert_with_values(ls, &iter, -/* +/* * The GTK docs are mute about the effects of the "row" value for performance. * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. * It *might* be faster to search the gtk_list_store and set row accurately, @@ -3985,7 +3985,7 @@ gtk_widget_show(sw); ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_INT); gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, sort_chat_users, NULL, NULL); @@ -3998,7 +3998,7 @@ "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); - gtk_widget_set_size_request(lbox, + gtk_widget_set_size_request(lbox, gaim_prefs_get_int("/gaim/gtk/conversations/chat/userlist_width"), -1); g_signal_connect(G_OBJECT(list), "button_press_event", @@ -4006,8 +4006,8 @@ g_signal_connect(G_OBJECT(list), "popup-menu", G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); g_signal_connect(G_OBJECT(list), "size-allocate", G_CALLBACK(size_allocate_cb), gtkconv); - - + + rend = gtk_cell_renderer_text_new(); g_object_set(rend, @@ -4478,7 +4478,7 @@ static void received_im_msg_cb(GaimAccount *account, char *sender, char *message, - GaimConversation *conv, int flags) + GaimConversation *conv, GaimMessageFlags flags) { GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); if (conv != NULL) @@ -5029,7 +5029,7 @@ #if GTK_CHECK_VERSION(2,6,0) gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, - GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); + GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); #endif l = cbuddies; @@ -5038,7 +5038,7 @@ l = l->next; } - /* Currently GTK+ maintains our sorted list after it's in the tree. + /* Currently GTK+ maintains our sorted list after it's in the tree. * This may change if it turns out we can manage it faster ourselves. */ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, @@ -5321,10 +5321,10 @@ g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); gtk_imhtml_associate_smiley(imhtml, sml, smiley); - + return TRUE; } - + static gboolean gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote) { @@ -5335,26 +5335,26 @@ if (!conv || !smile || !*smile) { return FALSE; } - + /* If smileys are off, return false */ if (gaim_gtkthemes_smileys_disabled()) return FALSE; - + /* If possible add this smiley to the current theme. * The addition is only temporary: custom smilies aren't saved to disk. */ conv_sml = gaim_account_get_protocol_name(conv->account); gtkconv = GAIM_GTK_CONVERSATION(conv); - + for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { if (!strcmp(list->sml, conv_sml)) { sml = list->sml; break; } } - + if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile)) return FALSE; - + if (!remote) /* If it's a local custom smiley, then add it for the entry */ if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile)) return FALSE; @@ -6229,7 +6229,7 @@ } static void -account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, +account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus) { GList *l; @@ -6404,7 +6404,7 @@ if (conv) gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); } - + static void update_buddy_icon(GaimBuddy *buddy) { @@ -6660,7 +6660,7 @@ gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, G_CALLBACK(account_signed_off_cb), GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); - + gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", handle, G_CALLBACK(received_im_msg_cb), NULL);
--- a/gtk/gtkmain.c Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/gtkmain.c Mon Oct 09 03:02:32 2006 +0000 @@ -793,6 +793,11 @@ #ifdef HAVE_STARTUP_NOTIFICATION startup_notification_complete(); #endif + +#ifdef _WIN32 + gtkwgaim_post_init(); +#endif + gtk_main(); #ifdef HAVE_SIGNAL_H
--- a/gtk/gtksound.c Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/gtksound.c Mon Oct 09 03:02:32 2006 +0000 @@ -144,7 +144,7 @@ static void im_msg_received_cb(GaimAccount *account, char *sender, char *message, GaimConversation *conv, - int flags, GaimSoundEventID event) + GaimMessageFlags flags, GaimSoundEventID event) { if (flags & GAIM_MESSAGE_DELAYED) return;
--- a/gtk/plugins/win32/winprefs/winprefs.c Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/plugins/win32/winprefs/winprefs.c Mon Oct 09 03:02:32 2006 +0000 @@ -55,7 +55,6 @@ static const char *PREF_DBLIST_HEIGHT = "/plugins/gtk/win32/winprefs/dblist_height"; static const char *PREF_DBLIST_SIDE = "/plugins/gtk/win32/winprefs/dblist_side"; static const char *PREF_BLIST_ON_TOP = "/plugins/gtk/win32/winprefs/blist_on_top"; -static const char *PREF_IM_BLINK = "/plugins/gtk/win32/winprefs/im_blink"; static const char *PREF_CHAT_BLINK = "/plugins/gtk/win32/winprefs/chat_blink"; /* Deprecated */ @@ -66,25 +65,12 @@ static GtkWidget *blist = NULL; static guint blist_visible_cb_id = 0; -/* flash info */ - -struct _WGAIM_FLASH_INFO { - guint t_handle; - guint sig_handler; -}; - enum { BLIST_TOP_NEVER = 0, BLIST_TOP_ALWAYS, BLIST_TOP_DOCKED, }; -typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; - -typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); - -static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; - /* * CODE */ @@ -247,128 +233,22 @@ blist_set_ontop(FALSE); } -static void load_winver_specific_procs(void) { - /* Used for Win98+ and WinNT5+ */ - MyFlashWindowEx = (LPFNFLASHWINDOWEX) wgaim_find_and_loadproc("user32.dll", "FlashWindowEx"); -} - -/* Window flasher */ -static gboolean flash_window_cb(gpointer data) { - FlashWindow((HWND) data, TRUE); - return TRUE; -} - -static int -halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data) +static gboolean +gtkwgaim_conv_chat_blink(GaimAccount *account, const char *who, char **message, + GaimConversation *conv, GaimMessageFlags flags, void *data) { - if(MyFlashWindowEx) { - HWND hWnd = data; - FLASHWINFO info; - - if(!IsWindow(hWnd)) - return 0; - - memset(&info, 0, sizeof(FLASHWINFO)); - info.cbSize = sizeof(FLASHWINFO); - info.hwnd = hWnd; - info.dwFlags = FLASHW_STOP; - info.dwTimeout = 0; - MyFlashWindowEx(&info); - - } else { - WGAIM_FLASH_INFO *finfo = data; - /* Stop flashing and remove filter */ - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n"); - gaim_timeout_remove(finfo->t_handle); - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n"); - g_signal_handler_disconnect(G_OBJECT(widget), - finfo->sig_handler); - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n"); - g_free(finfo); - } - return 0; -} - -/* FlashWindowEx is only supported by Win98+ and WinNT5+. If it's - not supported we do it our own way */ -static gboolean -wgaim_conv_blink(GaimConversation *conv, int flags) -{ - GaimGtkWindow *win; - GtkWidget *window; - - /* Don't flash for our own messages or system messages */ - if(flags & GAIM_MESSAGE_SEND || flags & GAIM_MESSAGE_SYSTEM) - return FALSE; - - if(conv == NULL) { - gaim_debug_info("winprefs", "gar!\n"); - return FALSE; - } - win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); - if(win == NULL) { - gaim_debug_info("winprefs", "gar2!\n"); - return FALSE; - } - window = win->window; - - if(MyFlashWindowEx) { - FLASHWINFO info; - if(GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) - return FALSE; - - memset(&info, 0, sizeof(FLASHWINFO)); - info.cbSize = sizeof(FLASHWINFO); - info.hwnd = GDK_WINDOW_HWND(window->window); - info.dwFlags = FLASHW_ALL | FLASHW_TIMER; - info.dwTimeout = 0; - MyFlashWindowEx(&info); - /* Stop flashing when window receives focus */ - g_signal_connect(G_OBJECT(window), "focus-in-event", - G_CALLBACK(halt_flash_filter), info.hwnd); - } else { - WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); - - /* Start Flashing window */ - finfo->t_handle = gaim_timeout_add(1000, flash_window_cb, - GDK_WINDOW_HWND(window->window)); - finfo->sig_handler = g_signal_connect(G_OBJECT(window), - "focus-in-event", G_CALLBACK(halt_flash_filter), finfo); - } + if(!gaim_prefs_get_bool(PREF_CHAT_BLINK)) + gtkwgaim_conv_blink(conv, flags); return FALSE; } -static gboolean -wgaim_conv_im_blink(GaimAccount *account, const char *who, char **message, - GaimConversation *conv, int flags, void *data) -{ - if(!gaim_prefs_get_bool(PREF_IM_BLINK)) - return FALSE; - - return wgaim_conv_blink(conv, flags); - -} - -static gboolean -wgaim_conv_chat_blink(GaimAccount *account, const char *who, char **message, - GaimConversation *conv, int flags, void *data) -{ - if(!gaim_prefs_get_bool(PREF_CHAT_BLINK)) - return FALSE; - - return wgaim_conv_blink(conv, flags); -} - /* * EXPORTED FUNCTIONS */ static gboolean plugin_load(GaimPlugin *plugin) { - /* Find out how to go blinky */ - load_winver_specific_procs(); - handle = plugin; /* blist docking init */ @@ -383,11 +263,7 @@ plugin, GAIM_CALLBACK(blist_create_cb), NULL); gaim_signal_connect(gaim_gtk_conversations_get_handle(), - "displaying-im-msg", plugin, GAIM_CALLBACK(wgaim_conv_im_blink), - NULL); - - gaim_signal_connect(gaim_gtk_conversations_get_handle(), - "displaying-chat-msg", plugin, GAIM_CALLBACK(wgaim_conv_chat_blink), + "displaying-chat-msg", plugin, GAIM_CALLBACK(gtkwgaim_conv_chat_blink), NULL); gaim_signal_connect((void*)gaim_get_core(), "quitting", plugin, @@ -463,8 +339,6 @@ /* Conversations */ vbox = gaim_gtk_make_frame(ret, _("Conversations")); - gaim_gtk_prefs_checkbox(_("_Flash window when IMs are received"), - PREF_IM_BLINK, vbox); gaim_gtk_prefs_checkbox(_("_Flash window when chat messages are received"), PREF_CHAT_BLINK, vbox); @@ -492,7 +366,7 @@ N_("WinGaim Options"), VERSION, N_("Options specific to Windows Gaim."), - N_("Provides options specific to Windows Gaim, such as buddy list docking and conversation flashing."), + N_("Provides options specific to Windows Gaim, such as buddy list docking."), "Herman Bloggs <hermanator12002@yahoo.com>", GAIM_WEBSITE, plugin_load, @@ -514,7 +388,6 @@ gaim_prefs_add_bool(PREF_DBLIST_DOCKED, FALSE); gaim_prefs_add_int(PREF_DBLIST_HEIGHT, 0); gaim_prefs_add_int(PREF_DBLIST_SIDE, 0); - gaim_prefs_add_bool(PREF_IM_BLINK, TRUE); gaim_prefs_add_bool(PREF_CHAT_BLINK, FALSE); /* Convert old preferences */
--- a/gtk/win32/gtkwin32dep.c Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/win32/gtkwin32dep.c Mon Oct 09 03:02:32 2006 +0000 @@ -49,9 +49,8 @@ #include <libintl.h> #include "gtkwin32dep.h" - #include "win32dep.h" - +#include "gtkconv.h" #include "wspell.h" /* @@ -60,6 +59,11 @@ HINSTANCE gaimexe_hInstance = 0; HINSTANCE gtkgaimdll_hInstance = 0; HWND messagewin_hwnd; +static int gtkwin32_handle; + +typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); +static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; + /* * PUBLIC CODE @@ -221,15 +225,82 @@ return win_hwnd; } +static int +halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data) { + if(MyFlashWindowEx) { + HWND hWnd = data; + FLASHWINFO info; + + if(!IsWindow(hWnd)) + return 0; + + memset(&info, 0, sizeof(FLASHWINFO)); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = hWnd; + info.dwFlags = FLASHW_STOP; + info.dwTimeout = 0; + MyFlashWindowEx(&info); + } + return 0; +} + +void +gtkwgaim_conv_blink(GaimConversation *conv, GaimMessageFlags flags) { + GaimGtkWindow *win; + GtkWidget *window; + + /* Don't flash for our own messages or system messages */ + if(flags & GAIM_MESSAGE_SEND || flags & GAIM_MESSAGE_SYSTEM) + return; + + if(conv == NULL) { + gaim_debug_info("gtkwgaim", "No conversation found to blink.\n"); + return; + } + + win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); + if(win == NULL) { + gaim_debug_info("gtkwgaim", "No conversation windows found to blink.\n"); + return; + } + + window = win->window; + + if(MyFlashWindowEx) { + FLASHWINFO info; + /* Don't flash if we have the window focused */ + if(GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) + return; + + memset(&info, 0, sizeof(FLASHWINFO)); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = GDK_WINDOW_HWND(window->window); + info.dwFlags = FLASHW_ALL | FLASHW_TIMER; + info.dwTimeout = 0; + MyFlashWindowEx(&info); + /* Stop flashing when window receives focus */ + g_signal_connect(G_OBJECT(window), "focus-in-event", + G_CALLBACK(halt_flash_filter), info.hwnd); + } +} + +static gboolean +gtkwgaim_conv_im_blink(GaimAccount *account, const char *who, char **message, + GaimConversation *conv, GaimMessageFlags flags, void *data) +{ + gtkwgaim_conv_blink(conv, flags); + return FALSE; +} void gtkwgaim_init(HINSTANCE hint) { + gaim_debug_info("gtkwgaim", "gtkwgaim_init start\n"); gaimexe_hInstance = hint; /* IdleTracker Initialization */ if(!wgaim_set_idlehooks()) - gaim_debug_error("gtkwgaim", "Failed to initialize idle tracker\n"); + gaim_debug_error("gtkwgaim", "Failed to initialize idle tracker\n"); wgaim_gtkspell_init(); gaim_debug_info("gtkwgaim", "GTK+ :%u.%u.%u\n", @@ -237,9 +308,19 @@ messagewin_hwnd = wgaim_message_window_init(); + MyFlashWindowEx = (LPFNFLASHWINDOWEX) wgaim_find_and_loadproc("user32.dll", "FlashWindowEx"); + gaim_debug_info("gtkwgaim", "gtkwgaim_init end\n"); } +void gtkwgaim_post_init(void) { + + gaim_signal_connect(gaim_gtk_conversations_get_handle(), + "displaying-im-msg", >kwin32_handle, GAIM_CALLBACK(gtkwgaim_conv_im_blink), + NULL); + +} + /* Windows Cleanup */ void gtkwgaim_cleanup(void) {
--- a/gtk/win32/gtkwin32dep.h Sun Oct 08 19:17:32 2006 +0000 +++ b/gtk/win32/gtkwin32dep.h Mon Oct 09 03:02:32 2006 +0000 @@ -24,20 +24,23 @@ #define _GTKWIN32DEP_H_ #include <windows.h> #include <gtk/gtk.h> +#include "conversation.h" HINSTANCE gtkwgaim_hinstance(void); /* Utility */ -int gtkwgaim_gz_decompress(const char* in, const char* out); -int gtkwgaim_gz_untar(const char* filename, const char* destdir); -void gtkwgaim_ensure_onscreen(GtkWidget *win); +int gtkwgaim_gz_decompress(const char* in, const char* out); +int gtkwgaim_gz_untar(const char* filename, const char* destdir); /* Misc */ -void gtkwgaim_notify_uri(const char *uri); +void gtkwgaim_notify_uri(const char *uri); +void gtkwgaim_ensure_onscreen(GtkWidget *win); +void gtkwgaim_conv_blink(GaimConversation *conv, GaimMessageFlags flags); /* init / cleanup */ -void gtkwgaim_init(HINSTANCE); -void gtkwgaim_cleanup(void); +void gtkwgaim_init(HINSTANCE); +void gtkwgaim_post_init(void); +void gtkwgaim_cleanup(void); #endif /* _WIN32DEP_H_ */
--- a/libgaim/plugins/signals-test.c Sun Oct 08 19:17:32 2006 +0000 +++ b/libgaim/plugins/signals-test.c Mon Oct 09 03:02:32 2006 +0000 @@ -243,7 +243,7 @@ static gboolean receiving_im_msg_cb(GaimAccount *account, char **sender, char **buffer, - GaimConversation *conv, int *flags, void *data) + GaimConversation *conv, GaimMessageFlags *flags, void *data) { gaim_debug_misc("signals test", "receiving-im-msg (%s, %s, %s, %s, %d)\n", gaim_account_get_username(account), *sender, *buffer, @@ -254,7 +254,7 @@ static void received_im_msg_cb(GaimAccount *account, char *sender, char *buffer, - GaimConversation *conv, int flags, void *data) + GaimConversation *conv, GaimMessageFlags flags, void *data) { gaim_debug_misc("signals test", "received-im-msg (%s, %s, %s, %s, %d)\n", gaim_account_get_username(account), sender, buffer, @@ -297,7 +297,7 @@ static gboolean receiving_chat_msg_cb(GaimAccount *account, char **sender, char **buffer, - GaimConversation *chat, int *flags, void *data) + GaimConversation *chat, GaimMessageFlags *flags, void *data) { gaim_debug_misc("signals test", "receiving-chat-msg (%s, %s, %s, %s, %d)\n", @@ -309,7 +309,7 @@ static void received_chat_msg_cb(GaimAccount *account, char *sender, char *buffer, - GaimConversation *chat, int flags, void *data) + GaimConversation *chat, GaimMessageFlags flags, void *data) { gaim_debug_misc("signals test", "received-chat-msg (%s, %s, %s, %s, %d)\n",