Thunarx.Renamer¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Box (14), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Orientable (2)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Gtk.Box (3), Gtk.Container (3), Gtk.Widget (39), Gtk.Orientable (1)
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The URL to the documentation of the renamer |
Child Properties¶
- Inherited:
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Derived classes should emit this signal using the |
Fields¶
- Inherited:
Class Details¶
- class Thunarx.Renamer(*args, **kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
- changed()¶
This method should be used by derived classes to emit the “changed” signal for self. See the documentation of the “changed” signal for details.
- get_help_url()¶
- Returns:
the URL of the documentation for self.
- Return type:
Returns the URL of the documentation for self or
None
if no specific documentation is available for self and the general documentation of the Thunar renamers should be displayed instead.
- Parameters:
window (
Gtk.Window
) – aGtk.Window
orNone
.files ([
Thunarx.FileInfo
]) – aGLib.List
ofThunarx.FileInfo
<!—->s.
- Returns:
the list of
Thunarx.MenuItem
<!—->s provided by self for the given list of files.- Return type:
Returns the list of
Thunarx.MenuItem
<!—->s provided by self for the given list of files. By default, this method returnsNone
(the empty list), but derived classes may override this method to provide additional items for files in the bulk renamer dialog list.The returned
Thunarx.MenuItem
<!—->s will be displayed in the file’s context menu of the bulk renamer dialog, when this self is active. For example, an ID3-Tag based renamer may add an menu item “Edit Tags” to the context menus of supported media files and, when activated, display a dialog (which should be transient and modal for window, if notNone
), which allows the users to edit media file tags on-the-fly.Derived classes that override this method should always check first if all the
Thunarx.FileInfo
<!—->s in the list of files are supported, and only return menu items that can be performed on this specific list of files. For example, the ID3-Tag renamer mentioned above, should first check whether all items in files are actually audio files. TheThunarx.FileInfo.has_mime_type
() of theThunarx.FileInfo
interface can be used to easily test whether a file in the files list is of a certain MIME type.Some menu items may only work properly if only a single file is selected (for example, the ID3-Tag renamer will probably only supporting editing one file at a time). In this case you have basicly two options: Either you can return
None
here if files does not contain exactly one item, or you can return the menu items as usual, but make them insensitive, using:thunarx_menu_item_set_sensitive (item, FALSE);
The latter has the advantage that the user will still notice the existance of the menu item and probably realize that it can only be applied to a single item at once.The caller is responsible to free the returned list using something like the following:
g_list_free_full (list, g_object_unref);
As a special note, this method automatically takes a reference on the self for everyThunarx.MenuItem
object returned from the real implementation of this method in self. This is to make sure that the extension stays in memory for at least the time that the menu items are used.The name of
Thunarx.MenuItem
<!—->s returned from this method must be namespaced with the module to avoid collision with internal file manager menu items and menu items provided by other extensions. For example, the menu item provided by the ID3-Tag renamer mentioned above, should be namedTagRenamer::edit-tags
(ifTagRenamer
is the class name). For additional information about the wayThunarx.MenuItem
<!—->s should be returned from extensions and the way they are used, read the description of theThunarx.MenuProvider
interface or read the introduction provided with this reference manual.A note of warning concerning the window parameter. Plugins should avoid taking a reference on window, as that might introduce a circular reference and can thereby cause a quite large memory leak. Instead, if window is not
None
, add a weak reference using the g_object_weak_ref() or g_object_add_weak_pointer() method. But don’t forget to release the weak reference if window survived the lifetime of your menu item (which is likely to be the case in most situations).
- get_name()¶
- Returns:
the user visible name for self.
- Return type:
Returns the user visible name for self, previously set with
Thunarx.Renamer.set_name
().
- load(settings)¶
- Parameters:
settings ({
object
:object
}) – aGLib.HashTable
which contains the previously saved settings for self as key/value pairs of strings.
Tells self to load its internal settings from the specified settings. The settings hash table contains previously saved settings, see
Thunarx.Renamer.save
(), as key/value pairs of strings. That is, both the keys and the values are strings.Implementations of
Thunarx.Renamer
may decide to override this method to perform custom loading of settings. If you do not override this method, the default method ofThunarx.Renamer
will be used, which simply loads allGObject.Object
properties provided by self<!—->s class (excluding the ones provided by the parent classes) from the settings. TheGObject.Object
properties must be transformable to strings and from strings.If you decide to override this method for your
Thunarx.Renamer
implementation, you should also overrideThunarx.Renamer.save
().
- process(file, text, index)¶
- Parameters:
file (
Thunarx.FileInfo
) – theThunarx.FileInfo
for the file whose new name - according to self - should be determined.text (
str
) – the part of the filename to which the self should be applied.index (
int
) – the index of the file in the list, used for renamers that work on numbering.
- Returns:
the string with which to replace text.
- Return type:
Determines the replacement for text (which is the relevant part of the full file name, i.e. either the suffix, the name or the name and the suffix).
The caller is responsible to free the returned string using
GLib.free
() when no longer needed.
- save(settings)¶
- Parameters:
settings ({
object
:object
}) – aGLib.HashTable
to which the current settings of self should be stored as key/value pairs of strings.
Tells self to save its internal settings to the specified settings, which can afterwards be loaded by
Thunarx.Renamer.load
().The strings saved to settings must be allocated by
GLib.strdup
(), both the keys and the values. For example to store the stringBar
for the settingFoo
, you’d use:g_hash_table_replace (settings, g_strdup ("Foo"), g_strdup ("Bar"));
Implementations of
Thunarx.Renamer
may decide to override this method to perform custom saving of settings. If you do not overrride this method, the default method ofThunarx.Renamer
will be used, which simply stores allGObject.Object
properties provided by the self<!—->s class (excluding the ones provided by the parent classes) to the settings. TheGObject.Object
properties must be transformable to strings.If you decide to override this method for your
Thunarx.Renamer
implementation, you should also overrideThunarx.Renamer.load
().
- set_help_url(help_url)¶
- Parameters:
help_url (
str
) – the new URL to the documentation of self.
The URL to the documentation of this
Thunarx.Renamer
. Derived classes can set this property to point to the documentation for the specific renamer. The documentation of the specific renamer in turn should contain a link to the general Thunar renamer documentation.May also be unset, in which case the general Thunar renamer documentation will be shown when the user clicks the “Help” button.
- set_name(name)¶
- Parameters:
name (
str
) – the new user visible name for self.
Sets the user visible name for self to name. This method should only be called by derived classes and prior to returning the self is returned from thunarx_renamer_provider_get_renamers().
- do_changed() virtual¶
This method should be used by derived classes to emit the “changed” signal for renamer. See the documentation of the “changed” signal for details.
- Parameters:
window (
Gtk.Window
) – aGtk.Window
orNone
.files ([
Thunarx.FileInfo
]) – aGLib.List
ofThunarx.FileInfo
<!—->s.
- Returns:
the list of
Thunarx.MenuItem
<!—->s provided by renamer for the given list of files.- Return type:
Returns the list of
Thunarx.MenuItem
<!—->s provided by renamer for the given list of files. By default, this method returnsNone
(the empty list), but derived classes may override this method to provide additional items for files in the bulk renamer dialog list.The returned
Thunarx.MenuItem
<!—->s will be displayed in the file’s context menu of the bulk renamer dialog, when this renamer is active. For example, an ID3-Tag based renamer may add an menu item “Edit Tags” to the context menus of supported media files and, when activated, display a dialog (which should be transient and modal for window, if notNone
), which allows the users to edit media file tags on-the-fly.Derived classes that override this method should always check first if all the
Thunarx.FileInfo
<!—->s in the list of files are supported, and only return menu items that can be performed on this specific list of files. For example, the ID3-Tag renamer mentioned above, should first check whether all items in files are actually audio files. TheThunarx.FileInfo.has_mime_type
() of theThunarx.FileInfo
interface can be used to easily test whether a file in the files list is of a certain MIME type.Some menu items may only work properly if only a single file is selected (for example, the ID3-Tag renamer will probably only supporting editing one file at a time). In this case you have basicly two options: Either you can return
None
here if files does not contain exactly one item, or you can return the menu items as usual, but make them insensitive, using:thunarx_menu_item_set_sensitive (item, FALSE);
The latter has the advantage that the user will still notice the existance of the menu item and probably realize that it can only be applied to a single item at once.The caller is responsible to free the returned list using something like the following:
g_list_free_full (list, g_object_unref);
As a special note, this method automatically takes a reference on the renamer for everyThunarx.MenuItem
object returned from the real implementation of this method in renamer. This is to make sure that the extension stays in memory for at least the time that the menu items are used.The name of
Thunarx.MenuItem
<!—->s returned from this method must be namespaced with the module to avoid collision with internal file manager menu items and menu items provided by other extensions. For example, the menu item provided by the ID3-Tag renamer mentioned above, should be namedTagRenamer::edit-tags
(ifTagRenamer
is the class name). For additional information about the wayThunarx.MenuItem
<!—->s should be returned from extensions and the way they are used, read the description of theThunarx.MenuProvider
interface or read the introduction provided with this reference manual.A note of warning concerning the window parameter. Plugins should avoid taking a reference on window, as that might introduce a circular reference and can thereby cause a quite large memory leak. Instead, if window is not
None
, add a weak reference using the g_object_weak_ref() or g_object_add_weak_pointer() method. But don’t forget to release the weak reference if window survived the lifetime of your menu item (which is likely to be the case in most situations).
- do_load(settings) virtual¶
- Parameters:
settings ({
object
:object
}) – aGLib.HashTable
which contains the previously saved settings for renamer as key/value pairs of strings.
Tells renamer to load its internal settings from the specified settings. The settings hash table contains previously saved settings, see
Thunarx.Renamer.save
(), as key/value pairs of strings. That is, both the keys and the values are strings.Implementations of
Thunarx.Renamer
may decide to override this method to perform custom loading of settings. If you do not override this method, the default method ofThunarx.Renamer
will be used, which simply loads allGObject.Object
properties provided by renamer<!—->s class (excluding the ones provided by the parent classes) from the settings. TheGObject.Object
properties must be transformable to strings and from strings.If you decide to override this method for your
Thunarx.Renamer
implementation, you should also overrideThunarx.Renamer.save
().
- do_process(file, text, index) virtual¶
- Parameters:
file (
Thunarx.FileInfo
) – theThunarx.FileInfo
for the file whose new name - according to renamer - should be determined.text (
str
) – the part of the filename to which the renamer should be applied.index (
int
) – the index of the file in the list, used for renamers that work on numbering.
- Returns:
the string with which to replace text.
- Return type:
Determines the replacement for text (which is the relevant part of the full file name, i.e. either the suffix, the name or the name and the suffix).
The caller is responsible to free the returned string using
GLib.free
() when no longer needed.
- do_save(settings) virtual¶
- Parameters:
settings ({
object
:object
}) – aGLib.HashTable
to which the current settings of renamer should be stored as key/value pairs of strings.
Tells renamer to save its internal settings to the specified settings, which can afterwards be loaded by
Thunarx.Renamer.load
().The strings saved to settings must be allocated by
GLib.strdup
(), both the keys and the values. For example to store the stringBar
for the settingFoo
, you’d use:g_hash_table_replace (settings, g_strdup ("Foo"), g_strdup ("Bar"));
Implementations of
Thunarx.Renamer
may decide to override this method to perform custom saving of settings. If you do not overrride this method, the default method ofThunarx.Renamer
will be used, which simply stores allGObject.Object
properties provided by the renamer<!—->s class (excluding the ones provided by the parent classes) to the settings. TheGObject.Object
properties must be transformable to strings.If you decide to override this method for your
Thunarx.Renamer
implementation, you should also overrideThunarx.Renamer.load
().
Signal Details¶
- Thunarx.Renamer.signals.changed(renamer)¶
- Signal Name:
changed
- Flags:
- Parameters:
renamer (
Thunarx.Renamer
) – The object which received the signal
Derived classes should emit this signal using the
Thunarx.Renamer.changed
() method whenever the user changed a setting in the renamer GUI.The file manager will then invoke
Thunarx.Renamer.process
() for all files that should be renamed and update the preview.
Property Details¶
- Thunarx.Renamer.props.help_url¶
-
The URL to the documentation of this
Thunarx.Renamer
. Derived classes can set this property to point to the documentation for the specific renamer. The documentation of the specific renamer in turn should contain a link to the general Thunar renamer documentation.May also be unset, in which case the general Thunar renamer documentation will be shown when the user clicks the “Help” button.