[gnome-boxes/wip/rishi/rhel: 1/16] os-database, wizard-source: Use named constants, not magic numbers
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/rishi/rhel: 1/16] os-database, wizard-source: Use named constants, not magic numbers
- Date: Wed, 13 Sep 2017 17:50:39 +0000 (UTC)
commit e6f4c1be482ac2875612f72bc55635954c4b3898
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Sep 13 19:33:25 2017 +0200
os-database, wizard-source: Use named constants, not magic numbers
src/os-database.vala | 11 +++++++++--
src/wizard-source.vala | 8 +++++---
2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/os-database.vala b/src/os-database.vala
index e5af73d..e595a37 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -10,6 +10,13 @@ public errordomain Boxes.OSDatabaseError {
}
private class Boxes.OSDatabase : GLib.Object {
+ public enum MediaURLsColumns {
+ URL = 0, // string
+ OS = 1, // Osinfo.Os
+
+ LAST
+ }
+
private const int DEFAULT_VCPUS = 1;
private const int64 DEFAULT_RAM = 2 * (int64) GIBIBYTES;
@@ -135,7 +142,7 @@ private class Boxes.OSDatabase : GLib.Object {
if (!yield ensure_db_loaded ())
throw new OSDatabaseError.DB_LOADING_FAILED ("Failed to load OS database");
- var store = new Gtk.ListStore (2, typeof (string), typeof (Osinfo.Os));
+ var store = new Gtk.ListStore (MediaURLsColumns.LAST, typeof (string), typeof (Osinfo.Os));
foreach (var entity in db.get_os_list ().get_elements ()) {
var os = entity as Os;
@@ -146,7 +153,7 @@ private class Boxes.OSDatabase : GLib.Object {
Gtk.TreeIter iter;
store.append (out iter);
- store.set (iter, 0, media.url, 1, os);
+ store.set (iter, MediaURLsColumns.URL, media.url, MediaURLsColumns.OS, os);
}
}
}
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 8545363..7beef6c 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -146,7 +146,9 @@ private class Boxes.WizardSource: Gtk.Stack {
media_urls_store.foreach ((store, path, iter) => {
string? os_uri;
- media_urls_store.get (iter, 0, out os_uri, 1, out os);
+ media_urls_store.get (iter,
+ OSDatabase.MediaURLsColumns.URL, out os_uri,
+ OSDatabase.MediaURLsColumns.OS, out os);
return os_uri == uri;
});
@@ -201,14 +203,14 @@ private class Boxes.WizardSource: Gtk.Stack {
try {
media_urls_store = os_db.get_all_media_urls_as_store.end (result);
var completion = new Gtk.EntryCompletion ();
- completion.text_column = 0;
+ completion.text_column = OSDatabase.MediaURLsColumns.URL;
completion.model = media_urls_store;
weak Gtk.CellRendererText cell = completion.get_cells ().nth_data (0) as
Gtk.CellRendererText;
cell.ellipsize = Pango.EllipsizeMode.MIDDLE;
completion.set_match_func ((store, key, iter) => {
string url;
- media_urls_store.get (iter, 0, out url);
+ media_urls_store.get (iter, OSDatabase.MediaURLsColumns.URL, out url);
return url.contains (key);
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]