Skip to content

Commit 0461127

Browse files
committed
Implement mount/unmount/autorun user interaction in Cinnamon.
Certain aspects of GtkMountOperation are broken under Wayland in Gtk3 and won't be fixed. Fortunately it can also use a dbus interface (org.gtk.MountOperationHandler) if a provider exists. This allows us to: - provide the 'device is in use' popup and showing which application is using it, when trying to eject a device. - provide the password/question dialog when mounting devices that require interaction before mounting. - eliminate a lot of code and translations from placesManager, and make the behavior identical when interacting with a device whether from a file manager or Cinnamon's drives applet. Translations are provided by Gtk, Gvfs instead (as when ejecting a device from a file manager). - Adds testMountDialogs.js for theme/dialog testing (activatable via looking-glass). Also replace mount-detection handling in cinnamon-settings-daemon. It was originally part of Cinnamon but mostly removed early on when Cinnamon was forked, and we've relied on csd-automount. With the implementation of CinnamonMountOperation for handling unmount operations, we can bring in the autorun dialog as well. - csd-automount is still used in fallback mode and managed by cinnamon-launcher in those situations (nm-applet, polkit agents are already handled here also). - linuxmint/cinnamon-settings-daemon#445 disables autostarting csd-automount at session startup. - Adds testAutorunDialog.js for theme/dialog testing (activatable via looking-glass).
1 parent ab9adeb commit 0461127

20 files changed

Lines changed: 2071 additions & 264 deletions

data/org.cinnamon.gschema.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,15 @@
611611
<default>""</default>
612612
<summary>Stores the position of the hoverclick window so it can be restored there later - format is x::y</summary>
613613
</key>
614+
<key name="remember-mount-password" type="b">
615+
<default>false</default>
616+
<summary>Whether to remember password for mounting encrypted or remote filesystems</summary>
617+
<description>
618+
When an encrypted device or remote filesystem is mounted, a password
619+
dialog may include a "Remember Password" checkbox. This key stores the
620+
default state of that checkbox.
621+
</description>
622+
</key>
614623
</schema>
615624

616625
<schema id="org.cinnamon.theme" path="/org/cinnamon/theme/"

data/theme/cinnamon-sass/widgets/_dialogs.scss

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@
4141
.dialog-list-box {
4242
spacing: 1em;
4343

44+
border-radius: $base_border_radius;
45+
4446
.dialog-list-item {
4547
spacing: 1em;
48+
border-radius: $base_border_radius;
49+
padding: $base_padding $base_padding * 2;
50+
transition-duration: 100ms;
51+
52+
&:hover { background-color: $light_bg_color; }
53+
&:selected { background-color: $accent_bg_color; }
4654

4755
.dialog-list-item-title { font-weight: bold; }
4856
.dialog-list-item-description {
@@ -194,3 +202,46 @@
194202
}
195203
}
196204
}
205+
206+
.autorun-dialog {
207+
min-width: 30em;
208+
209+
.dialog-content-box {
210+
margin-top: $base_margin;
211+
margin-bottom: $base_margin * 3;
212+
spacing: $base_margin * 3;
213+
max-width: 28em;
214+
215+
.dialog-list {
216+
.dialog-list-box {
217+
background-color: lighten($bg_color, 5%);
218+
spacing: 0;
219+
220+
.dialog-list-item {
221+
border-radius: 0;
222+
223+
&:first-child {
224+
border-radius: $base_border_radius $base_border_radius 0 0;
225+
}
226+
227+
&:last-child {
228+
border-radius: 0 0 $base_border_radius $base_border_radius;
229+
}
230+
}
231+
}
232+
}
233+
234+
.autorun-dialog-heading {
235+
@extend %title_2;
236+
text-align: center;
237+
}
238+
239+
.autorun-dialog-subheading {
240+
@extend %title_4;
241+
text-align: center;
242+
}
243+
244+
.autorun-dialog-description {
245+
}
246+
}
247+
}

