Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adrien Plazas
libhandy
Commits
9cdaa870
Commit
9cdaa870
authored
Sep 12, 2018
by
Adrien Plazas
Browse files
example: Use a HdyHeaderGroup
This automatically updates the headerbars' window decoration layout.
parent
ec017d03
Pipeline
#1141
passed with stage
in 2 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/example-window.c
View file @
9cdaa870
...
...
@@ -6,8 +6,8 @@ struct _ExampleWindow
{
GtkApplicationWindow
parent_instance
;
HdyLeaflet
*
header_box
;
HdyLeaflet
*
content_box
;
GtkHeaderBar
*
header_bar
;
GtkButton
*
back
;
GtkStackSidebar
*
sidebar
;
GtkStack
*
stack
;
...
...
@@ -15,6 +15,7 @@ struct _ExampleWindow
HdyDialer
*
dialer
;
GtkLabel
*
display
;
GtkWidget
*
arrows
;
HdyHeaderGroup
*
header_group
;
GtkAdjustment
*
adj_arrows_count
;
GtkAdjustment
*
adj_arrows_duration
;
};
...
...
@@ -38,6 +39,33 @@ example_window_key_pressed_cb (GtkWidget *sender,
return
FALSE
;
}
static
void
update
(
ExampleWindow
*
self
)
{
GtkWidget
*
header_child
=
hdy_leaflet_get_visible_child
(
self
->
header_box
);
HdyFold
fold
=
hdy_leaflet_get_fold
(
self
->
header_box
);
g_assert
(
header_child
==
NULL
||
GTK_IS_HEADER_BAR
(
header_child
));
hdy_header_group_set_focus
(
self
->
header_group
,
fold
==
HDY_FOLD_FOLDED
?
header_child
:
NULL
);
}
static
void
example_window_notify_header_visible_child_cb
(
GObject
*
sender
,
GParamSpec
*
pspec
,
ExampleWindow
*
self
)
{
update
(
self
);
}
static
void
example_window_notify_fold_cb
(
GObject
*
sender
,
GParamSpec
*
pspec
,
ExampleWindow
*
self
)
{
update
(
self
);
}
static
void
example_window_notify_visible_child_cb
(
GObject
*
sender
,
GParamSpec
*
pspec
,
...
...
@@ -219,8 +247,8 @@ example_window_class_init (ExampleWindowClass *klass)
object_class
->
constructed
=
example_window_constructed
;
gtk_widget_class_set_template_from_resource
(
widget_class
,
"/sm/puri/handy/example/ui/example-window.ui"
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
header_box
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
content_box
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
header_bar
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
back
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
sidebar
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
stack
);
...
...
@@ -228,9 +256,12 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
dialer
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
display
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
arrows
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
header_group
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
adj_arrows_count
);
gtk_widget_class_bind_template_child
(
widget_class
,
ExampleWindow
,
adj_arrows_duration
);
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"key_pressed_cb"
,
G_CALLBACK
(
example_window_key_pressed_cb
));
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"notify_header_visible_child_cb"
,
G_CALLBACK
(
example_window_notify_header_visible_child_cb
));
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"notify_fold_cb"
,
G_CALLBACK
(
example_window_notify_fold_cb
));
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"notify_visible_child_cb"
,
G_CALLBACK
(
example_window_notify_visible_child_cb
));
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"back_clicked_cb"
,
G_CALLBACK
(
example_window_back_clicked_cb
));
gtk_widget_class_bind_template_callback_full
(
widget_class
,
"submitted_cb"
,
G_CALLBACK
(
example_window_submitted_cb
));
...
...
examples/example-window.ui
View file @
9cdaa870
...
...
@@ -33,12 +33,14 @@
<property
name=
"mode-transition-type"
>
slide
</property>
<property
name=
"child-transition-type"
>
slide
</property>
<property
name=
"visible-child-name"
bind-source=
"content_box"
bind-property=
"visible-child-name"
bind-flags=
"sync-create"
/>
<signal
name=
"notify::visible-child"
handler=
"notify_header_visible_child_cb"
swapped=
"no"
/>
<signal
name=
"notify::fold"
handler=
"notify_fold_cb"
after=
"yes"
swapped=
"no"
/>
<child>
<object
class=
"GtkHeaderBar"
id=
"header_bar"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"title"
>
Handy Widget Factory
</property>
<property
name=
"show_close_button"
bind-source=
"header_box"
bind-property=
"folded"
bind-flags=
"sync-create"
/
>
<property
name=
"show_close_button"
>
True
</property
>
</object>
<packing>
<property
name=
"name"
>
sidebar
</property>
...
...
@@ -671,6 +673,12 @@
<widget
name=
"stack"
/>
</widgets>
</object>
<object
class=
"HdyHeaderGroup"
id=
"header_group"
>
<headerbars>
<headerbar
name=
"header_bar"
/>
<headerbar
name=
"sub_header_bar"
/>
</headerbars>
</object>
<object
class=
"GtkAdjustment"
id=
"column_width_adjustment"
>
<property
name=
"lower"
>
0
</property>
<property
name=
"upper"
>
10000
</property>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment