Package elisa :: Package plugins :: Package bad :: Package gtk_frontend :: Module gtk_list_view
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.gtk_frontend.gtk_list_view

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17   
18  __maintainer__ = 'Lionel Martin <lionel@fluendo.com>' 
19   
20   
21  from elisa.base_components.view import View 
22   
23  import pygtk 
24  pygtk.require('2.0') 
25  import gtk 
26   
27   
28  # FIXME: this code remains untested and is certainly broken 
29 -class GtkListView(View):
30 """ 31 This class implements gtk list view support 32 """ 33 34 supported_controllers = ('base:list_controller',) 35
36 - def __init__(self):
37 View.__init__(self) 38 self.context_path = 'gtk:gtk_context' 39 self.liststore = gtk.ListStore(str) 40 self.treeview = gtk.TreeView(self.liststore) 41 self.context_handle = self.treeview
42
43 - def initialize(self):
44 self.tvcolumn1 = gtk.TreeViewColumn("Test list") 45 46 self.treeview.append_column(self.tvcolumn1) 47 self.cell1 = gtk.CellRendererText() 48 #self.cell1.set_property('cell-background', 'pink') 49 self.tvcolumn1.pack_start(self.cell1, True) 50 self.tvcolumn1.set_attributes(self.cell1, text=0) 51 52 tree_selection = self.treeview.get_selection() 53 tree_selection.set_mode(gtk.SELECTION_SINGLE) 54 tree_selection.connect("changed", self._gtk_selection_changed)
55 56
57 - def _gtk_selection_changed(self, selection):
58 selected_rows = selection.get_selected_rows() 59 if selected_rows[1]: 60 new_index = selected_rows[1][0][0] 61 self.controller.model.current_selection = new_index
62 63
64 - def update(self):
65 self.liststore.clear() 66 67 for model in self._controller.model: 68 self.liststore.append([model]) 69 tree_selection = self.treeview.get_selection() 70 71 if len(self._controller.model): 72 iter = self.liststore.get_iter(0) 73 tree_selection.select_iter(iter)
74
75 - def inserted(self, elements, position):
76 self.update()
77
78 - def removed(self, elements, position):
79 self.update()
80
81 - def modified(self, key, value):
82 self.update()
83
84 - def dirtied(self):
85 self.update()
86
87 - def selection_changed(self, old_index, new_index):
88 self.treeview.get_selection().select_path(new_index)
89