[gnome-commander] Menu entry and methods for (un)selecting only files



commit f8727e918b4def016e460a732b5d3c006250aa1d
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Fri Jan 7 19:44:04 2022 +0100

    Menu entry and methods for (un)selecting only files

 NEWS                          |  1 +
 doc/C/releases.xml            |  3 +++
 src/gnome-cmd-file-list.cc    | 36 ++++++++++++++++++++++++++++++++++++
 src/gnome-cmd-file-list.h     |  2 ++
 src/gnome-cmd-main-menu.cc    |  4 ++++
 src/gnome-cmd-user-actions.cc | 14 ++++++++++++++
 src/gnome-cmd-user-actions.h  |  2 ++
 7 files changed, 62 insertions(+)
---
diff --git a/NEWS b/NEWS
index a599b959..f1f163e1 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ gnome-commander 1.14
 
 New features:
  * Selectable default action when drag-n-drop files with the mouse
+ * Menu entry for (un)selecting only files
 
 Bug fixes:
  * Fixed issue #3  (Mounted devices pluged when Commander is running are not noticed)
diff --git a/doc/C/releases.xml b/doc/C/releases.xml
index 108504dc..f840e11f 100644
--- a/doc/C/releases.xml
+++ b/doc/C/releases.xml
@@ -88,6 +88,9 @@
                         <listitem>
                             <para>Selectable default action when drag-n-drop files with the mouse</para>
                         </listitem>
+                        <listitem>
+                            <para>Menu entry for (un)selecting only files</para>
+                        </listitem>
                         <listitem>
                             <para>New or updated translations: ...</para>
                         </listitem>
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index cd102417..744799f2 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -2180,6 +2180,42 @@ GnomeCmdFile *GnomeCmdFileList::get_focused_file()
 }
 
 
+void GnomeCmdFileList::select_all_files()
+{
+    for (auto i = get_visible_files(); i; i = i->next)
+    {
+        auto gnomeCmdFile = static_cast<GnomeCmdFile*> (i->data);
+        if (gnomeCmdFile)
+        {
+               if(GNOME_CMD_IS_DIR(gnomeCmdFile))
+            {
+               unselect_file(gnomeCmdFile);
+            }
+            else
+            {
+               select_file(gnomeCmdFile);
+            }
+        }
+    }
+}
+
+
+void GnomeCmdFileList::unselect_all_files()
+{
+    for (auto i = get_visible_files(); i; i = i->next)
+    {
+        auto gnomeCmdFile = static_cast<GnomeCmdFile*> (i->data);
+        if (gnomeCmdFile)
+        {
+               if(!GNOME_CMD_IS_DIR(gnomeCmdFile))
+            {
+               unselect_file(gnomeCmdFile);
+            }
+        }
+    }
+}
+
+
 void GnomeCmdFileList::select_all()
 {
     priv->selected_files.clear();
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index a521bac3..06ceddfd 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -126,6 +126,8 @@ struct GnomeCmdFileList
     void unselect_file(GnomeCmdFile *f, gint row=-1);
     void select_all();
     void unselect_all();
+    void select_all_files();
+    void unselect_all_files();
 
     void toggle_file(GnomeCmdFile *f);
     void toggle();
diff --git a/src/gnome-cmd-main-menu.cc b/src/gnome-cmd-main-menu.cc
index e1d23b0e..a2029366 100644
--- a/src/gnome-cmd-main-menu.cc
+++ b/src/gnome-cmd-main-menu.cc
@@ -239,6 +239,8 @@ static GtkUIManager *get_file_menu_ui_manager()
     "    <menu action='MarkMenu'>"
     "      <menuitem action='SelectAll'/>"
     "      <menuitem action='UnselectAll'/>"
+    "      <menuitem action='SelectAllFiles'/>"
+    "      <menuitem action='UnSelectAllFiles'/>"
     "      <menuitem action='SelectWPattern'/>"
     "      <menuitem action='UnSelectWPattern'/>"
     "      <menuitem action='SelectWExtension'/>"
@@ -329,6 +331,8 @@ static GtkUIManager *get_file_menu_ui_manager()
         { "MarkMenu",           nullptr,              _("_Mark") },
         { "SelectAll",          GTK_STOCK_SELECT_ALL, _("_Select All"),                   "<Control>KP_Add", 
nullptr, (GCallback) mark_select_all },
         { "UnselectAll",        nullptr,              _("_Unselect All"),                 
"<Control>KP_Subtract", nullptr, (GCallback) mark_unselect_all },
+        { "SelectAllFiles",     nullptr,              _("Select all _Files"),              nullptr, nullptr, 
(GCallback) mark_select_all_files },
+        { "UnSelectAllFiles",   nullptr,              _("Unselect all Fi_les"),            nullptr, nullptr, 
(GCallback) mark_unselect_all_files },
         { "SelectWPattern",     nullptr,              _("Select with _Pattern"),          "KP_Add", nullptr, 
(GCallback) mark_select_with_pattern },
         { "UnSelectWPattern",   nullptr,              _("Unselect with P_attern"),        "KP_Subtract", 
nullptr, (GCallback) mark_unselect_with_pattern },
         { "SelectWExtension",   nullptr,              _("Select with same _Extension"),   nullptr, nullptr, 
(GCallback) mark_select_all_with_same_extension },
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 3db46a4b..cd27a969 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -245,6 +245,8 @@ static UserActionData user_actions_data[] = {
                                              {mark_compare_directories, "mark.compare_directories", 
N_("Compare directories")},
                                              {mark_invert_selection, "mark.invert", N_("Invert selection")},
                                              {mark_select_all, "mark.select_all", N_("Select all")},
+                                             {mark_select_all_files, "mark.select_all_files", N_("Select all 
files")},
+                                             {mark_unselect_all_files, "mark.unselect_all_files", 
N_("Unselect all files")},
                                              {mark_toggle, "mark.toggle", N_("Toggle selection")},
                                              {mark_toggle_and_step, "mark.toggle_and_step", N_("Toggle 
selection and move cursor downward")},
                                              {mark_unselect_all, "mark.unselect_all", N_("Unselect all")},
@@ -1294,6 +1296,18 @@ void mark_select_all (GtkMenuItem *menuitem, gpointer not_used)
 }
 
 
+void mark_select_all_files (GtkMenuItem *menuitem, gpointer not_used)
+{
+    get_fl (ACTIVE)->select_all_files();
+}
+
+
+void mark_unselect_all_files (GtkMenuItem *menuitem, gpointer not_used)
+{
+    get_fl (ACTIVE)->unselect_all_files();
+}
+
+
 void mark_unselect_all (GtkMenuItem *menuitem, gpointer not_used)
 {
     get_fl (ACTIVE)->unselect_all();
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index 36c3c51d..002d6013 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -253,6 +253,8 @@ GNOME_CMD_USER_ACTION(mark_toggle);
 GNOME_CMD_USER_ACTION(mark_toggle_and_step);
 GNOME_CMD_USER_ACTION(mark_select_all);
 GNOME_CMD_USER_ACTION(mark_unselect_all);
+GNOME_CMD_USER_ACTION(mark_select_all_files);
+GNOME_CMD_USER_ACTION(mark_unselect_all_files);
 GNOME_CMD_USER_ACTION(mark_select_with_pattern);
 GNOME_CMD_USER_ACTION(mark_unselect_with_pattern);
 GNOME_CMD_USER_ACTION(mark_invert_selection);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]