Пример #1
0
    def __init__(self):
        gtk.Alignment.__init__(self)
        self.__gobject_init__()

        self._expandpackage = False

        self._changeset = {}

        self._scrollwin = gtk.ScrolledWindow()
        self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
        self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
        self._scrollwin.show()
        self.add(self._scrollwin)

        self._treeview = gtk.TreeView()
        self._treeview.set_rules_hint(True)
        self._treeview.connect("button_press_event", self._buttonPress)
        self._treeview.connect("select_cursor_row", self._selectCursor)
        self._treeview.connect("cursor_changed", self._cursorChanged)
        self._treeview.show()
        self._scrollwin.add(self._treeview)

        selection = self._treeview.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)

        column = gtk.TreeViewColumn(_("Package"))
        renderer = PixbufCellRenderer()
        renderer.set_property("activate", self._pixbufClicked)
        renderer.set_property("xpad", 3)
        renderer.set_property("mode", gtk.CELL_RENDERER_MODE_ACTIVATABLE)
        column.pack_start(renderer, False)
        column.set_cell_data_func(renderer, self._setPixbuf)
        renderer = gtk.CellRendererText()
        column.pack_start(renderer, True)
        column.set_cell_data_func(renderer, self._setName)
        self._treeview.append_column(column)

        renderer = gtk.CellRendererText()
        self._treeview.insert_column_with_data_func(-1, _("Version"), renderer,
                                                    self._setVersion)

        self._ipixbuf = getPixbuf("package-installed")
        self._ilpixbuf = getPixbuf("package-installed-locked")
        self._apixbuf = getPixbuf("package-available")
        self._alpixbuf = getPixbuf("package-available-locked")
        self._npixbuf = getPixbuf("package-new")
        self._nlpixbuf = getPixbuf("package-new-locked")
        self._fpixbuf = getPixbuf("folder")
        self._Ipixbuf = getPixbuf("package-install")
        self._Rpixbuf = getPixbuf("package-remove")
        self._rpixbuf = getPixbuf("package-reinstall")
Пример #2
0
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Mirrors"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

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

        self._treemodel = gtk.TreeStore(gobject.TYPE_STRING)
        self._treeview = gtk.TreeView(self._treemodel)
        self._treeview.set_rules_hint(True)
        self._treeview.set_headers_visible(False)
        self._treeview.show()
        sw.add(self._treeview)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.rowEdited)
        self._treeview.insert_column_with_attributes(-1, _("Mirror"), renderer,
                                                     text=0)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.show()
        button.connect("clicked", lambda x: self.newMirror())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-delete")
        button.show()
        button.connect("clicked", lambda x: self.delMirror())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-close")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #3
0
def about(*args):
    license = """
            This program is free software; you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation; either version 2 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.

            You should have received a copy of the GNU General Public License
            along with this program; if not, write to the Free Software
            Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
            """
    gtk.about_dialog_set_url_hook(lambda dialog, url: url_show(url))
    aboutdlg = gtk.AboutDialog()
    aboutdlg.set_logo(getPixbuf("smart"))
    aboutdlg.set_version(VERSION)
    aboutdlg.set_name(NAME)
    aboutdlg.set_copyright("2008 Canonical, Inc.")
    aboutdlg.set_authors(AUTHORS)
    aboutdlg.set_license(license)
    aboutdlg.run()
    aboutdlg.destroy()
    return
def about(*args):
    license = """
            This program is free software; you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation; either version 2 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.

            You should have received a copy of the GNU General Public License
            along with this program; if not, write to the Free Software
            Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
            """
    gtk.about_dialog_set_url_hook(lambda dialog, url: url_show(url))
    aboutdlg = gtk.AboutDialog()
    aboutdlg.set_logo(getPixbuf("smart"))
    aboutdlg.set_version(VERSION)
    aboutdlg.set_name(NAME)
    aboutdlg.set_copyright("2008 Canonical, Inc.")
    aboutdlg.set_authors(AUTHORS)
    aboutdlg.set_license(license)
    aboutdlg.run()
    aboutdlg.destroy()
    return
Пример #5
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Change Summary"))
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self.connect("delete-event", delete)

        self._vbox = gtk.VBox()
        self._vbox.set_border_width(10)
        self._vbox.set_spacing(10)
        self._vbox.show()
        self.add(self._vbox)

        self._label = gtk.Label()
        self._vbox.pack_start(self._label, expand=False)

        self._pv = GtkPackageView()
        self._pv.getTreeView().set_headers_visible(False)
        self._pv.setExpandPackage(True)
        self._pv.show()
        self._vbox.pack_start(self._pv)

        self._sizelabel = gtk.Label()
        self._vbox.pack_start(self._sizelabel, expand=False)

        self._confirmbbox = gtk.HButtonBox()
        self._confirmbbox.set_spacing(10)
        self._confirmbbox.set_layout(gtk.BUTTONBOX_END)
        self._vbox.pack_start(self._confirmbbox, expand=False)

        self._cancelbutton = gtk.Button(stock="gtk-cancel")
        self._cancelbutton.show()
        self._cancelbutton.connect("clicked", lambda x: gtk.main_quit())
        self._confirmbbox.pack_start(self._cancelbutton)

        self._okbutton = gtk.Button(stock="gtk-ok")
        self._okbutton.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        self._okbutton.connect("clicked", clicked)
        self._confirmbbox.pack_start(self._okbutton)

        self._closebbox = gtk.HButtonBox()
        self._closebbox.set_spacing(10)
        self._closebbox.set_layout(gtk.BUTTONBOX_END)
        self._vbox.pack_start(self._closebbox, expand=False)

        self._closebutton = gtk.Button(stock="gtk-close")
        self._closebutton.show()
        self._closebutton.connect("clicked", lambda x: gtk.main_quit())
        self._closebbox.pack_start(self._closebutton)
