Verified Kaydet (Commit) 1aca5eaa authored tarafından Erdem Ersoy's avatar Erdem Ersoy

Add Cancel button for (un)installing and updating

üst 71714c78
...@@ -94,6 +94,9 @@ class InstallWindow(object): ...@@ -94,6 +94,9 @@ class InstallWindow(object):
self.InstallWindow.set_title(_("Installing...")) self.InstallWindow.set_title(_("Installing..."))
self.InstallWindow.show() self.InstallWindow.show()
self.InstallButtonCancel = install_builder.get_object("ActionButtonCancel")
self.InstallButtonCancel.set_sensitive(True)
self.InstallProgressBar = install_builder.get_object( self.InstallProgressBar = install_builder.get_object(
"ActionProgressBar") "ActionProgressBar")
self.ProgressBarValue = int(self.InstallProgressBar.get_fraction() * 100) self.ProgressBarValue = int(self.InstallProgressBar.get_fraction() * 100)
...@@ -142,7 +145,11 @@ class InstallWindow(object): ...@@ -142,7 +145,11 @@ class InstallWindow(object):
GLib.idle_add(self.InstallTextBuffer.set_text, GLib.idle_add(self.InstallTextBuffer.set_text,
self.StatusText, self.StatusText,
priority=GLib.PRIORITY_DEFAULT) priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
self.disconnect_handlers(handler_id_cancel) self.disconnect_handlers(handler_id_cancel)
GLib.idle_add(self.InstallButtonCancel.set_sensitive,
False,
priority=GLib.PRIORITY_DEFAULT)
def install_progress_callback(self, transaction, operation, progress): def install_progress_callback(self, transaction, operation, progress):
ref_to_install = Flatpak.Ref.parse(operation.get_ref()) ref_to_install = Flatpak.Ref.parse(operation.get_ref())
...@@ -251,6 +258,10 @@ class InstallWindow(object): ...@@ -251,6 +258,10 @@ class InstallWindow(object):
self.FlatpakTransaction.disconnect(self.handler_id_2) self.FlatpakTransaction.disconnect(self.handler_id_2)
self.FlatpakTransaction.disconnect(self.handler_id_error) self.FlatpakTransaction.disconnect(self.handler_id_error)
def on_press_cancel(self, button):
self.InstallCancellation.cancel()
self.InstallWindow.hide_on_delete()
def on_delete_action_window(self, widget, event): def on_delete_action_window(self, widget, event):
self.InstallCancellation.cancel() self.InstallCancellation.cancel()
widget.hide_on_delete() widget.hide_on_delete()
...@@ -93,6 +93,9 @@ class UninstallWindow(object): ...@@ -93,6 +93,9 @@ class UninstallWindow(object):
self.UninstallWindow.set_title(_("Uninstalling...")) self.UninstallWindow.set_title(_("Uninstalling..."))
self.UninstallWindow.show() self.UninstallWindow.show()
self.UninstallButtonCancel = uninstall_builder.get_object("ActionButtonCancel")
self.UninstallButtonCancel.set_sensitive(True)
self.UninstallProgressBar = uninstall_builder.get_object( self.UninstallProgressBar = uninstall_builder.get_object(
"ActionProgressBar") "ActionProgressBar")
self.ProgressBarValue = int( self.ProgressBarValue = int(
...@@ -143,7 +146,11 @@ class UninstallWindow(object): ...@@ -143,7 +146,11 @@ class UninstallWindow(object):
GLib.idle_add(self.UninstallTextBuffer.set_text, GLib.idle_add(self.UninstallTextBuffer.set_text,
self.StatusText, self.StatusText,
priority=GLib.PRIORITY_DEFAULT) priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
self.disconnect_handlers(handler_id_cancel) self.disconnect_handlers(handler_id_cancel)
GLib.idle_add(self.UninstallButtonCancel.set_sensitive,
False,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.5) time.sleep(0.5)
if self.ButtonNotPressedAlready: if self.ButtonNotPressedAlready:
...@@ -268,6 +275,10 @@ class UninstallWindow(object): ...@@ -268,6 +275,10 @@ class UninstallWindow(object):
self.FlatpakTransaction.disconnect(self.handler_id_2) self.FlatpakTransaction.disconnect(self.handler_id_2)
self.FlatpakTransaction.disconnect(self.handler_id_error) self.FlatpakTransaction.disconnect(self.handler_id_error)
def on_press_cancel(self, button):
self.InstallCancellation.cancel()
self.UninstallWindow.hide_on_delete()
def on_delete_action_window(self, widget, event): def on_delete_action_window(self, widget, event):
self.UninstallCancellation.cancel() self.UninstallCancellation.cancel()
widget.hide_on_delete() widget.hide_on_delete()
...@@ -91,6 +91,9 @@ class UpdateAllWindow(object): ...@@ -91,6 +91,9 @@ class UpdateAllWindow(object):
self.UpdateAllWindow.set_title(_("Updating All")) self.UpdateAllWindow.set_title(_("Updating All"))
self.UpdateAllWindow.show() self.UpdateAllWindow.show()
self.UpdateAllButtonCancel = update_all_builder.get_object("ActionButtonCancel")
self.UpdateAllButtonCancel.set_sensitive(True)
self.UpdateAllProgressBar = update_all_builder.get_object( self.UpdateAllProgressBar = update_all_builder.get_object(
"ActionProgressBar") "ActionProgressBar")
self.ProgressBarValue = int( self.ProgressBarValue = int(
...@@ -146,7 +149,11 @@ class UpdateAllWindow(object): ...@@ -146,7 +149,11 @@ class UpdateAllWindow(object):
GLib.idle_add(self.UpdateAllTextBuffer.set_text, GLib.idle_add(self.UpdateAllTextBuffer.set_text,
self.StatusText, self.StatusText,
priority=GLib.PRIORITY_DEFAULT) priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
self.disconnect_handlers(handler_id_cancel) self.disconnect_handlers(handler_id_cancel)
GLib.idle_add(self.UpdateAllButtonCancel.set_sensitive,
False,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.5) time.sleep(0.5)
UpdateAllWindow.at_updating = False UpdateAllWindow.at_updating = False
...@@ -286,6 +293,10 @@ class UpdateAllWindow(object): ...@@ -286,6 +293,10 @@ class UpdateAllWindow(object):
self.FlatpakTransaction.disconnect(self.handler_id_2) self.FlatpakTransaction.disconnect(self.handler_id_2)
self.FlatpakTransaction.disconnect(self.handler_id_error) self.FlatpakTransaction.disconnect(self.handler_id_error)
def on_press_cancel(self, button):
self.InstallCancellation.cancel()
self.UpdateAllWindow.hide_on_delete()
def on_delete_action_window(self, widget, event): def on_delete_action_window(self, widget, event):
self.UpdateAllCancellation.cancel() self.UpdateAllCancellation.cancel()
widget.hide_on_delete() widget.hide_on_delete()
...@@ -38,8 +38,25 @@ Author: Erdem Ersoy ...@@ -38,8 +38,25 @@ Author: Erdem Ersoy
<property name="icon_name">document-save</property> <property name="icon_name">document-save</property>
<property name="show_menubar">False</property> <property name="show_menubar">False</property>
<signal name="delete-event" handler="on_delete_action_window" swapped="no"/> <signal name="delete-event" handler="on_delete_action_window" swapped="no"/>
<child> <child type="titlebar">
<placeholder/> <object class="GtkHeaderBar" id="ActionHeader">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="ActionButtonCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_press_cancel" swapped="no"/>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child> </child>
<child> <child>
<object class="GtkBox" id="ActionBox"> <object class="GtkBox" id="ActionBox">
......
Markdown is supported
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