~mvo/software-center/fix-lp870847-5.2

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/apptreeview.py

  • Committer: Michael Vogt
  • Date: 2012-07-19 08:45:42 UTC
  • mfrom: (3062.1.3 5.2)
  • Revision ID: michael.vogt@ubuntu.com-20120719084542-k0miquj1op50eht6
mergedĀ lp:~gary-lasker/software-center/fix-lp969907-for-5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
    @property
127
127
    def appmodel(self):
128
128
        model = self.get_model()
 
129
        # FIXME: would be nice if that would be less ugly,
 
130
        # because we use a treefilter we need to get the "real"
 
131
        # model first
129
132
        if isinstance(model, Gtk.TreeModelFilter):
130
133
            return model.get_model()
131
134
        return model
505
508
                    model, it = sel.get_selected()
506
509
                    path = model.get_path(it)
507
510
                    if path:
508
 
                        self._init_activated(btn, self.get_model(), path)
 
511
                        self._init_activated(btn, model, path)
509
512
                        btn.has_focus = False
510
513
                        r = True
511
514
                    break
521
524
                            btn,
522
525
                            btn.name,
523
526
                            app,
524
 
                            model,
525
527
                            path)
526
528
 
527
529
    def _cell_data_func_cb(self, col, cell, model, it, user_data):
555
557
            text = ""
556
558
        cell.set_property('text', text)
557
559
 
558
 
    def _app_activated_cb(self, btn, btn_id, app, store, path):
 
560
    def _app_activated_cb(self, btn, btn_id, app, path):
559
561
        if self.rowref_is_category(app):
560
562
            return
561
 
 
562
 
        # FIXME: would be nice if that would be more elegant
563
 
        # because we use a treefilter we need to get the "real"
564
 
        # model first
565
 
        if type(store) is Gtk.TreeModelFilter:
566
 
            store = store.get_model()
567
 
 
568
 
        pkgname = self.appmodel.get_pkgname(app)
 
563
        model = self.appmodel
 
564
        # don't continue if we don't have a valid model (LP: #969907)
 
565
        if not model:
 
566
            return
 
567
 
 
568
        pkgname = model.get_pkgname(app)
569
569
 
570
570
        if btn_id == CellButtonIDs.INFO:
571
571
            self.app_view.emit("application-activated",
572
 
                               self.appmodel.get_application(app))
 
572
                               model.get_application(app))
573
573
        elif btn_id == CellButtonIDs.ACTION:
574
574
            btn.set_sensitive(False)
575
 
            store.row_changed(path, store.get_iter(path))
 
575
            model.row_changed(path, model.get_iter(path))
576
576
            app_manager = get_appmanager()
577
577
            # be sure we dont request an action for a pkg with
578
578
            # pre-existing actions
581
581
                              " '%s'" % pkgname)
582
582
                return False
583
583
            self._action_block_list.append(pkgname)
584
 
            if self.appmodel.is_installed(app):
 
584
            if model.is_installed(app):
585
585
                action = AppActions.REMOVE
586
 
            elif self.appmodel.is_purchasable(app):
587
 
                app_manager.buy_app(self.appmodel.get_application(app))
588
 
                store.notify_action_request(app, path)
 
586
            elif model.is_purchasable(app):
 
587
                app_manager.buy_app(model.get_application(app))
 
588
                model.notify_action_request(app, path)
589
589
                return
590
590
            else:
591
591
                action = AppActions.INSTALL
592
592
 
593
 
            store.notify_action_request(app, path)
 
593
            model.notify_action_request(app, path)
594
594
 
595
595
            app_manager.request_action(
596
 
                self.appmodel.get_application(app), [], [],
 
596
                model.get_application(app), [], [],
597
597
                action)
598
598
        return False
599
599