~mvo/software-center/improve-debug-in-piston-generic-helper

« back to all changes in this revision

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

  • Committer: Michael Vogt
  • Date: 2012-01-06 09:24:05 UTC
  • mfrom: (2628.1.1 software-center)
  • Revision ID: michael.vogt@ubuntu.com-20120106092405-rzdfgeiuemgjz971
* lp:~didrocks/software-center/oneconf-remove-computers-from-share
  - Enable (from the new spec) removing a host which isn't the 
    current one from the gui. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        '''Emit a signal for refreshing the installedpane if current view is concerned'''
77
77
        if hostid == self.current_hostid:
78
78
            self.emit("current-inventory-refreshed")
 
79
            
 
80
    def remove_computer(self, hostid):
 
81
        '''Remove a computer from the model'''
 
82
        model = self.get_model()
 
83
        if not model:
 
84
            return
 
85
        if hostid not in self.hostids:
 
86
            LOG.warning("ask to remove a computer that isn't registered: %s" % hostid)
 
87
            return
 
88
        iter_id = model.get_iter_first()
 
89
        while iter_id:
 
90
            if model.get_value(iter_id, self.COL_HOSTID) == hostid:
 
91
                model.remove(iter_id)
 
92
                self.hostids.remove(hostid)
 
93
                break
 
94
            iter_id = model.iter_next(iter_id)
 
95
        
79
96
        
80
97
    def on_cursor_changed(self, widget):
81
98
 
120
137
    # init the view
121
138
    w.register_computer("AAAAA", "NameA")
122
139
    w.register_computer("ZZZZZ", "NameZ")
 
140
    w.register_computer("DDDDD", "NameD")
123
141
    w.register_computer("CCCCC", "NameC")
124
 
    w.register_computer(None, "This computer should be first")
 
142
    w.register_computer("", "This computer should be first")
125
143
    w.select_first()
126
144
    
127
145
    GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
130
148
        print "%s selected for %s" % (hostid, hostname)
131
149
    
132
150
    w.connect("computer-changed", print_selected_hostid)
 
151
    
 
152
    w.remove_computer("DDDDD")
133
153
    win.show_all()
134
154
    return win
135
155