Skip to content

Commit

Permalink
Version 2.0 BETA 2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DEM0NAssissan7 authored Jul 29, 2021
1 parent f202525 commit 8b468ca
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
5 changes: 4 additions & 1 deletion desktopIconsUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const Gettext = imports.gettext.domain('desktopicons-neo');
const _ = Gettext.gettext;

function getDesktopDir() {
let desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
let desktopPath = Prefs.desktopSettings.get_string('desktop-directory');
if(desktopPath == 'null'){
desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
}
return Gio.File.new_for_commandline_arg(desktopPath);
}

Expand Down
14 changes: 13 additions & 1 deletion desktopManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ var DesktopManager = class {
this._scriptsDir = DesktopIconsUtil.getScriptsDir();
this.desktopFsId = this._desktopDir.query_info('id::filesystem', Gio.FileQueryInfoFlags.NONE, null).get_attribute_string('id::filesystem');
this._updateWritableByOthers();
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
try{
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
} catch(e){
logError(e, "schemaSource errored out. Fixing desktop-directory..");
Prefs.desktopSettings.set_string('desktop-directory', GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP));
this._monitorDesktopDir = this._desktopDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
}
this._monitorDesktopDir.set_rate_limit(1000);
this._monitorDesktopDir.connect('changed', (obj, file, otherFile, eventType) => this._updateDesktopIfChanged(file, otherFile, eventType));
this._monitorScriptDir = this._scriptsDir.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, null);
Expand Down Expand Up @@ -107,6 +113,12 @@ var DesktopManager = class {
this._updateDesktop();
}
});
Prefs.gtkSettings.connect('changed', (obj, key) => {
if (key == 'desktop-directory') {
this._desktopDir = Prefs.gtkSettings.get_string('desktop-directory');
this._updateDesktop();
}
});
this._gtkIconTheme = Gtk.IconTheme.get_default()
this._gtkIconTheme.connect('changed', () => {
this._updateDesktop();
Expand Down
23 changes: 22 additions & 1 deletion preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Gio = imports.gi.Gio;
const GioSSS = Gio.SettingsSchemaSource;
const DesktopIconsUtil = imports.desktopIconsUtil;
const Enums = imports.enums;
const DesktopManager = imports.desktopManager;

const Gettext = imports.gettext;

Expand Down Expand Up @@ -68,7 +69,7 @@ function get_schema(schema) {
let schemaSource;
let schemaFile = Gio.File.new_for_path(GLib.build_filenamev([extensionPath, 'schemas', 'gschemas.compiled']));
if (schemaFile.query_exists(null)) {
schemaSource = GioSSS.new_from_directory(GLib.build_filenamev([extensionPath, 'schemas']), GioSSS.get_default(), false);
schemaSource = GioSSS.new_from_directory(GLib.build_filenamev([extensionPath, 'schemas']), GioSSS.get_default(), false);
} else {
schemaSource = GioSSS.get_default();
}
Expand Down Expand Up @@ -107,6 +108,7 @@ function showPreferences() {
'bottom-left': _("Bottom-left corner"),
'bottom-right': _("Bottom-right corner")
}));
frame.add(buildFileChooserButton(desktopSettings, 'desktop-directory', _("Desktop directory > " + desktopSettings.get_string('desktop-directory')), _("Set desktop directory")));
frame.add(buildSelector(desktopSettings,
'icon-shape',
_("Icon shape"),
Expand Down Expand Up @@ -163,6 +165,25 @@ function buildSwitcher(settings, key, labelText) {
return hbox;
}

function buildFileChooserButton(settings, key, labelText, buttonText) {
function activateFileChooser(){hbox.add(filechooser)}
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 10 });
let label = new Gtk.Label({ label: labelText, xalign: 0 });
let button = new Gtk.Button({ label: buttonText })
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 });
button.connect('clicked', () => {
fileChooser.show();
});
fileChooser.connect('response', (dlg, response) => {
if (response !== Gtk.ResponseType.ACCEPT)
return;
settings.set_string(key, dlg.get_file().get_path());
});
hbox.pack_start(label, true, true, 0);
hbox.add(button);
return hbox;
}

function buildSelector(settings, key, labelText, elements) {
let listStore = new Gtk.ListStore();
listStore.set_column_types ([GObject.TYPE_STRING, GObject.TYPE_STRING]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<summary>Show personal folder</summary>
<description>Show the personal folder in the desktop.</description>
</key>
<key type="b" name="show-trash">
<key type="b" name="show-trash">
<default>true</default>
<summary>Show trash icon</summary>
<description>Show the trash icon in the desktop.</description>
Expand All @@ -52,6 +52,11 @@
<summary>Icon shape</summary>
<description>Set the shape of the icons</description>
</key>
<key type="s" name="desktop-directory">
<default>'null'</default>
<summary>Desktop icons working directory</summary>
<description>The directory that contains the files that the extension edits, displays, and interacts with.</description>
</key>
<key type="b" name="curved-corners">
<default>true</default>
<summary>Curve corners</summary>
Expand Down

0 comments on commit 8b468ca

Please sign in to comment.