← Back to team overview

cairo-dock-team team mailing list archive

[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/doCkranslator into lp:cairo-dock-plug-ins-extras

 

Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/doCkranslator into lp:cairo-dock-plug-ins-extras.

Requested reviews:
  Cairo-Dock Team (cairo-dock-team)


For Cairo-dock 2.2.0 or higher, the user can move from the translation result to a new translation, or edit the recently translated text.
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/doCkranslator/+merge/33602
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/doCkranslator into lp:cairo-dock-plug-ins-extras.
=== modified file 'Translator/Changelog.txt'
--- Translator/Changelog.txt	2010-08-23 19:19:08 +0000
+++ Translator/Changelog.txt	2010-08-25 00:45:51 +0000
@@ -1,3 +1,4 @@
+0.1.4:(August/24/2010): For Cairo-dock 2.2.0 or higher, the user can move from the translation result to a new translation, or edit the recently translated text.
 0.1.3: (August/23/2010): Adding the dock-level shortcut Ctrl + F9, requires Cairo-Dock 2.2.0 or higher. Removing glib import since it was redundant and causing problems in Debian Lenny.
 0.1.2:(August/8/2010): Formally known as doCkranslator, the applet was renamed to Translator.
 0.1.1:(July/18/2010): Switch languages menu added, thanks to Matttbe for this suggestion. util module added.

=== modified file 'Translator/Translator'
--- Translator/Translator	2010-08-23 19:19:08 +0000
+++ Translator/Translator	2010-08-25 00:45:51 +0000
@@ -186,12 +186,15 @@
         self.icon = icon
         self.configuration = configuration                                              # configuration file
         self.translated_text = ""
+        self.text_to_be_translated = ""
         self.source = None                                                              # get it from configuration file
         self.sources = []                                                               # list of possible source languages
         self.destiny = None                                                             # get it from configuration file
         self.destinies = []                                                             # list of possible resulting languages
         self.scroll_destiny_language = 0
         self.dialog_active_time = 10                                                    # time in seconds that the dialog window will be active
+        self.new_translation_key = 1                                                    # there are 3 buttons, cancel = 0, new = 1 ...
+        self.edit_translation_key = 2                                                   # ... and edit
 
     def start(self):
         log ("Applet start")
@@ -209,6 +212,7 @@
         self.icon.connect_to_signal("on_middle_click", self.action_on_middle_click)
         self.icon.connect_to_signal("on_reload_module", self.action_on_reload)
         self.icon.connect_to_signal("on_shortkey", self.action_on_dock_level_shortkey)
+        self.icon.connect_to_signal("on_answer_dialog", self.action_on_answer_dialog)
 
     def set_configuration_parameters(self):
         reader = ConfigParser.RawConfigParser()
@@ -242,15 +246,13 @@
 
         interface = Interface(sentence)                                                 # alimenta o tradutor com o sentence a ser traduzida
         translated = interface.translate_it(source, destiny)                            # o resultado, que eh texto traduzido
-
-        try:                                                                            # Cairo dock 2.2.0 or higher
-            self.icon.PopupDialog({'message':'Translated text', 'time-length':self.dialog_active_time}, {'widget-type':'text-entry', 'initial-value':translated})
-        except Exception:                                                               # Weirdly dbus.DBusException is not being thrown in CD < 2.2.0
-            log ("PopupDialog won't be shown, ShowDialog was used instead, update Cairo-dock to 2.2.0 or higher")
+        try:
+            self.icon.PopupDialog({'message':translated, "buttons":"cancel;stock_new;stock_edit"}, {})
+        except Exception:
+            log("Error caused PopupDialog not be shown, ShowDialog was used instead")
             self.icon.ShowDialog(translated, self.dialog_active_time)
         else:
-            log ("PopupDialog succesfully shown, Cairo-dock 2.2.0 or higher is up and running")
-
+            log("PopupDialog succesfully shown")
         self.set_to_clipboard(translated)                                               # coloca o resultado na area de transferencia
 
         self.inform_end_of_waiting_process()
@@ -266,7 +268,19 @@
 
     def action_on_answer(self, answer):
         if answer:
-        	self.translate(answer, self.source.abbrv, self.destiny.abbrv)               # what to be translated, the source and destination languages
+            self.text_to_be_translated = answer
+            self.translate(answer, self.source.abbrv, self.destiny.abbrv)               # what to be translated, the source and destination languages
+
+    # Caso eu tivesse usado o widget-type = 'text-entry', o valor do 'content' seria o
+    # conteudo string do campo de texto, mas como resultados com strings grandes tem
+    # pouca legibilidade na caixa de texto do 'text-entry', deixei o PopupDialog
+    # apenas funcionar como ShowDialog (exibindo mensagem). Portanto, o 'content' vem com 
+    # o valor igual ao do 'key' e nao como a string contida no campo de texto
+    def action_on_answer_dialog(self, key, content):
+        if (key == self.new_translation_key):                                            # cancel button = 0, and new = 1
+            self.ask_text()                                                              # abre a entrada para nova traducao
+        elif (key == self.edit_translation_key):
+            self.ask_text(self.text_to_be_translated)                                    # traducao com o valor anterior a ser editado 
 
     def action_on_middle_click(self):
         """When middle-clicked the applet get the clipboard 

=== modified file 'Translator/Translator.conf'
--- Translator/Translator.conf	2010-08-23 19:19:08 +0000
+++ Translator/Translator.conf	2010-08-25 00:45:51 +0000
@@ -1,4 +1,4 @@
-#!en;0.1.3
+#!en;0.1.4
 
 #[gtk-about]
 [Icon]

=== modified file 'Translator/auto-load.conf'
--- Translator/auto-load.conf	2010-08-23 19:19:08 +0000
+++ Translator/auto-load.conf	2010-08-25 00:45:51 +0000
@@ -10,4 +10,4 @@
 category = 5
 
 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
-version = 0.1.3
+version = 0.1.4


Follow ups