Package dtk :: Package ui :: Module statusbar

Source Code for Module dtk.ui.statusbar

 1  #! /usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  # Copyright (C) 2011 ~ 2012 Deepin, Inc. 
 5  #               2011 ~ 2012 Wang Yong 
 6  #  
 7  # Author:     Wang Yong <lazycat.manatee@gmail.com> 
 8  # Maintainer: Wang Yong <lazycat.manatee@gmail.com> 
 9  #  
10  # This program is free software: you can redistribute it and/or modify 
11  # it under the terms of the GNU General Public License as published by 
12  # the Free Software Foundation, either version 3 of the License, or 
13  # any later version. 
14  #  
15  # This program is distributed in the hope that it will be useful, 
16  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
17  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18  # GNU General Public License for more details. 
19  #  
20  # You should have received a copy of the GNU General Public License 
21  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
22   
23  from box import EventBox 
24  from draw import draw_line 
25  import gobject 
26  import gtk 
27   
28 -class Statusbar(EventBox):
29 ''' 30 Statusbar. 31 32 @undocumented: expose_status_separator 33 ''' 34
35 - def __init__(self, 36 height, 37 add_separator=False):
38 ''' 39 Initialize Statusbar class. 40 41 @param height: Statusbar height. 42 @param add_separator: Whether add separator between statusbar and window body, default is False. 43 ''' 44 # Init. 45 EventBox.__init__(self) 46 self.set_size_request(-1, height) 47 48 # Init status box. 49 self.status_box = gtk.VBox() 50 self.add(self.status_box) 51 52 # Init separator. 53 if add_separator: 54 self.separator = gtk.HBox() 55 self.separator.set_size_request(-1, 2) 56 self.separator.connect("expose-event", self.expose_status_separator) 57 self.status_box.pack_start(self.separator, False, False) 58 59 # Init status item box. 60 self.status_item_box = gtk.HBox() 61 self.status_box.pack_start(self.status_item_box, True, True) 62 63 # Show. 64 self.show_all()
65
66 - def expose_status_separator(self, widget, event):
67 ''' 68 Internal callback for `expose-event` signal. 69 ''' 70 # Init. 71 cr = widget.window.cairo_create() 72 rect = widget.allocation 73 74 # Draw separator. 75 cr.set_source_rgba(0, 0, 0, 0.5) 76 draw_line(cr, rect.x + 1, rect.y + 1, rect.x + rect.width - 1, rect.y + 1) 77 78 cr.set_source_rgba(1, 1, 1, 0.5) 79 draw_line(cr, rect.x + 1, rect.y + 2, rect.x + rect.width - 1, rect.y + 2) 80 81 return True
82 83 gobject.type_register(Statusbar) 84