mate-xapp-status-applet.py: Adapt to change brought by 9c4d5e92d2eb288.
Properties update asynchronously now, including the name (which is used
for sorting icons in the panel). The applet needs to update the sort
when the name changes to its final value.
Michael Webster
3 years ago
55 | 55 | return Gtk.PositionType.LEFT |
56 | 56 | |
57 | 57 | class StatusWidget(Gtk.ToggleButton): |
58 | __gsignals__ = { | |
59 | "re-sort": (GObject.SignalFlags.RUN_LAST, None, ()) | |
60 | } | |
61 | ||
58 | 62 | def __init__(self, icon, orientation, size): |
59 | 63 | super(Gtk.ToggleButton, self).__init__() |
60 | 64 | self.theme = Gtk.IconTheme.get_default() |
107 | 111 | print("Could not read metadata: %s" % e) |
108 | 112 | |
109 | 113 | self.proxy.connect("notify::icon-name", self._on_icon_name_changed) |
114 | self.proxy.connect("notify::name", self._on_name_changed) | |
110 | 115 | |
111 | 116 | self.in_widget = False |
112 | 117 | self.plain_surface = None |
125 | 130 | |
126 | 131 | def _on_icon_name_changed(self, proxy, gparamspec, data=None): |
127 | 132 | self.update_icon() |
133 | ||
134 | def _on_name_changed(self, proxy, gparamspec, data=None): | |
135 | self.emit("re-sort") | |
128 | 136 | |
129 | 137 | def update_icon(self): |
130 | 138 | string = self.proxy.props.icon_name |
375 | 383 | |
376 | 384 | self.indicators[name] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size()) |
377 | 385 | self.indicator_box.add(self.indicators[name]) |
386 | self.indicators[name].connect("re-sort", self.sort_icons) | |
378 | 387 | |
379 | 388 | self.sort_icons() |
380 | 389 | |
382 | 391 | name = proxy.get_name() |
383 | 392 | |
384 | 393 | self.indicator_box.remove(self.indicators[name]) |
394 | self.indicators[name].disconnect_by_func(self.sort_icons) | |
385 | 395 | del(self.indicators[name]) |
386 | 396 | |
387 | 397 | self.sort_icons() |
424 | 434 | |
425 | 435 | self.indicator_box.queue_resize() |
426 | 436 | |
427 | def sort_icons(self): | |
437 | def sort_icons(self, status_widget=None): | |
428 | 438 | icon_list = list(self.indicators.values()) |
429 | 439 | |
430 | 440 | # for i in icon_list: |
10 | 10 | DBUS_PATH = "/org/x/StatusIcon" |
11 | 11 | |
12 | 12 | class StatusWidget(Gtk.ToggleButton): |
13 | __gsignals__ = { | |
14 | "re-sort": (GObject.SignalFlags.RUN_LAST, None, ()) | |
15 | } | |
13 | 16 | |
14 | 17 | def __init__(self, icon): |
15 | 18 | super(Gtk.ToggleButton, self).__init__() |
41 | 44 | self.proxy.bind_property("secondary-menu-is-open", self, "active", flags) |
42 | 45 | |
43 | 46 | self.proxy.connect("notify::icon-name", self.on_icon_name_changed) |
47 | self.proxy.connect("notify::name", self.on_name_changed) | |
44 | 48 | |
45 | 49 | self.connect("button-press-event", self.on_button_press) |
46 | 50 | self.connect("button-release-event", self.on_button_release) |
50 | 54 | string = self.proxy.props.icon_name |
51 | 55 | |
52 | 56 | self.set_icon(string) |
57 | ||
58 | def on_name_changed(self, proxy, gparamspec, data=None): | |
59 | self.emit("re-sort") | |
53 | 60 | |
54 | 61 | def set_icon(self, string): |
55 | 62 | if string: |
163 | 170 | |
164 | 171 | self.indicators[name] = StatusWidget(proxy) |
165 | 172 | self.indicator_box.add(self.indicators[name]) |
173 | self.indicators[name].connect("re-sort", self.sort_icons) | |
166 | 174 | |
167 | 175 | self.sort_icons() |
168 | 176 | |
170 | 178 | name = proxy.get_name() |
171 | 179 | |
172 | 180 | self.indicator_box.remove(self.indicators[name]) |
181 | self.indicators[name].disconnect_by_func(self.sort_icons) | |
173 | 182 | del(self.indicators[name]) |
174 | 183 | |
175 | 184 | self.sort_icons() |