Exemplo n.º 1
0
    def build(self, model):
        view = red_thrashingtreeview.TreeView(model)
        view.set_rules_hint(1)
        self.view = view

        cols = [
            (_("Time"), COLUMN_TIME),
            (_("Action"), COLUMN_ACTION),
            (_("User"), COLUMN_USER),
            (_("Type"), COLUMN_TYPE),
            (_("Name"), COLUMN_NAME),
            (_("Old Version"), COLUMN_PKG_INITIAL),
            (_("New Version"), COLUMN_PKG_FINAL),
        ]

        for title, id in cols:
            col = gtk.TreeViewColumn(title, gtk.CellRendererText(), text=id)

            col.set_resizable(1)
            view.add_column(col, title=title, initially_visible=1, sort_id=id)

        view.sort_by(COLUMN_TIME)

        view.show_all()

        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.set_shadow_type(gtk.SHADOW_IN)
        self.add(view)
Exemplo n.º 2
0
    def make_channel_view(self):
        global model

        view = red_thrashingtreeview.TreeView(model)

        def toggle_cb(cr, path, model):
            c = model.get_list_item(int(path))
            model.toggle_subscribed(c)

        toggle = gtk.CellRendererToggle()
        toggle.set_property("activatable", 1)
        col = gtk.TreeViewColumn(_("Subscribed"),
                                 toggle,
                                 active=red_channelmodel.COLUMN_SUBSCRIBED)
        toggle.connect("toggled", toggle_cb, model)
        view.append_column(col)

        col = gtk.TreeViewColumn()
        col.set_title(_("Catalog Name"))
        r1 = gtk.CellRendererPixbuf()
        r2 = gtk.CellRendererText()
        col.pack_start(r1, 0)
        col.pack_start(r2, 0)
        col.set_attributes(r1, pixbuf=red_channelmodel.COLUMN_ICON)
        col.set_attributes(r2, text=red_channelmodel.COLUMN_NAME)
        view.append_column(col)

        return view
Exemplo n.º 3
0
    def __init__(self):

        gtk.Dialog.__init__(self, _("Unmount Catalog"))

        self.set_default_size(300, 300)

        model = red_channelmodel.ChannelModel(
            filter_fn=lambda x: x.get("mounted", 0))

        channels_to_unmount = {}
        for c in model.get_all():
            channels_to_unmount[c["id"]] = 0

        umount_col = model.add_column(lambda x: channels_to_unmount[x["id"]],
                                      gobject.TYPE_BOOLEAN)

        view = red_thrashingtreeview.TreeView(model)

        r = gtk.CellRendererText()
        col = gtk.TreeViewColumn(_("Catalog"), r, text=COLUMN_NAME)
        view.append_column(col)

        def toggle_cb(cr, path, mod):
            def set_cb(m, p):
                c = m.get_list_item(int(p))
                channels_to_unmount[c["id"]] = not channels_to_unmount[c["id"]]

            mod.changed(set_cb, path)

        r = gtk.CellRendererToggle()
        r.set_property("activatable", 1)
        r.set_property("xalign", 0.0)
        r.connect("toggled", toggle_cb, model)
        col = gtk.TreeViewColumn(_("Unmount?"), r, active=umount_col)
        view.append_column(col)

        view.show()

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.show()

        sw.add(view)
        self.vbox.pack_start(sw)

        b = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        b.connect("clicked", lambda x, y: y.destroy(), self)

        b = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        b.grab_default()

        def ok_clicked_cb(b, w, s):
            for cid in s:
                if s[cid]:
                    unmount_channel(cid)

            w.destroy()

        b.connect("clicked", ok_clicked_cb, self, channels_to_unmount)
