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
11723557
Commit
11723557
authored
Dec 31, 2021
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subclass ImagePageWidget
parent
aa06f0f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
69 deletions
+75
-69
image.rs
src/widgets/pages/image.rs
+41
-13
paginator.rs
src/widgets/paginator.rs
+2
-2
window.rs
src/widgets/window.rs
+32
-54
No files found.
src/widgets/pages/image.rs
View file @
11723557
use
gtk
::
glib
;
use
gtk
::
prelude
::
*
;
use
gtk
::
subclass
::
prelude
::
*
;
pub
struct
ImagePageWidget
{
pub
widget
:
gtk
::
Box
,
mod
imp
{
use
super
::
*
;
#[derive(Debug,
Default)]
pub
struct
ImagePageWidget
;
#[glib
::
object_subclass]
impl
ObjectSubclass
for
ImagePageWidget
{
const
NAME
:
&
'static
str
=
"ImagePageWidget"
;
type
ParentType
=
gtk
::
Box
;
type
Type
=
super
::
ImagePageWidget
;
}
impl
ObjectImpl
for
ImagePageWidget
{
fn
constructed
(
&
self
,
obj
:
&
Self
::
Type
)
{
let
layout_manager
=
obj
.layout_manager
()
.map
(|
l
|
l
.downcast
::
<
gtk
::
BoxLayout
>
()
.unwrap
())
.unwrap
();
layout_manager
.set_orientation
(
gtk
::
Orientation
::
Vertical
);
obj
.add_css_class
(
"page"
);
self
.parent_constructed
(
obj
);
}
}
impl
WidgetImpl
for
ImagePageWidget
{}
impl
BoxImpl
for
ImagePageWidget
{}
}
glib
::
wrapper!
{
pub
struct
ImagePageWidget
(
ObjectSubclass
<
imp
::
ImagePageWidget
>
)
@
extends
gtk
::
Widget
,
gtk
::
Box
;
}
impl
ImagePageWidget
{
pub
fn
new
(
resource_uri
:
&
str
,
head
:
String
,
body
:
String
)
->
Self
{
let
widget
=
gtk
::
Box
::
new
(
gtk
::
Orientation
::
Vertical
,
0
);
let
image_page
=
Self
{
widget
};
let
image_page
=
glib
::
Object
::
new
::
<
Self
>
(
&
[
(
"hexpand"
,
&
true
),
(
"vexpand"
,
&
true
),
(
"halign"
,
&
gtk
::
Align
::
Fill
),
(
"valign"
,
&
gtk
::
Align
::
Fill
),
])
.unwrap
();
image_page
.init
(
resource_uri
,
head
,
body
);
image_page
}
fn
init
(
&
self
,
resource_uri
:
&
str
,
head
:
String
,
body
:
String
)
{
self
.widget
.set_hexpand
(
true
);
self
.widget
.set_vexpand
(
true
);
self
.widget
.add_css_class
(
"page"
);
self
.widget
.set_halign
(
gtk
::
Align
::
Fill
);
self
.widget
.set_valign
(
gtk
::
Align
::
Fill
);
let
container
=
gtk
::
Box
::
builder
()
.orientation
(
gtk
::
Orientation
::
Vertical
)
.spacing
(
12
)
...
...
@@ -61,6 +89,6 @@ impl ImagePageWidget {
.build
();
container
.append
(
&
body_label
);
self
.
widget
.
append
(
&
clamp
);
self
.append
(
&
clamp
);
}
}
src/widgets/paginator.rs
View file @
11723557
...
...
@@ -150,11 +150,11 @@ impl PaginatorWidget {
Some
(())
}
pub
fn
add_page
(
&
self
,
page
:
gtk
::
Widget
)
{
pub
fn
add_page
(
&
self
,
page
:
impl
IsA
<
gtk
::
Widget
>
)
{
let
imp
=
self
.imp
();
let
page_nr
=
imp
.pages
.borrow
()
.len
();
imp
.carousel
.insert
(
&
page
,
page_nr
as
i32
);
imp
.pages
.borrow_mut
()
.push
(
page
);
imp
.pages
.borrow_mut
()
.push
(
page
.upcast
()
);
self
.update_position
();
}
...
...
src/widgets/window.rs
View file @
11723557
...
...
@@ -40,66 +40,44 @@ impl Window {
if
PROFILE
==
"Devel"
{
self
.widget
.add_css_class
(
"devel"
);
}
self
.paginator
.add_page
(
WelcomePageWidget
::
new
()
.widget.upcast
::
<
gtk
::
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."
),
)
.widget
.upcast
::
<
gtk
::
Widget
>
(),
);
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."
),
)
.widget
.upcast
::
<
gtk
::
Widget
>
(),
);
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."
),
)
.widget
.upcast
::
<
gtk
::
Widget
>
(),
);
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!"
),
)
.widget
.upcast
::
<
gtk
::
Widget
>
(),
);
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!"
),
)
.widget
.upcast
::
<
gtk
::
Widget
>
(),
);
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
.widget
.add_css_class
(
"last-page"
);
self
.paginator
.add_page
(
last_page
.widget.upcast
::
<
gtk
::
Widget
>
());
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