[gnome-commander] Options: make possible to select/deselect files only
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Options: make possible to select/deselect files only
- Date: Sun, 18 Dec 2011 16:11:43 +0000 (UTC)
commit 695d2af0f0c3ed6233cc4b27c2465338719d7b61
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sun Dec 18 17:06:57 2011 +0100
Options: make possible to select/deselect files only
doc/C/gnome-commander.xml | 10 +++++
src/gnome-cmd-data.cc | 4 ++
src/gnome-cmd-data.h | 2 +
src/gnome-cmd-file-list.cc | 77 +++++++++++++++++++++++++++++----------
src/gnome-cmd-options-dialog.cc | 14 +++++++-
5 files changed, 86 insertions(+), 21 deletions(-)
---
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 1ceb03b..46f77fe 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -4082,6 +4082,9 @@
matching system used.</para>
</listitem>
<listitem>
+ <para><guilabel>Selection</guilabel> makes directories selectable also by keyboard shortcuts.</para>
+ </listitem>
+ <listitem>
<para><guilabel>Sorting</guilabel> configures whether sorting is
case sensitive.</para>
</listitem>
@@ -7206,6 +7209,13 @@
</row>
<row valign="top">
<entry><para></para></entry>
+ <entry><para>select_dirs</para></entry>
+ <entry><para>boolean</para></entry>
+ <entry><para></para></entry>
+ <entry><para></para></entry>
+ </row>
+ <row valign="top">
+ <entry><para></para></entry>
<entry><para>show_block_device</para></entry>
<entry><para></para></entry>
<entry><para></para></entry>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 2574e87..61a8fa8 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -70,6 +70,7 @@ GnomeCmdData::Options::Options(const Options &cfg)
left_mouse_button_unselects = cfg.left_mouse_button_unselects;
middle_mouse_button_mode = cfg.middle_mouse_button_mode;
right_mouse_button_mode = cfg.right_mouse_button_mode;
+ select_dirs = cfg.select_dirs;
case_sens_sort = cfg.case_sens_sort;
alt_quick_search = cfg.alt_quick_search;
quick_search_exact_match_begin = cfg.quick_search_exact_match_begin;
@@ -124,6 +125,7 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
left_mouse_button_unselects = cfg.left_mouse_button_unselects;
middle_mouse_button_mode = cfg.middle_mouse_button_mode;
right_mouse_button_mode = cfg.right_mouse_button_mode;
+ select_dirs = cfg.select_dirs;
case_sens_sort = cfg.case_sens_sort;
alt_quick_search = cfg.alt_quick_search;
quick_search_exact_match_begin = cfg.quick_search_exact_match_begin;
@@ -1105,6 +1107,7 @@ void GnomeCmdData::load()
options.filter.hidden = gnome_cmd_data_get_bool ("/options/hidden_filter", TRUE);
options.filter.backup = gnome_cmd_data_get_bool ("/options/backup_filter", TRUE);
+ options.select_dirs = gnome_cmd_data_get_bool ("/sort/select_dirs", TRUE);
options.case_sens_sort = gnome_cmd_data_get_bool ("/sort/case_sensitive", TRUE);
main_win_width = get_int ("/gnome-commander-size/main_win/width", 600);
@@ -1542,6 +1545,7 @@ void GnomeCmdData::save()
gnome_cmd_data_set_bool ("/options/hidden_filter", options.filter.hidden);
gnome_cmd_data_set_bool ("/options/backup_filter", options.filter.backup);
+ gnome_cmd_data_set_bool ("/sort/select_dirs", options.select_dirs);
gnome_cmd_data_set_bool ("/sort/case_sensitive", options.case_sens_sort);
gnome_cmd_data_set_int ("/colors/mode", options.color_mode);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 7ab88bd..bebefb7 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -91,6 +91,7 @@ struct GnomeCmdData
gboolean left_mouse_button_unselects;
MiddleMouseButtonMode middle_mouse_button_mode;
RightMouseButtonMode right_mouse_button_mode;
+ gboolean select_dirs;
gboolean case_sens_sort;
gboolean alt_quick_search;
gboolean quick_search_exact_match_begin;
@@ -143,6 +144,7 @@ struct GnomeCmdData
left_mouse_button_unselects(TRUE),
middle_mouse_button_mode(MIDDLE_BUTTON_GOES_UP_DIR),
right_mouse_button_mode(RIGHT_BUTTON_POPUPS_MENU),
+ select_dirs(TRUE),
case_sens_sort(TRUE),
alt_quick_search(FALSE),
quick_search_exact_match_begin(TRUE),
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 4ea3e6c..17f5c38 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -608,18 +608,32 @@ static void toggle_files_with_same_extension (GnomeCmdFileList *fl, gboolean sel
void GnomeCmdFileList::toggle_with_pattern(Filter &pattern, gboolean mode)
{
- for (GList *i=get_visible_files(); i; i=i->next)
- {
- GnomeCmdFile *f = (GnomeCmdFile *) i->data;
+ if (gnome_cmd_data.options.select_dirs)
+ for (GList *i=get_visible_files(); i; i=i->next)
+ {
+ GnomeCmdFile *f = (GnomeCmdFile *) i->data;
- if (f && f->info && pattern.match(f->info->name))
+ if (f && f->info && pattern.match(f->info->name))
+ {
+ if (mode)
+ select_file(f);
+ else
+ unselect_file(f);
+ }
+ }
+ else
+ for (GList *i=get_visible_files(); i; i=i->next)
{
- if (mode)
- select_file(f);
- else
- unselect_file(f);
+ GnomeCmdFile *f = (GnomeCmdFile *) i->data;
+
+ if (f && !GNOME_CMD_IS_DIR (f) && f->info && pattern.match(f->info->name))
+ {
+ if (mode)
+ select_file(f);
+ else
+ unselect_file(f);
+ }
}
- }
}
@@ -1912,8 +1926,17 @@ void GnomeCmdFileList::select_all()
{
priv->selected_files.clear();
- for (GList *i=get_visible_files(); i; i=i->next)
- select_file((GnomeCmdFile *) i->data);
+ if (gnome_cmd_data.options.select_dirs)
+ for (GList *i=get_visible_files(); i; i=i->next)
+ select_file((GnomeCmdFile *) i->data);
+ else
+ for (GList *i=get_visible_files(); i; i=i->next)
+ {
+ GnomeCmdFile *f = (GnomeCmdFile *) i->data;
+
+ if (!GNOME_CMD_IS_DIR (f))
+ select_file(f);
+ }
}
@@ -1989,18 +2012,32 @@ void GnomeCmdFileList::invert_selection()
{
GnomeCmd::Collection<GnomeCmdFile *> sel = priv->selected_files;
- for (GList *i=get_visible_files(); i; i=i->next)
- {
- GnomeCmdFile *f = (GnomeCmdFile *) i->data;
+ if (gnome_cmd_data.options.select_dirs)
+ for (GList *i=get_visible_files(); i; i=i->next)
+ {
+ GnomeCmdFile *f = (GnomeCmdFile *) i->data;
- if (f && f->info)
+ if (f && f->info)
+ {
+ if (!sel.contain(f))
+ select_file(f);
+ else
+ unselect_file(f);
+ }
+ }
+ else
+ for (GList *i=get_visible_files(); i; i=i->next)
{
- if (!sel.contain(f))
- select_file(f);
- else
- unselect_file(f);
+ GnomeCmdFile *f = (GnomeCmdFile *) i->data;
+
+ if (f && !GNOME_CMD_IS_DIR (f) && f->info)
+ {
+ if (!sel.contain(f))
+ select_file(f);
+ else
+ unselect_file(f);
+ }
}
- }
}
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index e07cc21..963dfd0 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -116,6 +116,16 @@ inline GtkWidget *create_general_tab (GtkWidget *parent, GnomeCmdData::Options &
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ // Selection options
+ cat_box = create_vbox (parent, FALSE, 0);
+ cat = create_category (parent, cat_box, _("Selection"));
+ gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
+
+ check = create_check (parent, _("Select directories"), "select_dirs");
+ gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), cfg.select_dirs);
+
+
// Sort options
cat_box = create_vbox (parent, FALSE, 0);
cat = create_category (parent, cat_box, _("Sorting"));
@@ -186,6 +196,7 @@ inline void store_general_options (GtkWidget *dialog, GnomeCmdData::Options &cfg
GtkWidget *lmb_unselects_check = lookup_widget (dialog, "lmb_unselects_check");
GtkWidget *mmb_cd_up_radio = lookup_widget (dialog, "mmb_cd_up_radio");
GtkWidget *rmb_popup_radio = lookup_widget (dialog, "rmb_popup_radio");
+ GtkWidget *select_dirs = lookup_widget (dialog, "select_dirs");
GtkWidget *case_sens_check = lookup_widget (dialog, "case_sens_check");
GtkWidget *alt_quick_search = lookup_widget (dialog, "alt_quick_search");
GtkWidget *multiple_instance_check = lookup_widget (dialog, "multiple_instance_check");
@@ -205,6 +216,7 @@ inline void store_general_options (GtkWidget *dialog, GnomeCmdData::Options &cfg
cfg.right_mouse_button_mode = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rmb_popup_radio)) ? GnomeCmdData::RIGHT_BUTTON_POPUPS_MENU
: GnomeCmdData::RIGHT_BUTTON_SELECTS;
+ cfg.select_dirs = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (select_dirs));
cfg.case_sens_sort = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (case_sens_check));
cfg.alt_quick_search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (alt_quick_search));
cfg.allow_multiple_instances = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (multiple_instance_check));
@@ -1584,7 +1596,7 @@ inline void store_programs_options (GtkWidget *dialog, GnomeCmdData::Options &cf
cfg.set_editor(gtk_entry_get_text (GTK_ENTRY (entry2)));
cfg.set_differ(gtk_entry_get_text (GTK_ENTRY (entry3)));
cfg.set_term(gtk_entry_get_text (GTK_ENTRY (entry5)));
-
+
cfg.honor_expect_uris = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_uris));
cfg.use_internal_viewer = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_iv));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]