[simple-scan/gnome-3-28] Make all classes extent GLib.Object



commit daee59b3dd78c90037d5422a4703afc5e1221869
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Feb 11 10:03:20 2019 +1300

    Make all classes extent GLib.Object
    
    This makes reference counting more consistent and fixes #79

 src/book.vala      |  2 +-
 src/page-view.vala |  2 +-
 src/page.vala      |  2 +-
 src/scanner.vala   | 34 +++++++++++++++++-----------------
 4 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/src/book.vala b/src/book.vala
index d53b31a..6db2952 100644
--- a/src/book.vala
+++ b/src/book.vala
@@ -11,7 +11,7 @@
 
 public delegate void ProgressionCallback (double fraction);
 
-public class Book
+public class Book : Object
 {
     private List<Page> pages;
 
diff --git a/src/page-view.vala b/src/page-view.vala
index 03fecfb..5edea07 100644
--- a/src/page-view.vala
+++ b/src/page-view.vala
@@ -23,7 +23,7 @@ public enum CropLocation
     BOTTOM_RIGHT
 }
 
-public class PageView
+public class PageView : Object
 {
     /* Page being rendered */
     public Page page { get; private set; }
diff --git a/src/page.vala b/src/page.vala
index c859df9..b9cc0f6 100644
--- a/src/page.vala
+++ b/src/page.vala
@@ -17,7 +17,7 @@ public enum ScanDirection
     RIGHT_TO_LEFT
 }
 
-public class Page
+public class Page : Object
 {
     /* Width of the page in pixels after rotation applied */
     public int width
diff --git a/src/scanner.vala b/src/scanner.vala
index 58141b8..36e7bc5 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -11,13 +11,13 @@
 
 /* TODO: Could indicate the start of the next page immediately after the last page is received (i.e. before 
the sane_cancel()) */
 
-public class ScanDevice
+public class ScanDevice : Object
 {
     public string name;
     public string label;
 }
 
-public class ScanPageInfo
+public class ScanPageInfo : Object
 {
     /* Width, height in pixels */
     public int width;
@@ -36,7 +36,7 @@ public class ScanPageInfo
     public string device;
 }
 
-public class ScanLine
+public class ScanLine : Object
 {
     /* Line number */
     public int number;
@@ -73,7 +73,7 @@ public enum ScanType
     BATCH
 }
 
-public class ScanOptions
+public class ScanOptions : Object
 {
     public int dpi;
     public ScanMode scan_mode;
@@ -86,7 +86,7 @@ public class ScanOptions
     public int page_delay;
 }
 
-private class ScanJob
+private class ScanJob : Object
 {
     public int id;
     public string device;
@@ -208,7 +208,7 @@ private class NotifyGotLine : Notify
     }
 }
 
-public class Scanner
+public class Scanner : Object
 {
     /* Singleton object */
     private static Scanner scanner_object = null;
@@ -292,7 +292,7 @@ public class Scanner
         return false;
     }
 
-    private void notify (Notify notification)
+    private void notify_event (Notify notification)
     {
         notify_queue.push (notification);
         Idle.add (notify_idle_cb);
@@ -303,7 +303,7 @@ public class Scanner
         if ((scanning && !is_scanning) || (!scanning && is_scanning))
         {
             scanning = is_scanning;
-            notify (new NotifyScanningChanged ());
+            notify_event (new NotifyScanningChanged ());
         }
     }
 
@@ -382,7 +382,7 @@ public class Scanner
         else
             default_device = null;
 
-        notify (new NotifyUpdateDevices ((owned) devices));
+        notify_event (new NotifyUpdateDevices ((owned) devices));
     }
 
     private int scale_int (int source_min, int source_max, Sane.OptionDescriptor option, int value)
@@ -743,7 +743,7 @@ public class Scanner
 
     private static void authorization_cb (string resource, char[] username, char[] password)
     {
-        scanner_object.notify (new NotifyRequestAuthorization (resource));
+        scanner_object.notify_event (new NotifyRequestAuthorization (resource));
 
         var credentials = scanner_object.authorize_queue.pop ();
         for (var i = 0; credentials.username[i] != '\0' && i < Sane.MAX_USERNAME_LEN; i++)
@@ -783,7 +783,7 @@ public class Scanner
     {
         close_device ();
         state = ScanState.IDLE;
-        notify (new NotifyScanFailed (error_code, error_string));
+        notify_event (new NotifyScanFailed (error_code, error_string));
     }
 
     private bool handle_requests ()
@@ -1203,7 +1203,7 @@ public class Scanner
         /* Trigger timeout to close */
         // TODO
 
-        notify (new NotifyDocumentDone ());
+        notify_event (new NotifyDocumentDone ());
         set_scanning (false);
     }
 
@@ -1211,7 +1211,7 @@ public class Scanner
     {
         Sane.Status status;
 
-        notify (new NotifyExpectPage ());
+        notify_event (new NotifyExpectPage ());
 
         status = Sane.start (handle);
         debug ("sane_start (page=%d, pass=%d) -> %s", page_number, pass_number, Sane.status_to_string 
(status));
@@ -1265,7 +1265,7 @@ public class Scanner
 
         if (page_number != notified_page)
         {
-            notify (new NotifyGotPageInfo (job.id, info));
+            notify_event (new NotifyGotPageInfo (job.id, info));
             notified_page = page_number;
         }
 
@@ -1282,7 +1282,7 @@ public class Scanner
     {
         var job = (ScanJob) job_queue.data;
 
-        notify (new NotifyPageDone (job.id));
+        notify_event (new NotifyPageDone (job.id));
 
         /* If multi-pass then scan another page */
         if (!parameters.last_frame)
@@ -1300,7 +1300,7 @@ public class Scanner
 
             page_number++;
             pass_number = 0;
-            notify (new NotifyPageDone (job.id));
+            notify_event (new NotifyPageDone (job.id));
             state = ScanState.START;
             return;
         }
@@ -1448,7 +1448,7 @@ public class Scanner
                 line.data_length = (line.width * 2 + 7) / 8;
             }
 
-            notify (new NotifyGotLine (job.id, line));
+            notify_event (new NotifyGotLine (job.id, line));
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]