[gnome-boxes] Name logo files according to distro names
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Name logo files according to distro names
- Date: Tue, 17 Apr 2012 00:51:30 +0000 (UTC)
commit 77cbbfb3fa46af1bdaefac0d54b8adb7250bc611
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Apr 17 00:57:28 2012 +0300
Name logo files according to distro names
Logo fetching was broken for debian, ubuntu and opensuse after the
recent (0.1.1) short-id renaming changes in libosinfo. Now that libosinfo
reports 'distro', lets make use of that to make logo fetching faster and
simpler while we fix this issue.
https://bugzilla.gnome.org/show_bug.cgi?id=674228
data/icons/Makefile.am | 8 ++--
data/icons/{debianbuzz.svg => debian.svg} | 0
data/icons/{fedora1.svg => fedora.svg} | 0
data/icons/{opensuse102.svg => opensuse.svg} | 0
data/icons/{ubuntuhardy.svg => ubuntu.svg} | 0
src/util.vala | 42 +++++++++++--------------
src/wizard-source.vala | 2 +-
src/wizard.vala | 2 +-
8 files changed, 25 insertions(+), 29 deletions(-)
---
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 0da1412..0ad2aae 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -24,10 +24,10 @@ assets_DATA = \
$(NULL)
if ENABLE_LOGOS
-LOGOS = debianbuzz.svg \
- fedora1.svg \
- opensuse102.svg \
- ubuntuhardy.svg \
+LOGOS = debian.svg \
+ fedora.svg \
+ opensuse.svg \
+ ubuntu.svg \
$(NULL)
else
LOGOS =
diff --git a/data/icons/debianbuzz.svg b/data/icons/debian.svg
similarity index 100%
rename from data/icons/debianbuzz.svg
rename to data/icons/debian.svg
diff --git a/data/icons/fedora1.svg b/data/icons/fedora.svg
similarity index 100%
rename from data/icons/fedora1.svg
rename to data/icons/fedora.svg
diff --git a/data/icons/opensuse102.svg b/data/icons/opensuse.svg
similarity index 100%
rename from data/icons/opensuse102.svg
rename to data/icons/opensuse.svg
diff --git a/data/icons/ubuntuhardy.svg b/data/icons/ubuntu.svg
similarity index 100%
rename from data/icons/ubuntuhardy.svg
rename to data/icons/ubuntu.svg
diff --git a/src/util.vala b/src/util.vala
index 9a78842..d64b704 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -270,35 +270,27 @@ namespace Boxes {
return (devices.get_length () > 0) ? devices.get_nth (0) as Osinfo.Device : null;
}
- public Gtk.Image get_product_logo (Osinfo.Product? product, int size) {
+ public Gtk.Image get_os_logo (Osinfo.Os? os, int size) {
var image = new Gtk.Image.from_icon_name ("media-optical", 0);
image.pixel_size = size;
- if (product != null)
- fetch_product_logo (image, product, size);
+ if (os != null)
+ fetch_os_logo (image, os, size);
return image;
}
- public void fetch_product_logo (Gtk.Image image, Osinfo.Product product, int size) {
- var path = get_logo_path (product);
+ public void fetch_os_logo (Gtk.Image image, Osinfo.Os os, int size) {
+ var path = get_logo_path (os);
- if (path != null) {
- try {
- var pixbuf = new Gdk.Pixbuf.from_file_at_size (path, size, -1);
- image.set_from_pixbuf (pixbuf);
- } catch (GLib.Error error) {
- warning ("Error loading logo file '%s': %s", path, error.message);
- }
- } else {
- var derived = product.get_related (Osinfo.ProductRelationship.DERIVES_FROM);
- if (derived.get_length () == 0)
- return;
-
- // FIXME: Does Osinfo allows deriving from multiple products?
- var parent = derived.get_nth (0) as Osinfo.Product;
+ if (path == null)
+ return;
- fetch_product_logo (image, parent, size);
+ try {
+ var pixbuf = new Gdk.Pixbuf.from_file_at_size (path, size, -1);
+ image.set_from_pixbuf (pixbuf);
+ } catch (GLib.Error error) {
+ warning ("Error loading logo file '%s': %s", path, error.message);
}
}
@@ -359,17 +351,21 @@ namespace Boxes {
}
}
- private string? get_logo_path (Osinfo.Product product, string[] extensions = {".svg", ".png", ".jpg"}) {
+ private string? get_logo_path (Osinfo.Os os, string[] extensions = {".svg", ".png", ".jpg"}) {
if (extensions.length == 0)
return null;
- var path = get_pixmap (product.short_id + extensions[0]);
+ var path = get_pixmap (os.short_id + extensions[0]);
var file = File.new_for_path (path);
+ if (!file.query_exists ()) {
+ path = get_pixmap (os.distro + extensions[0]);
+ file = File.new_for_path (path);
+ }
if (file.query_exists ())
return path;
else
- return get_logo_path (product, extensions[1:extensions.length]);
+ return get_logo_path (os, extensions[1:extensions.length]);
}
[DBus (name = "org.freedesktop.Accounts")]
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 791ef76..a8091ab 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -156,7 +156,7 @@ private class Boxes.WizardSource: GLib.Object {
page = SourcePage.URL;
}, 15, 5, true, "installer-" + media.device_file + "-item");
- var image = get_product_logo (media.os, 64);
+ var image = get_os_logo (media.os, 64);
hbox.pack_start (image, false, false);
var vbox = new Gtk.VBox (true, 5);
diff --git a/src/wizard.vala b/src/wizard.vala
index f996f12..c680a46 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -219,7 +219,7 @@ private class Boxes.Wizard: Boxes.UI {
try {
install_media = media_manager.create_installer_media_for_path.end (result);
- fetch_product_logo (installer_image, install_media.os, 128);
+ fetch_os_logo (installer_image, install_media.os, 128);
prep_progress.fraction = 1.0;
page = page + 1;
} catch (IOError.CANCELLED cancel_error) { // We did this, so no warning!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]