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
8d0ad447
Commit
8d0ad447
authored
Feb 11, 2020
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to gtk3
Would love to keep using gtk4, but we can't get it into 3.36 otherwise.
parent
894dbdbf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
50 deletions
+61
-50
Cargo.lock
Cargo.lock
+0
-0
Cargo.toml
Cargo.toml
+4
-11
application.rs
src/application.rs
+31
-18
config.rs.in
src/config.rs.in
+10
-10
headerbar.rs
src/widgets/headerbar.rs
+11
-6
image.rs
src/widgets/pages/image.rs
+1
-1
welcome.rs
src/widgets/pages/welcome.rs
+1
-1
paginator.rs
src/widgets/paginator.rs
+3
-3
No files found.
Cargo.lock
View file @
8d0ad447
This diff is collapsed.
Click to expand it.
Cargo.toml
View file @
8d0ad447
...
...
@@ -5,17 +5,10 @@ authors = ["Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>"]
edition
=
"2018"
[dependencies]
glib
=
{
git
=
"https://github.com/gtk-rs/glib.git"
}
gio
=
{
git
=
"https://github.com/gtk-rs/gio.git"
}
glib
=
"0.9"
gdk
=
"0.12"
gtk
=
{
version
=
"0.8"
,
features=
["v3_16"]
}
gio
=
"0.8"
log
=
"0.4"
gettext-rs
=
{
version
=
"0.4"
,
features
=
["gettext-system"]
}
[dependencies.gdk]
package
=
"gdk4"
git
=
"https://github.com/gtk-rs/gdk4"
[dependencies.gtk]
package
=
"gtk4"
git
=
"https://github.com/gtk-rs/gtk4.git"
src/application.rs
View file @
8d0ad447
...
...
@@ -4,27 +4,27 @@ use crate::widgets::Window;
use
gio
::
prelude
::
*
;
use
gtk
::
prelude
::
*
;
use
std
::
env
;
use
std
::
rc
::
Rc
;
use
std
::
{
cell
::
RefCell
,
rc
::
Rc
}
;
pub
struct
Application
{
app
:
gtk
::
Application
,
window
:
R
c
<
Window
>
,
window
:
R
efCell
<
Rc
<
Option
<
Window
>>
>
,
}
impl
Application
{
pub
fn
new
()
->
Self
{
pub
fn
new
()
->
Rc
<
Self
>
{
let
app
=
gtk
::
Application
::
new
(
Some
(
config
::
APP_ID
),
gio
::
ApplicationFlags
::
FLAGS_NONE
)
.unwrap
();
let
window
=
Rc
::
new
(
Window
::
new
(
&
app
));
let
application
=
Self
{
app
,
window
};
let
application
=
Rc
::
new
(
Self
{
app
,
window
:
RefCell
::
new
(
Rc
::
new
(
None
)),
});
application
.setup_gactions
();
application
.setup_signals
();
application
.setup_css
();
application
.setup_signals
(
application
.clone
());
application
}
fn
setup_gactions
(
&
self
)
{
fn
setup_gactions
(
&
self
,
application
:
Rc
<
Self
>
)
{
// Quit
utils
::
action
(
&
self
.app
,
...
...
@@ -37,8 +37,10 @@ impl Application {
utils
::
action
(
&
self
.app
,
"start-tour"
,
clone!
(
@
strong
self
.window
as
window
=>
move
|
_
,
_
|
{
clone!
(
@
strong
application
=>
move
|
_
,
_
|
{
if
let
Some
(
window
)
=
&*
application
.window
.borrow
()
.clone
()
{
window
.start_tour
();
}
}),
);
...
...
@@ -54,32 +56,43 @@ impl Application {
utils
::
action
(
&
self
.app
,
"next-page"
,
clone!
(
@
strong
self
.window
as
window
=>
move
|
_
,
_
|
{
clone!
(
@
strong
application
=>
move
|
_
,
_
|
{
if
let
Some
(
window
)
=
&*
application
.window
.borrow
()
.clone
()
{
window
.next_page
();
}
}),
);
utils
::
action
(
&
self
.app
,
"previous-page"
,
clone!
(
@
strong
self
.window
as
window
=>
move
|
_
,
_
|
{
clone!
(
@
strong
application
=>
move
|
_
,
_
|
{
if
let
Some
(
window
)
=
&*
application
.window
.borrow
()
.clone
()
{
window
.previous_page
();
}
}),
);
self
.app
.set_accels_for_action
(
"app.quit"
,
&
[
"<primary>q"
]);
}
fn
setup_signals
(
&
self
)
{
self
.app
.connect_activate
(
clone!
(
@
weak
self
.window.widget
as
window
=>
move
|
app
|
{
app
.add_window
(
&
window
);
window
.present
();
fn
setup_signals
(
&
self
,
app
:
Rc
<
Self
>
)
{
self
.app
.connect_startup
(
clone!
(
@
weak
app
=>
move
|
_
|
{
app
.setup_css
();
app
.setup_gactions
(
app
.clone
());
}));
self
.app
.connect_activate
(
clone!
(
@
weak
app
=>
move
|
gtk_app
|
{
let
window
=
Window
::
new
(
&
gtk_app
);
gtk_app
.add_window
(
&
window
.widget
);
window
.widget
.present
();
window
.widget
.show_all
();
app
.window
.replace
(
Rc
::
new
(
Some
(
window
)));
}));
}
fn
setup_css
(
&
self
)
{
let
p
=
gtk
::
CssProvider
::
new
();
gtk
::
CssProvider
::
load_from_resource
(
&
p
,
"/org/gnome/Tour/style.css"
);
if
let
Some
(
display
)
=
gdk
::
Display
::
get_default
()
{
gtk
::
StyleContext
::
add_provider_for_
display
(
&
display
,
&
p
,
500
);
if
let
Some
(
screen
)
=
gdk
::
Screen
::
get_default
()
{
gtk
::
StyleContext
::
add_provider_for_
screen
(
&
screen
,
&
p
,
500
);
}
}
...
...
src/config.rs.in
View file @
8d0ad447
pub static APP_ID: &
'static
str = @APP_ID@;
pub static PKGDATADIR: &
'static
str = @PKGDATADIR@;
pub static PROFILE: &
'static
str = @PROFILE@;
pub static NAME_SUFFIX: &
'static
str = @NAME_SUFFIX@;
pub static VERSION: &
'static
str = @VERSION@;
pub static GETTEXT_PACKAGE: &
'static
str = @GETTEXT_PACKAGE@;
pub static LOCALEDIR: &
'static
str = @LOCALEDIR@;
pub static DISTRO_NAME: &
'static
str = @DISTRO_NAME@;
pub static DISTRO_VERSION: &
'static
str = @DISTRO_VERSION@;
pub static DISTRO_ICON_NAME: &
'static
str = @DISTRO_ICON_NAME@;
pub static APP_ID: &str = @APP_ID@;
pub static PKGDATADIR: &str = @PKGDATADIR@;
pub static PROFILE: &str = @PROFILE@;
pub static NAME_SUFFIX: &str = @NAME_SUFFIX@;
pub static VERSION: &str = @VERSION@;
pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub static LOCALEDIR: &str = @LOCALEDIR@;
pub static DISTRO_NAME: &str = @DISTRO_NAME@;
pub static DISTRO_VERSION: &str = @DISTRO_VERSION@;
pub static DISTRO_ICON_NAME: &str = @DISTRO_ICON_NAME@;
src/widgets/headerbar.rs
View file @
8d0ad447
...
...
@@ -4,6 +4,7 @@ use gtk::prelude::*;
pub
struct
HeaderBar
{
pub
widget
:
gtk
::
Stack
,
headerbar
:
gtk
::
HeaderBar
,
title
:
gtk
::
Label
,
next_btn
:
gtk
::
Button
,
}
...
...
@@ -11,16 +12,17 @@ impl HeaderBar {
pub
fn
new
()
->
Self
{
let
widget
=
gtk
::
Stack
::
new
();
let
headerbar
=
gtk
::
HeaderBar
::
new
();
let
title
=
gtk
::
Label
::
new
(
None
);
let
next_btn
=
gtk
::
Button
::
new
();
let
headerbar
=
Self
{
widget
,
headerbar
,
next_btn
};
let
headerbar
=
Self
{
widget
,
headerbar
,
title
,
next_btn
};
headerbar
.init
();
headerbar
}
pub
fn
start_tour
(
&
self
)
{
self
.widget
.set_visible_child_name
(
"pages"
);
self
.headerbar
.set_show_
title_buttons
(
false
);
self
.headerbar
.set_show_
close_button
(
false
);
}
pub
fn
set_page_nr
(
&
self
,
page_nr
:
i32
,
total_pages
:
i32
)
{
...
...
@@ -32,23 +34,26 @@ impl HeaderBar {
}
pub
fn
set_page_title
(
&
self
,
title
:
&
str
)
{
self
.
headerbar
.set_title
(
Some
(
title
)
);
self
.
title
.set_label
(
title
);
}
pub
fn
end_tour
(
&
self
)
{
self
.widget
.set_visible_child_name
(
"welcome"
);
self
.headerbar
.set_show_
title_buttons
(
true
);
self
.headerbar
.set_show_
close_button
(
true
);
}
fn
init
(
&
self
)
{
self
.headerbar
.set_show_title_buttons
(
true
);
self
.headerbar
.set_show_close_button
(
true
);
self
.headerbar
.set_custom_title
(
Some
(
&
self
.title
));
self
.title
.get_style_context
()
.add_class
(
"title"
);
self
.widget
.set_hexpand
(
true
);
self
.widget
.set_transition_type
(
gtk
::
StackTransitionType
::
SlideLeftRight
);
self
.widget
.set_transition_duration
(
300
);
self
.widget
.get_style_context
()
.add_class
(
"titlebar"
);
let
container
=
gtk
::
HeaderBar
::
new
();
container
.set_show_
title_buttons
(
true
);
container
.set_show_
close_button
(
true
);
container
.set_title
(
Some
(
&
gettext
(
"Welcome Tour"
)));
self
.widget
.add_named
(
&
container
,
"welcome"
);
...
...
src/widgets/pages/image.rs
View file @
8d0ad447
...
...
@@ -52,7 +52,7 @@ impl ImagePageWidget {
container
.set_valign
(
gtk
::
Align
::
Center
);
container
.set_property_margin
(
48
);
let
image
=
gtk
::
Picture
::
new_for_resource
(
Some
(
&
self
.resource_uri
)
);
let
image
=
gtk
::
Image
::
new_from_resource
(
&
self
.resource_uri
);
image
.set_valign
(
gtk
::
Align
::
Start
);
container
.add
(
&
image
);
...
...
src/widgets/pages/welcome.rs
View file @
8d0ad447
...
...
@@ -22,7 +22,7 @@ impl WelcomePageWidget {
self
.widget
.set_margin_top
(
24
);
self
.widget
.set_margin_bottom
(
24
);
let
logo
=
gtk
::
Image
::
new_from_icon_name
(
Some
(
config
::
DISTRO_ICON_NAME
));
let
logo
=
gtk
::
Image
::
new_from_icon_name
(
Some
(
config
::
DISTRO_ICON_NAME
)
,
gtk
::
IconSize
::
Dialog
);
logo
.set_pixel_size
(
196
);
self
.widget
.add
(
&
logo
);
...
...
src/widgets/paginator.rs
View file @
8d0ad447
...
...
@@ -28,7 +28,7 @@ impl PaginatorWidget {
}
pub
fn
get_current_page_nr
(
&
self
)
->
i32
{
self
.current_page
.borrow
()
.clone
()
*
self
.current_page
.borrow
()
}
pub
fn
get_current_page
(
&
self
)
->
Option
<&
Box
<
dyn
Pageable
>>
{
...
...
@@ -37,12 +37,12 @@ impl PaginatorWidget {
}
pub
fn
next
(
&
self
)
{
let
next_page
=
self
.current_page
.borrow
()
.clone
()
+
1
;
let
next_page
=
*
self
.current_page
.borrow
()
+
1
;
self
.go_to
(
next_page
);
}
pub
fn
previous
(
&
self
)
{
let
previous_page
=
self
.current_page
.borrow
()
.clone
()
-
1
;
let
previous_page
=
*
self
.current_page
.borrow
()
-
1
;
self
.go_to
(
previous_page
);
}
...
...
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