~mmcg069/software-center/appstore-experiment

« back to all changes in this revision

Viewing changes to softwarecenter/view/softwarepane.py

  • Committer: Matthew McGowan
  • Date: 2011-04-11 22:20:49 UTC
  • mfrom: (1354.61.45 trunk)
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20110411222049-57f5yne3zdtd3xf8
merge w trunk and resolve

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
        self.apps_category = None
192
192
        self.apps_subcategory = None
193
193
        self.apps_search_term = None
194
 
        self.custom_list_mode = False
195
194
        # keep track of applications that have been requested to be added
196
195
        # to the Unity launcher
197
196
        self.unity_launcher_items = {}
416
415
        # we only show the prompt for apps with a desktop file
417
416
        if not appdetails.desktop_file:
418
417
            return
419
 
        self.action_bar.set_label(_("Add %s to the launcher?" % app.name))
420
418
        self.action_bar.add_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER,
421
419
                                    _("Not Now"), 
422
420
                                    self.on_cancel_add_to_launcher, 
427
425
                                   app,
428
426
                                   appdetails,
429
427
                                   trans_id)
 
428
        self.action_bar.set_label(_("Add %s to the launcher?" % app.name))
430
429
        
431
430
    def on_add_to_launcher(self, app, appdetails, trans_id):
432
431
        """
434
433
        to the launcher
435
434
        """
436
435
        LOG.debug("the application '%s' will be added to the Unity launcher when installation is complete" % app.name)
437
 
        (icon_name, icon_size, icon_x, icon_y) = self._get_icon_details_for_launcher_service(app)
 
436
        (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app)
438
437
        launcher_info = UnityLauncherInfo(app.name,
439
 
                                          icon_name,
 
438
                                          appdetails.icon,
440
439
                                          "",        # we set the icon_file_path value *after* install
441
440
                                          icon_x,
442
441
                                          icon_y,
445
444
                                          "",        # we set the installed_desktop_file_path *after* install
446
445
                                          trans_id)
447
446
        self.unity_launcher_items[app.pkgname] = launcher_info
448
 
        self.action_bar.unset_label()
449
447
        self.action_bar.set_label(_("%s will be added to the launcher when installation completes." % app.name))
450
448
        self.action_bar.remove_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER)
451
449
        self.action_bar.remove_button(ACTION_BUTTON_ADD_TO_LAUNCHER)
452
450
 
453
 
    def _get_icon_details_for_launcher_service(self, app):
 
451
    def _get_onscreen_icon_details_for_launcher_service(self, app):
454
452
        if self.is_app_details_view_showing():
455
453
            return self.app_details_view.get_app_icon_details()
456
 
        elif self.is_applist_view_showing():
 
454
        else:
457
455
            # TODO: implement the app list view case once it has been specified
458
 
            return ("", "", None, None, None)
 
456
            return (0, 0, 0)
459
457
                                              
460
458
    def on_cancel_add_to_launcher(self, args):
461
459
        self.action_bar.clear()
467
465
            launcher_info.icon_file_path = get_file_path_from_iconname(self.icons,
468
466
                                                                       launcher_info.icon_name)
469
467
            launcher_info.installed_desktop_file_path \
470
 
                = convert_desktop_file_to_installed_location(launcher_info.app_install_desktop_file_path)
 
468
                = convert_desktop_file_to_installed_location(launcher_info.app_install_desktop_file_path,
 
469
                                                             result.pkgname)
471
470
            if result.success:
472
471
                self._send_dbus_signal_to_unity_launcher(launcher_info)
473
472
            self.action_bar.clear()
502
501
 
503
502
    def show_appview_spinner(self):
504
503
        """ display the spinner in the appview panel """
505
 
        self.action_bar.clear()
 
504
        if not self.apps_search_term:
 
505
            self.action_bar.clear()
506
506
        self.spinner_view.stop()
