~mvo/update-manager/not-automatic

« back to all changes in this revision

Viewing changes to UpdateManager/UpdateManager.py

  • Committer: Michael Vogt
  • Date: 2009-02-16 10:30:51 UTC
  • mfrom: (1256.1.14 main)
  • Revision ID: michael.vogt@ubuntu.com-20090216103051-m2aa2cgx0s2facxh
merge from the mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
 
107
107
class UpdateManager(SimpleGladeApp):
108
108
 
109
 
  def __init__(self, datadir):
 
109
  def __init__(self, datadir, options):
110
110
    self.setupDbus()
111
111
    gtk.window_set_default_icon_name("update-manager")
112
112
 
179
179
        self.show_versions = self.gconfclient.get_bool("/apps/update-manager/show_versions")
180
180
    except gobject.GError, e:
181
181
        self.show_versions = False
 
182
    # get progress object
 
183
    self.progress = GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
 
184
                                              self.progressbar_cache,
 
185
                                              self.label_cache,
 
186
                                              self.window_main)
182
187
    # restore state
183
188
    self.restore_state()
 
189
    if options.no_focus_on_map:
 
190
        self.window_main.set_focus_on_map(False)
 
191
        self.progress._window.set_focus_on_map(False)
184
192
    self.window_main.show()
185
193
 
186
194
  def install_column_view_func(self, cell_layout, renderer, model, iter):
304
312
      if self.expander_details.get_expanded():
305
313
        lock = thread.allocate_lock()
306
314
        lock.acquire()
307
 
        t=thread.start_new_thread(self.cache.get_changelog,(name,lock))
 
315
        t=thread.start_new_thread(self.cache.get_news_and_changelog,(name,lock))
308
316
        changes_buffer.set_text("%s\n" % _("Downloading list of changes..."))
309
317
        iter = changes_buffer.get_iter_at_line(1)
310
318
        anchor = changes_buffer.create_child_anchor(iter)
321
329
        # download finished (or canceld, or time-out)
322
330
        button.hide()
323
331
        button.disconnect(id);
324
 
 
 
332
    # display NEWS.Debian first, then the changelog
 
333
    changes = ""
 
334
    srcpkg = self.cache[name].sourcePackageName
 
335
    if self.cache.all_news.has_key(name):
 
336
        changes += self.cache.all_news[name]
325
337
    if self.cache.all_changes.has_key(name):
326
 
      changes = self.cache.all_changes[name]
327
 
      self.set_changes_buffer(changes_buffer, changes[0], name, changes[1])
 
338
        changes += self.cache.all_changes[name]
 
339
    if changes:
 
340
        self.set_changes_buffer(changes_buffer, changes, name, srcpkg)
328
341
 
329
342
  def show_context_menu(self, widget, event):
