def __init__(self): self.outbox = tichy.List() self.inbox = tichy.List() # Prepare the future notification self.notification_icon = tichy.Image(self.path('pics/message.png'), (32, 32)) self.notification = None
def run(self, window): self.window = window frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) self.question_text = tichy.Text("Question") self.question_text.view(vbox, expand=True, font_size=58) self.choices = tichy.List() self.choices.view(vbox, expand=True) frame.connect('back', self.on_quit) dic = codecs.open(Learn.path('characters.dic'), encoding='utf-8') logger.info("opening the dict") # dic = open(Learn.path('characters.dic'), 'r') dic = Dic.read(dic) self.full_dic = dic[:] brain = Brain() logger.info("start game") self.task = None while True: self.task = brain.ask(self.ask, dic) try: yield self.task except GeneratorExit: break
def __init__(self, group, name, type, value=None, setter=None, options="", model=None, ListLabel=None, edje_group=None, save_button=False, **kargs): assert issubclass(type, Item), type self.group = group self.edje_group = edje_group self.save_button = save_button self.name = name self.type = type self.Value = type.as_type(value) if value is not None else type() self.Setter = setter or self.setter self.options = tichy.List(options) self.model = model self.ListLabel = ListLabel # register the setting into the list of all settings Setting.groups.setdefault(group, {})[name] = self
def init(self): logger.info("bt loading") yield tichy.Service.get('ConfigService').wait_initialized() try: yield tichy.tasklet.WaitDBusName('org.bluez',time_out=120) self.usage_service = tichy.Service.get('Usage') yield self.usage_service.request_resource('Bluetooth') self.bus = dbus.SystemBus(mainloop=tichy.mainloop.dbus_loop) manager_obj = self.bus.get_object('org.bluez', "/") self.Manager = dbus.Interface(manager_obj, 'org.bluez.Manager') raise try: default_adapter = yield WaitDBus(self.Manager.DefaultAdapter) adapter = yield WaitDBus(self.Manager.FindAdapter, default_adapter) adapter_obj = self.bus.get_object('org.bluez', adapter) except: adapter_list = yield WaitDBus(self.Manager.ListAdapters) if len(adapter_list) == 0: logger.info("adapter list empty.. waiting") yield WaitDBusSignal(self.Manager, "AdapterAdded") adapter_list = yield WaitDBus(self.Manager.ListAdapters) adapter_obj = self.bus.get_object('org.bluez', adapter_list[0]) self.Adapter = dbus.Interface(adapter_obj, 'org.bluez.Adapter') self.config_service = tichy.Service.get("ConfigService") #setting up agent agent_path = "/test/agent" self.Agent = Agent(self.bus, agent_path) logger.debug("bluez Agent registered") self.Adapter.RegisterAgent(self.Agent, "DisplayYesNo") #listen for signals #on bt obj self.Adapter.connect_to_signal('DeviceFound',self.DeviceAppeared) self.Adapter.connect_to_signal('DeviceDisappeared',self.DeviceDisappeared) self.Adapter.connect_to_signal('DeviceRemoved',self.DeviceRemoved) print self.Adapter.GetProperties() #on service instance self.connect("close", self.close) self.scanning = False self.DeviceList = tichy.List() self.ListLabel = [('title','name'),('subtitle','addr')] self.scan_setting = tichy.settings.ListSetting('Bluetooth', 'List', tichy.Text, value="scan", setter=self.StartScanning, options=['scan'], model=self.DeviceList, ListLabel=self.ListLabel) status = tichy.settings.ToggleSetting('', 'status', tichy.Text, value=self.get_status(), setter=self.set_status, options=['active','inactive']) #password = tichy.settings.StringSetting('gprs', 'password', tichy.Text, value=self.get_password(), setter=self.set_password) #user = tichy.settings.StringSetting('gprs', 'user', tichy.Text, value=self.get_user(), setter=self.set_user) #apn = tichy.settings.StringSetting('gprs', 'apn', tichy.Text, value=self.get_apn(), setter=self.set_apn) #self.iface.connect_to_signal("NetworkStatus", self.status_change) #self.iface.connect_to_signal("ContextStatus", self.context_status_change) except Exception, e: logger.warning("can't use bt service : %s", e) raise
def __init__(self): super(ContactsService, self).__init__() self.contacts = tichy.List() # TODO: the problem here is that when we load the contacts we # are going to rewrite them ! self.contacts.connect('modified', self._on_contacts_modified) # For optimization we keep a map of number to contact self._number_to_contact = {}
def init(self): """register on the network""" logger.info("Turn on antenna power") logger.info("Register on the network") self.emit('provider-modified', "Charlie Telecom") self.network_strength = 100 yield tichy.Service.get('ConfigService').wait_initialized() self.config_service = tichy.Service.get("ConfigService") logger.info("got config service") self.values = self.config_service.get_items("call_forwarding") if self.values != None: self.values = dict(self.values) logger.info("realized values is none") self.SettingReason = tichy.settings.ListSetting( 'Call Forwarding', 'Reason', tichy.Text, value='unconditional', setter=self.ForwardingSetReason, options=[ "unconditional", "mobile busy", "no reply", "not reachable", "all", "all conditional" ], model=tichy.List([ ListSettingObject("unconditional", self.action), ListSettingObject("mobile busy", self.action), ListSettingObject("no reply", self.action), ListSettingObject("not reachable", self.action), ListSettingObject("all", self.action), ListSettingObject("all conditional", self.action) ]), ListLabel=[('title', 'name')]) self.SettingChannels = tichy.settings.Setting( 'Call Forwarding', 'channels', tichy.Text, value=self.ForwardingGet('class'), setter=self.ForwardingSetClass, options=["voice", "data", "voice+data", "fax", "voice+data+fax"]) self.SettingTargetNumber = tichy.settings.NumberSetting( 'Call Forwarding', 'Target Number', tichy.Text, value=self.ForwardingGet('number'), setter=self.ForwardingSetNumber) self.SettingTargetNumber = tichy.settings.NumberSetting( 'Call Forwarding', 'Timeout', tichy.Text, value=self.ForwardingGet('timeout'), setter=self.ForwardingSetTimeout) if len(self.logs) == 0: for i in range(3): call = Call('0049110', direction='out') self.logs.insert(0, call) yield None
def __init__(self, *args): super(MainMenu, self).__init__(*args) self.list = tichy.List() self.current_xdg_menu = None #### icon theme #### self.xdg_theme = 'gnome' logger.info("Using icon theme: %s" % (self.xdg_theme, )) #### supported desktopentry types #### self.xdg_types = ('Application', ) logger.info("Limit to following .desktop types: %s" % (self.xdg_types, ))
def _connect_dbus(self): try: yield WaitDBusName('org.freesmartphone.odeviced', time_out=120) bus = dbus.SystemBus(mainloop=tichy.mainloop.dbus_loop) rtc_obj = bus.get_object( 'org.freesmartphone.odeviced', '/org/freesmartphone/Device/RealTimeClock/rtc0') self.rtc = dbus.Interface( rtc_obj, 'org.freesmartphone.Device.RealTimeClock') self.ListLabel = [('title', 'name'), ('value', 'value')] self.hour = TimeSetting("hour", 3, tichy.List(range(24)), "int") self.minute = TimeSetting("minute", 4, tichy.List(range(60)), "int") self.ValueList = tichy.List() self.ValueList.append(self.hour) self.ValueList.append(self.minute) self.time_setting = tichy.settings.ListSetting( 'Time', 'set time', tichy.Text, value="set", setter=self.set_time, options=['set'], model=self.ValueList, ListLabel=self.ListLabel, edje_group="ValueSetting", save_button=True) self.ValueList.connect('save', self.UpdateSystemTime) except Exception, e: logger.warning( "can't use freesmartphone RealTimeClock service : %s", e)
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) # The search entry text = tichy.Text('') text.view(vbox, editable=True) text.connect('modified', self.on_text_modified) # The result actions self.results = tichy.List() self.results.actors_view(vbox, can_delete=False, expand=True) self.dict = Dict(self.path()) yield tichy.Wait(frame, 'back')
def __init__(self, group, name, type, value=None, setter=None, options="", listenObject=False, signal=False, **kargs): """Create a new setting :Parameters: group : str The group the setting belongs to. name : str The actual name of the setting type : tichy.Item The type of the setting value. This should be a tichy.Item, so we need to use tichy.Int instead of int, tichy.Text instead of str, etc.. value Optional intialization value setter A tasklet that will be called every time we try to set the Setting value. It takes the new value as argument. The Setting value will actually be set only after this tasklet returns. """ assert issubclass(type, Item), type self.group = group self.name = name self.type = type self.Value = type.as_type(value) if value is not None else type() self.Setter = setter or self.setter self.options = tichy.List(options) if listenObject: listenObject.connect_to_signal(signal, self.change_val) # register the setting into the list of all settings Setting.groups.setdefault(group, {})[name] = self
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) prefs = tichy.Service('Prefs') phone = prefs['phone'] # We create a list of actor on all the params we want to show self.params_list = tichy.List() for param in ['ring-tone', 'ring-volume']: param_item = ParamItem(phone, param) actor = tichy.Actor(param_item) self.params_list.append(actor) self.params_list.view(vbox) yield tichy.Wait(frame, 'back')
def __init__(self): self.outbox = tichy.List() self.inbox = tichy.List() self.messages = tichy.List() # Prepare the future notification self.notification = None
def __init__(self): super(MessagesService, self).__init__() self.messages = tichy.List() self.unread = tichy.Text(0) self.messages.connect('appended', self._update_unread) self.ready = False
def __init__(self): super(GSMService, self).__init__() self.logs = tichy.List() self._load_logs() self.logs.connect('modified', self._on_logs_modified)
def __init__(self, *args): super(FileBrowser, self).__init__(*args) self.list = tichy.List()
def init(self): logger.info('wifi service init') try: self.config_service = tichy.Service.get("ConfigService") yield self.config_service.wait_initialized() self.usage_service = tichy.Service.get('Usage') yield self.usage_service.wait_initialized() yield self.usage_service.request_resource('Wifi') bus = dbus.SystemBus(mainloop=tichy.mainloop.dbus_loop) ## power related power_obj = bus.get_object( 'org.freesmartphone.odeviced', '/org/freesmartphone/Device/PowerControl/WiFi') self.power_iface = dbus.Interface( power_obj, 'org.freesmartphone.Device.PowerControl') try_num = 0 ## devicing for i in range(5): try: obj = bus.get_object("org.moblin.connman", "/") logger.info("moblin success") except: logger.info("moblin failed") yield WaitFirst(Sleep(1)) continue else: break #raise Exception("moblin not starting") self.devicing_iface = dbus.Interface(obj, "org.moblin.connman.Manager") self.status_setting = tichy.settings.ToggleSetting( 'wifi', 'power', tichy.Text, value=self.get_power(), setter=self.power, options=['active', 'inactive']) self.NetworkList = tichy.List() self.ListLabel = [('title', 'name'), ('subtitle', 'info')] self.scan_setting = tichy.settings.ListSetting( 'wifi', 'scan', tichy.Text, value="Networks", setter=self.run_scan, options=['Networks'], model=self.NetworkList, ListLabel=self.ListLabel) if self.get_power(): self.get_device() self.devicing_iface.connect_to_signal('PropertyChanged', self.property_changed) self.connect("closing", self.closing) except Exception, e: logger.warning("can't use wifi service : %s", e) raise
def __init__(self): super(GSMService, self).__init__() self.logs = tichy.List() self.missed_call_count = tichy.Int(0) self.logs.connect('modified', self._on_logs_modified) self._load_logs()
def __init__(self): super(ContactsService, self).__init__() self.contacts = tichy.List() # TODO: the problem here is that when we load the contacts we # are going to rewrite them ! self.contacts.connect('modified', self._on_contacts_modified)
try: self.SettingReason = tichy.settings.ListSetting( 'Call Forwarding', 'Reason', tichy.Text, value='unconditional', setter=self.ForwardingSetReason, options=[ "unconditional", "mobile busy", "no reply", "not reachable", "all", "allconditional" ], model=tichy.List([ ListSettingObject("unconditional", self.action), ListSettingObject("mobile busy", self.action), ListSettingObject("no reply", self.action), ListSettingObject("not reachable", self.action), ListSettingObject("all", self.action), ListSettingObject("all conditional", self.action) ]), ListLabel=[('title', 'name')]) self.SettingForwarding = tichy.settings.ToggleSetting( 'Call Forwarding', 'active', tichy.Text, value=self.GetForwardingStatus('unconditional'), setter=self.ToggleForwarding, options=['active', 'inactive']) except Exception, ex: logger.error("Error in try call forwarding setting list : %s", ex)