Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-welcome
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-welcome
Commits
91d1d593
Commit
91d1d593
authored
Jul 14, 2020
by
Alexander Mikhaylenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paginator: Update position after adding pages
Otherwise it's mixed state until we swipe carousel the first time or press Next.
parent
a406830a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
paginator.rs
src/widgets/paginator.rs
+18
-12
No files found.
src/widgets/paginator.rs
View file @
91d1d593
...
...
@@ -56,26 +56,32 @@ impl PaginatorWidget {
let
page_nr
=
self
.pages
.borrow
()
.len
();
self
.carousel
.insert
(
&
page
.get_widget
(),
page_nr
as
i32
);
self
.pages
.borrow_mut
()
.push
(
page
);
}
fn
init
(
&
self
,
p
:
Rc
<
Self
>
)
{
self
.carousel
.set_property_expand
(
true
);
self
.carousel
.set_animation_duration
(
300
);
self
.update_position
();
}
self
.carousel
.connect_property_position_notify
(
clone!
(
@
weak
p
=>
move
|
carousel
|
{
let
n_pages
=
carousel
.get_n_pages
()
as
f64
;
let
position
=
carousel
.get_position
();
fn
update_position
(
&
self
)
{
let
n_pages
=
self
.
carousel
.get_n_pages
()
as
f64
;
let
position
=
self
.
carousel
.get_position
();
let
opacity
=
(
position
-
n_pages
+
2
_f64
)
.max
(
0
_f64
);
p
.close_btn
.set_opacity
(
opacity
);
p
.close_btn
.set_visible
(
opacity
>
0
_f64
);
self
.close_btn
.set_opacity
(
opacity
);
self
.close_btn
.set_visible
(
opacity
>
0
_f64
);
let
page_nr
=
position
.round
()
as
u32
;
let
pages
=
&
p
.pages
.borrow
();
let
pages
=
&
self
.pages
.borrow
();
let
page
=
pages
.get
(
page_nr
as
usize
)
.unwrap
();
p
.headerbar
.set_title
(
Some
(
&
page
.get_title
()));
p
.current_page
.replace
(
page_nr
);
self
.headerbar
.set_title
(
Some
(
&
page
.get_title
()));
self
.current_page
.replace
(
page_nr
);
}
fn
init
(
&
self
,
p
:
Rc
<
Self
>
)
{
self
.carousel
.set_property_expand
(
true
);
self
.carousel
.set_animation_duration
(
300
);
self
.carousel
.connect_property_position_notify
(
clone!
(
@
weak
p
=>
move
|
_
|
{
p
.update_position
();
}));
let
previous_btn
=
gtk
::
Button
::
with_label
(
&
gettext
(
"_Previous"
));
...
...
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