330
343
    """
433
446
          if self._get_last_apt_get_update_text() is not None:
434
447
              text_label_main = self._get_last_apt_get_update_text()
435
448
      else:
436
 
          text_header = "<big><b>%s</b></big>" % \
437
 
                        (ngettext("You can install %s update.",
438
 
                                  "You can install %s updates.", 
439
 
                                  num_updates) % \
440
 
                                  num_updates)
 
449
          # show different text on first run (UX team suggestion)
 
450
          firstrun = self.gconfclient.get_bool("/apps/update-manager/first_run")
 
451
          if firstrun:
 
452
              text_header = "<big><b>%s</b></big>" % _("Welcome to Ubuntu")
 
453
              text_label_main = _("These software updates have been issued since Ubuntu was released. If you don't want to install them now, choose \"Update Manager\" from the Administration Menu later.")
 
454
              self.gconfclient.set_bool("/apps/update-manager/first_run", False)
 
455
          else:
 
456
              text_header = "<big><b>%s</b></big>" % _("Software updates are available for this computer")
 
457
              text_label_main = _("If you don't want to install them now, choose \"Update Manager\" from the Administration menu later.")
441
458
          text_download = _("Download size: %s") % humanize_size(self.dl_size)
442
459
          self.notebook_details.set_sensitive(True)
443
460
          self.treeview_update.set_sensitive(True)
561
578
      iter = self.store.get_iter(path)
562
579
      pkg = self.store.get_value(iter, LIST_PKG)
563
580
      origin = self.store.get_value(iter, LIST_ORIGIN)
564
 
 
565
 
      print pkg.name
566
 
      print origin
567
 
 
568
581
      if pkg is not None:
569
582
          return
570
583
      self.setBusy(True)
571
584
      actiongroup = apt_pkg.GetPkgActionGroup(self.cache._depcache)
572
585
      for pkg in self.list.pkgs[origin]:
573
586
          if pkg.markedInstall or pkg.markedUpgrade:
574
 
              print "marking keep: ", pkg.name
 
587
              #print "marking keep: ", pkg.name
575
588
              pkg.markKeep()
576
589
          elif not (pkg.name in self.list.held_back):
577
 
              print "marking install: ", pkg.name
 
590
              #print "marking install: ", pkg.name
578
591
              pkg.markInstall(autoFix=False,autoInst=False)
579
592
      # check if we left breakage
580
593
      if self.cache._depcache.BrokenCount:
588
601
 
589
602
  def toggled(self, renderer, path):
590
603
    """ a toggle button in the listview was toggled """
591
 
    print "toggled"
592
604
    iter = self.store.get_iter(path)
593
605
    pkg = self.store.get_value(iter, LIST_PKG)
594
606
    # make sure that we don't allow to toggle deactivated updates
603
615
            Fix = apt_pkg.GetPkgProblemResolver(self.cache._depcache)
604
616
            Fix.ResolveByKeep()
605
617
    else:
606
 
        for ver in pkg._pkg.VersionList:
607
 
            print "looking at: ", ver
608
 
            for (verFileIter, index) in ver.FileList:
609
 
                if verFileIter.NotAutomatic:
610
 
                    print "setting candidate ver: ", ver
611
 
                    pkg._depcache.SetCandidateVer(pkg._pkg, ver)
612
 
                    print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
613
 
                    pkg._depcache.MarkInstall(pkg._pkg)
614
 
                    print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
615
 
                    break
616
618
        pkg.markInstall()
617
 
        print pkg.markedInstall
618
 
        print pkg.markedUpgrade
619
 
    print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
620
619
    self.treeview_update.queue_draw()
621
620
    self.refresh_updates_count()
622
621
    self.setBusy(False)
760
759
 
761
760
  def on_button_dist_upgrade_clicked(self, button):
762
761
      #print "on_button_dist_upgrade_clicked"
763
 
      progress = GtkProgress.GtkFetchProgress(self,
764
 
                                              _("Downloading the upgrade "
765
 
                                                "tool"),
766
 
                                              _("The upgrade tool will "
767
 
                                                "guide you through the "
768
 
                                                "upgrade process."))
769
 
      fetcher = DistUpgradeFetcherGtk(new_dist=self.new_dist, parent=self, progress=progress)
 
762
      fetcher = DistUpgradeFetcherGtk(new_dist=self.new_dist, parent=self, progress=self.progress)
770
763
      fetcher.run()
771
764
      
772
765
  def new_dist_available(self, meta_release, upgradable_to):
798
791
        #sys.exit()
799
792
 
800
793
    try:
801
 
        progress = GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
802
 
                                             self.progressbar_cache,
803
 
                                             self.label_cache,
804
 
                                             self.window_main)
805
794
        if hasattr(self, "cache"):
806
 
            self.cache.open(progress)
 
795
            self.cache.open(self.progress)
807
796
            self.cache._initDepCache()
808
797
        else:
809
 
            self.cache = MyCache(progress)
 
798
            self.cache = MyCache(self.progress)
810
799
    except AssertionError:
811
800
        # if the cache could not be opened for some reason,
812
801
        # let the release upgrader handle it, it deals
828
817
        dialog.destroy()
829
818
        sys.exit(1)
830
819
    else:
831
 
        progress.hide()
 
820
        self.progress.hide()
832
821
 
833
822
  def check_auto_update(self):
834
823
      # Check if automatic update is enabled. If not show a dialog to inform