Class k.u.v.SlaveView(gobject.GObject):

Part of kiwi.ui.views

known subclasses: kiwi.ui.views.BaseView, kiwi.ui.delegates.SlaveDelegate, kiwi.ui.delegates.GladeSlaveDelegate

Base class for all View classes. Defines the essential class attributes (controller, toplevel, widgets) and handles initialization of toplevel and widgets. Once AbstractView.__init__() has been called, you can be sure self.toplevel and self.widgets are sane and processed.

When a controller is associated with a View (the view should be passed in to its constructor) it will try and call a hook in the View called _attach_callbacks. See AbstractGladeView for an example of this method.

Function__init__

Creates a new SlaveView. Sets up self.toplevel and self.widgets

Function_get_notebooksUndocumented
Function_check_reservedUndocumented
Function_get_toplevelUndocumented
Functionget_glade_adaptor

Special init code that subclasses may want to override.

Functionon_attach

Hook function called when attach_slave is performed on slave views.

Functionon_startup

This is a virtual method that can be customized by classes that

Functionget_toplevel

Returns the toplevel widget in the view

Functionget_widget

Retrieves the named widget from the View

Functionset_controller

Sets the view's controller, checking to see if one has already

Functionshow_and_loop

Runs show() and runs the GTK+ event loop. If the parent

Functionshow

Shows the toplevel widget

Functionshow_all

Shows all widgets attached to the toplevel widget

Functionfocus_toplevel

Focuses the toplevel widget in the view

Functionfocus_topmost

Looks through widgets specified (if no widgets are specified,

Functionget_topmost_widget

A real hack; returns the widget that is most to the left and

Function_attach_callbacksUndocumented
Functionattach_slave

Attaches a slaveview to the current view, substituting the

Functionget_sizegroups

Get a list of sizegroups for the current view.

Function_merge_sizegroupUndocumented
Functiondetach_slave

Detatch a slave called name from view

Function_attach_groupsUndocumented
Functionget_slaveUndocumented
Functionconnect_multiple

Connect the same handler to the specified signal for a number of

Functiondisconnect_autoconnected

Disconnect handlers previously connected with

Functionhandler_blockUndocumented
Functionhandler_unblockUndocumented
Functionadd_proxy

Add a proxy to this view that automatically update a model when

Function_on_child__validation_changedUndocumented
Function_on_notebook_slave__validation_changedUndocumented
Functioncheck_and_notify_validityUndocumented
Functionforce_validationUndocumented
Functionregister_validate_function

The signature of the validate function is:

def __init__(self, toplevel=None, widgets=None, gladefile=None, toplevel_name=None, domain=None):

Creates a new SlaveView. Sets up self.toplevel and self.widgets and checks for reserved names.

def _get_notebooks(self):
Undocumented
def _check_reserved(self):
Undocumented
def _get_toplevel(self):
Undocumented
def get_glade_adaptor(self):

Special init code that subclasses may want to override.

def on_attach(self, parent):

Hook function called when attach_slave is performed on slave views.

def on_startup(self):

This is a virtual method that can be customized by classes that want to perform additional initalization after a controller has been set for it. If you need this, add this method to your View subclass and BaseController will call it when the controller is set to the proxy.

def get_toplevel(self):

Returns the toplevel widget in the view

def get_widget(self, name):

Retrieves the named widget from the View

def set_controller(self, controller):

Sets the view's controller, checking to see if one has already been set before.

def show_and_loop(self, parent=None):

Runs show() and runs the GTK+ event loop. If the parent argument is supplied and is a valid view, this view is set as a transient for the parent view

def show(self, *args):

Shows the toplevel widget

def show_all(self, *args):

Shows all widgets attached to the toplevel widget

def focus_toplevel(self):

Focuses the toplevel widget in the view

def focus_topmost(self, widgets=None):

Looks through widgets specified (if no widgets are specified, look through all widgets attached to the view and sets focus to the widget that is rendered in the position closest to the view window's top and left

  • widgets: a list of widget names to be searched through
def get_topmost_widget(self, widgets=None, can_focus=False):

A real hack; returns the widget that is most to the left and top of the window.

  • widgets: a list of widget names. If widgets is supplied, it only checks in the widgets in the list; otherwise, it looks at the widgets named in self.widgets, or, if self.widgets is None, looks through all widgets attached to the view.
  • can_focus: boolean, if set only searches through widget that can be focused
def _attach_callbacks(self, controller):
Undocumented
def attach_slave(self, name, slave):

Attaches a slaveview to the current view, substituting the widget specified by name. the widget specified *must* be a eventbox; its child widget will be removed and substituted for the specified slaveview's toplevel widget:

.-----------------------. the widget that is indicated in the diagram
|window/view (self.view)| as placeholder will be substituted for the
|  .----------------.   | slaveview's toplevel.
|  | eventbox (name)|   |  .-----------------.
|  |.--------------.|      |slaveview (slave)|
|  || placeholder  <----.  |.---------------.|
|  |'--------------'|    \___ toplevel      ||
|  '----------------'   |  ''---------------'|
'-----------------------'  '-----------------'

the original way of attachment (naming the *child* widget instead of the eventbox) is still supported for compatibility reasons but will print a warning.

def get_sizegroups(self):

Get a list of sizegroups for the current view.

def _merge_sizegroup(self, other_sizegroup):
Undocumented
def detach_slave(self, name):

Detatch a slave called name from view

def _attach_groups(self, win, accel_groups):
Undocumented
def get_slave(self, holder):
Undocumented
def connect_multiple(self, widgets, signal, handler, after=False):

Connect the same handler to the specified signal for a number of widgets.

  • widgets: a list of GtkWidgets
  • signal: a string specifying the signals
  • handler: a callback method
  • after: a boolean; if TRUE, we use connect_after(), otherwise, connect()
def disconnect_autoconnected(self):

Disconnect handlers previously connected with autoconnect_signals()

def handler_block(self, widget, signal_name=None):
Undocumented
def handler_unblock(self, widget, signal_name=None):
Undocumented
def add_proxy(self, model=None, widgets=None):

Add a proxy to this view that automatically update a model when the view changes. Arguments:

  • model. the object we are proxing. It can be None if we don't have a model yet and we want to display the interface and set it up with future models.
  • widgets. the list of widgets that contains model attributes to be proxied. If it is None (or not specified) it will be the whole list of widgets this View has.

This method return a Proxy object that you may want to use to force updates or setting new models. Keep a reference to it since there is no way to get that proxy later on. You have been warned (tm)

def _on_child__validation_changed(self, child, value, name):
Undocumented
def _on_notebook_slave__validation_changed(self, slave, value, name, label):
Undocumented
def check_and_notify_validity(self, force=False):
Undocumented
def force_validation(self):
Undocumented
def register_validate_function(self, function):

The signature of the validate function is:

def function(is_valid):

or, if it is a method:

def function(self, is_valid):

where the 'is_valid' parameter is True if all the widgets have valid data or False otherwise.