Changes

Jump to navigation Jump to search
→‎Choosing Objects: object_idobject_id_or_path:s
Line 246: Line 246:  
===Choosing Objects===
 
===Choosing Objects===
 
Call this method to bring up the Chooser dialog (which looks like a small journal overlayed on your activity):
 
Call this method to bring up the Chooser dialog (which looks like a small journal overlayed on your activity):
  chooser_id = org.laptop.Journal.ChooseObject(xid, what_filter)                      # only xid arg supported in Sugar 0.82!
+
 
The xid should be your activity's X window handle, or <tt>0</tt>. The filter says what type of Journal entries is preselected in the drop-down menu (''this parameter was added in Sugar 0.83''). It's a string containing either a bundle id (e.g., <tt>'my.organization.MyActivity'</tt>), or one of the generic data types (<tt>'Text', 'Image', 'Video', 'Audio', 'Link'</tt> [http://git.sugarlabs.org/projects/sugar-base/repos/mainline/blobs/master/src/sugar/mime.py#line32 definition]), or an empty string for no filter. The call returns immediately with a string chooser_id. You need to watch these signals which get emitted when an item is chosen or the dialog is canceled:
+
  chooser_id = org.laptop.Journal.ChooseObject(xid:s, what_filter:s)                      # in Sugar 0.82 this had only one argument
  ObjectChooserResponse(chooser_id, object_id)
+
 
  ObjectChooserCancelled(chooser_id)
+
The xid should be your activity's X window handle, or <tt>0</tt>. The filter says what type of Journal entries is preselected in the drop-down menu (''this parameter was added in Sugar 0.83''). It's a string containing either a bundle id (e.g., <tt>'my.organization.MyActivity'</tt>), or one of the generic data types (<tt>'Text', 'Image', 'Video', 'Audio', 'Link'</tt> [http://git.sugarlabs.org/projects/sugar-base/repos/mainline/blobs/master/src/sugar/mime.py#line32 definition]), or an empty string for no filter. The call returns immediately with a string chooser_id. You need to watch the following signals which get emitted when an item is chosen or the dialog is cancelled:
The object_id received in an ObjectChooserResponse signal then can be used to open the corresponding [[#Keeping and Resuming|datastore object]].
+
 
 +
  ObjectChooserResponse(chooser_id:s, object_id_or_path:s)
 +
  ObjectChooserCancelled(chooser_id:s)
 +
 
 +
The chooser_id can be tested to see if this signal was in response to our own request. This is important if the user opens two file choosers at the same time (possibly in two different activities). If the user closes the chooser without selecting anything, the ObjectChooserCancelled signal is sent. Otherwise, the ObjectChooserResponse signal will be sent, and its object_id_or_path string argument is either an object id or a file path. To distinguish between the two cases, check if the first character is a slash (<tt>'/'</tt>). If it indeed begins with a slash, then this is a utf8-encoded absolute path to a file, which can be opened directly. Otherwise, if the first character is not a slash, then object_id_or_path is an object id, which can be used to open the corresponding [[#Keeping and Resuming|datastore object]].
    
===Focusing Objects===
 
===Focusing Objects===
132

edits

Navigation menu