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
101fd925
Commit
101fd925
authored
Jan 24, 2020
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly switch between pages
parent
5863db56
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
12 deletions
+54
-12
application.rs
src/application.rs
+0
-1
headerbar.rs
src/widgets/headerbar.rs
+23
-9
welcome.rs
src/widgets/pages/welcome.rs
+1
-0
paginator.rs
src/widgets/paginator.rs
+8
-0
window.rs
src/widgets/window.rs
+22
-2
No files found.
src/application.rs
View file @
101fd925
...
@@ -65,7 +65,6 @@ impl Application {
...
@@ -65,7 +65,6 @@ impl Application {
window
.previous_page
();
window
.previous_page
();
}),
}),
);
);
self
.app
.set_accels_for_action
(
"app.quit"
,
&
[
"<primary>q"
]);
self
.app
.set_accels_for_action
(
"app.quit"
,
&
[
"<primary>q"
]);
}
}
...
...
src/widgets/headerbar.rs
View file @
101fd925
...
@@ -3,16 +3,18 @@ use gtk::prelude::*;
...
@@ -3,16 +3,18 @@ use gtk::prelude::*;
pub
struct
HeaderBar
{
pub
struct
HeaderBar
{
pub
widget
:
gtk
::
HeaderBar
,
pub
widget
:
gtk
::
HeaderBar
,
container
:
gtk
::
Stack
,
container
:
gtk
::
Stack
,
next_btn
:
gtk
::
Button
,
}
}
impl
HeaderBar
{
impl
HeaderBar
{
pub
fn
new
()
->
Self
{
pub
fn
new
()
->
Self
{
let
widget
=
gtk
::
HeaderBar
::
new
();
let
widget
=
gtk
::
HeaderBar
::
new
();
let
container
=
gtk
::
Stack
::
new
();
let
container
=
gtk
::
Stack
::
new
();
let
next_btn
=
gtk
::
Button
::
new
();
widget
.set_show_title_buttons
(
true
);
widget
.set_show_title_buttons
(
true
);
let
headerbar
=
Self
{
widget
,
container
};
let
headerbar
=
Self
{
widget
,
container
,
next_btn
};
headerbar
.init
();
headerbar
.init
();
headerbar
headerbar
}
}
...
@@ -22,6 +24,19 @@ impl HeaderBar {
...
@@ -22,6 +24,19 @@ impl HeaderBar {
self
.widget
.set_show_title_buttons
(
false
);
self
.widget
.set_show_title_buttons
(
false
);
}
}
pub
fn
set_page_nr
(
&
self
,
page_nr
:
i32
,
total_pages
:
i32
)
{
if
page_nr
==
total_pages
{
self
.next_btn
.set_label
(
"Done"
);
}
else
{
self
.next_btn
.set_label
(
"Next"
);
}
}
pub
fn
end_tour
(
&
self
)
{
self
.container
.set_visible_child_name
(
"welcome"
);
self
.widget
.set_show_title_buttons
(
true
);
}
fn
init
(
&
self
)
{
fn
init
(
&
self
)
{
self
.container
.set_hexpand
(
true
);
self
.container
.set_hexpand
(
true
);
self
.container
.set_transition_type
(
gtk
::
StackTransitionType
::
SlideLeftRight
);
self
.container
.set_transition_type
(
gtk
::
StackTransitionType
::
SlideLeftRight
);
...
@@ -37,16 +52,15 @@ impl HeaderBar {
...
@@ -37,16 +52,15 @@ impl HeaderBar {
previous_btn
.set_hexpand
(
true
);
previous_btn
.set_hexpand
(
true
);
previous_btn
.set_property_width_request
(
60
);
previous_btn
.set_property_width_request
(
60
);
let
next_btn
=
gtk
::
Button
::
new
();
self
.next_btn
.add
(
&
gtk
::
Label
::
new
(
Some
(
"Next"
)));
next_btn
.add
(
&
gtk
::
Label
::
new
(
Some
(
"Next"
)));
self
.next_btn
.get_style_context
()
.add_class
(
"suggested-action"
);
next_btn
.get_style_context
()
.add_class
(
"suggested-action"
);
self
.next_btn
.set_action_name
(
Some
(
"app.next-page"
));
next_btn
.set_action_name
(
Some
(
"app.next-page"
));
self
.next_btn
.set_halign
(
gtk
::
Align
::
End
);
next_btn
.set_halign
(
gtk
::
Align
::
End
);
self
.next_btn
.set_hexpand
(
true
);
next_btn
.set_hexpand
(
true
);
self
.next_btn
.set_property_width_request
(
60
);
next_btn
.set_property_width_request
(
60
);
pages_container
.add
(
&
previous_btn
);
pages_container
.add
(
&
previous_btn
);
pages_container
.add
(
&
next_btn
);
pages_container
.add
(
&
self
.
next_btn
);
self
.container
.add_named
(
&
pages_container
,
"pages"
);
self
.container
.add_named
(
&
pages_container
,
"pages"
);
self
.widget
.set_custom_title
(
Some
(
&
self
.container
));
self
.widget
.set_custom_title
(
Some
(
&
self
.container
));
...
...
src/widgets/pages/welcome.rs
View file @
101fd925
...
@@ -53,6 +53,7 @@ impl WelcomePageWidget {
...
@@ -53,6 +53,7 @@ impl WelcomePageWidget {
actions_container
.add
(
&
skip_tour_btn
);
actions_container
.add
(
&
skip_tour_btn
);
actions_container
.add
(
&
start_tour_btn
);
actions_container
.add
(
&
start_tour_btn
);
actions_container
.set_focus_child
(
Some
(
&
start_tour_btn
));
self
.widget
.add
(
&
actions_container
);
self
.widget
.add
(
&
actions_container
);
}
}
...
...
src/widgets/paginator.rs
View file @
101fd925
...
@@ -23,6 +23,14 @@ impl PaginatorWidget {
...
@@ -23,6 +23,14 @@ impl PaginatorWidget {
paginator
paginator
}
}
pub
fn
get_total_pages
(
&
self
)
->
i32
{
self
.pages
.len
()
.try_into
()
.unwrap_or
(
1
)
}
pub
fn
get_current_page
(
&
self
)
->
i32
{
self
.current_page
.borrow
()
.clone
()
}
pub
fn
next
(
&
self
)
{
pub
fn
next
(
&
self
)
{
let
next_page
=
self
.current_page
.borrow
()
.clone
()
+
1
;
let
next_page
=
self
.current_page
.borrow
()
.clone
()
+
1
;
self
.go_to
(
next_page
);
self
.go_to
(
next_page
);
...
...
src/widgets/window.rs
View file @
101fd925
...
@@ -35,12 +35,32 @@ impl Window {
...
@@ -35,12 +35,32 @@ impl Window {
self
.headerbar
.start_tour
();
self
.headerbar
.start_tour
();
}
}
fn
end_tour
(
&
self
)
{
self
.container
.set_visible_child_name
(
"welcome"
);
self
.headerbar
.end_tour
();
}
pub
fn
next_page
(
&
self
)
{
pub
fn
next_page
(
&
self
)
{
self
.paginator
.next
();
let
total_pages
=
self
.paginator
.get_total_pages
();
let
current_page
=
self
.paginator
.get_current_page
();
self
.headerbar
.set_page_nr
(
current_page
+
1
,
total_pages
);
if
current_page
==
total_pages
{
self
.widget
.destroy
();
}
else
{
self
.paginator
.next
();
}
}
}
pub
fn
previous_page
(
&
self
)
{
pub
fn
previous_page
(
&
self
)
{
self
.paginator
.previous
();
let
total_pages
=
self
.paginator
.get_total_pages
();
let
current_page
=
self
.paginator
.get_current_page
();
self
.headerbar
.set_page_nr
(
current_page
-
1
,
total_pages
);
match
current_page
{
1
=>
self
.end_tour
(),
_
=>
self
.paginator
.previous
(),
}
}
}
fn
init
(
&
mut
self
)
{
fn
init
(
&
mut
self
)
{
...
...
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