Ticket #158: guake.py.patch
| File guake.py.patch, 3.6 KB (added by makism, 2 years ago) |
|---|
-
src/guake.py
old new 35 35 import sys 36 36 from thread import start_new_thread 37 37 from time import sleep 38 import posix 38 39 39 40 import globalhotkeys 40 41 from simplegladeapp import SimpleGladeApp, bindtextdomain … … 50 51 bindtextdomain(name, locale_dir) 51 52 52 53 54 class PromptQuitDialog(SimpleGladeApp): 55 """Prompts the user whether to quit or not if there are procs running. 56 """ 57 def __init__ (self, parent, runningProcs): 58 super(PromptQuitDialog, self).__init__(gladefile('prompt_on_quit.glade'), 59 root='promptdialog') 60 self.parent = parent 61 self.dialog = self.get_widget('promptdialog') 62 self.dialog.set_keep_above (True) 63 64 self.parent.show_hide () 65 66 if runningProcs == 1: 67 self.get_widget("labelNumberOfProcs").set_markup( 68 "<b>There is one process still running.</b>" 69 ) 70 elif runningProcs > 1: 71 self.get_widget("labelNumberOfProcs").set_markup( 72 "<b>There are %d processes running...</b>" % runningProcs 73 ) 74 75 def on_buttonQuit_clicked(self, Button, *data): 76 gtk.main_quit () 77 78 def on_buttonCancel_clicked(self, Button, *data): 79 self.parent.show_hide () 80 self.dialog.destroy() 81 return gtk.FALSE 82 83 53 84 class AboutDialog(SimpleGladeApp): 54 85 """The About Guake dialog class 55 86 """ … … 337 368 key, mask = gtk.accelerator_parse(gets('quit')) 338 369 if key > 0: 339 370 self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, 340 gtk.main_quit)371 self.guake.accel_quit) 341 372 342 373 key, mask = gtk.accelerator_parse(gets('new_tab')) 343 374 if key > 0: … … 731 762 window_rect.height = window_rect.height * height / 100 732 763 return window_rect 733 764 765 def get_running_fg_processes(self): 766 """Get the number processes for each terminal/tab. The code is taken 767 from gnome-terminal. 768 """ 769 total_procs = 0 770 771 term_idx = 0 772 for terminal in self.term_list: 773 fdpty = terminal.get_pty () 774 term_pid = self.pid_list [term_idx] 775 776 fgpid = posix.tcgetpgrp(fdpty) 777 if fgpid == -1 or fgpid == term_pid: 778 pass 779 else: 780 total_procs += 1 781 782 term_idx += 1 783 784 return total_procs 785 734 786 # -- configuration -- 735 787 736 788 def load_config(self): 737 789 """"Just a proxy for all the configuration stuff. 738 790 """ 739 791 self.client.notify(KEY('/general/use_trayicon')) 792 self.client.notify(KEY('/general/prompt_on_quit')) 740 793 self.client.notify(KEY('/general/window_tabbar')) 741 794 self.client.notify(KEY('/general/window_ontop')) 742 795 self.client.notify(KEY('/general/window_size')) … … 750 803 self.client.notify(KEY('/style/background/transparency')) 751 804 self.client.notify(KEY('/general/use_default_font')) 752 805 806 def accel_quit(self, *args): 807 """Callback to prompt the user whether to quit Guake or not. 808 """ 809 if self.client.get_bool(KEY('/general/prompt_on_quit')): 810 procs = self.get_running_fg_processes() 811 812 if procs >= 1: 813 PromptQuitDialog (self, procs) 814 else: 815 gtk.main_quit () 816 else: 817 gtk.main_quit () 818 753 819 def accel_add(self, *args): 754 820 """Callback to add a new tab. Called by the accel key. 755 821 """