view.py

Go to the documentation of this file.
00001 # Copyright 2006  Timo Savola
00002 #
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU Lesser General Public License as published
00005 # by the Free Software Foundation; either version 2.1 of the License, or
00006 # (at your option) any later version.
00007 
00008 import sys
00009 import os
00010 import gobject
00011 import gtk
00012 
00013 import environment
00014 import execution
00015 
00016 class AbstractView (environment.ViewExtension):
00017         __gproperties__ = {
00018                 'relocatable': (gobject.TYPE_BOOLEAN,
00019                                 'Is view relocatable?',
00020                                 'The view widget can be unmapped without problems',
00021                                 True,
00022                                 gobject.PARAM_READABLE),
00023         }
00024 
00025         def __init__(self, env=None):
00026                 environment.ViewExtension.__init__(self)
00027 
00028                 if env:
00029                         self.env = env
00030 
00031         def do_get_property(self, property):
00032                 if property.name == 'relocatable':
00033                         return self.is_relocatable()
00034                 else:
00035                         raise AttributeError, 'Unknown property: %s' % property.name
00036 
00037         def is_relocatable(self):
00038                 return True
00039 
00040 gobject.type_register(AbstractView)
00041 
00042 class AbstractEmbedder (AbstractView):
00043         def __init__(self, env=None):
00044                 AbstractView.__init__(self, env)
00045 
00046                 self.socket = gtk.Socket()
00047                 self.socket.set_property('can-focus', True)
00048                 self.socket.connect_after('map', self.on_socket_map)
00049                 self.socket.show()
00050 
00051                 self.xid = None
00052 
00053         def on_socket_map(self, socket):
00054                 if self.xid is None:
00055                         self.xid = socket.get_id()
00056 
00057                         try:
00058                                 self.client_start(self.xid)
00059                         except:
00060                                 socket.destroy()
00061                                 raise
00062 
00063                         self.socket.connect_after('destroy', self.on_socket_destroy)
00064 
00065         def on_socket_destroy(self, socket):
00066                 self.client_destroy()
00067 
00068         def get_widget(self):
00069                 return self.socket
00070 
00071         def is_relocatable(self):
00072                 return False
00073 
00074         def client_start(self, xid):
00075                 pass
00076 
00077         def client_destroy(self):
00078                 pass
00079 
00080 gobject.type_register(AbstractEmbedder)

Generated on Thu Jan 18 09:47:40 2007 for Encode by  doxygen 1.4.7