Пример #6
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Channel"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)
        
        label = gtk.Label(_("Media path:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._mpvbox = gtk.VBox()
        self._mpvbox.set_spacing(10)
        self._mpvbox.show()
        table.attach(self._mpvbox, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        self._ok = button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #7
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Flag"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)

        label = gtk.Label(_("Name:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        self._flag = gtk.Entry()
        self._flag.set_width_chars(20)
        self._flag.show()
        table.attach(self._flag, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #8
0
    def __init__(self):

        self._fields = {}
        self._fieldn = 0

        self._tooltips = gtk.Tooltips()

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Edit Channel"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)

        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        self._table = gtk.Table()
        self._table.set_row_spacings(10)
        self._table.set_col_spacings(10)
        self._table.show()
        vbox.pack_start(self._table)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-ok")
        button.show()

        def clicked(x):
            self._result = True
            gtk.main_quit()

        button.connect("clicked", clicked)
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #9
0
 def run(self, command=None, argv=None):
     self.setCatchExceptions(True)
     self._window.set_icon(getPixbuf("smart"))
     self._window.show()
     self._ctrl.reloadChannels()
     self._changeset = ChangeSet(self._ctrl.getCache())
     self._pi.setChangeSet(self._changeset)
     self._progress.hide()
     self.refreshPackages()
     gtk.main()
     self.setCatchExceptions(False)
Пример #10
0
 def run(self, command=None, argv=None):
     self.setCatchExceptions(True)
     self._window.set_icon(getPixbuf("smart"))
     self._window.show()
     self._ctrl.reloadChannels()
     self._changeset = ChangeSet(self._ctrl.getCache())
     self._pi.setChangeSet(self._changeset)
     self._progress.hide()
     self.refreshPackages()
     gtk.main()
     self.setCatchExceptions(False)
Пример #11
0
    def __init__(self):

        self._fields = {}
        self._fieldn = 0

        self._tooltips = gtk.Tooltips()

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Edit Channel"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        self._table = gtk.Table()
        self._table.set_row_spacings(10)
        self._table.set_col_spacings(10)
        self._table.show()
        vbox.pack_start(self._table)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)
Пример #12
0
    def __init__(self):
        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Status"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_border_width(20)

        self._label = gtk.Label()
        self._label.show()
        self._window.add(self._label)

        self._lastshown = 0
Пример #13
0
    def __init__(self):
        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Status"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_border_width(20)

        self._label = gtk.Label()
        self._label.show()
        self._window.add(self._label)

        self._lastshown = 0
Пример #14
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Log"))
        self.set_geometry_hints(min_width=400, min_height=300)
        self.set_modal(True)

        self._vbox = gtk.VBox()
        self._vbox.set_border_width(10)
        self._vbox.set_spacing(10)
        self._vbox.show()
        self.add(self._vbox)

        self._scrollwin = gtk.ScrolledWindow()
        self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
        self._scrollwin.show()
        self._vbox.add(self._scrollwin)

        self._textview = gtk.TextView()
        self._textview.set_editable(False)
        self._textview.show()
        self._scrollwin.add(self._textview)

        self._buttonbox = gtk.HButtonBox()
        self._buttonbox.set_spacing(10)
        self._buttonbox.set_layout(gtk.BUTTONBOX_END)
        self._buttonbox.show()
        self._vbox.pack_start(self._buttonbox, expand=False, fill=False)

        self._clearbutton = gtk.Button(stock="gtk-clear")
        self._clearbutton.show()
        self._clearbutton.connect("clicked",
                                  lambda x: self._textview.get_buffer()
                                                         .set_text(""))
        self._buttonbox.pack_start(self._clearbutton)

        self._closebutton = gtk.Button(stock="gtk-close")
        self._closebutton.show()
        self._closebutton.connect("clicked", lambda x: self.hide())
        self._buttonbox.pack_start(self._closebutton)
Пример #15
0
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Package Priority"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)

        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        self._table = gtk.Table()
        self._table.set_row_spacings(10)
        self._table.set_col_spacings(10)
        self._table.show()
        vbox.pack_start(self._table)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-close")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #16
0
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Package Priority"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        # self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        self._table = gtk.Table()
        self._table.set_row_spacings(10)
        self._table.set_col_spacings(10)
        self._table.show()
        vbox.pack_start(self._table)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-close")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #17
0
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Flags"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        topvbox = gtk.VBox()
        topvbox.set_border_width(10)
        topvbox.set_spacing(10)
        topvbox.show()
        self._window.add(topvbox)

        tophbox = gtk.HBox()
        tophbox.set_spacing(20)
        tophbox.show()
        topvbox.add(tophbox)

        # Left side
        vbox = gtk.VBox()
        tophbox.set_spacing(10)
        vbox.show()
        tophbox.pack_start(vbox)

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

        self._flagsmodel = gtk.ListStore(gobject.TYPE_STRING)
        self._flagsview = gtk.TreeView(self._flagsmodel)
        self._flagsview.set_rules_hint(True)
        self._flagsview.show()
        sw.add(self._flagsview)

        selection = self._flagsview.get_selection()
        selection.connect("changed", self.flagSelectionChanged)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.flagEdited)
        self._flagsview.insert_column_with_attributes(-1, _("Flags"), renderer,
                                                      text=0)

        bbox = gtk.HButtonBox()
        bbox.set_border_width(5)
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_SPREAD)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.connect("clicked", lambda x: self.newFlag())
        button.show()
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-delete")
        button.connect("clicked", lambda x: self.delFlag())
        button.show()
        bbox.pack_start(button)
        self._delflag = button

        # Right side
        vbox = gtk.VBox()
        tophbox.set_spacing(10)
        vbox.show()
        tophbox.pack_start(vbox)

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

        self._targetsmodel = gtk.ListStore(gobject.TYPE_STRING)
        self._targetsview = gtk.TreeView(self._targetsmodel)
        self._targetsview.set_rules_hint(True)
        self._targetsview.show()
        sw.add(self._targetsview)

        selection = self._targetsview.get_selection()
        selection.connect("changed", self.targetSelectionChanged)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.targetEdited)
        self._targetsview.insert_column_with_attributes(-1, _("Targets"),
                                                        renderer, text=0)

        bbox = gtk.HButtonBox()
        bbox.set_border_width(5)
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_SPREAD)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.set_property("sensitive", False)
        button.connect("clicked", lambda x: self.newTarget())
        button.show()
        bbox.pack_start(button)
        self._newtarget = button

        button = gtk.Button(stock="gtk-delete")
        button.set_property("sensitive", False)
        button.connect("clicked", lambda x: self.delTarget())
        button.show()
        bbox.pack_start(button)
        self._deltarget = button


        # Bottom
        sep = gtk.HSeparator()
        sep.show()
        topvbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        topvbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-close")
        button.connect("clicked", lambda x: gtk.main_quit())
        button.show()
        bbox.pack_start(button)
Пример #18
0
    def __init__(self, hassub):
        Progress.__init__(self)
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.connect("delete-event", lambda x, y: True)

        self._hassub = hassub
        self._shorturl = ShortURL(50)
        self._ticking = False
        self._stopticking = False
        self._fetcher = None

        if hassub:
            self.set_size_request(500, 400)
        else:
            self.set_size_request(300, 80)

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Operation Progress"))
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        gtk.Window.add(self, vbox)

        self._topic = gtk.Label()
        self._topic.set_alignment(0, 0.5)
        self._topic.show()
        vbox.pack_start(self._topic, expand=False, fill=False)

        self._progress = gtk.ProgressBar()
        self._progress.set_size_request(-1, 25)
        self._progress.show()
        vbox.pack_start(self._progress, expand=False, fill=False)

        if hassub:
            self._scrollwin = gtk.ScrolledWindow()
            self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
            self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
            self._scrollwin.show()
            vbox.pack_start(self._scrollwin)

            self._treemodel = gtk.ListStore(gobject.TYPE_INT,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING)
            self._treeview = gtk.TreeView(self._treemodel)
            self._treeview.show()
            self._scrollwin.add(self._treeview)

            renderer = ProgressCellRenderer()
            column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            column.set_fixed_width(110)
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
            self._currentcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
            self._totalcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Speed"), renderer, text=4)
            self._speedcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Description"), renderer, text=1)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            self._treeview.append_column(column)

            self._subiters = {}
            self._subindex = 0
            self._lastpath = None

            self._bbox = gtk.HButtonBox()
            self._bbox.set_spacing(10)
            self._bbox.set_layout(gtk.BUTTONBOX_END)
            vbox.pack_start(self._bbox, expand=False)

            button = gtk.Button(stock="gtk-cancel")
            button.show()
            button.connect("clicked", self._cancel)
            self._bbox.pack_start(button)
Пример #19
0
    def __init__(self, hassub):
        Progress.__init__(self)
        gtk.Window.__init__(self)

        self.connect("delete-event", lambda x,y: True)

        # updates from subthreads not showing up [#592503]
        self._threadsafe = not glib or glib.glib_version < (2, 24, 0)

        self._hassub = hassub
        self._shorturl = ShortURL(50)
        self._ticking = False
        self._stopticking = False
        self._fetcher = None

        if hassub:
            self.set_size_request(500, 100)
            self.set_default_size(500, 400)
        else:
            self.set_size_request(300, 80)
        def configure_event(widget, event):
            maxlen = widget.allocation.width / 10
            self._shorturl = ShortURL(maxlen)
            return False
        self.connect("configure-event", configure_event)

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Operation Progress"))
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        gtk.Window.add(self, vbox)

        self._topic = gtk.Label()
        self._topic.set_alignment(0, 0.5)
        self._topic.show()
        vbox.pack_start(self._topic, expand=False, fill=False)

        self._progressbar = gtk.ProgressBar()
        self._progressbar.set_size_request(-1, 25)
        self._progressbar.show()
        vbox.pack_start(self._progressbar, expand=False, fill=False)

        if hassub:
            expander = gtk.Expander()
            expander.set_expanded(True)
            expander.show()
            def toggle_window(expander, param_spec):
                if expander.get_expanded():
                    self.resize(500, 400)
                else:
                    self.resize(500, 100)
            expander.connect("notify::expanded", toggle_window)
            vbox.pack_start(expander)

            self._scrollwin = gtk.ScrolledWindow()
            self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
            self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
            self._scrollwin.show()
            expander.add(self._scrollwin)

            self._treemodel = gtk.ListStore(gobject.TYPE_INT,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING)
            self._treeview = gtk.TreeView(self._treemodel)
            self._treeview.show()
            self._scrollwin.add(self._treeview)

            if gtk.pygtk_version < (2,6,0):
                renderer = ProgressCellRenderer()
                column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
            else:
                renderer = gtk.CellRendererProgress()
                # don't display the percent label
                renderer.set_property("text", "")
                column = gtk.TreeViewColumn(_("Progress"), renderer, value=0)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            column.set_fixed_width(110)
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
            self._currentcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
            self._totalcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Speed"), renderer, text=4)
            self._speedcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("ETA"), renderer, text=5)
            self._etacolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Description"), renderer, text=1)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            self._treeview.append_column(column)

            self._subiters = {}
            self._subindex = 0
            self._lastpath = None

            self._bbox = gtk.HButtonBox()
            self._bbox.set_spacing(10)
            self._bbox.set_layout(gtk.BUTTONBOX_END)
            vbox.pack_start(self._bbox, expand=False)

            button = gtk.Button(stock="gtk-cancel")
            button.show()
            button.connect("clicked", self._cancel)
            self._bbox.pack_start(button)
