[cheese] Install catalog instead of individual package
- From: Patricia Santana Cruz <patriciasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Install catalog instead of individual package
- Date: Mon, 13 Feb 2012 15:34:51 +0000 (UTC)
commit 388d85547ff1da7b7a57162637e94e2053d58ce5
Author: Patricia Santana Cruz <patriciasantanacruz gmail com>
Date: Fri Feb 10 20:59:33 2012 +0000
Install catalog instead of individual package
Replaced hardcoding the nautilus-sendto package name in the code for
runtime installation. Instead, a catalog (cheese.catalog) is used.
Fixes bug 669547.
Makefile.am | 4 ++++
data/cheese.catalog | 3 +++
src/cheese-window.vala | 39 +++++++++++++++++++++++++++++++++------
src/vapi/config.vapi | 2 ++
4 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6c78593..0bfb6b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -376,6 +376,10 @@ dist_pixmaps_DATA = \
data/pixmaps/cheese-2.svg \
data/pixmaps/cheese-3.svg
+catalogdir = $(pkgdatadir)
+dist_catalog_DATA = \
+ data/cheese.catalog
+
# Tests.
check_PROGRAMS = \
tests/test-libcheese \
diff --git a/data/cheese.catalog b/data/cheese.catalog
new file mode 100644
index 0000000..b6b6848
--- /dev/null
+++ b/data/cheese.catalog
@@ -0,0 +1,3 @@
+[PackageKit Catalog]
+
+InstallPackages=nautilus-sendto
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index e260a4d..fe482b0 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -31,7 +31,7 @@ using CanberraGtk;
[DBus(name = "org.freedesktop.PackageKit.Modify")]
interface PkProxy : GLib.Object {
- public abstract async void install_package_names (uint xid, string[] packages_names, string interaction) throws IOError;
+ public abstract async void install_catalogs (uint xid, string[] catalog_files, string interaction) throws IOError;
}
const int FULLSCREEN_TIMEOUT_INTERVAL = 5 * 1000;
@@ -410,17 +410,44 @@ public class Cheese.MainWindow : Gtk.Window
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit");
- string[] packages = { "nautilus-sendto" };
-
- yield pk_proxy.install_package_names ((uint) Gdk.X11Window.get_xid (this.get_window ()),
- packages,
- ""); // Use interaction defaults.
+ const string CATALOG = "cheese.catalog";
+ string[] catalogs = { get_data_file_dir (CATALOG) };
+ yield pk_proxy.install_catalogs ((uint) Gdk.X11Window.get_xid (this.get_window ()),
+ catalogs,
+ ""); // Use interaction defaults.
} catch (IOError error) {
critical ("D-Bus error: %s\n", error.message);
}
}
/**
+ * Search system directories for the given filename, starting
+ * with the in-installation-time custom prefix first.
+ *
+ * @param filename the file whose path will be searched.
+ * @return the system path for the given filename.
+ */
+ private string get_data_file_dir (string filename) {
+ var system_data_dirs = Environment.get_system_data_dirs ();
+ string[] data_dirs = {};
+ data_dirs += Config.DATADIR;
+
+ foreach (var dir in system_data_dirs)
+ data_dirs += dir;
+
+ foreach (var dir in data_dirs) {
+ var absolute_path = GLib.Path.build_filename (dir, Config.PACKAGE_TARNAME,
+ filename);
+ if (FileUtils.test (absolute_path, FileTest.EXISTS))
+ return absolute_path;
+ };
+
+ // Filename could not be found!
+ error ("Data file â%sâ could not be found in system data directories.",
+ filename);
+ }
+
+ /**
* Save the selected file in the thumbview to an alternate storage location.
*
* A file chooser dialog is shown to the user, asking where the file should
diff --git a/src/vapi/config.vapi b/src/vapi/config.vapi
index 9400f97..2508dff 100644
--- a/src/vapi/config.vapi
+++ b/src/vapi/config.vapi
@@ -2,9 +2,11 @@
namespace Config
{
public const string GETTEXT_PACKAGE;
+ public const string DATADIR;
public const string PACKAGE_DATADIR;
public const string PACKAGE_LOCALEDIR;
public const string PACKAGE_NAME;
public const string PACKAGE_VERSION;
+ public const string PACKAGE_TARNAME;
public const string VERSION;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]