~dylanmccall/update-manager/bug-1195573

« back to all changes in this revision

Viewing changes to UpdateManager/UpdatesAvailable.py

  • Committer: Michael Terry
  • Date: 2013-03-15 14:18:36 UTC
  • mfrom: (2614.1.1 missing-icon)
  • Revision ID: michael.terry@canonical.com-20130315141836-jipbv5x6dhg3rrsv
Look for to-be-updated application icons in app-install-data
(LP: #1145157)

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
 
207
207
 
208
208
class UpdatesAvailable(SimpleGtkbuilderApp):
 
209
    APP_INSTALL_ICONS_PATH = "/usr/share/app-install/icons"
209
210
 
210
211
    def __init__(self, app, header=None, desc=None):
211
212
        self.window_main = app
234
235
 
235
236
        self.settings = Gio.Settings("com.ubuntu.update-manager")
236
237
 
 
238
        # Special icon theme for looking up app-install-data icons
 
239
        self.app_icons = Gtk.IconTheme()
 
240
        self.app_icons.append_search_path(self.APP_INSTALL_ICONS_PATH)
 
241
 
237
242
        # create text view
238
243
        self.textview_changes = ChangelogViewer()
239
244
        self.textview_changes.show()
440
445
 
441
446
        gicon = None
442
447
        if data.group:
443
 
            gicon = data.group.icon
 
448
            gicon = self.get_app_install_icon(data.group.icon)
444
449
        elif data.item:
445
 
            gicon = data.item.icon
 
450
            gicon = self.get_app_install_icon(data.item.icon)
446
451
 
447
452
        renderer.set_property("gicon", gicon)
448
453
 
 
454
    def get_app_install_icon(self, icon):
 
455
        """Any application icon is coming from app-install-data's desktop
 
456
           files, which refer to icons from app-install-data's icon directory.
 
457
           So we look them up here."""
 
458
 
 
459
        if not isinstance(icon, Gio.ThemedIcon):
 
460
            return icon  # shouldn't happen
 
461
 
 
462
        info = self.app_icons.choose_icon(icon.get_names(), 16,
 
463
                                          Gtk.IconLookupFlags.FORCE_SIZE)
 
464
        if info is not None:
 
465
            return Gio.FileIcon.new(Gio.File.new_for_path(info.get_filename()))
 
466
        else:
 
467
            return icon  # Assume it's in one of the user's themes
 
468
 
449
469
    def pkg_label_renderer_data_func(self, cell_layout, renderer, model, iter,
450
470
                                     data):
451
471
        data = model.get_value(iter, LIST_UPDATE_DATA)