From 3b54fab9e068466d7752ff90d8bafaa38c8a24e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Oct 2009 07:34:07 -0400 Subject: [PATCH 1/4] remove the exception handler in kill_hud() i think sqlcoder put it in - it doesn't help because the exception isn't a python exception, it's a GTK exception. (looks like a bug in GTK.. not that they'll ever acknowledge anything) --- pyfpdb/HUD_main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 77d8312d..8fd032db 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -116,11 +116,7 @@ class HUD_main(object): # called by an event in the HUD, to kill this specific HUD if table in self.hud_dict: self.hud_dict[table].kill() - try: - # throws exception in windows sometimes (when closing using main_window menu?) - self.hud_dict[table].main_window.destroy() - except: - pass + self.hud_dict[table].main_window.destroy() self.vb.remove(self.hud_dict[table].tablehudlabel) del(self.hud_dict[table]) self.main_window.resize(1,1) From 0a084d11104bdda12196a370892c59561e9febc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Oct 2009 08:27:55 -0400 Subject: [PATCH 2/4] remove try..finally block in HUD_update idle_func function, move return to after the threads_leave() call, HUD now works in Win 7 --- pyfpdb/HUD_main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 8fd032db..021d1ff2 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -127,7 +127,7 @@ class HUD_main(object): def idle_func(): gtk.gdk.threads_enter() - try: + try: # TODO: seriously need to decrease the scope of this block.. what are we expecting to error? newlabel = gtk.Label("%s - %s" % (table.site, table_name)) self.vb.add(newlabel) newlabel.show() @@ -170,12 +170,13 @@ class HUD_main(object): # function idle_func() to be run by the gui thread, at its leisure. def idle_func(): gtk.gdk.threads_enter() - try: - self.hud_dict[table_name].update(new_hand_id, config) - [aw.update_gui(new_hand_id) for aw in self.hud_dict[table_name].aux_windows] - return False - finally: - gtk.gdk.threads_leave() +# try: + self.hud_dict[table_name].update(new_hand_id, config) + [aw.update_gui(new_hand_id) for aw in self.hud_dict[table_name].aux_windows] +# finally: + gtk.gdk.threads_leave() + return False + gobject.idle_add(idle_func) def read_stdin(self): # This is the thread function From f15bb627c0019c893a153e7d4fc2e2c90b71ee8a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2009 01:36:29 -0400 Subject: [PATCH 3/4] add trayicon, minimize to tray by default (doesn't work quite right on windows) --- pyfpdb/fpdb.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 4f3210f4..d23a003e 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -618,7 +618,49 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window.show() self.load_profile() + + self.statusIcon = gtk.StatusIcon() + self.statusIcon.set_from_stock(gtk.STOCK_HOME) + self.statusIcon.set_tooltip("Free Poker Database") + self.statusIcon.connect('activate', self.statusicon_activate) + self.statusMenu = gtk.Menu() + menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) + menuItem.connect('activate', self.dia_about) + self.statusMenu.append(menuItem) + menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) + menuItem.connect('activate', self.quit) + self.statusMenu.append(menuItem) + self.statusIcon.connect('popup-menu', self.statusicon_menu, self.statusMenu) + self.statusIcon.set_visible(True) + + self.window.connect('window-state-event', self.window_state_event_cb) sys.stderr.write("fpdb starting ...") + + def window_state_event_cb(self, window, event): + print "window_state_event", event + if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: + if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED: + print "FPDB minimized" + self.window.set_skip_taskbar_hint(True) + self.window.set_skip_pager_hint(True) + else: + print "FPDB unminimized" + self.window.set_skip_taskbar_hint(False) + self.window.set_skip_pager_hint(False) + + def statusicon_menu(self, widget, button, time, data = None): + # we don't need to pass data here, since we do keep track of most all + # our variables .. the example code that i looked at for this + # didn't use any long scope variables.. which might be an alright + # idea too sometime + if button == 3: + if data: + data.show_all() + data.popup(None, None, None, 3, time) + pass + + def statusicon_activate(self, widget, data = None): + self.window.present() def warning_box(self, str, diatitle="FPDB WARNING"): diaWarning = gtk.Dialog(title=diatitle, parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK)) From 22b3d5de7f14e3ef7852721a0f1778bfec804e9c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2009 05:03:25 -0400 Subject: [PATCH 4/4] should minimize to tray in windows. windows 7's tray doesn't like it much, but it'll get over it for now --- pyfpdb/fpdb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index d23a003e..83e442c1 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -41,6 +41,10 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sy else: pass #print "debug - not changing path" + +if os.name == 'nt': + import win32api + import win32con print "Python " + sys.version[0:3] + '...\n' @@ -639,12 +643,17 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") def window_state_event_cb(self, window, event): print "window_state_event", event if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: + # -20 = GWL_EXSTYLE can't find it in the pywin32 libs + #bits = win32api.GetWindowLong(self.window.window.handle, -20) + #bits = bits ^ (win32con.WS_EX_TOOLWINDOW | win32con.WS_EX_APPWINDOW) + + #win32api.SetWindowLong(self.window.window.handle, -20, bits) + if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED: - print "FPDB minimized" + self.window.hide() self.window.set_skip_taskbar_hint(True) self.window.set_skip_pager_hint(True) else: - print "FPDB unminimized" self.window.set_skip_taskbar_hint(False) self.window.set_skip_pager_hint(False) @@ -660,6 +669,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") pass def statusicon_activate(self, widget, data = None): + self.window.show() self.window.present() def warning_box(self, str, diatitle="FPDB WARNING"):