HdyViewSwitcherTitle

HdyViewSwitcherTitle — A view switcher title.

Functions

Properties

gboolean has-subtitle Read / Write
gint icon-size Read / Write
HdyViewSwitcherPolicy policy Read / Write
GtkStack * stack Read / Write
gchar * subtitle Read / Write
gchar * title Read / Write
gboolean title-visible Read
gboolean view-switcher-enabled Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── GtkBin
                    ╰── HdyViewSwitcherTitle

Implemented Interfaces

HdyViewSwitcherTitle implements AtkImplementorIface and GtkBuildable.

Description

A widget letting you switch between multiple views offered by a GtkStack, via an HdyViewSwitcher. It is designed to be used as the title widget of a HdyHeaderBar, and will display the window's title when the window is too narrow to fit the view switcher e.g. on mobile phones, or if there are less than two views.

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="HdyHeaderBar">
      <property name="centering-policy">strict</property>
      <child type="title">
        <object class="HdyViewSwitcherTitle"
                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="HdyViewSwitcherBar">
          <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

HdyViewSwitcherTitle has a single CSS node with name viewswitchertitle.

Functions

hdy_view_switcher_title_new ()

HdyViewSwitcherTitle *
hdy_view_switcher_title_new (void);

Creates a new HdyViewSwitcherTitle widget.

Returns

a new HdyViewSwitcherTitle

Since: 1.0


hdy_view_switcher_title_get_policy ()

HdyViewSwitcherPolicy
hdy_view_switcher_title_get_policy (HdyViewSwitcherTitle *self);

Gets the policy of self .

Parameters

Returns

the policy of self

Since: 1.0


hdy_view_switcher_title_set_policy ()

void
hdy_view_switcher_title_set_policy (HdyViewSwitcherTitle *self,
                                    HdyViewSwitcherPolicy policy);

Sets the policy of self .

Parameters

self

a HdyViewSwitcherTitle

 

policy

the new policy

 

Since: 1.0


hdy_view_switcher_title_get_icon_size ()

GtkIconSize
hdy_view_switcher_title_get_icon_size (HdyViewSwitcherTitle *self);

Get the icon size of the images used in the HdyViewSwitcher.

Parameters

Returns

the icon size of the images

Since: 1.0


hdy_view_switcher_title_set_icon_size ()

void
hdy_view_switcher_title_set_icon_size (HdyViewSwitcherTitle *self,
                                       GtkIconSize icon_size);

Change the icon size hint for the icons in a HdyViewSwitcher.

Parameters

self

a HdyViewSwitcherTitle

 

icon_size

the new icon size

 

Since: 1.0


hdy_view_switcher_title_get_stack ()

GtkStack *
hdy_view_switcher_title_get_stack (HdyViewSwitcherTitle *self);

Get the GtkStack being controlled by the HdyViewSwitcher.

Parameters

Returns

the GtkStack, or NULL if none has been set.

[nullable][transfer none]

Since: 1.0


hdy_view_switcher_title_set_stack ()

void
hdy_view_switcher_title_set_stack (HdyViewSwitcherTitle *self,
                                   GtkStack *stack);

Sets the GtkStack to control.

Parameters

self

a HdyViewSwitcherTitle

 

stack

a GtkStack.

[nullable]

Since: 1.0


hdy_view_switcher_title_get_title ()

const gchar *
hdy_view_switcher_title_get_title (HdyViewSwitcherTitle *self);

Gets the title of self . See hdy_view_switcher_title_set_title().

Parameters

Returns

the title of self , or NULL.

[transfer none][nullable]

Since: 1.0


hdy_view_switcher_title_set_title ()

void
hdy_view_switcher_title_set_title (HdyViewSwitcherTitle *self,
                                   const gchar *title);

Sets the title of self . The title should give a user additional details. A good title should not include the application name.

Parameters

self

a HdyViewSwitcherTitle

 

title

a title, or NULL.

[allow-none]

Since: 1.0


hdy_view_switcher_title_get_subtitle ()

const gchar *
hdy_view_switcher_title_get_subtitle (HdyViewSwitcherTitle *self);

Gets the subtitle of self . See hdy_view_switcher_title_set_subtitle().

Parameters

Returns

the subtitle of self , or NULL.

[transfer none][nullable]

Since: 1.0


hdy_view_switcher_title_set_subtitle ()

void
hdy_view_switcher_title_set_subtitle (HdyViewSwitcherTitle *self,
                                      const gchar *subtitle);

Sets the subtitle of self . The subtitle should give a user additional details.

