menus: Add rotate left and right buttons
This commit is contained in:
parent
57f573f98a
commit
c2e3bb2f83
5 changed files with 153 additions and 85 deletions
|
|
@ -1,5 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="image_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open With…</attribute>
|
||||
<attribute name="action">win.open-with</attribute>
|
||||
</item>
|
||||
<!--<item>
|
||||
<attribute name="label" translatable="yes">_Display On…</attribute>
|
||||
<attribute name="action">win.display-on</attribute>
|
||||
</item>-->
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Print…</attribute>
|
||||
<attribute name="action">win.print</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Copy</attribute>
|
||||
<attribute name="action">win.copy</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<attribute name="label" translatable="yes">Rotate</attribute>
|
||||
<attribute name="display-hint">inline-buttons</attribute>
|
||||
<item>
|
||||
<attribute name="custom">rotate-left</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="custom">rotate-right</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Set as Background…</attribute>
|
||||
<attribute name="action">win.set-background</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<template class="LpImagePage" parent="AdwBin">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
|
|
@ -36,6 +72,28 @@
|
|||
<object class="GtkPopoverMenu" id="popover">
|
||||
<property name="has-arrow">False</property>
|
||||
<property name="menu-model">image_menu</property>
|
||||
<child type="rotate-left">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">object-rotate-left-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Rotate Left</property>
|
||||
<property name="action-name">win.rotate</property>
|
||||
<property name="action-target">-90.0</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child type="rotate-right">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">object-rotate-right-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Rotate Right</property>
|
||||
<property name="action-name">win.rotate</property>
|
||||
<property name="action-target">90.0</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -43,32 +101,4 @@
|
|||
</object>
|
||||
</property>
|
||||
</template>
|
||||
<menu id="image_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open With…</attribute>
|
||||
<attribute name="action">win.open-with</attribute>
|
||||
</item>
|
||||
<!--<item>
|
||||
<attribute name="label" translatable="yes">_Display On…</attribute>
|
||||
<attribute name="action">win.display-on</attribute>
|
||||
</item>-->
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Print…</attribute>
|
||||
<attribute name="action">win.print</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Copy</attribute>
|
||||
<attribute name="action">win.copy</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Rotate</attribute>
|
||||
<attribute name="action">win.rotate-image</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Set as Background…</attribute>
|
||||
<attribute name="action">win.set-background</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="primary_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New Window</attribute>
|
||||
<attribute name="action">app.new-window</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open…</attribute>
|
||||
<attribute name="action">win.open</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open With…</attribute>
|
||||
<attribute name="action">win.open-with</attribute>
|
||||
</item>
|
||||
<!--<item>
|
||||
<attribute name="label" translatable="yes">_Display On…</attribute>
|
||||
<attribute name="action">win.display-on</attribute>
|
||||
</item>-->
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Print…</attribute>
|
||||
<attribute name="action">win.print</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<attribute name="label" translatable="yes">Rotate</attribute>
|
||||
<attribute name="display-hint">inline-buttons</attribute>
|
||||
<item>
|
||||
<attribute name="custom">rotate-left</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="custom">rotate-right</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Set as Background…</attribute>
|
||||
<attribute name="action">win.set-background</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Help</attribute>
|
||||
<attribute name="action">app.help</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About Image Viewer</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<template class="LpWindow" parent="AdwApplicationWindow">
|
||||
<property name="default-width">600</property>
|
||||
<property name="default-height">498</property>
|
||||
|
|
@ -37,8 +93,34 @@
|
|||
<child type="end">
|
||||
<object class="GtkMenuButton" id="menu_button">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="menu-model">primary_menu</property>
|
||||
<property name="tooltip-text" translatable="yes">Primary Menu</property>
|
||||
<property name="popover">
|
||||
<object class="GtkPopoverMenu">
|
||||
<property name="menu-model">primary_menu</property>
|
||||
<child type="rotate-left">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">object-rotate-left-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Rotate Left</property>
|
||||
<property name="action-name">win.rotate</property>
|
||||
<property name="action-target">-90.0</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child type="rotate-right">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">object-rotate-right-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Rotate Right</property>
|
||||
<property name="action-name">win.rotate</property>
|
||||
<property name="action-target">90.0</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
|
|
@ -105,52 +187,4 @@
|
|||
</object>
|
||||
</property>
|
||||
</template>
|
||||
<menu id="primary_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New Window</attribute>
|
||||
<attribute name="action">app.new-window</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open…</attribute>
|
||||
<attribute name="action">win.open</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open With…</attribute>
|
||||
<attribute name="action">win.open-with</attribute>
|
||||
</item>
|
||||
<!--<item>
|
||||
<attribute name="label" translatable="yes">_Display On…</attribute>
|
||||
<attribute name="action">win.display-on</attribute>
|
||||
</item>-->
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Print…</attribute>
|
||||
<attribute name="action">win.print</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Rotate</attribute>
|
||||
<attribute name="action">win.rotate-image</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Set as Background…</attribute>
|
||||
<attribute name="action">win.set-background</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Help</attribute>
|
||||
<attribute name="action">app.help</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About Image Viewer</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ mod imp {
|
|||
|
||||
fn dispose(&self) {
|
||||
let obj = self.instance();
|
||||
|
||||
self.rotation_animation.replace(None);
|
||||
|
||||
while let Some(child) = obj.first_child() {
|
||||
child.unparent();
|
||||
}
|
||||
|
|
@ -257,9 +260,9 @@ impl LpImage {
|
|||
gdk::ContentProvider::new_union(contents.as_slice())
|
||||
}
|
||||
|
||||
pub fn rotate(&self) {
|
||||
pub fn rotate(&self, angle: f64) {
|
||||
let target = &self.imp().rotation_target;
|
||||
target.set(target.get() + 90.);
|
||||
target.set(target.get() + angle);
|
||||
|
||||
let borrow = self.imp().rotation_animation.borrow();
|
||||
let animation = borrow.as_ref().unwrap();
|
||||
|
|
|
|||
|
|
@ -385,9 +385,9 @@ impl LpImageView {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rotate_image(&self) {
|
||||
pub fn rotate_image(&self, angle: f64) {
|
||||
if let Some(current_page) = self.current_page() {
|
||||
current_page.image().rotate();
|
||||
current_page.image().rotate(angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ mod imp {
|
|||
win.open_with();
|
||||
});
|
||||
|
||||
klass.install_action("win.rotate-image", None, move |win, _, _| {
|
||||
win.rotate_image();
|
||||
klass.install_action("win.rotate", Some("d"), move |win, _, angle| {
|
||||
win.rotate_image(angle.unwrap().get().unwrap());
|
||||
});
|
||||
|
||||
klass.install_action("win.set-background", None, move |win, _, _| {
|
||||
|
|
@ -290,8 +290,8 @@ impl LpWindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn rotate_image(&self) {
|
||||
self.imp().image_view.rotate_image()
|
||||
fn rotate_image(&self, angle: f64) {
|
||||
self.imp().image_view.rotate_image(angle)
|
||||
}
|
||||
|
||||
fn set_background(&self) {
|
||||
|
|
@ -352,6 +352,7 @@ impl LpWindow {
|
|||
self.action_set_enabled("win.set-background", enabled);
|
||||
self.action_set_enabled("win.toggle-fullscreen", enabled);
|
||||
self.action_set_enabled("win.print", enabled);
|
||||
self.action_set_enabled("win.rotate", enabled);
|
||||
self.action_set_enabled("win.copy", enabled);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue