~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/app.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-12-06 17:30:50 UTC
  • Revision ID: package-import@ubuntu.com-20121206173050-n7mxi5fzlsvtdh9l
Tags: 5.5.2
* lp:~mvo/software-center/fix-pygobject-deprecation-warnings:
  - fix deprecation warninings with the latest python-gi
* lp:~mvo/software-center/minor-logging-fixes:
  - drop some LOG.info() messages to LOG.debug() to spam the user
    less
* lp:~mvo/software-center/trivial-close-ui-tweak:
  - hide the main window immediately when closing down
* lp:~mvo/software-center/5.4-fix-save-person-to-config:
  - This branch ensures that the "username" is saved everytime
    that the ubuntu sso whoami call is done
* lp:~mvo/software-center/use-dpkg-builddeps:
  - use dpkg-checkbuilddeps to find test-dependencies
* lp:~mvo/software-center/update-sc-cmdline-flexibility:
  - update-software-center-agent: 
    + add --target-db-path commandline
  - update-software-center: 
    + add --app-install-desktop-dir and --target-db-path commandline
* lp:~mvo/software-center/raring-pep8:
  - fixes for new pep8

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
# order is import here, otherwise test/gtk3/test_purchase.py is unhappy
21
21
from gi.repository import GObject
 
22
from gi.repository import GLib
22
23
from gi.repository import Gtk
23
24
 
24
25
import atexit
54
55
from softwarecenter.db import (
55
56
    DebFileApplication,
56
57
    DebFileOpenError,
57
 
    )
 
58
)
58
59
from softwarecenter.db.utils import run_software_center_agent
59
60
from softwarecenter.i18n import init_locale
60
61
 
89
90
from softwarecenter.db.database import (
90
91
    StoreDatabase,
91
92
    get_reinstall_previous_purchases_query,
92
 
    )
 
93
)
93
94
try:
94
95
    from aptd_gtk3 import InstallBackendUI
95
96
    InstallBackendUI  # pyflakes
111
112
from softwarecenter.ui.gtk3.session.appmanager import (
112
113
    ApplicationManager,
113
114
    get_appmanager,
114
 
    )
 
115
)
115
116
from softwarecenter.ui.gtk3.session.viewmanager import (
116
117
    ViewManager,
117
118
    get_viewmanager,
118
 
    )
 
119
)
119
120
from softwarecenter.ui.gtk3.widgets.recommendations import (
120
121
    RecommendationsOptInDialog)
121
122
 
478
479
            self.menu_file.remove(self.menuitem_reinstall_purchases)
479
480
        else:
480
481
            # running the agent will trigger a db reload so we do it later
481
 
            GObject.timeout_add_seconds(3, self._run_software_center_agent)
 
482
            GLib.timeout_add_seconds(3, self._run_software_center_agent)
482
483
 
483
484
        # keep the cache clean
484
 
        GObject.timeout_add_seconds(15, self._run_expunge_cache_helper)
 
485
        GLib.timeout_add_seconds(15, self._run_expunge_cache_helper)
485
486
 
486
487
        # check to see if a new recommendations profile upload is
487
488
        # needed and upload if necessary
488
 
        GObject.timeout_add_seconds(45, self._upload_recommendations_profile)
 
489
        GLib.timeout_add_seconds(45, self._upload_recommendations_profile)
489
490
 
490
491
        # TODO: Remove the following two lines once we have remove repository
491
492
        #       support in aptdaemon (see LP: #723911)
511
512
        """ helper that expires the piston-mini-client cache """
512
513
        sc_expunge_cache = os.path.join(
513
514
            self.datadir, "expunge-cache.py")
514
 
        (pid, stdin, stdout, stderr) = GObject.spawn_async(
 
515
        (pid, stdin, stdout, stderr) = GLib.spawn_async(
515
516
            [sc_expunge_cache,
516
517
             "--by-unsuccessful-http-states",
517
518
             softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR,
621
622
        # when "app.run()" was called but has not finished setting up the
622
623
        # stuff yet, in this case its ok to just exit
623
624
        if Gtk.main_level() == 0:
624
 
            LOG.info("closing before the regular main loop was run")
 
625
            LOG.debug("closing before the regular main loop was run")
625
626
            sys.exit(0)
 
627
        # hide the main window early even if saving the state etc takes
 
628
        # a wee bit
 
629
        self.window_main.hide()
626
630
        self.save_state()
627
631
        self.destroy()
628
632
 
766
770
 
767
771
        # wait for the cache to become ready (if needed)
768
772
        if not self.cache.ready:
769
 
            GObject.timeout_add(
 
773
            GLib.timeout_add(
770
774
                100, lambda: self.on_menu_file_activate(menuitem))
771
775
            return False
772
776
 
804
808
            installed = bool(pkg.installed)
805
809
            self.menuitem_install.set_sensitive(not installed)
806
810
            self.menuitem_remove.set_sensitive(installed)
807
 
        # return False to ensure that a possible GObject.timeout_add ends
 
811
        # return False to ensure that a possible GLib.timeout_add ends
808
812
        return False
809
813
 
810
814
    def _on_reinstall_purchased_login(self, sso, oauth_result):
1048
1052
             "-n",
1049
1053
             "-t", str(xid)])
1050
1054
        # Monitor the subprocess regularly
1051
 
        GObject.timeout_add(100, self._poll_software_sources_subprocess, p)
 
1055
        GLib.timeout_add(100, self._poll_software_sources_subprocess, p)
1052
1056
 
1053
1057
    def _poll_software_sources_subprocess(self, popen):
1054
1058
        ret = popen.poll()
1160
1164
 
1161
1165
    def on_menuitem_help_activate(self, menuitem):
1162
1166
        # run browser
1163
 
        (pid, stdin, stdout, stderr) = GObject.spawn_async(
 
1167
        (pid, stdin, stdout, stderr) = GLib.spawn_async(
1164
1168
            ["yelp", "ghelp:software-center"], flags=GObject.SPAWN_SEARCH_PATH)
1165
1169
 
1166
1170
    def on_menuitem_tos_activate(self, menuitem):
1172
1176
    def _ask_and_repair_broken_cache(self):
1173
1177
        # wait until the window window is available
1174
1178
        if self.window_main.props.visible is False:
1175
 
            GObject.timeout_add_seconds(1, self._ask_and_repair_broken_cache)
 
1179
            GLib.timeout_add_seconds(1, self._ask_and_repair_broken_cache)
1176
1180
            return
1177
1181
        if dialogs.confirm_repair_broken_cache(self.window_main,
1178
1182
                                                      self.datadir):
1311
1315
                          _("The file “%s” could not be opened.") % e.path)
1312
1316
            search_text = app = None
1313
1317
 
1314
 
        LOG.info('show_available_packages: search_text is %r, app is %r.',
1315
 
                 search_text, app)
 
1318
        LOG.debug('show_available_packages: search_text is %r, app is %r.',
 
1319
                  search_text, app)
1316
1320
 
1317
1321
        if search_text:
1318
1322
            self.available_pane.init_view()
1373
1377
        self.window_main.show_all()
1374
1378
 
1375
1379
        # delay cache open
1376
 
        GObject.timeout_add(1, self.cache.open)
 
1380
        GLib.timeout_add(1, self.cache.open)
1377
1381
 
1378
1382
        # support both "pkg1 pkg" and "pkg1,pkg2" (and pkg1,pkg2 pkg3)
1379
1383
        if args: