From 15eb78c0c87f2a7a8fcb8f72998de9ba1e56d6d0 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:14:56 -0500 Subject: [PATCH 1/8] Fix bug with translated text. --- pyfpdb/Hello.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpdb/Hello.py b/pyfpdb/Hello.py index 1dd48cb4..79efddba 100644 --- a/pyfpdb/Hello.py +++ b/pyfpdb/Hello.py @@ -32,6 +32,8 @@ import sys import pygtk import gtk import gobject +import L10n +_ = L10n.get_translation() # FreePokerTools modules from Mucked import Aux_Window From 6696cab13cf599864e6c57e2d98117184375141b Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:16:19 -0500 Subject: [PATCH 2/8] Use sys.platform to detect OS instead of os.system. --- pyfpdb/HUD_main.pyw | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 pyfpdb/HUD_main.pyw diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw old mode 100755 new mode 100644 index 79b2fbfe..4a8f46ed --- a/pyfpdb/HUD_main.pyw +++ b/pyfpdb/HUD_main.pyw @@ -44,9 +44,11 @@ import Options (options, argv) = Options.fpdb_options() # get the correct module for the current os -if os.name == 'posix': +if sys.platform == 'linux2': import XTables as Tables -elif os.name == 'nt': +elif sys.platform == 'darwin': + import OSXTables as Tables +else: # This is bad--figure out the values for the various windows flavors import WinTables as Tables import locale From 9c73c0b791c33f9519b0d96c1257ab7b1cc677f7 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:33:55 -0500 Subject: [PATCH 3/8] New module for poker client window finding on OSX. --- pyfpdb/OSXTables.py | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 pyfpdb/OSXTables.py diff --git a/pyfpdb/OSXTables.py b/pyfpdb/OSXTables.py new file mode 100644 index 00000000..9d03cff7 --- /dev/null +++ b/pyfpdb/OSXTables.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""XWindows specific methods for TableWindows Class. +""" +# Copyright 2008 - 2010, Ray E. Barker + +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +import L10n +_ = L10n.get_translation() + +# Standard Library modules +import re +import os + +# pyGTK modules +import gtk + +# Other Library modules +from Quartz import CoreGraphics + +# FPDB modules +from TableWindow import Table_Window + +class Table(Table_Window): + + def find_table_parameters(self): + +# This is called by __init__(). Find the poker table window of interest, +# given the self.search_string. Then populate self.number, self.title, +# self.window, and self.parent (if required). + + self.number = None + WinList = CoreGraphics.CGWindowListCreate(0,0) + WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + + for d in WinListDict: + if re.search(self.search_string, d['kCGWindowName'], re.I): + title = d['kCGWindowName'] + if self.check_bad_words(title): continue + self.number = d['kCGWindowNumber'] + self.title = title + if self.number is None: + return None + + def get_geometry(self): + + WinList = CoreGraphics.CGWindowListCreate(0,0) + WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + + for d in WinListDict: + if d['kCGWindowNumber'] == self.number: + return {'x' : d['kCGWindowBounds']['X'], + 'y' : d['kCGWindowBounds']['Y'], + 'width' : d['kCGWindowBounds']['Width'], + 'height' : d['kCGWindowBounds']['Height'] + } + return None + + def get_window_title(self): + WinList = CoreGraphics.CGWindowListCreate(0,0) + WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + + for d in WinListDict: + if d['kCGWindowNumber'] == self.number: + return d['kCGWindowName'] + return None + + def topify(self, window): +# The idea here is to call set_transient_for on the HUD window, with the table window +# as the argument. This should keep the HUD window on top of the table window, as if +# the hud window was a dialog belonging to the table. + +# This is the gdkhandle for the HUD window + gdkwindow = gtk.gdk.window_foreign_new(window.number) + gdkwindow.set_transient_for(self.gdkhandle) From efc2db9fca4c27dd93625c5a6c90b92591b959e2 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:35:03 -0500 Subject: [PATCH 4/8] Make HUD_main.pyw executable. --- pyfpdb/HUD_main.pyw | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 pyfpdb/HUD_main.pyw diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw old mode 100644 new mode 100755 From 16da7ceda779383dc0b3dbd98412a77102cf05c6 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:43:41 -0500 Subject: [PATCH 5/8] Update to work with OSXTables changes. --- pyfpdb/Tables_Demo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) mode change 100755 => 100644 pyfpdb/Tables_Demo.py diff --git a/pyfpdb/Tables_Demo.py b/pyfpdb/Tables_Demo.py old mode 100755 new mode 100644 index 86e5f1f3..fb573a6f --- a/pyfpdb/Tables_Demo.py +++ b/pyfpdb/Tables_Demo.py @@ -22,12 +22,8 @@ Main program module to test/demo the Tables subclasses. ######################################################################## -import L10n -_ = L10n.get_translation() - # Standard Library modules import sys -import os # pyGTK modules import pygtk @@ -36,11 +32,15 @@ import gobject # fpdb/free poker tools modules import Configuration +import L10n +_ = L10n.get_translation() # get the correct module for the current os -if os.name == 'posix': +if sys.platform == 'linux2': import XTables as Tables -elif os.name == 'nt': +elif sys.platform == 'darwin': + import OSXTables as Tables +else: # This is bad--figure out the values for the various windows flavors import WinTables as Tables config = Configuration.Config() From 2027c9b89ffb8cbe0330eba3c782ad4d3d655e4c Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 17 Dec 2010 22:44:40 -0500 Subject: [PATCH 6/8] Maked executable. --- pyfpdb/Tables_Demo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 pyfpdb/Tables_Demo.py diff --git a/pyfpdb/Tables_Demo.py b/pyfpdb/Tables_Demo.py old mode 100644 new mode 100755 From 3b6867df296afd4c7426f96a1712216be675763b Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Sat, 18 Dec 2010 10:04:34 -0500 Subject: [PATCH 7/8] Another try at sussing the Quartz bindings. --- pyfpdb/OSXTables.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pyfpdb/OSXTables.py b/pyfpdb/OSXTables.py index 9d03cff7..e99d53e1 100644 --- a/pyfpdb/OSXTables.py +++ b/pyfpdb/OSXTables.py @@ -31,7 +31,7 @@ import os import gtk # Other Library modules -from Quartz import CoreGraphics +from Quartz.CoreGraphics import * # FPDB modules from TableWindow import Table_Window @@ -45,39 +45,39 @@ class Table(Table_Window): # self.window, and self.parent (if required). self.number = None - WinList = CoreGraphics.CGWindowListCreate(0,0) - WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + WinList = CGWindowListCreate(0,0) + WinListDict = CGWindowListCreateDescriptionFromArray(WinList) for d in WinListDict: - if re.search(self.search_string, d['kCGWindowName'], re.I): - title = d['kCGWindowName'] + if re.search(self.search_string, d[kCGWindowName], re.I): + title = d[kCGWindowName] if self.check_bad_words(title): continue - self.number = d['kCGWindowNumber'] + self.number = d[kCGWindowNumber] self.title = title if self.number is None: return None def get_geometry(self): - WinList = CoreGraphics.CGWindowListCreate(0,0) - WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + WinList = CGWindowListCreate(0,0) + WinListDict = CGWindowListCreateDescriptionFromArray(WinList) for d in WinListDict: - if d['kCGWindowNumber'] == self.number: - return {'x' : d['kCGWindowBounds']['X'], - 'y' : d['kCGWindowBounds']['Y'], - 'width' : d['kCGWindowBounds']['Width'], - 'height' : d['kCGWindowBounds']['Height'] + if d[CGWindowNumber] == self.number: + return {'x' : d[kCGWindowBounds][X], + 'y' : d[kCGWindowBounds][Y], + 'width' : d[kCGWindowBounds][Width], + 'height' : d[kCGWindowBounds][Height] } return None def get_window_title(self): - WinList = CoreGraphics.CGWindowListCreate(0,0) - WinListDict = CoreGraphics.CGWindowListCreateDescriptionFromArray(WinList) + WinList = CGWindowListCreate(0,0) + WinListDict = CGWindowListCreateDescriptionFromArray(WinList) for d in WinListDict: - if d['kCGWindowNumber'] == self.number: - return d['kCGWindowName'] + if d[kCGWindowNumber] == self.number: + return d[kCGWindowName] return None def topify(self, window): From d8cf53a2bd1c813af27972d29e8bfa40d4b5be66 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Sat, 18 Dec 2010 10:43:56 -0500 Subject: [PATCH 8/8] Don't fail on windows that don't have names. --- pyfpdb/OSXTables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/OSXTables.py b/pyfpdb/OSXTables.py index e99d53e1..8baa6aec 100644 --- a/pyfpdb/OSXTables.py +++ b/pyfpdb/OSXTables.py @@ -49,7 +49,7 @@ class Table(Table_Window): WinListDict = CGWindowListCreateDescriptionFromArray(WinList) for d in WinListDict: - if re.search(self.search_string, d[kCGWindowName], re.I): + if re.search(self.search_string, d.get(kCGWindowName, ""), re.I): title = d[kCGWindowName] if self.check_bad_words(title): continue self.number = d[kCGWindowNumber]