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
8afee947
You need to sign in or sign up before continuing.
Commit
8afee947
authored
Jan 29, 2022
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i18n: move more string to UI files
This only leaves us with only one translatable string defined on a rust file, due to the low gettext/rust support...
parent
1bff7f23
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
30 deletions
+35
-30
window.ui
data/resources/ui/window.ui
+6
-0
POTFILES.in
po/POTFILES.in
+1
-2
image_page.rs
src/widgets/image_page.rs
+11
-5
paginator.rs
src/widgets/paginator.rs
+5
-23
window.rs
src/widgets/window.rs
+12
-0
No files found.
data/resources/ui/window.ui
View file @
8afee947
...
...
@@ -6,6 +6,12 @@
<property
name=
"content"
>
<object
class=
"PaginatorWidget"
id=
"paginator"
>
<child>
<object
class=
"ImagePageWidget"
id=
"welcome_page"
>
<property
name=
"resource-uri"
>
/org/gnome/Tour/welcome.svg
</property>
<property
name=
"head"
translatable=
"yes"
>
Start the Tour
</property>
</object>
</child>
<child>
<object
class=
"ImagePageWidget"
>
<property
name=
"resource-uri"
>
/org/gnome/Tour/overview.svg
</property>
<property
name=
"head"
translatable=
"yes"
>
Get an Overview
</property>
...
...
po/POTFILES.in
View file @
8afee947
...
...
@@ -2,6 +2,5 @@ data/org.gnome.Tour.desktop.in.in
data/org.gnome.Tour.metainfo.xml.in.in
data/resources/ui/paginator.ui
data/resources/ui/window.ui
src/widgets/image_page.rs
src/widgets/paginator.rs
src/widgets/window.rs
src/main.rs
src/widgets/image_page.rs
View file @
8afee947
...
...
@@ -7,12 +7,13 @@ mod imp {
use
glib
::
once_cell
::
sync
::
Lazy
;
use
glib
::{
ParamFlags
,
ParamSpec
,
ParamSpecString
,
Value
};
use
gtk
::
glib
::
once_cell
::
sync
::
OnceCell
;
use
std
::
cell
::
RefCell
;
#[derive(Debug,
Default)]
pub
struct
ImagePageWidget
{
pub
(
super
)
resource_uri
:
OnceCell
<
String
>
,
pub
(
super
)
head
:
OnceCell
<
String
>
,
pub
(
super
)
body
:
Once
Cell
<
String
>
,
pub
(
super
)
body
:
Ref
Cell
<
String
>
,
pub
(
super
)
picture
:
gtk
::
Picture
,
}
...
...
@@ -105,7 +106,7 @@ mod imp {
"Body"
,
"The body of the page"
,
None
,
ParamFlags
::
READWRITE
|
ParamFlags
::
CONSTRUCT
_ONLY
,
ParamFlags
::
READWRITE
|
ParamFlags
::
CONSTRUCT
,
),
]
});
...
...
@@ -124,8 +125,9 @@ mod imp {
self
.head
.set
(
head
)
.unwrap
();
}
"body"
=>
{
let
body
=
value
.get
()
.unwrap
();
self
.body
.set
(
body
)
.unwrap
();
if
let
Some
(
body
)
=
value
.get
::
<
Option
<
String
>>
()
.unwrap
()
{
self
.body
.replace
(
body
);
}
}
_
=>
unimplemented!
(),
}
...
...
@@ -135,7 +137,7 @@ mod imp {
match
pspec
.name
()
{
"resource-uri"
=>
self
.resource_uri
.get
()
.to_value
(),
"head"
=>
self
.head
.get
()
.to_value
(),
"body"
=>
self
.body
.
get
()
.to_value
(),
"body"
=>
self
.body
.
borrow
()
.to_value
(),
_
=>
unimplemented!
(),
}
}
...
...
@@ -158,4 +160,8 @@ impl ImagePageWidget {
])
.unwrap
()
}
pub
fn
set_body
(
&
self
,
body
:
&
str
)
{
self
.set_property
(
"body"
,
&
body
);
}
}
src/widgets/paginator.rs
View file @
8afee947
use
crate
::{
utils
::
i18n_f
,
widgets
::
ImagePageWidget
};
use
gettextrs
::
gettext
;
use
gtk
::
prelude
::
*
;
use
gtk
::{
gdk
,
...
...
@@ -9,8 +7,7 @@ use gtk::{
mod
imp
{
use
super
::
*
;
use
std
::
cell
::
Cell
;
use
std
::
cell
::
RefCell
;
use
std
::
cell
::{
Cell
,
RefCell
};
#[derive(Debug,
gtk
::
CompositeTemplate)]
#[template(resource
=
"/org/gnome/Tour/ui/paginator.ui"
)]
...
...
@@ -35,7 +32,7 @@ mod imp {
start_btn
:
TemplateChild
::
default
(),
next_btn
:
TemplateChild
::
default
(),
previous_btn
:
TemplateChild
::
default
(),
pages
:
RefCell
::
new
(
Vec
::
new
()
),
pages
:
RefCell
::
default
(
),
current_page
:
Cell
::
new
(
0
),
going_backward
:
Cell
::
new
(
false
),
}
...
...
@@ -72,21 +69,6 @@ mod imp {
obj
.update_position
();
}));
let
name
=
glib
::
os_info
(
"NAME"
)
.unwrap_or_else
(||
"GNOME"
.into
());
let
version
=
glib
::
os_info
(
"VERSION"
)
.unwrap_or_else
(||
""
.into
());
let
body
=
i18n_f
(
// Translators: The following string is formated as "Learn about new and essential features in GNOME 3.36" for example
"Learn about the key features in {name} {version}."
,
&
[(
"name"
,
&
name
),
(
"version"
,
&
version
)],
);
let
welcome_page
=
ImagePageWidget
::
new
(
"/org/gnome/Tour/welcome.svg"
,
gettext
(
"Start the Tour"
),
body
,
);
obj
.add_page
(
Some
(
-
1
),
welcome_page
);
let
controller
=
gtk
::
EventControllerKey
::
new
();
controller
.connect_key_pressed
(
clone!
(
@
weak
obj
=>
@
default
-
return
gtk
::
Inhibit
(
true
),
move
|
_controller
,
keyval
,
_keycode
,
_state
|
{
if
keyval
==
gdk
::
Key
::
Right
{
...
...
@@ -115,7 +97,7 @@ mod imp {
if
!
self
.carousel
.is_bound
()
{
self
.parent_add_child
(
buildable
,
builder
,
child
,
type_
);
}
else
{
buildable
.add_page
(
None
,
child
.clone
()
.downcast
::
<
gtk
::
Widget
>
()
.unwrap
());
buildable
.add_page
(
child
.clone
()
.downcast
::
<
gtk
::
Widget
>
()
.unwrap
());
}
}
}
...
...
@@ -151,10 +133,10 @@ impl PaginatorWidget {
Some
(())
}
pub
fn
add_page
(
&
self
,
at
:
Option
<
i32
>
,
page
:
impl
IsA
<
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
,
at
.unwrap_or
(
page_nr
as
i32
)
);
imp
.carousel
.insert
(
&
page
,
page_nr
as
i32
);
imp
.pages
.borrow_mut
()
.push
(
page
.upcast
());
self
.update_position
();
...
...
src/widgets/window.rs
View file @
8afee947
use
crate
::
utils
::
i18n_f
;
use
adw
::
prelude
::
*
;
use
gtk
::
subclass
::
prelude
::
*
;
use
gtk
::{
gio
,
glib
};
...
...
@@ -16,6 +17,8 @@ mod imp {
pub
struct
Window
{
#[template_child]
pub
(
super
)
paginator
:
TemplateChild
<
PaginatorWidget
>
,
#[template_child]
pub
(
super
)
welcome_page
:
TemplateChild
<
ImagePageWidget
>
,
}
#[glib
::
object_subclass]
...
...
@@ -42,6 +45,15 @@ mod imp {
if
config
::
PROFILE
==
"Devel"
{
widget
.add_css_class
(
"devel"
);
}
let
name
=
glib
::
os_info
(
"NAME"
)
.unwrap_or_else
(||
"GNOME"
.into
());
let
version
=
glib
::
os_info
(
"VERSION"
)
.unwrap_or_else
(||
""
.into
());
let
body
=
i18n_f
(
// Translators: The following string is formated as "Learn about new and essential features in GNOME 3.36" for example
"Learn about the key features in {name} {version}."
,
&
[(
"name"
,
&
name
),
(
"version"
,
&
version
)],
);
self
.welcome_page
.set_body
(
&
body
);
self
.parent_constructed
(
widget
);
}
}
...
...
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