From 69b064dd973afa37b71958d1fcd25ea6b7b18b8c Mon Sep 17 00:00:00 2001
From: Cyril Peponnet <nexus@aflb.com>
Date: Thu, 3 Sep 2009 16:25:06 +0200
Subject: [PATCH] Add cmd line parameter to launch several nammed tabs and exectue command
---
ChangeLog | 6 ++++++
src/dbusiface.py | 4 ++++
src/guake.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d11c95b..9f7d5e0 100644
|
a
|
b
|
|
| | 1 | 2009-09-03 Cyril Peponnet <nexus@aflb.com> |
| | 2 | |
| | 3 | * FEATURE : adding a cmd line parameter to read a file with tab/name/command settings |
| | 4 | * src/guake.py : adding load_conf_tab def, parameters, modify add_tab and hide_context_menu, adding import re |
| | 5 | * src/dbusiface.py : adding load_conf_tab method |
| | 6 | |
| 1 | 7 | 2008-11-25 Gabriel Falcão <gabriel@nacaolivre.org> |
| 2 | 8 | |
| 3 | 9 | * src/guake.py: Applying Licio's (liciofernando@gmail.com) patch for |
diff --git a/src/dbusiface.py b/src/dbusiface.py
index f4b490f..cee2f44 100644
|
a
|
b
|
|
| 38 | 38 | @dbus.service.method(DBUS_NAME) |
| 39 | 39 | def show_hide(self): |
| 40 | 40 | self.guake.show_hide() |
| | 41 | |
| | 42 | @dbus.service.method(DBUS_NAME, in_signature='s') |
| | 43 | def load_conf_tab(self, config=''): |
| | 44 | self.guake.load_conf_tab(config) |
| 41 | 45 | |
| 42 | 46 | @dbus.service.method(DBUS_NAME, in_signature='s') |
| 43 | 47 | def add_tab(self, directory=''): |
diff --git a/src/guake.py b/src/guake.py
index 2f444ff..d8b6cf6 100644
|
a
|
b
|
|
| 35 | 35 | import signal |
| 36 | 36 | from thread import start_new_thread |
| 37 | 37 | from time import sleep |
| | 38 | import re |
| 38 | 39 | |
| 39 | 40 | import globalhotkeys |
| 40 | 41 | from simplegladeapp import SimpleGladeApp, bindtextdomain |
| … |
… |
|
| 560 | 561 | self.resizer.connect('motion-notify-event', self.on_resizer_drag) |
| 561 | 562 | |
| 562 | 563 | # adding the first tab on guake |
| 563 | | self.add_tab() |
| | 564 | # REMOVED : not really usefull because if we spawn without a term, it is created in show def |
| | 565 | #self.add_tab() |
| 564 | 566 | |
| 565 | 567 | # loading and setting up configuration stuff |
| 566 | 568 | GConfHandler(self) |
| … |
… |
|
| 591 | 593 | 'press <b>%s</b> to use it.') % label, filename) |
| 592 | 594 | notification.show() |
| 593 | 595 | |
| | 596 | def load_conf_tab(self, config): |
| | 597 | """Method that read an existing config file to set some tabs at launch |
| | 598 | and exectute some commands in them |
| | 599 | """ |
| | 600 | self.conffilepath = os.path.expanduser(config) |
| | 601 | try: |
| | 602 | self.conffile = open(self.conffilepath,'r') |
| | 603 | for line in self.conffile: |
| | 604 | # check if the line begin with # and ignore them |
| | 605 | if re.match("^#|^\n",line): |
| | 606 | continue |
| | 607 | tabprop = line.split(";") |
| | 608 | if len(tabprop) == 1: |
| | 609 | self.add_tab(tabprop[0]) |
| | 610 | else: |
| | 611 | self.add_tab(tabprop[0],tabprop[1].replace("\\n","\n")) |
| | 612 | |
| | 613 | except IOError as (errno, strerror): |
| | 614 | print "Error : No config file found !" |
| | 615 | |
| | 616 | except: |
| | 617 | print "Error reading file" |
| | 618 | |
| 594 | 619 | def execute_command(self, command, tab=None): |
| 595 | 620 | """Execute the `command' in the `tab'. If tab is None, the |
| 596 | 621 | command will be executed in the currently selected |
| … |
… |
|
| 965 | 990 | |
| 966 | 991 | return params |
| 967 | 992 | |
| 968 | | def add_tab(self, directory=None): |
| | 993 | def add_tab(self, name=None, command=None, directory=None): |
| 969 | 994 | """Adds a new tab to the terminal notebook. |
| 970 | 995 | """ |
| 971 | 996 | box = GuakeTerminalBox() |
| … |
… |
|
| 988 | 1013 | pid = box.terminal.fork_command(**final_params) |
| 989 | 1014 | self.pid_list.append(pid) |
| 990 | 1015 | |
| 991 | | # Adding a new radio button to the tabbar |
| 992 | | label = _('Terminal %s') % self.tab_counter |
| | 1016 | # Adding a new radio button to the tabbar, check if we put a name |
| | 1017 | if name == None: |
| | 1018 | label = _('Terminal %s') % self.tab_counter |
| | 1019 | else: |
| | 1020 | label = name.replace("\n","") |
| | 1021 | |
| | 1022 | # if we have somting to execute, do it |
| | 1023 | if command != None: |
| | 1024 | box.terminal.feed_child(command) |
| | 1025 | |
| 993 | 1026 | tabs = self.tabs.get_children() |
| 994 | 1027 | parent = tabs and tabs[0] or None |
| 995 | 1028 | |
| … |
… |
|
| 1090 | 1123 | """ |
| 1091 | 1124 | from optparse import OptionParser |
| 1092 | 1125 | parser = OptionParser() |
| | 1126 | |
| | 1127 | parser.add_option('-c', '--config', dest='config', |
| | 1128 | action='store', default=False, |
| | 1129 | help=_('Use a config file to add names tabs and launch commands')) |
| | 1130 | |
| 1093 | 1131 | parser.add_option('-t', '--toggle-visibility', dest='show_hide', |
| 1094 | 1132 | action='store_true', default=False, |
| 1095 | 1133 | help=_('Toggles the visibility of the terminal window')) |
| … |
… |
|
| 1141 | 1179 | already_running = False |
| 1142 | 1180 | |
| 1143 | 1181 | called_with_param = False |
| | 1182 | |
| | 1183 | if options.config: |
| | 1184 | remote_object.load_conf_tab(options.config) |
| | 1185 | called_with_param = True |
| 1144 | 1186 | |
| 1145 | 1187 | if options.show_hide: |
| 1146 | | remote_object.show_hide() |
| | 1188 | remote_object.show_hide |
| | 1189 | called_with_param = True() |
| 1147 | 1190 | called_with_param = True |
| 1148 | 1191 | |
| 1149 | 1192 | if options.show_preferences: |