Add manual excluding directories (#168)
This commit is contained in:
parent
97f7c8370d
commit
a8c0a80bcf
|
@ -444,6 +444,7 @@ Author: Rafał Mikrut
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_start">5</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">1</property>
|
<property name="spacing">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -662,9 +663,9 @@ Author: Rafał Mikrut
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_start">5</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">1</property>
|
<property name="spacing">1</property>
|
||||||
<property name="homogeneous">True</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="buttons_add_excluded_directory">
|
<object class="GtkButton" id="buttons_add_excluded_directory">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -697,7 +698,7 @@ Author: Rafał Mikrut
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">Add</property>
|
<property name="label" translatable="yes">Add </property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -748,7 +749,7 @@ Author: Rafał Mikrut
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">Remove</property>
|
<property name="label" translatable="yes">Remove </property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -767,6 +768,57 @@ Author: Rafał Mikrut
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="buttons_manual_add_excluded_directory">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkAlignment">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xscale">0</property>
|
||||||
|
<property name="yscale">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="spacing">4</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">insert-link</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Manual Add</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|
|
@ -46,6 +46,50 @@ pub fn connect_selection_of_directories(gui_data: &GuiData) {
|
||||||
dialog_manual_add_directory.close();
|
dialog_manual_add_directory.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Add manually excluded directory
|
||||||
|
{
|
||||||
|
let scrolled_window_excluded_directories = gui_data.scrolled_window_excluded_directories.clone();
|
||||||
|
let window_main = gui_data.window_main.clone();
|
||||||
|
let buttons_manual_add_excluded_directory = gui_data.buttons_manual_add_excluded_directory.clone();
|
||||||
|
buttons_manual_add_excluded_directory.connect_clicked(move |_| {
|
||||||
|
let dialog_manual_add_directory = gtk::Dialog::with_buttons(
|
||||||
|
Some("Add excluded directory manually"),
|
||||||
|
Some(&window_main),
|
||||||
|
gtk::DialogFlags::MODAL,
|
||||||
|
&[("Ok", gtk::ResponseType::Ok), ("Close", gtk::ResponseType::Cancel)],
|
||||||
|
);
|
||||||
|
let entry: gtk::Entry = gtk::Entry::new();
|
||||||
|
|
||||||
|
for widgets in dialog_manual_add_directory.get_children() {
|
||||||
|
// By default GtkBox is child of dialog, so we can easily add other things to it
|
||||||
|
widgets.clone().downcast::<gtk::Box>().unwrap().add(&entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog_manual_add_directory.show_all();
|
||||||
|
|
||||||
|
let response_type = dialog_manual_add_directory.run();
|
||||||
|
if response_type == gtk::ResponseType::Ok {
|
||||||
|
let text = entry.get_text().to_string().trim().to_string();
|
||||||
|
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
|
let text = Common::normalize_windows_path(text).to_string_lossy().to_string();
|
||||||
|
|
||||||
|
if !text.is_empty() {
|
||||||
|
let tree_view = scrolled_window_excluded_directories.get_children().get(0).unwrap().clone().downcast::<gtk::TreeView>().unwrap();
|
||||||
|
let list_store = tree_view.get_model().unwrap().downcast::<gtk::ListStore>().unwrap();
|
||||||
|
|
||||||
|
let col_indices = [0];
|
||||||
|
|
||||||
|
let values: [&dyn ToValue; 1] = [&text];
|
||||||
|
list_store.set(&list_store.append(), &col_indices, &values);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dialog_manual_add_directory.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog_manual_add_directory.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
// Add included directory
|
// Add included directory
|
||||||
{
|
{
|
||||||
let scrolled_window_included_directories = gui_data.scrolled_window_included_directories.clone();
|
let scrolled_window_included_directories = gui_data.scrolled_window_included_directories.clone();
|
||||||
|
|
|
@ -67,6 +67,7 @@ pub struct GuiData {
|
||||||
pub buttons_manual_add_directory: gtk::Button,
|
pub buttons_manual_add_directory: gtk::Button,
|
||||||
pub buttons_add_included_directory: gtk::Button,
|
pub buttons_add_included_directory: gtk::Button,
|
||||||
pub buttons_remove_included_directory: gtk::Button,
|
pub buttons_remove_included_directory: gtk::Button,
|
||||||
|
pub buttons_manual_add_excluded_directory: gtk::Button,
|
||||||
pub buttons_add_excluded_directory: gtk::Button,
|
pub buttons_add_excluded_directory: gtk::Button,
|
||||||
pub buttons_remove_excluded_directory: gtk::Button,
|
pub buttons_remove_excluded_directory: gtk::Button,
|
||||||
|
|
||||||
|
@ -281,6 +282,7 @@ impl GuiData {
|
||||||
let buttons_manual_add_directory: gtk::Button = builder.get_object("buttons_manual_add_directory").unwrap();
|
let buttons_manual_add_directory: gtk::Button = builder.get_object("buttons_manual_add_directory").unwrap();
|
||||||
let buttons_add_included_directory: gtk::Button = builder.get_object("buttons_add_included_directory").unwrap();
|
let buttons_add_included_directory: gtk::Button = builder.get_object("buttons_add_included_directory").unwrap();
|
||||||
let buttons_remove_included_directory: gtk::Button = builder.get_object("buttons_remove_included_directory").unwrap();
|
let buttons_remove_included_directory: gtk::Button = builder.get_object("buttons_remove_included_directory").unwrap();
|
||||||
|
let buttons_manual_add_excluded_directory: gtk::Button = builder.get_object("buttons_manual_add_excluded_directory").unwrap();
|
||||||
let buttons_add_excluded_directory: gtk::Button = builder.get_object("buttons_add_excluded_directory").unwrap();
|
let buttons_add_excluded_directory: gtk::Button = builder.get_object("buttons_add_excluded_directory").unwrap();
|
||||||
let buttons_remove_excluded_directory: gtk::Button = builder.get_object("buttons_remove_excluded_directory").unwrap();
|
let buttons_remove_excluded_directory: gtk::Button = builder.get_object("buttons_remove_excluded_directory").unwrap();
|
||||||
|
|
||||||
|
@ -434,6 +436,7 @@ impl GuiData {
|
||||||
buttons_manual_add_directory,
|
buttons_manual_add_directory,
|
||||||
buttons_add_included_directory,
|
buttons_add_included_directory,
|
||||||
buttons_remove_included_directory,
|
buttons_remove_included_directory,
|
||||||
|
buttons_manual_add_excluded_directory,
|
||||||
buttons_add_excluded_directory,
|
buttons_add_excluded_directory,
|
||||||
buttons_remove_excluded_directory,
|
buttons_remove_excluded_directory,
|
||||||
buttons_popover_select_all,
|
buttons_popover_select_all,
|
||||||
|
|
Loading…
Reference in a new issue