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
ba2f81ad
Commit
ba2f81ad
authored
Dec 31, 2021
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subclass Window
parent
11723557
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
38 deletions
+68
-38
application.rs
src/application.rs
+10
-10
paginator.rs
src/widgets/paginator.rs
+6
-0
window.rs
src/widgets/window.rs
+52
-28
No files found.
src/application.rs
View file @
ba2f81ad
...
...
@@ -16,7 +16,7 @@ mod imp {
#[derive(Debug,
Default)]
pub
struct
Application
{
pub
(
super
)
window
:
OnceCell
<
W
indow
>
,
pub
(
super
)
window
:
OnceCell
<
W
eakRef
<
Window
>
>
,
}
#[glib
::
object_subclass]
...
...
@@ -30,11 +30,12 @@ mod imp {
impl
ApplicationImpl
for
Application
{
fn
activate
(
&
self
,
application
:
&
Self
::
Type
)
{
let
window
=
Window
::
new
(
&
application
);
application
.add_window
(
&
window
.widget
);
window
.
widget
.
present
();
self
.window
.set
(
window
);
application
.add_window
(
&
window
);
window
.present
();
self
.window
.set
(
window
.downgrade
())
.unwrap
(
);
self
.parent_activate
(
application
);
}
fn
startup
(
&
self
,
application
:
&
Self
::
Type
)
{
// Quit
utils
::
action
(
...
...
@@ -68,8 +69,8 @@ mod imp {
"next-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
if
window
.paginator
.try_next
()
.is_none
()
{
window
.
widget
.
close
();
if
window
.paginator
()
.try_next
()
.is_none
()
{
window
.close
();
}
}),
);
...
...
@@ -79,7 +80,7 @@ mod imp {
"previous-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
if
window
.paginator
.try_previous
()
.is_none
()
{
if
window
.paginator
()
.try_previous
()
.is_none
()
{
window
.reset_tour
();
}
}),
...
...
@@ -107,9 +108,8 @@ impl Application {
.unwrap
()
}
fn
window
(
&
self
)
->
&
Window
{
// and_then(|w| w.upgrade())
self
.imp
()
.window
.get
()
.unwrap
()
fn
window
(
&
self
)
->
Window
{
self
.imp
()
.window
.get
()
.and_then
(|
w
|
w
.upgrade
())
.unwrap
()
}
pub
fn
run
()
{
...
...
src/widgets/paginator.rs
View file @
ba2f81ad
...
...
@@ -212,3 +212,9 @@ impl PaginatorWidget {
}
}
}
impl
Default
for
PaginatorWidget
{
fn
default
()
->
Self
{
Self
::
new
()
}
}
src/widgets/window.rs
View file @
ba2f81ad
use
adw
::
prelude
::
*
;
use
gettextrs
::
gettext
;
use
gtk
::
subclass
::
prelude
::
*
;
use
gtk
::{
gio
,
glib
};
use
super
::
pages
::{
ImagePageWidget
,
WelcomePageWidget
};
use
super
::
paginator
::
PaginatorWidget
;
use
crate
::
config
::{
APP_ID
,
PROFILE
};
use
crate
::
Application
;
#[derive(Debug)]
pub
struct
Window
{
pub
widget
:
adw
::
ApplicationWindow
,
pub
paginator
:
PaginatorWidget
,
}
impl
Window
{
pub
fn
new
(
app
:
&
Application
)
->
Self
{
let
widget
=
adw
::
ApplicationWindow
::
new
(
app
);
let
paginator
=
PaginatorWidget
::
new
();
let
mut
window_widget
=
Window
{
widget
,
paginator
};
window_widget
.init
();
window_widget
}
mod
imp
{
use
super
::
*
;
use
crate
::
config
;
use
adw
::
subclass
::
prelude
::
*
;
pub
fn
start_tour
(
&
self
)
{
self
.paginator
.set_page
(
1
);
#[derive(Debug,
Default)]
pub
struct
Window
{
pub
(
super
)
paginator
:
PaginatorWidget
,
}
pub
fn
reset_tour
(
&
self
)
{
self
.paginator
.set_page
(
0
);
#[glib
::
object_subclass]
impl
ObjectSubclass
for
Window
{
const
NAME
:
&
'static
str
=
"Window"
;
type
Type
=
super
::
Window
;
type
ParentType
=
adw
::
ApplicationWindow
;
}
fn
init
(
&
mut
self
)
{
self
.widget
.set_default_size
(
960
,
720
);
self
.widget
.set_icon_name
(
Some
(
APP_ID
));
impl
ObjectImpl
for
Window
{
fn
constructed
(
&
self
,
widget
:
&
Self
::
Type
)
{
widget
.set_default_size
(
960
,
720
);
widget
.set_icon_name
(
Some
(
config
::
APP_ID
));
// Devel Profile
if
PROFILE
==
"Devel"
{
self
.
widget
.add_css_class
(
"devel"
);
if
config
::
PROFILE
==
"Devel"
{
widget
.add_css_class
(
"devel"
);
}
self
.paginator
.add_page
(
WelcomePageWidget
::
new
()
.widget
);
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/overview.svg"
,
...
...
@@ -79,6 +73,36 @@ impl Window {
last_page
.add_css_class
(
"last-page"
);
self
.paginator
.add_page
(
last_page
);
self
.widget
.set_content
(
Some
(
&
self
.paginator
));
widget
.set_content
(
Some
(
&
self
.paginator
));
self
.parent_constructed
(
widget
);
}
}
impl
WidgetImpl
for
Window
{}
impl
WindowImpl
for
Window
{}
impl
ApplicationWindowImpl
for
Window
{}
impl
AdwApplicationWindowImpl
for
Window
{}
}
glib
::
wrapper!
{
pub
struct
Window
(
ObjectSubclass
<
imp
::
Window
>
)
@
extends
gtk
::
Widget
,
gtk
::
Window
,
gtk
::
ApplicationWindow
,
adw
::
ApplicationWindow
,
@
implements
gio
::
ActionMap
,
gio
::
ActionGroup
;
}
impl
Window
{
pub
fn
new
(
app
:
&
Application
)
->
Self
{
glib
::
Object
::
new
(
&
[(
"application"
,
app
)])
.unwrap
()
}
pub
fn
paginator
(
&
self
)
->
PaginatorWidget
{
self
.imp
()
.paginator
.clone
()
}
pub
fn
start_tour
(
&
self
)
{
self
.imp
()
.paginator
.set_page
(
1
);
}
pub
fn
reset_tour
(
&
self
)
{
self
.imp
()
.paginator
.set_page
(
0
);
}
}
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