[gnome-usage] quit-process-dialog: Introduce the Quit Process Dialog
- From: Petr Štětka <pstetka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-usage] quit-process-dialog: Introduce the Quit Process Dialog
- Date: Mon, 6 Nov 2017 07:25:55 +0000 (UTC)
commit 9a1a1f1efc43801cef369d0d38ea1e60bfa92fec
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Nov 1 16:55:44 2017 +0100
quit-process-dialog: Introduce the Quit Process Dialog
According to the mockups at
https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/usage/usage-performance.png
Solves #22
data/org.gnome.Usage.gresource.xml | 2 +-
data/ui/process-dialog.ui | 24 ------
data/ui/quit-process-dialog.ui | 37 ++++++++
src/meson.build | 2 +-
src/process-dialog.vala | 159 ------------------------------------
src/process-row.vala | 2 +-
src/quit-process-dialog.vala | 52 ++++++++++++
src/sub-process-sub-row.vala | 2 +-
8 files changed, 93 insertions(+), 187 deletions(-)
---
diff --git a/data/org.gnome.Usage.gresource.xml b/data/org.gnome.Usage.gresource.xml
index 84e4e4d..2f0e1a6 100644
--- a/data/org.gnome.Usage.gresource.xml
+++ b/data/org.gnome.Usage.gresource.xml
@@ -5,7 +5,7 @@
<file preprocess="xml-stripblanks">ui/header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/no-results-found-view.ui</file>
<file preprocess="xml-stripblanks">ui/performance-view.ui</file>
- <file preprocess="xml-stripblanks">ui/process-dialog.ui</file>
+ <file preprocess="xml-stripblanks">ui/quit-process-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/storage-actionbar.ui</file>
<file preprocess="xml-stripblanks">ui/storage-view.ui</file>
<file preprocess="xml-stripblanks">ui/process-row.ui</file>
diff --git a/data/ui/quit-process-dialog.ui b/data/ui/quit-process-dialog.ui
new file mode 100644
index 0000000..cb73ecd
--- /dev/null
+++ b/data/ui/quit-process-dialog.ui
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+
+ <template class="UsageQuitProcessDialog" parent="GtkMessageDialog">
+ <property name="modal">True</property>
+ <property name="resizable">False</property>
+ <property name="message-type">question</property>
+ <property name="text" translatable="yes" comments="Translators: This sentence is later suffixed with an
application name. Example: 'Force Quit Videos?'">Force Quit %s?</property>
+ <property name="secondary-text">Usaved work might be lost.</property>
+
+ <child type="action">
+ <object class="GtkButton" id="button_cancel">
+ <property name="visible">True</property>
+ <property name="can-default">True</property>
+ <property name="label" translatable="yes">Cancel</property>
+ <signal name="clicked" handler="cancel" swapped="no"/>
+ </object>
+ </child>
+
+ <child type="action">
+ <object class="GtkButton" id="button_force_quit">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Force Quit</property>
+ <signal name="clicked" handler="on_force_quit_button_clicked"/>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ </child>
+
+ <action-widgets>
+ <action-widget response="accept">button_force_quit</action-widget>
+ <action-widget response="cancel">button_cancel</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index cdf1bb3..22a2d8a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -21,10 +21,10 @@ vala_sources = [
'no-results-found-view.vala',
'performance-view.vala',
'pie-chart.vala',
- 'process-dialog.vala',
'process-list-box.vala',
'process-row.vala',
'process.vala',
+ 'quit-process-dialog.vala',
'settings.vala',
'storage-actionbar.vala',
'storage-analyzer.vala',
diff --git a/src/process-row.vala b/src/process-row.vala
index b4ca3ae..29524b5 100644
--- a/src/process-row.vala
+++ b/src/process-row.vala
@@ -218,7 +218,7 @@ namespace Usage
}
else
{
- var dialog = new ProcessDialog(process.pid, process.display_name, process.cmdline);
+ var dialog = new QuitProcessDialog(process.pid, process.display_name);
dialog.show_all();
}
}
diff --git a/src/quit-process-dialog.vala b/src/quit-process-dialog.vala
new file mode 100644
index 0000000..46e78e4
--- /dev/null
+++ b/src/quit-process-dialog.vala
@@ -0,0 +1,52 @@
+/* quit-process-dialog.vala
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Felipe Borges <felipeborges gnome org>
+ */
+
+using Gtk;
+
+namespace Usage
+{
+ [GtkTemplate (ui = "/org/gnome/Usage/ui/quit-process-dialog.ui")]
+ public class QuitProcessDialog : Gtk.MessageDialog
+ {
+ Pid pid { set; get; }
+
+ public QuitProcessDialog(Pid pid, string app_name)
+ {
+ this.text = this.text.printf(app_name);
+ }
+
+ [GtkCallback]
+ private void on_force_quit_button_clicked ()
+ {
+ debug ("Terminating %d", (int) this.pid);
+ Posix.kill(this.pid, Posix.SIGKILL);
+
+ this.destroy();
+ }
+
+ [GtkCallback]
+ public void cancel ()
+ {
+ /* FIXME: For some reason we are not able to connect to the
+ * destroy signal right from the .ui file. */
+ this.destroy();
+ }
+ }
+}
diff --git a/src/sub-process-sub-row.vala b/src/sub-process-sub-row.vala
index 77d13e8..eba1b32 100644
--- a/src/sub-process-sub-row.vala
+++ b/src/sub-process-sub-row.vala
@@ -93,7 +93,7 @@ namespace Usage
public new void activate()
{
- var dialog = new ProcessDialog(process.pid, process.cmdline, process.cmdline);
+ var dialog = new QuitProcessDialog(process.pid, process.cmdline);
dialog.show_all();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]