~ubuntu-branches/ubuntu/saucy/install-package/saucy

« back to all changes in this revision

Viewing changes to install-package.py

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2009-08-20 23:05:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090820230536-epdlmo96k5u6lwlm
Tags: 0.4.1
Make install-package attachable to another window (similar to kdesudo)
This enables better use by applications like AptUrl

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        self._block = False
95
95
 
96
96
class MainWindow (QDialog):
97
 
    def __init__ (self, mode, packages):
 
97
    def __init__ (self, mode, packages, attach=None):
98
98
        QDialog.__init__ (self)
99
99
 
100
100
        if os.path.exists("install-package.ui"):
157
157
        self.connect(self.buttonBox, SIGNAL("clicked(QAbstractButton*)"), self.quit)
158
158
        QTimer.singleShot(10, self.resizing)
159
159
 
 
160
        if attach != None:
 
161
            KWindowSystem.setMainWindow(self, attach)
 
162
 
160
163
    def quit(self):
161
164
        self.hide()
162
165
        sys.exit() #QApplication.exit() causes a crash :(
252
255
    aboutData   = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
253
256
 
254
257
    options = KCmdLineOptions()
 
258
    options.add("attach <winid>", ki18n("Attaches the window to an X app specified by winid"))
255
259
    options.add("install", ki18n("Install a package"))
256
260
    options.add("uninstall", ki18n("Uninstall a package"))
257
261
    options.add("update", ki18n("Reload package list"))
275
279
        KMessageBox.sorry(None, i18n("Usage: install-package --install &lt;package>, or, --uninstall &lt;package>"), i18n("Command Use"), KMessageBox.Notify)
276
280
        sys.exit(1)
277
281
 
 
282
    if args.isSet("attach") and args.count() > 0:
 
283
        attach = int(args.getOption("attach"))
 
284
    else:
 
285
        attach = None
 
286
 
278
287
    for item in range(args.count()):
279
288
        packages.append(unicode(args.arg(item)))
280
289
 
284
293
        KMessageBox.sorry(None, text, title, KMessageBox.Notify)
285
294
        sys.exit(1)
286
295
 
287
 
    mainWindow = MainWindow(mode, packages)
 
296
    mainWindow = MainWindow(mode, packages, attach)
288
297
    mainWindow.show()
289
298
 
290
299
    app.exec_()