[gedit] Init the metadata manager in the loader test



commit 8bd2e9c1e00bfa276ca9a1987d655f7f43755e7a
Author: Paolo Borelli <pborelli gnome org>
Date:   Wed Feb 19 11:40:38 2014 +0100

    Init the metadata manager in the loader test
    
    If we are configured to use it, also use it in the test

 gedit/gedit-app.c              |   12 ------------
 gedit/gedit-metadata-manager.c |   15 +++++++++------
 gedit/gedit-metadata-manager.h |    2 +-
 tests/document-loader.c        |   31 ++++++++++++++++++++++++++++---
 4 files changed, 38 insertions(+), 22 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index def7698..a283adc 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -52,7 +52,6 @@
 
 #ifndef ENABLE_GVFS_METADATA
 #include "gedit-metadata-manager.h"
-#define METADATA_FILE "gedit-metadata.xml"
 #endif
 
 #define GEDIT_PAGE_SETUP_FILE          "gedit-page-setup"
@@ -410,10 +409,6 @@ gedit_app_startup (GApplication *application)
        GtkSourceStyleSchemeManager *manager;
        const gchar *dir;
        gchar *icon_dir;
-#ifndef ENABLE_GVFS_METADATA
-       const gchar *cache_dir;
-       gchar *metadata_filename;
-#endif
        GError *error = NULL;
        GFile *css_file;
        GtkCssProvider *provider;
@@ -445,14 +440,7 @@ gedit_app_startup (GApplication *application)
        g_free (icon_dir);
 
 #ifndef ENABLE_GVFS_METADATA
-       /* Setup metadata-manager */
-       cache_dir = gedit_dirs_get_user_cache_dir ();
-
-       metadata_filename = g_build_filename (cache_dir, METADATA_FILE, NULL);
-
        gedit_metadata_manager_init (metadata_filename);
-
-       g_free (metadata_filename);
 #endif
 
        /* Load settings */
diff --git a/gedit/gedit-metadata-manager.c b/gedit/gedit-metadata-manager.c
index 2de1b07..14bc398 100644
--- a/gedit/gedit-metadata-manager.c
+++ b/gedit/gedit-metadata-manager.c
@@ -22,14 +22,16 @@
 #include <time.h>
 #include <stdlib.h>
 #include <libxml/xmlreader.h>
-#include "gedit-metadata-manager.h"
 #include "gedit-debug.h"
+#include "gedit-dirs.h"
+#include "gedit-metadata-manager.h"
 
 /*
 #define GEDIT_METADATA_VERBOSE_DEBUG   1
 */
 
-#define MAX_ITEMS      50
+#define MAX_ITEM 50
+#define METADATA_FILE "gedit-metadata.xml"
 
 typedef struct _GeditMetadataManager GeditMetadataManager;
 
@@ -100,8 +102,10 @@ gedit_metadata_manager_arm_timeout (void)
  * See also gedit_metadata_manager_shutdown().
  */
 void
-gedit_metadata_manager_init (const gchar *metadata_filename)
+gedit_metadata_manager_init (void)
 {
+       const gchar *cache_dir;
+
        gedit_debug (DEBUG_METADATA);
 
        if (gedit_metadata_manager != NULL)
@@ -117,9 +121,8 @@ gedit_metadata_manager_init (const gchar *metadata_filename)
                                       g_free,
                                       item_free);
 
-       gedit_metadata_manager->metadata_filename = g_strdup (metadata_filename);
-
-       return;
+       cache_dir = gedit_dirs_get_user_cache_dir ();
+       gedit_metadata_manager->metadata_filename = g_build_filename (cache_dir, METADATA_FILE, NULL);
 }
 
 /**
diff --git a/gedit/gedit-metadata-manager.h b/gedit/gedit-metadata-manager.h
index 2d17e55..6b075e3 100644
--- a/gedit/gedit-metadata-manager.h
+++ b/gedit/gedit-metadata-manager.h
@@ -27,7 +27,7 @@
 
 G_BEGIN_DECLS
 
-void            gedit_metadata_manager_init            (const gchar *metadata_filename);
+void            gedit_metadata_manager_init            (void);
 
 void            gedit_metadata_manager_shutdown        (void);
 
diff --git a/tests/document-loader.c b/tests/document-loader.c
index 3f1d32d..046a748 100644
--- a/tests/document-loader.c
+++ b/tests/document-loader.c
@@ -20,11 +20,19 @@
  * Boston, MA  02110-1301  USA
  */
 
-#include "gedit-document-loader.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <glib.h>
 #include <string.h>
+#include "gedit-dirs.h"
+#include "gedit-document-loader.h"
+#ifndef ENABLE_GVFS_METADATA
+#include "gedit-metadata-manager.h"
+#endif
 
 static gboolean test_completed;
 
@@ -229,12 +237,29 @@ test_begin_new_line_detection ()
 int main (int   argc,
           char *argv[])
 {
+       int ret;
+
        g_test_init (&argc, &argv, NULL);
 
+       gedit_dirs_init ();
+
+#ifndef ENABLE_GVFS_METADATA
+       gedit_metadata_manager_init (metadata_filename);
+#endif
+
        g_test_add_func ("/document-loader/end-line-stripping", test_end_line_stripping);
        g_test_add_func ("/document-loader/end-new-line-detection", test_end_new_line_detection);
        g_test_add_func ("/document-loader/begin-new-line-detection", test_begin_new_line_detection);
 
-       return g_test_run ();
+       ret = g_test_run ();
+
+#ifndef ENABLE_GVFS_METADATA
+       gedit_metadata_manager_shutdown ();
+#endif
+
+       gedit_dirs_shutdown ();
+
+       return ret;
 }
-/* ex:ts=8:noet: */
+
+/* ex:set ts=8 noet: */


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