[gnome-boxes/wip/run-in-bg: 2/6] Rename all singleton access methods to "get_default ()"




commit c16e329f4a34a3b4a20676f29f83c1f3f4502e30
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Dec 7 12:40:01 2020 +0100

    Rename all singleton access methods to "get_default ()"
    
    We were using get_instance() and get_defaul(), and it is about time
    we are consistent about those.
    
    https://blogs.gnome.org/xclaesse/2010/02/11/how-to-make-a-gobject-singleton/
    get_default() is the most popular/standardized name, so get_default
    it is.

 src/assistant/identify-os-popover.vala  | 2 +-
 src/assistant/index-page.vala           | 6 +++---
 src/assistant/preparation-page.vala     | 2 +-
 src/assistant/rhel-download-dialog.vala | 2 +-
 src/assistant/vm-assistant.vala         | 2 +-
 src/collection-toolbar.vala             | 2 +-
 src/downloader.vala                     | 6 +++---
 src/downloads-hub.vala                  | 2 +-
 src/libvirt-machine-properties.vala     | 2 +-
 src/libvirt-machine.vala                | 2 +-
 src/media-manager.vala                  | 2 +-
 src/unattended-installer.vala           | 4 ++--
 src/util-app.vala                       | 2 +-
 src/vm-creator.vala                     | 2 +-
 src/vm-importer.vala                    | 2 +-
 15 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/src/assistant/identify-os-popover.vala b/src/assistant/identify-os-popover.vala
