Merge branch 'master' of git://git.assembla.com/free_poker_tools.git

This commit is contained in:
eblade 2009-02-28 14:22:06 -05:00
commit 7a7eb25529
3 changed files with 35 additions and 43 deletions

View File

@ -194,16 +194,10 @@ class GuiBulkImport():
self.load_button.show() self.load_button.show()
# see how many hands are in the db and adjust accordingly # see how many hands are in the db and adjust accordingly
db_parms = config.get_db_parameters('fpdb') tcursor = db.db.cursor()
db.connect(db_parms['db-backend'], tcursor.execute("Select max(id) from Hands;")
db_parms['db-host'], row = tcursor.fetchone()
db_parms['db-databaseName'], tcursor.close()
db_parms['db-user'],
db_parms['db-password'])
cursor = db.db.cursor()
cursor.execute("Select max(id) from Hands;")
row = cursor.fetchone()
db.disconnect() # that's all we need this for
self.n_hands_in_db = row[0] self.n_hands_in_db = row[0]
if self.n_hands_in_db == 0: if self.n_hands_in_db == 0:
self.cb.set_active(2) self.cb.set_active(2)

View File

@ -76,7 +76,14 @@ class HUD_main(object):
def destroy(*args): # call back for terminating the main eventloop def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit() gtk.main_quit()
def kill_hud(self, event, table):
# called by an event in the HUD, to kill this specific HUD
self.hud_dict[table].kill()
self.hud_dict[table].main_window.destroy()
self.vb.remove(self.hud_dict[table].tablehudlabel)
del(self.hud_dict[table])
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict, cards): def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict, cards):
def idle_func(): def idle_func():
@ -117,18 +124,6 @@ class HUD_main(object):
gtk.gdk.threads_leave() gtk.gdk.threads_leave()
gobject.idle_add(idle_func) gobject.idle_add(idle_func)
def HUD_removed(self, tablename):
tablename = Tables.clean_title(tablename)
# TODO: There's a potential problem here somewhere, that this hacks around .. the table_name as being passed to HUD_create is cleaned,
# but the table.name as being passed here is not cleaned. I don't know why. -eric
if tablename in self.hud_dict and self.hud_dict[tablename].deleted:
self.vb.remove(self.hud_dict[tablename].tablehudlabel)
del self.hud_dict[tablename]
return False
return True
def read_stdin(self): # This is the thread function def read_stdin(self): # This is the thread function
"""Do all the non-gui heavy lifting for the HUD program.""" """Do all the non-gui heavy lifting for the HUD program."""

View File

@ -81,7 +81,7 @@ class Hud:
self.main_window = gtk.Window() self.main_window = gtk.Window()
self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC) self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC)
self.main_window.set_title(self.table.name + " FPDBHUD") self.main_window.set_title(self.table.name + " FPDBHUD")
self.main_window.destroyhandler = self.main_window.connect("destroy", self.kill_hud) # self.main_window.destroyhandler = self.main_window.connect("destroy", self.kill_hud)
self.main_window.set_decorated(False) self.main_window.set_decorated(False)
self.main_window.set_opacity(self.colors["hudopacity"]) self.main_window.set_opacity(self.colors["hudopacity"])
@ -106,7 +106,7 @@ class Hud:
self.menu = gtk.Menu() self.menu = gtk.Menu()
self.item1 = gtk.MenuItem('Kill this HUD') self.item1 = gtk.MenuItem('Kill this HUD')
self.menu.append(self.item1) self.menu.append(self.item1)
self.item1.connect("activate", self.kill_hud_menu) self.item1.connect("activate", self.parent.kill_hud, self.table.name)
self.item1.show() self.item1.show()
self.item2 = gtk.MenuItem('Save Layout') self.item2 = gtk.MenuItem('Save Layout')
@ -168,23 +168,18 @@ class Hud:
return True return True
return False return False
def kill_hud(self, *args): def kill(self, *args):
if self.deleted: # kill all stat_windows, popups and aux_windows in this HUD
return # no killing self twice. # heap dead, burnt bodies, blood 'n guts, veins between my teeth
for k in self.stat_windows: for s in self.stat_windows.itervalues():
self.stat_windows[k].window.destroy() for p in s.popups:
s.kill_popup(p)
s.window.destroy()
self.stat_windows = {}
# also kill any aux windows # also kill any aux windows
for m in self.aux_windows: for m in self.aux_windows:
m.destroy() m.destroy()
self.aux_windows.remove(m) self.aux_windows = []
self.deleted = True
self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right
self.main_window.destroy()
self.parent.HUD_removed(self.table.name)
def kill_hud_menu(self, *args):
self.main_window.destroy()
def reposition_windows(self, *args): def reposition_windows(self, *args):
for w in self.stat_windows: for w in self.stat_windows:
@ -285,7 +280,8 @@ class Hud:
def update(self, hand, config): def update(self, hand, config):
self.hand = hand # this is the last hand, so it is available later self.hand = hand # this is the last hand, so it is available later
self.update_table_position() if os.name == 'nt':
self.update_table_position()
for s in self.stat_dict: for s in self.stat_dict:
try: try:
@ -345,7 +341,7 @@ class Stat_Window:
# and double-clicks. # and double-clicks.
if event.button == 3: # right button event if event.button == 3: # right button event
Popup_window(widget, self) self.popups.append(Popup_window(widget, self))
if event.button == 2: # middle button event if event.button == 2: # middle button event
self.window.hide() self.window.hide()
@ -356,7 +352,11 @@ class Stat_Window:
self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time) self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time)
else: else:
self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
def kill_popup(self, popup):
popup.window.destroy()
self.popups.remove(popup)
def relocate(self, x, y): def relocate(self, x, y):
self.x = x + self.table.x self.x = x + self.table.x
self.y = y + self.table.y self.y = y + self.table.y
@ -372,6 +372,7 @@ class Stat_Window:
self.y = y + table.y # x and y are the location relative to table.x & y self.y = y + table.y # x and y are the location relative to table.x & y
self.player_id = player_id # looks like this isn't used ;) self.player_id = player_id # looks like this isn't used ;)
self.sb_click = 0 # used to figure out button clicks self.sb_click = 0 # used to figure out button clicks
self.popups = [] # list of open popups for this stat window
self.useframes = parent.config.get_frames(parent.site) self.useframes = parent.config.get_frames(parent.site)
self.window = gtk.Window() self.window = gtk.Window()
@ -431,6 +432,7 @@ def destroy(*args): # call back for terminating the main eventloop
class Popup_window: class Popup_window:
def __init__(self, parent, stat_window): def __init__(self, parent, stat_window):
self.sb_click = 0 self.sb_click = 0
self.stat_window = stat_window
# create the popup window # create the popup window
self.window = gtk.Window() self.window = gtk.Window()
@ -513,7 +515,8 @@ class Popup_window:
pass pass
if event.button == 3: # right button event if event.button == 3: # right button event
self.window.destroy() self.stat_window.kill_popup(self)
# self.window.destroy()
def toggle_decorated(self, widget): def toggle_decorated(self, widget):
top = widget.get_toplevel() top = widget.get_toplevel()