def main():
    """The main entry point, compatible with setuptools entry points."""
    # pylint: disable=bad-continuation
    from optparse import OptionParser
    parser = OptionParser(version="%%prog v%s" % __version__,
            usage="%prog [options] <argument> ...",
            description=__doc__.replace('\r\n', '\n').split('\n--snip--\n')[0])
    parser.add_option('-v', '--verbose', action="count", dest="verbose",
        default=2, help="Increase the verbosity. Use twice for extra effect")
    parser.add_option('-q', '--quiet', action="count", dest="quiet",
        default=0, help="Decrease the verbosity. Use twice for extra effect")
    # Reminder: %default can be used in help strings.

    # Allow pre-formatted descriptions
    parser.formatter.format_description = lambda description: description

    opts, _ = parser.parse_args()

    # Set up clean logging to stderr
    log_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING,
                  logging.INFO, logging.DEBUG]
    opts.verbose = min(opts.verbose - opts.quiet, len(log_levels) - 1)
    opts.verbose = max(opts.verbose, 0)
    logging.basicConfig(level=log_levels[opts.verbose],
                        format='%(levelname)s: %(message)s')

    print('\n'.join(repr(x) for x in get_games()))
Exemple #2
0
    def run(self):
        entries = self.app.entries
        if not entries:
            entries = get_games()
            gobject.idle_add(self.app.set_entries, entries)

        for pos, entry in enumerate(entries):
            row = (GtkIconWrapper.get_scaled_icon(entry.icon, ICON_SIZE), entry.name, xmlescape(entry.summarize()), pos)
            log.debug("Adding row: %s", row)
            gobject.idle_add(self.add_row, row)
def main():
    """The main entry point, compatible with setuptools entry points."""
    app = QApplication(sys.argv)

    with open(os.path.join(os.path.dirname(__file__), 'testgui.ui')) as fobj:
        window = loadUi(fobj)

    model = GameListModel(get_games())
    model_sorted = QSortFilterProxyModel()
    model_sorted.setDynamicSortFilter(True)
    model_sorted.setSortCaseSensitivity(Qt.CaseInsensitive)
    model_sorted.setSourceModel(model)
    model_sorted.sort(0, Qt.AscendingOrder)

    window.view_games.setModel(model_sorted)
    window.show()

    sys.exit(app.exec_())
Exemple #4
0
def main():
    """The main entry point, compatible with setuptools entry points."""
    # pylint: disable=bad-continuation
    from optparse import OptionParser
    parser = OptionParser(version="%%prog v%s" % __version__,
                          usage="%prog [options] <argument> ...",
                          description=__doc__.replace(
                              '\r\n', '\n').split('\n--snip--\n')[0])
    parser.add_option(
        '-v',
        '--verbose',
        action="count",
        dest="verbose",
        default=2,
        help="Increase the verbosity. Use twice for extra effect")
    parser.add_option(
        '-q',
        '--quiet',
        action="count",
        dest="quiet",
        default=0,
        help="Decrease the verbosity. Use twice for extra effect")
    # Reminder: %default can be used in help strings.

    # Allow pre-formatted descriptions
    parser.formatter.format_description = lambda description: description

    opts, _ = parser.parse_args()

    # Set up clean logging to stderr
    log_levels = [
        logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO,
        logging.DEBUG
    ]
    opts.verbose = min(opts.verbose - opts.quiet, len(log_levels) - 1)
    opts.verbose = max(opts.verbose, 0)
    logging.basicConfig(level=log_levels[opts.verbose],
                        format='%(levelname)s: %(message)s')

    print('\n'.join(repr(x) for x in get_games()))
Exemple #5
0
    def __init__(self):
        self.builder = gtk.Builder()
        self.icon_theme = gtk.icon_theme_get_default()

        """Parts of __init__ that should only run in the single instance."""
        # Check for some deps late enough to display a GUI error message
        self.gtkbuilder_load('testgui.glade')
        self.data = self.builder.get_object('store_games')

        self.view = self.builder.get_object("view_games")
        self.view.set_selection_mode(
            gtk.SELECTION_MULTIPLE)

        # Apparently Glade doesn't let you set these in the XML for IconView
        self.view.set_text_column(1)
        self.view.set_pixbuf_column(0)

        self.entries = get_games()
        self.populate_model(self.entries)

        self.mainwin = self.builder.get_object('mainwin')
        self.mainwin.set_title('%s %s' %
                               (self.mainwin.get_title(), __version__))
        self.mainwin.show_all()
Exemple #6
0
 def __init__(self, entries=None):
     gtk.GenericTreeModel.__init__(self)
     self.entries = entries or get_games()