1
0
mirror of https://github.com/GNOME/gedit synced 2024-06-30 23:15:01 +00:00

filebrowser: remove confirm-trash gsetting, as in Nautilus

Nautilus has removed the gsetting, keeping its default value (true) for
the behavior.

So, always ask for confirmation.

This fixes a crash at startup:
```
GLib-GIO-ERROR: Settings schema 'org.gnome.nautilus.preferences' does
not contain a key named 'confirm-trash'
```

In the future, before using an external GSettings key, we should
introspect at run-time if the *key* exists (not only the GSettings base
object, which was already checked here for NAUTILUS_BASE_SETTINGS with
NAUTILUS_FALLBACK_SETTINGS as a fallback).

We could have kept the confirm-trash gsetting key from
org.gnome.gedit.plugins.filebrowser.nautilus, and still use it, so that
users could configure that aspect, but we think it's better to follow
what Nautilus does, and the fewer options we have, the better (easier to
test).
This commit is contained in:
Sébastien Wilmet 2022-07-16 13:47:21 +02:00
parent 63343b24bf
commit 56a285ab9f
2 changed files with 0 additions and 36 deletions

View File

@ -50,7 +50,6 @@
#define NAUTILUS_BASE_SETTINGS "org.gnome.nautilus.preferences"
#define NAUTILUS_FALLBACK_SETTINGS "org.gnome.gedit.plugins.filebrowser.nautilus"
#define NAUTILUS_CLICK_POLICY_KEY "click-policy"
#define NAUTILUS_CONFIRM_TRASH_KEY "confirm-trash"
#define TERMINAL_BASE_SETTINGS "org.gnome.desktop.default-applications.terminal"
#define TERMINAL_EXEC_KEY "exec"
@ -66,10 +65,8 @@ struct _GeditFileBrowserPluginPrivate
GeditFileBrowserWidget *tree_widget;
gboolean auto_root;
gulong end_loading_handle;
gboolean confirm_trash;
guint click_policy_handle;
guint confirm_trash_handle;
};
enum
@ -321,19 +318,10 @@ on_click_policy_changed (GSettings *settings,
gedit_file_browser_view_set_click_policy (view, policy);
}
static void
on_confirm_trash_changed (GSettings *settings,
const gchar *key,
GeditFileBrowserPlugin *plugin)
{
plugin->priv->confirm_trash = g_settings_get_boolean (settings, key);
}
static void
install_nautilus_prefs (GeditFileBrowserPlugin *plugin)
{
GeditFileBrowserPluginPrivate *priv = plugin->priv;
gboolean prefb;
GeditFileBrowserViewClickPolicy policy;
GeditFileBrowserView *view;
@ -349,18 +337,6 @@ install_nautilus_prefs (GeditFileBrowserPlugin *plugin)
"changed::" NAUTILUS_CLICK_POLICY_KEY,
G_CALLBACK (on_click_policy_changed),
plugin);
/* Get confirm_trash */
prefb = g_settings_get_boolean (priv->nautilus_settings,
NAUTILUS_CONFIRM_TRASH_KEY);
priv->confirm_trash = prefb;
priv->confirm_trash_handle =
g_signal_connect (priv->nautilus_settings,
"changed::" NAUTILUS_CONFIRM_TRASH_KEY,
G_CALLBACK (on_confirm_trash_changed),
plugin);
}
static void
@ -588,12 +564,6 @@ gedit_file_browser_plugin_deactivate (GeditWindowActivatable *activatable)
priv->click_policy_handle);
}
if (priv->confirm_trash_handle)
{
g_signal_handler_disconnect (priv->nautilus_settings,
priv->confirm_trash_handle);
}
panel = gedit_window_get_side_panel (priv->window);
gtk_container_remove (GTK_CONTAINER (panel), GTK_WIDGET (priv->tree_widget));
}
@ -932,9 +902,6 @@ on_confirm_delete_cb (GeditFileBrowserWidget *widget,
gchar *secondary;
gboolean result;
if (!priv->confirm_trash)
return TRUE;
if (paths->next == NULL)
{
normal = get_filename_from_path (GTK_TREE_MODEL (store), (GtkTreePath *)(paths->data));

View File

@ -51,8 +51,5 @@
<key name="click-policy" enum="org.gnome.gedit.plugins.filebrowser.nautilus.ClickPolicy">
<default>'double'</default>
</key>
<key name="confirm-trash" type="b">
<default>true</default>
</key>
</schema>
</schemalist>