Commit 997a8b01 authored by Danial Behzadi's avatar Danial Behzadi
Browse files

add cancel button for progress

parent 27d28fe7
......@@ -6,7 +6,6 @@
actions for carburetor
'''
import os
import re
from subprocess import PIPE, Popen
......@@ -86,6 +85,8 @@ def on_connect(action, param, app):
app.spinner = ui.get('Spinner')
app.spinner.start()
app.spinner.show()
stop_button = ui.get('StopButton')
stop_button.set_visible(True)
main_label = ui.get('MainLabel')
if functions.is_running():
text_stopping = config._("Disconnecting…")
......@@ -98,7 +99,9 @@ def on_connect(action, param, app):
app.task = Popen(
config.COMMAND + action,
stdout=PIPE, shell=True,
preexec_fn=os.setsid)
start_new_session=True)
if action == 'start':
config.dconf.set_int('pid', app.task.pid)
app.io_id = GLib.io_add_watch(
app.task.stdout, GLib.IO_IN,
functions.set_progress)
......
......@@ -12,8 +12,8 @@ import gi
gi.require_versions({'Gtk': '3.0'})
from gi.repository import Gtk
from . import ui
from . import actions
from . import ui
class Application(Gtk.Application):
......
......@@ -26,7 +26,7 @@ _ = gettext.gettext
COMMAND = "tractor "
app_name = _("Carburetor")
app_comment = _("Settings for Tractor")
VERSION = "3.4"
VERSION = "3.5"
GLib.set_application_name(app_name)
Notify.init(app_name)
......
......@@ -71,18 +71,22 @@ def set_to_stopped(app):
set status to stopped
'''
image = ui.get('MainImage')
image.set_from_icon_name('process-stop', Gtk.IconSize.DIALOG)
image.set_from_icon_name('process-stop-symbolic', Gtk.IconSize.DIALOG)
image.show()
label = ui.get('MainLabel')
label.set_label(config._("Stopped"))
button = ui.get('ConnectButton')
text_start = config._("_Connect")
button.set_label(text_start)
style = button.get_style_context()
style.remove_class('red')
style.add_class('green')
button.set_label(text_start)
button = ui.get('ActionMenuButton')
button.set_sensitive(False)
button = ui.get('StopButton')
button.set_visible(False)
dconf = config.dconf
dconf.reset('pid')
if app:
app.notification = config._("Tractor is stopped")
......@@ -104,6 +108,8 @@ def set_to_running(app):
button.set_label(text_stop)
button = ui.get('ActionMenuButton')
button.set_sensitive(True)
button = ui.get('StopButton')
button.set_visible(False)
if app:
app.notification = config._("Tractor is running")
......
......@@ -6,6 +6,8 @@
handlers for ui events
"""
import os
import signal
from subprocess import PIPE, Popen
from gi.repository import Gio, Gtk
......@@ -25,6 +27,12 @@ class Handler:
def on_SetProxyItem_realize(self, item):
functions.set_checkbox()
def on_StopButton_clicked(self, button):
dconf = config.dconf
pid = dconf.get_int('pid')
os.killpg(os.getpgid(pid), signal.SIGTERM)
dconf.reset('pid')
def on_ActionExitNode_realize(self, combo):
_ = config._
nodes = {
......
......@@ -103,7 +103,7 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
<object class="GtkImage" id="MainImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">process-stop</property>
<property name="icon-name">process-stop-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
......@@ -123,12 +123,41 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
</packing>
</child>
<child>
<object class="GtkLabel" id="MainLabel">
<object class="GtkBox" id="StatusBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stopped</property>
<property name="wrap">True</property>
<property name="ellipsize">middle</property>
<child>
<object class="GtkLabel" id="MainLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stopped</property>
<property name="ellipsize">middle</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="StopButton">
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<signal name="clicked" handler="on_StopButton_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">close-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......
carburetor (3.5) hirsute; urgency=medium
* Add a cancel button for progress
-- Danial Behzadi <dani.behzi@ubuntu.com> Thu, 10 Jun 2021 06:25:00 +0430
carburetor (3.4) hirsute; urgency=medium
* Some refactors and lintings
......
......@@ -7,7 +7,7 @@ Build-Depends: debhelper (>=9), dh-python, python3-all, python3-setuptools
Package: carburetor
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, tractor (>=2.4-0~), python3, python3-gi(>=3.10.2), python3-gi-cairo, gir1.2-gtk-3.0, python3-distutils, gir1.2-handy-1
Depends: ${shlibs:Depends}, ${misc:Depends}, tractor (>=3.8~), python3, python3-gi(>=3.10.2), python3-gi-cairo, gir1.2-gtk-3.0, python3-distutils, gir1.2-handy-1
Description: Settings app for Tractor
This package is a graphical settings for tractor
which is an app using Python stem to provide
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment