Package elisa :: Package plugins :: Package bad :: Package raval_frontend :: Module manager_view
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.raval_frontend.manager_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  from elisa.core import common 
 18   
 19  plugin_registry = common.application.plugin_registry 
 20  PigmentView = plugin_registry.get_component_class('pigment:pigment_view') 
 21  BaseListView = plugin_registry.get_component_class('raval:list_view') 
 22   
23 -class ManagerView(PigmentView):
24 25 supported_controllers = ('raval:manager_controller',) 26 27 current = None 28 29 bindings = {'location': 'location', 30 'context': 'context', 31 'context_visible': 'context_visible', 32 'context_active' : 'context_active'} 33
34 - def attribute_set(self, origin, key, old_value, new_value):
35 PigmentView.attribute_set(self, origin, key, old_value, new_value) 36 37 if key == "current": 38 self.create_view(new_value) 39 elif key == "loading": 40 if isinstance(self.current , BaseListView): 41 self.current.loading = new_value
42
43 - def context_visible__set(self, value):
44 if value: 45 self.context.show() 46 else: 47 self.context.hide()
48
49 - def context_active__set(self, value):
50 if hasattr(self, 'context') and self.context is not None: 51 self.context.active = value
52
53 - def create_view(self, controller):
54 self.debug("Creating view for %r (current view=%r)", controller, 55 self.current) 56 57 # removing the old view 58 if self.current != None: 59 def remove_old_view(old_view): 60 old_view.clean()
61 62 old_view = self.current 63 fadeout = plugin_registry.create_component('pigment:fadeout_transition') 64 fadeout.apply(old_view, lambda: remove_old_view(old_view)) 65 66 # disconnect the view from its controller 67 old_view.controller = None 68 69 else: 70 old_view = None 71 72 # create a corresponding view 73 model_path = controller.model.path 74 75 content_type = getattr(controller.model, 'content_type', None) 76 view_path = self.frontend.get_view_path(model_path, 77 content_type=content_type) 78 # FIXME: calling a private method 79 self._create_child_view("current", view_path) 80 81 fadein = plugin_registry.create_component('pigment:fadein_transition') 82 fadein.apply(self.current) 83 84 # ... and link it to the controller 85 self.current.controller = controller 86 87 self.debug("Switched betweeen %r and %r", old_view, self.current)
88
89 - def controller_changed(self, old_controller, new_controller):
90 self.create_view(new_controller.current)
91
92 - def _memory_usage_tests(self):
93 import pgm, gc 94 from elisa.core.component import Component 95 gc.collect() 96 97 #display layer counts in pigment 98 canvas = self.frontend.context.viewport_handle.get_canvas() 99 print "canvas layer count = ", canvas.get_layer_count(pgm.DRAWABLE_FAR), canvas.get_layer_count(pgm.DRAWABLE_MIDDLE), canvas.get_layer_count(pgm.DRAWABLE_NEAR) 100 101 #display in python object referenced for Image and component 102 from pgm.widgets.scrollbar import Scrollbar 103 from shaded_list_view import ShadedListView 104 img = [] 105 comp = [] 106 f = gc.get_objects() 107 for o in f: 108 if isinstance(o, pgm.Image): 109 img.append(o) 110 if isinstance(o, Component): 111 comp.append(o) 112 113 print "python ref: img=%s, comp=%s" % (len(img), len(comp) ) 114 115 #print all the objects with more than 100 instances 116 """ 117 from elisa.plugins.bad.helper_frontend.report_tools import ReportTools 118 r = ReportTools() 119 ii = r.get_instance_infos(min_count = 100) 120 for inst in ii.keys(): 121 print "%s inst = %s, count= %s" % ( ii[inst][0], inst, ii[inst][0]) 122 print "---------------------------------------------" 123 """
124