Exemplo n.º 1
0
    def create_ui_not_downloaded(self):
        download_button = hildon.Button(self.BUTTON_HEIGHT,
                                        hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        shownotes_button = hildon.Button(self.BUTTON_HEIGHT,
                                         hildon.BUTTON_ARRANGEMENT_VERTICAL)
        play_button = hildon.Button(self.BUTTON_HEIGHT,
                                    hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        mark_new_button = hildon.GtkRadioButton(gtk.HILDON_SIZE_FINGER_HEIGHT
                                                | gtk.HILDON_SIZE_AUTO_WIDTH)
        mark_old_button = hildon.GtkRadioButton(
            gtk.HILDON_SIZE_FINGER_HEIGHT | gtk.HILDON_SIZE_AUTO_WIDTH,
            mark_new_button)

        marknew_actions = gtk.HBox(homogeneous=True)
        for button in (mark_new_button, mark_old_button):
            button.set_mode(False)
            marknew_actions.add(button)

        self.action_play.set_property('label', _('Stream'))
        self.radio_action_mark_new.set_property('label', _('New episode'))
        self.radio_action_mark_old.set_property('label', _('Old episode'))

        self.action_download.connect_proxy(download_button)
        self.action_shownotes.connect_proxy(shownotes_button)
        self.action_play.connect_proxy(play_button)
        self.radio_action_mark_new.connect_proxy(mark_new_button)
        self.radio_action_mark_old.connect_proxy(mark_old_button)

        if self.episode.length > 0:
            download_button.set_title(self.action_download.props.label)
            download_button.set_value(self.episode.get_filesize_string())

        if self.episode.total_time > 0:
            play_button.set_title(self.action_play.props.label)

        mark_new_button.set_active(not self.episode.is_played)
        mark_old_button.set_active(self.episode.is_played)

        table = gtk.Table(2, 2, True)
        table.attach(download_button, 0, 1, 0, 1)
        table.attach(shownotes_button, 1, 2, 0, 1)
        table.attach(play_button, 0, 1, 1, 2)
        table.attach(marknew_actions, 1, 2, 1, 2)
        return table
Exemplo n.º 2
0
 def radio_button_factory(action):
     b = hildon.GtkRadioButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
     b.set_mode(False)
     if not radio_button_group:
         radio_button_group.append(b)
     else:
         b.set_group(radio_button_group[0])
     b.set_label(action.props.label)
     b.set_active(action.get_active())
     actions_to_update.append((action, b))
     return b
Exemplo n.º 3
0
    def set_menu_choice(self, name, icons_labels, selected, visible, cb):

        if (not name in self.__menu_items):
            group = None
            items = []
            cnt = 0
            for icon, label in icons_labels:
                if (platforms.MAEMO5):
                    item = hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, group)
                    item.set_mode(False)
                else:
                    item = gtk.RadioMenuItem(group, label)

                if (icon):
                    if (platforms.MAEMO5):
                        img = gtk.Image()
                        img.set_from_pixbuf(icon)
                        item.set_image(img)

                elif (label):
                    if (platforms.MAEMO5):
                        item.set_label(label)

                if (not group): group = item
                items.append(item)
                if (platforms.MAEMO5):
                    self.__menu.add_filter(item)
                    item.connect("clicked", lambda src, cb, cnt: cb(cnt), cb,
                                 cnt)

                else:
                    self.__menu.append(item)
                    item.connect("activate", lambda src, cb, cnt: cb(cnt), cb,
                                 cnt)

                cnt += 1
            #end for
            self.__menu_items[name] = items

        else:
            items = self.__menu_items[name]

        for item in items:
            if (visible):
                item.show()
            else:
                item.hide()
        #end for

        items[selected].set_active(True)
Exemplo n.º 4
0
 def testGroupConstructor(self):
     first = hildon.GtkRadioButton(self.size_policy)
     second = hildon.GtkRadioButton(self.size_policy, first)
Exemplo n.º 5
0
 def testBasic(self):
     a = hildon.GtkRadioButton(self.size_policy)
     self.assertTrue(type(a) is hildon.GtkRadioButton)
     self.assertRaises(TypeError, hildon.GtkRadioButton)
Exemplo n.º 6
0
    def _display_results(self, caches, truncated):
        sortfuncs = [
            ('Dist', lambda x, y: cmp(x.prox, y.prox)),
            ('Name', lambda x, y: cmp(x.title, y.title)),
            ('Diff',
             lambda x, y: cmp(x.difficulty
                              if x.difficulty > 0 else 100, y.difficulty
                              if y.difficulty > 0 else 100)),
            ('Terr', lambda x, y: cmp(x.terrain
                                      if x.terrain > 0 else 100, y.terrain
                                      if y.terrain > 0 else 100)),
            ('Size', lambda x, y: cmp(x.size if x.size > 0 else 100, y.size
                                      if y.size > 0 else 100)),
            ('Type', lambda x, y: cmp(x.type, y.type)),
        ]

        if self.gps_data != None and self.gps_data.position != None:
            for c in caches:
                c.prox = c.distance_to(self.gps_data.position)
        else:
            for c in caches:
                c.prox = None

        win = hildon.StackableWindow()
        win.set_title("Search results")
        ls = gtk.ListStore(str, str, str, str, object)

        tv = hildon.TouchSelector()
        col1 = tv.append_column(ls, gtk.CellRendererText())

        c1cr = gtk.CellRendererText()
        c1cr.ellipsize = pango.ELLIPSIZE_MIDDLE
        c2cr = gtk.CellRendererText()
        c3cr = gtk.CellRendererText()
        c4cr = gtk.CellRendererText()

        col1.pack_start(c1cr, True)
        col1.pack_end(c2cr, False)
        col1.pack_start(c3cr, False)
        col1.pack_end(c4cr, False)

        col1.set_attributes(c1cr, text=0)
        col1.set_attributes(c2cr, text=1)
        col1.set_attributes(c3cr, text=2)
        col1.set_attributes(c4cr, text=3)

        def select_cache(widget, data, more):
            self.show_cache(self._get_selected(tv)[4])

        tv.connect("changed", select_cache, None)

        def on_change_sort(widget, sortfunc):
            tv.handler_block_by_func(select_cache)
            ls.clear()
            caches.sort(cmp=sortfunc)
            for c in caches:
                ls.append([
                    self.shorten_name(c.title, 40), " " + c.get_size_string(),
                    ' D%s T%s' % (c.get_difficulty(), c.get_terrain()),
                    " " + geo.Coordinate.format_distance(c.prox), c
                ])
            tv.handler_unblock_by_func(select_cache)

        menu = hildon.AppMenu()
        button = None
        for name, function in sortfuncs:
            button = hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, button)
            button.set_label(name)
            button.connect("clicked", on_change_sort, function)
            menu.add_filter(button)
            button.set_mode(False)

        def download_geocaches(widget):
            self.core.download_cache_details_list(caches)

        button = hildon.Button(gtk.HILDON_SIZE_AUTO,
                               hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_title("Download Details")
        button.set_value("for all Geocaches")
        button.connect("clicked", download_geocaches)
        menu.append(button)

        menu.show_all()
        win.set_app_menu(menu)
        win.add(tv)

        on_change_sort(None, sortfuncs[0][1])

        win.show_all()
        if truncated:
            hildon.hildon_banner_show_information_with_markup(
                win, "hu", "Showing only the first %d results." % len(caches))

        win.connect('delete_event', self.hide_search_view)
Exemplo n.º 7
0
 def testBasic(self):
     a = hildon.GtkRadioButton(self.size_policy)
     self.assertTrue(isinstance(a, hildon.GtkRadioButton))
     self.assertRaises(TypeError, hildon.GtkRadioButton)