Codebase list xapp / 18301e6
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 2 years ago
2 changed file(s) with 20 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5555 return Gtk.PositionType.LEFT
5656
5757 class StatusWidget(Gtk.ToggleButton):
58 __gsignals__ = {
59 "re-sort": (GObject.SignalFlags.RUN_LAST, None, ())
60 }
61
5862 def __init__(self, icon, orientation, size):
5963 super(Gtk.ToggleButton, self).__init__()
6064 self.theme = Gtk.IconTheme.get_default()
107111 print("Could not read metadata: %s" % e)
108112
109113 self.proxy.connect("notify::icon-name", self._on_icon_name_changed)
114 self.proxy.connect("notify::name", self._on_name_changed)
110115
111116 self.in_widget = False
112117 self.plain_surface = None
125130
126131 def _on_icon_name_changed(self, proxy, gparamspec, data=None):
127132 self.update_icon()
133
134 def _on_name_changed(self, proxy, gparamspec, data=None):
135 self.emit("re-sort")
128136
129137 def update_icon(self):
130138 string = self.proxy.props.icon_name
375383
376384 self.indicators[name] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size())
377385 self.indicator_box.add(self.indicators[name])
386 self.indicators[name].connect("re-sort", self.sort_icons)
378387
379388 self.sort_icons()
380389
382391 name = proxy.get_name()
383392
384393 self.indicator_box.remove(self.indicators[name])
394 self.indicators[name].disconnect_by_func(self.sort_icons)
385395 del(self.indicators[name])
386396
387397 self.sort_icons()
424434
425435 self.indicator_box.queue_resize()
426436
427 def sort_icons(self):
437 def sort_icons(self, status_widget=None):
428438 icon_list = list(self.indicators.values())
429439
430440 # for i in icon_list:
1010 DBUS_PATH = "/org/x/StatusIcon"
1111
1212 class StatusWidget(Gtk.ToggleButton):
13 __gsignals__ = {
14 "re-sort": (GObject.SignalFlags.RUN_LAST, None, ())
15 }
1316
1417 def __init__(self, icon):
1518 super(Gtk.ToggleButton, self).__init__()
4144 self.proxy.bind_property("secondary-menu-is-open", self, "active", flags)
4245
4346 self.proxy.connect("notify::icon-name", self.on_icon_name_changed)
47 self.proxy.connect("notify::name", self.on_name_changed)
4448
4549 self.connect("button-press-event", self.on_button_press)
4650 self.connect("button-release-event", self.on_button_release)
5054 string = self.proxy.props.icon_name
5155
5256 self.set_icon(string)
57
58 def on_name_changed(self, proxy, gparamspec, data=None):
59 self.emit("re-sort")
5360
5461 def set_icon(self, string):
5562 if string:
163170
164171 self.indicators[name] = StatusWidget(proxy)
165172 self.indicator_box.add(self.indicators[name])
173 self.indicators[name].connect("re-sort", self.sort_icons)
166174
167175 self.sort_icons()
168176
170178 name = proxy.get_name()
171179
172180 self.indicator_box.remove(self.indicators[name])
181 self.indicators[name].disconnect_by_func(self.sort_icons)
173182 del(self.indicators[name])
174183
175184 self.sort_icons()