Updating branch refs/heads/master
         to c85322c147e9436ed497d5f1da544a6fe6ce72a1 (commit)
       from 3a639f649f4027a00e0a3e2446713cd3344495b8 (commit)

commit c85322c147e9436ed497d5f1da544a6fe6ce72a1
Author: Peter de Ridder <[email protected]>
Date:   Wed Aug 24 21:15:56 2011 +0200

    Overruling .squeeze files

 libsqueeze/libsqueeze.c      |   40 +++++++++++++++++++---------------------
 libsqueeze/support-factory.c |    6 ++++++
 libsqueeze/support-factory.h |    2 ++
 libsqueeze/support-reader.c  |    2 ++
 4 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/libsqueeze/libsqueeze.c b/libsqueeze/libsqueeze.c
index 9c9956a..2dd2105 100644
--- a/libsqueeze/libsqueeze.c
+++ b/libsqueeze/libsqueeze.c
@@ -44,16 +44,22 @@ lsq_read_squeeze_dir(const gchar *dir)
     {
       if(g_str_has_suffix(filename, ".squeeze"))
       {
-       /**
-        * FIXME: factories should be per-mime-type, not per-template
+       /* see if a file with this name was already loaded.
+        * skip this file. configuration was overruled
         */
-       gchar *path = g_strconcat(dir, "/", filename, NULL);
-       LSQSupportFactory *factory = lsq_support_reader_parse_file(path);
-       if(factory)
+       if ( NULL == g_slist_find_custom(support_factory_list, filename, 
(GCompareFunc)lsq_suport_factory_compare_filename) )
        {
-         support_factory_list = g_slist_append(support_factory_list, factory);
+         /**
+          * FIXME: factories should be per-mime-type, not per-template
+          */
+         gchar *path = g_strconcat(dir, "/", filename, NULL);
+         LSQSupportFactory *factory = lsq_support_reader_parse_file(path);
+         if(factory)
+         {
+           support_factory_list = g_slist_append(support_factory_list, 
factory);
+         }
+         g_free(path);
        }
-       g_free(path);
       }
     }
 
@@ -72,28 +78,20 @@ lsq_init(void)
 
   lsq_opened_archive_list = NULL;
 
+  data_squeeze = g_build_path("/", user_dir, "squeeze", NULL);
+  lsq_read_squeeze_dir(data_squeeze);
+  g_free(data_squeeze);
+
   data_squeeze = g_build_path("/", DATADIR, "squeeze", NULL);
   lsq_read_squeeze_dir(data_squeeze);
   g_free(data_squeeze);
 
-  /* FIXME: compare filenames for overruling .squeeze file configurations */
-  if (0 != strcmp(DATADIR, user_dir) && 0 != strcmp(DATADIR "/", user_dir))
+  for (; NULL != *system_dirs; ++system_dirs)
   {
-    data_squeeze = g_build_path("/", user_dir, "squeeze", NULL);
+    data_squeeze = g_build_path("/", *system_dirs, "squeeze", NULL);
     lsq_read_squeeze_dir(data_squeeze);
     g_free(data_squeeze);
   }
-
-  for (; NULL != *system_dirs; ++system_dirs)
-  {
-
-    if (0 != strcmp(DATADIR, *system_dirs) && 0 != strcmp(DATADIR "/", 
*system_dirs))
-    {
-      data_squeeze = g_build_path("/", *system_dirs, "squeeze", NULL);
-      lsq_read_squeeze_dir(data_squeeze);
-      g_free(data_squeeze);
-    }
-  }
 }
 
 void
diff --git a/libsqueeze/support-factory.c b/libsqueeze/support-factory.c
index d520f63..6d9f631 100644
--- a/libsqueeze/support-factory.c
+++ b/libsqueeze/support-factory.c
@@ -130,3 +130,9 @@ lsq_support_factory_add_template(LSQSupportFactory 
*factory, LSQSupportTemplate
 
 }
 
+gint
+lsq_suport_factory_compare_filename(const LSQSupportFactory *factory, const 
gchar *filename)
+{
+  return strcmp(factory->filename, filename);
+}
+
diff --git a/libsqueeze/support-factory.h b/libsqueeze/support-factory.h
index 8a14e90..2d10d83 100644
--- a/libsqueeze/support-factory.h
+++ b/libsqueeze/support-factory.h
@@ -27,6 +27,7 @@ typedef struct _LSQSupportFactory LSQSupportFactory;
 struct _LSQSupportFactory
 {
        GObject           parent;
+       gchar              *filename;
        gchar              *id;
        GSList            *mime_support;
 };
@@ -41,5 +42,6 @@ struct _LSQSupportFactoryClass
 GType                          lsq_support_factory_get_type(void);
 void                            
lsq_support_factory_init_archive(LSQSupportFactory *builder, LSQArchive 
*archive);
 void                            
lsq_support_factory_add_template(LSQSupportFactory *factory, LSQSupportTemplate 
*s_template);
+gint lsq_suport_factory_compare_filename(const LSQSupportFactory *factory, 
const gchar *filename);
 
 #endif /* __LIBSQUEEZE_SUPPORT_FACTORY_H__ */
diff --git a/libsqueeze/support-reader.c b/libsqueeze/support-reader.c
index cb83387..150cf56 100644
--- a/libsqueeze/support-reader.c
+++ b/libsqueeze/support-reader.c
@@ -138,6 +138,8 @@ lsq_support_reader_parse_file(const gchar *filename)
 
        XfceRc *rc = xfce_rc_simple_open(filename, TRUE);
 
+       factory->filename = g_path_get_basename(filename);
+
        xfce_rc_set_group(rc, "Desktop Entry");
 
        type = xfce_rc_read_entry(rc, "Type", "");
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to