index b0933524..4a1b751d 100644
--- a/src/assistant/identify-os-popover.vala
+++ b/src/assistant/identify-os-popover.vala
@@ -22,7 +22,7 @@ public IdentifyOsPopover () {
 
     private async void setup_model () {
         try {
-            var media_manager = MediaManager.get_instance ();
+            var media_manager = MediaManager.get_default ();
             os_list = yield media_manager.os_db.get_all_oses_sorted_by_release_date ();
         } catch (GLib.Error error) {
             warning ("Failed to load OS list: %s", error.message);
diff --git a/src/assistant/index-page.vala b/src/assistant/index-page.vala
index da020754..cf7c858e 100644
--- a/src/assistant/index-page.vala
+++ b/src/assistant/index-page.vala
@@ -55,7 +55,7 @@ public void go_back () {
     }
 
     private async void populate_media_lists () {
-        var media_manager = MediaManager.get_instance ();
+        var media_manager = MediaManager.get_default ();
         yield media_manager.connect_to_tracker ();
 
         installer_medias = yield media_manager.list_installer_medias ();
@@ -128,7 +128,7 @@ private async void on_featured_media_selected (Gtk.ListBoxRow row) {
         if (entry.os != null && entry.os.id.has_prefix ("http://redhat.com/rhel/";)) {
             (new RHELDownloadDialog (dialog, entry).run ());
         } else {
-            DownloadsHub.get_instance ().add_item (entry);
+            DownloadsHub.get_default ().add_item (entry);
         }
 
         dialog.shutdown ();
@@ -146,7 +146,7 @@ private async void on_select_file_button_clicked () {
                                                       _("Open"), _("Cancel"));
         file_chooser.bind_property ("visible", dialog, "visible", BindingFlags.INVERT_BOOLEAN);
         if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
-            var media_manager = MediaManager.get_instance ();
+            var media_manager = MediaManager.get_default ();
             try {
                 var media = yield media_manager.create_installer_media_for_path (file_chooser.get_filename 
(),
                                                                                  cancellable);
diff --git a/src/assistant/preparation-page.vala b/src/assistant/preparation-page.vala
index d070eb76..aba91071 100644
--- a/src/assistant/preparation-page.vala
+++ b/src/assistant/preparation-page.vala
@@ -33,7 +33,7 @@
 
     public async void setup (InstallerMedia media, Osinfo.Os? os = null) {
         try {
-            var media_manager = MediaManager.get_instance ();
+            var media_manager = MediaManager.get_default ();
             this.media = media_manager.create_installer_media_from_media (media, os);
         } catch (GLib.Error error) {
             warning ("Failed to setup installation media '%s': %s", media.device_file, error.message);
diff --git a/src/assistant/rhel-download-dialog.vala b/src/assistant/rhel-download-dialog.vala
index 8f9c6cd1..5bba05b0 100644
--- a/src/assistant/rhel-download-dialog.vala
+++ b/src/assistant/rhel-download-dialog.vala
@@ -81,7 +81,7 @@ private bool on_decide_policy (WebKit.WebView web_view,
         debug ("RHEL ISO download URI: %s", download_uri);
 
         entry.url = download_uri;
-        DownloadsHub.get_instance ().add_item (entry);
+        DownloadsHub.get_default ().add_item (entry);
 
         decision.ignore ();
         this.close ();
diff --git a/src/assistant/vm-assistant.vala b/src/assistant/vm-assistant.vala
index 24ab18c2..901c7cba 100644
--- a/src/assistant/vm-assistant.vala
+++ b/src/assistant/vm-assistant.vala
@@ -49,7 +49,7 @@ public VMAssistant (AppWindow app_window, string? path = null) {
     }
 
     private async void prepare_for_path (string path) {
-        var media_manager = MediaManager.get_instance ();
+        var media_manager = MediaManager.get_default ();
 
         try {
             var installer_media = yield media_manager.create_installer_media_for_path (path, null);
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index 2d45058f..77465052 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -45,7 +45,7 @@ public void setup_ui (AppWindow window) {
         MenuModel menu = (MenuModel) builder.get_object ("app-menu");
         hamburger_btn.popover = new Popover.from_model (hamburger_btn, menu);
 
-        downloads_hub_btn.popover = DownloadsHub.get_instance ();
+        downloads_hub_btn.popover = DownloadsHub.get_default ();
     }
 
     public void click_back_button () {
diff --git a/src/downloader.vala b/src/downloader.vala
index 8b30ab52..d6b22abd 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -28,7 +28,7 @@ public Download (File remote_file, File cached_file, ActivityProgress progress)
         "https",
     };
 
-    public static Downloader get_instance () {
+    public static Downloader get_default () {
         if (downloader == null)
             downloader = new Downloader ();
 
@@ -204,7 +204,7 @@ public static async void fetch_os_logo (Gtk.Image image, Osinfo.Os os, int size)
             cached_paths += system_cached_path;
 
         try {
-            var cached_file = yield get_instance ().download (remote_file, cached_paths);
+            var cached_file = yield get_default ().download (remote_file, cached_paths);
             var pixbuf = new Gdk.Pixbuf.from_file_at_size (cached_file.get_path (), size, size);
             image.set_from_pixbuf (pixbuf);
         } catch (GLib.Error error) {
@@ -227,7 +227,7 @@ public static async string fetch_media (string           uri,
 
         return_val_if_fail (basename != null && basename != "" && basename != "/", null);
 
-        var downloader = Downloader.get_instance ();
+        var downloader = Downloader.get_default ();
         var cache = Path.build_filename (GLib.Environment.get_user_special_dir (GLib.UserDirectory.DOWNLOAD),
                                          basename);
 
diff --git a/src/downloads-hub.vala b/src/downloads-hub.vala
index 16f14c53..11ea2724 100644
--- a/src/downloads-hub.vala
+++ b/src/downloads-hub.vala
@@ -4,7 +4,7 @@
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/downloads-hub.ui")]
 private class Boxes.DownloadsHub : Gtk.Popover {
     private static DownloadsHub instance;
-    public static DownloadsHub get_instance () {
+    public static DownloadsHub get_default () {
         if (instance == null)
             instance = new DownloadsHub ();
 
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 93c59e9f..2bd89153 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -290,7 +290,7 @@ private async void mark_recommended_resources (SizeProperty? ram_property, SizeP
         if (os_id == null)
             return null;
 
-        var os_db = MediaManager.get_instance ().os_db;
+        var os_db = MediaManager.get_default ().os_db;
         try {
             return yield os_db.get_os_by_id (os_id);
         } catch (OSDatabaseError error) {
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 474be0db..8efed2fb 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -797,7 +797,7 @@ public async bool supports_accel3d () {
         if (os_id == null)
             return null;
 
-        var os_db = MediaManager.get_instance ().os_db;
+        var os_db = MediaManager.get_default ().os_db;
         try {
             return yield os_db.get_os_by_id (os_id);
         } catch (OSDatabaseError error) {
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 3197700f..5e585e2c 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -16,7 +16,7 @@
 
     private Sparql.Connection connection;
 
-    public static MediaManager get_instance () {
+    public static MediaManager get_default () {
         if (media_manager == null)
             media_manager = new MediaManager ();
 
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 5a0e9f5b..d48db8b1 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -515,7 +515,7 @@ private async void setup_driver (DeviceDriver          driver,
                                      ActivityProgress      progress,
                                      AddUnattendedFileFunc add_func,
                                      Cancellable?          cancellable) throws GLib.Error {
-        var downloader = Downloader.get_instance ();
+        var downloader = Downloader.get_default ();
 
         var driver_files = new GLib.List<UnattendedFile> ();
         var location = driver.get_location ();
@@ -662,7 +662,7 @@ else if (compatibility == CPUArchCompatibility.COMPATIBLE && drivers.lookup (loc
     }
 
     private string get_preferred_keyboard (string lang) {
-        var os_db = MediaManager.get_instance ().os_db;
+        var os_db = MediaManager.get_default ().os_db;
         var datamap = os_db.get_datamap ("http://x.org/x11-keyboard";);
         string kbd_layout = null;
 
diff --git a/src/util-app.vala b/src/util-app.vala
index ecef9460..9648ec0e 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -186,7 +186,7 @@ else if (media.url.contains ("dvd"))
         }
 
         GLib.List<Osinfo.Media> list = new GLib.List<Osinfo.Media> ();
-        var os_db = MediaManager.get_instance ().os_db;
+        var os_db = MediaManager.get_default ().os_db;
         for (Xml.Node* iter = root->children; iter != null; iter = iter->next) {
             var os_id = iter->get_content ();
             try {
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index c4b71aa5..1139595e 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -88,7 +88,7 @@ public virtual void launch_vm (LibvirtMachine machine, int64 access_last_time =
     }
 
     protected virtual async void continue_installation (LibvirtMachine machine) {
-        install_media = yield MediaManager.get_instance ().create_installer_media_from_config 
(machine.domain_config);
+        install_media = yield MediaManager.get_default ().create_installer_media_from_config 
(machine.domain_config);
         num_reboots = VMConfigurator.get_num_reboots (machine.domain_config);
         var name = machine.domain.get_name ();
 
diff --git a/src/vm-importer.vala b/src/vm-importer.vala
index c6de3200..f61af3e9 100644
--- a/src/vm-importer.vala
+++ b/src/vm-importer.vala
@@ -28,7 +28,7 @@ public override void launch_vm (LibvirtMachine machine, int64 access_last_time =
     }
 
     protected override async void continue_installation (LibvirtMachine machine) {
-        install_media = yield MediaManager.get_instance ().create_installer_media_from_config 
(machine.domain_config);
+        install_media = yield MediaManager.get_default ().create_installer_media_from_config 
(machine.domain_config);
         machine.vm_creator = this;
 
         yield post_import_setup (machine);


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