Mercurial > pidgin.yaz
changeset 29811:8d2a8d07cf85
merge of '8958bbc5a8fc6f85d0906e37b0754808791b4007'
and 'adb61741bcb6be653032843d5cd82714f4729d02'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 20 Feb 2010 07:05:51 +0000 |
parents | 693e54b7d62b (current diff) c3cd8f9fe4b1 (diff) |
children | 551253814063 |
files | pidgin/gtkdocklet-x11.c |
diffstat | 8 files changed, 37 insertions(+), 448 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/plugins/log_reader.c Sat Feb 20 06:45:38 2010 +0000 +++ b/libpurple/plugins/log_reader.c Sat Feb 20 07:05:51 2010 +0000 @@ -2644,7 +2644,7 @@ g_free(contents); } g_free(path); -#endif /* !GTK_CHECK_VERSION(2,6,0) */ +#endif /* !GLIB_CHECK_VERSION(2,6,0) */ } /* path */ if (!found) {
--- a/pidgin/Makefile.am Sat Feb 20 06:45:38 2010 +0000 +++ b/pidgin/Makefile.am Sat Feb 20 07:05:51 2010 +0000 @@ -89,7 +89,6 @@ gtkdnd-hints.c \ gtkdocklet.c \ gtkdocklet-gtk.c \ - gtkdocklet-x11.c \ gtkeventloop.c \ gtkft.c \ gtkicon-theme.c \
--- a/pidgin/gtkdocklet-gtk.c Sat Feb 20 06:45:38 2010 +0000 +++ b/pidgin/gtkdocklet-gtk.c Sat Feb 20 07:05:51 2010 +0000 @@ -26,8 +26,6 @@ #include "pidginstock.h" #include "gtkdocklet.h" -#if GTK_CHECK_VERSION(2,10,0) - /* globals */ GtkStatusIcon *docklet = NULL; @@ -155,6 +153,3 @@ gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), DATADIR G_DIR_SEPARATOR_S "pixmaps" G_DIR_SEPARATOR_S "pidgin" G_DIR_SEPARATOR_S "tray"); } - -#endif /* GTK_CHECK_VERSION(2,10,0) */ -
--- a/pidgin/gtkdocklet-x11.c Sat Feb 20 06:45:38 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,359 +0,0 @@ -/* - * System tray icon (aka docklet) plugin for Purple - * - * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> - * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> - * Inspired by a similar plugin by: - * John (J5) Palmieri <johnp@martianrock.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02111-1301, USA. - */ - -#include "internal.h" -#include "pidgin.h" -#include "debug.h" -#include "prefs.h" -#include "pidginstock.h" - -#include "gtkdialogs.h" - -#include "eggtrayicon.h" -#include "gtkdocklet.h" -#include <gdk/gdkkeysyms.h> - -#if !GTK_CHECK_VERSION(2,10,0) - -#define SHORT_EMBED_TIMEOUT 5000 -#define LONG_EMBED_TIMEOUT 15000 - -/* globals */ -static EggTrayIcon *docklet = NULL; -static GtkWidget *image = NULL; -static GtkTooltips *tooltips = NULL; -static GdkPixbuf *blank_icon = NULL; -static int embed_timeout = 0; -static int docklet_height = 0; - -/* protos */ -static void docklet_x11_create(gboolean); - -static gboolean -docklet_x11_recreate_cb(gpointer data) -{ - docklet_x11_create(TRUE); - - return FALSE; /* for when we're called by the glib idle handler */ -} - -static void -docklet_x11_embedded_cb(GtkWidget *widget, void *data) -{ - purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 embedded\n"); - - g_source_remove(embed_timeout); - embed_timeout = 0; - pidgin_docklet_embedded(); - purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE); -} - -static void -docklet_x11_destroyed_cb(GtkWidget *widget, void *data) -{ - purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 destroyed\n"); - - pidgin_docklet_remove(); - - g_object_unref(G_OBJECT(docklet)); - docklet = NULL; - - g_idle_add(docklet_x11_recreate_cb, NULL); -} - -static gboolean -docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data) -{ - if (event->type != GDK_BUTTON_PRESS) - return FALSE; - - pidgin_docklet_clicked(event->button); - return TRUE; -} - -static gboolean -docklet_x11_pressed_cb(GtkWidget *button, GdkEventKey *event) -{ - guint state, keyval; - - state = event->state & gtk_accelerator_get_default_mod_mask(); - keyval = event->keyval; - if (state == 0 && - (keyval == GDK_Return || - keyval == GDK_KP_Enter || - keyval == GDK_ISO_Enter || - keyval == GDK_space || - keyval == GDK_KP_Space)) - { - pidgin_docklet_clicked(1); - return TRUE; - } - - return FALSE; -} - -static void -docklet_x11_popup_cb(GtkWidget *button) -{ - pidgin_docklet_clicked(3); -} - -static void -docklet_x11_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending) -{ - const gchar *icon_name = NULL; - - g_return_if_fail(image != NULL); - - switch (status) { - case PURPLE_STATUS_OFFLINE: - icon_name = PIDGIN_STOCK_TRAY_OFFLINE; - break; - case PURPLE_STATUS_AWAY: - icon_name = PIDGIN_STOCK_TRAY_AWAY; - break; - case PURPLE_STATUS_UNAVAILABLE: - icon_name = PIDGIN_STOCK_TRAY_BUSY; - break; - case PURPLE_STATUS_EXTENDED_AWAY: - icon_name = PIDGIN_STOCK_TRAY_XA; - break; - case PURPLE_STATUS_INVISIBLE: - icon_name = PIDGIN_STOCK_TRAY_INVISIBLE; - break; - default: - icon_name = PIDGIN_STOCK_TRAY_AVAILABLE; - break; - } - - if (pending) - icon_name = PIDGIN_STOCK_TRAY_PENDING; - if (connecting) - icon_name = PIDGIN_STOCK_TRAY_CONNECT; - - if(icon_name) { - int icon_size; - if (docklet_height < 22) - icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); - else if (docklet_height < 32) - icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); - else if (docklet_height < 48) - icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM); - else - icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE); - - gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, icon_size); - } -} - -static void -docklet_x11_resize_icon(GtkWidget *widget) -{ - if (docklet_height == MIN(widget->allocation.height, widget->allocation.width)) - return; - docklet_height = MIN(widget->allocation.height, widget->allocation.width); - pidgin_docklet_update_icon(); -} - -static void -docklet_x11_blank_icon(void) -{ - if (!blank_icon) { - GtkIconSize size = GTK_ICON_SIZE_LARGE_TOOLBAR; - gint width, height; - g_object_get(G_OBJECT(image), "icon-size", &size, NULL); - gtk_icon_size_lookup(size, &width, &height); - blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - gdk_pixbuf_fill(blank_icon, 0); - } - - gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon); -} - -static void -docklet_x11_set_tooltip(gchar *tooltip) -{ - if (!tooltips) - tooltips = gtk_tooltips_new(); - - /* image->parent is a GtkEventBox */ - if (tooltip) { - gtk_tooltips_enable(tooltips); - gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL); - } else { - gtk_tooltips_set_tip(tooltips, image->parent, "", NULL); - gtk_tooltips_disable(tooltips); - } -} - -static void -docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in, - gpointer user_data) -{ - GtkWidget *widget = GTK_WIDGET(docklet); - GtkRequisition req; - gint menu_xpos, menu_ypos; - - gtk_widget_size_request(GTK_WIDGET(menu), &req); - gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos); - - menu_xpos += widget->allocation.x; - menu_ypos += widget->allocation.y; - - if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2) - menu_ypos -= req.height; - else - menu_ypos += widget->allocation.height; - - *x = menu_xpos; - *y = menu_ypos; - - *push_in = TRUE; -} - -static void -docklet_x11_destroy(void) -{ - g_return_if_fail(docklet != NULL); - - if (embed_timeout) - g_source_remove(embed_timeout); - - pidgin_docklet_remove(); - - g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL); - gtk_widget_destroy(GTK_WIDGET(docklet)); - - g_object_unref(G_OBJECT(docklet)); - docklet = NULL; - - if (blank_icon) - g_object_unref(G_OBJECT(blank_icon)); - blank_icon = NULL; - - image = NULL; - - purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 destroyed\n"); -} - -static gboolean -docklet_x11_embed_timeout_cb(gpointer data) -{ - /* The docklet was not embedded within the timeout. - * Remove it as a visibility manager, but leave the plugin - * loaded so that it can embed automatically if/when a notification - * area becomes available. - */ - purple_debug_info("docklet", "X11 failed to embed within timeout\n"); - pidgin_docklet_remove(); - - return FALSE; -} - -static void -docklet_x11_create(gboolean recreate) -{ - GtkWidget *box; - - if (docklet) { - /* if this is being called when a tray icon exists, it's because - something messed up. try destroying it before we proceed, - although docklet_refcount may be all hosed. hopefully won't happen. */ - purple_debug(PURPLE_DEBUG_WARNING, "docklet", "trying to create icon but it already exists?\n"); - docklet_x11_destroy(); - } - - docklet = egg_tray_icon_new(PIDGIN_NAME); - box = gtk_event_box_new(); - image = gtk_image_new(); - GTK_WIDGET_SET_FLAGS (image, GTK_CAN_FOCUS); - - g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL); - g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL); - g_signal_connect(G_OBJECT(docklet), "size-allocate", G_CALLBACK(docklet_x11_resize_icon), NULL); - g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_x11_clicked_cb), NULL); - g_signal_connect(G_OBJECT(box), "key-press-event", G_CALLBACK(docklet_x11_pressed_cb), NULL); - g_signal_connect(G_OBJECT(box), "popup-menu", G_CALLBACK(docklet_x11_popup_cb), NULL); - gtk_container_add(GTK_CONTAINER(box), image); - gtk_container_add(GTK_CONTAINER(docklet), box); - - if (!gtk_check_version(2,4,0)) - g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); - - gtk_widget_show_all(GTK_WIDGET(docklet)); - - /* ref the docklet before we bandy it about the place */ - g_object_ref(G_OBJECT(docklet)); - - /* This is a hack to avoid a race condition between the docklet getting - * embedded in the notification area and the gtkblist restoring its - * previous visibility state. If the docklet does not get embedded within - * the timeout, it will be removed as a visibility manager until it does - * get embedded. Ideally, we would only call docklet_embedded() when the - * icon was actually embedded. This only happens when the docklet is first - * created, not when being recreated. - * - * The x11 docklet tracks whether it successfully embedded in a pref and - * allows for a longer timeout period if it successfully embedded the last - * time it was run. This should hopefully solve problems with the buddy - * list not properly starting hidden when Pidgin is started on login. - */ - if(!recreate) { - pidgin_docklet_embedded(); - if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) { - embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); - } else { - embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); - } - } - - purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 created\n"); -} - -static void -docklet_x11_create_ui_op(void) -{ - docklet_x11_create(FALSE); -} - -static struct docklet_ui_ops ui_ops = -{ - docklet_x11_create_ui_op, - docklet_x11_destroy, - docklet_x11_update_icon, - docklet_x11_blank_icon, - docklet_x11_set_tooltip, - docklet_x11_position_menu -}; - -void -docklet_ui_init() -{ - pidgin_docklet_set_ui_ops(&ui_ops); - purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11"); - purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE); -} - -#endif /* !GTK_CHECK_VERSION(2,10,0) */ -
--- a/pidgin/gtkprefs.c Sat Feb 20 06:45:38 2010 +0000 +++ b/pidgin/gtkprefs.c Sat Feb 20 07:05:51 2010 +0000 @@ -902,9 +902,7 @@ cell_rend = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "markup", 1, NULL); -#if GTK_CHECK_VERSION(2,6,0) g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); -#endif gtk_drag_dest_set(combo_box, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te, sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE);
--- a/pidgin/plugins/win32/transparency/win2ktrans.c Sat Feb 20 06:45:38 2010 +0000 +++ b/pidgin/plugins/win32/transparency/win2ktrans.c Sat Feb 20 07:05:51 2010 +0000 @@ -72,8 +72,6 @@ static const char *OPT_WINTRANS_BL_ONTOP = "/plugins/gtk/win32/wintrans/bl_always_on_top"; static GSList *window_list = NULL; -static BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) = NULL; - /* * CODE */ @@ -81,31 +79,31 @@ /* Set window transparency level */ static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, gboolean always_on_top) { - if (MySetLayeredWindowAttributes) { - HWND hWnd = GDK_WINDOW_HWND(window->window); - LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); - if (enabled) { - style |= WS_EX_LAYERED; - } else { - style &= ~WS_EX_LAYERED; - } - SetWindowLong(hWnd, GWL_EXSTYLE, style); + + HWND hWnd = GDK_WINDOW_HWND(window->window); + LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); + if (enabled) { + style |= WS_EX_LAYERED; + } else { + style &= ~WS_EX_LAYERED; + } + SetWindowLong(hWnd, GWL_EXSTYLE, style); - if (enabled) { - SetWindowPos(hWnd, - always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, - 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - MySetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); - } else { - /* Ask the window and its children to repaint */ - SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + if (enabled) { + SetWindowPos(hWnd, + always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, + 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + SetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); + } else { + /* Ask the window and its children to repaint */ + SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - RedrawWindow(hWnd, NULL, NULL, - RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); - } + RedrawWindow(hWnd, NULL, NULL, + RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } + } /* When a conv window is focused, if we're only transparent when unfocused, @@ -491,14 +489,6 @@ * EXPORTED FUNCTIONS */ static gboolean plugin_load(PurplePlugin *plugin) { - MySetLayeredWindowAttributes = (void*) wpurple_find_and_loadproc( - "user32.dll", "SetLayeredWindowAttributes"); - - if (!MySetLayeredWindowAttributes) { - purple_debug_error(WINTRANS_PLUGIN_ID, - "SetLayeredWindowAttributes API not found (Required W2K+)\n"); - return FALSE; - } purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin,
--- a/pidgin/win32/gtkwin32dep.c Sat Feb 20 06:45:38 2010 +0000 +++ b/pidgin/win32/gtkwin32dep.c Sat Feb 20 07:05:51 2010 +0000 @@ -47,8 +47,6 @@ #include "zlib.h" #include "untar.h" -#include <libintl.h> - #include "gtkwin32dep.h" #include "win32dep.h" #include "gtkconv.h" @@ -64,8 +62,6 @@ HWND messagewin_hwnd; static int gtkwin32_handle; -typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); -static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; static gboolean pwm_handles_connections = TRUE; @@ -308,6 +304,7 @@ void winpidgin_window_flash(GtkWindow *window, gboolean flash) { GdkWindow * gdkwin; + FLASHWINFO info; g_return_if_fail(window != NULL); @@ -319,25 +316,19 @@ if(GDK_WINDOW_DESTROYED(gdkwin)) return; - if(MyFlashWindowEx) { - FLASHWINFO info; + memset(&info, 0, sizeof(FLASHWINFO)); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = GDK_WINDOW_HWND(gdkwin); + if (flash) { + DWORD flashCount; + info.uCount = 3; + if (SystemParametersInfo(SPI_GETFOREGROUNDFLASHCOUNT, 0, &flashCount, 0)) + info.uCount = flashCount; + info.dwFlags = FLASHW_ALL | FLASHW_TIMER; + } else + info.dwFlags = FLASHW_STOP; + info.dwTimeout = 0; - memset(&info, 0, sizeof(FLASHWINFO)); - info.cbSize = sizeof(FLASHWINFO); - info.hwnd = GDK_WINDOW_HWND(gdkwin); - if (flash) { - DWORD flashCount; - info.uCount = 3; - if (SystemParametersInfo(SPI_GETFOREGROUNDFLASHCOUNT, 0, &flashCount, 0)) - info.uCount = flashCount; - info.dwFlags = FLASHW_ALL | FLASHW_TIMER; - } else - info.dwFlags = FLASHW_STOP; - info.dwTimeout = 0; - - MyFlashWindowEx(&info); - } else - FlashWindow(GDK_WINDOW_HWND(gdkwin), flash); } void @@ -399,8 +390,6 @@ messagewin_hwnd = winpidgin_message_window_init(); - MyFlashWindowEx = (LPFNFLASHWINDOWEX) wpurple_find_and_loadproc("user32.dll", "FlashWindowEx"); - purple_debug_info("winpidgin", "winpidgin_init end\n"); } @@ -436,36 +425,16 @@ return TRUE; } -typedef HMONITOR WINAPI _MonitorFromWindow(HWND, DWORD); -typedef BOOL WINAPI _GetMonitorInfo(HMONITOR, LPMONITORINFO); - static gboolean get_WorkingAreaRectForWindow(HWND hwnd, RECT *workingAreaRc) { - static _MonitorFromWindow *the_MonitorFromWindow; - static _GetMonitorInfo *the_GetMonitorInfo; - static gboolean initialized = FALSE; HMONITOR monitor; MONITORINFO info; - if(!initialized) { - the_MonitorFromWindow = (_MonitorFromWindow*) - wpurple_find_and_loadproc("user32", "MonitorFromWindow"); - the_GetMonitorInfo = (_GetMonitorInfo*) - wpurple_find_and_loadproc("user32", "GetMonitorInfoA"); - initialized = TRUE; - } - - if(!the_MonitorFromWindow) - return FALSE; - - if(!the_GetMonitorInfo) - return FALSE; - - monitor = the_MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); + monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); info.cbSize = sizeof(info); - if(!the_GetMonitorInfo(monitor, &info)) + if(!GetMonitorInfo(monitor, &info)) return FALSE; CopyRect(workingAreaRc, &(info.rcWork));
--- a/po/POTFILES.in Sat Feb 20 06:45:38 2010 +0000 +++ b/po/POTFILES.in Sat Feb 20 07:05:51 2010 +0000 @@ -213,14 +213,12 @@ pidgin/gtkaccount.c pidgin/gtkblist-theme.c pidgin/gtkblist.c -pidgin/gtkcellview.c pidgin/gtkcertmgr.c pidgin/gtkconn.c pidgin/gtkconv.c pidgin/gtkdebug.c pidgin/gtkdialogs.c pidgin/gtkdocklet.c -pidgin/gtkexpander.c pidgin/gtkft.c pidgin/gtkimhtml.c pidgin/gtkimhtmltoolbar.c @@ -241,7 +239,6 @@ pidgin/gtkutils.c pidgin/gtkwhiteboard.c pidgin/pidgin.h -pidgin/pidgincombobox.c pidgin/pidginstock.c pidgin/pidgintooltip.c pidgin/pixmaps/emotes/default/24/default.theme.in