Codebase list xapp / 3483223
test-scripts: have xapp-status-applet sort icons in the same manner the real applets do (symbolic to the right, then by alpha process name). Michael Webster 4 years ago
1 changed file(s) with 27 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4343 self.set_icon(string)
4444
4545 def set_icon(self, string):
46 if os.path.exists(string):
47 self.image.set_from_file(string)
46 if string:
47 if string and os.path.exists(string):
48 self.image.set_from_file(string)
49 else:
50 self.image.set_from_icon_name(string, Gtk.IconSize.DIALOG)
4851 else:
49 self.image.set_from_icon_name(string, Gtk.IconSize.DIALOG)
52 self.image.set_from_icon_name("image-missing", Gtk.IconSize.DIALOG)
5053
5154 def on_button_press(self, widget, event):
5255 # We're simulating a top panel here
132135 self.indicator_box.add(self.indicators[name])
133136 self.window.show_all()
134137
138 self.sort_icons()
139
135140 def on_icon_removed(self, monitor, proxy):
136141 name = proxy.get_name()
137142
138143 self.indicator_box.remove(self.indicators[name])
139144 del(self.indicators[name])
140145
146 self.sort_icons()
147
148 def sort_icons(self, status_icon=None):
149 icon_list = list(self.indicators.values())
150
151 # for i in icon_list:
152 # print("before: ", i.proxy.props.icon_name, i.proxy.props.name.lower())
153
154 icon_list.sort(key=lambda icon: icon.proxy.props.name.lower())
155 icon_list.sort(key=lambda icon: icon.proxy.props.icon_name.lower().endswith("symbolic"))
156
157 # for i in icon_list:
158 # print("after: ", i.proxy.props.icon_name, i.proxy.props.name.lower())
159
160 icon_list.reverse()
161
162 for icon in icon_list:
163 self.indicator_box.reorder_child(icon, 0)
164
141165 if __name__ == '__main__':
142166 applet = StatusApplet()
143167 Gtk.main()