2 # -*- coding: utf-8 -*-
3 """XWindows specific methods for TableWindows Class.
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 ########################################################################
24 _
= L10n
.get_translation()
26 # Standard Library modules
33 # Other Library modules
34 from Quartz
.CoreGraphics
import *
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).
48 WinList
= CGWindowListCreate(0,0)
49 WinListDict
= CGWindowListCreateDescriptionFromArray(WinList
)
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
])
58 if self
.number
is None:
61 def get_geometry(self
):
63 WinList
= CGWindowListCreate(0,0)
64 WinListDict
= CGWindowListCreateDescriptionFromArray(WinList
)
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'])
75 def get_window_title(self
):
76 WinList
= CGWindowListCreate(0,0)
77 WinListDict
= CGWindowListCreateDescriptionFromArray(WinList
)
80 if d
[kCGWindowNumber
] == self
.number
:
81 return d
[kCGWindowName
]
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
)