Theming: GOffice Reference Manual

## Theming Theming — a list of default styles to apply to appropriate graph elements. |

## Functions

gboolean | gog_theme_delete ()
GogTheme * | gog_theme_dup ()
GogTheme * | gog_theme_edit ()
void | gog_theme_foreach ()
void | gog_theme_fillin_style ()
GogAxisColorMap const * | gog_theme_get_color_map ()
char const * | gog_theme_get_description ()
char const * | gog_theme_get_id ()
char const * | gog_theme_get_name ()
GoResourceType | gog_theme_get_resource_type ()
GSList * | gog_theme_registry_get_theme_names ()
GogTheme * | gog_theme_registry_lookup ()
void | gog_theme_save_to_home_dir ()

## Properties

GoResourceType | resource-type | Read / Write / Construct Only

## Types and Values

| GogTheme

## Object Hierarchy

        GObject
        ╰── GogTheme

## Implemented Interfaces

GogTheme implements GOPersist.

## Description

The library provides two hard coded themes, "Default", and "Guppi". Other themes are described in files, some of which might be distributed with the library.

A file defining a theme is an xml file with a <GogTheme> root node. The root element needs to have an Id which should be unique. The uuid command provides such Ids.

The contents must be: _name|name+, _description?|description*, GOStyle+.

_name and name nodes:

The _name node should be used for themes distributed with goffice, localized names will be in *.po files and only the default name for "C" locale needs to be there. Other files need at least one name node for the default name, and might have some translated names with an appropriate "xml:lang" attribute.

_description and description nodes:

These work just like name nodes. The difference is that no description node is mandatory. A theme can work perfectly without a description.

GOStyle nodes:

These nodes actually define the theme. Attributes and contents are: node attributes: class, role. node contents: (line|outline)?, fill?, marker?, font?, text_layout?

The attributes define the target for the style. You might have a class and a role attribute, or just one of them. If the role attribute is given, the class attribute, if given, represents the class of the parent object. A GOStyle node with no class or role will be used as default when another style is missing. If several such nodes exist, the last one will be used. If no default style exists, the "Default" theme is applied for missing nodes. The list of GOStyle nodes might be:

class | role | contents | comments
GogGraph |  | outline, fill
GogGraph | Title | outline, fill, font, text_layout | The graph title
GogChart |  | outline, fill
GogChart | Title | outline, fill, font, text_layout | The chart title
GogLegend |  | outline, fill, font
GogAxis |  | line, font, text_layout
GogAxisLine |  | line, font
GogGrid |  | outline, fill | GogGrid is actually the back plane
| MajorGrid | line, fill
| MinorGrid | line, fill
GogLabel |  | outline, fill, font, text_layout
GogSeries |  | line, fill, marker | One is needed for each entry in the palette
GogTrendLine |  | line
GogRegEqn |  | outline, fill, font, text_layout
GogSeriesLabels |  | outline, fill, font, text_layout
GogRegEqn |  | outline, fill, font, text_layout
GogSeriesLabel |  | outline, fill, font, text_layout
GogDataLabel |  | outline, fill, font, text_layout
GogEquation |  | outline, fill, font, text_layout

The line and outline nodes are actually the same so using line in place of outline is not an issue. A color is specified either using the format RR:GG::BB:AA or a string as defined in rgb.txt, so black can be specified as "black" or "00:00:00:FF".

"line" or "outline" node:

attribute | value
| comments
dash | one of "none", "solid", "s-dot", "s-dash-dot", "s-dash-dot-dot", "dash-dot-dot-dot", "dot", "s-dash", "dash", "l-dash", "dash-dot", or "dash-dot-dot"
color | any color as described above
width | float | not always taken into account

"fill" node

contents: (pattern|gradient)?

attribute | value | comments
type | one of "none", "pattern", or "gradient"

"pattern" node

Should be included in the fill node if type is pattern.

attribute | value
type | one of "solid", "grey75", "grey50", "grey25", "grey12.5", "grey6.25", "horiz", "vert", "rev-diag", "diag", "diag-cross", "thick-diag-cross", "thin-horiz", "thin-vert", "thin-rev-diag", "thin-diag", "thin-horiz-cross", "thin-diag-cross", "foreground-solid", "small-circles","semi-circles", "thatch", "large-circles", or "bricks"
fore | any color as described above
back | any color as described above

"gradient" node

Should be included in the fill node if type is gradient.

