Changeset 7b54f1e9f0b6bd7ef9bb2c833107eaa887fb4896
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rbfa2a8e
|
r7b54f1e
|
|
| 34 | 34 | import signal |
| 35 | 35 | import sys |
| 36 | | import warnings |
| 37 | 36 | from thread import start_new_thread |
| 38 | 37 | from time import sleep |
| 39 | 38 | |
| 40 | | import dbusiface |
| 41 | 39 | import globalhotkeys |
| 42 | 40 | from simplegladeapp import SimpleGladeApp, bindtextdomain |
| … |
… |
|
| 74 | 72 | |
| 75 | 73 | class AboutDialog(SimpleGladeApp): |
| | 74 | """The About Guake dialog class |
| | 75 | """ |
| 76 | 76 | def __init__(self): |
| 77 | 77 | super(AboutDialog, self).__init__(gladefile('about.glade'), |
| 78 | 78 | root='aboutdialog') |
| 79 | | ad = self.get_widget('aboutdialog') |
| | 79 | dialog = self.get_widget('aboutdialog') |
| 80 | 80 | |
| 81 | 81 | # the terminal window can be opened and the user *must* see |
| 82 | 82 | # this window |
| 83 | | ad.set_keep_above(True) |
| | 83 | dialog.set_keep_above(True) |
| 84 | 84 | |
| 85 | 85 | # images |
| 86 | 86 | ipath = pixmapfile('guake-notification.png') |
| 87 | 87 | 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) |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | class Guake(SimpleGladeApp): |
| | 95 | """Guake main class. Handles specialy the main window. |
| | 96 | """ |
| 95 | 97 | def __init__(self): |
| 96 | 98 | super(Guake, self).__init__(gladefile('guake.glade')) |
| 97 | 99 | self.client = gconf.client_get_default() |
| 98 | 100 | self.gconf = GuakeGConf(self) |
| | 101 | |
| 99 | 102 | # setting global hotkey and showing a pretty notification =) |
| 100 | 103 | globalhotkeys.init() |
| … |
… |
|
| 190 | 193 | |
| 191 | 194 | 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)) |
| 193 | 196 | self.resize(*self.get_final_window_size()) |
| 194 | 197 | |
| 195 | | def on_window_lostfocus(self,window, event): |
| | 198 | def on_window_lostfocus(self, window, event): |
| 196 | 199 | getb = lambda x:self.client.get_bool(x) |
| 197 | 200 | value = getb(GCONF_PATH+'general/hide_on_lost_focus') |
| … |
… |
|
| 252 | 255 | |
| 253 | 256 | def show_about(self): |
| | 257 | """Hides the main window and creates an instance of the About |
| | 258 | Dialog. |
| | 259 | """ |
| 254 | 260 | self.hide() |
| 255 | 261 | AboutDialog() |
| 256 | 262 | |
| 257 | 263 | def show_prefs(self): |
| | 264 | """Hides the main window and creates an instance of the |
| | 265 | Preferences window. |
| | 266 | """ |
| 258 | 267 | self.hide() |
| 259 | 268 | PrefsDialog(self).show() |
| … |
… |
|
| 294 | 303 | |
| 295 | 304 | def hide(self): |
| 296 | | self.window.hide() # FIXME: Don't use hide_all here! |
| | 305 | self.window.hide() # Don't use hide_all here! |
| 297 | 306 | self.visible = False |
| 298 | 307 | |
| 299 | 308 | def get_window_size(self): |
| 300 | | screen = self.window.get_screen() |
| | 309 | screen = self.window.get_screen() |
| 301 | 310 | height = self.client.get_int(GCONF_PATH+'general/window_size') |
| | 311 | |
| 302 | 312 | # avoiding X Window system error |
| 303 | 313 | max_height = screen.get_height() |
| 304 | | |
| 305 | 314 | if height > max_height: |
| 306 | 315 | height = max_height |
| 307 | 316 | |
| 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 |
| 311 | 321 | return width, height |
| 312 | 322 | |
| … |
… |
|
| 324 | 334 | |
| 325 | 335 | def load_config(self): |
| | 336 | """"Just a proxy for all the configuration stuff. |
| | 337 | """ |
| 326 | 338 | self.set_fgcolor() |
| 327 | 339 | self.set_font() |
| … |
… |
|
| 332 | 344 | |
| 333 | 345 | def load_accel_map(self): |
| 334 | | # Sets the accel map of quit context option. |
| | 346 | """Sets the accel map of quit context option. |
| | 347 | """ |
| 335 | 348 | key, mask = gtk.accelerator_parse('<Control>q') |
| 336 | 349 | gtk.accel_map_add_entry('<main>/Quit', key, mask) |
| … |
… |
|
| 338 | 351 | |
| 339 | 352 | def load_accelerators(self): |
| | 353 | """Reads all gconf paths under /apps/guake/keybindings/local |
| | 354 | and adds to the main accel_group. |
| | 355 | """ |
| 340 | 356 | gets = lambda x:self.client.get_string(x) |
| 341 | 357 | ac = gets(GCONF_PATH+'keybindings/local/new_tab') |
| … |
… |
|
| 382 | 398 | |
| 383 | 399 | def accel_add(self, *args): |
| | 400 | """Callback to add a new tab. Called by the accel key. |
| | 401 | """ |
| 384 | 402 | self.add_tab() |
| 385 | 403 | return True |
| 386 | 404 | |
| 387 | 405 | def accel_prev(self, *args): |
| | 406 | """Callback to go to the previous tab. Called by the accel key. |
| | 407 | """ |
| 388 | 408 | if self.notebook.get_current_page() == 0: |
| 389 | 409 | self.notebook.set_current_page(self.notebook.get_n_pages()-1) |
| … |
… |
|
| 393 | 413 | |
| 394 | 414 | def accel_next(self, *args): |
| | 415 | """Callback to go to the next tab. Called by the accel key. |
| | 416 | """ |
| 395 | 417 | if self.notebook.get_current_page()+1 == self.notebook.get_n_pages(): |
| 396 | 418 | self.notebook.set_current_page(0) |
| … |
… |
|
| 400 | 422 | |
| 401 | 423 | def accel_copy_clipboard(self, *args): |
| | 424 | """Callback to copy text in the shown terminal. Called by the |
| | 425 | accel key. |
| | 426 | """ |
| 402 | 427 | pos = self.notebook.get_current_page() |
| 403 | 428 | self.term_list[pos].copy_clipboard() |
| … |
… |
|
| 405 | 430 | |
| 406 | 431 | def accel_paste_clipboard(self, *args): |
| | 432 | """Callback to paste text in the shown terminal. Called by the |
| | 433 | accel key. |
| | 434 | """ |
| 407 | 435 | pos = self.notebook.get_current_page() |
| 408 | 436 | self.term_list[pos].paste_clipboard() |
| … |
… |
|
| 410 | 438 | |
| 411 | 439 | 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 | """ |
| 412 | 445 | gbool = lambda x: self.client.get_bool(GCONF_PATH+'general/%s' % x) |
| 413 | 446 | tabs_visible = gbool("toolbar_visible_in_fullscreen") |
| … |
… |
|
| 483 | 516 | |
| 484 | 517 | 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') |
| 486 | 519 | delete = self.client.get_string(GCONF_PATH+'general/compat_delete') |
| 487 | 520 | for i in self.term_list: |
| 488 | | i.set_backspace_binding(backspace) |
| | 521 | i.set_backspace_binding(bkspace) |
| 489 | 522 | i.set_delete_binding(delete) |
| 490 | 523 | |
| … |
… |
|
| 623 | 656 | self.term_list[last_added].set_background_transparent(not use_bgimage) |
| 624 | 657 | |
| 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) |
| 630 | 664 | |
| 631 | 665 | 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) |
| 633 | 667 | self.term_list[last_added].set_sensitive(True) |
| 634 | 668 | |
| … |
… |
|
| 636 | 670 | self.term_list[last_added].set_flags(gtk.CAN_FOCUS) |
| 637 | 671 | self.term_list[last_added].connect('child-exited', |
| 638 | | self.on_terminal_exited, mhbox) |
| | 672 | self.on_terminal_exited, |
| | 673 | mhbox) |
| 639 | 674 | self.term_list[last_added].grab_focus() |
| 640 | 675 | |
| … |
… |
|
| 664 | 699 | |
| 665 | 700 | 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 |
| 667 | 702 | a sigterm and if it doesn't work, a sigkill. Between these two |
| 668 | 703 | signals, we have a timeout of 3 seconds, so is recommended to |