[vinagre] Convert directory lookup functions to Vala



commit 2c8ebeea9c2825355152be11b0ed76b4254ceb46
Author: David King <amigadave amigadave com>
Date:   Thu Jun 30 14:20:13 2011 +0200

    Convert directory lookup functions to Vala
    
    Remove vinagre-dirs.c and vinagre-dirs.h. Remove include directives for
    deleted header. Add DATADIR, LIBDIR and VINAGRE_ABI_VERSION to
    config.vapi. Slightly rework some of the directory lookups based on bug
    653722. Remove the plugin directory lookups, as they are no longer used.
    Remove other unused functions.

 Makefile.am                           |    3 +-
 vinagre/vapi/config.vapi              |    4 +
 vinagre/vinagre-bookmarks-migration.c |    1 -
 vinagre/vinagre-bookmarks.c           |    1 -
 vinagre/vinagre-cache-prefs.c         |    1 -
 vinagre/vinagre-connect.c             |    1 -
 vinagre/vinagre-dirs.c                |  190 ---------------------------------
 vinagre/vinagre-dirs.h                |   43 --------
 vinagre/vinagre-dirs.vala             |   48 ++++++++
 vinagre/vinagre-plugins-engine.c      |    1 -
 vinagre/vinagre-window.c              |    1 -
 11 files changed, 53 insertions(+), 241 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 88307fc..361a68c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,6 @@ noinst_vinagreh_headers = \
 	vinagre/vinagre-connect.h \
 	vinagre/vinagre-connection.h \
 	vinagre/vinagre-debug.h \
-	vinagre/vinagre-dirs.h \
 	vinagre/vinagre-dnd.h \
 	vinagre/vinagre-notebook.h \
 	vinagre/vinagre-options.h \
@@ -97,7 +96,7 @@ handwritten_sources = \
 	vinagre/vinagre-connect.c \
 	vinagre/vinagre-connection.c \
 	vinagre/vinagre-debug.c \
-	vinagre/vinagre-dirs.c \
+	vinagre/vinagre-dirs.vala \
 	vinagre/vinagre-notebook.c \
 	vinagre/vinagre-prefs.c \
 	vinagre/vinagre-reverse-vnc-listener.c \
diff --git a/vinagre/vapi/config.vapi b/vinagre/vapi/config.vapi
index 2e461c2..4f13d60 100644
--- a/vinagre/vapi/config.vapi
+++ b/vinagre/vapi/config.vapi
@@ -1,8 +1,12 @@
+// Take the values from config.h.
 [CCode (cprefix="", lower_case_cprefix = "", cheader_filename = "config.h")]
 namespace Vinagre.Config
 {
+    public const string DATADIR;
+    public const string LIBDIR;
     public const string PACKAGE_TARNAME;
     public const string PACKAGE_URL;
     public const string PACKAGE_VERSION;
+    public const string VINAGRE_ABI_VERSION;
     public const string VINAGRE_DATADIR;
 } // namespace Vinagre.Config
diff --git a/vinagre/vinagre-bookmarks-migration.c b/vinagre/vinagre-bookmarks-migration.c
index e8c1c45..68ee504 100644
--- a/vinagre/vinagre-bookmarks-migration.c
+++ b/vinagre/vinagre-bookmarks-migration.c
@@ -36,7 +36,6 @@
 #include "vinagre-bookmarks-migration.h"
 #include "vinagre-bookmarks.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-dirs.h"
 
 static void
 fill_xml (GSList *list, xmlTextWriter *writer)
diff --git a/vinagre/vinagre-bookmarks.c b/vinagre/vinagre-bookmarks.c
index ad06e65..2087145 100644
--- a/vinagre/vinagre-bookmarks.c
+++ b/vinagre/vinagre-bookmarks.c
@@ -30,7 +30,6 @@
 #include "vinagre-bookmarks-migration.h"
 #include "vinagre-connection.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-dirs.h"
 
 struct _VinagreBookmarksPrivate
 {
diff --git a/vinagre/vinagre-cache-prefs.c b/vinagre/vinagre-cache-prefs.c
index c962321..4330d74 100644
--- a/vinagre/vinagre-cache-prefs.c
+++ b/vinagre/vinagre-cache-prefs.c
@@ -21,7 +21,6 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include "vinagre-cache-prefs.h"
-#include "vinagre-dirs.h"
 
 static GKeyFile *keyfile = NULL;
 static char* filename = NULL;
diff --git a/vinagre/vinagre-connect.c b/vinagre/vinagre-connect.c
index a2b05ff..115064e 100644
--- a/vinagre/vinagre-connect.c
+++ b/vinagre/vinagre-connect.c
@@ -36,7 +36,6 @@
 #include "vinagre-prefs.h"
 #include "vinagre-cache-prefs.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-dirs.h"
 
 typedef struct {
   GtkBuilder *xml;
diff --git a/vinagre/vinagre-dirs.vala b/vinagre/vinagre-dirs.vala
new file mode 100644
index 0000000..d8afd97
--- /dev/null
+++ b/vinagre/vinagre-dirs.vala
@@ -0,0 +1,48 @@
+/*  Vinagre - GNOME Remote Desktop viewer
+ *
+ *  Copyright (C) 2011  David King <amigadave amigadave com>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Vinagre.Dirs {
+    public string get_user_cache_dir () {
+        return Path.build_filename (Environment.get_user_cache_dir (),
+            Config.PACKAGE_TARNAME);
+    }
+
+    public string get_user_data_dir () {
+        return Path.build_filename (Environment.get_user_data_dir (),
+            Config.PACKAGE_TARNAME);
+    }
+
+    // Only used by get_ui_file ().
+    private string get_vinagre_data_dir () {
+#if ! G_OS_WIN32
+        // TODO: const string[] data_dirs = Environment.get_system_data_dirs ();
+        return Path.build_filename (Config.DATADIR,
+            "%s-%s".printf (Config.PACKAGE_TARNAME,
+                Config.VINAGRE_ABI_VERSION));
+#else
+        return Path.build_filename (
+            Win32.get_package_installation_directory_of_module (null), "share",
+            "%s-%s".printf (Config.PACKAGE_TARNAME,
+                Config.VINAGRE_ABI_VERSION));
+#endif
+    }
+
+    public string get_ui_file (string filename) {
+        return Path.build_filename (get_vinagre_data_dir (), filename);
+    }
+}
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
index fefa35e..b592ad9 100644
--- a/vinagre/vinagre-plugins-engine.c
+++ b/vinagre/vinagre-plugins-engine.c
@@ -19,7 +19,6 @@
  */
 
 #include "vinagre-plugins-engine.h"
-#include "vinagre-dirs.h"
 #include "vinagre-debug.h"
 #include "vinagre-protocol.h"
 #include "vinagre-prefs.h"
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index f2a1740..c5c504e 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -41,7 +41,6 @@
 #include "vinagre-window-private.h"
 #include "vinagre-bookmarks-entry.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-dirs.h"
 
 #ifdef VINAGRE_HAVE_AVAHI
 #include "vinagre-mdns.h"



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