Ejemplo n.º 1
0
    def __init__(self):

        self.callbacks = {}
        self.conf = SlogConf()
        proxy = Proxy(self.conf)
        self.google = GoogleEngine(proxy)

        gladefile = os.path.join(path, "google.glade")
        self.wtree = gtk.glade.XML(gladefile, domain="slog")
        self.wtree.signal_autoconnect({
            "on_btn_clear_clicked":
            self.on_btn_clear_clicked,
            "on_btn_translate_clicked":
            self.on_translate_clicked
        })

        self.vbox = self.wtree.get_widget("vbox1")
        self.vbox.unparent()

        self.textview = self.wtree.get_widget("textview1")

        self.cmb_target = self.wtree.get_widget("combo_targets")
        cell = gtk.CellRendererText()
        self.cmb_target.pack_start(cell, True)
        self.cmb_target.add_attribute(cell, 'text', 0)
        self.model = gtk.ListStore(str, str, str)
        self.cmb_target.set_model(self.model)

        reload_targets(self.google.languages, self.model,
                       self.conf.get_google_targets())
        self.cmb_target.set_active(self.conf.google_target)
Ejemplo n.º 2
0
	def __init__(self):

		self.callbacks = {}
		self.conf = SlogConf()
		proxy = Proxy(self.conf)
		self.google = GoogleEngine(proxy)

		gladefile = os.path.join(path, "google.glade")
		self.wtree = gtk.glade.XML(gladefile, domain="slog")
		self.wtree.signal_autoconnect({
				"on_btn_clear_clicked" : self.on_btn_clear_clicked,
				"on_btn_translate_clicked" : self.on_translate_clicked
		})

		self.vbox = self.wtree.get_widget("vbox1")
		self.vbox.unparent()

		self.textview = self.wtree.get_widget("textview1")

		self.cmb_target = self.wtree.get_widget("combo_targets")
		cell = gtk.CellRendererText()
		self.cmb_target.pack_start(cell, True)
		self.cmb_target.add_attribute(cell, 'text', 0)
		self.model = gtk.ListStore(str, str, str)
		self.cmb_target.set_model(self.model)
		
		reload_targets(self.google.languages, self.model, self.conf.get_google_targets())
		self.cmb_target.set_active(self.conf.google_target)
Ejemplo n.º 3
0
class GoogleView(object):

	def __init__(self):

		""" Google View Widget """

		self.callbacks = {}
		self.conf = SlogConf()
		proxy = Proxy(self.conf)
		self.google = GoogleEngine(proxy)

		gladefile = os.path.join(path, "google.glade")
		self.wtree = gtk.glade.XML(gladefile, domain="slog")
		self.wtree.signal_autoconnect({
				"on_btn_clear_clicked" : self.on_btn_clear_clicked,
				"on_btn_translate_clicked" : self.on_translate_clicked
		})

		self.vbox = self.wtree.get_widget("vbox1")
		self.vbox.unparent()

		self.textview = self.wtree.get_widget("textview1")

		self.cmb_target = self.wtree.get_widget("combo_targets")
		cell = gtk.CellRendererText()
		self.cmb_target.pack_start(cell, True)
		self.cmb_target.add_attribute(cell, 'text', 0)
		self.model = gtk.ListStore(str, str, str)
		self.cmb_target.set_model(self.model)

		reload_targets(self.google.languages, self.model, self.conf.get_google_targets())
		self.cmb_target.set_active(self.conf.google_target)

	def __fire_translate_changed(self, translate):

		""" Оповестить обработчики о том, что перевод изменился"""

		callback = self.callbacks["translate_it"]
		if callback is not None:
			callback("Google", translate)

	def __fire_status_changed(self, message, needClear=False):

		""" Оповестить обработчики о том, что статус изменился"""

		callback = self.callbacks["changed"]
		if callback is not None:
			gobject.idle_add(callback, message)
			if needClear:
				gobject.timeout_add(5000, self.__fire_status_changed, "")

	# Thread function
	def request_google(self, src, dst, text):
		try:
			translate = self.google.translate(src, dst, text)
		except urllib2.URLError, err:
			msg = "Google error: %s" % err
			print msg
			self.__fire_status_changed(msg, True)
		else:
Ejemplo n.º 4
0
class GoogleView(object):
    def __init__(self):

        self.callbacks = {}
        self.conf = SlogConf()
        proxy = Proxy(self.conf)
        self.google = GoogleEngine(proxy)

        gladefile = os.path.join(path, "google.glade")
        self.wtree = gtk.glade.XML(gladefile, domain="slog")
        self.wtree.signal_autoconnect({
            "on_btn_clear_clicked":
            self.on_btn_clear_clicked,
            "on_btn_translate_clicked":
            self.on_translate_clicked
        })

        self.vbox = self.wtree.get_widget("vbox1")
        self.vbox.unparent()

        self.textview = self.wtree.get_widget("textview1")

        self.cmb_target = self.wtree.get_widget("combo_targets")
        cell = gtk.CellRendererText()
        self.cmb_target.pack_start(cell, True)
        self.cmb_target.add_attribute(cell, 'text', 0)
        self.model = gtk.ListStore(str, str, str)
        self.cmb_target.set_model(self.model)

        reload_targets(self.google.languages, self.model,
                       self.conf.get_google_targets())
        self.cmb_target.set_active(self.conf.google_target)

    def __fire_translate_changed(self, translate):
        callback = self.callbacks["translate_it"]
        if callback is not None:
            callback("Google", translate)

    def __fire_status_changed(self, message, needClear=False):
        callback = self.callbacks["changed"]
        if callback is not None:
            gobject.idle_add(callback, message)
            if needClear:
                gobject.timeout_add(5000, self.__fire_status_changed, "")

    # Thread function
    def request_google(self, src, dst, text):
        try:
            translate = self.google.translate(src, dst, text)
        except urllib2.URLError, err:
            msg = "Google error: %s" % err
            print msg
            self.__fire_status_changed(msg, True)
        else: