From da45dfd031f7d73a359c526868cb6a22a33b0eae Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Thu, 20 Dec 2012 01:01:34 -0600 Subject: Update docs for g-i --- docs/reference/caja-python-column-provider.xml | 32 +-- docs/reference/caja-python-column.xml | 16 +- docs/reference/caja-python-file-info.xml | 54 ++--- docs/reference/caja-python-info-provider.xml | 66 +++--- .../caja-python-location-widget-provider.xml | 17 +- docs/reference/caja-python-menu-item.xml | 32 +-- docs/reference/caja-python-menu-provider.xml | 225 ++++++--------------- docs/reference/caja-python-menu.xml | 26 +-- docs/reference/caja-python-operation-result.xml | 16 +- docs/reference/caja-python-overview-example.xml | 64 +++--- docs/reference/caja-python-overview-methods.xml | 4 +- docs/reference/caja-python-overview.xml | 27 ++- .../caja-python-property-page-provider.xml | 45 +++-- docs/reference/caja-python-property-page.xml | 16 +- 14 files changed, 277 insertions(+), 363 deletions(-) (limited to 'docs/reference') diff --git a/docs/reference/caja-python-column-provider.xml b/docs/reference/caja-python-column-provider.xml index e9acb19..ba4956e 100644 --- a/docs/reference/caja-python-column-provider.xml +++ b/docs/reference/caja-python-column-provider.xml @@ -4,8 +4,8 @@ - caja.ColumnProvider - caja.ColumnProvider Reference + Caja.ColumnProvider + Caja.ColumnProvider Reference @@ -16,7 +16,7 @@ Synopsis - caja.ColumnProvider + Caja.ColumnProvider get_columns @@ -33,32 +33,32 @@ Description - If subclassed, Caja will request a list of caja.Column + If subclassed, Caja will request a list of Caja.Column objects, which are then displayed when the user is in List mode. - An extension sub-classing caja.ColumnProvider - will almost always want to sub-class caja.InfoProvider + An extension sub-classing Caja.ColumnProvider + will almost always want to sub-class Caja.InfoProvider as well, since that is how an extension provides information for each item in a directory listing. - caja.ColumnProvider Example + Caja.ColumnProvider Example import os import urllib -import caja +from gi.repository import Caja, GObject -class ColumnExtension(caja.ColumnProvider, caja.InfoProvider): +class ColumnExtension(GObject.GObject, Caja.ColumnProvider, Caja.InfoProvider): def __init__(self): pass def get_columns(self): - return caja.Column("CajaPython::block_size_column", - "block_size", - "Block size", - "Get the block size"), + return Caja.Column(name="CajaPython::block_size_column", + attribute="block_size", + label="Block size", + description="Get the block size"), def update_file_info(self, file): if file.get_uri_scheme() != 'file': @@ -80,7 +80,7 @@ class ColumnExtension(caja.ColumnProvider, caja.InfoProvider): Passive Methods - caja.ColumnProvider.get_columns + Caja.ColumnProvider.get_columns get_columns @@ -90,13 +90,13 @@ class ColumnExtension(caja.ColumnProvider, caja.InfoProvider): Returns : - a list of caja.Column + a list of Caja.Column The get_columns() method returns a list of - caja.Column. + Caja.Column. diff --git a/docs/reference/caja-python-column.xml b/docs/reference/caja-python-column.xml index 0d79032..8d4b9b7 100644 --- a/docs/reference/caja-python-column.xml +++ b/docs/reference/caja-python-column.xml @@ -4,8 +4,8 @@ - caja.Column - caja.Column Reference + Caja.Column + Caja.Column Reference @@ -16,11 +16,11 @@ Synopsis - caja.Column + Caja.Column gobject.GObject - caja.Column + Caja.Column name attribute label @@ -37,7 +37,7 @@ Ancestry +-- gobject.GObject - +-- caja.Column + +-- Caja.Column @@ -50,7 +50,7 @@ Description - A list of caja.Column objects is returned by caja.ColumnProvider extensions. + A list of Caja.Column objects is returned by Caja.ColumnProvider extensions. @@ -122,7 +122,7 @@ Constructor - caja.Column + Caja.Column name attribute label @@ -149,7 +149,7 @@ - Creates a new caja.Column object. + Creates a new Caja.Column object. diff --git a/docs/reference/caja-python-file-info.xml b/docs/reference/caja-python-file-info.xml index a581c84..fb156ee 100644 --- a/docs/reference/caja-python-file-info.xml +++ b/docs/reference/caja-python-file-info.xml @@ -4,8 +4,8 @@ - caja.FileInfo - caja.FileInfo Reference + Caja.FileInfo + Caja.FileInfo Reference @@ -16,7 +16,7 @@ Synopsis - caja.FileInfo + Caja.FileInfo gobject.GInterface @@ -126,7 +126,7 @@ Ancestry +-- gobject.GInterface - +-- caja.FileInfo + +-- Caja.FileInfo @@ -139,8 +139,8 @@ Description - caja.FileInfo objects are passed - to extensions by the caja.InfoProvider. + Caja.FileInfo objects are passed + to extensions by the Caja.InfoProvider. @@ -154,7 +154,7 @@ Public Methods - caja.FileInfo.is_gone + Caja.FileInfo.is_gone is_gone @@ -167,7 +167,7 @@ - caja.FileInfo.get_file_type + Caja.FileInfo.get_file_type get_file_type @@ -180,7 +180,7 @@ - caja.FileInfo.get_location + Caja.FileInfo.get_location get_location @@ -193,7 +193,7 @@ - caja.FileInfo.get_name + Caja.FileInfo.get_name get_name @@ -206,7 +206,7 @@ - caja.FileInfo.get_uri + Caja.FileInfo.get_uri get_uri @@ -219,7 +219,7 @@ - caja.FileInfo.get_activation_uri + Caja.FileInfo.get_activation_uri get_activation_uri @@ -232,20 +232,20 @@ - caja.FileInfo.get_parent_info + Caja.FileInfo.get_parent_info get_parent_info Returns : - the caja.FileInfo object associated with the file's parent + the Caja.FileInfo object associated with the file's parent - caja.FileInfo.get_parent_location + Caja.FileInfo.get_parent_location get_parent_location @@ -258,7 +258,7 @@ - caja.FileInfo.get_parent_uri + Caja.FileInfo.get_parent_uri get_parent_uri @@ -271,7 +271,7 @@ - caja.FileInfo.get_mount + Caja.FileInfo.get_mount get_mount @@ -284,7 +284,7 @@ - caja.FileInfo.get_uri_scheme + Caja.FileInfo.get_uri_scheme get_uri_scheme @@ -297,7 +297,7 @@ - caja.FileInfo.get_mime_type + Caja.FileInfo.get_mime_type get_mime_type @@ -310,7 +310,7 @@ - caja.FileInfo.is_mime_type + Caja.FileInfo.is_mime_type is_mime_type mimetype @@ -328,7 +328,7 @@ - caja.FileInfo.is_directory + Caja.FileInfo.is_directory is_directory @@ -341,7 +341,7 @@ - caja.FileInfo.can_write + Caja.FileInfo.can_write can_write @@ -354,7 +354,7 @@ - caja.FileInfo.add_emblem + Caja.FileInfo.add_emblem add_emblem emblem_name @@ -368,7 +368,7 @@ - caja.FileInfo.get_string_attribute + Caja.FileInfo.get_string_attribute get_string_attribute attribute_name @@ -386,7 +386,7 @@ - caja.FileInfo.add_string_attribute + Caja.FileInfo.add_string_attribute add_string_attribute attribute_name @@ -405,12 +405,12 @@ - caja.FileInfo.invalidate_extension_info + Caja.FileInfo.invalidate_extension_info invalidate_extension_info Invalidates the information Caja has about this file, which causes it to request new information - from its caja.InfoProvider providers. + from its Caja.InfoProvider providers. diff --git a/docs/reference/caja-python-info-provider.xml b/docs/reference/caja-python-info-provider.xml index 556bb59..424fdb0 100644 --- a/docs/reference/caja-python-info-provider.xml +++ b/docs/reference/caja-python-info-provider.xml @@ -4,8 +4,8 @@ - caja.InfoProvider - caja.InfoProvider Reference + Caja.InfoProvider + Caja.InfoProvider Reference @@ -16,7 +16,7 @@ Synopsis - caja.InfoProvider + Caja.InfoProvider update_file_info @@ -38,11 +38,11 @@ - update_complete_invoke + Caja.info_provider_update_complete_invoke provider handle closure - resultcaja.OPERATION_COMPLETE + resultCaja.OperationResult.COMPLETE @@ -61,18 +61,20 @@ - caja.InfoProvider Example + Caja.InfoProvider Example -import os.path -import caja +from gi.repository import Caja, GObject -class SimpleInfoProviderExample(caja.InfoProvider): +class ColumnExtension(GObject.GObject, Caja.InfoProvider): def __init__(self): pass - def update_file_info(self, file): - if os.path.splitext(file.get_name())[1] == ".mp3": - file.add_emblem("multimedia") + def update_file_info_full(self, provider, handle, closure, file): + gobject.timeout_add_seconds(3, self.update_cb, provider, handle, closure) + return Caja.OperationResult.IN_PROGRESS + + def update_cb(self, provider, handle, closure): + Caja.info_provider_update_complete_invoke(closure, provider, handle, Caja.OperationResult.FAILED) @@ -86,7 +88,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): Passive Methods - caja.InfoProvider.update_file_info + Caja.InfoProvider.update_file_info update_file_info @@ -96,7 +98,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): file : - a caja.FileInfo object + a Caja.FileInfo object @@ -108,7 +110,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): - caja.InfoProvider.update_file_info_full + Caja.InfoProvider.update_file_info_full update_file_info_full @@ -121,7 +123,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): provider : - the current caja.InfoProvider instance + the current Caja.InfoProvider instance handle : @@ -129,21 +131,21 @@ class SimpleInfoProviderExample(caja.InfoProvider): closure : - a C Closure that must be passed to update_complete_invoke if that method is called + a C Closure that must be passed to Caja.info_provider_update_complete_invoke if that method is called file : - a caja.FileInfo object + a Caja.FileInfo object Returns : - None or a caja.OperationResult enum + None or a Caja.OperationResult enum This method is called by Caja for each file or folder that exists under the - current directory listing. Originally, caja.InfoProvider + current directory listing. Originally, Caja.InfoProvider only provided the update_file_info method, which blocked Caja when the method required a lot of computation time. This method was created to allow an extension to tell Caja that it will be spending time on an operation and that @@ -151,8 +153,8 @@ class SimpleInfoProviderExample(caja.InfoProvider): In order to notify Caja of your extension's intentions, you must return a - caja.OperationResult enum. - Then, when the operation has completed, call the self.update_complete_invoke method, passing the provider, + Caja.OperationResult enum. + Then, when the operation has completed, call the Caja.info_provider_update_complete_invoke method, passing the provider, handle and closure variables as parameters. @@ -167,7 +169,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): - caja.InfoProvider.cancel_update + Caja.InfoProvider.cancel_update cancel_update @@ -178,7 +180,7 @@ class SimpleInfoProviderExample(caja.InfoProvider): provider : - the current caja.InfoProvider instance + the current Caja.InfoProvider instance handle : @@ -202,20 +204,20 @@ class SimpleInfoProviderExample(caja.InfoProvider): Active Methods - caja.InfoProvider.update_complete_invoke + Caja.info_provider_update_complete_invoke - update_complete_invoke + info_provider_update_complete_invoke provider handle closure - resultcaja.OPERATION_COMEPLETE + resultCaja.OperationResult.COMPLETE provider : - the current caja.InfoProvider instance + the current Caja.InfoProvider instance handle : @@ -223,18 +225,18 @@ class SimpleInfoProviderExample(caja.InfoProvider): closure : - a C Closure that must be passed to update_complete_invoke if that method is called + a C Closure that must be passed to Caja.info_provider_update_complete_invoke if that method is called result : - an optional parameter. If left out, caja.OPERATION_COMPLETE is assumed. - Otherwise, you may pass any any of the caja.OperationResult enums. + an optional parameter. If left out, Caja.OperationResult.COMPLETE is assumed. + Otherwise, you may pass any any of the Caja.OperationResult enums. An extension must call this method for each update_file_info_full method that - returns the caja.OPERATION_IN_PROGRESS enum. + returns the Caja.OperationResult.IN_PROGRESS enum. The method must be called with the provider, handle, and closure parameters which were passed to the earlier update_file_info_full method. diff --git a/docs/reference/caja-python-location-widget-provider.xml b/docs/reference/caja-python-location-widget-provider.xml index ff39657..3fd4927 100644 --- a/docs/reference/caja-python-location-widget-provider.xml +++ b/docs/reference/caja-python-location-widget-provider.xml @@ -4,8 +4,8 @@ - caja.LocationWidgetProvider - caja.LocationWidgetProvider Reference + Caja.LocationWidgetProvider + Caja.LocationWidgetProvider Reference @@ -16,7 +16,7 @@ Synopsis - caja.LocationWidgetProvider + Caja.LocationWidgetProvider get_widget @@ -38,17 +38,16 @@ - caja.LocationWidgetProvider Example + Caja.LocationWidgetProvider Example -import caja -import gtk +from gi.repository import Caja, GObject, Gtk -class LocationProviderExample(caja.LocationWidgetProvider): +class ColumnExtension(GObject.GObject, Caja.LocationWidgetProvider): def __init__(self): pass def get_widget(self, uri, window): - entry = gtk.Entry() + entry = Gtk.Entry() entry.set_text(uri) entry.show() return entry @@ -65,7 +64,7 @@ class LocationProviderExample(caja.LocationWidgetProvider): Passive Methods - caja.LocationWidgetProvider.get_widget + Caja.LocationWidgetProvider.get_widget get_widget diff --git a/docs/reference/caja-python-menu-item.xml b/docs/reference/caja-python-menu-item.xml index 798afa7..ea391f1 100644 --- a/docs/reference/caja-python-menu-item.xml +++ b/docs/reference/caja-python-menu-item.xml @@ -4,8 +4,8 @@ - caja.MenuItem - caja.MenuItem Reference + Caja.MenuItem + Caja.MenuItem Reference @@ -16,11 +16,11 @@ Synopsis - caja.MenuItem + Caja.MenuItem gobject.GObject - caja.MenuItem + Caja.MenuItem name label tooltip @@ -47,7 +47,7 @@ Ancestry +-- gobject.GObject - +-- caja.MenuItem + +-- Caja.MenuItem @@ -60,7 +60,7 @@ Description - caja.MenuItem objects are appended to lists to create menus and submenus. + Caja.MenuItem objects are appended to lists to create menus and submenus. @@ -95,7 +95,7 @@ "menu" - The caja.Menu menu object belonging to this item. May be None. + The Caja.Menu menu object belonging to this item. May be None. Read-Write @@ -161,7 +161,7 @@ Constructor - caja.MenuItem + Caja.MenuItem name label tooltip @@ -188,7 +188,7 @@ - Creates a new caja.MenuItem object. + Creates a new Caja.MenuItem object. @@ -201,18 +201,18 @@ Public Methods - caja.MenuItem.activate + Caja.MenuItem.activate activate - Generates the "activate" signal for this caja.MenuItem. + Generates the "activate" signal for this Caja.MenuItem. - caja.MenuItem.set_submenu + Caja.MenuItem.set_submenu set_submenu menu @@ -220,11 +220,11 @@ menu : - a caja.Menu + a Caja.Menu - Attaches a caja.Menu as the submenu for this caja.MenuItem. + Attaches a Caja.Menu as the submenu for this Caja.MenuItem. @@ -238,7 +238,7 @@ Signal Details - The "activate" caja.MenuItem Signal + The "activate" Caja.MenuItem Signal callback @@ -250,7 +250,7 @@ item : - the caja.MenuItem being activated + the Caja.MenuItem being activated user_param1 : diff --git a/docs/reference/caja-python-menu-provider.xml b/docs/reference/caja-python-menu-provider.xml index 0050bec..4e750a0 100644 --- a/docs/reference/caja-python-menu-provider.xml +++ b/docs/reference/caja-python-menu-provider.xml @@ -4,8 +4,8 @@ - caja.MenuProvider - caja.MenuProvider Reference + Caja.MenuProvider + Caja.MenuProvider Reference @@ -16,7 +16,7 @@ Synopsis - caja.MenuProvider + Caja.MenuProvider get_file_items @@ -45,20 +45,7 @@ - get_toolbar_items - window - folder - - - - get_toolbar_items_full - provider - window - folder - - - - emit_items_updated_signal + Caja.menu_provider_emit_items_updated_signal provider @@ -72,61 +59,56 @@ Description - If subclassed, Caja will request a list of caja.MenuItem objects, + If subclassed, Caja will request a list of Caja.MenuItem objects, which are then attached to various menus. Caja expects at least one of - the following methods to be defined (or their *_full variants): get_file_items, - get_background_items, or get_toolbar_items. + the following methods to be defined (or their *_full variants): get_file_items or + get_background_items. + + The get_toolbar_items methods were removed in caja-python 1.0 because they were removed from Caja 3. Technically, you should still be + able to call those methods with caja-python 1.0 if you are running Caja 2.x with annotations. - caja.MenuProvider Example + Caja.MenuProvider Example -import os -import urllib - -import gtk -import caja -import mateconf - -TERMINAL_KEY = '/desktop/mate/applications/terminal/exec' +from gi.repository import Caja, GObject -class OpenTerminalExtension(caja.MenuProvider): +class ColumnExtension(GObject.GObject, Caja.MenuProvider): def __init__(self): - self.client = mateconf.client_get_default() - - def _open_terminal(self, file): - filename = urllib.unquote(file.get_uri()[7:]) - terminal = self.client.get_string(TERMINAL_KEY) - - os.chdir(filename) - os.system('%s &' % terminal) + pass - def menu_activate_cb(self, menu, file): - self._open_terminal(file) - - def menu_background_activate_cb(self, menu, file): - self._open_terminal(file) - def get_file_items(self, window, files): - if len(files) != 1: - return - - file = files[0] - if not file.is_directory() or file.get_uri_scheme() != 'file': - return - - item = caja.MenuItem('CajaPython::openterminal_file_item', - 'Open Terminal' , - 'Open Terminal In %s' % file.get_name()) - item.connect('activate', self.menu_activate_cb, file) - return item, + top_menuitem = Caja.MenuItem(name='ExampleMenuProvider::Foo', + label='Foo', + tip='', + icon='') + + submenu = Caja.Menu() + top_menuitem.set_submenu(submenu) + + sub_menuitem = Caja.MenuItem(name='ExampleMenuProvider::Bar', + label='Bar', + tip='', + icon='') + submenu.append_item(sub_menuitem) + + return top_menuitem, def get_background_items(self, window, file): - item = caja.MenuItem('CajaPython::openterminal_item', - 'Open Terminal Here', - 'Open Terminal In This Directory') - item.connect('activate', self.menu_background_activate_cb, file) - return item, + submenu = Caja.Menu() + submenu.append_item(Caja.MenuItem(name='ExampleMenuProvider::Bar2', + label='Bar2', + tip='', + icon='')) + + menuitem = Caja.MenuItem(name='ExampleMenuProvider::Foo2', + label='Foo2', + tip='', + icon='') + menuitem.set_submenu(submenu) + + return menuitem, + @@ -159,7 +141,7 @@ class OpenTerminalExtension(caja.MenuProvider): Passive Methods - caja.MenuProvider.get_file_items + Caja.MenuProvider.get_file_items get_file_items @@ -174,22 +156,22 @@ class OpenTerminalExtension(caja.MenuProvider): menu : - a list of caja.FileInfo objects. + a list of Caja.FileInfo objects. Returns : - a list of caja.MenuItem objects + a list of Caja.MenuItem objects The get_file_items() method returns a list of - caja.MenuItem objects. + Caja.MenuItem objects. - caja.MenuProvider.get_file_items_full + Caja.MenuProvider.get_file_items_full get_file_items_full @@ -201,7 +183,7 @@ class OpenTerminalExtension(caja.MenuProvider): provider : - the current caja.MenuProvider instance + the current Caja.MenuProvider instance window : @@ -209,21 +191,21 @@ class OpenTerminalExtension(caja.MenuProvider): files : - a list of caja.FileInfo objects. + a list of Caja.FileInfo objects. Returns : - a list of caja.MenuItem objects + a list of Caja.MenuItem objects The get_file_items_full() method returns a list of - caja.MenuItem objects. + Caja.MenuItem objects. This method was created in order to allow extension writers to call the - caja.MenuProvider.emit_items_updated_signal, which must + Caja.menu_provider_emit_items_updated_signal, which must be passed the current provider instance. @@ -233,7 +215,7 @@ class OpenTerminalExtension(caja.MenuProvider): - caja.MenuProvider.get_background_items + Caja.MenuProvider.get_background_items get_background_items @@ -248,22 +230,22 @@ class OpenTerminalExtension(caja.MenuProvider): folder : - the current folder, as a caja.FileInfo object. + the current folder, as a Caja.FileInfo object. Returns : - a list of caja.MenuItem objects + a list of Caja.MenuItem objects The get_background_items() method returns a list of - caja.MenuItem objects. + Caja.MenuItem objects. - caja.MenuProvider.get_background_items_full + Caja.MenuProvider.get_background_items_full get_background_items_full @@ -275,7 +257,7 @@ class OpenTerminalExtension(caja.MenuProvider): provider : - the current caja.MenuProvider instance + the current Caja.MenuProvider instance window : @@ -283,21 +265,21 @@ class OpenTerminalExtension(caja.MenuProvider): folder : - the current folder, as a caja.FileInfo object. + the current folder, as a Caja.FileInfo object. Returns : - a list of caja.MenuItem objects + a list of Caja.MenuItem objects The get_background_items_full() method returns a list of - caja.MenuItem objects. + Caja.MenuItem objects. This method was created in order to allow extension writers to call the - caja.MenuProvider.emit_items_updated_signal, which must + Caja.menu_provider_emit_items_updated_signal, which must be passed the current provider instance. @@ -305,96 +287,23 @@ class OpenTerminalExtension(caja.MenuProvider): - - - caja.MenuProvider.get_toolbar_items - - - get_toolbar_items - window - folder - - - - - window : - the current gtk.Window instance - - - folder : - the current folder, as a caja.FileInfo object. - - - Returns : - a list of caja.MenuItem objects - - - - - The get_toolbar_items() method returns a list of - caja.MenuItem objects. - - - - - caja.MenuProvider.get_toolbar_items_full - - - get_toolbar_items_full - provider - window - folder - - - - - provider : - the current caja.MenuProvider instance - - - window : - the current gtk.Window instance - - - folder : - the current folder, as a caja.FileInfo object. - - - Returns : - a list of caja.MenuItem objects - - - - - The get_toolbar_items_full() method returns a list of - caja.MenuItem objects. - - - This method was created in order to allow extension writers to call the - caja.MenuProvider.emit_items_updated_signal, which must - be passed the current provider instance. - - - This method was introduced in caja-python 0.7.0. - - Active Methods - caja.MenuProvider.emit_items_updated_signal + Caja.menu_provider_emit_items_updated_signal - emit_items_updated_signal + menu_provider_emit_items_updated_signal provider provider : - the current caja.MenuProvider instance + the current Caja.MenuProvider instance @@ -417,7 +326,7 @@ class OpenTerminalExtension(caja.MenuProvider): Signal Details - The "items-updated" caja.MenuProvider Signal + The "items-updated" Caja.MenuProvider Signal Emits the "items-updated" signal. diff --git a/docs/reference/caja-python-menu.xml b/docs/reference/caja-python-menu.xml index 678585b..95fa94f 100644 --- a/docs/reference/caja-python-menu.xml +++ b/docs/reference/caja-python-menu.xml @@ -4,8 +4,8 @@ - caja.Menu - caja.Menu Reference + Caja.Menu + Caja.Menu Reference @@ -16,11 +16,11 @@ Synopsis - caja.Menu + Caja.Menu gobject.GObject - caja.Menu + Caja.Menu @@ -43,7 +43,7 @@ Ancestry +-- gobject.GObject - +-- caja.Menu + +-- Caja.Menu @@ -56,7 +56,7 @@ Description - A caja.Menu object allows an extension to create sub-menus. + A Caja.Menu object allows an extension to create sub-menus. @@ -71,11 +71,11 @@ Constructor - caja.Menu + Caja.Menu - Creates a new caja.Menu object. + Creates a new Caja.Menu object. @@ -89,7 +89,7 @@ Public Methods - caja.Menu.append_item + Caja.Menu.append_item append_item item @@ -97,22 +97,22 @@ item : - a caja.MenuItem + a Caja.MenuItem - Append a caja.MenuItem to a caja.Menu. + Append a Caja.MenuItem to a Caja.Menu. - caja.Menu.get_items + Caja.Menu.get_items get_items - Returns a list of caja.MenuItem objects attached to the caja.Menu. + Returns a list of Caja.MenuItem objects attached to the Caja.Menu. diff --git a/docs/reference/caja-python-operation-result.xml b/docs/reference/caja-python-operation-result.xml index 3720f2f..ee13b01 100644 --- a/docs/reference/caja-python-operation-result.xml +++ b/docs/reference/caja-python-operation-result.xml @@ -4,8 +4,8 @@ - caja.OperationResult - caja.OperationResult Reference + Caja.OperationResult + Caja.OperationResult Reference @@ -18,8 +18,8 @@ Description - The caja.OperationResult constants are - used by the caja.InfoProvider provider to + The Caja.OperationResult constants are + used by the Caja.InfoProvider provider to notify Caja what the extension intends to do when Caja calls the extension's update_file_info_full method. The possible values are as follows: @@ -27,20 +27,20 @@ - caja.OPERATION_COMPLETE + Caja.OperationResult.COMPLETE The operation is complete and Caja can move on to the next update_file_info_full call. - caja.OPERATION_IN_PROGRESS + Caja.OperationResult.IN_PROGRESS - The operation is in progress and running asynchronously and Caja should wait until the update_complete_invoke method + The operation is in progress and running asynchronously and Caja should wait until the Caja.info_provider_update_complete_invoke method is called before moving on to the next update_file_info_full call. - caja.OPERATION_FAILED + Caja.OperationResult.FAILED The operation has failed. diff --git a/docs/reference/caja-python-overview-example.xml b/docs/reference/caja-python-overview-example.xml index b429365..ea1175d 100644 --- a/docs/reference/caja-python-overview-example.xml +++ b/docs/reference/caja-python-overview-example.xml @@ -11,49 +11,43 @@ A Simple Extension -import caja - -class SimpleMenuExtension(caja.MenuProvider): -def __init__(self): - pass - -def menu_activate_cb(self, menu, file): - print "menu_activate_cb",file - -def get_file_items(self, window, files): - if len(files) != 1: - return - - file = files[0] - - item = caja.MenuItem( - "SimpleMenuExtension::Show_File_Name", - "Showing %s" % file.get_name(), - "Showing %s" % file.get_name() - ) - item.connect('activate', self.menu_activate_cb, file) - - return [item] +from gi.repository import Caja, GObject + +class ColumnExtension(GObject.GObject, Caja.MenuProvider): + def __init__(self): + pass + + def menu_activate_cb(self, menu, file): + print "menu_activate_cb",file + + def get_file_items(self, window, files): + if len(files) != 1: + return + + file = files[0] + + item = Caja.MenuItem( + name="SimpleMenuExtension::Show_File_Name", + label="Showing %s" % file.get_name(), + tip="Showing %s" % file.get_name() + ) + item.connect('activate', self.menu_activate_cb, file) + + return [item] - Save this file as TestExtension.py in the ~/.caja/python-extensions folder. - You may need to create this folder. To run, open the terminal and type: - - - -$ caja -q -$ caja --no-desktop - + Save this file as TestExtension.py in the ~/.local/share/caja-python/extensions folder. + You may need to create this folder. To run, simply restart Caja. - Once Caja starts, right-click on a file and you should see a new menu item, + Once Caja restarts, right-click on a file and you should see a new menu item, "Showing #filename#". It is as simple as that! As mentioned above, in order to - get loaded by Caja, a python extension must import the caja module, - create a class derived from a caja *Provider, then create the methods that + get loaded by Caja, a python extension must import the Caja module from gi.repository, + create a class derived from a caja *Provider and a gobject.GObject, and create the methods that will be called by Caja when it requests information from its providers. In this case, when someone right-clicks on a file, Caja will ask all of its MenuProviders for additional menu items to show the user. When folders or files are clicked, - the get_file_items method is called and a list of caja.MenuItems is expected. + the get_file_items method is called and a list of Caja.MenuItems is expected. diff --git a/docs/reference/caja-python-overview-methods.xml b/docs/reference/caja-python-overview-methods.xml index 973aecd..2a86a92 100644 --- a/docs/reference/caja-python-overview-methods.xml +++ b/docs/reference/caja-python-overview-methods.xml @@ -10,8 +10,8 @@ Because caja-python is an interface to a Caja' extension interface rather than a true library, it is rather quirky in how it works. One example of this is that several providers have additional public methods that an extension actively calls, rather than the extension defining and the method in their class that is called by - Caja. You can see this with the caja.MenuProvider.emit_items_updated_signal - and caja.InfoProvider.update_complete_invoke methods, which + Caja. You can see this with the Caja.menu_provider_emit_items_updated_signal + and Caja.info_provider_update_complete_invoke methods, which the extension actively calls, passing the provider instance as a parameter. diff --git a/docs/reference/caja-python-overview.xml b/docs/reference/caja-python-overview.xml index e92dedf..8c778dd 100644 --- a/docs/reference/caja-python-overview.xml +++ b/docs/reference/caja-python-overview.xml @@ -6,9 +6,9 @@ Overview - Writing a Caja-Python extension is a fairly straight-forward process. - One simply imports the caja module and creates a class which is derived from a number - of the caja module's classes. When an extension derives a class, it becomes a "provider", + Writing a Caja-Python extension is a fairly straight-forward process. + One simply imports the Caja module from the gobject introspection repository and creates a class which is derived from a gobject.GObject and + one of the Caja module's classes. When an extension derives a class, it becomes a "provider", telling Caja to ask it for information. There are several types of providers available for extensions to use: there is MenuProvider, LocationWidgetProvider, ColumnProvider, PropertyPageProvider, and InfoProvider, all of which will be explained @@ -16,20 +16,25 @@ Here are the basic steps: - 1. A script is written and installed to the standard python extensions install path - 2. Caja is (re)started and loads the Caja-Python C extension, which in turn loads all python extensions - 3. Any python script in the standard python extensions install path that imports the caja module and derives - the main class from a caja module class will be loaded + 1. A script is written and installed to the standard caja-python extension install path + 2. Caja is (re)started and loads the caja-python C extension, which in turn loads all python extensions it can find + 3. Any python script in the standard caja-python extension install path that imports the Caja module from the gobject introspection repository and derives + the main class from a Caja module class will be loaded A note about the standard python extensions install path -The install path for individual users is ~/.caja/python-extensions. -The system-wide install path is $PREFIX/lib/caja/extensions-2.0/python. However, some 64 bit distributions, -such as Fedora, put Caja-Python extensions in $PREFIX/lib64/caja/extensions-2.0/python. -As of caja-python 0.7.0, caja-python looks in ~/.local/share/caja-python/extensions +As of caja-python 0.7.0 (and continued in 1.0+), caja-python looks in ~/.local/share/caja-python/extensions for local extensions and $PREFIX/share/caja-python/extensions for global extensions. + + +A note about compatibility issues for caja-python 1.0 + 1. We no longer support the "import caja" command that previous versions used. This is because + caja-python now directly uses Caja's annotations, which must be imported by the "from gi.repository import Caja" command. + 2. The extension class must now derive itself from a gobject.GObject in addition to the standard Caja classes. + 3. For now, some Caja class constructors require passing named arguments instead of a standard argument list. This requirement may go away at some point. + diff --git a/docs/reference/caja-python-property-page-provider.xml b/docs/reference/caja-python-property-page-provider.xml index 1ecb50f..8cb3662 100644 --- a/docs/reference/caja-python-property-page-provider.xml +++ b/docs/reference/caja-python-property-page-provider.xml @@ -4,8 +4,8 @@ - caja.PropertyPageProvider - caja.PropertyPageProvider Reference + Caja.PropertyPageProvider + Caja.PropertyPageProvider Reference @@ -16,7 +16,7 @@ Synopsis - caja.PropertyPageProvider + Caja.PropertyPageProvider get_pages @@ -38,15 +38,14 @@ - caja.PropertyPageProvider Example + Caja.PropertyPageProvider Example import hashlib import urllib -import gtk -import caja +from gi.repository import Caja, GObject, Gtk -class MD5SumPropertyPage(caja.PropertyPageProvider): +class ColumnExtension(GObject.GObject, Caja.PropertyPageProvider): def __init__(self): pass @@ -63,25 +62,31 @@ class MD5SumPropertyPage(caja.PropertyPageProvider): filename = urllib.unquote(file.get_uri()[7:]) - self.property_label = gtk.Label('MD5Sum') + self.property_label = Gtk.Label('MD5Sum') self.property_label.show() - self.hbox = gtk.HBox(0, False) + self.hbox = Gtk.HBox(homogeneous=False, spacing=0) self.hbox.show() - label = gtk.Label('MD5Sum:') + label = Gtk.Label('MD5Sum:') label.show() - self.hbox.pack_start(label) + self.hbox.pack_start(label, False, False, 0) - self.value_label = gtk.Label() - self.hbox.pack_start(self.value_label) + self.value_label = Gtk.Label() + self.hbox.pack_start(self.value_label, False, False, 0) - md5sum = hashlib.md5(filename).hexdigest() - self.value_label.set_text(md5sum) + md5sum = hashlib.md5() + with open(filename,'rb') as f: + for chunk in iter(lambda: f.read(8192), ''): + md5sum.update(chunk) + f.close() + + self.value_label.set_text(md5sum.hexdigest()) self.value_label.show() - return caja.PropertyPage("CajaPython::md5_sum", - self.property_label, self.hbox), + return Caja.PropertyPage(name="CajaPython::md5_sum", + label=self.property_label, + page=self.hbox), @@ -95,7 +100,7 @@ class MD5SumPropertyPage(caja.PropertyPageProvider): Passive Methods - caja.PropertyPageProvider.get_pages + Caja.PropertyPageProvider.get_pages get_pages @@ -105,11 +110,11 @@ class MD5SumPropertyPage(caja.PropertyPageProvider): files : - a list of caja.FileInfo objects. + a list of Caja.FileInfo objects. Returns : - a list of caja.PropertyPage objects + a list of Caja.PropertyPage objects diff --git a/docs/reference/caja-python-property-page.xml b/docs/reference/caja-python-property-page.xml index c1131ff..706dafa 100644 --- a/docs/reference/caja-python-property-page.xml +++ b/docs/reference/caja-python-property-page.xml @@ -4,8 +4,8 @@ - caja.PropertyPage - caja.PropertyPage Reference + Caja.PropertyPage + Caja.PropertyPage Reference @@ -16,11 +16,11 @@ Synopsis - caja.PropertyPage + Caja.PropertyPage gobject.GObject - caja.PropertyPage + Caja.PropertyPage name label page @@ -36,7 +36,7 @@ Ancestry +-- gobject.GObject - +-- caja.PropertyPage + +-- Caja.PropertyPage @@ -49,7 +49,7 @@ Description - A caja.PropertyPage object is returned by caja.PropertyPageProvider extensions. + A Caja.PropertyPage object is returned by Caja.PropertyPageProvider extensions. @@ -103,7 +103,7 @@ Constructor - caja.PropertyPage + Caja.PropertyPage name label page @@ -125,7 +125,7 @@ - Creates a new caja.PropertyPage object. + Creates a new Caja.PropertyPage object. -- cgit v1.2.1