Skip to content

Commit

Permalink
SFTP Plugin: add an experimental option to disable automounting
Browse files Browse the repository at this point in the history
Add a GSetting with a toggle in the experimental section for disabling
automount on connection. The existing behaviour will retained, as there
is little to no overhead for an idle connection and most users don't
report this being a problem.

cc #882
  • Loading branch information
andyholmes committed Sep 11, 2020
1 parent c72931a commit 855c249
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
6 changes: 5 additions & 1 deletion data/org.gnome.Shell.Extensions.GSConnect.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@
<default>{}</default>
</key>
</schema>
<schema id="org.gnome.Shell.Extensions.GSConnect.Plugin.SFTP"/>
<schema id="org.gnome.Shell.Extensions.GSConnect.Plugin.SFTP">
<key name="automount" type="b">
<default>true</default>
</key>
</schema>
<schema id="org.gnome.Shell.Extensions.GSConnect.Plugin.Share">
<key name="receive-files" type="b">
<default>true</default>
Expand Down
57 changes: 57 additions & 0 deletions data/ui/preferences-device-panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,63 @@
</accessibility>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="sftp">
<property name="height_request">56</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selectable">False</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="sftp-automount-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">SFTP Automount</property>
<accessibility>
<relation type="label-for" target="sftp"/>
<relation type="label-for" target="sftp-automount"/>
</accessibility>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="sftp-automount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="action_name">settings.automount</property>
<accessibility>
<relation type="controlled-by" target="sftp"/>
<relation type="labelled-by" target="sftp-automount-label"/>
</accessibility>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
<accessibility>
<relation type="controller-for" target="sftp-automount"/>
<relation type="labelled-by" target="sftp-automount-label"/>
</accessibility>
</object>
</child>
<accessibility>
<relation type="labelled-by" target="experimental-label"/>
</accessibility>
Expand Down
3 changes: 3 additions & 0 deletions src/preferences/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ var Panel = GObject.registerClass({
settings = this.pluginSettings('photo');
this.actions.add_action(settings.create_action('share-camera'));

settings = this.pluginSettings('sftp');
this.actions.add_action(settings.create_action('automount'));

settings = this.pluginSettings('share');
this.actions.add_action(settings.create_action('receive-files'));

Expand Down
12 changes: 10 additions & 2 deletions src/service/plugins/sftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ var Plugin = GObject.registerClass({

// Only enable for Lan connections
if (this.device.channel instanceof Lan.Channel) {
this.mount();
if (this.settings.get_boolean('automount'))
this.mount();
} else {
this.device.lookup_action('mount').enabled = false;
this.device.lookup_action('unmount').enabled = false;
Expand Down Expand Up @@ -398,7 +399,14 @@ var Plugin = GObject.registerClass({
const index = this.device.removeMenuAction('device.mount');
this.device.addMenuItem(filesMenuItem, index);
} catch (e) {
logError(e, this.device.name);
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
const service = Gio.Application.get_default();

if (service !== null)
service.notify_error(e);
else
logError(e, this.device.name);
}
}
}

Expand Down

0 comments on commit 855c249

Please sign in to comment.