Beispiel #1
0
 def setScreenWidth(self, width):
     self._screenwidth = width
     self._topicwidth = int(width * 0.4)
     self._hashwidth = int(width - self._topicwidth - 1)
     self._topicmask = "%%-%d.%ds" % (self._topicwidth, self._topicwidth)
     self._topicmaskn = "%%4d:%%-%d.%ds" % (self._topicwidth - 5,
                                            self._topicwidth - 5)
     self._shorturl = ShortURL(width - 4)
Beispiel #2
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)
Beispiel #3
0
 def configure_event(widget, event):
     maxlen = widget.allocation.width / 10
     self._shorturl = ShortURL(maxlen)
     return False
Beispiel #4
0
    def __init__(self, hassub, parent=None):
        Progress.__init__(self)
        qt.QDialog.__init__(self, parent)

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

        self._beenshown = False
        self._mainthread = None

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

        self.setIcon(getPixmap("smart"))
        self.setCaption(_("Operation Progress"))

        vbox = qt.QVBoxLayout(self, 10, 10)
        vbox.setResizeMode(qt.QLayout.FreeResize)
        vbox.setMargin(10)
        vbox.setSpacing(10)

        self._topic = qt.QLabel(self)
        vbox.addWidget(self._topic)

        self._progressbar = qt.QProgressBar(self)
        self._progressbar.setPercentageVisible(True)
        self._progressbar.show()
        vbox.addWidget(self._progressbar)

        if hassub:
            self._listview = qt.QListView(self)
            self._listview.setSorting(-1, False)
            self._listview.setSelectionMode(qt.QListView.NoSelection)
            self._listview.show()
            vbox.addWidget(self._listview)

            column = self._listview.addColumn(_("Progress"))
            self._listview.setColumnWidthMode(column, qt.QListView.Manual)
            self._listview.setColumnWidth(column, 55)
            column = self._listview.addColumn(_("Current"))
            self._currentcolumn = column
            column = self._listview.addColumn(_("Total"))
            self._totalcolumn = column
            column = self._listview.addColumn(_("Speed"))
            self._speedcolumn = column
            column = self._listview.addColumn(_("ETA"))
            self._etacolumn = column
            column = self._listview.addColumn(_("Description"))
            self._listview.setColumnWidthMode(column, qt.QListView.Manual)
            self._listview.setColumnWidth(column, 165)
            self._desccolumn = column

            self._subiters = {}
            self._subindex = 0

            self._bbox = qt.QHBox(self)
            self._bbox.setSpacing(10)
            self._bbox.layout().addStretch(1)
            vbox.addWidget(self._bbox)

            button = qt.QPushButton(_("Cancel"), self._bbox)
            button.show()
            qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._cancel)
Beispiel #5
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)