Hello community,

here is the log from the commit of package translator for openSUSE:Factory 
checked in at 2018-04-04 11:05:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/translator (Old)
 and      /work/SRC/openSUSE:Factory/.translator.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "translator"

Wed Apr  4 11:05:27 2018 rev:4 rq:593090 version:1.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/translator/translator.changes    2018-02-24 
16:39:17.501639155 +0100
+++ /work/SRC/openSUSE:Factory/.translator.new/translator.changes       
2018-04-04 11:05:35.155675764 +0200
@@ -1,0 +2,10 @@
+Sat Mar 17 16:09:57 UTC 2018 - avvi...@yandex.by
+
+- Update to 1.2.0:
+  * Merge pull request #37 from 
+    mkinitcpio/#35-Ugly_selected_text_highlight
+  * Fix #24 Fix #13
+  * Remove space
+  * Fix text selection style
+
+-------------------------------------------------------------------

Old:
----
  Translator-1.1.0.tar.gz

New:
----
  Translator-1.2.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ translator.spec ++++++
--- /var/tmp/diff_new_pack.0hacQb/_old  2018-04-04 11:05:36.267635464 +0200
+++ /var/tmp/diff_new_pack.0hacQb/_new  2018-04-04 11:05:36.267635464 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           translator
-Version:        1.1.0
+Version:        1.2.0
 Release:        0
 Summary:        Translation program
 License:        GPL-3.0+

++++++ Translator-1.1.0.tar.gz -> Translator-1.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/CMakeLists.txt 
new/Translator-1.2.0/CMakeLists.txt
--- old/Translator-1.1.0/CMakeLists.txt 2018-02-14 19:45:17.000000000 +0100
+++ new/Translator-1.2.0/CMakeLists.txt 2018-03-14 17:40:12.000000000 +0100
@@ -32,6 +32,7 @@
 
 vala_precompile(VALA_C ${EXEC_NAME}
     src/Main.vala
+    src/utils/TranslatorError.vala
     src/LangInfo.vala
     src/widgets/PopoverCombo.vala
     src/TranslatorApplication.vala
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Translator-1.1.0/data/com.github.rapidfingers.translator.appdata.xml 
new/Translator-1.2.0/data/com.github.rapidfingers.translator.appdata.xml
--- old/Translator-1.1.0/data/com.github.rapidfingers.translator.appdata.xml    
2018-02-14 19:45:17.000000000 +0100
+++ new/Translator-1.2.0/data/com.github.rapidfingers.translator.appdata.xml    
2018-03-14 17:40:12.000000000 +0100
@@ -62,5 +62,14 @@
         </ul>
 ​      </description>
 ​    </release>
+    <release version="1.2.0" date="2018-03-14">
+​      <description>
+​         <ul>
+            <li>Toast message if no connection to server</li>
+            <li>Fix ugly text selection color</li>
+            <li>Minor bugfix</li>
+        </ul>
+​      </description>
+​    </release>
 ​ </releases>
 </component>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/debian/changelog 
new/Translator-1.2.0/debian/changelog
--- old/Translator-1.1.0/debian/changelog       2018-02-14 19:45:17.000000000 
+0100
+++ new/Translator-1.2.0/debian/changelog       2018-03-14 17:40:12.000000000 
+0100
@@ -1,3 +1,9 @@
+translate (1.2.0) precise; urgency=low
+  * Toast message if no connection to server
+  * Fix ugly text selection color
+  * Minor bugfix
+ -- Grabli66 <grabl...@gmail.com>  Tue, 14 March 2018 19:39:00 -0500
+
 translate (1.1.0) precise; urgency=low
   * System icons
   * Better dark theme look
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/src/AsyncTaskExecuter.vala 
new/Translator-1.2.0/src/AsyncTaskExecuter.vala
--- old/Translator-1.1.0/src/AsyncTaskExecuter.vala     2018-02-14 
19:45:17.000000000 +0100
+++ new/Translator-1.2.0/src/AsyncTaskExecuter.vala     2018-03-14 
17:40:12.000000000 +0100
@@ -1,13 +1,16 @@
+/// For executing task on thread
 private class AsyncTask : GLib.Object {
   private bool _isActive;
   private int _timeout;
   private AsyncTaskExecuter _parent;
 
+  /// Constructor
   public AsyncTask(AsyncTaskExecuter parent, int timeout) {
     _parent = parent;
     _timeout = timeout;
   }
 
+  /// Execute on thread
   public void Run() {
       try {
         Thread.usleep(_timeout);
@@ -23,8 +26,12 @@
         });
 
         _isActive = false;
-      } catch (Error e) {
-          stderr.printf(e.message);
+      } 
+      catch(TranslatorError e) {
+        _parent.OnError(e);
+      }      
+      catch (Error e) {
+        stderr.printf(e.message);
       }
     }
 
