window, image_view: Cleanups
* Move context menu model to image_view.ui * Remove useless property assignment
This commit is contained in:
parent
293dc3c124
commit
e41acf0701
3 changed files with 26 additions and 53 deletions
|
|
@ -58,6 +58,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPopoverMenu" id="popover">
|
<object class="GtkPopoverMenu" id="popover">
|
||||||
<property name="has-arrow">False</property>
|
<property name="has-arrow">False</property>
|
||||||
|
<property name="menu-model">image_menu</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -84,4 +85,28 @@
|
||||||
<class name="image-view"/>
|
<class name="image-view"/>
|
||||||
</style>
|
</style>
|
||||||
</template>
|
</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">_Rotate</attribute>
|
||||||
|
<attribute name="action">win.rotate-image</attribute>
|
||||||
|
</item>-->
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">_Set As Wallpaper</attribute>
|
||||||
|
<attribute name="action">win.set-wallpaper</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
<property name="modal">false</property>
|
<property name="modal">false</property>
|
||||||
<property name="flap">
|
<property name="flap">
|
||||||
<object class="GtkHeaderBar" id="headerbar">
|
<object class="GtkHeaderBar" id="headerbar">
|
||||||
<property name="css-classes">titlebar</property>
|
|
||||||
<property name="show_title_buttons" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create|invert-boolean"/>
|
<property name="show_title_buttons" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create|invert-boolean"/>
|
||||||
<binding name="opacity">
|
<binding name="opacity">
|
||||||
<lookup type="GtkWidget" name="opacity">
|
<lookup type="GtkWidget" name="opacity">
|
||||||
|
|
@ -48,9 +47,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="IvImageView" id="image_view">
|
<object class="IvImageView" id="image_view"/>
|
||||||
<property name="popover-menu-model">image_menu</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -104,28 +101,4 @@
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
<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">_Rotate</attribute>
|
|
||||||
<attribute name="action">win.rotate-image</attribute>
|
|
||||||
</item>-->
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">_Set As Wallpaper</attribute>
|
|
||||||
<attribute name="action">win.set-wallpaper</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</menu>
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,6 @@ mod imp {
|
||||||
fn properties() -> &'static [glib::ParamSpec] {
|
fn properties() -> &'static [glib::ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
glib::ParamSpec::new_object(
|
|
||||||
"popover-menu-model",
|
|
||||||
"Popover Menu Model",
|
|
||||||
"The menu model for the menu button",
|
|
||||||
gio::MenuModel::static_type(),
|
|
||||||
glib::ParamFlags::READWRITE,
|
|
||||||
),
|
|
||||||
glib::ParamSpec::new_string(
|
glib::ParamSpec::new_string(
|
||||||
"filename",
|
"filename",
|
||||||
"Filename",
|
"Filename",
|
||||||
|
|
@ -140,30 +133,12 @@ mod imp {
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
|
||||||
match psec.name() {
|
match psec.name() {
|
||||||
"popover-menu-model" => self.popover_menu_model.borrow().to_value(),
|
|
||||||
"filename" => self.filename.borrow().to_value(),
|
"filename" => self.filename.borrow().to_value(),
|
||||||
"controls" => self.controls.to_value(),
|
"controls" => self.controls.to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
psec: &glib::ParamSpec,
|
|
||||||
) {
|
|
||||||
match psec.name() {
|
|
||||||
"popover-menu-model" => {
|
|
||||||
let model: Option<gio::MenuModel> = value.get().unwrap();
|
|
||||||
self.popover.set_menu_model(model.as_ref());
|
|
||||||
*self.popover_menu_model.borrow_mut() = model;
|
|
||||||
}
|
|
||||||
_ => unimplemented!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn constructed(&self, obj: &Self::Type) {
|
fn constructed(&self, obj: &Self::Type) {
|
||||||
self.parent_constructed(obj);
|
self.parent_constructed(obj);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue