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
43 | 43 | self.set_icon(string) |
44 | 44 | |
45 | 45 | 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) | |
48 | 51 | else: |
49 | self.image.set_from_icon_name(string, Gtk.IconSize.DIALOG) | |
52 | self.image.set_from_icon_name("image-missing", Gtk.IconSize.DIALOG) | |
50 | 53 | |
51 | 54 | def on_button_press(self, widget, event): |
52 | 55 | # We're simulating a top panel here |
132 | 135 | self.indicator_box.add(self.indicators[name]) |
133 | 136 | self.window.show_all() |
134 | 137 | |
138 | self.sort_icons() | |
139 | ||
135 | 140 | def on_icon_removed(self, monitor, proxy): |
136 | 141 | name = proxy.get_name() |
137 | 142 | |
138 | 143 | self.indicator_box.remove(self.indicators[name]) |
139 | 144 | del(self.indicators[name]) |
140 | 145 | |
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 | ||
141 | 165 | if __name__ == '__main__': |
142 | 166 | applet = StatusApplet() |
143 | 167 | Gtk.main() |