Changeset 7b54f1e9f0b6bd7ef9bb2c833107eaa887fb4896

Show
Ignore:
Timestamp:
12/17/08 19:55:30 (3 years ago)
Author:
Lincoln de Sousa <lincoln@…>
Children:
12326de82f59f708023edba4e431e5d50283c683
Parents:
1b0c2e65c9719e00c4bd748054c3b70593c8ebcd
git-committer:
Lincoln de Sousa <lincoln@…> (12/17/08 19:55:30)
Message:

Cosmetic updates to improve the code quality
and some documentation improvement

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/guake.py

    rbfa2a8e r7b54f1e  
    3434import signal 
    3535import sys 
    36 import warnings 
    3736from thread import start_new_thread 
    3837from time import sleep 
    3938 
    40 import dbusiface 
    4139import globalhotkeys 
    4240from simplegladeapp import SimpleGladeApp, bindtextdomain 
     
    7472 
    7573class AboutDialog(SimpleGladeApp): 
     74    """The About Guake dialog class 
     75    """ 
    7676    def __init__(self): 
    7777        super(AboutDialog, self).__init__(gladefile('about.glade'), 
    7878                                          root='aboutdialog') 
    79         ad = self.get_widget('aboutdialog') 
     79        dialog = self.get_widget('aboutdialog') 
    8080 
    8181        # the terminal window can be opened and the user *must* see 
    8282        # this window 
    83         ad.set_keep_above(True) 
     83        dialog.set_keep_above(True) 
    8484 
    8585        # images 
    8686        ipath = pixmapfile('guake-notification.png') 
    8787        img = gtk.gdk.pixbuf_new_from_file(ipath) 
    88         ad.set_property('logo', img) 
    89  
    90         ad.set_name('Guake!') 
    91         ad.set_version(version) 
     88        dialog.set_property('logo', img) 
     89 
     90        dialog.set_name('Guake!') 
     91        dialog.set_version(version) 
    9292 
    9393 
    9494class Guake(SimpleGladeApp): 
     95    """Guake main class. Handles specialy the main window. 
     96    """ 
    9597    def __init__(self): 
    9698        super(Guake, self).__init__(gladefile('guake.glade')) 
    9799        self.client = gconf.client_get_default() 
    98100        self.gconf = GuakeGConf(self) 
     101 
    99102        # setting global hotkey and showing a pretty notification =) 
    100103        globalhotkeys.init() 
     
    190193             
    191194        if 'GDK_BUTTON1_MASK' in mod.value_names: 
    192             self.client.set_int(GCONF_PATH + 'general/window_size', int(percent)) 
     195            self.client.set_int(GCONF_PATH+'general/window_size', int(percent)) 
    193196            self.resize(*self.get_final_window_size()) 
    194197 
    195     def on_window_lostfocus(self,window, event): 
     198    def on_window_lostfocus(self, window, event): 
    196199        getb = lambda x:self.client.get_bool(x) 
    197200        value = getb(GCONF_PATH+'general/hide_on_lost_focus') 
     
    252255 
    253256    def show_about(self): 
     257        """Hides the main window and creates an instance of the About 
     258        Dialog. 
     259        """ 
    254260        self.hide() 
    255261        AboutDialog() 
    256262 
    257263    def show_prefs(self): 
     264        """Hides the main window and creates an instance of the 
     265        Preferences window. 
     266        """ 
    258267        self.hide() 
    259268        PrefsDialog(self).show() 
     
    294303 
    295304    def hide(self): 
    296         self.window.hide() # FIXME: Don't use hide_all here! 
     305        self.window.hide() # Don't use hide_all here! 
    297306        self.visible = False 
    298307 
    299308    def get_window_size(self): 
    300         screen = self.window.get_screen() 
     309        screen = self.window.get_screen() 
    301310        height = self.client.get_int(GCONF_PATH+'general/window_size') 
     311 
    302312        # avoiding X Window system error 
    303313        max_height = screen.get_height() 
    304  
    305314        if height > max_height: 
    306315            height = max_height 
    307316 
    308         # get the width just from the first/default monitor 
    309         # in the future we might create a field to select which monitor you wanna use 
    310         width = screen.get_monitor_geometry(0).width 
     317        # get the width just from the first/default monitor in the 
     318        # future we might create a field to select which monitor you 
     319        # wanna use 
     320        width = screen.get_monitor_geometry(0).width 
    311321        return width, height 
    312322 
     
    324334 
    325335    def load_config(self): 
     336        """"Just a proxy for all the configuration stuff. 
     337        """ 
    326338        self.set_fgcolor() 
    327339        self.set_font() 
     
    332344 
    333345    def load_accel_map(self): 
    334         # Sets the accel map of quit context option. 
     346        """Sets the accel map of quit context option. 
     347        """ 
    335348        key, mask = gtk.accelerator_parse('<Control>q') 
    336349        gtk.accel_map_add_entry('<main>/Quit', key, mask) 
     
    338351 
    339352    def load_accelerators(self): 
     353        """Reads all gconf paths under /apps/guake/keybindings/local 
     354        and adds to the main accel_group. 
     355        """ 
    340356        gets = lambda x:self.client.get_string(x) 
    341357        ac = gets(GCONF_PATH+'keybindings/local/new_tab') 
     
    382398 
    383399    def accel_add(self, *args): 
     400        """Callback to add a new tab. Called by the accel key. 
     401        """ 
    384402        self.add_tab() 
    385403        return True 
    386404 
    387405    def accel_prev(self, *args): 
     406        """Callback to go to the previous tab. Called by the accel key. 
     407        """ 
    388408        if self.notebook.get_current_page() == 0: 
    389409            self.notebook.set_current_page(self.notebook.get_n_pages()-1) 
     
    393413 
    394414    def accel_next(self, *args): 
     415        """Callback to go to the next tab. Called by the accel key. 
     416        """ 
    395417        if self.notebook.get_current_page()+1 == self.notebook.get_n_pages(): 
    396418            self.notebook.set_current_page(0) 
     
    400422 
    401423    def accel_copy_clipboard(self, *args): 
     424        """Callback to copy text in the shown terminal. Called by the 
     425        accel key. 
     426        """ 
    402427        pos = self.notebook.get_current_page() 
    403428        self.term_list[pos].copy_clipboard() 
     
    405430 
    406431    def accel_paste_clipboard(self, *args): 
     432        """Callback to paste text in the shown terminal. Called by the 
     433        accel key. 
     434        """ 
    407435        pos = self.notebook.get_current_page() 
    408436        self.term_list[pos].paste_clipboard() 
     
    410438 
    411439    def accel_toggle_fullscreen(self, *args): 
     440        """Callback toggle the fullscreen status of the main 
     441        window. It uses the toolbar_visible_in_fullscreen variable 
     442        from gconf to decide if the tabbar will or not be 
     443        shown. Called by the accel key. 
     444        """ 
    412445        gbool = lambda x: self.client.get_bool(GCONF_PATH+'general/%s' % x) 
    413446        tabs_visible = gbool("toolbar_visible_in_fullscreen") 
     
    483516 
    484517    def set_erasebindings(self): 
    485         backspace = self.client.get_string(GCONF_PATH+'general/compat_backspace') 
     518        bkspace = self.client.get_string(GCONF_PATH+'general/compat_backspace') 
    486519        delete = self.client.get_string(GCONF_PATH+'general/compat_delete') 
    487520        for i in self.term_list: 
    488             i.set_backspace_binding(backspace) 
     521            i.set_backspace_binding(bkspace) 
    489522            i.set_delete_binding(delete) 
    490523 
     
    623656        self.term_list[last_added].set_background_transparent(not use_bgimage) 
    624657 
    625         # TODO: maybe the better way is give these choices to the user... 
    626         self.term_list[last_added].set_audible_bell(False) # without boring beep 
    627         self.term_list[last_added].set_visible_bell(False) # without visible beep 
    628         self.term_list[last_added].set_scroll_on_output(True) # auto scroll 
    629         self.term_list[last_added].set_scroll_on_keystroke(True) # auto scroll 
     658        self.term_list[last_added].set_audible_bell(False) 
     659        self.term_list[last_added].set_visible_bell(False) 
     660 
     661        # TODO: make configurable by gconf optional 
     662        self.term_list[last_added].set_scroll_on_output(True) 
     663        self.term_list[last_added].set_scroll_on_keystroke(True) 
    630664 
    631665        history_size = self.client.get_int(GCONF_PATH+'general/history_size') 
    632         self.term_list[last_added].set_scrollback_lines(history_size) # history size 
     666        self.term_list[last_added].set_scrollback_lines(history_size) 
    633667        self.term_list[last_added].set_sensitive(True) 
    634668         
     
    636670        self.term_list[last_added].set_flags(gtk.CAN_FOCUS) 
    637671        self.term_list[last_added].connect('child-exited', 
    638                 self.on_terminal_exited, mhbox) 
     672                                           self.on_terminal_exited, 
     673                                           mhbox) 
    639674        self.term_list[last_added].grab_focus() 
    640675 
     
    664699 
    665700    def delete_shell(self, pid): 
    666         """This function will kill the shell on a tab, trying to sent 
     701        """This function will kill the shell on a tab, trying to send 
    667702        a sigterm and if it doesn't work, a sigkill. Between these two 
    668703        signals, we have a timeout of 3 seconds, so is recommended to