AdwViewSwitcherBar

AdwViewSwitcherBar — A view switcher action bar.

Functions

Properties

AdwViewSwitcherPolicy policy Read / Write
gboolean reveal Read / Write
GtkStack * stack Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── AdwViewSwitcherBar

Implemented Interfaces

AdwViewSwitcherBar implements GtkAccessible, GtkBuildable and GtkConstraintTarget.

Description

An action bar letting you switch between multiple views offered by a GtkStack, via an AdwViewSwitcher. It is designed to be put at the bottom of a window and to be revealed only on really narrow windows e.g. on mobile phones. It can't be revealed if there are less than two pages.

You can conveniently bind the “reveal” property to “title-visible” to automatically reveal the view switcher bar when the title label is displayed in place of the view switcher.

An example of the UI definition for a common use case:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<object class="GtkWindow"/>
  <child type="titlebar">
    <object class="AdwHeaderBar">
      <property name="centering-policy">strict</property>
      <child type="title">
        <object class="AdwViewSwitcherTitle"
                id="view_switcher_title">
          <property name="stack">stack</property>
        </object>
      </child>
    </object>
  </child>
  <child>
    <object class="GtkBox">
      <child>
        <object class="GtkStack" id="stack"/>
      </child>
      <child>
        <object class="AdwViewSwitcherBar">
          <property name="stack">stack</property>
          <property name="reveal"
                    bind-source="view_switcher_title"
                    bind-property="title-visible"
                    bind-flags="sync-create"/>
        </object>
      </child>
    </object>
  </child>
</object>

CSS nodes

AdwViewSwitcherBar has a single CSS node with name viewswitcherbar.

Functions

adw_view_switcher_bar_new ()

GtkWidget *
adw_view_switcher_bar_new (void);

Creates a new AdwViewSwitcherBar widget.

Returns

a new AdwViewSwitcherBar

Since: 1.0


adw_view_switcher_bar_get_policy ()

AdwViewSwitcherPolicy
adw_view_switcher_bar_get_policy (AdwViewSwitcherBar *self);

Gets the policy of self .

Parameters

self

a AdwViewSwitcherBar

 

Returns

the policy of self

Since: 1.0


adw_view_switcher_bar_set_policy ()

void
adw_view_switcher_bar_set_policy (AdwViewSwitcherBar *self,
                                  AdwViewSwitcherPolicy policy);

Sets the policy of self .

Parameters

self

a AdwViewSwitcherBar

 

policy

the new policy

 

Since: 1.0


adw_view_switcher_bar_get_stack ()

GtkStack *
adw_view_switcher_bar_get_stack (AdwViewSwitcherBar *self);

Get the GtkStack being controlled by the AdwViewSwitcher.

Parameters

self

a AdwViewSwitcherBar

 

Returns

the GtkStack, or NULL if none has been set.

[nullable][transfer none]

Since: 1.0


adw_view_switcher_bar_set_stack ()

void
adw_view_switcher_bar_set_stack (AdwViewSwitcherBar *self,
                                 GtkStack *stack);

Sets the GtkStack to control.

Parameters

self

a AdwViewSwitcherBar

 

stack

a GtkStack.

[nullable]

Since: 1.0


adw_view_switcher_bar_get_reveal ()

gboolean
adw_view_switcher_bar_get_reveal (AdwViewSwitcherBar *self);

Gets whether self should be revealed or not.

Parameters

self

a AdwViewSwitcherBar

 

Returns

TRUE if self is revealed, FALSE if not.

Since: 1.0


adw_view_switcher_bar_set_reveal ()

void
adw_view_switcher_bar_set_reveal (AdwViewSwitcherBar *self,
                                  gboolean reveal);

Sets whether self should be revealed or not.

Parameters

self

a AdwViewSwitcherBar

 

reveal

TRUE to reveal self

 

Since: 1.0

Types and Values

ADW_TYPE_VIEW_SWITCHER_BAR

#define ADW_TYPE_VIEW_SWITCHER_BAR (adw_view_switcher_bar_get_type())

AdwViewSwitcherBar

typedef struct _AdwViewSwitcherBar AdwViewSwitcherBar;

Property Details

The “policy” property

  “policy”                   AdwViewSwitcherPolicy

The AdwViewSwitcherPolicy the AdwViewSwitcher should use to determine which mode to use.

Owner: AdwViewSwitcherBar

Flags: Read / Write

Default value: ADW_VIEW_SWITCHER_POLICY_NARROW

Since: 1.0


The “reveal” property

  “reveal”                   gboolean

Whether the bar should be revealed or hidden.

Owner: AdwViewSwitcherBar

Flags: Read / Write

Default value: FALSE

Since: 1.0


The “stack” property

  “stack”                    GtkStack *

The GtkStack the AdwViewSwitcher controls.

Owner: AdwViewSwitcherBar

Flags: Read / Write

Since: 1.0

See Also

AdwViewSwitcher, AdwViewSwitcherTitle