attribute | value | comments
direction | one of "n-s", "s-n", "n-s-mirrored", "s-n-mirrored", "w-e", "e-w", "w-e-mirrored", "e-w-mirrored", "nw-se", "se-nw", "nw-se-mirrored", "se-nw-mirrored", "ne-sw", "sw-ne", "sw-ne-mirrored", or "ne-sw-mirrored" |
start_color | any color as described above |
brightness | float | meaningful only for monocolor gradients
end_color | any color as described above | meaningful only for bicolor gradients

"marker" node

attribute | value | comments
shape | one of "none", "square", "diamond", "triangle-down", "triangle-up", "triangle-right", "triangle-left", "circle", "x", "cross", "asterisk", "bar", "half-bar", "butterfly", "hourglass", or "lefthalf-bar" |
fill-color | any color as described above |
outline-color | any color as described above |
size | float | not always taken into account

"font" node

attribute | value
color | any color as described above
font | a string describing the font such as "Sans 10"

"text_layout" node

attribute | value | comments
angle | float | expressed in degrees

## Functions

### gog_theme_delete ()

    gboolean
    gog_theme_delete (GogTheme *theme);

Destroys the theme and remove it from the user directory and from the database.

#### Parameters

theme | a GogTheme |

#### Returns

`TRUE` on success.

### gog_theme_dup ()

    GogTheme *
    gog_theme_dup (GogTheme *theme);

Duplicates `theme` with a new Id.

#### Parameters

theme | a GogTheme |

#### Returns

the new theme.

[transfer full]

### gog_theme_edit ()

    GogTheme *
    gog_theme_edit (GogTheme *theme,
                    GOCmdContext *cc);

Displays a dialog box to edit the theme. This can be done only for locally installed themes that are writeable.

#### Parameters

theme | the GogTheme to edit or `NULL` to create a new one. |
cc | a GOCmdContext or `NULL`. |

#### Returns

The edited theme or `NULL` if the edition has been cancelled.

[transfer none]

### gog_theme_foreach ()

    void
    gog_theme_foreach (GFunc handler,
                       gpointer user_data);

Executes `handler` to each theme installed on the system, including built-in themes.

#### Parameters

handler | a GFunc using a theme as first argument. | [scope call]
user_data | data to pass to `handler` |

### gog_theme_fillin_style ()

    void
    gog_theme_fillin_style (GogTheme const *theme,
                            GOStyle *style,
                            GogObject const *obj,
                            int ind,
                            GOStyleFlag relevant_fields);

Fill in the auto aspects of `style` based on `theme` 's element for objects of type/role similar to `obj` with index `ind` . If `relevant_fields` is GO_STYLE_ALL, fillin the entire style, not just the auto portions included in `relevant_fields` .

#### Parameters

theme | GogTheme |
style | GOStyle to initialize |
obj | GogObject The object associated with `style` |
ind | an optional index |
relevant_fields | GOStyleFlag |

### gog_theme_get_color_map ()

    GogAxisColorMap const *
    gog_theme_get_color_map (GogTheme const *theme,
                             gboolean discrete);

Retrieves the themed color map. Each theme has a discrete color map and a continuous one.

#### Parameters

theme | GogTheme |
discrete | whether the map is for a discrete axis. |

#### Returns

the requested color map.

[transfer none]

### gog_theme_get_description ()

    char const *
    gog_theme_get_description (GogTheme const *theme);

### gog_theme_get_id ()

    char const *
    gog_theme_get_id (GogTheme const *theme);

Retrieves the theme Id.

#### Parameters

theme | a GogTheme |

#### Returns

the GogTheme Id.

### gog_theme_get_name ()

    char const *
    gog_theme_get_name (GogTheme const *theme);

#### Parameters

theme | a GogTheme |

#### Returns

the GogTheme name.

### gog_theme_get_resource_type ()

    GoResourceType
    gog_theme_get_resource_type (GogTheme const *theme);

### gog_theme_registry_get_theme_names ()

    GSList *
    gog_theme_registry_get_theme_names (void);

#### Returns

a newly allocated theme name list from theme registry.

[element-type utf8][transfer container]

### gog_theme_registry_lookup ()

    GogTheme *
    gog_theme_registry_lookup (char const *name);

#### Parameters

name | a theme name |

#### Returns

a GogTheme from theme registry.

[transfer none]

### gog_theme_save_to_home_dir ()

    void
    gog_theme_save_to_home_dir (GogTheme *theme);

Writes the theme to the user directory so that it becomes permanently available.

#### Parameters

theme | the GogTheme to save |

## Types and Values

### GogTheme

    typedef struct _GogTheme GogTheme;

## Property Details

### The `“resource-type”` property

      “resource-type”            GoResourceType

The resource type for the theme.

Owner: GogTheme

Flags: Read / Write / Construct Only

Default value: GO_RESOURCE_INVALID