Ticket #148: guake_with_notification_on_trayicon.py.patch
| File guake_with_notification_on_trayicon.py.patch, 4.1 KB (added by makism, 3 years ago) |
|---|
-
src/guake.py
old new 553 553 # resizer stuff 554 554 self.resizer.connect('motion-notify-event', self.on_resizer_drag) 555 555 556 # supress the notification when creating the first tab 557 self.notification_supress = True 558 559 # notification interval 560 self.notification_interval = 5 * 1000 561 562 # terminals emitting notification ;) 563 self.notification_terms = list () 564 565 # ignore terminals 566 self.notification_ignore = list() 567 568 # add a callback :-) 569 gobject.timeout_add(self.notification_interval, self.notification_for_contents_changes) 570 556 571 # adding the first tab on guake 557 572 self.add_tab() 558 573 … … 612 627 self.losefocus_time = gtk.gdk.x11_get_server_time(self.window.window) 613 628 self.hide() 614 629 630 def on_ignore_output_toggled(self, CheckMenuItem): 631 state = CheckMenuItem.get_active() 632 tab = self.selected_tab 633 634 if state: 635 if tab not in self.notification_ignore: 636 self.notification_ignore.append (tab) 637 else: 638 for idx, t in enumerate(self.notification_ignore): 639 if tab is t: 640 del self.notification_ignore[idx] 641 return 642 615 643 def show_menu(self, *args): 616 644 """Show the tray icon menu. 617 645 """ … … 644 672 self.showing_context_menu = True 645 673 self.selected_tab = target 646 674 menu = self.get_widget('tab-menu') 675 676 if self.selected_tab in self.notification_ignore: 677 menu.get_children()[0].set_active(True) 678 else: 679 menu.get_children()[0].set_active(False) 680 647 681 menu.popup(None, None, None, 3, event.get_time()) 648 682 self.set_terminal_focus() 649 683 … … 664 698 def show_hide(self, *args): 665 699 """Toggles the main window visibility 666 700 """ 701 if len (self.notification_terms) > 0: 702 self.notification_terms = list () 703 if self.tray_icon.get_blinking(): 704 self.tray_icon.set_blinking(False) 705 667 706 event_time = self.hotkeys.get_current_event_time() 668 707 669 708 if self.losefocus_time and \ … … 923 962 924 963 return params 925 964 965 def on_contents_change(self, terminalWidget, terminalId): 966 if self.notification_supress: 967 self.notification_supress = False 968 return 969 970 for idx, term in enumerate(self.term_list): 971 if term is terminalWidget: 972 target_tab = self.tabs.get_children()[idx] 973 if target_tab in self.notification_ignore: 974 return 975 break 976 977 if self.window.get_property('visible') == False: 978 #print "Something happened on terminal %d!" % terminalId 979 if terminalId not in self.notification_terms: 980 self.notification_terms.append (terminalId) 981 else: 982 self.notification_supress = True 983 984 def notification_for_contents_changes(self, *args): 985 if self.notification_supress: 986 return True 987 988 l = len(self.notification_terms) 989 if l > 0: 990 str = "" 991 992 if self.tray_icon.get_blinking() == False: 993 self.tray_icon.set_blinking(True) 994 gobject.timeout_add (30 * 1000, lambda: self.tray_icon.set_blinking(False)) 995 self.notification_terms = list () 996 997 return True 998 926 999 def add_tab(self, *args): 927 1000 """Adds a new tab to the terminal notebook. 928 1001 """ 1002 if len (self.term_list) == 0: 1003 self.notification_supress = True 1004 929 1005 box = GuakeTerminalBox() 930 1006 box.terminal.grab_focus() 931 1007 box.terminal.connect('button-press-event', self.show_context_menu) 932 1008 box.terminal.connect('child-exited', self.on_terminal_exited, box) 1009 box.terminal.connect('contents-changed', self.on_contents_change, len(self.term_list)) 933 1010 box.show() 934 1011 935 1012 last_added = len(self.term_list)