Пример #20
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Package Priority"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)
        
        label = gtk.Label(_("Package Name:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        self._name = gtk.Entry()
        self._name.show()
        table.attach(self._name, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Channel Alias:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._alias = gtk.Entry()
        self._alias.set_text("*")
        self._alias.show()
        table.attach(self._alias, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Priority:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL)

        self._priority = gtk.SpinButton()
        self._priority.set_width_chars(8)
        self._priority.set_increments(1, 10)
        self._priority.set_numeric(True)
        self._priority.set_range(-100000,+100000)
        self._priority.show()
        align = gtk.Alignment(0.0, 0.5)
        align.show()
        align.add(self._priority)
        table.attach(align, 1, 2, 2, 3, gtk.EXPAND|gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)
Пример #21
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Channel"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)
        
        label = gtk.Label(_("Method:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        methodvbox = gtk.VBox()
        methodvbox.set_spacing(10)
        methodvbox.show()
        table.attach(methodvbox, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)

        ok = button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)

        radio = None
        self._method = None
        def method_toggled(button, method):
            if button.get_active():
                self._method = method
        for method, descr in [("manual",
                               _("Provide channel information")),
                              ("descriptionpath",
                               _("Read channel description from local path")),
                              ("descriptionurl",
                               _("Read channel description from URL")),
                              ("detectmedia",
                               _("Detect channel in media (CDROM, DVD, etc)")),
                              ("detectpath",
                               _("Detect channel in local path"))]:
            if not self._method:
                self._method = method
            radio = gtk.RadioButton(radio, descr)
            radio.connect("activate", lambda x: ok.activate())
            radio.connect("toggled", method_toggled, method)
            radio.show()
            methodvbox.pack_start(radio)
Пример #22
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Channel"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)
        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.set_size_request(-1, 300)
        sw.add_with_viewport(table)
        sw.show()
        vbox.pack_start(sw)
        
        label = gtk.Label(_("Type:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._typevbox = gtk.VBox()
        self._typevbox.set_spacing(10)
        self._typevbox.show()
        table.attach(self._typevbox, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)

        self._ok = button = gtk.Button(stock="gtk-ok")
        button.show()
        def clicked(x):
            self._result = True
            gtk.main_quit()
        button.connect("clicked", clicked)
        bbox.pack_start(button)
Пример #23
0
    def __init__(self, parent=None):

        self._changed = False

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Channels"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

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

        self._treemodel = gtk.ListStore(gobject.TYPE_INT,
                                        gobject.TYPE_STRING,
                                        gobject.TYPE_STRING,
                                        gobject.TYPE_STRING,
                                        gobject.TYPE_INT);
        self._treeview = gtk.TreeView(self._treemodel)
        self._treeview.set_rules_hint(True)
        self._treeview.show()
        sw.add(self._treeview)

        renderer = gtk.CellRendererToggle()
        renderer.set_property("xpad", 4)
        renderer.set_active(False)
        def toggled(cell, path):
            model = self._treemodel
            iter = model.get_iter(path)
            model.set(iter, 0, not bool(model.get_value(iter, 0)))
        renderer.connect("toggled", toggled)
        self._treeview.insert_column_with_attributes(-1, "", renderer,
                                                     active=0)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 4)
        self._treeview.insert_column_with_attributes(-1, _("Pri"), renderer,
                                                     text=4)
        self._treeview.insert_column_with_attributes(-1, _("Alias"), renderer,
                                                     text=1)
        self._treeview.insert_column_with_attributes(-1, _("Type"), renderer,
                                                     text=2)
        self._treeview.insert_column_with_attributes(-1, _("Name"), renderer,
                                                     text=3)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.show()
        button.connect("clicked", lambda x: self.newChannel())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-delete")
        button.show()
        def clicked(x):
            selection = self._treeview.get_selection()
            model, iter = selection.get_selected()
            if not iter:
                return
            alias = model.get_value(iter, 1)
            self.delChannel(alias)
        button.connect("clicked", clicked)
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-properties")
        button.show()
        def clicked(x):
            selection = self._treeview.get_selection()
            model, iter = selection.get_selected()
            if not iter:
                return
            alias = model.get_value(iter, 1)
            self.editChannel(alias)
        button.connect("clicked", clicked)
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-close")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
Пример #24
0
    aboutdlg.set_logo(getPixbuf("smart"))
    aboutdlg.set_version(VERSION)
    aboutdlg.set_name(NAME)
    aboutdlg.set_copyright("2008 Canonical, Inc.")
    aboutdlg.set_authors(AUTHORS)
    aboutdlg.set_license(license)
    aboutdlg.run()
    aboutdlg.destroy()
    return


import smart
ctrl = smart.init()

app_window = gtk.StatusIcon()
app_window.set_from_pixbuf(getPixbuf("smart"))

app_window.connect("popup-menu", show_popup_menu)

menu_items = (
    ("Check for updates", smart_update),
    ("Launch Smart", smart_gui),
    None,
    ("About...", about),
    ("Exit", exit_applet),
)

factory = gtk.IconFactory()
factory.add_default()
icon_set = gtk.IconSet(getPixbuf("smart"))
factory.add("smart-icon", icon_set)
Пример #25
0
    def packagePopup(self, packageview, pkgs, event):

        menu = gtk.Menu()

        hasinstalled = bool([pkg for pkg in pkgs if pkg.installed
                             and self._changeset.get(pkg) is not REMOVE])
        hasnoninstalled = bool([pkg for pkg in pkgs if not pkg.installed
                                and self._changeset.get(pkg) is not INSTALL])

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-install"))
        item = gtk.ImageMenuItem(_("Install"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, INSTALL))
        if not hasnoninstalled:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-reinstall"))
        item = gtk.ImageMenuItem(_("Reinstall"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, REINSTALL))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)


        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-remove"))
        item = gtk.ImageMenuItem(_("Remove"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, REMOVE))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        if not hasinstalled:
            image.set_from_pixbuf(getPixbuf("package-available"))
        else:
            image.set_from_pixbuf(getPixbuf("package-installed"))
        item = gtk.ImageMenuItem(_("Keep"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, KEEP))
        if not [pkg for pkg in pkgs if pkg in self._changeset]:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-broken"))
        item = gtk.ImageMenuItem(_("Fix problems"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, FIX))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)

        inconsistent = False
        thislocked = None
        alllocked = None
        names = pkgconf.getFlagTargets("lock")
        if [pkg for pkg in pkgs if pkg in self._changeset]:
            inconsistent = True
        else:
            for pkg in pkgs:
                if (names and pkg.name in names and 
                    ("=", pkg.version) in names[pkg.name]):
                    newthislocked = True
                    newalllocked = len(names[pkg.name]) > 1
                else:
                    newthislocked = False
                    newalllocked = pkgconf.testFlag("lock", pkg)
                if (thislocked is not None and thislocked != newthislocked or
                    alllocked is not None and alllocked != newalllocked):
                    inconsistent = True
                    break
                thislocked = newthislocked
                alllocked = newalllocked

        image = gtk.Image()
        if thislocked:
            item = gtk.ImageMenuItem(_("Unlock this version"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available"))
            def unlock_this(x):
                self.lockPackages(pkgs, False)
            item.connect("activate", unlock_this)
        else:
            item = gtk.ImageMenuItem(_("Lock this version"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed-locked"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available-locked"))
            def lock_this(x):
                self.lockPackages(pkgs, True)
            item.connect("activate", lock_this)
        item.set_image(image)
        if inconsistent:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        if alllocked:
            item = gtk.ImageMenuItem(_("Unlock all versions"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available"))
            def unlock_all(x):
                self.lockAllPackages(pkgs, False)
            item.connect("activate", unlock_all)
        else:
            item = gtk.ImageMenuItem(_("Lock all versions"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed-locked"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available-locked"))
            def lock_all(x):
                self.lockAllPackages(pkgs, True)
            item.connect("activate", lock_all)
        item.set_image(image)
        if inconsistent:
            item.set_sensitive(False)
        menu.append(item)

        item = gtk.MenuItem(_("Priority"))
        def priority(x):
            GtkSinglePriority(self._window).show(pkgs[0])
            self._pi.setPackage(pkgs[0])
        item.connect("activate", priority)
        if len(pkgs) != 1:
            item.set_sensitive(False)
        menu.append(item)

        menu.show_all()
        menu.popup(None, None, None, event.button, event.time)
Пример #26
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Icon Legend"))

        font = self.style.font_desc.copy()
        font.set_size(font.get_size()-pango.SCALE)

        boldfont = font.copy()
        boldfont.set_weight(pango.WEIGHT_BOLD)

        self._vbox = gtk.VBox()
        self._vbox.set_border_width(10)
        self._vbox.set_spacing(10)
        self._vbox.show()
        self.add(self._vbox)

        attrslabel = pango.AttrList()
        attrslabel.insert(pango.AttrFontDesc(boldfont, 0, -1))

        label = gtk.Label(_("The following icons are used to indicate\nthe current status of a package:"))
        label.set_attributes(attrslabel)
        label.show()
        self._vbox.add(label)

        table = gtk.Table()
        table.set_row_spacings(2)
        table.set_col_spacings(5)
        table.set_border_width(5)
        table.show()
        self._vbox.add(table)
  
        row = 0
        for icon, legend in [
        (getPixbuf("package-install"),            _("Marked for installation")),
        (getPixbuf("package-reinstall"),          _("Marked for re-installation")),
        (getPixbuf("package-upgrade"),            _("Marked for upgrade")),
        (getPixbuf("package-downgrade"),          _("Marked for downgrade")),
        (getPixbuf("package-remove"),             _("Marked for removal")),
        (getPixbuf("package-available"),          _("Not installed")),
        (getPixbuf("package-new"),                _("Not installed (new)")),
        (getPixbuf("package-available-locked"),   _("Not installed (locked)")),
        (getPixbuf("package-installed"),          _("Installed")),
        (getPixbuf("package-installed-outdated"), _("Installed (upgradable)")),
        (getPixbuf("package-installed-locked"),   _("Installed (locked)")),
        (getPixbuf("package-broken"),             _("Broken")),
        ]:
            image = gtk.Image()
            image.set_from_pixbuf(icon)
            image.show()
            table.attach(image, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
            label = gtk.Label(legend)
            label.set_alignment(0.0, 0.5)
            label.show()
            table.attach(label, 1, 2, row, row+1, gtk.FILL, gtk.FILL)
            row += 1
        
        self._buttonbox = gtk.HButtonBox()
        self._buttonbox.set_spacing(10)
        self._buttonbox.set_layout(gtk.BUTTONBOX_END)
        self._buttonbox.show()
        self._vbox.pack_start(self._buttonbox, expand=False, fill=False)

        self._closebutton = gtk.Button(stock="gtk-close")
        self._closebutton.show()
        self._closebutton.connect("clicked", lambda x: self.hide())
        self._buttonbox.pack_start(self._closebutton)
Пример #27
0
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Flags"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True
        self._window.connect("delete-event", delete)

        topvbox = gtk.VBox()
        topvbox.set_border_width(10)
        topvbox.set_spacing(10)
        topvbox.show()
        self._window.add(topvbox)

        tophbox = gtk.HBox()
        tophbox.set_spacing(20)
        tophbox.show()
        topvbox.add(tophbox)

        # Left side
        vbox = gtk.VBox()
        tophbox.set_spacing(10)
        vbox.show()
        tophbox.pack_start(vbox)

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

        self._flagsmodel = gtk.ListStore(gobject.TYPE_STRING)
        self._flagsview = gtk.TreeView(self._flagsmodel)
        self._flagsview.set_rules_hint(True)
        self._flagsview.show()
        sw.add(self._flagsview)

        selection = self._flagsview.get_selection()
        selection.connect("changed", self.flagSelectionChanged)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.flagEdited)
        self._flagsview.insert_column_with_attributes(-1, _("Flags"), renderer,
                                                      text=0)

        bbox = gtk.HButtonBox()
        bbox.set_border_width(5)
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_SPREAD)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.connect("clicked", lambda x: self.newFlag())
        button.show()
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-delete")
        button.connect("clicked", lambda x: self.delFlag())
        button.show()
        bbox.pack_start(button)
        self._delflag = button

        # Right side
        vbox = gtk.VBox()
        tophbox.set_spacing(10)
        vbox.show()
        tophbox.pack_start(vbox)

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

        self._targetsmodel = gtk.ListStore(gobject.TYPE_STRING)
        self._targetsview = gtk.TreeView(self._targetsmodel)
        self._targetsview.set_rules_hint(True)
        self._targetsview.show()
        sw.add(self._targetsview)

        selection = self._targetsview.get_selection()
        selection.connect("changed", self.targetSelectionChanged)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.targetEdited)
        self._targetsview.insert_column_with_attributes(-1, _("Targets"),
                                                        renderer, text=0)

        bbox = gtk.HButtonBox()
        bbox.set_border_width(5)
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_SPREAD)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.set_property("sensitive", False)
        button.connect("clicked", lambda x: self.newTarget())
        button.show()
        bbox.pack_start(button)
        self._newtarget = button

        button = gtk.Button(stock="gtk-delete")
        button.set_property("sensitive", False)
        button.connect("clicked", lambda x: self.delTarget())
        button.show()
        bbox.pack_start(button)
        self._deltarget = button


        # Bottom
        sep = gtk.HSeparator()
        sep.show()
        topvbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        topvbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-close")
        button.connect("clicked", lambda x: gtk.main_quit())
        button.show()
        bbox.pack_start(button)
    aboutdlg = gtk.AboutDialog()
    aboutdlg.set_logo(getPixbuf("smart"))
    aboutdlg.set_version(VERSION)
    aboutdlg.set_name(NAME)
    aboutdlg.set_copyright("2008 Canonical, Inc.")
    aboutdlg.set_authors(AUTHORS)
    aboutdlg.set_license(license)
    aboutdlg.run()
    aboutdlg.destroy()
    return

import smart
ctrl = smart.init()

app_window = gtk.StatusIcon()
app_window.set_from_pixbuf(getPixbuf("smart"))

app_window.connect("popup-menu", show_popup_menu)

menu_items = (
    ("Check for updates", smart_update),
    ("Launch Smart", smart_gui),
    None,
    ("About...", about),
    ("Exit", exit_applet),
    )

factory = gtk.IconFactory ()
factory.add_default ()
icon_set = gtk.IconSet(getPixbuf("smart"))
factory.add("smart-icon", icon_set)
Пример #29
0
    def __init__(self, parent=None):
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Smart Preferences"))
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_geometry_hints(min_width=400, min_height=300)

        self._vbox = gtk.VBox()
        self._vbox.set_border_width(10)
        self._vbox.set_spacing(10)
        self._vbox.show()
        self.add(self._vbox)

        self._notebook = gtk.Notebook()
        self._notebook.show()
        self._vbox.add(self._notebook)

        if gtk.pygtk_version < (2,12,0):
            self._tooltips = gtk.Tooltips()

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_border_width(5)
        sw.show()

        table = gtk.Table()
        table.set_row_spacings(2)
        table.set_col_spacings(5)
        table.set_border_width(5)
        table.show()
        sw.add_with_viewport(table)

        def set_tooltip(widget, text):
            if gtk.pygtk_version < (2,12,0):
                self._tooltips.set_tip(widget, text)
            else:
                widget.set_tooltip_text(text)

        self._remove_packages = gtk.CheckButton(_("Remove Packages"))
        set_tooltip(self._remove_packages,
                    _("Remove downloaded packages after installation"))
        self._remove_packages.set_active(sysconf.get("remove-packages", True))
        self._remove_packages.show()
        table.attach(self._remove_packages, 0, 1, 0, 0+1,
                     gtk.FILL, gtk.FILL)

        self._commit_stepped = gtk.CheckButton(_("Commit Stepped"))
        set_tooltip(self._commit_stepped,
                    _("Split operations in steps before committing"))
        self._commit_stepped.set_active(sysconf.get("commit-stepped", False))
        self._commit_stepped.show()
        table.attach(self._commit_stepped, 0, 1, 1, 1+1,
                     gtk.FILL, gtk.FILL)

        label = gtk.Label(_("General"))
        self._notebook.append_page(sw, label)

        self._buttonbox = gtk.HButtonBox()
        self._buttonbox.set_spacing(10)
        self._buttonbox.set_layout(gtk.BUTTONBOX_END)
        self._buttonbox.show()
        self._vbox.pack_start(self._buttonbox, expand=False, fill=False)

        self._closebutton = gtk.Button(stock="gtk-close")
        self._closebutton.show()
        self._closebutton.connect("clicked", lambda x: self.close())
        self._buttonbox.pack_start(self._closebutton)
Пример #30
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Icon Legend"))

        font = self.style.font_desc.copy()
        font.set_size(font.get_size() - pango.SCALE)

        boldfont = font.copy()
        boldfont.set_weight(pango.WEIGHT_BOLD)

        self._vbox = gtk.VBox()
        self._vbox.set_border_width(10)
        self._vbox.set_spacing(10)
        self._vbox.show()
        self.add(self._vbox)

        attrslabel = pango.AttrList()
        attrslabel.insert(pango.AttrFontDesc(boldfont, 0, -1))

        label = gtk.Label(
            _("The following icons are used to indicate\nthe current status of a package:"
              ))
        label.set_attributes(attrslabel)
        label.show()
        self._vbox.add(label)

        table = gtk.Table()
        table.set_row_spacings(2)
        table.set_col_spacings(5)
        table.set_border_width(5)
        table.show()
        self._vbox.add(table)

        row = 0
        for icon, legend in [
            (getPixbuf("package-install"), _("Marked for installation")),
            (getPixbuf("package-reinstall"), _("Marked for re-installation")),
            (getPixbuf("package-upgrade"), _("Marked for upgrade")),
            (getPixbuf("package-downgrade"), _("Marked for downgrade")),
            (getPixbuf("package-remove"), _("Marked for removal")),
            (getPixbuf("package-available"), _("Not installed")),
            (getPixbuf("package-new"), _("Not installed (new)")),
            (getPixbuf("package-available-locked"),
             _("Not installed (locked)")),
            (getPixbuf("package-installed"), _("Installed")),
            (getPixbuf("package-installed-outdated"),
             _("Installed (upgradable)")),
            (getPixbuf("package-installed-locked"), _("Installed (locked)")),
            (getPixbuf("package-broken"), _("Broken")),
        ]:
            image = gtk.Image()
            image.set_from_pixbuf(icon)
            image.show()
            table.attach(image, 0, 1, row, row + 1, gtk.FILL, gtk.FILL)
            label = gtk.Label(legend)
            label.set_alignment(0.0, 0.5)
            label.show()
            table.attach(label, 1, 2, row, row + 1, gtk.FILL, gtk.FILL)
            row += 1

        self._buttonbox = gtk.HButtonBox()
        self._buttonbox.set_spacing(10)
        self._buttonbox.set_layout(gtk.BUTTONBOX_END)
        self._buttonbox.show()
        self._vbox.pack_start(self._buttonbox, expand=False, fill=False)

        self._closebutton = gtk.Button(stock="gtk-close")
        self._closebutton.show()
        self._closebutton.connect("clicked", lambda x: self.hide())
        self._buttonbox.pack_start(self._closebutton)
Пример #31
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Package Priority"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)

        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)

        label = gtk.Label(_("Package Name:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        self._name = gtk.Entry()
        self._name.show()
        table.attach(self._name, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Channel Alias:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._alias = gtk.Entry()
        self._alias.set_text("*")
        self._alias.show()
        table.attach(self._alias, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Priority:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL)

        self._priority = gtk.SpinButton()
        self._priority.set_width_chars(8)
        self._priority.set_increments(1, 10)
        self._priority.set_numeric(True)
        self._priority.set_range(-100000, +100000)
        self._priority.show()
        align = gtk.Alignment(0.0, 0.5)
        align.show()
        align.add(self._priority)
        table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-cancel")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-ok")
        button.show()

        def clicked(x):
            self._result = True
            gtk.main_quit()

        button.connect("clicked", clicked)
        bbox.pack_start(button)
Пример #32
0
    def packagePopup(self, packageview, pkgs, event):

        menu = gtk.Menu()

        hasinstalled = bool([pkg for pkg in pkgs if pkg.installed
                             and self._changeset.get(pkg) is not REMOVE])
        hasnoninstalled = bool([pkg for pkg in pkgs if not pkg.installed
                                and self._changeset.get(pkg) is not INSTALL])

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-install"))
        item = gtk.ImageMenuItem(_("Install"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, INSTALL))
        if not hasnoninstalled:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-reinstall"))
        item = gtk.ImageMenuItem(_("Reinstall"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, REINSTALL))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)


        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-remove"))
        item = gtk.ImageMenuItem(_("Remove"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, REMOVE))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        if not hasinstalled:
            image.set_from_pixbuf(getPixbuf("package-available"))
        else:
            image.set_from_pixbuf(getPixbuf("package-installed"))
        item = gtk.ImageMenuItem(_("Keep"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, KEEP))
        if not [pkg for pkg in pkgs if pkg in self._changeset]:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        image.set_from_pixbuf(getPixbuf("package-broken"))
        item = gtk.ImageMenuItem(_("Fix problems"))
        item.set_image(image)
        item.connect("activate", lambda x: self.actOnPackages(pkgs, FIX))
        if not hasinstalled:
            item.set_sensitive(False)
        menu.append(item)

        inconsistent = False
        thislocked = None
        alllocked = None
        names = pkgconf.getFlagTargets("lock")
        if [pkg for pkg in pkgs if pkg in self._changeset]:
            inconsistent = True
        else:
            for pkg in pkgs:
                if (names and pkg.name in names and 
                    ("=", pkg.version) in names[pkg.name]):
                    newthislocked = True
                    newalllocked = len(names[pkg.name]) > 1
                else:
                    newthislocked = False
                    newalllocked = pkgconf.testFlag("lock", pkg)
                if (thislocked is not None and thislocked != newthislocked or
                    alllocked is not None and alllocked != newalllocked):
                    inconsistent = True
                    break
                thislocked = newthislocked
                alllocked = newalllocked

        image = gtk.Image()
        if thislocked:
            item = gtk.ImageMenuItem(_("Unlock this version"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available"))
            def unlock_this(x):
                for pkg in pkgs:
                    pkgconf.clearFlag("lock", pkg.name, "=", pkg.version)
                self._pv.queue_draw()
                self._pi.setPackage(pkgs[0])
            item.connect("activate", unlock_this)
        else:
            item = gtk.ImageMenuItem(_("Lock this version"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed-locked"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available-locked"))
            def lock_this(x):
                for pkg in pkgs:
                    pkgconf.setFlag("lock", pkg.name, "=", pkg.version)
                self._pv.queue_draw()
                self._pi.setPackage(pkgs[0])
            item.connect("activate", lock_this)
        item.set_image(image)
        if inconsistent:
            item.set_sensitive(False)
        menu.append(item)

        image = gtk.Image()
        if alllocked:
            item = gtk.ImageMenuItem(_("Unlock all versions"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available"))
            def unlock_all(x):
                for pkg in pkgs:
                    pkgconf.clearFlag("lock", pkg.name)
                self._pv.queue_draw()
                self._pi.setPackage(pkgs[0])
            item.connect("activate", unlock_all)
        else:
            item = gtk.ImageMenuItem(_("Lock all versions"))
            if not hasnoninstalled:
                image.set_from_pixbuf(getPixbuf("package-installed-locked"))
            else:
                image.set_from_pixbuf(getPixbuf("package-available-locked"))
            def lock_all(x):
                for pkg in pkgs:
                    pkgconf.setFlag("lock", pkg.name)
                self._pv.queue_draw()
                self._pi.setPackage(pkgs[0])
            item.connect("activate", lock_all)
        item.set_image(image)
        if inconsistent:
            item.set_sensitive(False)
        menu.append(item)

        item = gtk.MenuItem(_("Priority"))
        def priority(x):
            GtkSinglePriority(self._window).show(pkgs[0])
            self._pi.setPackage(pkgs[0])
        item.connect("activate", priority)
        if len(pkgs) != 1:
            item.set_sensitive(False)
        menu.append(item)

        menu.show_all()
        menu.popup(None, None, None, event.button, event.time)
Пример #33
0
    def __init__(self, hassub):
        Progress.__init__(self)
        gtk.Window.__init__(self)
        self.__gobject_init__()

        self.connect("delete-event", lambda x,y: True)

        self._hassub = hassub
        self._shorturl = ShortURL(50)
        self._ticking = False
        self._stopticking = False
        self._fetcher = None

        if hassub:
            self.set_size_request(500, 400)
        else:
            self.set_size_request(300, 80)

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Operation Progress"))
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        gtk.Window.add(self, vbox)

        self._topic = gtk.Label()
        self._topic.set_alignment(0, 0.5)
        self._topic.show()
        vbox.pack_start(self._topic, expand=False, fill=False)

        self._progress = gtk.ProgressBar()
        self._progress.set_size_request(-1, 25)
        self._progress.show()
        vbox.pack_start(self._progress, expand=False, fill=False)

        if hassub:
            self._scrollwin = gtk.ScrolledWindow()
            self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
            self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
            self._scrollwin.show()
            vbox.pack_start(self._scrollwin)

            self._treemodel = gtk.ListStore(gobject.TYPE_INT,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING,
                                            gobject.TYPE_STRING)
            self._treeview = gtk.TreeView(self._treemodel)
            self._treeview.show()
            self._scrollwin.add(self._treeview)

            renderer = ProgressCellRenderer()
            column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            column.set_fixed_width(110)
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
            self._currentcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
            self._totalcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Speed"), renderer, text=4)
            self._speedcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Description"), renderer, text=1)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            self._treeview.append_column(column)

            self._subiters = {}
            self._subindex = 0
            self._lastpath = None

            self._bbox = gtk.HButtonBox()
            self._bbox.set_spacing(10)
            self._bbox.set_layout(gtk.BUTTONBOX_END)
            vbox.pack_start(self._bbox, expand=False)

            button = gtk.Button(stock="gtk-cancel")
            button.show()
            button.connect("clicked", self._cancel)
            self._bbox.pack_start(button)
Пример #34
0
    def __init__(self, hassub):
        Progress.__init__(self)
        gtk.Window.__init__(self)

        self.connect("delete-event", lambda x, y: True)

        # updates from subthreads not showing up [#592503]
        self._threadsafe = not glib or glib.glib_version < (2, 24, 0)

        self._hassub = hassub
        self._shorturl = ShortURL(50)
        self._ticking = False
        self._stopticking = False
        self._fetcher = None

        if hassub:
            self.set_size_request(500, 100)
            self.set_default_size(500, 400)
        else:
            self.set_size_request(300, 80)

        def configure_event(widget, event):
            maxlen = widget.allocation.width / 10
            self._shorturl = ShortURL(maxlen)
            return False

        self.connect("configure-event", configure_event)

        self.set_icon(getPixbuf("smart"))
        self.set_title(_("Operation Progress"))
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        gtk.Window.add(self, vbox)

        self._topic = gtk.Label()
        self._topic.set_alignment(0, 0.5)
        self._topic.show()
        vbox.pack_start(self._topic, expand=False, fill=False)

        self._progressbar = gtk.ProgressBar()
        self._progressbar.set_size_request(-1, 25)
        self._progressbar.show()
        vbox.pack_start(self._progressbar, expand=False, fill=False)

        if hassub:
            expander = gtk.Expander()
            expander.set_expanded(True)
            expander.show()

            def toggle_window(expander, param_spec):
                if expander.get_expanded():
                    self.resize(500, 400)
                else:
                    self.resize(500, 100)

            expander.connect("notify::expanded", toggle_window)
            vbox.pack_start(expander)

            self._scrollwin = gtk.ScrolledWindow()
            self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
            self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
            self._scrollwin.show()
            expander.add(self._scrollwin)

            self._treemodel = gtk.ListStore(
                gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING,
                gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
            self._treeview = gtk.TreeView(self._treemodel)
            self._treeview.show()
            self._scrollwin.add(self._treeview)

            if gtk.pygtk_version < (2, 6, 0):
                renderer = ProgressCellRenderer()
                column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
            else:
                renderer = gtk.CellRendererProgress()
                # don't display the percent label
                renderer.set_property("text", "")
                column = gtk.TreeViewColumn(_("Progress"), renderer, value=0)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            column.set_fixed_width(110)
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
            self._currentcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
            self._totalcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Speed"), renderer, text=4)
            self._speedcolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("ETA"), renderer, text=5)
            self._etacolumn = column
            self._treeview.append_column(column)

            renderer = gtk.CellRendererText()
            renderer.set_fixed_height_from_font(True)
            column = gtk.TreeViewColumn(_("Description"), renderer, text=1)
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
            self._treeview.append_column(column)

            self._subiters = {}
            self._subindex = 0
            self._lastpath = None

            self._bbox = gtk.HButtonBox()
            self._bbox.set_spacing(10)
            self._bbox.set_layout(gtk.BUTTONBOX_END)
            vbox.pack_start(self._bbox, expand=False)

            button = gtk.Button(stock="gtk-cancel")
            button.show()
            button.connect("clicked", self._cancel)
            self._bbox.pack_start(button)