Note that HdyViewSwitcherTitle by default reserves room for the subtitle, even if none is currently set. If this is not desired, set the “has-subtitle” property to FALSE.

Parameters

self

a HdyViewSwitcherTitle

 

subtitle

a subtitle, or NULL.

[allow-none]

Since: 1.0


hdy_view_switcher_title_get_has_subtitle ()

gboolean
hdy_view_switcher_title_get_has_subtitle
                               (HdyViewSwitcherTitle *self);

gets whether the view switcher reserves space for a subtitle, regardless if one is currently set or not.

Parameters

Returns

TRUE if the view switcher reserves space for a subtitle

Since: 1.0


hdy_view_switcher_title_set_has_subtitle ()

void
hdy_view_switcher_title_set_has_subtitle
                               (HdyViewSwitcherTitle *self,
                                gboolean has_subtitle);

Sets whether the view switcher should reserve space for a subtitle, even if none is currently set.

Parameters

self

a HdyViewSwitcherTitle

 

has_subtitle

TRUE to reserve space for a subtitle

 

Since: 1.0


hdy_view_switcher_title_get_view_switcher_enabled ()

gboolean
hdy_view_switcher_title_get_view_switcher_enabled
                               (HdyViewSwitcherTitle *self);

Gets whether self 's view switcher is enabled.

See hdy_view_switcher_title_set_view_switcher_enabled().

Parameters

Returns

TRUE if the view switcher is enabled, FALSE otherwise.

Since: 1.0


hdy_view_switcher_title_set_view_switcher_enabled ()

void
hdy_view_switcher_title_set_view_switcher_enabled
                               (HdyViewSwitcherTitle *self,
                                gboolean enabled);

Make self enable or disable its view switcher. If it is disabled, the title will be displayed instead. This allows to programmatically and prematurely hide the view switcher of self even if it fits in the available space.

This can be used e.g. to ensure the view switcher is hidden below a certain window width, or any other constraint you find suitable.

Parameters

self

a HdyViewSwitcherTitle

 

enabled

TRUE to enable the view switcher, FALSE to disable it

 

Since: 1.0


hdy_view_switcher_title_get_title_visible ()

gboolean
hdy_view_switcher_title_get_title_visible
                               (HdyViewSwitcherTitle *self);

Get whether the title label of self is visible.

Parameters

Returns

TRUE if the title label of self is visible, FALSE if not.

Since: 1.0

Types and Values

HDY_TYPE_VIEW_SWITCHER_TITLE

#define HDY_TYPE_VIEW_SWITCHER_TITLE (hdy_view_switcher_title_get_type())

HdyViewSwitcherTitleClass

typedef struct {
  GtkBinClass parent_class;
} HdyViewSwitcherTitleClass;

HdyViewSwitcherTitle

typedef struct _HdyViewSwitcherTitle HdyViewSwitcherTitle;

Property Details

The “has-subtitle” property

  “has-subtitle”             gboolean

If TRUE, reserve space for a subtitle, even if none is currently set.

Flags: Read / Write

Default value: TRUE

Since: 1.0


The “icon-size” property

  “icon-size”                gint

Use the "icon-size" property to hint the icons to use, you almost certainly want to leave this as GTK_ICON_SIZE_BUTTON.

Flags: Read / Write

Allowed values: >= 0

Default value: 4

Since: 1.0


The “policy” property

  “policy”                   HdyViewSwitcherPolicy

The HdyViewSwitcherPolicy the HdyViewSwitcher should use to determine which mode to use.

Flags: Read / Write

Default value: HDY_VIEW_SWITCHER_POLICY_WIDE

Since: 1.0


The “stack” property

  “stack”                    GtkStack *

The GtkStack the HdyViewSwitcher controls.

Flags: Read / Write

Since: 1.0


The “subtitle” property

  “subtitle”                 gchar *

The subtitle of the HdyViewSwitcher.

Flags: Read / Write

Default value: NULL

Since: 1.0


The “title” property

  “title”                    gchar *

The title of the HdyViewSwitcher.

Flags: Read / Write

Default value: NULL

Since: 1.0


The “title-visible” property

  “title-visible”            gboolean

Whether the bar should be revealed or hidden.

Flags: Read

Default value: TRUE

Since: 1.0


The “view-switcher-enabled” property

  “view-switcher-enabled”    gboolean

Whether the bar should be revealed or hidden.

Flags: Read / Write

Default value: TRUE

Since: 1.0

See Also

HdyHeaderBar, HdyViewSwitcher, HdyViewSwitcherBar