Skip to content

Commit

Permalink
* [gtk] Handle situation where no folders exist (issue 62)
Browse files Browse the repository at this point in the history
* Remove KeyboardInterrupt handling as it didn't work anyway (issue 3)
* Fix window.get_active_geometry() (issue 77)
* Don't use absolute path name to application icon
* Add 'status' function to init script to meet Redhat sysv init specs
* Bump version and update changelog for v0.71.1 release


git-svn-id: http://autokey.googlecode.com/svn/trunk@303 65b5f37c-86d1-11de-b610-71a7c637a048
  • Loading branch information
cdekter committed Oct 22, 2010
1 parent 3d16b02 commit 4bf2b0c
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 37 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: autokey
Version: 0.71.0
Version: 0.71.1
Summary: Desktop automation utility
Home-page: http://autokey.googlecode.com/
Author: Chris Dekter
Expand Down
5 changes: 1 addition & 4 deletions autokey-gtk
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import sys
from autokey.gtkapp import Application

a = Application()
try:
a.main()
except KeyboardInterrupt:
a.shutdown()
a.main()
sys.exit(0)

5 changes: 1 addition & 4 deletions autokey-qt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import sys
from autokey.qtapp import Application

a = Application()
try:
a.main()
except KeyboardInterrupt:
a.shutdown()
a.main()
sys.exit(0)

16 changes: 12 additions & 4 deletions debian/autokey-common.init
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class AutoKeyDaemon(daemon.Daemon):

def __init__(self):
logFile = "/var/log/autokey-daemon.log"
if os.path.exists(logFile):
shutil.move(logFile, logFile + '.old')
daemon.Daemon.__init__(self, '/var/run/autokey-daemon.pid', stdout=logFile, stderr=logFile)

def get_device_paths(self):
Expand All @@ -45,6 +43,10 @@ class AutoKeyDaemon(daemon.Daemon):

def run(self):
print "AutoKey daemon starting"

if os.path.exists(self.stdout):
shutil.move(self.stdout, self.stdout + '.old')

if os.path.exists(DOMAIN_SOCKET_PATH):
os.remove(DOMAIN_SOCKET_PATH)
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
Expand Down Expand Up @@ -136,13 +138,19 @@ if __name__ == "__main__":
elif 'force-reload' == sys.argv[1]:
# we don't support on-the-fly reloading,
# so just restart the daemon per DPM 9.3.2
daemon.restart()
daemon.restart()
elif 'status' == sys.argv[1]:
if daemon.checkpid():
print "AutoKey daemon is running"
else:
print "AutoKey daemon is stopped"
sys.exit(3)
else:
print "Unknown command"
sys.exit(2)
sys.exit(0)
else:
print "usage: %s {start|stop|restart|force-reload}" % sys.argv[0]
print "usage: %s {status|start|stop|restart|force-reload}" % sys.argv[0]
sys.exit(2)

sys.exit(0)
Expand Down
10 changes: 10 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
autokey (0.71.1-0~maverick) maverick; urgency=low

* [gtk] Handle situation where no folders exist (issue 62)
* Remove KeyboardInterrupt handling as it didn't work anyway (issue 3)
* Fix window.get_active_geometry() (issue 77)
* Don't use absolute path name to application icon
* Add 'status' function to init script to meet Redhat sysv init specs

-- Chris Dekter <[email protected]> Fri, 22 Oct 2010 13:21:11 +1100

autokey (0.71.0-0~lucid) lucid; urgency=low

* Add an import/export facility (issue 58)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name="autokey",
version="0.71.0",
version="0.71.1",
author="Chris Dekter",
author_email="[email protected]",
url="http://autokey.googlecode.com/",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

APP_NAME = "AutoKey"
CATALOG = ""
VERSION = "0.71.0"
VERSION = "0.71.1"
HOMEPAGE = "http://autokey.googlecode.com/"
BUG_EMAIL = "[email protected]"

Expand Down
95 changes: 74 additions & 21 deletions src/lib/gtkui/configwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,33 @@ def __getattr__(self, attr):
# Magic fudge to allow us to pretend to be the ui class we encapsulate
return getattr(self.ui, attr)

class BlankPage:

def __init__(self, parentWindow):
self.parentWindow = parentWindow
builder = get_ui("blankpage.xml")
self.ui = builder.get_object("blankpage")

def load(self, theFolder):
pass

def save(self):
pass

def set_item_title(self, newTitle):
pass

def reset(self):
pass

def validate(self):
return True

def on_modified(self, widget, data=None):
pass

def set_dirty(self):
self.parentWindow.set_dirty(True)

class FolderPage:

Expand Down Expand Up @@ -573,9 +600,12 @@ def __init__(self, app):
#self.uiManager.get_action("/MenuBar/Settings/enable-monitoring").set_active(app.service.is_running())
#self.uiManager.get_action("/MenuBar/Settings/enable-monitoring").set_sensitive(not app.serviceDisabled)

rootIter = self.treeView.get_model().get_iter_root()
self.treeView.get_selection().select_iter(rootIter)
rootIter = self.treeView.get_model().get_iter_root()
if rootIter is not None:
self.treeView.get_selection().select_iter(rootIter)

self.on_tree_selection_changed(self.treeView)

self.treeView.columns_autosize()

width, height = ConfigManager.SETTINGS[WINDOW_DEFAULT_SIZE]
Expand Down Expand Up @@ -606,24 +636,35 @@ def set_dirty(self, dirty):
self.revertButton.set_sensitive(dirty)

