[gnome-commander] The user can now select the default behavior for mouse DnD action, fixing #51
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] The user can now select the default behavior for mouse DnD action, fixing #51
- Date: Mon, 15 Nov 2021 22:12:29 +0000 (UTC)
commit 0d0c5bdb98e004e4151d1fdfe5d4f2d384aed463
Author: Uwe Scholz <u scholz83 gmx de>
Date: Mon Nov 15 23:08:39 2021 +0100
The user can now select the default behavior for mouse DnD action, fixing #51
NEWS | 3 ++-
data/org.gnome.gnome-commander.gschema.xml | 4 ++--
doc/C/index.docbook | 8 ++++++--
doc/C/releases.xml | 5 ++++-
src/dialogs/gnome-cmd-options-dialog.cc | 29 +++++++++++++++++++-------
src/gnome-cmd-data.cc | 14 ++++++-------
src/gnome-cmd-data.h | 4 ++--
src/gnome-cmd-file-list.cc | 33 +++++++++++++++++++++---------
src/gnome-cmd-types.h | 8 ++++++++
9 files changed, 76 insertions(+), 32 deletions(-)
---
diff --git a/NEWS b/NEWS
index 253898e2..15eb5fee 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,7 @@ gnome-commander 1.14
---------------
New features:
- * ...
+ * Selectable default action when drag-n-drop files with the mouse
Bug fixes:
* Fixed issue #3 (Mounted devices pluged when Commander is running are not noticed)
@@ -15,6 +15,7 @@ Bug fixes:
* Fixed issue #41 (Directory not unreferenced correctly from cache when renamed)
* Fixed issue #46 (Automatic refresh of folder content is not correct)
* Fixed issue #47 (Duplicate directory when copying over an existing directory)
+ * Fixed issue #51 (Move and not copy by default on same filesystem)
* Fixed issue #52 (Auto refresh when changing permissions etc)
* Fixed issue #74 (Does not show mounted external drives)
* Fixed issue #75 (Newly inserted DVD does not show up)
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index c1498023..f6085d55 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -607,8 +607,8 @@
This option defines the default behavior when items will be overwritten by a move command.
</description>
</key>
- <key name="mouse-drag-and-drop" type="b">
- <default>true</default>
+ <key name="mouse-drag-and-drop" enum="org.gnome.gnome-commander.GnomeCmdDefaultDndMode">
+ <default>'query'</default>
<summary>Confirm mouse drag and drop</summary>
<description>
This option defines the behavior of mouse drag and drop operations.
diff --git a/doc/C/index.docbook b/doc/C/index.docbook
index 9d9e03d2..7b47a373 100644
--- a/doc/C/index.docbook
+++ b/doc/C/index.docbook
@@ -1001,6 +1001,10 @@
</para>
</listitem>
</itemizedlist>
+ <para>When not pressing a key while droping the selection, the default is to query for the action to be
+ executed, i.e. copy, move or create a symbolic link. In the &app; options you can change that
behavior
+ to copy or to move the selection. See also under <xref
linkend="gnome-commander-prefs-confirmation"/>.
+ </para>
</sect2>
<!-- ================ Copying Files Subsection ======================= -->
<sect2 id="gnome-commander-copy">
@@ -5230,8 +5234,8 @@
moved already exists in the target location</para>
</listitem>
<listitem>
- <para><guilabel>Drag and Drop</guilabel> configure the action when an item
- is dropped after dragging it with the mouse</para>
+ <para><guilabel>Default Drag and Drop Action</guilabel> configure the action when an item
+ is dropped after dragging it with the mouse</para>
</listitem>
</itemizedlist>
</para>
diff --git a/doc/C/releases.xml b/doc/C/releases.xml
index fb1a8a74..4a20045e 100644
--- a/doc/C/releases.xml
+++ b/doc/C/releases.xml
@@ -56,6 +56,9 @@
<listitem>
<para>Fixed issue #47 (Duplicate directory when copying over an existing
directory)</para>
</listitem>
+ <listitem>
+ <para>Fixed issue #51 (Move and not copy by default on same filesystem)</para>
+ </listitem>
<listitem>
<para>Fixed issue #52 (Auto refresh when changing permissions etc)</para>
</listitem>
@@ -71,7 +74,7 @@
<para>
<itemizedlist>
<listitem>
- <para>...</para>
+ <para>Selectable default action when drag-n-drop files with the mouse</para>
</listitem>
<listitem>
<para>New or updated translations: ...</para>
diff --git a/src/dialogs/gnome-cmd-options-dialog.cc b/src/dialogs/gnome-cmd-options-dialog.cc
index 7d2bb818..3288508d 100644
--- a/src/dialogs/gnome-cmd-options-dialog.cc
+++ b/src/dialogs/gnome-cmd-options-dialog.cc
@@ -1105,13 +1105,21 @@ static GtkWidget *create_confirmation_tab (GtkWidget *parent, GnomeCmdData::Opti
/* Drag and Drop options
*/
cat_box = create_vbox (parent, FALSE, 0);
- cat = create_category (parent, cat_box, _("Drag and Drop"));
+ cat = create_category (parent, cat_box, _("Default Drag and Drop Action"));
gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
- check = create_check (parent, _("Confirm mouse operation"), "confirm_mouse_dnd_check");
- gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), cfg.confirm_mouse_dnd);
-
+ radio = create_radio (parent, NULL, _("Confirm mouse operation"), "mouse_dnd_default");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (cfg.mouse_dnd_default==GNOME_CMD_DEFAULT_DND_QUERY)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ radio = create_radio (parent, get_radio_group (radio), _("Copy"), "mouse_dnd_copy");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (cfg.mouse_dnd_default==GNOME_CMD_DEFAULT_DND_COPY)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ radio = create_radio (parent, get_radio_group (radio), _("Move"), "mouse_dnd_move");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (cfg.mouse_dnd_default==GNOME_CMD_DEFAULT_DND_MOVE)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
return frame;
}
@@ -1129,7 +1137,9 @@ void store_confirmation_options (GtkWidget *dialog, GnomeCmdData::Options &cfg)
GtkWidget *confirm_move_query = lookup_widget (dialog, "move_overwrite_query");
GtkWidget *confirm_move_rename_all = lookup_widget (dialog, "move_rename_all");
GtkWidget *confirm_move_skip_all = lookup_widget (dialog, "move_overwrite_skip_all");
- GtkWidget *confirm_mouse_dnd_check = lookup_widget (dialog, "confirm_mouse_dnd_check");
+ GtkWidget *mouse_dnd_query = lookup_widget (dialog, "mouse_dnd_default");
+ GtkWidget *mouse_dnd_copy = lookup_widget (dialog, "mouse_dnd_copy");
+ GtkWidget *mouse_dnd_move = lookup_widget (dialog, "mouse_dnd_move");
cfg.confirm_delete = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_delete_check));
@@ -1153,7 +1163,12 @@ void store_confirmation_options (GtkWidget *dialog, GnomeCmdData::Options &cfg)
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_move_skip_all)))
cfg.confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_SKIP_ALL;
- cfg.confirm_mouse_dnd = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_mouse_dnd_check));
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mouse_dnd_query)))
+ cfg.mouse_dnd_default = GNOME_CMD_DEFAULT_DND_QUERY;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mouse_dnd_copy)))
+ cfg.mouse_dnd_default = GNOME_CMD_DEFAULT_DND_COPY;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mouse_dnd_move)))
+ cfg.mouse_dnd_default = GNOME_CMD_DEFAULT_DND_MOVE;
}
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index d64a8f9d..1cc4af25 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -451,10 +451,10 @@ static void on_confirm_move_overwrite_changed ()
static void on_mouse_drag_and_drop_changed ()
{
- gboolean confirm_mouse_dnd;
+ gint mouse_dnd_default;
- confirm_mouse_dnd = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP);
- gnome_cmd_data.options.confirm_mouse_dnd = confirm_mouse_dnd;
+ mouse_dnd_default = g_settings_get_enum (gnome_cmd_data.options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP);
+ gnome_cmd_data.options.mouse_dnd_default = (GnomeCmdDefaultDndMode) mouse_dnd_default;
}
static void on_select_dirs_changed ()
@@ -1423,7 +1423,7 @@ GnomeCmdData::Options::Options(const Options &cfg)
confirm_delete_default = cfg.confirm_delete_default;
confirm_copy_overwrite = cfg.confirm_copy_overwrite;
confirm_move_overwrite = cfg.confirm_move_overwrite;
- confirm_mouse_dnd = cfg.confirm_mouse_dnd;
+ mouse_dnd_default = cfg.mouse_dnd_default;
filter = cfg.filter;
backup_pattern = g_strdup (cfg.backup_pattern);
backup_pattern_list = patlist_new (cfg.backup_pattern);
@@ -1487,7 +1487,7 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
confirm_delete = cfg.confirm_delete;
confirm_copy_overwrite = cfg.confirm_copy_overwrite;
confirm_move_overwrite = cfg.confirm_move_overwrite;
- confirm_mouse_dnd = cfg.confirm_mouse_dnd;
+ mouse_dnd_default = cfg.mouse_dnd_default;
filter = cfg.filter;
backup_pattern = g_strdup (cfg.backup_pattern);
backup_pattern_list = patlist_new (cfg.backup_pattern);
@@ -3120,7 +3120,7 @@ void GnomeCmdData::load()
options.confirm_delete_default = (GtkButtonsType) g_settings_get_enum (options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_DELETE_DEFAULT);
options.confirm_copy_overwrite = (GnomeCmdConfirmOverwriteMode) g_settings_get_enum
(options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_COPY_OVERWRITE);
options.confirm_move_overwrite = (GnomeCmdConfirmOverwriteMode) g_settings_get_enum
(options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_MOVE_OVERWRITE);
- options.confirm_mouse_dnd = g_settings_get_boolean (options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP);
+ options.mouse_dnd_default = (GnomeCmdDefaultDndMode) g_settings_get_enum
(options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP);
options.filter.file_types[G_FILE_IS_UNKNOWN] = g_settings_get_boolean (options.gcmd_settings->filter,
GCMD_SETTINGS_FILTER_HIDE_UNKNOWN);
options.filter.file_types[G_FILE_IS_REGULAR] = g_settings_get_boolean (options.gcmd_settings->filter,
GCMD_SETTINGS_FILTER_HIDE_REGULAR);
@@ -3494,7 +3494,7 @@ void GnomeCmdData::save()
set_gsettings_enum_when_changed (options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_DELETE_DEFAULT,
options.confirm_delete_default);
set_gsettings_enum_when_changed (options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_COPY_OVERWRITE,
options.confirm_copy_overwrite);
set_gsettings_enum_when_changed (options.gcmd_settings->confirm, GCMD_SETTINGS_CONFIRM_MOVE_OVERWRITE,
options.confirm_move_overwrite);
- set_gsettings_when_changed (options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP, &(options.confirm_mouse_dnd));
+ set_gsettings_enum_when_changed (options.gcmd_settings->confirm,
GCMD_SETTINGS_CONFIRM_MOUSE_DRAG_AND_DROP, options.mouse_dnd_default);
set_gsettings_when_changed (options.gcmd_settings->filter, GCMD_SETTINGS_FILTER_HIDE_UNKNOWN,
&(options.filter.file_types[G_FILE_IS_UNKNOWN]));
set_gsettings_when_changed (options.gcmd_settings->filter, GCMD_SETTINGS_FILTER_HIDE_REGULAR,
&(options.filter.file_types[G_FILE_IS_REGULAR]));
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 198e09b8..cef02213 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -357,7 +357,7 @@ struct GnomeCmdData
GtkButtonsType confirm_delete_default;
GnomeCmdConfirmOverwriteMode confirm_copy_overwrite;
GnomeCmdConfirmOverwriteMode confirm_move_overwrite;
- gboolean confirm_mouse_dnd;
+ GnomeCmdDefaultDndMode mouse_dnd_default;
// Filters
FilterSettings filter;
gchar *backup_pattern;
@@ -414,7 +414,7 @@ struct GnomeCmdData
confirm_delete_default(GTK_BUTTONS_OK),
confirm_copy_overwrite(GNOME_CMD_CONFIRM_OVERWRITE_QUERY),
confirm_move_overwrite(GNOME_CMD_CONFIRM_OVERWRITE_QUERY),
- confirm_mouse_dnd(TRUE),
+ mouse_dnd_default(GNOME_CMD_DEFAULT_DND_QUERY),
backup_pattern(nullptr),
backup_pattern_list(nullptr),
honor_expect_uris(FALSE),
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 199baa7b..806385d5 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -3129,7 +3129,9 @@ static void free_dnd_popup_data (gpointer *data)
}
-static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData
*selection_data, guint info, guint32 time, GnomeCmdFileList *fl)
+static void drag_data_received (GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, GtkSelectionData *selection_data,
+ guint info, guint32 time, GnomeCmdFileList *fl)
{
GtkCList *clist = *fl;
@@ -3154,19 +3156,30 @@ static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint
gdk_display_get_pointer (gdk_display_get_default (), nullptr, &x, &y, &mask);
- if (gnome_cmd_data.options.confirm_mouse_dnd && !(mask&(GDK_SHIFT_MASK|GDK_CONTROL_MASK)))
+ if (!(mask & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)))
{
- gpointer *arr = g_new (gpointer, 2);
-
- arr[0] = gFileGlist;
- arr[1] = to;
-
- gtk_item_factory_popup_with_data (fl->priv->ifac, arr, (GDestroyNotify) free_dnd_popup_data, x, y,
0, time);
-
+ gpointer *arr = nullptr;
+ switch (gnome_cmd_data.options.mouse_dnd_default)
+ {
+ case GNOME_CMD_DEFAULT_DND_QUERY:
+ arr = g_new (gpointer, 2);
+ arr[0] = gFileGlist;
+ arr[1] = to;
+ gtk_item_factory_popup_with_data (fl->priv->ifac, arr, (GDestroyNotify) free_dnd_popup_data,
x, y, 0, time);
+ break;
+ case GNOME_CMD_DEFAULT_DND_MOVE:
+ fl->drop_files(GnomeCmdFileList::DndMode::MOVE, G_FILE_COPY_NONE, gFileGlist, to);
+ break;
+ case GNOME_CMD_DEFAULT_DND_COPY:
+ fl->drop_files(GnomeCmdFileList::DndMode::COPY, G_FILE_COPY_NONE, gFileGlist, to);
+ break;
+ default:
+ break;
+ }
return;
}
- // find out what operation to perform
+ // find out what operation to perform if Shift or Control was pressed while DnD
#if defined (__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
diff --git a/src/gnome-cmd-types.h b/src/gnome-cmd-types.h
index 81206241..1ad048d3 100644
--- a/src/gnome-cmd-types.h
+++ b/src/gnome-cmd-types.h
@@ -102,6 +102,14 @@ typedef enum // The (reversed) order of following enums compared to the occurenc
}GnomeCmdConfirmOverwriteMode;
+typedef enum
+{
+ GNOME_CMD_DEFAULT_DND_QUERY,
+ GNOME_CMD_DEFAULT_DND_COPY,
+ GNOME_CMD_DEFAULT_DND_MOVE
+}GnomeCmdDefaultDndMode;
+
+
struct GnomeCmdColorTheme
{
gboolean respect_theme {TRUE};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]