Skip to content

Commit

Permalink
Add config schema to set local folders
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoday committed Jul 7, 2011
1 parent 58e0848 commit 61a46fe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Expand Up @@ -32,9 +32,9 @@ NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = .
DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure \
config/install-sh config/missing
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
TODO config/install-sh config/missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \
$(top_srcdir)/configure.ac
Expand Down
10 changes: 9 additions & 1 deletion src/Makefile.am
Expand Up @@ -18,7 +18,15 @@ metadata.json: metadata.json.in $(top_builddir)/config.status
-e "s|[@]shell_current@|$(PACKAGE_VERSION)|" \
-e "s|[@]url@|$(extensionurl)|" $< > $@

CLEANFILES = metadata.json

gschemas_in = org.gnome.shell.extensions.wallpapers.gschema.xml.in

@INTLTOOL_XML_NOMERGE_RULE@

gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)

@GSETTINGS_RULES@

CLEANFILES = metadata.json $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

10 changes: 7 additions & 3 deletions src/Makefile.in
Expand Up @@ -178,16 +178,18 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
extensionurl =
extensionurl = https://github.com/jgoday/gnome-shell-extension-wallpapers

# Change these to modify how installation is performed
topextensiondir = $(datadir)/gnome-shell/extensions
uuid = wallpapers@jgoday.wordpress.com
extensiondir = $(topextensiondir)/$(uuid)
dist_extension_DATA = extension.js stylesheet.css
nodist_extension_DATA = metadata.json $(EXTRA_EXTENSION)
EXTRA_DIST = metadata.json.in
CLEANFILES = metadata.json
EXTRA_DIST = metadata.json.in $(gschemas_in)
gschemas_in = org.gnome.shell.extensions.wallpapers.gschema.xml.in
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
CLEANFILES = metadata.json $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
all: all-am

.SUFFIXES:
Expand Down Expand Up @@ -423,6 +425,8 @@ metadata.json: metadata.json.in $(top_builddir)/config.status

@INTLTOOL_XML_NOMERGE_RULE@

@GSETTINGS_RULES@

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
25 changes: 18 additions & 7 deletions src/extension.js
Expand Up @@ -16,16 +16,15 @@ const Soup = imports.gi.Soup;
const St = imports.gi.St;
const Tweener = imports.ui.tweener;

const DIRECTORIES = ["/usr/share/backgrounds",
GLib.get_home_dir() + "/Pictures",
GLib.get_user_data_dir() + "/wallpapers"];
const DIRECTORIES = [GLib.get_user_data_dir() + "/wallpapers"];

const THUMBNAIL_WIDTH = 300;
const THUMBNAIL_HEIGHT = 190;

const CELL_WIDTH = 310;
const CELL_HEIGHT = 190;

const WALLPAPERS_SCHEMA = "org.gnome.shell.extensions.wallpapers";
const FOLDERS_KEY = "folders";
const SET_BACKGROUND_SCHEMA = "org.gnome.desktop.background";
const SET_BACKGROUND_KEY = "picture-uri";
const SPINNER_ANIMATION_TIME = 0.2;
Expand Down Expand Up @@ -121,8 +120,7 @@ LocalProvider.prototype = {
ImageProvider.prototype._init.call(this);
},
search: function() {
var dirs = DIRECTORIES;

let dirs = this.getDirectories();
let i = 0;
let obj = this;
let count = 0 ;
Expand Down Expand Up @@ -165,12 +163,25 @@ LocalProvider.prototype = {
"file://" + dir + "/" + name,
"");
}
count ++;
if (name.isImage()) {
count ++;
}
}
this._total_count = count;
}
}
obj.emit('search_images_done');
},
getDirectories: function() {
function _parseFolder(s) {
return s.replace("~", GLib.get_home_dir()).trim();
}

let settings = new Gio.Settings({ schema: WALLPAPERS_SCHEMA });

return settings.get_string(FOLDERS_KEY).split(",").map(
function(s) { return _parseFolder(s); }
).concat(DIRECTORIES);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/org.gnome.shell.extensions.wallpapers.gschema.xml.in
@@ -0,0 +1,9 @@
<schemalist gettext-domain="gnome-shell-extension-wallpapers">
<schema path="/org/gnome/shell/extensions/wallpapers/" id="org.gnome.shell.extensions.wallpapers">
<key name="folders" type="s">
<default>/usr/share/backgrounds</default>
<_summary>Comma separated list of folders.</_summary>
<_description>Choose the folders to search images.</_description>
</key>
</schema>
</schemalist>

0 comments on commit 61a46fe

Please sign in to comment.