コード例 #1
0
ファイル: eventlist.py プロジェクト: loomchild/sojourner
    def __create_treeview(self):
        treeview = gtk.TreeView(self.store)
        treeview.set_headers_visible(False)
        treeview.connect("row-activated", self.event_activated)

        tvcolumn = gtk.TreeViewColumn('Stuff')
        treeview.append_column(tvcolumn)

        add_swatch_cells(tvcolumn, colour_col=EventList.COL_SWATCH_COLOUR,
            visible_col=EventList.COL_IS_EVENT)

        cell = gtk.CellRendererText()
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
        tvcolumn.pack_start(cell, True)

        def text_data_func(column, cell, model, i):
            is_event, markup = self.store.get(i,
                EventList.COL_IS_EVENT, EventList.COL_MARKUP)
            xalign = 0.0 if is_event else 0.5
            cell.set_properties(markup=markup, xalign=xalign)

        tvcolumn.set_cell_data_func(cell, text_data_func)

        cell = gtk.CellRendererPixbuf()
        cell.set_property("icon-name", STAR_ICON)
        tvcolumn.pack_start(cell, False)
        tvcolumn.add_attribute(cell, 'visible', EventList.COL_FAVOURITED)

        pannable = MaybePannableArea()
        pannable.add(treeview)
        self.add_with_margins(pannable)

        self.show_all()
コード例 #2
0
ファイル: eventwindow.py プロジェクト: olethanh/sojourner
    def __init__(self, schedule, event, favourite_toggled_cb):
        MaybeStackableWindow.__init__(self, event.title, self._on_orientation_changed)
        self.schedule = schedule
        self.event = event
        self.favourite_toggled_cb = favourite_toggled_cb

        vbox = gtk.VBox(spacing=12)

        self.label = gtk.Label()
        self.label.set_markup(event.full())
        self.label.set_properties(wrap=True)
        vbox.pack_start(self.label, expand=False)

        toggle = MagicCheckButton("Favourite")
        toggle.set_active(event in self.schedule.favourites)
        toggle.connect("toggled", self.toggle_toggled)
        vbox.pack_end(toggle, expand=False)

        self._update_conflicted_events()
        conflicts_button = MagicButton("Overlapped events")
        conflicts_button.connect("clicked", self._conflicts_button_clicked_cb)
        vbox.pack_end(conflicts_button, expand=False)

        pannable = MaybePannableArea()
        pannable.add_with_viewport(vbox)
        self.add_with_margins(pannable)
        self.show_all()

        if not self.conflict_events:
            conflicts_button.hide()
コード例 #3
0
    def __init__(self, schedule, event, favourite_toggled_cb):
        MaybeStackableWindow.__init__(self, event.title,
            self._on_orientation_changed)
        self.schedule = schedule
        self.event = event
        self.favourite_toggled_cb = favourite_toggled_cb

        vbox = gtk.VBox(spacing=12)

        self.label = gtk.Label()
        self.label.set_markup(event.full())
        self.label.set_properties(wrap=True)
        vbox.pack_start(self.label, expand=False)

        toggle = MagicCheckButton("Favourite")
        toggle.set_active(event in self.schedule.favourites)
        toggle.connect('toggled', self.toggle_toggled)
        vbox.pack_end(toggle, expand=False)

        self._update_conflicted_events()
        conflicts_button = MagicButton('Overlapped events')
        conflicts_button.connect('clicked', self._conflicts_button_clicked_cb)
        vbox.pack_end(conflicts_button, expand=False)

        pannable = MaybePannableArea()
        pannable.add_with_viewport(vbox)
        self.add_with_margins(pannable)
        self.show_all()

        if not self.conflict_events:
            conflicts_button.hide()
コード例 #4
0
ファイル: eventlist.py プロジェクト: wjt/sojourner
    def __create_treeview(self):
        treeview = gtk.TreeView(self.store)
        treeview.set_headers_visible(False)
        treeview.connect("row-activated", self.event_activated)

        tvcolumn = gtk.TreeViewColumn('Stuff')
        treeview.append_column(tvcolumn)

        add_swatch_cells(tvcolumn,
                         colour_col=EventList.COL_SWATCH_COLOUR,
                         visible_col=EventList.COL_IS_EVENT)

        cell = gtk.CellRendererText()
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
        tvcolumn.pack_start(cell, True)

        def text_data_func(column, cell, model, i):
            is_event, markup = self.store.get(i, EventList.COL_IS_EVENT,
                                              EventList.COL_MARKUP)
            xalign = 0.0 if is_event else 0.5
            cell.set_properties(markup=markup, xalign=xalign)

        tvcolumn.set_cell_data_func(cell, text_data_func)

        cell = gtk.CellRendererPixbuf()
        cell.set_property("icon-name", STAR_ICON)
        tvcolumn.pack_start(cell, False)
        tvcolumn.add_attribute(cell, 'visible', EventList.COL_FAVOURITED)

        pannable = MaybePannableArea()
        pannable.add(treeview)
        self.add_with_margins(pannable)

        self.show_all()
コード例 #5
0
    def __init__(self, schedule, title, categories, event_fmt,
                 show_swatches=False):
        MaybeStackableWindow.__init__(self, title)
        self.schedule = schedule
        self.categories = categories
        self.event_fmt = event_fmt
        # This should really be   (str, list) but that doesn't seem to work:
        #   TypeError: could not get typecode from object
        # I guess list is not a subclass of object.
        self.store = gtk.ListStore(str, object, str, gtk.gdk.Color)

        for category, events in sorted(categories.items()):
            summary = """<b>%(category)s</b>
<small>%(event_summary)s</small>""" % {
                'category': esc(category),
                'event_summary': summarize_events(events),
            }
            colour = get_color(category) if show_swatches else None
            self.store.append((category, events, summary, colour))

        treeview = gtk.TreeView(self.store)
        treeview.set_headers_visible(False)
        treeview.connect("row-activated", self.category_activated)

        tvcolumn = gtk.TreeViewColumn('Stuff')
        treeview.append_column(tvcolumn)

        # FIXME: it'd be nice to show the colours on the room list, too, to
        # show which track(s) are in that room. But then we'd need to support
        # showing more than one.
        if show_swatches:
            add_swatch_cells(tvcolumn,
                colour_col=CategoryList.COL_CATEGORY_COLOUR)

        cell = gtk.CellRendererText()
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
        tvcolumn.pack_start(cell, True)

        tvcolumn.add_attribute(cell, 'markup',
            CategoryList.COL_CATEGORY_SUMMARY)

        pannable = MaybePannableArea()
        pannable.add(treeview)
        self.add_with_margins(pannable)

        self.show_all()