pidgin/pidgin

Parents ca0198d7ccdd
Children b82c365e04e8
Remove the winprefs plugin as it only interacts with the buddy list window which we will soon be removing

Testing Done:
Built locally, which means I didn't test it on windows, but it's just deleting windows stuff so it should be fine.

Reviewed at https://reviews.imfreedom.org/r/190/
--- a/pidgin/plugins/meson.build Fri Oct 30 16:34:33 2020 -0500
+++ b/pidgin/plugins/meson.build Sun Nov 01 02:42:18 2020 -0600
@@ -6,10 +6,6 @@
subdir('gestures')
subdir('xmppconsole')
-if IS_WIN32
- subdir('win32/winprefs')
-endif
-
if PLUGINS
contact_priority = library('contact_priority', 'contact_priority.c',
dependencies : [libpurple_dep, libpidgin_dep, glib],
--- a/pidgin/plugins/win32/winprefs/gtkappbar.c Fri Oct 30 16:34:33 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,697 +0,0 @@
-/*
- * purple - WinPurple Options Plugin
- *
- * File: gtkappbar.c
- * Date: August 2, 2003
- * Description: Appbar functionality for Windows GTK+ applications
- *
- * Copyright (C) 2003, Herman Bloggs <hermanator12002@yahoo.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
- *
- */
-/*
- * TODO:
- * - Move 'App on top' feature from Trans plugin to here
- * - Bug: Multiple Show/Hide Desktop calls causes client area to disappear
- */
-#include <windows.h>
-#include <winver.h>
-#include <stdio.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkwin32.h>
-#include "gtkappbar.h"
-
-#define APPBAR_CALLBACK WM_USER + 1010
-
-typedef HMONITOR WINAPI purple_MonitorFromPoint(POINT, DWORD);
-typedef HMONITOR WINAPI purple_MonitorFromWindow(HWND, DWORD);
-typedef BOOL WINAPI purple_GetMonitorInfo(HMONITOR, LPMONITORINFO);
-
-static void gtk_appbar_do_dock(GtkAppBar *ab, UINT side);
-
-static inline HWND
-appbar_get_handle(GtkAppBar *ab)
-{
- return GDK_WINDOW_HWND(gtk_widget_get_window(ab->win));
-}
-
-/* Retrieve the rectangular display area from the specified monitor
- * Return TRUE if successful, otherwise FALSE
- */
-static gboolean
-get_rect_from_monitor(HMODULE hmod, HMONITOR monitor, RECT *rect) {
- purple_GetMonitorInfo *the_GetMonitorInfo;
- MONITORINFO info;
-
- if (!(the_GetMonitorInfo = (purple_GetMonitorInfo*)
- GetProcAddress(hmod, "GetMonitorInfoA"))) {
- return FALSE;
- }
-
- info.cbSize = sizeof(info);
- if (!the_GetMonitorInfo(monitor, &info)) {
- return FALSE;
- }
-
- CopyRect(rect, &(info.rcMonitor));
-
- return TRUE;
-}
-
-/**
- * This will only work on Win98+ and Win2K+
- * Return TRUE if successful, otherwise FALSE
- */
-static gboolean
-get_rect_at_point_multimonitor(POINT pt, RECT *rect) {
- HMODULE hmod;
- purple_MonitorFromPoint *the_MonitorFromPoint;
- HMONITOR monitor;
-
- if (!(hmod = GetModuleHandle("user32"))) {
- return FALSE;
- }
-
- if (!(the_MonitorFromPoint = (purple_MonitorFromPoint*)
- GetProcAddress(hmod, "MonitorFromPoint"))) {
- return FALSE;
- }
-
- monitor =
- the_MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
-
- return get_rect_from_monitor(hmod, monitor, rect);
-}
-
-/**
- * This will only work on Win98+ and Win2K+
- * Return TRUE if successful, otherwise FALSE
- */
-static gboolean
-get_rect_of_window_multimonitor(HWND window, RECT *rect) {
- HMODULE hmod;
- purple_MonitorFromWindow *the_MonitorFromWindow;
- HMONITOR monitor;
-
- if (!(hmod = GetModuleHandle("user32"))) {
- return FALSE;
- }
-
- if (!(the_MonitorFromWindow = (purple_MonitorFromWindow*)
- GetProcAddress(hmod, "MonitorFromWindow"))) {
- return FALSE;
- }
-
- monitor =
- the_MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
-
- return get_rect_from_monitor(hmod, monitor, rect);
-}
-
-/*
- * Fallback if cannot get the RECT from the monitor directly
- */
-static void get_default_workarea(RECT *rect) {
- if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, FALSE)) {
- /* I don't think this will ever happen */
- rect->left = 0;
- rect->top = 0;
- rect->bottom = GetSystemMetrics(SM_CYSCREEN);
- rect->right = GetSystemMetrics(SM_CXSCREEN);
- }
-}
-
-/* Retrieve the rectangle of the active work area at a point */
-static void get_rect_at_point(POINT pt, RECT *rc) {
- if (!get_rect_at_point_multimonitor(pt, rc)) {
- get_default_workarea(rc);
- }
-}
-
-/* Retrieve the rectangle of the active work area of a window*/
-static void get_rect_of_window(HWND window, RECT *rc) {
- if (!get_rect_of_window_multimonitor(window, rc)) {
- get_default_workarea(rc);
- }
-}
-
-static void get_window_normal_rc(HWND hwnd, RECT *rc) {
- WINDOWPLACEMENT wplc;
- GetWindowPlacement(hwnd, &wplc);
- CopyRect(rc, &wplc.rcNormalPosition);
-}
-#if 0
-static void print_rect(RECT *rc) {
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "RECT: L:%ld R:%ld T:%ld B:%ld\n",
- rc->left, rc->right, rc->top, rc->bottom);
-}
-#endif
-/** Set the window style to be the "Tool Window" style - small header, no min/max buttons */
-static void set_toolbar(HWND hwnd, gboolean val) {
- LONG style = GetWindowLong(hwnd, GWL_EXSTYLE);
-
- if(val && !(style & WS_EX_TOOLWINDOW))
- style |= WS_EX_TOOLWINDOW;
- else if(!val && style & WS_EX_TOOLWINDOW)
- style &= ~WS_EX_TOOLWINDOW;
- else
- return;
- SetWindowLong(hwnd, GWL_EXSTYLE, style);
- SetWindowPos(hwnd, 0, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-
-/* This really should be the following, but SWP_FRAMECHANGED strangely causes initermittent problems "Show Desktop" done more than once.
- * Not having SWP_FRAMECHANGED *should* cause the Style not to be applied, but i haven't noticed any problems
- * SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
- */
-}
-/** Register the window as an appbar */
-static gboolean gtk_appbar_register(GtkAppBar *ab, HWND hwnd) {
- APPBARDATA abd;
-
- abd.cbSize = sizeof(APPBARDATA);
- abd.hWnd = hwnd;
- abd.uCallbackMessage = APPBAR_CALLBACK;
-
- ab->registered = SHAppBarMessage(ABM_NEW, &abd);
-
- return ab->registered;
-}
-/** Unregister the window as an appbar */
-static gboolean gtk_appbar_unregister(GtkAppBar *ab, HWND hwnd) {
- APPBARDATA abd;
-
- if(!ab->registered)
- return TRUE;
-
- abd.cbSize = sizeof(APPBARDATA);
- abd.hWnd = hwnd;
-
- SHAppBarMessage(ABM_REMOVE, &abd); /** This always returns TRUE */
-
- ab->registered = FALSE;
-
- ab->docked = FALSE;
- ab->undocking = FALSE;
- ab->docking = FALSE;
-
- return TRUE;
-}
-
-static void gtk_appbar_querypos(GtkAppBar *ab, HWND hwnd, RECT rcWorkspace) {
- APPBARDATA abd;
- guint iWidth = 0;
-
- if(!ab->registered)
- gtk_appbar_register(ab, hwnd);
-
- abd.hWnd = hwnd;
- abd.cbSize = sizeof(APPBARDATA);
- abd.uEdge = ab->side;
-
- iWidth = ab->docked_rect.right - ab->docked_rect.left;
-
- abd.rc.top = rcWorkspace.top;
- abd.rc.bottom = rcWorkspace.bottom;
- switch (abd.uEdge)
- {
- case ABE_LEFT:
- abd.rc.left = rcWorkspace.left;
- abd.rc.right = rcWorkspace.left + iWidth;
- break;
-
- case ABE_RIGHT:
- abd.rc.right = rcWorkspace.right;
- abd.rc.left = rcWorkspace.right - iWidth;
- break;
- }
-
- /* Ask the system for the screen space */
- SHAppBarMessage(ABM_QUERYPOS, &abd);
-
- switch (abd.uEdge)
- {
- case ABE_LEFT:
- abd.rc.right = abd.rc.left + iWidth;
- break;
-
- case ABE_RIGHT:
- abd.rc.left = abd.rc.right - iWidth;
- break;
- }
-
- CopyRect(&(ab->docked_rect), &abd.rc);
-}
-/* Actually set the size and screen location of the appbar */
-static void gtk_appbar_setpos(GtkAppBar *ab, HWND hwnd) {
- APPBARDATA abd;
-
- if(!ab->registered)
- gtk_appbar_register(ab, hwnd);
-
- abd.hWnd = hwnd;
- abd.cbSize = sizeof(APPBARDATA);
- CopyRect(&abd.rc, &(ab->docked_rect));
- abd.uEdge = ab->side;
-
- SHAppBarMessage(ABM_SETPOS, &abd);
-}
-/** Let any callbacks know that we have docked or undocked */
-static void gtk_appbar_dispatch_dock_cbs(GtkAppBar *ab, gboolean val) {
- GSList *lst = ab->dock_cbs;
-
- while(lst) {
- GtkAppBarDockCB dock_cb = lst->data;
- dock_cb(val);
- lst = lst->next;
- }
-}
-
-static GdkFilterReturn wnd_moving(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
- POINT cp;
- RECT *rc = (RECT*)msg->lParam;
- RECT monRect;
- int side = -1;
- long dockAreaWidth = 0;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_moving\n");
-
- GetCursorPos(&cp);
- get_rect_at_point(cp, &monRect);
-
- dockAreaWidth = (monRect.right - monRect.left) / 10;
- /* Which part of the screen are we in ? */
- if (cp.x > (monRect.right - dockAreaWidth)) {
- side = ABE_RIGHT;
- } else if (cp.x < (monRect.left + dockAreaWidth)) {
- side = ABE_LEFT;
- }
-
- if(!ab->docked) {
- if( (side == ABE_RIGHT || side == ABE_LEFT) ) {
- if( !ab->docking ) {
- ab->side = side;
- GetWindowRect(msg->hwnd, &(ab->docked_rect));
- gtk_appbar_querypos(ab, msg->hwnd, monRect);
-
- /* save pre-docking height */
- ab->undocked_height = rc->bottom - rc->top;
- ab->docking = TRUE;
- }
- }
- else
- ab->docking = FALSE;
- }
- else if(side < 0) {
- gtk_appbar_unregister(ab, msg->hwnd);
- ab->undocking = TRUE;
- rc->bottom = rc->top + ab->undocked_height;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkFilterReturn wnd_sizing(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_sizing\n");
- if(ab->docked) {
- RECT *rc = (RECT*)msg->lParam;
- if(ab->side == ABE_LEFT && msg->wParam == WMSZ_RIGHT) {
- ab->docked_rect.right = rc->right;
- gtk_appbar_setpos(ab, msg->hwnd);
- }
- else if(ab->side == ABE_RIGHT && msg->wParam == WMSZ_LEFT) {
- ab->docked_rect.left = rc->left;
- gtk_appbar_setpos(ab, msg->hwnd);
- }
- return GDK_FILTER_REMOVE;
- }
- return GDK_FILTER_CONTINUE;
-}
-/** Notify the system that the appbar has been activated */
-static GdkFilterReturn wnd_activate(GtkAppBar *ab, GdkXEvent *xevent) {
- if (ab->registered) {
- APPBARDATA abd;
- MSG *msg = (MSG*)xevent;
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_activate\n");
-
- abd.hWnd = msg->hwnd;
- abd.cbSize = sizeof(APPBARDATA);
-
- SHAppBarMessage(ABM_ACTIVATE, &abd);
- }
- return GDK_FILTER_CONTINUE;
-}
-
-static void show_hide(GtkAppBar *ab, gboolean hide) {
- purple_debug_info("gtkappbar", "show_hide(%d)\n", hide);
-
- if (hide) {
- purple_debug_info("gtkappbar", "hidden\n");
- gtk_appbar_unregister(ab, appbar_get_handle(ab));
- ab->docked = TRUE;
- ab->iconized = TRUE;
- } else {
- ab->iconized = FALSE;
- purple_debug_info("gtkappbar", "shown\n");
- ab->docked = FALSE;
- gtk_appbar_do_dock(ab, ab->side);
- }
-
-}
-
-/** Notify the system that the appbar's position has changed */
-static GdkFilterReturn wnd_poschanged(GtkAppBar *ab, GdkXEvent *xevent) {
- if (ab->registered) {
- APPBARDATA abd;
- MSG *msg = (MSG*)xevent;
-
- purple_debug(PURPLE_DEBUG_MISC, "gtkappbar", "wnd_poschanged\n");
-
- abd.hWnd = msg->hwnd;
- abd.cbSize = sizeof(APPBARDATA);
-
- SHAppBarMessage(ABM_WINDOWPOSCHANGED, &abd);
-
- }
- return GDK_FILTER_CONTINUE;
-}
-/** The window is about to change */
-static GdkFilterReturn wnd_poschanging(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
- WINDOWPOS *wpos = (WINDOWPOS*)msg->lParam;
-
- purple_debug(PURPLE_DEBUG_MISC, "gtkappbar", "wnd_poschanging\n");
-
- if(ab->docked || ab->docking) {
- wpos->x = ab->docked_rect.left;
- wpos->y = ab->docked_rect.top;
- wpos->cx = ab->docked_rect.right - ab->docked_rect.left;
- wpos->cy = ab->docked_rect.bottom - ab->docked_rect.top;
- if(IsIconic(msg->hwnd))
- set_toolbar(msg->hwnd, FALSE);
- /*return GDK_FILTER_REMOVE;*/
- }
-
- if (ab->docked) {
- if (ab->iconized && wpos->flags & SWP_SHOWWINDOW)
- show_hide(ab, FALSE);
- else if (!ab->iconized && wpos->flags & SWP_HIDEWINDOW)
- show_hide(ab, TRUE);
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkFilterReturn wnd_exitsizemove(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_exitsizemove\n");
- if(ab->docking) {
- gtk_appbar_setpos(ab, msg->hwnd);
- ab->docking = FALSE;
- ab->docked = TRUE;
- ShowWindow(msg->hwnd, SW_HIDE);
- set_toolbar(msg->hwnd, TRUE);
- ShowWindow(msg->hwnd, SW_SHOW);
- gtk_appbar_dispatch_dock_cbs(ab, TRUE);
- } else if(ab->undocking) {
- ShowWindow(msg->hwnd, SW_HIDE);
- set_toolbar(msg->hwnd, FALSE);
- ShowWindow(msg->hwnd, SW_SHOW);
- gtk_appbar_dispatch_dock_cbs(ab, FALSE);
- ab->undocking = FALSE;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkFilterReturn wnd_showwindow(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- purple_debug_info("gtkappbar", "wnd_showwindow\n");
- if(msg->wParam && ab->docked) {
- show_hide(ab, FALSE);
- } else if(!msg->wParam && ab->docked) {
- show_hide(ab, TRUE);
- }
- return GDK_FILTER_CONTINUE;
-}
-
-/** The window's size has changed */
-static GdkFilterReturn wnd_size(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_size\n");
-
- if(msg->wParam == SIZE_MINIMIZED) {
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "Minimize\n");
- if(ab->docked) {
- gtk_appbar_unregister(ab, appbar_get_handle(ab));
- ab->docked = TRUE;
- }
- }
- else if(msg->wParam == SIZE_RESTORED) {
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "Restore\n");
- if (!ab->iconized && ab->docked) {
- gtk_appbar_do_dock(ab, ab->side);
- }
- }
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkFilterReturn wnd_nchittest(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- if(ab->docked) {
- UINT ret = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
-
- switch(ret) {
- case HTBOTTOM:
- case HTBOTTOMLEFT:
- case HTBOTTOMRIGHT:
- case HTTOP:
- case HTTOPLEFT:
- case HTTOPRIGHT:
- return GDK_FILTER_REMOVE;
- case HTLEFT:
- if(ab->side == ABE_LEFT)
- return GDK_FILTER_REMOVE;
- break;
- case HTRIGHT:
- if(ab->side == ABE_RIGHT)
- return GDK_FILTER_REMOVE;
- break;
- }
- }
- return GDK_FILTER_CONTINUE;
-}
-
-#if 0
-static GdkFilterReturn wnd_initmenupopup(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
-
- if(ab->docked && HIWORD(msg->lParam)) {
- HMENU sysmenu = GetSystemMenu(msg->hwnd, FALSE);
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_initpopupmenu: docked: %d ismenu: %d\n", ab->docked, IsMenu(sysmenu));
- if(EnableMenuItem(sysmenu, SC_MAXIMIZE, MF_BYCOMMAND|MF_GRAYED)<0)
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "SC_MAXIMIZE Menu item does not exist\n");
- if(EnableMenuItem(sysmenu, SC_MOVE, MF_BYCOMMAND|MF_GRAYED)<0)
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "SC_MOVE Menu item does not exist\n");
- return GDK_FILTER_CONTINUE;
- }
- else
- GetSystemMenu(msg->hwnd, TRUE);
- return GDK_FILTER_CONTINUE;
-}
-#endif
-
-static GdkFilterReturn gtk_appbar_callback(GtkAppBar *ab, GdkXEvent *xevent) {
- MSG *msg = (MSG*)xevent;
- RECT orig, windowRect;
-
- switch (msg->wParam) {
- case ABN_STATECHANGE:
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_STATECHANGE\n");
- break;
-
- case ABN_FULLSCREENAPP:
- purple_debug(PURPLE_DEBUG_MISC, "gtkappbar", "gtk_appbar_callback: ABN_FULLSCREENAPP: %d\n", (BOOL)msg->lParam);
- if (!ab->iconized && ab->docked) {
- if ((BOOL)msg->lParam) {
- SetWindowPos(msg->hwnd, HWND_BOTTOM, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- } else {
- SetWindowPos(msg->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
- }
- }
-
- break;
- case ABN_POSCHANGED:
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_POSCHANGED\n");
- CopyRect(&orig, &(ab->docked_rect));
- get_rect_of_window(msg->hwnd, &windowRect);
- gtk_appbar_querypos(ab, msg->hwnd, windowRect);
- if (EqualRect(&orig, &(ab->docked_rect)) == 0) {
- MoveWindow(msg->hwnd, ab->docked_rect.left, ab->docked_rect.top,
- ab->docked_rect.right - ab->docked_rect.left,
- ab->docked_rect.bottom - ab->docked_rect.top, TRUE);
- }
- gtk_appbar_setpos(ab, msg->hwnd);
- break;
-#if 0
- default:
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: %d\n", msg->wParam);
-#endif
- }
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkFilterReturn gtk_appbar_event_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) {
- MSG *msg = (MSG*)xevent;
-
- /*printf("MSG: %s\n", message_to_string (msg->message));*/
- switch(msg->message) {
- case WM_EXITSIZEMOVE:
- return wnd_exitsizemove(data, xevent);
- case WM_WINDOWPOSCHANGING:
- return wnd_poschanging(data, xevent);
- case WM_WINDOWPOSCHANGED:
- return wnd_poschanged(data, xevent);
- case WM_ACTIVATE:
- return wnd_activate(data, xevent);
- case WM_SIZING:
- return wnd_sizing(data, xevent);
- case WM_MOVING:
- return wnd_moving(data, xevent);
- case WM_SHOWWINDOW:
- return wnd_showwindow(data, xevent);
- case WM_NCHITTEST:
- return wnd_nchittest(data, xevent);
-#if 0
- case WM_INITMENUPOPUP:
- return wnd_initmenupopup(data, xevent);
-#endif
- case WM_SIZE:
- return wnd_size(data, xevent);
- case APPBAR_CALLBACK:
- return gtk_appbar_callback(data, xevent);
-#if 0
- default:
- purple_debug_info("gtkappbar", "gtk_appbar_event_filter %d\n", msg->message);
-#endif
- }
- return GDK_FILTER_CONTINUE;
-}
-
-static void gtk_appbar_do_dock(GtkAppBar *ab, UINT side) {
- RECT orig, windowRect;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_do_dock\n");
-
- if (!ab || !IsWindow(appbar_get_handle(ab)))
- return;
-
- ab->side = side;
- get_window_normal_rc(appbar_get_handle(ab), &(ab->docked_rect));
- CopyRect(&orig, &(ab->docked_rect));
- get_rect_of_window(appbar_get_handle(ab), &windowRect);
- gtk_appbar_querypos(ab, appbar_get_handle(ab), windowRect);
- if(EqualRect(&orig, &(ab->docked_rect)) == 0)
- MoveWindow(appbar_get_handle(ab),
- ab->docked_rect.left,
- ab->docked_rect.top,
- ab->docked_rect.right - ab->docked_rect.left,
- ab->docked_rect.bottom - ab->docked_rect.top, TRUE);
- gtk_appbar_setpos(ab, appbar_get_handle(ab));
- ab->docked = TRUE;
-}
-
-void gtk_appbar_dock(GtkAppBar *ab, UINT side) {
- HWND hwnd;
-
- g_return_if_fail(ab != NULL);
-
- hwnd = appbar_get_handle(ab);
-
- g_return_if_fail(IsWindow(hwnd));
-
- ab->iconized = IsIconic(hwnd);
-
- if (!ab->docked && !ab->iconized)
- ShowWindow(hwnd, SW_HIDE);
- gtk_appbar_do_dock(ab, side);
- set_toolbar(hwnd, TRUE);
- if (!ab->iconized)
- ShowWindow(hwnd, SW_SHOW);
-}
-
-void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb) {
- if(!ab)
- return;
- ab->dock_cbs = g_slist_prepend(ab->dock_cbs, dock_cb);
-}
-
-GtkAppBar *gtk_appbar_add(GtkWidget *win) {
- GtkAppBar *ab;
-
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_add\n");
-
- if(!win)
- return NULL;
- ab = g_new0(GtkAppBar, 1);
- ab->win = win;
-
- /* init docking coords */
- get_window_normal_rc(appbar_get_handle(ab), &(ab->docked_rect));
-
- /* Add main window filter */
- gdk_window_add_filter(gtk_widget_get_window(win),
- gtk_appbar_event_filter,
- ab);
- return ab;
-}
-
-void gtk_appbar_remove(GtkAppBar *ab) {
- HWND hwnd;
- purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_remove\n");
-
- if(!ab)
- return;
-
- hwnd = appbar_get_handle(ab);
- gdk_window_remove_filter(gtk_widget_get_window(ab->win),
- gtk_appbar_event_filter,
- ab);
- if(ab->docked) {
- gtk_window_resize(GTK_WINDOW(ab->win),
- ab->docked_rect.right - ab->docked_rect.left,
- ab->undocked_height);
- if (!ab->iconized)
- ShowWindow(hwnd, SW_HIDE);
- set_toolbar(hwnd, FALSE);
- if (!ab->iconized)
- ShowWindow(hwnd, SW_SHOW);
- }
- gtk_appbar_unregister(ab, hwnd);
-
- g_slist_free(ab->dock_cbs);
-
- g_free(ab);
-}
--- a/pidgin/plugins/win32/winprefs/gtkappbar.h Fri Oct 30 16:34:33 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * purple - WinPurple Options Plugin
- *
- * File: gtkappbar.h
- * Date: August 2, 2003
- * Description: Appbar functionality for Windows GTK+ applications
- *
- * Copyright (C) 2003, Herman Bloggs <hermanator12002@yahoo.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
- *
- */
-#ifndef _GTKAPPBAR_H_
-#define _GTKAPPBAR_H_
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-typedef struct {
- GtkWidget *win;
- /** The rectangle of the screen area used for docking */
- RECT docked_rect;
- /** The height of the window prior to docking */
- UINT undocked_height;
- /** The side of the screen to which the window is docked*/
- UINT side;
- /** Is the window currently docked? */
- gboolean docked;
- /** Is the window currently in the process of docking? */
- gboolean docking;
- gboolean undocking;
- /** Is the window currently registered as an appbar */
- gboolean registered;
- /** Callback functions to notify of dock state change */
- GSList *dock_cbs;
- /** Is the window currently iconized? */
- gboolean iconized;
-} GtkAppBar;
-
-typedef void (*GtkAppBarDockCB)(gboolean);
-
-GtkAppBar *gtk_appbar_add(GtkWidget *win);
-void gtk_appbar_remove(GtkAppBar *ab);
-void gtk_appbar_dock(GtkAppBar *ab, UINT side);
-void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb);
-
-#endif /* _GTKAPPBAR_H_ */
--- a/pidgin/plugins/win32/winprefs/meson.build Fri Oct 30 16:34:33 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-winprefs_SOURCES = [
- 'gtkappbar.c',
- 'gtkappbar.h',
- 'winprefs.c'
-]
-
-winprefs = library('winprefs', winprefs_SOURCES,
- dependencies : [libpurple_dep, libpidgin_dep, glib],
- name_prefix : '',
- install : true, install_dir : PIDGIN_PLUGINDIR)
--- a/pidgin/plugins/win32/winprefs/winprefs.c Fri Oct 30 16:34:33 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * pidgin - Windows Pidgin Options Plugin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * 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 <purple.h>
-
-#include <pidgin.h>
-
-/*
- * MACROS & DEFINES
- */
-#define WINPREFS_PLUGIN_ID "gtk-win-prefs"
-
-#define RUNKEY "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"
-
-/*
- * LOCALS
- */
-static const char *PREF_DBLIST_DOCKABLE = "/plugins/gtk/win32/winprefs/dblist_dockable";
-static const char *PREF_DBLIST_DOCKED = "/plugins/gtk/win32/winprefs/dblist_docked";
-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";
-/* Deprecated */
-static const char *PREF_CHAT_BLINK = "/plugins/gtk/win32/winprefs/chat_blink";
-static const char *PREF_DBLIST_ON_TOP = "/plugins/gtk/win32/winprefs/dblist_on_top";
-
-static PurplePlugin *handle = NULL;
-static GtkAppBar *blist_ab = NULL;
-static GtkWidget *blist = NULL;
-static guint blist_visible_cb_id = 0;
-
-enum {
- BLIST_TOP_NEVER = 0,
- BLIST_TOP_ALWAYS,
- BLIST_TOP_DOCKED,
-};
-
-/*
- * CODE
- */
-
-/* BLIST DOCKING */
-
-static void blist_save_state() {
- if(blist_ab) {
- if(purple_prefs_get_bool(PREF_DBLIST_DOCKABLE) && blist_ab->docked) {
- purple_prefs_set_int(PREF_DBLIST_HEIGHT, blist_ab->undocked_height);
- purple_prefs_set_int(PREF_DBLIST_SIDE, blist_ab->side);
- purple_prefs_set_bool(PREF_DBLIST_DOCKED, blist_ab->docked);
- } else
- purple_prefs_set_bool(PREF_DBLIST_DOCKED, FALSE);
- }
-}
-
-static void blist_set_ontop(gboolean val) {
- if(!blist)
- return;
-
- gtk_window_set_keep_above(
- GTK_WINDOW(PIDGIN_BUDDY_LIST(purple_blist_get_default())->window),
- val);
-}
-
-static void blist_dock_cb(gboolean val) {
- if(val) {
- purple_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking...\n");
- if(purple_prefs_get_int(PREF_BLIST_ON_TOP) != BLIST_TOP_NEVER)
- blist_set_ontop(TRUE);
- } else {
- purple_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking...\n");
- blist_set_ontop(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS);
- }
-}
-
-static void blist_set_dockable(gboolean val) {
- if(val) {
- if(blist_ab == NULL && blist != NULL) {
- blist_ab = gtk_appbar_add(blist);
- gtk_appbar_add_dock_cb(blist_ab, blist_dock_cb);
- }
- } else {
- if(blist_ab != NULL) {
- gtk_appbar_remove(blist_ab);
- blist_ab = NULL;
- }
-
- blist_set_ontop(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS);
- }
-}
-
-/* PLUGIN CALLBACKS */
-
-/* We need this because the blist destroy cb won't be called before the
- plugin is unloaded, when quitting */
-static void purple_quit_cb() {
- purple_debug_info(WINPREFS_PLUGIN_ID, "purple_quit_cb: removing appbar\n");
- blist_save_state();
- blist_set_dockable(FALSE);
-}
-
-/* Listen for the first time the window stops being withdrawn */
-static void blist_visible_cb(const char *pref, PurplePrefType type,
- gconstpointer value, gpointer user_data) {
- if(purple_prefs_get_bool(pref)) {
- gtk_appbar_dock(blist_ab,
- purple_prefs_get_int(PREF_DBLIST_SIDE));
-
- if(purple_prefs_get_int(PREF_BLIST_ON_TOP)
- == BLIST_TOP_DOCKED)
- blist_set_ontop(TRUE);
-
- /* We only need to be notified about this once */
- purple_prefs_disconnect_callback(blist_visible_cb_id);
- }
-}
-
-/* This needs to be delayed otherwise, when the blist is originally created and
- * hidden, it'll trigger the blist_visible_cb */
-static gboolean listen_for_blist_visible_cb(gpointer data) {
- if (handle != NULL)
- blist_visible_cb_id =
- purple_prefs_connect_callback(handle,
- PIDGIN_PREFS_ROOT "/blist/list_visible",
- blist_visible_cb, NULL);
-
- return FALSE;
-}
-
-static void blist_create_cb(PurpleBuddyList *purple_blist, void *data) {
- purple_debug_info(WINPREFS_PLUGIN_ID, "buddy list created\n");
-
- blist = PIDGIN_BUDDY_LIST(purple_blist)->window;
-
- if(purple_prefs_get_bool(PREF_DBLIST_DOCKABLE)) {
- blist_set_dockable(TRUE);
- if(purple_prefs_get_bool(PREF_DBLIST_DOCKED)) {
- blist_ab->undocked_height = purple_prefs_get_int(PREF_DBLIST_HEIGHT);
- if(!(gdk_window_get_state(gtk_widget_get_window(blist))
- & GDK_WINDOW_STATE_WITHDRAWN)) {
- gtk_appbar_dock(blist_ab,
- purple_prefs_get_int(PREF_DBLIST_SIDE));
- if(purple_prefs_get_int(PREF_BLIST_ON_TOP)
- == BLIST_TOP_DOCKED)
- blist_set_ontop(TRUE);
- } else {
- g_idle_add(listen_for_blist_visible_cb, NULL);
- }
- }
- }
-
- if(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS)
- blist_set_ontop(TRUE);
-
-}
-
-/* WIN PREFS GENERAL */
-
-static void
-winprefs_set_autostart(GtkWidget *w) {
- gchar runval[MAX_PATH] = {0};
-
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
- GetModuleFileName(NULL, runval, MAX_PATH);
-
- if(!wpurple_write_reg_string(HKEY_CURRENT_USER, RUNKEY, "Pidgin", runval)
- /* For Win98 */
- && !wpurple_write_reg_string(HKEY_LOCAL_MACHINE, RUNKEY, "Pidgin", runval))
- purple_debug_error(WINPREFS_PLUGIN_ID, "Could not set registry key value\n");
-
- g_free(runval);
-}
-
-static void
-winprefs_set_multiple_instances(GtkWidget *w) {
- wpurple_write_reg_string(HKEY_CURRENT_USER, "Environment", "PIDGIN_MULTI_INST",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)) ? "1" : NULL);
-}
-
-static void
-winprefs_set_blist_dockable(const char *pref, PurplePrefType type,
- gconstpointer value, gpointer user_data)
-{
- blist_set_dockable(GPOINTER_TO_INT(value));
-}
-
-static void
-winprefs_set_blist_ontop(const char *pref, PurplePrefType type,
- gconstpointer value, gpointer user_data)
-{
- gint setting = purple_prefs_get_int(PREF_BLIST_ON_TOP);
- if((setting == BLIST_TOP_DOCKED && blist_ab && blist_ab->docked)
- || setting == BLIST_TOP_ALWAYS)
- blist_set_ontop(TRUE);
- else
- blist_set_ontop(FALSE);
-}
-
-/*
- * EXPORTED FUNCTIONS
- */
-
-static GtkWidget* get_config_frame(PurplePlugin *plugin) {
- GtkWidget *ret;
- GtkWidget *vbox;
- GtkWidget *button;
- char *run_key_val;
- char *tmp;
-
- ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 18);
- gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
-
- /* Autostart */
- vbox = pidgin_make_frame(ret, _("Startup"));
- tmp = g_strdup_printf(_("_Start %s on Windows startup"), PIDGIN_NAME);
- button = gtk_check_button_new_with_mnemonic(tmp);
- g_free(tmp);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- if ((run_key_val = wpurple_read_reg_string(HKEY_CURRENT_USER, RUNKEY, "Pidgin"))
- || (run_key_val = wpurple_read_reg_string(HKEY_LOCAL_MACHINE, RUNKEY, "Pidgin"))) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
- g_free(run_key_val);
- }
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(winprefs_set_autostart), NULL);
- gtk_widget_show(button);
-
- button = gtk_check_button_new_with_mnemonic(_("Allow multiple instances"));
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- if ((run_key_val = wpurple_read_reg_string(HKEY_CURRENT_USER, "Environment", "PIDGIN_MULTI_INST"))) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
- g_free(run_key_val);
- }
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(winprefs_set_multiple_instances), NULL);
- gtk_widget_show(button);
-
- /* Buddy List */
- vbox = pidgin_make_frame(ret, _("Buddy List"));
- pidgin_prefs_checkbox(_("_Dockable Buddy List"),
- PREF_DBLIST_DOCKABLE, vbox);
-
- /* Blist On Top */
- pidgin_prefs_dropdown(vbox, _("_Keep Buddy List window on top:"),
- PURPLE_PREF_INT, PREF_BLIST_ON_TOP,
- _("Never"), BLIST_TOP_NEVER,
- _("Always"), BLIST_TOP_ALWAYS,
- /* XXX: Did this ever work? */
- _("Only when docked"), BLIST_TOP_DOCKED,
- NULL);
-
- gtk_widget_show_all(ret);
- return ret;
-}
-
-static PidginPluginInfo *
-plugin_query(GError **error)
-{
- const gchar * const authors[] = {
- "Herman Bloggs <hermanator12002@yahoo.com>",
- NULL
- };
-
- return pidgin_plugin_info_new(
- "id", WINPREFS_PLUGIN_ID,
- "name", N_("Windows Pidgin Options"),
- "version", DISPLAY_VERSION,
- "category", N_("User interface"),
- "summary", N_("Options specific to Pidgin for Windows."),
- "description", N_("Provides options specific to Pidgin for "
- "Windows, such as buddy list docking."),
- "authors", authors,
- "website", PURPLE_WEBSITE,
- "abi-version", PURPLE_ABI_VERSION,
- "gtk-config-frame-cb", get_config_frame,
- NULL
- );
-}
-
-static gboolean plugin_load(PurplePlugin *plugin, GError **error) {
- purple_prefs_add_none("/plugins/gtk");
- purple_prefs_add_none("/plugins/gtk/win32");
- purple_prefs_add_none("/plugins/gtk/win32/winprefs");
- purple_prefs_add_bool(PREF_DBLIST_DOCKABLE, FALSE);
- purple_prefs_add_bool(PREF_DBLIST_DOCKED, FALSE);
- purple_prefs_add_int(PREF_DBLIST_HEIGHT, 0);
- purple_prefs_add_int(PREF_DBLIST_SIDE, 0);
-
- /* Convert old preferences */
- if(purple_prefs_exists(PREF_DBLIST_ON_TOP)) {
- gint blist_top = BLIST_TOP_NEVER;
- if(purple_prefs_get_bool(PREF_BLIST_ON_TOP))
- blist_top = BLIST_TOP_ALWAYS;
- else if(purple_prefs_get_bool(PREF_DBLIST_ON_TOP))
- blist_top = BLIST_TOP_DOCKED;
- purple_prefs_remove(PREF_BLIST_ON_TOP);
- purple_prefs_remove(PREF_DBLIST_ON_TOP);
- purple_prefs_add_int(PREF_BLIST_ON_TOP, blist_top);
- } else
- purple_prefs_add_int(PREF_BLIST_ON_TOP, BLIST_TOP_NEVER);
- purple_prefs_remove(PREF_CHAT_BLINK);
-
- handle = plugin;
-
- /* blist docking init */
- if (purple_blist_get_default() &&
- PIDGIN_BUDDY_LIST(purple_blist_get_default()) &&
- PIDGIN_BUDDY_LIST(purple_blist_get_default())->window) {
- blist_create_cb(purple_blist_get_default(), NULL);
- }
-
- /* This really shouldn't happen anymore generally, but if for some strange
- reason, the blist is recreated, we need to set it up again. */
- purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created",
- plugin, PURPLE_CALLBACK(blist_create_cb), NULL);
-
- purple_signal_connect((void*)purple_get_core(), "quitting", plugin,
- PURPLE_CALLBACK(purple_quit_cb), NULL);
-
- purple_prefs_connect_callback(handle, PREF_BLIST_ON_TOP,
- winprefs_set_blist_ontop, NULL);
- purple_prefs_connect_callback(handle, PREF_DBLIST_DOCKABLE,
- winprefs_set_blist_dockable, NULL);
-
- return TRUE;
-}
-
-static gboolean plugin_unload(PurplePlugin *plugin, GError **error) {
- blist_set_dockable(FALSE);
- blist_set_ontop(FALSE);
-
- handle = NULL;
-
- return TRUE;
-}
-
-PURPLE_PLUGIN_INIT(winprefs, plugin_query, plugin_load, plugin_unload);
--- a/po/POTFILES.in Fri Oct 30 16:34:33 2020 -0500
+++ b/po/POTFILES.in Sun Nov 01 02:42:18 2020 -0600
@@ -383,8 +383,6 @@
pidgin/plugins/spellchk.c
pidgin/plugins/transparency.c
pidgin/plugins/unity.c
-pidgin/plugins/win32/winprefs/gtkappbar.c
-pidgin/plugins/win32/winprefs/winprefs.c
pidgin/plugins/xmppconsole/console.ui
pidgin/plugins/xmppconsole/xmppconsole.c
pidgin/resources/Log/log-viewer.ui