We can select file by pressing "space" in treeview. (#415)
This commit is contained in:
parent
33d6e73516
commit
73fdc1dffd
|
@ -1,6 +1,9 @@
|
||||||
use crate::help_functions::*;
|
use crate::help_functions::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
const KEY_ENTER: u16 = 36;
|
||||||
|
const KEY_SPACE: u16 = 65;
|
||||||
|
|
||||||
// TODO add option to open files and folders from context menu activated by pressing ONCE with right mouse button
|
// TODO add option to open files and folders from context menu activated by pressing ONCE with right mouse button
|
||||||
|
|
||||||
pub fn opening_double_click_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -12,10 +15,7 @@ pub fn opening_double_click_function_duplicates(tree_view: >k::TreeView, event
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsDuplicates::Name as u32, ColumnsDuplicates::Path as u32, ColumnsDuplicates::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsDuplicates::Name as i32, ColumnsDuplicates::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -27,11 +27,9 @@ pub fn opening_double_click_function_empty_folders(tree_view: >k::TreeView, ev
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsEmptyFolders::Name as u32, ColumnsEmptyFolders::Path as u32, ColumnsEmptyFolders::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsEmptyFolders::Name as i32, ColumnsEmptyFolders::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||||
common_open_function(tree_view, ColumnsEmptyFiles::Name as i32, ColumnsEmptyFiles::Path as i32, OpenMode::PathAndName);
|
common_open_function(tree_view, ColumnsEmptyFiles::Name as i32, ColumnsEmptyFiles::Path as i32, OpenMode::PathAndName);
|
||||||
|
@ -41,10 +39,7 @@ pub fn opening_double_click_function_empty_files(tree_view: >k::TreeView, even
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsEmptyFiles::Name as u32, ColumnsEmptyFiles::Path as u32, ColumnsEmptyFiles::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsEmptyFiles::Name as i32, ColumnsEmptyFiles::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -56,10 +51,7 @@ pub fn opening_double_click_function_temporary_files(tree_view: >k::TreeView,
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsTemporaryFiles::Name as u32, ColumnsTemporaryFiles::Path as u32, ColumnsTemporaryFiles::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsTemporaryFiles::Name as i32, ColumnsTemporaryFiles::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_big_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_big_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -71,10 +63,7 @@ pub fn opening_double_click_function_big_files(tree_view: >k::TreeView, event:
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_big_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_big_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsBigFiles::Name as u32, ColumnsBigFiles::Path as u32, ColumnsBigFiles::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsBigFiles::Name as i32, ColumnsBigFiles::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_zeroed_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_zeroed_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -86,10 +75,7 @@ pub fn opening_double_click_function_zeroed_files(tree_view: >k::TreeView, eve
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_zeroed_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_zeroed_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsZeroedFiles::Name as u32, ColumnsZeroedFiles::Path as u32, ColumnsZeroedFiles::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsZeroedFiles::Name as i32, ColumnsZeroedFiles::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_same_music(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_same_music(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -101,10 +87,7 @@ pub fn opening_double_click_function_same_music(tree_view: >k::TreeView, event
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_same_music(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_same_music(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsSameMusic::Name as u32, ColumnsSameMusic::Path as u32, ColumnsSameMusic::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsSameMusic::Name as i32, ColumnsSameMusic::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -115,11 +98,9 @@ pub fn opening_double_click_function_similar_images(tree_view: >k::TreeView, e
|
||||||
}
|
}
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_enter_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsSimilarImages::Name as u32, ColumnsSimilarImages::Path as u32, ColumnsSimilarImages::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsSimilarImages::Name as i32, ColumnsSimilarImages::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -131,10 +112,7 @@ pub fn opening_double_click_function_invalid_symlinks(tree_view: >k::TreeView,
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsInvalidSymlinks::Name as u32, ColumnsInvalidSymlinks::Path as u32, ColumnsInvalidSymlinks::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsInvalidSymlinks::Name as i32, ColumnsInvalidSymlinks::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opening_double_click_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
pub fn opening_double_click_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||||
|
@ -146,18 +124,27 @@ pub fn opening_double_click_function_broken_files(tree_view: >k::TreeView, eve
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
}
|
}
|
||||||
pub fn opening_enter_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
pub fn opening_enter_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||||
if event.keycode() == Some(36) {
|
handle_tree_keypress(tree_view, event, ColumnsBrokenFiles::Name as u32, ColumnsBrokenFiles::Path as u32, ColumnsBrokenFiles::ActiveSelectButton as u32)
|
||||||
common_open_function(tree_view, ColumnsBrokenFiles::Name as i32, ColumnsBrokenFiles::Path as i32, OpenMode::PathAndName);
|
|
||||||
}
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum OpenMode {
|
enum OpenMode {
|
||||||
OnlyPath,
|
OnlyPath,
|
||||||
PathAndName,
|
PathAndName,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn common_open_function(tree_view: >k::TreeView, column_name: i32, column_path: i32, opening_mode: OpenMode) {
|
fn common_mark_function(tree_view: >k::TreeView, column_name: u32) {
|
||||||
|
let selection = tree_view.selection();
|
||||||
|
let (selection_rows, tree_model) = selection.selected_rows();
|
||||||
|
|
||||||
|
let model = get_list_store(tree_view);
|
||||||
|
|
||||||
|
for tree_path in selection_rows.iter().rev() {
|
||||||
|
let value = !tree_model.value(&tree_model.iter(tree_path).unwrap(), column_name as i32).get::<bool>().unwrap();
|
||||||
|
model.set_value(&tree_model.iter(tree_path).unwrap(), column_name, &value.to_value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn common_open_function(tree_view: >k::TreeView, column_name: i32, column_path: i32, opening_mode: OpenMode) {
|
||||||
let selection = tree_view.selection();
|
let selection = tree_view.selection();
|
||||||
let (selection_rows, tree_model) = selection.selected_rows();
|
let (selection_rows, tree_model) = selection.selected_rows();
|
||||||
|
|
||||||
|
@ -180,3 +167,18 @@ pub fn common_open_function(tree_view: >k::TreeView, column_name: i32, column_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_tree_keypress(tree_view: >k::TreeView, event: &gdk::EventKey, name_column: u32, path_column: u32, mark_column: u32) -> gtk::Inhibit {
|
||||||
|
match event.keycode() {
|
||||||
|
Some(KEY_ENTER) => {
|
||||||
|
// Enter
|
||||||
|
common_open_function(tree_view, name_column as i32, path_column as i32, OpenMode::PathAndName);
|
||||||
|
}
|
||||||
|
Some(KEY_SPACE) => {
|
||||||
|
// Space
|
||||||
|
common_mark_function(tree_view, mark_column);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
gtk::Inhibit(false)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue