4
# Copyright (C) 2009 Jason Smith
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
29
from docky.docky import DockyItem, DockySink
30
from signal import signal, SIGTERM
32
except ImportError, e:
35
class DockyTerminalItem(DockyItem):
36
def __init__(self, path):
37
DockyItem.__init__(self, path)
39
client = gconf.client_get_default()
40
self.terminal = client.get_string("/desktop/gnome/applications/terminal/exec")
41
if self.terminal == None:
42
self.terminal = "gnome-terminal"
44
self.path = urllib.unquote(str(self.iface.GetUri ()[7:]))
45
if not os.path.isdir (self.path):
46
self.path = os.path.dirname (self.path)
48
self.add_menu_item("Open Terminal Here", "terminal")
50
def menu_pressed(self, menu_id):
51
if self.id_map[menu_id] == "Open Terminal Here":
54
os.system ('%s &' % self.terminal)
57
def add_menu_item(self, name, icon):
58
menu_id = self.iface.AddMenuItem(name, icon, "actions")
59
self.id_map[menu_id] = name
61
class DockyTerminalSink(DockySink):
62
def item_path_found(self, pathtoitem, item):
63
if item.GetOwnsUri() and item.GetUri().startswith ("file://"):
64
self.items[pathtoitem] = DockyTerminalItem(pathtoitem)
66
dockysink = DockyTerminalSink()
71
if __name__ == "__main__":
72
mainloop = gobject.MainLoop(is_running=True)
74
atexit.register (cleanup)
75
signal(SIGTERM, lambda signum, stack_frame: exit(1))