예제 #1
0
    def show(self):
        """Show the ConnectionManager dialog."""
        self.builder = gtk.Builder()
        self.builder.add_from_file(
            resource_filename('deluge.ui.gtkui',
                              os.path.join('glade', 'connection_manager.ui')))
        self.connection_manager = self.builder.get_object('connection_manager')
        self.connection_manager.set_transient_for(
            component.get('MainWindow').window)

        # Create status pixbufs
        if not HOSTLIST_PIXBUFS:
            for stock_id in (gtk.STOCK_NO, gtk.STOCK_YES, gtk.STOCK_CONNECT):
                HOSTLIST_PIXBUFS.append(
                    self.connection_manager.render_icon(
                        stock_id, gtk.ICON_SIZE_MENU))

        # Setup the hostlist liststore and treeview
        self.treeview = self.builder.get_object('treeview_hostlist')
        self.liststore = self.builder.get_object('liststore_hostlist')

        render = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_('Status'), render)
        column.set_cell_data_func(render, cell_render_status,
                                  HOSTLIST_COL_STATUS)
        self.treeview.append_column(column)

        render = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Host'), render, text=HOSTLIST_COL_HOST)
        host_data = (HOSTLIST_COL_HOST, HOSTLIST_COL_PORT, HOSTLIST_COL_USER)
        column.set_cell_data_func(render, cell_render_host, host_data)
        column.set_expand(True)
        self.treeview.append_column(column)

        column = gtk.TreeViewColumn(_('Version'),
                                    gtk.CellRendererText(),
                                    text=HOSTLIST_COL_VERSION)
        self.treeview.append_column(column)

        # Load any saved host entries
        self._load_liststore()
        # Set widgets to values from gtkui config.
        self._load_widget_config()
        self._update_widget_buttons()

        # Connect the signals to the handlers
        self.builder.connect_signals(self)
        self.treeview.get_selection().connect(
            'changed', self.on_hostlist_selection_changed)

        # Set running True before update status call.
        self.running = True

        if windows_check():
            # Call to simulate() required to workaround showing daemon status (see #2813)
            reactor.simulate()
        self._update_host_status()

        # Trigger the on_selection_changed code and select the first host if possible
        self.treeview.get_selection().unselect_all()
        if len(self.liststore):
            self.treeview.get_selection().select_path(0)

        # Run the dialog
        self.connection_manager.run()

        # Dialog closed so cleanup.
        self.running = False
        self.connection_manager.destroy()
        del self.builder
        del self.connection_manager
        del self.liststore
        del self.treeview
예제 #2
0
    def show(self):
        """Show the ConnectionManager dialog."""
        self.builder = gtk.Builder()
        self.builder.add_from_file(resource_filename(
            'deluge.ui.gtkui', os.path.join('glade', 'connection_manager.ui')))
        self.connection_manager = self.builder.get_object('connection_manager')
        self.connection_manager.set_transient_for(component.get('MainWindow').window)

        # Create status pixbufs
        if not HOSTLIST_PIXBUFS:
            for stock_id in (gtk.STOCK_NO, gtk.STOCK_YES, gtk.STOCK_CONNECT):
                HOSTLIST_PIXBUFS.append(
                    self.connection_manager.render_icon(stock_id, gtk.ICON_SIZE_MENU))

        # Setup the hostlist liststore and treeview
        self.treeview = self.builder.get_object('treeview_hostlist')
        self.liststore = self.builder.get_object('liststore_hostlist')

        render = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_('Status'), render)
        column.set_cell_data_func(render, cell_render_status, HOSTLIST_COL_STATUS)
        self.treeview.append_column(column)

        render = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Host'), render, text=HOSTLIST_COL_HOST)
        host_data = (HOSTLIST_COL_HOST, HOSTLIST_COL_PORT, HOSTLIST_COL_USER)
        column.set_cell_data_func(render, cell_render_host, host_data)
        column.set_expand(True)
        self.treeview.append_column(column)

        column = gtk.TreeViewColumn(_('Version'), gtk.CellRendererText(), text=HOSTLIST_COL_VERSION)
        self.treeview.append_column(column)

        # Load any saved host entries
        self._load_liststore()
        # Set widgets to values from gtkui config.
        self._load_widget_config()
        self._update_widget_buttons()

        # Connect the signals to the handlers
        self.builder.connect_signals(self)
        self.treeview.get_selection().connect('changed', self.on_hostlist_selection_changed)

        # Set running True before update status call.
        self.running = True

        if windows_check():
            # Call to simulate() required to workaround showing daemon status (see #2813)
            reactor.simulate()
        self._update_host_status()

        # Trigger the on_selection_changed code and select the first host if possible
        self.treeview.get_selection().unselect_all()
        if len(self.liststore):
            self.treeview.get_selection().select_path(0)

        # Run the dialog
        self.connection_manager.run()

        # Dialog closed so cleanup.
        self.running = False
        self.connection_manager.destroy()
        del self.builder
        del self.connection_manager
        del self.liststore
        del self.treeview
예제 #3
0
        buildmaster = self.buildmaster_entry.get_text()
        self.parent.set_buildmaster(buildmaster)
        self.w.unmap()


def factory(applet, iid):
    MyApplet(applet)
    applet.show_all()
    return True


from twisted.internet import reactor

# instead of reactor.run(), we do the following:
reactor.startRunning()
reactor.simulate()
gnomeapplet.bonobo_factory("OAFIID:GNOME_Buildbot_Factory",
                           gnomeapplet.Applet.__gtype__,
                           "buildbot", "0", factory)

# code ends here: bonobo_factory runs gtk.mainloop() internally and
# doesn't return until the program ends

# SUPPORTING FILES:

# save the following as ~/lib/bonobo/servers/bb_applet.server, and update all
# the pathnames to match your system
bb_applet_server = """
<oaf_info>

<oaf_server iid="OAFIID:GNOME_Buildbot_Factory"
예제 #4
0
        buildmaster = self.buildmaster_entry.get_text()
        self.parent.set_buildmaster(buildmaster)
        self.w.unmap()


def factory(applet, iid):
    MyApplet(applet)
    applet.show_all()
    return True


from twisted.internet import reactor

# instead of reactor.run(), we do the following:
reactor.startRunning()
reactor.simulate()
gnomeapplet.bonobo_factory("OAFIID:GNOME_Buildbot_Factory",
                           gnomeapplet.Applet.__gtype__, "buildbot", "0",
                           factory)

# code ends here: bonobo_factory runs gtk.mainloop() internally and
# doesn't return until the program ends

# SUPPORTING FILES:

# save the following as ~/lib/bonobo/servers/bb_applet.server, and update all
# the pathnames to match your system
bb_applet_server = """
<oaf_info>

<oaf_server iid="OAFIID:GNOME_Buildbot_Factory"