Commit 3520322e authored by Ali Abdallah's avatar Ali Abdallah
Browse files

This commit implements Excludes paths

Any path found in a plugin Excludes will be ignored,
code contributed by Markus Kolb xfce@tower-net.de Bug #16130.
parent 4626d3a9
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ enum
  PROP_HASH_KEYS,
  PROP_PRIORITY,
  PROP_MAX_FILE_SIZE,
  PROP_LOCATIONS
  PROP_LOCATIONS,
  PROP_EXCLUDES
};


@@ -70,6 +71,7 @@ struct _TumblerAbstractThumbnailerPrivate
  gint    priority;
  gint64  max_file_size;
  GSList *locations;
  GSList *excludes;
};


@@ -101,6 +103,7 @@ tumbler_abstract_thumbnailer_class_init (TumblerAbstractThumbnailerClass *klass)
  g_object_class_override_property (gobject_class, PROP_PRIORITY, "priority");
  g_object_class_override_property (gobject_class, PROP_MAX_FILE_SIZE, "max-file-size");
  g_object_class_override_property (gobject_class, PROP_LOCATIONS, "locations");
  g_object_class_override_property (gobject_class, PROP_EXCLUDES, "excludes");
}


@@ -180,6 +183,9 @@ tumbler_abstract_thumbnailer_finalize (GObject *object)
  g_slist_foreach (thumbnailer->priv->locations, (GFunc) g_object_unref, NULL);
  g_slist_free (thumbnailer->priv->locations);

  g_slist_foreach (thumbnailer->priv->excludes, (GFunc) g_object_unref, NULL);
  g_slist_free (thumbnailer->priv->excludes);

  (*G_OBJECT_CLASS (tumbler_abstract_thumbnailer_parent_class)->finalize) (object);
}

@@ -222,6 +228,12 @@ tumbler_abstract_thumbnailer_get_property (GObject *object,
      g_value_set_pointer (value, dup);
      break;

    case PROP_EXCLUDES:
      dup = g_slist_copy (thumbnailer->priv->excludes);
      g_slist_foreach (dup, (GFunc) g_object_ref, NULL);
      g_value_set_pointer (value, dup);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
@@ -267,6 +279,12 @@ tumbler_abstract_thumbnailer_set_property (GObject *object,
      thumbnailer->priv->locations = dup;
      break;

    case PROP_EXCLUDES:
      dup = g_slist_copy (g_value_get_pointer (value));
      g_slist_foreach (dup, (GFunc) g_object_ref, NULL);
      thumbnailer->priv->excludes = dup;
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
+26 −6
Original line number Diff line number Diff line
@@ -117,6 +117,12 @@ tumbler_thumbnailer_class_init (TumblerThumbnailerIface *klass)
                                                             "locations",
                                                             G_PARAM_READWRITE));

  g_object_interface_install_property (klass,
                                       g_param_spec_pointer ("excludes",
                                                             "excludes",
                                                             "excludes",
                                                             G_PARAM_READWRITE));

  tumbler_thumbnailer_signals[SIGNAL_READY] =
    g_signal_new ("ready",
                  TUMBLER_TYPE_THUMBNAILER,
@@ -242,12 +248,26 @@ gboolean
tumbler_thumbnailer_supports_location (TumblerThumbnailer *thumbnailer,
                                       GFile              *file)
{
  GSList   *locations, *lp;
  GSList   *locations, *excludes, *lp, *ep;
  gboolean  supported = FALSE;
  gboolean  excluded  = FALSE;

  g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer), FALSE);
  g_return_val_if_fail (G_IS_FILE (file), FALSE);

  /* check first if file is excluded */
  g_object_get (thumbnailer, "excludes", &excludes, NULL);
  if (excludes != NULL)
  {
    for (ep = excludes; !excluded && ep != NULL; ep = ep->next)
      if (g_file_has_prefix (file, G_FILE (ep->data)))
        excluded = TRUE;
  }

  /* Path is excluded */
  if (excluded)
    return FALSE;

  /* we're cool if no locations are set */
  g_object_get (thumbnailer, "locations", &locations, NULL);
  if (locations == NULL)
+8 −0
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@ main (int argc,
  const gchar             *type_name;
  gchar                  **paths;
  GSList                  *locations;
  GSList                  *excludes;

  /* set the program name */
  g_set_prgname (G_LOG_DOMAIN);
@@ -322,10 +323,15 @@ main (int argc,
          locations = locations_from_strv (paths);
          g_strfreev (paths);

          paths = g_key_file_get_string_list (rc, type_name, "Excludes", NULL, NULL);
          excludes = locations_from_strv (paths);
          g_strfreev (paths);

          g_object_set (G_OBJECT (tp->data),
                        "priority", priority,
                        "max-file-size", file_size,
                        "locations", locations,
                        "excludes", excludes,
                        NULL);

          /* ready for usage */
@@ -335,6 +341,8 @@ main (int argc,
          g_object_unref (tp->data);
          g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
          g_slist_free (locations);
          g_slist_foreach (excludes, (GFunc) g_object_unref, NULL);
          g_slist_free (excludes);
        }

      /* free the thumbnailer list */
+15 −1
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@
#              priority will be tried.
#              Absolute paths, environement variables, ~/ and ~username/
#              are allowed. Leave empty to allow all locations.
# Excludes:    ;-separated path list the plugin will not be used in.
#              Absolute paths, environement variables, ~/ and ~username/
#              are allowed. Leave empty to exclude nothing. Please note
#              that paths in Excludes precede those in Locations.
# MaxFileSize: Maximum size of the source file the plugin will still
#              try to generate a plugin for. The size is in bytes,
#              0 disabled the check.
@@ -26,6 +30,7 @@
Disabled=false
Priority=3
Locations=
Excludes=
MaxFileSize=209715200

# Supports all type GdkPixbuf supports
@@ -33,6 +38,7 @@ MaxFileSize=209715200
Disabled=false
Priority=2
Locations=
Excludes=
MaxFileSize=209715200

# RAW image files using libopenraw
@@ -40,6 +46,7 @@ MaxFileSize=209715200
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=209715200

###
@@ -53,6 +60,7 @@ MaxFileSize=209715200
Disabled=true
Priority=3
Locations=~/movies
Excludes=
MaxFileSize=0
#APIKey=your-api-key-from-themoviedb.org

@@ -61,6 +69,7 @@ MaxFileSize=0
Disabled=false
Priority=2
Locations=
Excludes=
MaxFileSize=2147483648

# GStreamer plugin
@@ -68,6 +77,7 @@ MaxFileSize=2147483648
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=2147483648

###
@@ -79,6 +89,7 @@ MaxFileSize=2147483648
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=209715200


@@ -87,6 +98,7 @@ MaxFileSize=209715200
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=209715200

# Open document thumbnailer (ODF)
@@ -94,6 +106,7 @@ MaxFileSize=209715200
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=209715200

# thumbnailers provided by .thumbnailer desktop files
@@ -101,4 +114,5 @@ MaxFileSize=209715200
Disabled=false
Priority=1
Locations=
Excludes=
MaxFileSize=2147483648