@@ -38,20 +45,39 @@
   }
 }
 
+/// Executer of AsyncTask
 public class AsyncTaskExecuter : GLib.Object {
+  /// Thread pool
   private ThreadPool<AsyncTask> _pool;
+
+  /// Async task to execute
   private AsyncTask _task;
+
+  /// Timeout of execution
   protected int ExecuteTimeout = 300000;  // Timeout before executing
 
-  public virtual void OnExecute() {}
+  /// On error signal
+  public signal void error(TranslatorError error);
+
+  /// Main working method
+  public virtual void OnExecute() throws TranslatorError {}
+
+  /// On work result
   public virtual void OnResult() {}
 
+  /// On error
+  public void OnError(TranslatorError err) {
+    error(err);
+  }
+
+  /// Constructor
   public AsyncTaskExecuter() {
     _pool = new ThreadPool<AsyncTask>.with_owned_data ((worker) => {
       worker.Start ();
     }, 7, false);
   }
 
+  /// Run task
   protected void Run() {
     if (_task != null) {
         _task.Stop();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/src/TranslatorService.vala 
new/Translator-1.2.0/src/TranslatorService.vala
--- old/Translator-1.1.0/src/TranslatorService.vala     2018-02-14 
19:45:17.000000000 +0100
+++ new/Translator-1.2.0/src/TranslatorService.vala     2018-03-14 
17:40:12.000000000 +0100
@@ -6,14 +6,17 @@
   private string _to;
   private string _text;
 
+  /// On result
   public signal void result(string[] text);
 
+  /// Constructor
   public TranslateService() {
     base();
   }
 
-  public override void OnExecute() {
-    var ntext = Soup.URI.encode(_text, null);
+  /// Task main working method
+  public override void OnExecute() throws TranslatorError {
+    var ntext = Soup.URI.encode(_text, null);    
     var request = 
@"https://translate.yandex.net/api/v1.5/tr.json/translate?key=$(API_KEY)&lang=$(_from)-$(_to)&text=$(ntext)";
     var root = WebJsonClient.Get(request);
     var data = new Gee.ArrayList<string>();
@@ -31,10 +34,12 @@
     }
   }
 
+  /// On result
   public override void OnResult() {
     result(_result);
   }
 
+  /// Start to translate
   public void Translate(string from, string to, string text) {
     _from = from;
     _to = to;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/src/TranslatorWindow.vala 
new/Translator-1.2.0/src/TranslatorWindow.vala
--- old/Translator-1.1.0/src/TranslatorWindow.vala      2018-02-14 
19:45:17.000000000 +0100
+++ new/Translator-1.2.0/src/TranslatorWindow.vala      2018-03-14 
17:40:12.000000000 +0100
@@ -1,7 +1,9 @@
 
 // Main translator window
 public class TranslateWindow : Gtk.ApplicationWindow {
-    private TranslateService service;
+    /// Service for translating
+    private TranslateService _translateService;
+    /// Dictionary service
     private DictionaryService _dictService;
 
     private GlobalSettings global = GlobalSettings.instance();
@@ -41,6 +43,9 @@
     private Gtk.TextTag _normalTag;
     private Gtk.Label _dictLangLabel;
 
+    /// Toast for messages
+    private Granite.Widgets.Toast _toast;
+
     private static int DEFAULT_WIDTH = 0;
     private static int DEFAULT_HEIGHT = 640;
 
@@ -71,7 +76,10 @@
         var style = @"
             GtkTextView {
                 background-color: RGBA(255,0,0,0);
-            }        
+            }
+            GtkTextView:selected {
+                background-color: #3689e6;
+            }
             .dark-separator {
                 color: #888;
             }
@@ -84,16 +92,27 @@
         Granite.Widgets.Utils.set_theming_for_screen (this.get_screen (), 
style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
 
+    /// On service error
+    private void onServiceError(TranslatorError error) {
+        _isTranslating = false;
+        _progressSpinner.active = false;
+
+        _toast.title = _(error.message);
+        _toast.send_notification();
+    }
+
     // Constructor
     // TODO: separate to methods
     public TranslateWindow() {
         langs = global.getLangs();
 
-        service = new TranslateService();
-        service.result.connect(onTranslate);
+        _translateService = new TranslateService();
+        _translateService.result.connect(onTranslate);
+        _translateService.error.connect(onServiceError);
 
         _dictService = new DictionaryService();
         _dictService.result.connect(onDictResult);
+        _dictService.error.connect(onServiceError);
 
         this.window_position = Gtk.WindowPosition.CENTER;
         this.set_gravity(Gdk.Gravity.CENTER);
@@ -183,6 +202,8 @@
         var paned = new Gtk.Paned(Gtk.Orientation.VERTICAL);
         _leftBox.pack_start(paned);
 
+        var topOverlay = new Gtk.Overlay();
+
         topText = new Gtk.TextView();
         topText.set_margin_left(7);
         topText.set_margin_top(7);
@@ -194,6 +215,10 @@
         topScroll.set_policy (Gtk.PolicyType.AUTOMATIC, 
Gtk.PolicyType.AUTOMATIC);
         topScroll.add (topText);
 
+        _toast = new Granite.Widgets.Toast("");
+        topOverlay.add(topScroll);
+        topOverlay.add_overlay(_toast);  
+
         /// Translate destination
         var bottomOverlay = new Gtk.Overlay();        
 
@@ -213,9 +238,10 @@
         _progressSpinner = new Gtk.Spinner ();
         _progressSpinner.active = false;
         _progressSpinner.margin = 70;
-        
+                
+
         bottomOverlay.add(bottomScroll);
-        bottomOverlay.add_overlay(_progressSpinner);        
+        bottomOverlay.add_overlay(_progressSpinner);
 
         var topBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
         var topLabelBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
@@ -229,7 +255,7 @@
         topLabelBox.pack_start(topLabelLang, false, true, 5);
         topLabelBox.pack_end(topLabelLen, false, true, 5);
 
-        topBox.pack_start(topScroll);
+        topBox.pack_start(topOverlay);
         topBox.pack_start(topLabelBox, false, true, 0);
 
         var bottomBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
@@ -378,12 +404,14 @@
         }
     }
 
+    /// On change value in left combobox
     private void onLeftComboChange() {
         onLangChange(false);
     }
 
+    /// On change value in right combobox
     private void onRightComboChange(LangInfo info) {
-        onLangChange(true);        
+        onLangChange(true);
     }
 
     // Swap languages
@@ -413,7 +441,7 @@
 
         _isTranslating = true;
         _progressSpinner.active = true;
-        service.Translate(leftLang.id, rightLang.id, topText.buffer.text);     
   
+        _translateService.Translate(leftLang.id, rightLang.id, 
topText.buffer.text);        
     }
 
     /// On translate complete
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/src/WebJsonClient.vala 
new/Translator-1.2.0/src/WebJsonClient.vala
--- old/Translator-1.1.0/src/WebJsonClient.vala 2018-02-14 19:45:17.000000000 
+0100
+++ new/Translator-1.2.0/src/WebJsonClient.vala 2018-03-14 17:40:12.000000000 
+0100
@@ -1,6 +1,10 @@
+/// For fetch json from url
 public class WebJsonClient : GLib.Object {
-  private static Json.Parser _parser;
+  /// No connection to server code
+  private const int NO_CONNECTION = 2;
 
+  /// Json parser
+  private static Json.Parser _parser;  
   private static Json.Parser parser {
     get {
       if (_parser == null) _parser = new Json.Parser();
@@ -8,7 +12,8 @@
     }
   }
 
-  public static Json.Object Get(string request) {
+  /// Get json from url
+  public static Json.Object Get(string request) throws TranslatorError {
     var session = new Soup.SessionSync ();
     session.timeout = GlobalSettings.SERVER_RESPOND_TIMEOUT;
     session.proxy_uri = GlobalSettings.getProxyUri();
@@ -16,7 +21,11 @@
     var url = new Soup.URI(request);
     var message = new Soup.Message.from_uri ("GET", url);
 
-    var status = session.send_message (message);
+    var status = session.send_message(message);
+    if (status == NO_CONNECTION) {
+      throw new TranslatorError.NoConnection(_("No connection to server"));
+    }
+    
     var mess = (string)message.response_body.data;
     parser.load_from_data (mess);    
     return parser.get_root ().get_object ();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Translator-1.1.0/src/utils/TranslatorError.vala 
new/Translator-1.2.0/src/utils/TranslatorError.vala
--- old/Translator-1.1.0/src/utils/TranslatorError.vala 1970-01-01 
01:00:00.000000000 +0100
+++ new/Translator-1.2.0/src/utils/TranslatorError.vala 2018-03-14 
17:40:12.000000000 +0100
@@ -0,0 +1,5 @@
+/// Exceptions
+public errordomain TranslatorError {
+    /// No connection error
+    NoConnection;
+}
\ No newline at end of file


Reply via email to