[Rigo/RigoDaemon] implement transaction state update notifications

This commit is contained in:
Fabio Erculiani
2012-03-26 10:00:29 +02:00
parent 72def71a07
commit ee25f790af
6 changed files with 104 additions and 15 deletions

View File

@@ -61,7 +61,7 @@ from entropy.core.settings.base import SystemSettings
import entropy.tools
from RigoDaemon.enums import ActivityStates, AppActions, \
AppTransactionOutcome
AppTransactionOutcome, AppTransactionStates
from RigoDaemon.config import DbusConfig
TEXT = TextInterface()
@@ -516,12 +516,22 @@ class RigoDaemonService(dbus.service.Object):
outcome = AppTransactionOutcome.INTERNAL_ERROR
try:
self.activity_progress(activity, 0)
self.application_processing_update(
package_id, repository_id,
AppTransactionStates.DOWNLOAD, 50)
# FIXME, complete
# simulate
self._entropy.output("Application Management Message")
time.sleep(2.5)
self.activity_progress(activity, 50)
time.sleep(2.5)
time.sleep(20.0)
self.application_processing_update(
package_id, repository_id,
AppTransactionStates.MANAGE, 100)
self._entropy.output("Application Management Complete")
outcome = AppTransactionOutcome.SUCCESS
finally:
@@ -881,11 +891,26 @@ class RigoDaemonService(dbus.service.Object):
Signal all the connected Clients that we're currently
processing the given Application.
"""
write_output("processing_application(): %d,"
write_output("processing_application(): %i,"
"%s, action: %s" % (
package_id, repository_id, action,),
debug=True)
@dbus.service.signal(dbus_interface=BUS_NAME,
signature='issi')
def application_processing_update(self, package_id, repository_id,
app_transaction_state, progress):
"""
Signal all the connected Clients an Application processing
update.
"""
write_output("application_processing_update(): %i,"
"%s, transaction_state: %s, progress: %i" % (
package_id, repository_id,
app_transaction_state,
progress,),
debug=True)
@dbus.service.signal(dbus_interface=BUS_NAME,
signature='isss')
def application_processed(self, package_id, repository_id,

View File

@@ -44,12 +44,19 @@ class ActivityStates:
class AppActions:
""" Application Transaction States """
""" Application Transaction Actions """
INSTALL = "install"
REMOVE = "remove"
IDLE = "idle"
class AppTransactionStates:
""" Application Transaction States """
DOWNLOAD = "download"
MANAGE = "manage"
class AppTransactionOutcome:
SUCCESS = "success"

View File

@@ -52,11 +52,13 @@ class AppListStore(Gtk.ListStore):
),
}
def __init__(self, entropy_client, entropy_ws, view, icons):
def __init__(self, entropy_client, entropy_ws, rigo_service,
view, icons):
Gtk.ListStore.__init__(self)
self._view = view
self._entropy = entropy_client
self._entropy_ws = entropy_ws
self._service = rigo_service
self._icons = icons
self.set_column_types(self.COL_TYPES)
@@ -249,6 +251,9 @@ class AppListStore(Gtk.ListStore):
return app
def get_transaction_progress(self, pkg_match):
# FIXME, lxnay complete this
# int from 0 - 100, or -1 for no transaction
return -1
app, state, progress = self._service.get_transaction_state()
if app is None:
return -1
if app.get_details().pkg != pkg_match:
return -1
return progress

View File

@@ -204,7 +204,8 @@ class AppTreeView(Gtk.TreeView):
btn_h = btn.height
tr.normal_height = max(32 + 4*ypad, em(2.5) + 4*ypad)
tr.selected_height = tr.normal_height + btn_h + StockEms.MEDIUM
tr.selected_height = tr.normal_height + btn_h + StockEms.MEDIUM \
+ ypad
return
def _on_style_updated(self, widget, tr):

View File

@@ -187,7 +187,7 @@ class CellRendererAppView(Gtk.CellRendererText):
else:
x = cell_area.x+cell_area.width-lw-self.pixbuf_width-2*xpad
y = cell_area.y+ypad
y = cell_area.y + ypad
Gtk.render_layout(context, cr, x, y, layout)
return
@@ -239,8 +239,9 @@ class CellRendererAppView(Gtk.CellRendererText):
action_btn = self.get_button_by_name(CellButtonIDs.ACTION)
x, _, w, h = action_btn.allocation
# shift the bar to the top edge
y = cell_area.y + ypad
# shift the bar under the rating info
y = cell_area.y + ypad + self.apptitle_height + self.STAR_SIZE
y += ypad
context.save()
context.add_class("trough")
@@ -268,7 +269,7 @@ class CellRendererAppView(Gtk.CellRendererText):
is_rtl, is_available):
# layout buttons and paint
y = cell_area.y+cell_area.height-ypad
y = cell_area.y + cell_area.height - ypad
spacing = self.button_spacing
if not is_rtl:

View File

@@ -179,6 +179,7 @@ class RigoServiceController(GObject.Object):
_ACTIVITY_PROGRESS_SIGNAL = "activity_progress"
_ACTIVITY_COMPLETED_SIGNAL = "activity_completed"
_PROCESSING_APPLICATION_SIGNAL = "processing_application"
_APPLICATION_PROCESSING_UPDATE = "application_processing_update"
_APPLICATION_PROCESSED_SIGNAL = "application_processed"
_APPLICATIONS_MANAGED_SIGNAL = "applications_managed"
_SUPPORTED_APIS = [0]
@@ -208,6 +209,9 @@ class RigoServiceController(GObject.Object):
self._local_activity = LocalActivityStates.READY
self._local_activity_mutex = Lock()
self._daemon_activity_progress = 0
self._daemon_transaction_app = None
self._daemon_transaction_app_state = None
self._daemon_transaction_app_progress = -1
self._please_wait_box = None
self._please_wait_mutex = Lock()
@@ -426,6 +430,13 @@ class RigoServiceController(GObject.Object):
self._processing_application_signal,
dbus_interface=self.DBUS_INTERFACE)
# RigoDaemon tells us about an Application
# processing status update
self.__entropy_bus.connect_to_signal(
self._APPLICATION_PROCESSING_UPDATE,
self._application_processing_update_signal,
dbus_interface=self.DBUS_INTERFACE)
# RigoDaemon tells us that a queued app action
# is now complete
self.__entropy_bus.connect_to_signal(
@@ -470,17 +481,40 @@ class RigoServiceController(GObject.Object):
(package_id, repository_id),
redraw_callback=_redraw_callback)
self._wc.set_application(app, daemon_action)
self._daemon_transaction_app = app
self._daemon_transaction_app_state = None
self._daemon_transaction_app_progress = 0
self.emit("application-processing", app, daemon_action)
def _application_processing_update_signal(
self, package_id, repository_id, app_transaction_state,
progress):
const_debug_write(
__name__,
"_application_processing_update_signal: received for "
"%i, %s, transaction_state: %s, progress: %i" % (
package_id, repository_id,
app_transaction_state, progress))
app = Application(
self._entropy, self._entropy_ws,
(package_id, repository_id))
self._daemon_transaction_app = app
self._daemon_transaction_app_progress = progress
self._daemon_transaction_app_state = app_transaction_state
def _application_processed_signal(self, package_id, repository_id,
daemon_action, app_outcome):
const_debug_write(
__name__,
"_application_processed_signal: received for "
"%d, %s, action: %s, outcome: %s" % (
"%i, %s, action: %s, outcome: %s" % (
package_id, repository_id, daemon_action, app_outcome))
self._daemon_transaction_app = None
self._daemon_transaction_app_progress = -1
self._daemon_transaction_app_state = None
app = Application(
self._entropy, self._entropy_ws,
(package_id, repository_id),
@@ -826,6 +860,22 @@ class RigoServiceController(GObject.Object):
### GP PUBLIC METHODS
def get_transaction_state(self):
"""
Return current RigoDaemon Application transaction
state information, if available.
"""
app = self._daemon_transaction_app
state = self._daemon_transaction_app_state
progress = self._daemon_transaction_app_progress
if app is None:
state = None
progress = -1
if state is None:
app = None
progress = -1
return app, state, progress
def application_request(self, app, app_action):
"""
Start Application Action (install/remove).
@@ -2243,7 +2293,7 @@ class Rigo(Gtk.Application):
self._app_store = AppListStore(
self._entropy, self._entropy_ws,
self._view, icons)
self._service, self._view, icons)
def _queue_draw(*args):
self._view.queue_draw()
self._app_store.connect("redraw-request", _queue_draw)