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
93f6a97f
Verified
Commit
93f6a97f
authored
Feb 04, 2025
by
Кирилл Уницаев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a button to the image-page widget
parent
f5b429d9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
4 deletions
+73
-4
image-page.ui
data/resources/ui/image-page.ui
+31
-0
window-gnome.ui
data/resources/ui/window-gnome.ui
+2
-0
window-hyprland.ui
data/resources/ui/window-hyprland.ui
+2
-0
image_page.rs
src/widgets/image_page.rs
+38
-4
No files found.
data/resources/ui/image-page.ui
View file @
93f6a97f
...
...
@@ -19,12 +19,14 @@
<property
name=
"margin-top"
>
12
</property>
<property
name=
"margin-start"
>
12
</property>
<property
name=
"margin-end"
>
12
</property>
<child>
<object
class=
"GtkPicture"
id=
"picture"
>
<property
name=
"can-shrink"
>
false
</property>
<property
name=
"content-fit"
>
contain
</property>
</object>
</child>
<child>
<object
class=
"GtkLabel"
id=
"head_label"
>
<property
name=
"label"
bind-source=
"ImagePageWidget"
bind-property=
"head"
/>
...
...
@@ -36,6 +38,7 @@
</style>
</object>
</child>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"label"
bind-source=
"ImagePageWidget"
bind-property=
"body"
/>
...
...
@@ -49,6 +52,34 @@
</style>
</object>
</child>
<child>
<object
class=
"GtkButton"
id=
"action_button"
>
<property
name=
"visible"
>
false
</property>
<property
name=
"halign"
>
center
</property>
<style>
<class
name=
"suggested-action, pill"
/>
</style>
<child>
<object
class=
"GtkBox"
>
<property
name=
"orientation"
>
horizontal
</property>
<property
name=
"spacing"
>
6
</property>
<child>
<object
class=
"GtkImage"
id=
"button_icon_widget"
>
<property
name=
"visible"
>
false
</property>
<property
name=
"icon-name"
bind-source=
"ImagePageWidget"
bind-property=
"button-icon"
/>
<property
name=
"pixel-size"
>
16
</property>
</object>
</child>
<child>
<object
class=
"GtkLabel"
id=
"button_label_widget"
>
<property
name=
"label"
bind-source=
"ImagePageWidget"
bind-property=
"button-label"
/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
...
...
data/resources/ui/window-gnome.ui
View file @
93f6a97f
...
...
@@ -9,6 +9,8 @@
<object
class=
"ImagePageWidget"
id=
"welcome_page"
>
<property
name=
"resource-uri"
>
/ru/ximperlinux/Welcome/base/welcome.svg
</property>
<property
name=
"head"
translatable=
"yes"
>
Welcome to GNOME
</property>
<property
name=
"button-label"
translatable=
"yes"
>
Open Wiki
</property>
<property
name=
"button-url"
>
https://wiki.ximperlinux.ru
</property>
</object>
</child>
<child>
...
...
data/resources/ui/window-hyprland.ui
View file @
93f6a97f
...
...
@@ -9,6 +9,8 @@
<object
class=
"ImagePageWidget"
id=
"welcome_page"
>
<property
name=
"resource-uri"
>
/ru/ximperlinux/Welcome/base/welcome.svg
</property>
<property
name=
"head"
translatable=
"yes"
>
Welcome to Hyprland
</property>
<property
name=
"button-label"
translatable=
"yes"
>
Open Wiki
</property>
<property
name=
"button-url"
>
https://wiki.ximperlinux.ru
</property>
</object>
</child>
<child>
...
...
src/widgets/image_page.rs
View file @
93f6a97f
use
gtk
::{
glib
,
prelude
::
*
,
subclass
::
prelude
::
*
};
use
gtk
::{
g
io
,
g
lib
,
prelude
::
*
,
subclass
::
prelude
::
*
};
mod
imp
{
use
std
::
cell
::{
OnceCell
,
RefCell
};
use
super
::
*
;
#[derive(Debug,
Default,
glib
::
Properties,
gtk
::
CompositeTemplate)]
#[properties(wrapper_type
=
super
::
ImagePageWidget)]
#[template(resource
=
"/ru/ximperlinux/Welcome/ui/image-page.ui"
)]
pub
struct
ImagePageWidget
{
#[property(get,
set=
Self
::
set_resource_uri,
construct_only)]
#[property(get,
set
=
Self
::
set_resource_uri,
construct_only)]
pub
(
super
)
resource_uri
:
OnceCell
<
String
>
,
#[property(get,
set,
construct_only)]
pub
(
super
)
head
:
OnceCell
<
String
>
,
#[property(get,
set,
construct)]
pub
(
super
)
body
:
RefCell
<
Option
<
String
>>
,
#[property(get,
set,
construct)]
pub
(
super
)
button_label
:
RefCell
<
Option
<
String
>>
,
#[property(get,
set,
construct)]
pub
(
super
)
button_icon
:
RefCell
<
Option
<
String
>>
,
#[property(get,
set,
construct)]
pub
(
super
)
button_url
:
RefCell
<
Option
<
String
>>
,
#[template_child]
pub
(
super
)
picture
:
TemplateChild
<
gtk
::
Picture
>
,
#[template_child]
pub
(
super
)
container
:
TemplateChild
<
gtk
::
Box
>
,
#[template_child]
pub
(
super
)
action_button
:
TemplateChild
<
gtk
::
Button
>
,
#[template_child]
pub
(
super
)
button_label_widget
:
TemplateChild
<
gtk
::
Label
>
,
#[template_child]
pub
(
super
)
button_icon_widget
:
TemplateChild
<
gtk
::
Image
>
,
}
#[glib
::
object_subclass]
...
...
@@ -28,9 +40,10 @@ mod imp {
type
Type
=
super
::
ImagePageWidget
;
fn
class_init
(
klass
:
&
mut
Self
::
Class
)
{
klass
.bind_template
();
klass
.set_layout_manager_type
::
<
adw
::
ClampLayout
>
();
klass
.bind_template
();
}
fn
instance_init
(
obj
:
&
glib
::
subclass
::
InitializingObject
<
Self
>
)
{
obj
.init_template
();
}
...
...
@@ -38,10 +51,31 @@ mod imp {
#[glib
::
derived_properties]
impl
ObjectImpl
for
ImagePageWidget
{
fn
constructed
(
&
self
)
{
if
let
Some
(
label
)
=
self
.button_label
.borrow
()
.clone
()
{
self
.button_label_widget
.set_label
(
&
label
);
self
.action_button
.set_visible
(
true
);
}
if
let
Some
(
icon_name
)
=
self
.button_icon
.borrow
()
.as_ref
()
{
let
button_icon_widget
=
self
.button_icon_widget
.get
();
button_icon_widget
.set_visible
(
true
);
button_icon_widget
.set_icon_name
(
Some
(
&
icon_name
));
}
if
let
Some
(
url
)
=
self
.button_url
.borrow
()
.clone
()
{
let
button
=
self
.action_button
.get
();
button
.connect_clicked
(
move
|
_
|
{
let
_
=
gio
::
AppInfo
::
launch_default_for_uri
(
&
url
,
None
::
<&
gio
::
AppLaunchContext
>
);
});
}
}
fn
dispose
(
&
self
)
{
self
.container
.unparent
();
}
}
impl
WidgetImpl
for
ImagePageWidget
{}
impl
ImagePageWidget
{
...
...
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