parent
c2bffbc686
commit
c3410943b8
2 changed files with 21 additions and 20 deletions
|
|
@ -125,26 +125,8 @@ mod imp {
|
|||
}
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
// bind_template() is a function generated by the
|
||||
// CompositeTemplate macro to bind all children at once.
|
||||
Self::bind_template(klass);
|
||||
|
||||
klass.add_binding(gdk::Key::c, gdk::ModifierType::CONTROL_MASK, |window| {
|
||||
if window.has_metadata_selected() {
|
||||
// Pass on to normal copy handler to copy selected metadata
|
||||
glib::Propagation::Proceed
|
||||
} else {
|
||||
window.copy_image();
|
||||
glib::Propagation::Stop
|
||||
}
|
||||
});
|
||||
|
||||
klass.add_binding_action(
|
||||
gdk::Key::question,
|
||||
gdk::ModifierType::CONTROL_MASK,
|
||||
"app.shortcuts",
|
||||
);
|
||||
|
||||
// Set up actions
|
||||
Action::init_actions(klass);
|
||||
}
|
||||
|
|
@ -607,7 +589,7 @@ impl LpImageWindow {
|
|||
}
|
||||
|
||||
/// Returns true if some text in metadata is currently selected
|
||||
fn has_metadata_selected(&self) -> bool {
|
||||
pub fn has_metadata_selected(&self) -> bool {
|
||||
let Some(window) = self.try_window() else {
|
||||
return false;
|
||||
};
|
||||
|
|
@ -623,7 +605,7 @@ impl LpImageWindow {
|
|||
}
|
||||
|
||||
/// Copy image to clipboard or metadata text if selected
|
||||
fn copy_image(&self) {
|
||||
pub fn copy_image(&self) {
|
||||
let imp = self.imp();
|
||||
|
||||
if let Err(e) = imp.image_view.copy() {
|
||||
|
|
|
|||
|
|
@ -88,6 +88,25 @@ mod imp {
|
|||
WindowAction::init_actions_and_bindings(klass);
|
||||
|
||||
ActionPartGlobal::init_actions_and_bindings(klass);
|
||||
|
||||
// Don't use an action since we want to control propagation
|
||||
klass.add_binding(gdk::Key::c, gdk::ModifierType::CONTROL_MASK, |window| {
|
||||
let image_window = window.image_window();
|
||||
if image_window.has_metadata_selected() {
|
||||
// Pass on to normal copy handler to copy selected metadata
|
||||
glib::Propagation::Proceed
|
||||
} else {
|
||||
image_window.copy_image();
|
||||
glib::Propagation::Stop
|
||||
}
|
||||
});
|
||||
|
||||
// Only add shortcut since action is created by libadwaita
|
||||
klass.add_binding_action(
|
||||
gdk::Key::question,
|
||||
gdk::ModifierType::CONTROL_MASK,
|
||||
"app.shortcuts",
|
||||
);
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue