Ticket #30: alt_num_go_to_specific_tab.diff

File alt_num_go_to_specific_tab.diff, 2.2 KB (added by eljunior, 12 months ago)

ugly patch against version 0.4.2 that fix the problem

  • src/guake.py

    diff --git a/src/guake.py b/src/guake.py
    index 6214fb2..a4ec4b6 100644
    a b  
    539539 
    540540        # important widgets 
    541541        self.window = self.get_widget('window-root') 
     542        # ugly hack to shortcut alt-NUM (go to tab) NUM work 
     543        self.gototabgroup = gtk.AccelGroup() 
     544        self.window.add_accel_group(self.gototabgroup) 
    542545        self.notebook = self.get_widget('notebook-teminals') 
    543546        self.tabs = self.get_widget('hbox-tabs') 
    544547        self.toolbar = self.get_widget('toolbar') 
     
    11561159 
    11571160        self.tabs.pack_start(bnt, expand=False, padding=1) 
    11581161        self.tab_counter += 1 
     1162        self.update_accels() 
    11591163 
    11601164        self.notebook.append_page(box, None) 
    11611165        self.notebook.set_current_page(self.notebook.page_num(box)) 
    11621166        self.load_config() 
    11631167 
     1168    def update_accels(self): 
     1169        """Attribute accelerators for first ten tabs""" 
     1170        tabs = self.tabs.get_children() 
     1171        tabaccel = 1 
     1172        for tab in tabs: 
     1173            if tabaccel > 9: 
     1174                break 
     1175            real_accel = ord(str(tabaccel)) 
     1176            if tabaccel == 10: 
     1177                real_accel = ord('0') 
     1178            tab.add_accelerator('clicked', self.gototabgroup, real_accel, gtk.gdk.MOD1_MASK, ()) 
     1179            tabaccel += 1 
     1180 
     1181    def disconnect_accels(self): 
     1182        """Disconnect accelerators (to be called upon deleting a tab)""" 
     1183        for i in range(10): 
     1184            self.gototabgroup.disconnect_key(ord(str(i)), gtk.gdk.MOD1_MASK) 
     1185 
    11641186    def delete_tab(self, pagepos, kill=True): 
    11651187        """This function will destroy the notebook page, terminal and 
    11661188        tab widgets and will call the function to kill interpreter 
    11671189        forked by vte. 
    11681190        """ 
     1191        self.disconnect_accels() 
    11691192        self.tabs.get_children()[pagepos].destroy() 
    11701193        self.notebook.remove_page(pagepos) 
    11711194        self.term_list.pop(pagepos).destroy() 
     
    11781201            self.hide() 
    11791202            # avoiding the delay on next Guake show request 
    11801203            self.add_tab() 
     1204        self.update_accels() 
    11811205 
    11821206    def delete_shell(self, pid): 
    11831207        """This function will kill the shell on a tab, trying to send