docs/reference/cinnamon/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ignore = [
22
'cinnamon-recorder-src.h',
33
'cinnamon-recorder.h',
4+
'cinnamon-mount-operation.h',
45
st_headers,
56
st_private_headers,
67
tray_headers,

files/usr/bin/cinnamon-launcher

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Launcher:
7373

7474
self.polkit_agent_proc = None
7575
self.nm_applet_proc = None
76+
self.automount_proc = None
7677
self.can_restart = False
7778
self.dialog = None
7879

@@ -161,6 +162,10 @@ class Launcher:
161162
print(f"Launching for fallback session: nm-applet")
162163
self.nm_applet_proc = subprocess.Popen(["nm-applet"])
163164

165+
if shutil.which("csd-automount"):
166+
print(f"Launching for fallback session: csd-automount")
167+
self.automount_proc = subprocess.Popen(["csd-automount"])
168+
164169
def kill_fallback_helpers(self):
165170
if self.polkit_agent_proc is not None:
166171
print("Killing fallback polkit agent")
@@ -180,6 +185,15 @@ class Launcher:
180185
self.nm_applet_proc.kill()
181186
self.nm_applet_proc = None
182187

188+
if self.automount_proc is not None:
189+
print("Killing fallback csd-automount")
190+
self.automount_proc.terminate()
191+
try:
192+
self.automount_proc.wait(timeout=5)
193+
except subprocess.TimeoutExpired:
194+
self.automount_proc.kill()
195+
self.automount_proc = None
196+
183197
@async_function
184198
def monitor_memory(self):
185199
if psutil.pid_exists(self.cinnamon_pid):

js/misc/loginManager.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ var LoginManagerSystemd = class {
7979
constructor() {
8080
this._managerProxy = null;
8181
this._sessionProxy = null;
82+
this.sessionIsActive = true;
8283
this.isLocked = false;
8384

8485
this._initSession();
@@ -152,25 +153,26 @@ var LoginManagerSystemd = class {
152153

153154
this._sessionProxy.connectSignal('Lock', () => {
154155
_log('LoginManager: Received Lock signal from logind, emitting lock');
156+
this.isLocked = true;
155157
this.emit('lock');
156158
});
157159

158160
this._sessionProxy.connectSignal('Unlock', () => {
159161
_log('LoginManager: Received Unlock signal from logind, emitting unlock');
162+
this.isLocked = false;
160163
this.emit('unlock');
161164
});
162165

163166
this._sessionProxy.connect('g-properties-changed', (proxy, changed, invalidated) => {
164167
if ('Active' in changed.deep_unpack()) {
165168
let active = this._sessionProxy.Active;
169+
this.sessionIsActive = active;
166170
_log(`LoginManager: Session Active property changed: ${active}`);
167-
if (active) {
168-
_log('LoginManager: Session became active, emitting active');
169-
this.emit('active');
170-
}
171+
this.emit('active-changed', active);
171172
}
172173
});
173174

175+
this.sessionIsActive = this._sessionProxy.Active;
174176
this.emit('session-ready');
175177
} catch (e) {
176178
global.logError('LoginManager: Failed to connect to logind session: ' + e.message);
@@ -230,6 +232,8 @@ var LoginManagerConsoleKit = class {
230232
constructor() {
231233
this._managerProxy = null;
232234
this._sessionProxy = null;
235+
this.sessionIsActive = true;
236+
this.isLocked = false;
233237

234238
this._initSession();
235239
}
@@ -274,20 +278,20 @@ var LoginManagerConsoleKit = class {
274278

275279
this._sessionProxy.connectSignal('Lock', () => {
276280
_log('LoginManager: Received Lock signal from ConsoleKit, emitting lock');
281+
this.isLocked = true;
277282
this.emit('lock');
278283
});
279284

280285
this._sessionProxy.connectSignal('Unlock', () => {
281286
_log('LoginManager: Received Unlock signal from ConsoleKit, emitting unlock');
287+
this.isLocked = false;
282288
this.emit('unlock');
283289
});
284290

285291
this._sessionProxy.connectSignal('ActiveChanged', (proxy, sender, [active]) => {
292+
this.sessionIsActive = active;
286293
_log(`LoginManager: ConsoleKit ActiveChanged: ${active}`);
287-
if (active) {
288-
_log('LoginManager: Session became active, emitting active');
289-
this.emit('active');
290-
}
294+
this.emit('active-changed', active);
291295
});
292296

293297
this.emit('session-ready');

0 commit comments

Comments
 (0)