Skip to content

Commit

Permalink
Add status icons, clean some warnings
Browse files Browse the repository at this point in the history
Signed-off-by: dmitry-erin <[email protected]>
  • Loading branch information
dmitry-erin committed Sep 3, 2024
1 parent 9735e95 commit 1b235bb
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/control_panel_gui.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
<file>icons/icon_arrow.svg</file>
<file>icons/icon_close.svg</file>
<file>icons/icon_download.svg</file>
<file>icons/ellipse_green.svg</file>
<file>icons/ellipse_yellow.svg</file>
<file>icons/ellipse_red.svg</file>
</gresource>
</gresources>
3 changes: 3 additions & 0 deletions src/icons/ellipse_green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/icons/ellipse_red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/icons/ellipse_yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 35 additions & 11 deletions src/ui/vm_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,39 @@
</object>
</child>
<child>
<object class="GtkLabel" id="vm_status_label">
<style><class name="normal-text"/></style>
<property name="label">No status</property>
<object class="GtkBox">
<style><class name="info-box"/></style>
<property name="orientation">horizontal</property>
<property name="margin-start">20</property>
<property name="margin-end">10</property>
<property name="margin-top">0</property>
<property name="margin-bottom">10</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="height-request">20</property>
<property name="vexpand">false</property>
<property name="hexpand">false</property>
<child>
<object class="GtkImage" id="vm_status_icon">
<property name="visible">true</property>
<property name="can_focus">false</property>
<property name="margin-top">0</property>
<property name="valign">center</property>
<property name="vexpand">false</property>
<property name="hexpand">false</property>
<property name="pixel-size">8</property>
</object>
</child>
<child>
<object class="GtkLabel" id="vm_status_label">
<style><class name="normal-text"/></style>
<property name="label">No status</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="xalign">0.0</property>
<property name="yalign">0.5</property>
</object>
</child>
</object>
</child>
<child>
Expand All @@ -56,9 +81,8 @@
<property name="margin-bottom">10</property>
<child>
<object class="GtkImage" id="security_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<!--<property name="resource">/org/gnome/controlpanelgui/icons/security_well.svg</property>-->
<property name="visible">true</property>
<property name="can_focus">false</property>
<property name="width-request">16</property>
<property name="height-request">20</property>
</object>
Expand All @@ -67,7 +91,7 @@
<object class="GtkLabel" id="security_label">
<style><class name="normal-text"/></style>
<property name="label">This VM is secure!</property>
<property name="margin-start">20</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
Expand Down
19 changes: 19 additions & 0 deletions src/vm_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ mod imp {
#[template_child]
pub vm_status_label: TemplateChild<Label>,
#[template_child]
pub vm_status_icon: TemplateChild<Image>,
#[template_child]
pub vm_details_label: TemplateChild<Label>,
#[template_child]
pub security_icon: TemplateChild<Image>,
Expand Down Expand Up @@ -155,6 +157,7 @@ impl VMSettings {
//make new
let name = self.imp().vm_name_label.get();
let status = self.imp().vm_status_label.get();
let status_icon = self.imp().vm_status_icon.get();
let details = self.imp().vm_details_label.get();
let security_icon = self.imp().security_icon.get();
let security_label = self.imp().security_label.get();
Expand Down Expand Up @@ -185,6 +188,22 @@ impl VMSettings {
// Save binding
bindings.push(status_binding);

let status_icon_binding = vm_object
.bind_property("status", &status_icon, "resource")
.sync_create()
.transform_to(move |_, value: &glib::Value| {
let status = value.get::<u8>().unwrap_or(0);
match status {//make struct like for icon?
0 => Some(glib::Value::from("/org/gnome/controlpanelgui/icons/ellipse_green.svg")),
1 => Some(glib::Value::from("/org/gnome/controlpanelgui/icons/ellipse_red.svg")),
2 => Some(glib::Value::from("/org/gnome/controlpanelgui/icons/ellipse_yellow.svg")),
_ => Some(glib::Value::from("/org/gnome/controlpanelgui/icons/ellipse_red.svg")),
}
})
.build();
// Save binding
bindings.push(status_icon_binding);

let details_binding = vm_object
.bind_property("details", &details, "label")
.sync_create()
Expand Down

0 comments on commit 1b235bb

Please sign in to comment.