Struct gtk::ApplicationWindow
source · [−]#[repr(transparent)]pub struct ApplicationWindow { /* private fields */ }
Expand description
ApplicationWindow
is a Window
subclass that offers some
extra functionality for better integration with Application
features. Notably, it can handle both the application menu as well
as the menubar. See GtkApplicationExt::set_app_menu()
and
GtkApplicationExt::set_menubar()
.
This class implements the gio::ActionGroup
and gio::ActionMap
interfaces,
to let you add window-specific actions that will be exported by the
associated Application
, together with its application-wide
actions. Window-specific actions are prefixed with the “win.”
prefix and application-wide actions are prefixed with the “app.”
prefix. Actions must be addressed with the prefixed name when
referring to them from a gio::MenuModel
.
Note that widgets that are placed inside a ApplicationWindow
can also activate these actions, if they implement the
Actionable
interface.
As with Application
, the GDK lock will be acquired when
processing actions arriving from other processes and should therefore
be held when activating actions locally (if GDK threads are enabled).
The settings property::Settings::gtk-shell-shows-app-menu
and
property::Settings::gtk-shell-shows-menubar
tell GTK+ whether the
desktop environment is showing the application menu and menubar
models outside the application as part of the desktop shell.
For instance, on OS X, both menus will be displayed remotely;
on Windows neither will be. gnome-shell (starting with version 3.4)
will display the application menu, but not the menubar.
If the desktop environment does not display the menubar, then
ApplicationWindow
will automatically show a MenuBar
for it.
This behaviour can be overridden with the property::ApplicationWindow::show-menubar
property. If the desktop environment does not display the application
menu, then it will automatically be included in the menubar or in the
windows client-side decorations.
A GtkApplicationWindow with a menubar
⚠️ The following code is in C ⚠️
GtkApplication *app = gtk_application_new ("org.gtk.test", 0);
GtkBuilder *builder = gtk_builder_new_from_string (
"<interface>"
" <menu id='menubar'>"
" <submenu label='_Edit'>"
" <item label='_Copy' action='win.copy'/>"
" <item label='_Paste' action='win.paste'/>"
" </submenu>"
" </menu>"
"</interface>",
-1);
GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder,
"menubar"));
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
g_object_unref (builder);
// ...
GtkWidget *window = gtk_application_window_new (app);
Handling fallback yourself
The XML format understood by Builder
for gio::MenuModel
consists
of a toplevel <menu>
element, which contains one or more <item>
elements. Each <item>
element contains <attribute>
and <link>
elements with a mandatory name attribute. <link>
elements have the
same content model as <menu>
. Instead of <link name="submenu>
or
<link name="section">
, you can use <submenu>
or <section>
elements.
Attribute values can be translated using gettext, like other Builder
content. <attribute>
elements can be marked for translation with a
translatable="yes"
attribute. It is also possible to specify message
context and translator comments, using the context and comments attributes.
To make use of this, the Builder
must have been given the gettext
domain to use.
The following attributes are used when constructing menu items:
- “label”: a user-visible string to display
- “action”: the prefixed name of the action to trigger
- “target”: the parameter to use when activating the action
- “icon” and “verb-icon”: names of icons that may be displayed
- “submenu-action”: name of an action that may be used to determine if a submenu can be opened
- “hidden-when”: a string used to determine when the item will be hidden. Possible values include “action-disabled”, “action-missing”, “macos-menubar”.
The following attributes are used when constructing sections:
- “label”: a user-visible string to use as section heading
- “display-hint”: a string used to determine special formatting for the section. Possible values include “horizontal-buttons”.
- “text-direction”: a string used to determine the
TextDirection
to use when “display-hint” is set to “horizontal-buttons”. Possible values include “rtl”, “ltr”, and “none”.
The following attributes are used when constructing submenus:
- “label”: a user-visible string to display
- “icon”: icon name to display
Implements
ApplicationWindowExt
, GtkWindowExt
, BinExt
, ContainerExt
, WidgetExt
, glib::ObjectExt
, BuildableExt
, gio::prelude::ActionGroupExt
, gio::prelude::ActionMapExt
, [GtkWindowExtManual
][trait@crate::prelude::GtkWindowExtManual], ContainerExtManual
, WidgetExtManual
, BuildableExtManual
Implementations
sourceimpl ApplicationWindow
impl ApplicationWindow
pub const NONE: Option<&'static ApplicationWindow> = None
sourcepub fn builder() -> ApplicationWindowBuilder
pub fn builder() -> ApplicationWindowBuilder
Creates a new builder-pattern struct instance to construct ApplicationWindow
objects.
This method returns an instance of ApplicationWindowBuilder
which can be used to create ApplicationWindow
objects.
sourceimpl ApplicationWindow
impl ApplicationWindow
pub fn new<P: IsA<Application>>(application: &P) -> ApplicationWindow
Trait Implementations
sourceimpl Clone for ApplicationWindow
impl Clone for ApplicationWindow
sourceimpl Debug for ApplicationWindow
impl Debug for ApplicationWindow
sourceimpl Display for ApplicationWindow
impl Display for ApplicationWindow
sourceimpl Hash for ApplicationWindow
impl Hash for ApplicationWindow
sourceimpl<T: ApplicationWindowImpl> IsSubclassable<T> for ApplicationWindow
impl<T: ApplicationWindowImpl> IsSubclassable<T> for ApplicationWindow
sourcefn class_init(class: &mut Class<Self>)
fn class_init(class: &mut Class<Self>)
sourcefn instance_init(instance: &mut InitializingObject<T>)
fn instance_init(instance: &mut InitializingObject<T>)
sourceimpl Ord for ApplicationWindow
impl Ord for ApplicationWindow
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl ParentClassIs for ApplicationWindow
impl ParentClassIs for ApplicationWindow
sourceimpl<OT: ObjectType> PartialEq<OT> for ApplicationWindow
impl<OT: ObjectType> PartialEq<OT> for ApplicationWindow
sourceimpl<OT: ObjectType> PartialOrd<OT> for ApplicationWindow
impl<OT: ObjectType> PartialOrd<OT> for ApplicationWindow
sourcefn partial_cmp(&self, other: &OT) -> Option<Ordering>
fn partial_cmp(&self, other: &OT) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl StaticType for ApplicationWindow
impl StaticType for ApplicationWindow
sourcefn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for ApplicationWindow
impl IsA<ActionGroup> for ApplicationWindow
impl IsA<ActionMap> for ApplicationWindow
impl IsA<Bin> for ApplicationWindow
impl IsA<Buildable> for ApplicationWindow
impl IsA<Container> for ApplicationWindow
impl IsA<Widget> for ApplicationWindow
impl IsA<Window> for ApplicationWindow
Auto Trait Implementations
impl RefUnwindSafe for ApplicationWindow
impl !Send for ApplicationWindow
impl !Sync for ApplicationWindow
impl Unpin for ApplicationWindow
impl UnwindSafe for ApplicationWindow
Blanket Implementations
sourceimpl<O> ActionGroupExt for Owhere
O: IsA<ActionGroup>,
impl<O> ActionGroupExt for Owhere
O: IsA<ActionGroup>,
fn action_added(&self, action_name: &str)
fn action_enabled_changed(&self, action_name: &str, enabled: bool)
fn action_removed(&self, action_name: &str)
fn action_state_changed(&self, action_name: &str, state: &Variant)
fn activate_action(&self, action_name: &str, parameter: Option<&Variant>)
fn change_action_state(&self, action_name: &str, value: &Variant)
fn is_action_enabled(&self, action_name: &str) -> bool
fn action_parameter_type(&self, action_name: &str) -> Option<VariantType>
fn action_state(&self, action_name: &str) -> Option<Variant>
fn action_state_hint(&self, action_name: &str) -> Option<Variant>
fn action_state_type(&self, action_name: &str) -> Option<VariantType>
fn has_action(&self, action_name: &str) -> bool
fn list_actions(&self) -> Vec<GString, Global>
fn connect_action_added<F>(&self, detail: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&O, &str),
fn connect_action_enabled_changed<F>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&O, &str, bool),
fn connect_action_removed<F>(&self, detail: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&O, &str),
fn connect_action_state_changed<F>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&O, &str, &Variant),
sourceimpl<O> ActionMapExt for Owhere
O: IsA<ActionMap>,
impl<O> ActionMapExt for Owhere
O: IsA<ActionMap>,
fn add_action(&self, action: &impl IsA<Action>)
fn lookup_action(&self, action_name: &str) -> Option<Action>
fn remove_action(&self, action_name: &str)
sourceimpl<O> ActionMapExtManual for Owhere
O: IsA<ActionMap>,
impl<O> ActionMapExtManual for Owhere
O: IsA<ActionMap>,
fn add_action_entries(
&self,
entries: impl IntoIterator<Item = ActionEntry<O>>
) -> Result<(), BoolError>
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere
T: ObjectType,
sourcefn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourcefn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourceunsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
T
unconditionally. Read moresourceunsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
&T
unconditionally. Read moresourceimpl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
sourceimpl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere
T: ObjectType,
sourcefn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere
U: StaticType,
true
if the object is an instance of (can be cast to) T
.sourcefn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moresourcefn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
T
. Read moresourcefn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
T
of the object. Read moresourcefn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
fn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
sourcefn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
sourcefn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
sourcefn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
sourcefn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
fn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
property_name
of the object and cast it to the type V. Read moresourcefn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moresourcefn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moresourcefn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.sourcefn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.sourcefn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
sourceunsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
key
. Read moresourceunsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
key
. Read moresourcefn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
sourcefn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
sourcefn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
sourcefn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
sourcefn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_name
on this object. Read moresourcefn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_id
on this object. Read moresourcefn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourcefn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourceunsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourceunsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourcefn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_name
on this object. Read moresourcefn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_id
on this object. Read moresourcefn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures. Read moresourcefn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.sourcefn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
sourcefn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
sourcefn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
notify
signal of the object. Read moresourcefn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
notify
signal of the object. Read moresourceunsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
notify
signal of the object. Read more