507
507
        self.spinner_notebook.set_current_page(self.PAGE_SPINNER)
508
508
        # "mask" the spinner view momentarily to prevent it from flashing into
553
553
        # calculate the number of apps/pkgs
554
554
        pkgs = 0
555
555
        apps = 0
 
556
 
556
557
#        if appstore.active:
557
558
        if enquirer.limit > 0 and enquirer.limit < enquirer.nr_pkgs:
558
559
            apps = min(enquirer.limit, enquirer.nr_apps)
561
562
            apps = enquirer.nr_apps
562
563
            pkgs = enquirer.nr_pkgs
563
564
 
564
 
        self.action_bar.unset_label()
 
565
        if not self.is_app_details_view_showing():
 
566
            self.action_bar.unset_label()
565
567
 
566
568
        if (appstore and 
567
569
            self.is_applist_view_showing() and
573
575
                label = gettext.ngettext("_Hide %(amount)i technical item_",
574
576
                                         "_Hide %(amount)i technical items_",
575
577
                                         pkgs) % { 'amount': pkgs, }
576
 
                self.action_bar.set_label(label, self._hide_nonapp_pkgs) 
 
578
                self.action_bar.set_label(label, link_result=self._hide_nonapp_pkgs) 
577
579
            else:
578
580
                label = gettext.ngettext("_Show %(amount)i technical item_",
579
581
                                         "_Show %(amount)i technical items_",
580
582
                                         pkgs) % { 'amount': pkgs, }
581
 
                self.action_bar.set_label(label, self._show_nonapp_pkgs)
 
583
                self.action_bar.set_label(label, link_result=self._show_nonapp_pkgs)
582
584
 
583
585
    def update_search_help(self):
584
586
        search = self.searchentry.get_text()
673
675
 
674
676
    @wait_for_apt_cache_ready
675
677
    def _refresh_apps_with_apt_cache(self, query):
676
 
        LOG.debug("softwarepane query: %s" % query)
677
 
#~ =======
678
 
        #~ self.refresh_seq_nr += 1
679
 
        #~ LOG.debug("softwarepane query: %s" % query)
680
 
#~ 
681
 
        #~ old_model = self.app_view.get_model()
682
 
        #~ if old_model is not None:
683
 
            #~ # *ugh* deactivate the old model because otherwise it keeps
684
 
            #~ # getting progress_changed events and eats CPU time until its
685
 
            #~ # garbage collected
686
 
            #~ old_model.active = False
687
 
            #~ while gtk.events_pending():
688
 
                #~ gtk.main_iteration()
689
 
#~ 
690
 
        #~ LOG.debug("softwarepane query: %s" % query)
691
 
        #~ # create new model and attach it
692
 
        #~ seq_nr = self.refresh_seq_nr
693
 
        #~ # In custom list mode, search should yield the exact package name.
694
 
        #~ new_model = AppStore(self.cache,
695
 
                             #~ self.db,
696
 
                             #~ self.icons,
697
 
                             #~ query,
698
 
                             #~ limit=self.get_app_items_limit(),
699
 
                             #~ sortmode=self.get_sort_mode(),
700
 
                             #~ exact=self.custom_list_mode,
701
 
                             #~ nonapps_visible = self.nonapps_visible,
702
 
                             #~ filter=self.apps_filter)
703
 
#~ 
704
 
        #~ #print "new_model", new_model, len(new_model), seq_nr
705
 
        #~ # between request of the new model and actual delivery other
706
 
        #~ # events may have happend
707
 
        #~ if seq_nr != self.refresh_seq_nr:
708
 
            #~ LOG.info("discarding new model (%s != %s)" % (seq_nr, self.refresh_seq_nr))
709
 
            #~ return False
710
 
#~ >>>>>>> MERGE-SOURCE
711
 
 
712
678
        # set model
713
679
        with ExecutionTime("enquirer.set_query()"):
714
680
            self.enquirer.set_query(query,