10 from choices
import settings
14 BGAP
= 1 # Between each bar
15 LGAP
= 2 # Between label and bar
17 class SetOfBars(g
.EventBox
):
18 def __init__(self
, orient
= barwidget
.VERT
, length
= -1,
19 menu_pos_func
= None):
20 g
.EventBox
.__init
__(self
)
21 self
.menu_pos_func
= menu_pos_func
22 self
.layout(orient
, length
)
23 self
.connect("button-press-event", self
.button_cb
)
24 self
.connect("button-release-event", self
.button_cb
)
26 def layout(self
, orient
, length
= -1):
29 if orient
== barwidget
.VERT
:
30 self
.box
= g
.HBox(False, BGAP
)
32 self
.pack
= g
.VBox
.pack_end
34 self
.box
= g
.VBox(False, BGAP
)
36 self
.pack
= g
.HBox
.pack_start
41 for n
in range(settings
.get_num_bars()):
47 def repack(self
, orient
= None, length
= None):
53 self
.layout(orient
, length
)
55 def update_label_font(self
, font_name
= None):
57 font_name
= settings
.get_label_font()
58 pfd
= pango
.FontDescription(font_name
)
62 def add_bar(self
, num
):
63 desc
= plugins
.all_descs
[num
]
64 sub_box
= self
.SubBox(False, LGAP
)
65 l
= g
.Label(desc
.label
)
66 pfd
= pango
.FontDescription(settings
.get_label_font())
68 self
.pack(sub_box
, l
, False, True, 0)
70 b
= barwidget
.BarWidget(desc
, self
.orient
, self
.length
)
71 self
.pack(sub_box
, b
, True, True, 0)
76 def button_cb(self
, widget
, event
):
77 if event
.type == g
.gdk
.BUTTON_RELEASE
and event
.button
== 1:
78 choicesui
.run_dialog(self
)
79 elif event
.type == g
.gdk
.BUTTON_PRESS
and event
.button
== 3:
81 i
= g
.ImageMenuItem(g
.STOCK_ABOUT
)
82 i
.connect("activate", show_about
)
84 i
= g
.ImageMenuItem(g
.STOCK_PREFERENCES
)
85 i
.connect("activate", self
.run_choices_dialog
)
87 i
= g
.ImageMenuItem(g
.STOCK_QUIT
)
88 i
.connect("activate", quit
)
91 menu
.popup(None, None, self
.menu_pos_func
, event
.button
, event
.time
)
93 def run_choices_dialog(self
, item
):
94 choicesui
.run_dialog(self
)
96 def get_bar_widget(self
, num
):
99 def get_label_widget(self
, num
):
100 return self
.labels
[num
]
108 def show_about(item
):
109 global logo
, authors
, version
110 if not authors
and not version
:
111 app_info
= rox
.AppInfo
.AppInfo(os
.path
.join(rox
.app_dir
, 'AppInfo.xml'))
112 authors
= app_info
.getAuthors()
114 app_info
.findElements('Version')[0].firstChild
.nodeValue
.split()[0]
116 authors
= "Tony Houghton"
118 logo
= g
.gdk
.pixbuf_new_from_file_at_size( \
119 os
.path
.join(rox
.app_dir
, '.DirIcon'), 64, 64)
121 d
.set_name("SysBars")
123 d
.set_version(version
)
124 d
.set_copyright("\302\251 Tony Houghton")
125 d
.set_website('http://www.realh.co.uk')
126 d
.set_authors([authors
])