some cleanups and comments
This commit is contained in:
parent
336fee0f3d
commit
e5782dd736
|
@ -204,15 +204,19 @@ class GuiAutoImport (threading.Thread):
|
|||
# That is not correct. It should open another dir for importing while piping the
|
||||
# results to the same pipe. This means that self.path should be a a list of dirs
|
||||
# to watch.
|
||||
if widget.get_active() or data == "autostart": # toggled on
|
||||
if data == "autostart":
|
||||
self.startButton.set_active(True)
|
||||
return
|
||||
|
||||
if widget == self.startButton and self.startButton.get_active():
|
||||
# - Does the lock acquisition need to be more sophisticated for multiple dirs?
|
||||
# (see comment above about what to do if pipe already open)
|
||||
# - Ideally we want to release the lock if the auto-import is killed by some
|
||||
# kind of exception - is this possible?
|
||||
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||
if self.settings['global_lock'].acquire(False, source="AutoImport"): # returns false immediately if lock not acquired
|
||||
self.addText(_("\nGlobal lock taken ... Auto Import Started.\n"))
|
||||
self.doAutoImportBool = True
|
||||
widget.set_label(_(u' _Stop Auto Import '))
|
||||
self.startButton.set_label(_(u' _Stop Auto Import '))
|
||||
while gtk.events_pending(): # change the label NOW don't wait for the pipe to open
|
||||
gtk.main_iteration(False)
|
||||
if self.pipe_to_hud is None:
|
||||
|
|
|
@ -964,7 +964,7 @@ class fpdb:
|
|||
self.quitting = True
|
||||
# TODO: check if current settings differ from profile, if so offer to save or abort
|
||||
|
||||
if self.db!=None:
|
||||
if self.db is not None:
|
||||
if self.db.backend == self.db.MYSQL_INNODB:
|
||||
try:
|
||||
import _mysql_exceptions
|
||||
|
@ -1096,8 +1096,11 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
self.db = None
|
||||
self.status_bar = None
|
||||
self.quitting = False
|
||||
|
||||
self.visible = False
|
||||
self.threads = [] # objects used by tabs - no need for threads, gtk handles it
|
||||
self.closeq = Queue.Queue(20) # used to signal ending of a thread (only logviewer for now)
|
||||
|
||||
# create window, move it to specific location on command line
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
if options.xloc is not None or options.yloc is not None:
|
||||
if options.xloc is None:
|
||||
|
@ -1106,9 +1109,11 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
options.yloc = 0
|
||||
self.window.move(options.xloc,options.yloc)
|
||||
|
||||
# connect to required events
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.set_title("Free Poker DB - v%s" % (VERSION, ))
|
||||
# set a default x/y size for the window
|
||||
self.window.set_border_width(1)
|
||||
defx, defy = 900, 720
|
||||
sx, sy = gtk.gdk.screen_width(), gtk.gdk.screen_height()
|
||||
|
@ -1117,19 +1122,18 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
self.window.set_default_size(defx, defy)
|
||||
self.window.set_resizable(True)
|
||||
|
||||
# main area of window
|
||||
self.main_vbox = gtk.VBox(False, 1)
|
||||
self.main_vbox.set_border_width(1)
|
||||
self.window.add(self.main_vbox)
|
||||
self.main_vbox.show()
|
||||
|
||||
# create our Main Menu Bar
|
||||
menubar = self.get_menu(self.window)
|
||||
self.main_vbox.pack_start(menubar, False, True, 0)
|
||||
menubar.show()
|
||||
#done menubar
|
||||
|
||||
self.threads = [] # objects used by tabs - no need for threads, gtk handles it
|
||||
self.closeq = Queue.Queue(20) # used to signal ending of a thread (only logviewer for now)
|
||||
|
||||
# create a tab bar
|
||||
self.nb = gtk.Notebook()
|
||||
self.nb.set_show_tabs(True)
|
||||
self.nb.show()
|
||||
|
@ -1139,8 +1143,10 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
self.pages = [] # the contents of the page, not removed if tab is closed
|
||||
self.nb_tab_names = [] # list of tab names currently displayed in notebook
|
||||
|
||||
# create the first tab
|
||||
self.tab_main_help(None, None)
|
||||
|
||||
# determine window visibility from command line options
|
||||
if options.minimized:
|
||||
self.window.iconify()
|
||||
if options.hidden:
|
||||
|
@ -1149,8 +1155,10 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
if not options.hidden:
|
||||
self.window.show()
|
||||
self.visible = True # Flip on
|
||||
|
||||
self.load_profile(create_db = True)
|
||||
|
||||
# setup error logging
|
||||
if not options.errorsToConsole:
|
||||
fileName = os.path.join(self.config.dir_log, 'fpdb-errors.txt')
|
||||
print (_("\nNote: error output is being diverted to fpdb-errors.txt and HUD-errors.txt in: %s") % self.config.dir_log) \
|
||||
|
@ -1158,6 +1166,7 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
errorFile = open(fileName, 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
||||
# set up tray-icon and menu
|
||||
self.statusIcon = gtk.StatusIcon()
|
||||
# use getcwd() here instead of sys.path[0] so that py2exe works:
|
||||
cards = os.path.join(os.getcwd(), '..','gfx','fpdb-cards.png')
|
||||
|
@ -1173,13 +1182,10 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
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)
|
||||
# set default menu options
|
||||
self.addImageToTrayMenu(gtk.STOCK_ABOUT, self.dia_about)
|
||||
self.addImageToTrayMenu(gtk.STOCK_QUIT, self.quit)
|
||||
|
||||
self.statusIcon.connect('popup-menu', self.statusicon_menu, self.statusMenu)
|
||||
self.statusIcon.set_visible(True)
|
||||
|
@ -1190,6 +1196,25 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
if options.autoimport:
|
||||
self.tab_auto_import(None)
|
||||
|
||||
def addImageToTrayMenu(self, image, event=None):
|
||||
menuItem = gtk.ImageMenuItem(image)
|
||||
if event is not None:
|
||||
menuItem.connect('activate', event)
|
||||
self.statusMenu.append(menuItem)
|
||||
menuItem.show()
|
||||
return menuItem
|
||||
|
||||
def addLabelToTrayMenu(self, label, event=None):
|
||||
menuItem = gtk.MenuItem(label)
|
||||
if event is not None:
|
||||
menuItem.connect('activate', event)
|
||||
self.statusMenu.append(menuItem)
|
||||
menuItem.show()
|
||||
return menuItem
|
||||
|
||||
def removeFromTrayMenu(self, menuItem):
|
||||
menuItem.destroy()
|
||||
menuItem = None
|
||||
|
||||
def __iconify(self):
|
||||
self.visible = False
|
||||
|
|
Loading…
Reference in New Issue
Block a user