ofn3-resource-manager

# ofn3-resource manager

This plugin lets you quickly activate or deactivate collections of resources. This reduces clutter in the resources lists and improves Gimp performance by reducing the number of resources it needs to cache. To do so:

- Resource collections are kept in a separate folder, either as ZIP or as folders.
- When they are put online, they appear as subfolders in a folder that Gimp searches for resources
  - ZIP files are uncompressed in a like-named folder
  - Collection folders are either copied or linked (they are linked by default on systems that allow it: OSX and Linux)
- When they are put offline, the folder that was created when they were put online is erased (warning:: this can cause data loss if you save data in such folders)
- The plugin doesn’t track which collection has been activated by the plugin. It is assumed that any folder in the active Gimp folder that correspond to a like-named collection in the storage folder is an activated collection.

## Installation

- copy all the `.py` files in a `ofn3-resource-manager` subfolder of the plug-ins folder in your profile or in the Gimp installation tree (`/usr/lib/gimp/2.0/plug-ins/` for linux users)
- on Linux and OSX, make sure that `ofn3-resource-manager.py` has its executable flag set: `chmod +x ofn3-resource-manager.py`
- The `ofn3-resource-manager.ini` file is searched in that order:
  - in the `plug-in-settings` subfolder of the user’s Gimp profile
  - in the same folder as `ofn3-resource-manager.py`

## Usage

### File system preparation

- For each enabled resource type, there should be a “storage” folder (ie, one for brushes, one for palettes…)
- With the default configuration this is a sibling if the active resource folder in the user profile (for instance `brushes_storage` alongside `brushes`).
- This storage folder will in turn contain:
  - child folders with one or more resource (each such folder is an individually selectable set)
  - ZIP files with one or more addons (each such ZIP is an individually selectable set)

To activate a collection, the manager makes the resources appear in one of the folders Gimp uses for active resources (see `Edit > Preferences > Folders`)

### Invocation

Using the default configuration, the plugin is started for the relevant list of resources:

### Configuration file

If used, the configuration file should be named after the script name (`ofn3-resource-manager.ini`, unless you rename the script). It is searched in that order: * in the `plug-in-settings` subfolder of the user’s Gimp profile * in the same folder as `ofn3-resource-manager.py`

The configuration file has a section for each of the managed resource types (brushes, patterns…). A section starts with its name between brackets: `[section]`

There is also a `[common]` section for general settings and for settings that have a common value across several sections (unless overriden by a specific setting in other sections).

The configurable items so far are:

#### In `common`:

- `enable`: the list of types with an addon managers

#### In resource types sections (or [common]):

- `resources_active`: the folder for active resources (where Gimp looks for them, typically in your Gimp profile)
- `resources_stored`: the folder for managed resources (where the manager looks for them)
- `use_links`: [`yes`|`no`]: use symbolic links instead of copy when the operating system allows it.
- `menu_path`: the location in the Gimp menus for the menu entry to start the resource manager
- `menu_label`: the label on the menu entry for the resource manager
- `menu_blurb`: the description that pops up when you hower the mouse above the menu entry
- `dialog_title`: the title of the resource manager dialog

For all these items, some specific values dynamically replaced when reading the configuration:

- `${user_home}`: the user’s home folder
- `${gimp_user}`: the user’s Gimp profile folder
- `${gimp_data}`: the global Gimp data folder (in the Gimp installation tree, in Linux: `/usr/share/gimp/2.0/`)
- `${type_l}`: the lower case name of the resource types: “brushes”
- `${type_c}`: the capitalized name of the resource types: “Brushes”

These last two items can be used for menu locations and folders.

The default settings correspond to the following configuration:

    [common]
    enable:brushes dynamics fonts gradients palettes patterns
    resources_active: ${gimp_user}/${type_l}
    resources_stored: ${gimp_user}/${type_l}_storage
    menu_path: <${type_c}>/${type_c} Menu
    menu_label: Manage ${type_l} sets...
    menu_blurb: Put online/offline sets of ${type_l}
    dialog_title: ${type_c} sets manager

    # No data in specific sections in the default configuration
    [brushes]
    [dynamics]
    [fonts]
    [gradients]
    [palettes]
    [patterns]

In the end, the folder structure should look like this:

    {gimp_user_profile}
    ├── brushes/
    │   └── Untitled.vbr
    ├── palettes/                   # Active palette folder used by Gimp
    │   ├── Firecode-copy.gpl
    │   ├── Greens/                 # Palette set activated by plugin
    │   │   ├── Greens-copy-#1.gpl  # (folder or ZIP with same name in the *_storage)
    │   │   ├── Greens-copy-#2.gpl
    │   │   ├── Greens-copy-#3.gpl
    │   │   └── Greens-copy.gpl
    │   ├── PaletteFromImage.gpl
    │   └── PaletteFromImage-RC2.gpl
    ├── palettes_storage/           # Storage palette folder
    │   ├── Altitude/               # Inactive palette set
    │   │   └── Altitude.gpl
    │   └── Greens/                 # Activated palette set
    │       ├── Greens-copy-#1.gpl  # (folder with same name in the active folder)
    │       ├── Greens-copy-#2.gpl
    │       ├── Greens-copy-#3.gpl
    │       └── Greens-copy.gpl
    ├── patterns/                   # Active pattern folder used by Gimp
    │   └── JpegPattern.jpg
    ├── patterns_storage/           # Storage pattern folder
    │   └── Colors.zip              # A collection as a ZIP
    ├── plug-ins/
    │    ├── ofn3-resource-manager/
    │    │    ├── configuration.py
    │    │    ├── container.py
    │    │    ├── gimphelpers.py
    │    │    ├── manager.py
    │    │    ├── ofn3-resource-manager.ini  # Possible location
    │    │    └── ofn3-resource-manager.py
    │    └── {other plugins}
    ├── plug-in-settings/
    │   ├── ofn3-resource-manager.ini  # Possible location
    │   └── {other files}

## Notes

### Registration

Gimp updates the registration data for the plugins only when it notices a new plugin executable, or when an already registered executable changes (according to the file change date). Changing the menu-related configuration items above requires Gimp to update its registration data, but since the plugin file itself hasn’t changed it will not notice it.

You can force Gimp to re-acquire the registration data using one the three methods below:

- Editing the `pluginrc` file in the Gimp profile, locating the line starting with `(plug-in-def` that bears the plugin file name, and delete the file contents from that line up to and not including the next `(plug-in-def`.
- Deleting the `pluginrc` file, but this makes Gimp re-run all the plugins for registration the next time it starts.
- Renaming the plugin file. Gimp will delete the registration data obtained under its previous name, and make that new plugin register itself.