Ticket #173: 0001-Add-cmd-line-parameter-to-launch-several-nammed-tabs.patch

File 0001-Add-cmd-line-parameter-to-launch-several-nammed-tabs.patch, 4.9 KB (added by cpeponnet, 3 years ago)
  • ChangeLog

    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  
     12009-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 
    172008-11-25  Gabriel Falcão <gabriel@nacaolivre.org> 
    28 
    39        * src/guake.py: Applying Licio's (liciofernando@gmail.com) patch for 
  • src/dbusiface.py

    diff --git a/src/dbusiface.py b/src/dbusiface.py
    index f4b490f..cee2f44 100644
    a b  
    3838    @dbus.service.method(DBUS_NAME) 
    3939    def show_hide(self): 
    4040        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) 
    4145 
    4246    @dbus.service.method(DBUS_NAME, in_signature='s') 
    4347    def add_tab(self, directory=''): 
  • src/guake.py

    diff --git a/src/guake.py b/src/guake.py
    index 2f444ff..d8b6cf6 100644
    a b  
    3535import signal 
    3636from thread import start_new_thread 
    3737from time import sleep 
     38import re 
    3839 
    3940import globalhotkeys 
    4041from simplegladeapp import SimpleGladeApp, bindtextdomain 
     
    560561        self.resizer.connect('motion-notify-event', self.on_resizer_drag) 
    561562 
    562563        # 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() 
    564566 
    565567        # loading and setting up configuration stuff 
    566568        GConfHandler(self) 
     
    591593                  'press <b>%s</b> to use it.') % label, filename) 
    592594            notification.show() 
    593595 
     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                 
    594619    def execute_command(self, command, tab=None): 
    595620        """Execute the `command' in the `tab'. If tab is None, the 
    596621        command will be executed in the currently selected 
     
    965990 
    966991        return params 
    967992 
    968     def add_tab(self, directory=None): 
     993    def add_tab(self, name=None, command=None, directory=None): 
    969994        """Adds a new tab to the terminal notebook. 
    970995        """ 
    971996        box = GuakeTerminalBox() 
     
    9881013        pid = box.terminal.fork_command(**final_params) 
    9891014        self.pid_list.append(pid) 
    9901015 
    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 
    9931026        tabs = self.tabs.get_children() 
    9941027        parent = tabs and tabs[0] or None 
    9951028 
     
    10901123    """ 
    10911124    from optparse import OptionParser 
    10921125    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 
    10931131    parser.add_option('-t', '--toggle-visibility', dest='show_hide', 
    10941132            action='store_true', default=False, 
    10951133            help=_('Toggles the visibility of the terminal window')) 
     
    11411179        already_running = False 
    11421180 
    11431181    called_with_param = False 
     1182    
     1183    if options.config: 
     1184        remote_object.load_conf_tab(options.config) 
     1185        called_with_param = True 
    11441186 
    11451187    if options.show_hide: 
    1146         remote_object.show_hide() 
     1188        remote_object.show_hide 
     1189        called_with_param = True() 
    11471190        called_with_param = True 
    11481191 
    11491192    if options.show_preferences: