Ticket #162: Add-key-bindings-for-window-resizing.patch

File Add-key-bindings-for-window-resizing.patch, 7.8 KB (added by astratto, 3 years ago)

Add key bindings

  • data/guake.schemas

    From b34d0a2bba4f65d95d0dac4d422b0d721fad7578 Mon Sep 17 00:00:00 2001
    From: Stefano Tortarolo <stefano.tortarolo@gmail.com>
    Date: Tue, 21 Jul 2009 14:22:54 +0200
    Subject: [PATCH 4/4] Add key bindings for window resizing
    
    ---
     data/guake.schemas      |   48 ++++++++++++++++++++++++++++++++++
     src/guake.py            |   65 +++++++++++++++++++++++++++++++++++++++++++++-
     src/guake_globals.py.in |    1 +
     src/prefs.py            |    8 ++++++
     4 files changed, 120 insertions(+), 2 deletions(-)
    
    diff --git a/data/guake.schemas b/data/guake.schemas
    index b6b27b6..ae3e527 100644
    a b  
    306306        </schema> 
    307307 
    308308        <schema> 
     309            <key>/schemas/apps/guake/keybindings/local/increase_width</key> 
     310            <applyto>/apps/guake/keybindings/local/increase_width</applyto> 
     311            <owner>guake</owner> 
     312            <type>string</type> 
     313            <default>&lt;Control&gt;&lt;Super&gt;Right</default> 
     314            <locale name="C"> 
     315                <short>Increase width</short> 
     316                <long>Increase main window width.</long> 
     317            </locale> 
     318        </schema> 
     319 
     320        <schema> 
     321            <key>/schemas/apps/guake/keybindings/local/decrease_width</key> 
     322            <applyto>/apps/guake/keybindings/local/decrease_width</applyto> 
     323            <owner>guake</owner> 
     324            <type>string</type> 
     325            <default>&lt;Control&gt;&lt;Super&gt;Left</default> 
     326            <locale name="C"> 
     327                <short>Decrease main window width</short> 
     328                <long>Decrease main window width.</long> 
     329            </locale> 
     330        </schema> 
     331 
     332        <schema> 
     333            <key>/schemas/apps/guake/keybindings/local/increase_height</key> 
     334            <applyto>/apps/guake/keybindings/local/increase_height</applyto> 
     335            <owner>guake</owner> 
     336            <type>string</type> 
     337            <default>&lt;Control&gt;&lt;Super&gt;Up</default> 
     338            <locale name="C"> 
     339                <short>Increase height</short> 
     340                <long>Increase main window height.</long> 
     341            </locale> 
     342        </schema> 
     343 
     344        <schema> 
     345            <key>/schemas/apps/guake/keybindings/local/decrease_height</key> 
     346            <applyto>/apps/guake/keybindings/local/decrease_height</applyto> 
     347            <owner>guake</owner> 
     348            <type>string</type> 
     349            <default>&lt;Control&gt;&lt;Super&gt;Down</default> 
     350            <locale name="C"> 
     351                <short>Decrease main window height</short> 
     352                <long>Decrease main window height.</long> 
     353            </locale> 
     354        </schema> 
     355 
     356        <schema> 
    309357            <key>/schemas/apps/guake/keybindings/local/new_tab</key> 
    310358            <applyto>/apps/guake/keybindings/local/new_tab</applyto> 
    311359            <owner>guake</owner> 
  • src/guake.py

    diff --git a/src/guake.py b/src/guake.py
    index cb7afd4..1bdd0f3 100644
    a b  
    4343from common import test_gconf, pixmapfile, gladefile, ShowableError, _ 
    4444from guake_globals import NAME, VERSION, LOCALE_DIR, KEY, GCONF_PATH, \ 
    4545    TERMINAL_MATCH_EXPRS, TERMINAL_MATCH_TAGS, \ 
    46     ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER 
     46    ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, WINDOW_RESIZING_STEP 
    4747 
    4848pynotify.init('Guake!') 
    4949 
     
    315315 
    316316        keys = ['toggle_fullscreen', 'new_tab', 'close_tab', 'rename_tab', 
    317317                'previous_tab', 'next_tab', 'clipboard_copy', 'clipboard_paste', 
    318                 'quit', 
     318                'quit', 'increase_width', 'decrease_width', 'increase_height', 
     319                'decrease_height', 
    319320                ] 
    320321        for key in keys: 
    321322            notify_add(LKEY(key), self.reload_accelerators) 
     
    354355            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
    355356                                           gtk.main_quit) 
    356357 
     358        key, mask = gtk.accelerator_parse(gets('increase_width')) 
     359        if key > 0: 
     360            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
     361                                           self.guake.accel_wincrease) 
     362 
     363        key, mask = gtk.accelerator_parse(gets('decrease_width')) 
     364        if key > 0: 
     365            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
     366                                           self.guake.accel_wdecrease) 
     367 
     368        key, mask = gtk.accelerator_parse(gets('increase_height')) 
     369        if key > 0: 
     370            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
     371                                           self.guake.accel_hincrease) 
     372 
     373        key, mask = gtk.accelerator_parse(gets('decrease_height')) 
     374        if key > 0: 
     375            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
     376                                           self.guake.accel_hdecrease) 
     377 
    357378        key, mask = gtk.accelerator_parse(gets('new_tab')) 
    358379        if key > 0: 
    359380            self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 
     
    882903 
    883904        return True 
    884905 
     906    def accel_wincrease(self, *args): 
     907        """Callback increase width using the window_width variable 
     908        """ 
     909        width = self.client.get_int(KEY('/general/window_width')) 
     910        if width + WINDOW_RESIZING_STEP >= 100: 
     911            width = 100 
     912        else: 
     913            width += WINDOW_RESIZING_STEP 
     914        self.client.set_int(KEY('/general/window_width'), width) 
     915 
     916    def accel_wdecrease(self, *args): 
     917        """Callback decrease width using the window_width variable 
     918        """ 
     919        width = self.client.get_int(KEY('/general/window_width')) 
     920        if width - WINDOW_RESIZING_STEP <= 0: 
     921            width = WINDOW_RESIZING_STEP 
     922        else: 
     923            width -= WINDOW_RESIZING_STEP 
     924        self.client.set_int(KEY('/general/window_width'), width) 
     925 
     926    def accel_hincrease(self, *args): 
     927        """Callback increase height using the window_height variable 
     928        """ 
     929        height = self.client.get_int(KEY('/general/window_height')) 
     930        if height + WINDOW_RESIZING_STEP >= 100: 
     931            height = 100 
     932        else: 
     933            height += WINDOW_RESIZING_STEP 
     934        self.client.set_int(KEY('/general/window_height'), height) 
     935 
     936    def accel_hdecrease(self, *args): 
     937        """Callback decrease height using the window_height variable 
     938        """ 
     939        height = self.client.get_int(KEY('/general/window_height')) 
     940        if height - WINDOW_RESIZING_STEP <= 0: 
     941            height = WINDOW_RESIZING_STEP 
     942        else: 
     943            height -= WINDOW_RESIZING_STEP 
     944        self.client.set_int(KEY('/general/window_height'), height) 
     945 
    885946    # -- callbacks -- 
    886947 
    887948    def on_terminal_exited(self, term, widget): 
  • src/guake_globals.py.in

    diff --git a/src/guake_globals.py.in b/src/guake_globals.py.in
    index 002e55a..aea240e 100644
    a b  
    5656 
    5757TERMINAL_MATCH_TAGS = 'schema', 'http', 'email' 
    5858ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT = range(3) 
     59WINDOW_RESIZING_STEP = 10 
  • src/prefs.py

    diff --git a/src/prefs.py b/src/prefs.py
    index 92b6293..ab33cdf 100644
    a b  
    5757               'label': _('Toggle Guake visibility')}, 
    5858              {'key': LKEY('toggle_fullscreen'), 
    5959               'label': _('Toggle Fullscreen')}, 
     60              {'key': LKEY('increase_width'), 
     61               'label': _('Increase width')}, 
     62              {'key': LKEY('decrease_width'), 
     63               'label': _('Decrease width')}, 
     64              {'key': LKEY('increase_height'), 
     65               'label': _('Increase height')}, 
     66              {'key': LKEY('decrease_height'), 
     67               'label': _('Decrease height')}, 
    6068              {'key': LKEY('quit'), 
    6169               'label': _('Quit')}, 
    6270              ]},