window, image_view: Cleanups

* Move context menu model to image_view.ui
* Remove useless property assignment
This commit is contained in:
Christopher Davis 2021-09-24 06:12:37 -07:00
parent 293dc3c124
commit e41acf0701
3 changed files with 26 additions and 53 deletions

View file

@ -58,6 +58,7 @@
<child>
<object class="GtkPopoverMenu" id="popover">
<property name="has-arrow">False</property>
<property name="menu-model">image_menu</property>
</object>
</child>
</object>
@ -84,4 +85,28 @@
<class name="image-view"/>
</style>
</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>

View file

@ -13,7 +13,6 @@
<property name="modal">false</property>
<property name="flap">
<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"/>
<binding name="opacity">
<lookup type="GtkWidget" name="opacity">
@ -48,9 +47,7 @@
</object>
</child>
<child>
<object class="IvImageView" id="image_view">
<property name="popover-menu-model">image_menu</property>
</object>
<object class="IvImageView" id="image_view"/>
</child>
</object>
</property>
@ -104,28 +101,4 @@
</item>
</section>
</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>

View file

@ -91,13 +91,6 @@ mod imp {
fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
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(
"filename",
"Filename",
@ -140,30 +133,12 @@ mod imp {
fn property(&self, _obj: &Self::Type, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
match psec.name() {
"popover-menu-model" => self.popover_menu_model.borrow().to_value(),
"filename" => self.filename.borrow().to_value(),
"controls" => self.controls.to_value(),
_ => 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) {
self.parent_constructed(obj);