Skip to content

Commit

Permalink
Use AdwDialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Apr 5, 2024
1 parent faa22e4 commit 07dd202
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
6 changes: 2 additions & 4 deletions data/resources/ui/dialogs/app_dialog.ui
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ResAppDialog" parent="AdwWindow">
<template class="ResAppDialog" parent="AdwDialog">
<property name="width_request">360</property>
<property name="default_width">480</property>
<property name="height_request">600</property>
<property name="default_height">600</property>
<property name="modal">true</property>
<property name="content_width">480</property>
<property name="title" translatable="yes">Application Information</property>
<child>
<object class="GtkBox">
Expand Down
6 changes: 2 additions & 4 deletions data/resources/ui/dialogs/process_dialog.ui
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ResProcessDialog" parent="AdwWindow">
<template class="ResProcessDialog" parent="AdwDialog">
<property name="width_request">360</property>
<property name="default_width">480</property>
<property name="height_request">600</property>
<property name="default_height">600</property>
<property name="modal">true</property>
<property name="content_width">480</property>
<property name="title" translatable="yes">Process Information</property>
<child>
<object class="GtkBox">
Expand Down
8 changes: 3 additions & 5 deletions src/ui/dialogs/app_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use process_data::Containerization;

use crate::config::PROFILE;
use crate::i18n::i18n;
use crate::ui::window::MainWindow;
use crate::utils::app::AppItem;
use crate::utils::units::{convert_speed, convert_storage};

Expand Down Expand Up @@ -57,7 +56,7 @@ mod imp {
impl ObjectSubclass for ResAppDialog {
const NAME: &'static str = "ResAppDialog";
type Type = super::ResAppDialog;
type ParentType = adw::Window;
type ParentType = adw::Dialog;

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Expand All @@ -83,12 +82,12 @@ mod imp {

impl WidgetImpl for ResAppDialog {}
impl WindowImpl for ResAppDialog {}
impl AdwWindowImpl for ResAppDialog {}
impl AdwDialogImpl for ResAppDialog {}
}

glib::wrapper! {
pub struct ResAppDialog(ObjectSubclass<imp::ResAppDialog>)
@extends gtk::Widget, gtk::Window, adw::Window;
@extends gtk::Widget, adw::Dialog;
}

impl ResAppDialog {
Expand All @@ -97,7 +96,6 @@ impl ResAppDialog {
}

pub fn init(&self, app: &AppItem) {
self.set_transient_for(Some(&MainWindow::default()));
self.setup_widgets(app);
}

Expand Down
8 changes: 3 additions & 5 deletions src/ui/dialogs/process_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use process_data::Containerization;

use crate::config::PROFILE;
use crate::i18n::i18n;
use crate::ui::window::MainWindow;
use crate::utils::boot_time;
use crate::utils::process::ProcessItem;
use crate::utils::units::{convert_speed, convert_storage};
Expand Down Expand Up @@ -59,7 +58,7 @@ mod imp {
impl ObjectSubclass for ResProcessDialog {
const NAME: &'static str = "ResProcessDialog";
type Type = super::ResProcessDialog;
type ParentType = adw::Window;
type ParentType = adw::Dialog;

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Expand All @@ -85,12 +84,12 @@ mod imp {

impl WidgetImpl for ResProcessDialog {}
impl WindowImpl for ResProcessDialog {}
impl AdwWindowImpl for ResProcessDialog {}
impl AdwDialogImpl for ResProcessDialog {}
}

glib::wrapper! {
pub struct ResProcessDialog(ObjectSubclass<imp::ResProcessDialog>)
@extends gtk::Widget, gtk::Window, adw::Window;
@extends gtk::Widget, adw::Dialog;
}

impl ResProcessDialog {
Expand All @@ -99,7 +98,6 @@ impl ResProcessDialog {
}

pub fn init<S: AsRef<str>>(&self, process: &ProcessItem, user: S) {
self.set_transient_for(Some(&MainWindow::default()));
self.setup_widgets(process, user.as_ref());
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/applications/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl ResApplications {
let imp = self.imp();
let app_dialog = ResAppDialog::new();
app_dialog.init(app_item);
app_dialog.set_visible(true);
app_dialog.present(&MainWindow::default());
*imp.open_dialog.borrow_mut() =
Some((app_item.id.as_ref().map(|gs| gs.to_string()), app_dialog));
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/processes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl ResProcesses {
let imp = self.imp();
let process_dialog = ResProcessDialog::new();
process_dialog.init(process, self.get_user_name_by_uid(process.uid));
process_dialog.set_visible(true);
process_dialog.present(&MainWindow::default());
*imp.open_dialog.borrow_mut() = Some((process.pid, process_dialog));
}

Expand Down

0 comments on commit 07dd202

Please sign in to comment.