#!/usr/bin/python3

import gi
import pyatspi
import time

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject

class HelloWorldApp(Gtk.Application):

    def __init__(self):
        Gtk.Application.__init__(self)
        self.connect("activate", self.onActivate)

    def onActivate(self, data=None):
        window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
        window.set_title("Pick an item")
        window.set_size_request(100, -1)

        combobox = Gtk.ComboBox()
        window.add(combobox)

        cell = Gtk.CellRendererText()
        combobox.pack_start(cell, True)
        combobox.add_attribute(cell, 'text', 0)
        model = Gtk.ListStore(GObject.TYPE_STRING)
        for i in range(1000):
            storeiter = model.append(None)
            model.set_value(storeiter, 0, "item %i" % i)
        combobox.set_model(model)
        combobox.set_active(0)

        window.show_all()
        self.add_window(window)

        starttime = time.time()
        print("starting app iteration")
        for app in pyatspi.Registry.getDesktop(0):
            pass
        print("time: %.4f" % (time.time() - starttime))

if __name__ == "__main__":
    app = HelloWorldApp()
    app.run(None)
