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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
74 deletions
+104
-74
application.rs
src/application.rs
+10
-10
paginator.rs
src/widgets/paginator.rs
+6
-0
window.rs
src/widgets/window.rs
+88
-64
No files found.
src/application.rs
View file @
ba2f81ad
...
@@ -16,7 +16,7 @@ mod imp {
...
@@ -16,7 +16,7 @@ mod imp {
#[derive(Debug,
Default)]
#[derive(Debug,
Default)]
pub
struct
Application
{
pub
struct
Application
{
pub
(
super
)
window
:
OnceCell
<
W
indow
>
,
pub
(
super
)
window
:
OnceCell
<
W
eakRef
<
Window
>
>
,
}
}
#[glib
::
object_subclass]
#[glib
::
object_subclass]
...
@@ -30,11 +30,12 @@ mod imp {
...
@@ -30,11 +30,12 @@ mod imp {
impl
ApplicationImpl
for
Application
{
impl
ApplicationImpl
for
Application
{
fn
activate
(
&
self
,
application
:
&
Self
::
Type
)
{
fn
activate
(
&
self
,
application
:
&
Self
::
Type
)
{
let
window
=
Window
::
new
(
&
application
);
let
window
=
Window
::
new
(
&
application
);
application
.add_window
(
&
window
.widget
);
application
.add_window
(
&
window
);
window
.
widget
.
present
();
window
.present
();
self
.window
.set
(
window
);
self
.window
.set
(
window
.downgrade
())
.unwrap
(
);
self
.parent_activate
(
application
);
self
.parent_activate
(
application
);
}
}
fn
startup
(
&
self
,
application
:
&
Self
::
Type
)
{
fn
startup
(
&
self
,
application
:
&
Self
::
Type
)
{
// Quit
// Quit
utils
::
action
(
utils
::
action
(
...
@@ -68,8 +69,8 @@ mod imp {
...
@@ -68,8 +69,8 @@ mod imp {
"next-page"
,
"next-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
let
window
=
application
.window
();
if
window
.paginator
.try_next
()
.is_none
()
{
if
window
.paginator
()
.try_next
()
.is_none
()
{
window
.
widget
.
close
();
window
.close
();
}
}
}),
}),
);
);
...
@@ -79,7 +80,7 @@ mod imp {
...
@@ -79,7 +80,7 @@ mod imp {
"previous-page"
,
"previous-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
let
window
=
application
.window
();
if
window
.paginator
.try_previous
()
.is_none
()
{
if
window
.paginator
()
.try_previous
()
.is_none
()
{
window
.reset_tour
();
window
.reset_tour
();
}
}
}),
}),
...
@@ -107,9 +108,8 @@ impl Application {
...
@@ -107,9 +108,8 @@ impl Application {
.unwrap
()
.unwrap
()
}
}
fn
window
(
&
self
)
->
&
Window
{
fn
window
(
&
self
)
->
Window
{
// and_then(|w| w.upgrade())
self
.imp
()
.window
.get
()
.and_then
(|
w
|
w
.upgrade
())
.unwrap
()
self
.imp
()
.window
.get
()
.unwrap
()
}
}
pub
fn
run
()
{
pub
fn
run
()
{
...
...
src/widgets/paginator.rs
View file @
ba2f81ad
...
@@ -212,3 +212,9 @@ impl PaginatorWidget {
...
@@ -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
adw
::
prelude
::
*
;
use
gettextrs
::
gettext
;
use
gettextrs
::
gettext
;
use
gtk
::
subclass
::
prelude
::
*
;
use
gtk
::{
gio
,
glib
};
use
super
::
pages
::{
ImagePageWidget
,
WelcomePageWidget
};
use
super
::
pages
::{
ImagePageWidget
,
WelcomePageWidget
};
use
super
::
paginator
::
PaginatorWidget
;
use
super
::
paginator
::
PaginatorWidget
;
use
crate
::
config
::{
APP_ID
,
PROFILE
};
use
crate
::
Application
;
use
crate
::
Application
;
#[derive(Debug)]
mod
imp
{
pub
struct
Window
{
use
super
::
*
;
pub
widget
:
adw
::
ApplicationWindow
,
use
crate
::
config
;
pub
paginator
:
PaginatorWidget
,
use
adw
::
subclass
::
prelude
::
*
;
#[derive(Debug,
Default)]
pub
struct
Window
{
pub
(
super
)
paginator
:
PaginatorWidget
,
}
#[glib
::
object_subclass]
impl
ObjectSubclass
for
Window
{
const
NAME
:
&
'static
str
=
"Window"
;
type
Type
=
super
::
Window
;
type
ParentType
=
adw
::
ApplicationWindow
;
}
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
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"
,
gettext
(
"Get an Overview"
),
gettext
(
"Press the Super key to see open windows and apps."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/search.svg"
,
gettext
(
"Just Type to Search"
),
gettext
(
"Type in the overview to search. Launch apps, find things."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/workspaces.svg"
,
gettext
(
"Keep on Top with Workspaces"
),
gettext
(
"Easily organize windows with the workspaces view."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/blank.svg"
,
gettext
(
"Up/Down for the Overview"
),
gettext
(
"On a touchpad, use three-finger vertical swipes. Try it!"
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/blank.svg"
,
gettext
(
"Left/Right for Workspaces"
),
gettext
(
"On a touchpad, use three-finger horizontal swipes. Try it!"
),
));
let
last_page
=
ImagePageWidget
::
new
(
"/org/gnome/Tour/ready-to-go.svg"
,
gettext
(
"That's it. Have a nice day!"
),
gettext
(
"To get more advice and tips, see the Help app."
),
);
last_page
.add_css_class
(
"last-page"
);
self
.paginator
.add_page
(
last_page
);
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
{
impl
Window
{
pub
fn
new
(
app
:
&
Application
)
->
Self
{
pub
fn
new
(
app
:
&
Application
)
->
Self
{
let
widget
=
adw
::
ApplicationWindow
::
new
(
app
);
glib
::
Object
::
new
(
&
[(
"application"
,
app
)])
.unwrap
()
}
let
paginator
=
PaginatorWidget
::
new
();
let
mut
window_widget
=
Window
{
widget
,
paginator
};
window_widget
.init
();
pub
fn
paginator
(
&
self
)
->
PaginatorWidget
{
window_widget
self
.imp
()
.paginator
.clone
()
}
}
pub
fn
start_tour
(
&
self
)
{
pub
fn
start_tour
(
&
self
)
{
self
.paginator
.set_page
(
1
);
self
.
imp
()
.
paginator
.set_page
(
1
);
}
}
pub
fn
reset_tour
(
&
self
)
{
pub
fn
reset_tour
(
&
self
)
{
self
.paginator
.set_page
(
0
);
self
.imp
()
.paginator
.set_page
(
0
);
}
fn
init
(
&
mut
self
)
{
self
.widget
.set_default_size
(
960
,
720
);
self
.widget
.set_icon_name
(
Some
(
APP_ID
));
// Devel Profile
if
PROFILE
==
"Devel"
{
self
.widget
.add_css_class
(
"devel"
);
}
self
.paginator
.add_page
(
WelcomePageWidget
::
new
()
.widget
);
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/overview.svg"
,
gettext
(
"Get an Overview"
),
gettext
(
"Press the Super key to see open windows and apps."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/search.svg"
,
gettext
(
"Just Type to Search"
),
gettext
(
"Type in the overview to search. Launch apps, find things."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/workspaces.svg"
,
gettext
(
"Keep on Top with Workspaces"
),
gettext
(
"Easily organize windows with the workspaces view."
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/blank.svg"
,
gettext
(
"Up/Down for the Overview"
),
gettext
(
"On a touchpad, use three-finger vertical swipes. Try it!"
),
));
self
.paginator
.add_page
(
ImagePageWidget
::
new
(
"/org/gnome/Tour/blank.svg"
,
gettext
(
"Left/Right for Workspaces"
),
gettext
(
"On a touchpad, use three-finger horizontal swipes. Try it!"
),
));
let
last_page
=
ImagePageWidget
::
new
(
"/org/gnome/Tour/ready-to-go.svg"
,
gettext
(
"That's it. Have a nice day!"
),
gettext
(
"To get more advice and tips, see the Help app."
),
);
last_page
.add_css_class
(
"last-page"
);
self
.paginator
.add_page
(
last_page
);
self
.widget
.set_content
(
Some
(
&
self
.paginator
));
}
}
}
}
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