~alexeftimie/software-center/backend-refactor

« back to all changes in this revision

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

  • Committer: Alex Eftimie
  • Date: 2011-08-13 06:36:59 UTC
  • mfrom: (1809.1.284 software-center)
  • Revision ID: alex@rosedu.org-20110813063659-ek45gk5q5qop3elp
mergedĀ fromĀ lp:software-center

Show diffs side-by-side

added added

removed removed

Lines of Context:
346
346
        # setup window name and about information (needs branding)
347
347
        name = self.distro.get_app_name()
348
348
        self.window_main.set_title(name)
349
 
        #~ self.aboutdialog.set_name(name)
350
 
        #~ about_description = self.distro.get_app_description()
351
 
        #~ self.aboutdialog.set_comments(about_description)
 
349
        self.aboutdialog.set_name(name)
 
350
        about_description = self.distro.get_app_description()
 
351
        self.aboutdialog.set_comments(about_description)
352
352
 
353
 
        #~ # about dialog
 
353
        # about dialog
354
354
        self.aboutdialog.connect("response", lambda dialog, rid: dialog.hide())
355
 
        #~ self.aboutdialog.connect("delete_event", self.aboutdialog.hide_on_delete)
 
355
        self.aboutdialog.connect("delete_event", lambda w,e: self.aboutdialog.hide_on_delete())
356
356
 
357
 
        #~ # restore state
 
357
        # restore state
358
358
        self.config = get_config()
359
359
        self.restore_state()
360
360
 
364
364
        self.status_box.a11y.set_role(Atk.Role.STATUSBAR)
365
365
        self.status_box.add(self.label_status)
366
366
 
367
 
        # FIXME this stuff seems to be causing a segfault...
368
 
        #~ # make the local cache directory if it doesn't already exist
369
 
        #~ icon_cache_dir = SOFTWARE_CENTER_ICON_CACHE_DIR
370
 
        #~ if not os.path.exists(icon_cache_dir):
371
 
            #~ os.makedirs(icon_cache_dir)
372
 
        #~ self.icons.append_search_path(icon_cache_dir)
373
 
 
374
367
        # run s-c-agent update
375
368
        if options.disable_buy:
376
369
            file_menu = self.builder.get_object("menu1")
384
377
            GObject.child_watch_add(
385
378
                pid, self._on_update_software_center_agent_finished)
386
379
 
387
 
 
388
 
        # FIXME:  REMOVE THIS once launchpad integration is enabled
389
 
        #         by default
390
 
        #~ if not options.enable_lp:
391
 
            #~ file_menu = self.builder.get_object("menu1")
392
 
            #~ file_menu.remove(self.builder.get_object("menuitem_launchpad_private_ppas"))
393
 
 
394
380
        if options.disable_buy and not options.enable_lp:
395
381
            file_menu.remove(self.builder.get_object("separator_login"))
396
382
            
412
398
        #~ self.view_switcher.connect("view-changed", 
413
399
                                   #~ self.on_view_switcher_changed)
414
400
 
415
 
        # XXX lp integration still uses gtk2
416
401
        # launchpad integration help, its ok if that fails
417
 
        #~ try:
418
 
            #~ import LaunchpadIntegration
419
 
            #~ LaunchpadIntegration.set_sourcepackagename("software-center")
420
 
            #~ LaunchpadIntegration.add_items(self.menu_help, 1, True, False)
421
 
        #~ except Exception, e:
422
 
            #~ LOG.debug("launchpad integration error: '%s'" % e)
 
402
        try:
 
403
            from gi.repository import LaunchpadIntegration
 
404
            LaunchpadIntegration.set_sourcepackagename("software-center")
 
405
            LaunchpadIntegration.add_items(self.menu_help, 1, True, False)
 
406
        except Exception, e:
 
407
            LOG.debug("launchpad integration error: '%s'" % e)
423
408
 
424
409
 
425
410
 
434
419
 
435
420
    # callbacks
436
421
    def on_realize(self, widget):
437
 
        def display_lobby():
438
 
            self.view_manager.set_active_view(ViewPages.AVAILABLE)
439
 
            return
440
 
        GObject.idle_add(display_lobby)
441
422
        return
442
423
 
443
424
    def on_available_pane_created(self, widget):
1146
1127
        # allow s-c to be called with a search term
1147
1128
        if packages and packages[0].startswith("search:"):
1148
1129
            packages[0] = packages[0].partition("search:")[2]
1149
 
            self.available_pane.navigation_bar.remove_all(animate=False) # animate *must* be false here
1150
 
            self.view_switcher.set_view(ViewPages.AVAILABLE)
1151
 
            self.available_pane.notebook.set_current_page(
1152
 
                self.available_pane.PAGE_APPLIST)
 
1130
            self.available_pane.init_view()
1153
1131
            self.available_pane.searchentry.set_text(" ".join(packages))
1154
1132
            return
1155
1133
 
1175
1153
                # if the pkg is installed, show it in the installed pane
1176
1154
                if (app.pkgname in self.cache and 
1177
1155
                    self.cache[app.pkgname].installed):
1178
 
                    self.installed_pane.loaded = True
1179
 
                    self.view_switcher.set_view(ViewPages.INSTALLED)
1180
 
                    self.installed_pane.loaded = False
1181
 
                    self.available_pane.bypassed = True
 
1156
                    self.installed_pane.init_view()
1182
1157
                    self.installed_pane.show_app(app)
1183
1158
                else:
1184
 
                    self.view_switcher.set_view(ViewPages.AVAILABLE)
 
1159
                    self.available_pane.init_view()
1185
1160
                    self.available_pane.show_app(app)
1186
 
 
1187
1161
            show_app(self, app)
1188
 
 
1189
 
        if len(packages) > 1:
 
1162
            return    
 
1163
        elif len(packages) > 1:
1190
1164
            # turn multiple packages into a search with ","
 
1165
            self.available_pane.init_view()
1191
1166
            self.available_pane.searchentry.set_text(",".join(packages))
1192
 
            self.available_pane.notebook.set_current_page(
1193
 
                self.available_pane.PAGE_APPLIST)
 
1167
            return
 
1168
        # normal startup, queue showing the lobby when we are ready
 
1169
        def show_lobby():
 
1170
            self.view_manager.set_active_view(ViewPages.AVAILABLE)
 
1171
        GObject.idle_add(show_lobby)
1194
1172
 
1195
1173
    def restore_state(self):
1196
1174
        if self.config.has_option("general", "size"):
1234
1212
                if "," in arg:
1235
1213
                    args.extend(arg.split(","))
1236
1214
                    del args[i]
 
1215
 
 
1216
        # FIXME: make this more predictable and less random
 
1217
        # show args when the app is ready
1237
1218
        self.show_available_packages(args)
 
1219
 
1238
1220
        atexit.register(self.save_state)
1239
1221
        SimpleGtkbuilderApp.run(self)