Ticket #10: 0002-Allow-window-width-to-be-customized.patch

File 0002-Allow-window-width-to-be-customized.patch, 8.2 KB (added by astratto, 3 years ago)

A patch to allow width resizing

  • data/guake.schemas

    From 75207e168070482f7714d1e06229f463e9941a75 Mon Sep 17 00:00:00 2001
    From: Stefano Tortarolo <stefano.tortarolo@gmail.com>
    Date: Mon, 20 Jul 2009 12:27:39 +0200
    Subject: [PATCH 2/3] Allow window width to be customized
    
    ---
     data/guake.schemas |   15 ++++++++++++++-
     data/prefs.glade   |   41 ++++++++++++++++++++++++++++++++++++++++-
     src/guake.py       |   13 ++++++++-----
     src/prefs.py       |   12 +++++++++++-
     4 files changed, 73 insertions(+), 8 deletions(-)
    
    diff --git a/data/guake.schemas b/data/guake.schemas
    index fb25663..6273c7c 100644
    a b  
    9292            </locale> 
    9393        </schema> 
    9494 
    95         <schema> 
     95        <schema> 
     96            <key>/schemas/apps/guake/general/window_width</key> 
     97            <applyto>/apps/guake/general/window_width</applyto> 
     98            <owner>guake</owner> 
     99            <type>int</type> 
     100            <default>100</default> 
     101            <locale name="C"> 
     102                <short>Window height.</short> 
     103                <long>Percent of the screen that will be used by guake 
     104                  terminal horizontally.</long> 
     105            </locale> 
     106        </schema> 
     107 
     108        <schema> 
    96109            <key>/schemas/apps/guake/general/window_height</key> 
    97110            <applyto>/apps/guake/general/window_height</applyto> 
    98111            <owner>guake</owner> 
  • data/prefs.glade

    diff --git a/data/prefs.glade b/data/prefs.glade
    index 31f348d..798585f 100644
    a b  
    336336                          <widget class="GtkLabel" id="label24"> 
    337337                            <property name="visible">True</property> 
    338338                            <property name="ypad">6</property> 
    339                             <property name="label" translatable="yes">&lt;b&gt;Main Window size&lt;/b&gt;</property> 
     339                            <property name="label" translatable="yes">&lt;b&gt;Main Window height&lt;/b&gt;</property> 
    340340                            <property name="use_markup">True</property> 
    341341                          </widget> 
    342342                          <packing> 
     
    348348                        <property name="position">3</property> 
    349349                      </packing> 
    350350                    </child> 
     351                    <child> 
     352                      <widget class="GtkFrame" id="frame12"> 
     353                        <property name="visible">True</property> 
     354                        <property name="label_xalign">0</property> 
     355                        <property name="shadow_type">GTK_SHADOW_NONE</property> 
     356                        <child> 
     357                          <widget class="GtkAlignment" id="alignment12"> 
     358                            <property name="visible">True</property> 
     359                            <property name="left_padding">12</property> 
     360                            <child> 
     361                              <widget class="GtkHScale" id="window_width"> 
     362                                <property name="visible">True</property> 
     363                                <property name="can_focus">True</property> 
     364                                <property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> 
     365                                <property name="adjustment">50 10 110 10 10 10</property> 
     366                                <property name="digits">0</property> 
     367                                <property name="draw_value">False</property> 
     368                                <property name="value_pos">GTK_POS_RIGHT</property> 
     369                                <signal name="value_changed" handler="on_window_width_value_changed"/> 
     370                              </widget> 
     371                            </child> 
     372                          </widget> 
     373                        </child> 
     374                        <child> 
     375                          <widget class="GtkLabel" id="label25"> 
     376                            <property name="visible">True</property> 
     377                            <property name="ypad">6</property> 
     378                            <property name="label" translatable="yes">&lt;b&gt;Main Window width&lt;/b&gt;</property> 
     379                            <property name="use_markup">True</property> 
     380                          </widget> 
     381                          <packing> 
     382                            <property name="type">label_item</property> 
     383                          </packing> 
     384                        </child> 
     385                      </widget> 
     386                      <packing> 
     387                        <property name="position">4</property> 
     388                      </packing> 
     389                    </child> 
    351390                  </widget> 
    352391                </child> 
    353392                <child> 
  • src/guake.py

    diff --git a/src/guake.py b/src/guake.py
    index e9917fd..270ad48 100644
    a b  
    9595        notify_add(KEY('/general/use_trayicon'), self.trayicon_toggled) 
    9696        notify_add(KEY('/general/window_ontop'), self.ontop_toggled) 
    9797        notify_add(KEY('/general/window_tabbar'), self.tabbar_toggled) 
     98        notify_add(KEY('/general/window_width'), self.size_changed) 
    9899        notify_add(KEY('/general/window_height'), self.size_changed) 
    99100 
    100101        notify_add(KEY('/general/use_scrollbar'), self.scrollbar_toggled) 
     
    145146            self.guake.toolbar.hide() 
    146147 
    147148    def size_changed(self, client, connection_id, entry, data): 
    148         """If the gconf var window_height be changed, this method will 
    149         be called and will call the resize function in guake. 
     149        """If the gconf var window_height or window_width are changed, 
     150        this method will be called and will call the resize function 
     151        in guake. 
    150152        """ 
    151153        window_rect = self.guake.get_final_window_rect() 
    152154        self.guake.window.resize(window_rect.width, window_rect.height) 
     
    738740 
    739741    def get_final_window_rect(self): 
    740742        """Gets the final size of the main window of guake. The height 
    741         is just the window_height property. But width is calculated as 
    742         100% of the screen and tested against the monitor geometry 
    743         width. 
     743        is the window_height property, while width is window_width. 
    744744        """ 
    745745        screen = self.window.get_screen() 
    746746        height = self.client.get_int(KEY('/general/window_height')) 
     747        width = self.client.get_int(KEY('/general/window_width')) 
    747748 
    748749        # get the rectangle just from the first/default monitor in the 
    749750        # future we might create a field to select which monitor you 
     
    751752        window_rect = screen.get_monitor_geometry(0) 
    752753 
    753754        window_rect.height = window_rect.height * height / 100 
     755        window_rect.width = window_rect.width * width / 100 
    754756        return window_rect 
    755757 
    756758    # -- configuration -- 
     
    761763        self.client.notify(KEY('/general/use_trayicon')) 
    762764        self.client.notify(KEY('/general/window_tabbar')) 
    763765        self.client.notify(KEY('/general/window_ontop')) 
     766        self.client.notify(KEY('/general/window_width')) 
    764767        self.client.notify(KEY('/general/window_height')) 
    765768        self.client.notify(KEY('/general/use_scrollbar')) 
    766769        self.client.notify(KEY('/general/history_size')) 
  • src/prefs.py

    diff --git a/src/prefs.py b/src/prefs.py
    index 552fb6c..88daed2 100644
    a b  
    138138        """ 
    139139        self.client.set_bool(KEY('/general/window_tabbar'), chk.get_active()) 
    140140 
     141    def on_window_width_value_changed(self, wscale): 
     142        """Changes the value of window_width in gconf 
     143        """ 
     144        val = wscale.get_value() 
     145        self.client.set_int(KEY('/general/window_width'), int(val)) 
     146 
    141147    def on_window_height_value_changed(self, hscale): 
    142148        """Changes the value of window_height in gconf 
    143149        """ 
     
    397403        value = self.client.get_bool(KEY('/general/window_tabbar')) 
    398404        self.get_widget('window_tabbar').set_active(value) 
    399405 
    400         # size 
     406        # width 
     407        value = float(self.client.get_int(KEY('/general/window_width'))) 
     408        self.get_widget('window_width').set_value(value) 
     409 
     410        # height 
    401411        value = float(self.client.get_int(KEY('/general/window_height'))) 
    402412        self.get_widget('window_height').set_value(value) 
    403413