NbtkStyle

NbtkStyle — a data store for style properties

Synopsis

                    NbtkStylable;
                    NbtkStylableIface;
enum                NbtkStyleError;
                    NbtkStyle;
NbtkStyle *         nbtk_style_get_default              (void);
NbtkStyle *         nbtk_style_new                      (void);
gboolean            nbtk_style_load_from_file           (NbtkStyle *style,
                                                         const gchar *filename,
                                                         GError **error);
void                nbtk_style_get_property             (NbtkStyle *style,
                                                         NbtkStylable *stylable,
                                                         GParamSpec *pspec,
                                                         GValue *value);

Object Hierarchy

  GInterface
   +----NbtkStylable
  GObject
   +----NbtkStyle

Known Implementations

NbtkStylable is implemented by NbtkScrollView, NbtkScrollBar, NbtkWidget, NbtkViewport, NbtkGrid, NbtkEntry, NbtkLabel, NbtkTooltip, NbtkTable, NbtkBin and NbtkButton.

Properties

  "style"                    NbtkStyle*            : Read / Write

Signals

  "style-notify"                                   : Run First / No Recursion / Has Details / Action / No Hooks
  "style-set"                                      : Run Last
  "changed"                                        : Run Last

Description

NbtkStyle is a property data store that can read properties from a style sheet. It is queried with objects that implement the NbtkStylable interface.

Details

NbtkStylable

typedef struct _NbtkStylable NbtkStylable;


NbtkStylableIface

typedef struct {
  GTypeInterface g_iface;

  /* virtual functions */
  NbtkStyle *(* get_style) (NbtkStylable *stylable);
  void       (* set_style) (NbtkStylable *stylable,
                            NbtkStyle    *style);

  /* context virtual functions */
  NbtkStylable *(*get_container)    (NbtkStylable *stylable);
  NbtkStylable *(*get_base_style)   (NbtkStylable *stylable);
  const gchar  *(*get_style_id)     (NbtkStylable *stylable);
  const gchar  *(*get_style_type)   (NbtkStylable *stylable);
  const gchar  *(*get_style_class)  (NbtkStylable *stylable);
  const gchar  *(*get_pseudo_class) (NbtkStylable *stylable);
  gchar        *(*get_attribute)    (NbtkStylable *stylable,
                                     const gchar  *name);
  gboolean      (*get_viewport)     (NbtkStylable *stylable,
                                     gint         *x,
                                     gint         *y,
                                     gint         *width,
                                     gint         *height);

  /* signals, not vfuncs */
  void (* style_notify) (NbtkStylable *stylable,
                         GParamSpec   *pspec);

  void (* style_set)    (NbtkStylable *stylable,
                         NbtkStyle    *old_style);
} NbtkStylableIface;


enum NbtkStyleError

typedef enum { /*< prefix=NBTK_STYLE_ERROR >*/
  NBTK_STYLE_ERROR_INVALID_FILE
} NbtkStyleError;


NbtkStyle

typedef struct _NbtkStyle NbtkStyle;

The contents of this structure is private and should only be accessed using the provided API.


nbtk_style_get_default ()

NbtkStyle *         nbtk_style_get_default              (void);

Return the default NbtkStyle object. This includes the current theme (if any).

Returns :

a NbtkStyle object. This must not be freed or unref'd by applications

nbtk_style_new ()

NbtkStyle *         nbtk_style_new                      (void);

Creates a new NbtkStyle object. This must be freed using g_object_unref when no longer required.

Returns :

a newly allocated NbtkStyle

nbtk_style_load_from_file ()

gboolean            nbtk_style_load_from_file           (NbtkStyle *style,
                                                         const gchar *filename,
                                                         GError **error);

Load style information from the specified file.

style :

a NbtkStyle

filename :

filename of the style sheet to load

error :

a GError or NULL

Returns :

TRUE if the style information was loaded successfully. Returns FALSE on error.

nbtk_style_get_property ()

void                nbtk_style_get_property             (NbtkStyle *style,
                                                         NbtkStylable *stylable,
                                                         GParamSpec *pspec,
                                                         GValue *value);

Requests the property described in pspec for the specified stylable

style :

the style data store object

stylable :

a stylable to retreive the data for

pspec :

a GParamSpec describing the property required

value :

a GValue to place the return value in

Property Details

The "style" property

  "style"                    NbtkStyle*            : Read / Write

The NbtkStyle attached to a stylable object.

Signal Details

The "style-notify" signal

void                user_function                      (NbtkStylable *nbtkstylable,
                                                        GParamSpec   *arg1,
                                                        gpointer      user_data)         : Run First / No Recursion / Has Details / Action / No Hooks

nbtkstylable :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "style-set" signal

void                user_function                      (NbtkStylable *stylable,
                                                        NbtkStyle    *old_style,
                                                        gpointer      user_data)      : Run Last

The ::style-set signal is emitted each time the NbtkStyle attached to stylable has been changed.

stylable :

the NbtkStylable that received the signal

old_style :

the previously set NbtkStyle for stylable

user_data :

user data set when the signal handler was connected.

The "changed" signal

void                user_function                      (NbtkStyle *arg0,
                                                        gpointer   user_data)      : Run Last

Indicates that the style data has changed in some way. For example, a new stylesheet may have been loaded.

user_data :

user data set when the signal handler was connected.