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
56031b7a
Commit
56031b7a
authored
Jan 01, 2022
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
port PaginatorWidget to CompositeTemplate
parent
626d7733
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
78 deletions
+108
-78
resources.gresource.xml
data/resources.gresource.xml
+1
-0
paginator.ui
data/resources/ui/paginator.ui
+80
-0
paginator.rs
src/widgets/paginator.rs
+27
-78
No files found.
data/resources.gresource.xml
View file @
56031b7a
...
...
@@ -2,6 +2,7 @@
<gresources>
<gresource
prefix=
"/org/gnome/Tour/"
>
<file
compressed=
"true"
alias=
"style.css"
>
resources/style.css
</file>
<file
compressed=
"true"
preprocess=
"xml-stripblanks"
alias=
"ui/paginator.ui"
>
resources/ui/paginator.ui
</file>
<file
compressed=
"true"
preprocess=
"xml-stripblanks"
alias=
"ui/window.ui"
>
resources/ui/window.ui
</file>
<file
compressed=
"true"
alias=
"welcome.svg"
>
resources/assets/welcome.svg
</file>
<file
compressed=
"true"
alias=
"overview.svg"
>
resources/assets/overview.svg
</file>
...
...
data/resources/ui/paginator.ui
0 → 100644
View file @
56031b7a
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template
class=
"PaginatorWidget"
parent=
"GtkBox"
>
<child>
<object
class=
"GtkHeaderBar"
>
<property
name=
"show-title-buttons"
>
True
</property>
<property
name=
"title-widget"
>
<object
class=
"AdwCarouselIndicatorDots"
id=
"carousel_dots"
>
<property
name=
"carousel"
>
carousel
</property>
</object>
</property>
<style>
<class
name=
"flat"
/>
</style>
</object>
</child>
<child>
<object
class=
"GtkBox"
>
<property
name=
"margin-start"
>
12
</property>
<property
name=
"margin-end"
>
12
</property>
<child>
<object
class=
"GtkOverlay"
id=
"previous_overlay"
>
<property
name=
"valign"
>
center
</property>
<child>
<object
class=
"GtkButton"
id=
"previous_btn"
>
<property
name=
"icon-name"
>
left-large-symbolic
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"action-name"
>
app.previous-page
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Previous
</property>
<style>
<class
name=
"circular"
/>
</style>
</object>
</child>
</object>
</child>
<child>
<object
class=
"AdwCarousel"
id=
"carousel"
>
<property
name=
"hexpand"
>
True
</property>
<property
name=
"vexpand"
>
True
</property>
</object>
</child>
<child>
<object
class=
"GtkOverlay"
id=
"start_overlay"
>
<property
name=
"valign"
>
center
</property>
<child>
<object
class=
"GtkButton"
id=
"start_btn"
>
<property
name=
"icon-name"
>
right-large-symbolic
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"action-name"
>
app.start-tour
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Start
</property>
<style>
<class
name=
"suggested-action"
/>
<class
name=
"circular"
/>
</style>
</object>
</child>
<child
type=
"overlay"
>
<object
class=
"GtkOverlay"
id=
"next_overlay"
>
<property
name=
"valign"
>
center
</property>
<property
name=
"can-target"
>
false
</property>
<child>
<object
class=
"GtkButton"
id=
"next_btn"
>
<property
name=
"icon-name"
>
right-large-symbolic
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"action-name"
>
app.next-page
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Next
</property>
<style>
<class
name=
"circular"
/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
src/widgets/paginator.rs
View file @
56031b7a
use
gettextrs
::
gettext
;
use
gtk
::
prelude
::
*
;
use
gtk
::{
glib
::{
self
,
clone
},
subclass
::
prelude
::
*
,
};
use
std
::
cell
::
RefCell
;
mod
imp
{
use
std
::
cell
::
Cell
;
use
super
::
*
;
use
std
::
cell
::
Cell
;
use
std
::
cell
::
RefCell
;
#[derive(Debug)]
#[derive(Debug,
gtk
::
CompositeTemplate)]
#[template(resource
=
"/org/gnome/Tour/ui/paginator.ui"
)]
pub
struct
PaginatorWidget
{
pub
(
super
)
carousel
:
adw
::
Carousel
,
pub
(
super
)
carousel_dots
:
adw
::
CarouselIndicatorDots
,
pub
(
super
)
headerbar
:
gtk
::
HeaderBar
,
#[template_child]
pub
(
super
)
carousel
:
TemplateChild
<
adw
::
Carousel
>
,
pub
(
super
)
pages
:
RefCell
<
Vec
<
gtk
::
Widget
>>
,
pub
(
super
)
current_page
:
Cell
<
u32
>
,
pub
(
super
)
next_overlay
:
gtk
::
Overlay
,
pub
(
super
)
next_btn
:
gtk
::
Button
,
pub
(
super
)
start_btn
:
gtk
::
Button
,
pub
(
super
)
previous_btn
:
gtk
::
Button
,
#[template_child]
pub
(
super
)
next_overlay
:
TemplateChild
<
gtk
::
Overlay
>
,
#[template_child]
pub
(
super
)
next_btn
:
TemplateChild
<
gtk
::
Button
>
,
#[template_child]
pub
(
super
)
start_btn
:
TemplateChild
<
gtk
::
Button
>
,
#[template_child]
pub
(
super
)
previous_btn
:
TemplateChild
<
gtk
::
Button
>
,
}
impl
Default
for
PaginatorWidget
{
fn
default
()
->
Self
{
Self
{
carousel
:
adw
::
Carousel
::
new
(),
carousel_dots
:
adw
::
CarouselIndicatorDots
::
new
(),
headerbar
:
gtk
::
HeaderBar
::
builder
()
.show_title_buttons
(
true
)
.build
(),
start_btn
:
gtk
::
Button
::
from_icon_name
(
Some
(
"right-large-symbolic"
)),
next_overlay
:
gtk
::
Overlay
::
new
(),
next_btn
:
gtk
::
Button
::
from_icon_name
(
Some
(
"right-large-symbolic"
)),
previous_btn
:
gtk
::
Button
::
from_icon_name
(
Some
(
"left-large-symbolic"
)),
carousel
:
TemplateChild
::
default
(),
start_btn
:
TemplateChild
::
default
(),
next_overlay
:
TemplateChild
::
default
(),
next_btn
:
TemplateChild
::
default
(),
previous_btn
:
TemplateChild
::
default
(),
pages
:
RefCell
::
new
(
Vec
::
new
()),
current_page
:
Cell
::
new
(
0
),
}
...
...
@@ -45,6 +45,14 @@ mod imp {
const
NAME
:
&
'static
str
=
"PaginatorWidget"
;
type
ParentType
=
gtk
::
Box
;
type
Type
=
super
::
PaginatorWidget
;
fn
class_init
(
klass
:
&
mut
Self
::
Class
)
{
Self
::
bind_template
(
klass
);
}
fn
instance_init
(
obj
:
&
glib
::
subclass
::
InitializingObject
<
Self
>
)
{
obj
.init_template
();
}
}
impl
ObjectImpl
for
PaginatorWidget
{
...
...
@@ -54,71 +62,12 @@ mod imp {
.map
(|
l
|
l
.downcast
::
<
gtk
::
BoxLayout
>
()
.unwrap
())
.unwrap
();
layout_manager
.set_orientation
(
gtk
::
Orientation
::
Vertical
);
self
.headerbar
.add_css_class
(
"flat"
);
self
.carousel_dots
.set_carousel
(
Some
(
&
self
.carousel
));
self
.carousel
.set_hexpand
(
true
);
self
.carousel
.set_vexpand
(
true
);
self
.carousel
.set_scroll_params
(
&
adw
::
SpringParams
::
new
(
1.0
,
0.5
,
300.0
));
self
.carousel
.connect_position_notify
(
clone!
(
@
weak
obj
=>
move
|
_
|
{
obj
.update_position
();
}));
self
.start_btn
.add_css_class
(
"suggested-action"
);
self
.start_btn
.set_use_underline
(
true
);
self
.start_btn
.set_valign
(
gtk
::
Align
::
Center
);
self
.start_btn
.set_action_name
(
Some
(
"app.start-tour"
));
self
.start_btn
.set_tooltip_text
(
Some
(
&
gettext
(
"Start"
)));
self
.start_btn
.add_css_class
(
"circular"
);
self
.next_btn
.set_tooltip_text
(
Some
(
&
gettext
(
"Next"
)));
self
.next_btn
.set_use_underline
(
true
);
self
.next_btn
.set_valign
(
gtk
::
Align
::
Center
);
self
.next_btn
.set_action_name
(
Some
(
"app.next-page"
));
self
.next_btn
.add_css_class
(
"circular"
);
self
.previous_btn
.set_use_underline
(
true
);
self
.previous_btn
.set_valign
(
gtk
::
Align
::
Center
);
self
.previous_btn
.set_action_name
(
Some
(
"app.previous-page"
));
self
.previous_btn
.set_tooltip_text
(
Some
(
&
gettext
(
"Previous"
)));
self
.previous_btn
.add_css_class
(
"circular"
);
self
.next_overlay
.set_child
(
Some
(
&
self
.next_btn
));
self
.next_overlay
.set_valign
(
gtk
::
Align
::
Center
);
self
.next_overlay
.set_can_target
(
false
);
let
previous_overlay
=
gtk
::
Overlay
::
new
();
previous_overlay
.set_valign
(
gtk
::
Align
::
Center
);
previous_overlay
.add_overlay
(
&
self
.previous_btn
);
let
start_overlay
=
gtk
::
Overlay
::
new
();
start_overlay
.set_child
(
Some
(
&
self
.start_btn
));
start_overlay
.set_valign
(
gtk
::
Align
::
Center
);
start_overlay
.add_overlay
(
&
self
.next_overlay
);
let
btn_size_group
=
gtk
::
SizeGroup
::
new
(
gtk
::
SizeGroupMode
::
Horizontal
);
btn_size_group
.add_widget
(
&
self
.previous_btn
);
btn_size_group
.add_widget
(
&
self
.next_overlay
);
btn_size_group
.add_widget
(
&
start_overlay
);
self
.headerbar
.set_title_widget
(
Some
(
&
self
.carousel_dots
));
obj
.append
(
&
self
.headerbar
);
let
container
=
gtk
::
Box
::
builder
()
.orientation
(
gtk
::
Orientation
::
Horizontal
)
.margin_start
(
12
)
.margin_end
(
12
)
.build
();
container
.append
(
&
previous_overlay
);
container
.append
(
&
self
.carousel
);
container
.append
(
&
start_overlay
);
obj
.append
(
&
container
);
self
.parent_constructed
(
obj
);
}
}
...
...
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