Exemplo n.º 4
0
    def __init__(self):
        gtk.ScrolledWindow.__init__(self)

        model = NewsModel()

        view = red_thrashingtreeview.TreeView()
        view.set_model(model)

        view.set_headers_visible(0)
        view.set_rules_hint(1)
        sel = view.get_selection()
        sel.set_mode(gtk.SELECTION_NONE)

        col = gtk.TreeViewColumn("Icon",
                                 gtk.CellRendererPixbuf(),
                                 pixbuf=COLUMN_ICON)

        view.append_column(col)

        col = gtk.TreeViewColumn()
        r1 = gtk.CellRendererText()
        col.pack_start(r1, 0)
        col.set_attributes(r1, markup=COLUMN_TITLE)

        view.append_column(col)

        view.show_all()

        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.set_shadow_type(gtk.SHADOW_IN)
        self.add(view)
Exemplo n.º 5
0
def make_users_view(model):
    view = red_thrashingtreeview.TreeView(model)
    view.set_headers_visible(0)

    col = gtk.TreeViewColumn(_("User"),
                             gtk.CellRendererText(),
                             text=COLUMN_NAME)
    view.append_column(col)
    return view
Exemplo n.º 6
0
    def __init__(self, opt):
        gtk.ScrolledWindow.__init__(self)

        model = PrivilegesModel(opt)

        view = red_thrashingtreeview.TreeView()
        view.set_model(model)
        view.set_headers_visible(0)

        col = gtk.TreeViewColumn(_("Privilege"),
                                 gtk.CellRendererText(),
                                 text=PRIVILEGE_COLUMN_PRIVILEGE)
        view.append_column(col)

        def activated_cb(renderer, path, model):
            path = (int(path), )
            privilege = model.get_list_item(path[0])
            user = opt.get_selected_user()
            if user:
                current_user = rcd_util.get_current_user()
                if user.name_get(
                ) == current_user and privilege == "superuser":
                    # Warn the user about removing their own superuser priv
                    dialog = gtk.MessageDialog(
                        None, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
                        _("If you remove superuser "
                          "privileges from yourself, you "
                          "will be unable to re-add them."
                          "\n\n"
                          "Are you sure you want to do "
                          "this?"))
                    response = dialog.run()
                    dialog.destroy()
                    if response == gtk.RESPONSE_NO or response == gtk.RESPONSE_DELETE_EVENT:
                        return

                # We want opposite state
                active = not renderer.get_active()
                user.privilege_set(privilege, active)

        r = gtk.CellRendererToggle()
        r.set_property("activatable", 1)
        r.connect("toggled", activated_cb, model)
        col = gtk.TreeViewColumn(_("Enabled"),
                                 r,
                                 active=PRIVILEGE_COLUMN_ENABLED)
        view.append_column(col)

        view.show_all()

        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.set_shadow_type(gtk.SHADOW_IN)
        self.add(view)
Exemplo n.º 7
0
    def build(self):
        unique_prefs = [self.prefs[x] for x in self.prefs
                        if not x in self.view.all_handled_prefs()]
        
        model = PrefsModel(unique_prefs, None)
        view = red_thrashingtreeview.TreeView(model)
        view.set_sensitive(rcd_util.check_server_permission("superuser"))

        col = gtk.TreeViewColumn(_("Description"),
                                 gtk.CellRendererText(),
                                 text=COLUMN_DESCRIPTION)
        view.append_column(col)

        r = CellRendererPref()

        def activated_cb(r, pref, page):
            opp = ximian_xmlrpclib.Boolean(not pref["value"])

            page.prefs[pref["name"]]["value"] = opp
            page.enqueue(pref["name"])

        r.connect("activated", activated_cb, self)

        def editing_done_cb(r, pref, value, page):
            try:
                v = int(value)
            except ValueError:
                v = value

            # Don't set the pref if we didn't change anything.
            if v == pref.get("value"):
                return

            page.prefs[pref["name"]]["value"] = v
            page.enqueue(pref["name"])

        r.connect("editing_done", editing_done_cb, self)

        col = gtk.TreeViewColumn(_("Value"), r, value=COLUMN_VALUE)
        view.append_column(col)

        self.pack_start(view, expand=1, fill=1, padding=12)