示例#1
0
    def start_shoebot(self):
        # sbot_bin=gtk2_utils.sbot_executable()
        sbot_bin = which("sbot")  ### TODO - use same mechanism as gtk3

        if not sbot_bin:
            textbuffer = self.output_widget.get_buffer()
            textbuffer.set_text("Cannot find sbot in path.")
            while gtk.events_pending():
                gtk.main_iteration(block=False)
            return False

        if self.bot and self.bot.process.poll() == None:
            print("Sending quit.")
            self.bot.send_command("quit")

        # get the text buffer
        doc = self.window.get_active_document()
        if not doc:
            return

        title = "%s - Shoebot on gedit" % doc.get_short_name_for_display()
        cwd = os.path.dirname(doc.get_uri_for_display()) or None

        start, end = doc.get_bounds()
        source = doc.get_text(start, end, False)
        if not source:
            return False

        textbuffer = self.output_widget.get_buffer()
        textbuffer.set_text("running shoebot at %s\n" % sbot_bin)

        while gtk.events_pending():
            gtk.main_iteration()

        self.disconnect_change_handler(doc)
        self.changed_handler_id = doc.connect("changed", self.doc_changed)

        self.bot = ide_utils.ShoebotProcess(
            source,
            self.use_socketserver,
            self.show_varwindow,
            self.use_fullscreen,
            self.verbose_output,
            title,
            cwd=cwd,
            sbot=sbot_bin,
        )
        self.idle_handler_id = gobject.idle_add(self.update_shoebot)
示例#2
0
    def start_shoebot(self):
        sbot_bin = gtk3_utils.sbot_executable()
        if not sbot_bin:
            textbuffer = self.text.get_buffer()
            textbuffer.set_text("Cannot find sbot in path.")
            while Gtk.events_pending():
                Gtk.main_iteration()
            return False

        if self.bot and self.bot.process.poll() == None:
            print("Sending quit.")
            self.bot.send_command("quit")
            # TODO - wait for response.

        # get the text buffer
        doc = self.window.get_active_document()
        if not doc:
            return

        title = "%s - Shoebot on gedit" % doc.get_short_name_for_display()
        cwd = os.path.dirname(doc.get_uri_for_display()) or None

        start, end = doc.get_bounds()
        source = doc.get_text(start, end, False)
        if not source:
            return False

        textbuffer = self.text.get_buffer()
        textbuffer.set_text("running shoebot at %s\n" % sbot_bin)

        while Gtk.events_pending():
            Gtk.main_iteration()

        self.disconnect_change_handler(doc)
        self.changed_handler_id = doc.connect("changed", self.doc_changed)

        self.bot = ide_utils.ShoebotProcess(
            source,
            self.socket_server_enabled,
            self.var_window_enabled,
            self.full_screen_enabled,
            self.verbose_output_enabled,
            title,
            cwd=cwd,
            sbot=sbot_bin,
        )
        self.idle_handler_id = GObject.idle_add(self.update_shoebot)