Carbon Poker offers a 5 card stud game that wasn't listed here. It's not available...
[fpdb-dooglus.git] / pyfpdb / OSXTables.py
blob3ed64c98a6c8c29fd2c1396d3737e3d2f7bf9a1a
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """XWindows specific methods for TableWindows Class.
4 """
5 # Copyright 2008 - 2011, Ray E. Barker
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ########################################################################
23 import L10n
24 _ = L10n.get_translation()
26 # Standard Library modules
27 import re
28 import os
30 # pyGTK modules
31 import gtk
33 # Other Library modules
34 from Quartz.CoreGraphics import *
36 # FPDB modules
37 from TableWindow import Table_Window
39 class Table(Table_Window):
41 def find_table_parameters(self):
43 # This is called by __init__(). Find the poker table window of interest,
44 # given the self.search_string. Then populate self.number, self.title,
45 # self.window, and self.parent (if required).
47 self.number = None
48 WinList = CGWindowListCreate(0,0)
49 WinListDict = CGWindowListCreateDescriptionFromArray(WinList)
51 for d in WinListDict:
52 if re.search(self.search_string, d.get(kCGWindowName, ""), re.I):
53 title = d[kCGWindowName]
54 if self.check_bad_words(title): continue
55 self.number = int(d[kCGWindowNumber])
56 self.title = title
57 return self.title
58 if self.number is None:
59 return None
61 def get_geometry(self):
63 WinList = CGWindowListCreate(0,0)
64 WinListDict = CGWindowListCreateDescriptionFromArray(WinList)
66 for d in WinListDict:
67 if d[kCGWindowNumber] == self.number:
68 return {'x' : int(d[kCGWindowBounds]['X']),
69 'y' : int(d[kCGWindowBounds]['Y']),
70 'width' : int(d[kCGWindowBounds]['Width']),
71 'height' : int(d[kCGWindowBounds]['Height'])
73 return None
75 def get_window_title(self):
76 WinList = CGWindowListCreate(0,0)
77 WinListDict = CGWindowListCreateDescriptionFromArray(WinList)
79 for d in WinListDict:
80 if d[kCGWindowNumber] == self.number:
81 return d[kCGWindowName]
82 return None
84 def topify(self, window):
85 # The idea here is to call set_transient_for on the HUD window, with the table window
86 # as the argument. This should keep the HUD window on top of the table window, as if
87 # the hud window was a dialog belonging to the table.
89 # This is the gdkhandle for the HUD window
90 gdkwindow = gtk.gdk.window_foreign_new(window.window.xid)
91 gdkwindow.set_transient_for(window.window)