def update_actions(self, items, changed):
canCreate = isinstance(items[0], model.Folder) and len(items) == 1
canCopy = True
for item in items:
if isinstance(item, model.Folder):
canCopy = False
break
if len(items) == 0:
canCreate = False
canCopy = False
canRecord = False
enableAny = False
else:
canCreate = isinstance(items[0], model.Folder) and len(items) == 1
canCopy = True
canRecord = isinstance(items[0], model.Script) and len(items) == 1
enableAny = True
for item in items:
if isinstance(item, model.Folder):
canCopy = False
break

self.uiManager.get_action("/MenuBar/File/create").set_sensitive(True)
self.uiManager.get_action("/MenuBar/File/create").set_sensitive(enableAny)
self.uiManager.get_action("/MenuBar/File/create/new-top-folder").set_sensitive(True)
self.uiManager.get_action("/MenuBar/File/create/new-folder").set_sensitive(canCreate)
self.uiManager.get_action("/MenuBar/File/create/new-phrase").set_sensitive(canCreate)
self.uiManager.get_action("/MenuBar/File/create/new-script").set_sensitive(canCreate)
self.uiManager.get_action("/MenuBar/File/import").set_sensitive(canCreate)
self.uiManager.get_action("/MenuBar/File/export").set_sensitive(True)
self.uiManager.get_action("/MenuBar/File/export").set_sensitive(enableAny)

self.uiManager.get_action("/MenuBar/Edit/copy-item").set_sensitive(canCopy)
self.uiManager.get_action("/MenuBar/Edit/cut-item").set_sensitive(enableAny)
self.uiManager.get_action("/MenuBar/Edit/paste-item").set_sensitive(canCreate and len(self.cutCopiedItems) > 0)
self.uiManager.get_action("/MenuBar/Edit/record").set_sensitive(isinstance(items[0], model.Script) and len(items) == 1)
self.uiManager.get_action("/MenuBar/Edit/delete-item").set_sensitive(enableAny)
self.uiManager.get_action("/MenuBar/Edit/rename").set_sensitive(enableAny)
self.uiManager.get_action("/MenuBar/Edit/record").set_sensitive(canRecord)

if changed:
self.uiManager.get_action("/MenuBar/File/save").set_sensitive(False)
Expand Down Expand Up @@ -901,7 +942,7 @@ def __removeItem(self, model, item):
self.treeView.get_selection().select_iter(nextIter)
elif parentIter is not None:
self.treeView.get_selection().select_iter(parentIter)
else:
elif model.iter_n_children(None) > 0:
selectIter = model.iter_nth_child(None, model.iter_n_children(None) - 1)
self.treeView.get_selection().select_iter(selectIter)

Expand Down Expand Up @@ -1023,17 +1064,25 @@ def on_treeview_buttonrelease(self, widget, event, data=None):

def on_tree_selection_changed(self, widget, data=None):
selectedObjects = self.__getTreeSelection()
if len(selectedObjects) == 1:

if len(selectedObjects) == 0:
self.stack.set_current_page(0)
self.set_dirty(False)
self.cancel_record()
self.update_actions(selectedObjects, True)
self.selectedObject = None

elif len(selectedObjects) == 1:
selectedObject = selectedObjects[0]

if isinstance(selectedObject, model.Folder):
self.stack.set_current_page(0)
self.stack.set_current_page(1)
self.folderPage.load(selectedObject)
elif isinstance(selectedObject, model.Phrase):
self.stack.set_current_page(1)
self.stack.set_current_page(2)
self.phrasePage.load(selectedObject)
else:
self.stack.set_current_page(2)
self.stack.set_current_page(3)
self.scriptPage.load(selectedObject)

self.set_dirty(False)
Expand Down Expand Up @@ -1155,20 +1204,22 @@ def __getattr__(self, attr):
def __getTreeSelection(self):
selection = self.treeView.get_selection()
model, items = selection.get_selected_rows()
ret = []

if items:
ret = []
for item in items:
value = model.get_value(model[item].iter, AkTreeModel.OBJECT_COLUMN)
if value.parent not in ret: # Filter out any child objects that belong to a parent already in the list
ret.append(value)
return ret
else:
return None

return ret

def __initStack(self):
self.blankPage = BlankPage(self)
self.folderPage = FolderPage(self)
self.phrasePage = PhrasePage(self)
self.scriptPage = ScriptPage(self)
self.stack.append_page(self.blankPage.ui)
self.stack.append_page(self.folderPage.ui)
self.stack.append_page(self.phrasePage.ui)
self.stack.append_page(self.scriptPage.ui)
Expand Down Expand Up @@ -1205,8 +1256,10 @@ def __getCurrentPage(self):
return self.folderPage
elif isinstance(self.selectedObject, model.Phrase):
return self.phrasePage
else:
elif isinstance(self.selectedObject, model.Script):
return self.scriptPage
else:
return None


class AkTreeModel(gtk.TreeStore):
Expand Down
2 changes: 1 addition & 1 deletion src/lib/scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def get_active_geometry(self):
matchingLine = line

if matchingLine is not None:
output = matchingLine[14:].split(' ')[0:3]
output = matchingLine.split()[2:6]
return map(int, output)
else:
return None
Expand Down

0 comments on commit 4bf2b0c

Please sign in to comment.