~evfool/sessioninstaller/fix790500

« back to all changes in this revision

Viewing changes to sessioninstaller/core.py

  • Committer: sebi at glatzor
  • Date: 2010-07-03 06:23:49 UTC
  • Revision ID: sebi@glatzor.de-20100703062349-ev4yd6o7lk09a3o9
Rework dialogs for the mime type handler installation

Show diffs side-by-side

added added

removed removed

Lines of Context:
900
900
            dia.hide()
901
901
            raise errors.ModifyInternalError(message)
902
902
        sender_name = yield self._get_sender_name(sender)
903
 
        title = _("Searching for mime type handlers")
 
903
        title = _("Searching for suitable software to open files")
904
904
        mime_types = set(mime_types_list)
905
905
        mime_names = [gio.content_type_get_description(mt) for mt in mime_types]
906
906
        if sender_name:
907
 
            message = gettext.ngettext("%s requires to install additional "
908
 
                                       "software which can open files of "
909
 
                                       "the mime type %s.",
910
 
                                       "%s requires to install additional "
911
 
                                       "software which can open files of "
912
 
                                       "the following mime types:\n%s",
913
 
                                       len(mime_types)) % (sender_name,
914
 
                                                          ", ".join(mime_names))
 
907
            #TRANSLATORS: %s is an application
 
908
            message = gettext.ngettext("%s requires to install software to "
 
909
                                       "open files of the following file type:",
 
910
                                       "%s requires to install software to "
 
911
                                       "open files of the following file "
 
912
                                       "types:",
 
913
                                       len(mime_types)) % sender_name
915
914
        else:
916
 
            message = gettext.ngettext("You have to install additional "
917
 
                                       "software to open files of the "
918
 
                                       "mime type %s.",
919
 
                                       "You have to install additional "
920
 
                                       "software to open files of the "
921
 
                                       "following mime types:\n%s",
922
 
                                       len(mime_types)) % (sender_name,
923
 
                                                          ", ".join(mime_names))
 
915
            message = gettext.ngettext("Software to open files of the "
 
916
                                       "following file type is required "
 
917
                                       "but is not installed:",
 
918
                                       "Software to open files of the "
 
919
                                       "following file types is required "
 
920
                                       "but is not installed:",
 
921
                                       len(mime_types))
 
922
        mime_types_desc = [gio.content_type_get_description(mime_type) \
 
923
                           for mime_type in mime_types]
 
924
        message += self._get_bullet_list(mime_types_desc)
924
925
        progress = ProgressDialog(title, message, parent)
925
926
        progress.show_all()
926
927
        while gtk.events_pending():
951
952
                    continue
952
953
            except KeyError:
953
954
                continue
954
 
            for mime_type in desktop_entry.getMimeTypes():
 
955
            supported_mime_types = set(desktop_entry.getMimeTypes())
 
956
            for mime_type in supported_mime_types:
955
957
                if not mime_type in mime_types:
956
 
                    mixed = True
957
958
                    continue
958
959
                package_map.setdefault(pkg_name, [[], set(), 0])
959
960
                #FIXME: Don't add desktop entries twice
965
966
                if package_map[pkg_name][2] < popcon:
966
967
                    package_map[pkg_name][2] = popcon
967
968
                unsatisfied.discard(mime_type)
 
969
                if not mixed and \
 
970
                   not supported_mime_types.issuperset(mime_types):
 
971
                    mixed = True
968
972
        progress.hide()
969
973
        progress.destroy()
970
 
        if mixed:
971
 
            details=_("Mime types")
 
974
        if mixed or unsatisfied:
 
975
            details = _("Supported file types")
972
976
        else:
973
 
            details=None
974
 
        title = _("Install mime type handler?")
 
977
            details = None
 
978
        title = _("Install software to open files?")
975
979
        if unsatisfied:
976
 
            #TRANSLATORS: list separator
977
 
            unsatisfied_str = _(", ").join(unsatisfied)
 
980
            unsatisfied_desc = [gio.content_type_get_description(mime_type) \
 
981
                                for mime_type in unsatisfied]
 
982
            unsatisfied_str = self._get_bullet_list(unsatisfied_desc)
978
983
            message += "\n\n"
979
 
            message += gettext.ngettext("%s isn't supported.",
980
 
                                        "Unsupported mime types: %s",
 
984
            #TRANSLATORS: %s is either a single file type or a bullet list of
 
985
            #             file types
 
986
            message += gettext.ngettext("%s is not supported.",
 
987
                                        "Unsupported file types: %s",
981
988
                                        len(unsatisfied)) % unsatisfied_str
982
989
        confirm = ConfirmInstallDialog(title, message, parent=parent,
983
990
                                       details=details,
984
991
                                       selectable=len(package_map) > 1,
985
 
                                       package_type=_("Handler"))
 
992
                                       package_type=_("Application"))
986
993
        for pkg, (entries, provides, score) in package_map.iteritems():
987
994
            if len(provides) == len(mime_types):
988
995
                details = _("All")