3
# Copyright (c) 2008 Canonical
5
# Author: Tollef Fog Heen <tfheen@err.no>
6
# Emmet Hikory <persia@ubuntu.com>
7
# Michael Vogt <mvo@ubuntu.com>
9
# This program is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License as
11
# published by the Free Software Foundation; either version 2 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program; if not, write to the Free Software
21
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24
from UpdateManager.UpdateManager import UpdateManager
33
from gettext import gettext as _
34
from UpdateManager.Common.utils import *
40
# actions for "invoke_manager"
41
(INSTALL, UPDATE) = range(2)
43
# DistUpgrade.DistUpgradeViewGtk.GtkInstallProgressAdapter is better,
44
# but requires more effort, and vte. This is a simpler implementation.
46
from DistUpgrade.DistUpgradeViewGtk import DistUpgradeViewGtk, GtkFetchProgressAdapter, GtkInstallProgressAdapter
47
from DistUpgrade.DistUpgradeView import (STEP_PREPARE,
55
class HildonFetchProgress(GtkFetchProgressAdapter):
56
def __init__(self, parent, header, msg):
57
GtkFetchProgressAdapter.__init__(self, parent)
59
for i in range(1,STEP_N):
61
parent.label_title.set_markup("<b><big>%s</big></b>" % header)
63
GtkFetchProgressAdapter.start(self)
64
# this is only needed when a InstallProgressAdapter is used
65
# in addition to the FetchProgress one - they share the
67
self.parent.setStep(STEP_FETCH)
69
class HildonInstallProgressAdapter(GtkInstallProgressAdapter):
70
def __init__(self, parent, header, msg):
71
GtkInstallProgressAdapter.__init__(self, parent)
72
# hide step not relevant
73
for i in (STEP_PREPARE,
78
# and show only those two
82
parent.label_title.set_markup("<b><big>%s</big></b>" % header)
83
def startUpdate(self):
84
GtkInstallProgressAdapter.startUpdate(self)
85
self.parent.setStep(STEP_INSTALL)
87
class UpdateManagerHildon(UpdateManager):
89
def __init__(self, datadir):
90
UpdateManager.__init__(self, datadir)
91
self.program = hildon.Program()
92
self.program.__init__()
94
self.window = hildon.Window()
95
self.window.set_title("PyGlade")
96
self.program.add_window(self.window)
97
#print dir(self.glade)
98
for widget in [ "window_main", "dialog_release_notes", "window_fetch",
99
"dialog_manual_update", "dialog_cacheprogress",
100
"dialog_dist_upgrade" ]:
101
self.glade.get_widget(widget).reparent(self.window)
104
# FIXME: below is still too much duplicated code m'kay
105
def invoke_manager(self, action):
106
# don't display apt-listchanges, we already showed the changelog
107
os.environ["APT_LISTCHANGES_FRONTEND"]="none"
108
os.environ["DEBIAN_FRONTEND"] = "noninteractive"
109
# Do not suspend during the update process
110
(dev, cookie) = inhibit_sleep()
111
# set window to insensitive
112
self.window_main.set_sensitive(False)
113
self.window_main.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
115
self.run_synaptic(None, action, None)
117
s = _("Reading package information")
118
self.label_cache_progress_title.set_label("<b><big>%s</big></b>" % s)
121
# Allow suspend after synaptic is finished
123
allow_sleep(dev, cookie)
124
self.window_main.set_sensitive(True)
125
self.window_main.window.set_cursor(None)
128
def run_synaptic(self, id, action, lock):
130
apt_pkg.PkgSystemUnLock()
134
if self.view == None:
135
self.view = DistUpgradeViewGtk("/usr/share/update-manager")
136
self.view.window_main.set_transient_for(self.window_main)
138
fprogress = HildonFetchProgress(self.view,
139
_("Downloading Package Information"),
140
_("The repositories will be checked for new, removed, or "
141
"updated software packages"))
142
self.view.window_main.show()
144
# FIXME: add error handling (commit() and update() both can
146
if action == INSTALL:
147
iprogress = HildonInstallProgressAdapter(self.view,
148
_("Downloading Package Updates"),
149
_("The selected package updates are being downloaded and "
150
"installed on the system"))
151
self.cache.commit(fprogress, iprogress)
152
elif action == UPDATE:
153
self.cache.update(fprogress)
155
print _("run_synaptic called with unknown action")
157
self.view.window_main.hide()