ThunarxRenamer

ThunarxRenamer — The abstract base class for bulk renamers

Synopsis

#include <thunarx/thunarx.h>

                    ThunarxRenamer;
struct              ThunarxRenamerClass;
const gchar *       thunarx_renamer_get_help_url        (ThunarxRenamer *renamer);
void                thunarx_renamer_set_help_url        (ThunarxRenamer *renamer,
                                                         const gchar *help_url);
const gchar *       thunarx_renamer_get_name            (ThunarxRenamer *renamer);
void                thunarx_renamer_set_name            (ThunarxRenamer *renamer,
                                                         const gchar *name);
gchar *             thunarx_renamer_process             (ThunarxRenamer *renamer,
                                                         ThunarxFileInfo *file,
                                                         const gchar *text,
                                                         guint index);
void                thunarx_renamer_load                (ThunarxRenamer *renamer,
                                                         GHashTable *settings);
void                thunarx_renamer_save                (ThunarxRenamer *renamer,
                                                         GHashTable *settings);
GList *             thunarx_renamer_get_actions         (ThunarxRenamer *renamer,
                                                         GtkWindow *window,
                                                         GList *files);
void                thunarx_renamer_changed             (ThunarxRenamer *renamer);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkBox
                                 +----GtkVBox
                                       +----ThunarxRenamer

Implemented Interfaces

ThunarxRenamer implements AtkImplementorIface, GtkBuildable and GtkOrientable.

Properties

  "help-url"                 gchar*                : Read / Write
  "name"                     gchar*                : Read / Write / Construct Only

Signals

  "changed"                                        : Run First

Description

The abstract base class ThunarxRenamer is implemented by extensions which provide additional bulk renamers that should be used in the bulk rename dialog.

Derived classes must override the thunarx_renamer_process() method, which is called by the bulk rename dialog for every file to generate a new name. For example, the ThunarSbrReplaceRenamer class included in the thunar-sbr plugin (which is part of the Thunar distribution) provides a bulk renamer, named Search & Replace, which allows the user to rename multiple files by searching for a pattern in each file name and, if the pattern is found, replacing it with the specified replacement text.

The active ThunarxRenamers user interface is displayed in a frame below the file list, as shown in the screenshot above. Derived classes should try to limit the number of widgets displayed in the main user interface. For example, if you have more than six settings, you should consider adding an Advanced, button which opens a dialog with the additional settings.

Details

ThunarxRenamer

typedef struct _ThunarxRenamer ThunarxRenamer;

Abstract base instance type for bulk renamers.


struct ThunarxRenamerClass

struct ThunarxRenamerClass {
  /* virtual methods */
  gchar *(*process)     (ThunarxRenamer  *renamer,
                         ThunarxFileInfo *file,
                         const gchar     *text,
                         guint            index);

  void   (*load)        (ThunarxRenamer  *renamer,
                         GHashTable      *settings);
  void   (*save)        (ThunarxRenamer  *renamer,
                         GHashTable      *settings);

  GList *(*get_actions) (ThunarxRenamer  *renamer,
                         GtkWindow       *window,
                         GList           *files);


  /* signals */
  void (*changed) (ThunarxRenamer *renamer);
};

Abstract base class with virtual methods implemented by extensions that provide additional bulk renamers for the integrated bulk rename module in Thunar.

process ()

see thunarx_renamer_process().

load ()

see thunarx_renamer_load().

save ()

see thunarx_renamer_save().

get_actions ()

see thunarx_renamer_get_actions().

changed ()

see thunarx_renamer_changed().

thunarx_renamer_get_help_url ()

const gchar *       thunarx_renamer_get_help_url        (ThunarxRenamer *renamer);

Returns the URL of the documentation for renamer or NULL if no specific documentation is available for renamer and the general documentation of the Thunar renamers should be displayed instead.

renamer :

a ThunarxRenamer.

Returns :

the URL of the documentation for renamer.

thunarx_renamer_set_help_url ()

void                thunarx_renamer_set_help_url        (ThunarxRenamer *renamer,
                                                         const gchar *help_url);

The URL to the documentation of this ThunarxRenamer. 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.

renamer :

a ThunarxRenamer.

help_url :

the new URL to the documentation of renamer.

thunarx_renamer_get_name ()

const gchar *       thunarx_renamer_get_name            (ThunarxRenamer *renamer);

Returns the user visible name for renamer, previously set with thunarx_renamer_set_name().

renamer :

a ThunarxRenamer.

Returns :

the user visible name for renamer.

thunarx_renamer_set_name ()

void                thunarx_renamer_set_name            (ThunarxRenamer *renamer,
                                                         const gchar *name);

Sets the user visible name for renamer to name. This method should only be called by derived classes and prior to returning the renamer is returned from thunarx_renamer_provider_get_renamers().

renamer :

a ThunarxRenamer.

name :

the new user visible name for renamer.

thunarx_renamer_process ()

gchar *             thunarx_renamer_process             (ThunarxRenamer *renamer,
                                                         ThunarxFileInfo *file,
                                                         const gchar *text,
                                                         guint index);

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 g_free() when no longer needed.

renamer :

a ThunarxRenamer.

file :

the ThunarxFileInfo for the file whose new name - according to renamer - should be determined.

text :

the part of the filename to which the renamer should be applied.

Returns :

the string with which to replace text.

thunarx_renamer_load ()

void                thunarx_renamer_load                (ThunarxRenamer *renamer,
                                                         GHashTable *settings);

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 ThunarxRenamer may decide to override this method to perform custom loading of settings. If you do not override this method, the default method of ThunarxRenamer will be used, which simply loads all GObject properties provided by renamers class (excluding the ones provided by the parent classes) from the settings. The GObject properties must be transformable to strings and from strings.

If you decide to override this method for your ThunarxRenamer implementation, you should also override thunarx_renamer_save().

renamer :

a ThunarxRenamer.

settings :

a GHashTable which contains the previously saved settings for renamer as key/value pairs of strings.

thunarx_renamer_save ()

void                thunarx_renamer_save                (ThunarxRenamer *renamer,
                                                         GHashTable *settings);

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 g_strdup(), both the keys and the values. For example to store the string Bar for the setting Foo, you'd use:

1
2
3
4