mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
screenshot: Use FileManager1 to show files
This commit is contained in:
parent
1dda339395
commit
0a34cface1
3 changed files with 62 additions and 24 deletions
33
data/dbus-interfaces/org.freedesktop.FileManager1.xml
Normal file
33
data/dbus-interfaces/org.freedesktop.FileManager1.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE node PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"https://dbus.freedesktop.org/doc/introspect.dtd" >
|
||||
<!--
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<node>
|
||||
<interface name='org.freedesktop.FileManager1'>
|
||||
<method name='ShowFolders'>
|
||||
<arg type='as' name='URIs' direction='in'/>
|
||||
<arg type='s' name='StartupId' direction='in'/>
|
||||
</method>
|
||||
<method name='ShowItems'>
|
||||
<arg type='as' name='URIs' direction='in'/>
|
||||
<arg type='s' name='StartupId' direction='in'/>
|
||||
</method>
|
||||
<method name='ShowItemProperties'>
|
||||
<arg type='as' name='URIs' direction='in'/>
|
||||
<arg type='s' name='StartupId' direction='in'/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
<file preprocess="xml-stripblanks">org.freedesktop.bolt1.Device.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.bolt1.Manager.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.DBus.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.FileManager1.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.GeoClue2.Agent.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.GeoClue2.Manager.xml</file>
|
||||
<file preprocess="xml-stripblanks">org.freedesktop.impl.portal.Access.xml</file>
|
||||
|
|
|
|||
|
|
@ -33,6 +33,32 @@ const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot');
|
|||
const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');
|
||||
const ScreencastProxy = Gio.DBusProxy.makeProxyWrapper(ScreencastIface);
|
||||
|
||||
const FileManagerIface = loadInterfaceXML('org.freedesktop.FileManager1');
|
||||
const FileManagerProxy = Gio.DBusProxy.makeProxyWrapper(FileManagerIface);
|
||||
|
||||
function showInFiles(file) {
|
||||
new FileManagerProxy(
|
||||
Gio.DBus.session,
|
||||
'org.freedesktop.FileManager1',
|
||||
'/org/freedesktop/FileManager1',
|
||||
(proxy, error) => {
|
||||
if (error) {
|
||||
Main.notifyError(
|
||||
_('Unable to Show in Files'),
|
||||
_('File manager encountered a problem'));
|
||||
console.warn(error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
proxy.ShowItemsAsync([file.get_uri()], '').catch(e => {
|
||||
Main.notifyError(
|
||||
_('Unable to Show in Files'),
|
||||
_('File manager encountered a problem'));
|
||||
console.warn(e.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const IconLabelButton = GObject.registerClass(
|
||||
class IconLabelButton extends St.Button {
|
||||
_init(iconName, label, params) {
|
||||
|
|
@ -2034,18 +2060,7 @@ export const ScreenshotUI = GObject.registerClass({
|
|||
_('Click here to view the video.')
|
||||
);
|
||||
// Translators: button on the screencast notification.
|
||||
notification.addAction(_('Show in Files'), () => {
|
||||
const app =
|
||||
Gio.app_info_get_default_for_type('inode/directory', false);
|
||||
|
||||
if (app === null) {
|
||||
// It may be null e.g. in a toolbox without nautilus.
|
||||
log('Error showing in files: no default app set for inode/directory');
|
||||
return;
|
||||
}
|
||||
|
||||
app.launch([file], global.create_app_launch_context(0, -1));
|
||||
});
|
||||
notification.addAction(_('Show in Files'), () => showInFiles(file));
|
||||
notification.connect('activated', () => {
|
||||
try {
|
||||
Gio.app_info_launch_default_for_uri(
|
||||
|
|
@ -2275,18 +2290,7 @@ function _storeScreenshot(bytes, pixbuf) {
|
|||
|
||||
if (!disableSaveToDisk) {
|
||||
// Translators: button on the screenshot notification.
|
||||
notification.addAction(_('Show in Files'), () => {
|
||||
const app =
|
||||
Gio.app_info_get_default_for_type('inode/directory', false);
|
||||
|
||||
if (app === null) {
|
||||
// It may be null e.g. in a toolbox without nautilus.
|
||||
log('Error showing in files: no default app set for inode/directory');
|
||||
return;
|
||||
}
|
||||
|
||||
app.launch([file], global.create_app_launch_context(0, -1));
|
||||
});
|
||||
notification.addAction(_('Show in Files'), () => showInFiles(file));
|
||||
notification.connect('activated', () => {
|
||||
try {
|
||||
Gio.app_info_launch_default_for_uri(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue