Codebase list xapp / a407f7c
mate-xapp-status-applet.py: handle a null icon name correctly. The os.path.exists cannot accept a null path, and neither can GtkIconTheme.has_icon. Michael Webster 3 years ago
1 changed file(s) with 19 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
143143
144144 self.image.set_pixel_size(size)
145145
146 try:
147 if os.path.exists(string):
148 icon_file = Gio.File.new_for_path(string)
149 icon = Gio.FileIcon.new(icon_file)
150 self.image.set_from_gicon(icon, Gtk.IconSize.MENU)
151 return
152 else:
153 if self.theme.has_icon(string):
154 icon = Gio.ThemedIcon.new(string)
146 fallback = True
147
148 if string:
149 try:
150 if os.path.exists(string):
151 icon_file = Gio.File.new_for_path(string)
152 icon = Gio.FileIcon.new(icon_file)
155153 self.image.set_from_gicon(icon, Gtk.IconSize.MENU)
156 return
157 except GLib.Error as e:
158 print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, e.message))
159 except TypeError as e:
160 print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, str(e)))
154 else:
155 if self.theme.has_icon(string):
156 icon = Gio.ThemedIcon.new(string)
157 self.image.set_from_gicon(icon, Gtk.IconSize.MENU)
158
159 fallback = False
160 except GLib.Error as e:
161 print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, e.message))
162 except TypeError as e:
163 print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, str(e)))
161164
162165 #fallback
163 self.image.set_from_icon_name("image-missing", Gtk.IconSize.MENU)
166 if fallback:
167 self.image.set_from_icon_name("image-missing", Gtk.IconSize.MENU)
164168
165169 # TODO?
166170 def on_enter_notify(self, widget, event):