Skip to content

Commit 8b468ca

Browse files
Version 2.0 BETA 2
Holy sweet lordy I just spend 2 hours adding a single option to the menu. Oh well, it works I guess. Go ahead and test out this patch and report any bugs. This will be the last feature I add to this release. Anything beyond this point will be bug fixes ONLY (until it releases, of course). Cheers! Oh yeah, also added a couple fixes here and there, cleaning up the code and stuff.
1 parent f202525 commit 8b468ca

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

desktopIconsUtil.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const Gettext = imports.gettext.domain('desktopicons-neo');
2626
const _ = Gettext.gettext;
2727

2828
function getDesktopDir() {
29-
let desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
29+
let desktopPath = Prefs.desktopSettings.get_string('desktop-directory');
30+
if(desktopPath == 'null'){
31+
desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
32+
}
3033
return Gio.File.new_for_commandline_arg(desktopPath);
3134
}
3235

desktopManager.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ var DesktopManager = class {
6868
this._scriptsDir = DesktopIconsUtil.getScriptsDir();
6969
this.desktopFsId = this._desktopDir.query_info('id::filesystem', Gio.FileQueryInfoFlags.NONE, null).get_attribute_string('id::filesystem');
7070
this._updateWritableByOthers();
71-
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
71+
try{
72+
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
73+
} catch(e){
74+
logError(e, "schemaSource errored out. Fixing desktop-directory..");
75+
Prefs.desktopSettings.set_string('desktop-directory', GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP));
76+
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
77+
}
7278
this._monitorDesktopDir.set_rate_limit(1000);
7379
this._monitorDesktopDir.connect('changed', (obj, file, otherFile, eventType) => this._updateDesktopIfChanged(file, otherFile, eventType));
7480
this._monitorScriptDir = this._scriptsDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
@@ -107,6 +113,12 @@ var DesktopManager = class {
107113
this._updateDesktop();
108114
}
109115
});
116+
Prefs.gtkSettings.connect('changed', (obj, key) => {
117+
if (key == 'desktop-directory') {
118+
this._desktopDir = Prefs.gtkSettings.get_string('desktop-directory');
119+
this._updateDesktop();
120+
}
121+
});
110122
this._gtkIconTheme = Gtk.IconTheme.get_default()
111123
this._gtkIconTheme.connect('changed', () => {
112124
this._updateDesktop();

preferences.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Gio = imports.gi.Gio;
2424
const GioSSS = Gio.SettingsSchemaSource;
2525
const DesktopIconsUtil = imports.desktopIconsUtil;
2626
const Enums = imports.enums;
27+
const DesktopManager = imports.desktopManager;
2728

2829
const Gettext = imports.gettext;
2930

@@ -68,7 +69,7 @@ function get_schema(schema) {
6869
let schemaSource;
6970
let schemaFile = Gio.File.new_for_path(GLib.build_filenamev([extensionPath, 'schemas', 'gschemas.compiled']));
7071
if (schemaFile.query_exists(null)) {
71-
schemaSource = GioSSS.new_from_directory(GLib.build_filenamev([extensionPath, 'schemas']), GioSSS.get_default(), false);
72+
schemaSource = GioSSS.new_from_directory(GLib.build_filenamev([extensionPath, 'schemas']), GioSSS.get_default(), false);
7273
} else {
7374
schemaSource = GioSSS.get_default();
7475
}
@@ -107,6 +108,7 @@ function showPreferences() {
107108
'bottom-left': _("Bottom-left corner"),
108109
'bottom-right': _("Bottom-right corner")
109110
}));
111+
frame.add(buildFileChooserButton(desktopSettings, 'desktop-directory', _("Desktop directory > " + desktopSettings.get_string('desktop-directory')), _("Set desktop directory")));
110112
frame.add(buildSelector(desktopSettings,
111113
'icon-shape',
112114
_("Icon shape"),
@@ -163,6 +165,25 @@ function buildSwitcher(settings, key, labelText) {
163165
return hbox;
164166
}
165167

168+
function buildFileChooserButton(settings, key, labelText, buttonText) {
169+
function activateFileChooser(){hbox.add(filechooser)}
170+
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 10 });
171+
let label = new Gtk.Label({ label: labelText, xalign: 0 });
172+
let button = new Gtk.Button({ label: buttonText })
173+
let fileChooser = new Gtk.FileChooserNative({ title: "Choose a Directory (You MUST restart the extension to see/apply changes)", action: Gtk.FileChooserAction.SELECT_FOLDER, modal: true });
174+
button.connect('clicked', () => {
175+
fileChooser.show();
176+
});
177+
fileChooser.connect('response', (dlg, response) => {
178+
if (response !== Gtk.ResponseType.ACCEPT)
179+
return;
180+
settings.set_string(key, dlg.get_file().get_path());
181+
});
182+
hbox.pack_start(label, true, true, 0);
183+
hbox.add(button);
184+
return hbox;
185+
}
186+
166187
function buildSelector(settings, key, labelText, elements) {
167188
let listStore = new Gtk.ListStore();
168189
listStore.set_column_types ([GObject.TYPE_STRING, GObject.TYPE_STRING]);

schemas/org.gnome.shell.extensions.desktopicons-neo.gschema.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<summary>Show personal folder</summary>
3838
<description>Show the personal folder in the desktop.</description>
3939
</key>
40-
<key type="b" name="show-trash">
40+
<key type="b" name="show-trash">
4141
<default>true</default>
4242
<summary>Show trash icon</summary>
4343
<description>Show the trash icon in the desktop.</description>
@@ -52,6 +52,11 @@
5252
<summary>Icon shape</summary>
5353
<description>Set the shape of the icons</description>
5454
</key>
55+
<key type="s" name="desktop-directory">
56+
<default>'null'</default>
57+
<summary>Desktop icons working directory</summary>
58+
<description>The directory that contains the files that the extension edits, displays, and interacts with.</description>
59+
</key>
5560
<key type="b" name="curved-corners">
5661
<default>true</default>
5762
<summary>Curve corners</summary>

0 commit comments

Comments
 (0)