Codebase list xapp / e5112f9
Update upstream source from tag 'upstream/2.2.14' Update to upstream version '2.2.14' with Debian dir 47bffb6623b4a81ad27f980269ce2d6b99026a50 Joshua Peisach 1 year, 8 months ago
3 changed file(s) with 60 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
00 project('xapp',
11 'c',
2 version : '2.2.13',
2 version : '2.2.14',
33 default_options : [ 'buildtype=debugoptimized' ],
44 )
55
4343 </description>
4444 </key>
4545 </schema>
46 <schema id="org.x.apps.mate-panel-applet" path="/org/x/apps/mate-panel-applet/" gettext-domain="xapps">
47 <key name="symbolic-icon-offset" type="i">
48 <default>8</default>
49 <summary>Pixels smaller than the panel height to make symbolic icons</summary>
50 </key>
51 <key name="color-icon-offset" type="i">
52 <default>8</default>
53 <summary>Pixels smaller than the panel height to make color icons</summary>
54 </key>
55 </schema>
4656
4757 </schemalist>
2222 locale.bindtextdomain("xapp", applet_constants.LOCALEDIR)
2323 locale.textdomain("xapp")
2424
25 ICON_SIZE_REDUCTION = 2
25 DEFAULT_ICON_SIZE = 22
26
2627 VISIBLE_LABEL_MARGIN = 5 # When an icon has a label, add a margin between icon and label
27 SYMBOLIC_ICON_SIZE = 22
2828
2929 statusicon_css_string = """
3030 .statuswidget-horizontal {
5959 "re-sort": (GObject.SignalFlags.RUN_LAST, None, ())
6060 }
6161
62 def __init__(self, icon, orientation, size):
62 def __init__(self, icon, orientation, size, symbolic_icon_offset, color_icon_offset):
6363 super(Gtk.ToggleButton, self).__init__()
6464 self.theme = Gtk.IconTheme.get_default()
6565 self.orientation = orientation
66 self.size = size
66 self.icon_size = DEFAULT_ICON_SIZE
67 self.symbolic_icon_offset = symbolic_icon_offset
68 self.color_icon_offset = color_icon_offset
6769
6870 self.proxy = icon
69 self.proxy.props.icon_size = size
71 self.proxy.props.icon_size = DEFAULT_ICON_SIZE
7072
7173 # this is the bus owned name
7274 self.name = self.proxy.get_name()
126128 self.connect("leave-notify-event", self.on_leave_notify)
127129
128130 self.update_orientation()
129 self.update_icon()
131 self.update_icon(size)
130132
131133 def _on_icon_name_changed(self, proxy, gparamspec, data=None):
132134 self.update_icon()
134136 def _on_name_changed(self, proxy, gparamspec, data=None):
135137 self.emit("re-sort")
136138
137 def update_icon(self):
139 def update_icon_offsets(self, symbolic, color):
140 self.symbolic_icon_offset = symbolic
141 self.color_icon_offset = color
142 self.update_icon()
143
144 def update_icon(self, new_size=None):
145 if new_size != None and new_size == self.icon_size:
146 return
147
148 if new_size:
149 self.icon_size = new_size
150
151 self.proxy.props.icon_size = self.icon_size - self.symbolic_icon_offset
138152 string = self.proxy.props.icon_name
139 self.proxy.props.icon_size = self.size
140153
141154 self.set_icon(string)
142155
171184
172185 if string:
173186 if "symbolic" in string:
174 size = SYMBOLIC_ICON_SIZE
187 size = self.icon_size - self.symbolic_icon_offset
175188 else:
176 size = self.size - ICON_SIZE_REDUCTION
189 size = self.icon_size - self.color_icon_offset
177190
178191 self.image.set_pixel_size(size)
179192
195208
196209 #fallback
197210 if fallback:
198 self.image.set_pixel_size(self.size - ICON_SIZE_REDUCTION)
211 self.image.set_pixel_size(self.icon_size - self.symbolic_icon_offset)
199212 self.image.set_from_icon_name("image-missing", Gtk.IconSize.MENU)
200213
201214 def menu_state_changed(self, proxy, pspec, data=None):
307320 self.applet.set_can_focus(False)
308321 self.applet.set_background_widget(self.applet)
309322
323 self.settings = Gio.Settings(schema_id="org.x.apps.mate-panel-applet")
324 self.settings.connect("changed", self.icon_offsets_changed)
325
310326 self.add_about()
311327
312328 button_css = Gtk.CssProvider()
364380
365381 def on_applet_destroy(self, widget, data=None):
366382 self.destroy_monitor()
383 self.settings = None
367384 Gtk.main_quit()
368385
369386 def setup_monitor (self):
388405 def on_icon_added(self, monitor, proxy):
389406 key = self.make_key(proxy)
390407
391 self.indicators[key] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size())
408 symbolic_icon_offset = self.settings.get_int("symbolic-icon-offset")
409 color_icon_offset = self.settings.get_int("color-icon-offset")
410
411
412 self.indicators[key] = StatusWidget(proxy,
413 self.applet.get_orient(),
414 self.applet.get_size(),
415 symbolic_icon_offset,
416 color_icon_offset)
417
392418 self.indicator_box.add(self.indicators[key])
393419 self.indicators[key].connect("re-sort", self.sort_icons)
394420
409435 def on_applet_size_changed(self, applet, size, data=None):
410436 for key in self.indicators.keys():
411437 indicator = self.indicators[key]
412
413 indicator.size = applet.get_size()
414 indicator.update_icon()
438 indicator.update_icon(size)
439
440 self.applet.queue_resize()
441
442 def icon_offsets_changed(self, settings, key):
443 symbolic = self.settings.get_int("symbolic-icon-offset")
444 color = self.settings.get_int("color-icon-offset")
445
446 for key in self.indicators.keys():
447 indicator = self.indicators[key]
448 indicator.update_icon_offsets(symbolic, color)
415449
416450 self.applet.queue_resize()
417451