StarredRating

StarredRating — A widget for the typical five-star rating.

Synopsis

#include <libstarrred/libstarrred.h>

struct              StarredRating;
struct              StarredRatingClass;
gunichar            starred_rating_get_black_char       (StarredRating *rating);
const gchar *       starred_rating_get_black_icon_name  (StarredRating *rating);
gboolean            starred_rating_get_editable         (StarredRating *rating);
gboolean            starred_rating_get_has_frame        (StarredRating *rating);
GtkIconSize         starred_rating_get_icon_size        (StarredRating *rating);
gint                starred_rating_get_max_rating       (StarredRating *rating);
gint                starred_rating_get_min_rating       (StarredRating *rating);
gint                starred_rating_get_rating           (StarredRating *rating);
gunichar            starred_rating_get_white_char       (StarredRating *rating);
const gchar *       starred_rating_get_white_icon_name  (StarredRating *rating);
GtkWidget *         starred_rating_new                  (void);
void                starred_rating_set_black_char       (StarredRating *rating,
                                                         gunichar black_char);
void                starred_rating_set_black_icon_name  (StarredRating *rating,
                                                         const gchar *icon_name);
void                starred_rating_set_editable         (StarredRating *rating,
                                                         gboolean editable);
void                starred_rating_set_has_frame        (StarredRating *rating,
                                                         gboolean has_frame);
void                starred_rating_set_icon_size        (StarredRating *rating,
                                                         GtkIconSize size);
void                starred_rating_set_max_rating       (StarredRating *rating,
                                                         gint value);
void                starred_rating_set_min_rating       (StarredRating *rating,
                                                         gint value);
void                starred_rating_set_rating           (StarredRating *rating,
                                                         gint value);
void                starred_rating_set_white_char       (StarredRating *rating,
                                                         gunichar white_char);
void                starred_rating_set_white_icon_name  (StarredRating *rating,
                                                         const gchar *icon_name);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkWidget
               +----GtkMisc
                     +----StarredRating

Implemented Interfaces

StarredRating implements AtkImplementorIface, GtkBuildable and GtkCellEditable.

Properties

  "black-char"               guint                 : Read / Write
  "black-icon-name"          gchar*                : Read / Write
  "editable"                 gboolean              : Read / Write
  "has-frame"                gboolean              : Read / Write
  "icon-size"                GtkIconSize           : Read / Write
  "max-rating"               gint                  : Read / Write
  "min-rating"               gint                  : Read / Write
  "rating"                   gint                  : Read / Write
  "white-char"               guint                 : Read / Write
  "white-icon-name"          gchar*                : Read / Write

Description

By adjusting properties like "min-rating" and "max-rating" also other rating systems systems but five-star rating are supported.

Example 1. Single-star favorites

    GtkWidget *widget = starred_rating_new ();
    starred_rating_set_editable (STARRED_RATING (widget), TRUE);
    starred_rating_set_max_rating (STARRED_RATING (widget), 1);
  


Example 2. Require at least one star

    GtkWidget *widget = starred_rating_new ();
    starred_rating_set_editable (STARRED_RATING (widget), TRUE);
    starred_rating_set_min_rating (STARRED_RATING (widget), 1);
  


Example 3. Display hearts instead of stars

    GtkWidget *widget = starred_rating_new ();
    starred_rating_set_editable (STARRED_RATING (widget), TRUE);
    starred_rating_set_black_char (STARRED_RATING (widget), 0x2665); /* BLACK HEART SUIT */
    starred_rating_set_white_char (STARRED_RATING (widget), 0x2661); /* WHITE HEART SUIT */
  


Details

struct StarredRating

struct StarredRating;

Opaque data structure representing StarredRating instances.


struct StarredRatingClass

struct StarredRatingClass {
  GtkMiscClass parent_class;

  /* Padding for future expansion */
  void (*_starred_reserved1) (void);
  void (*_starred_reserved2) (void);
  void (*_starred_reserved3) (void);
  void (*_starred_reserved4) (void);
  void (*_starred_reserved5) (void);
};

Virtual methods of the StarredRating class.

GtkMiscClass parent_class;

Virtual methods of the super class.

_starred_reserved1 ()

(skip) Padding for future expansion

_starred_reserved2 ()

(skip) Padding for future expansion

_starred_reserved3 ()

(skip) Padding for future expansion

_starred_reserved4 ()

(skip) Padding for future expansion

_starred_reserved5 ()

(skip) Padding for future expansion

starred_rating_get_black_char ()

gunichar            starred_rating_get_black_char       (StarredRating *rating);

Reads the "black-char" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_black_icon_name ()

const gchar *       starred_rating_get_black_icon_name  (StarredRating *rating);

Reads the "black-icon-name" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_editable ()

gboolean            starred_rating_get_editable         (StarredRating *rating);

Reads the "editable" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_has_frame ()

gboolean            starred_rating_get_has_frame        (StarredRating *rating);

Reads the "has-frame" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_icon_size ()

GtkIconSize         starred_rating_get_icon_size        (StarredRating *rating);

Reads the "icon-size" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_max_rating ()

gint                starred_rating_get_max_rating       (StarredRating *rating);

Reads the "max-rating" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_min_rating ()

gint                starred_rating_get_min_rating       (StarredRating *rating);

Reads the "min-rating" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_rating ()

gint                starred_rating_get_rating           (StarredRating *rating);

Reads the "rating" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_white_char ()

gunichar            starred_rating_get_white_char       (StarredRating *rating);

Reads the "white-char" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_get_white_icon_name ()

const gchar *       starred_rating_get_white_icon_name  (StarredRating *rating);

Reads the "white-icon-name" property.

rating :

The StarredRating instance

Returns :

The current property value.

starred_rating_new ()

GtkWidget *         starred_rating_new                  (void);

Creates a new StarredRating instance. Its default properties represent an immutable five-star rating.

Returns :

The newly allocated widget.

starred_rating_set_black_char ()

void                starred_rating_set_black_char       (StarredRating *rating,
                                                         gunichar black_char);

Writes to the "black-char" property.

rating :

The StarredRating instance

black_char :

The new property value.

starred_rating_set_black_icon_name ()

void                starred_rating_set_black_icon_name  (StarredRating *rating,
                                                         const gchar *icon_name);

Writes to the "black-icon-name" property.

rating :

The StarredRating instance

icon_name :

The new property value. [allow-none]

starred_rating_set_editable ()

void                starred_rating_set_editable         (StarredRating *rating,
                                                         gboolean editable);

Writes to the "editable" property.

rating :

The StarredRating instance

editable :

The new property value.

starred_rating_set_has_frame ()

void                starred_rating_set_has_frame        (StarredRating *rating,
                                                         gboolean has_frame);

Writes to the "has-frame" property.

rating :

The StarredRating instance

has_frame :

The new property value.

starred_rating_set_icon_size ()

void                starred_rating_set_icon_size        (StarredRating *rating,
                                                         GtkIconSize size);

Writes to the "icon-size" property.

rating :

The StarredRating instance

size :

The new property value.

starred_rating_set_max_rating ()

void                starred_rating_set_max_rating       (StarredRating *rating,
                                                         gint value);

Writes to the "max-rating" property.

rating :

The StarredRating instance

value :

The new property value.

starred_rating_set_min_rating ()

void                starred_rating_set_min_rating       (StarredRating *rating,
                                                         gint value);

Writes to the "min-rating" property.

rating :

The StarredRating instance

value :

The new property value.

starred_rating_set_rating ()

void                starred_rating_set_rating           (StarredRating *rating,
                                                         gint value);

Writes to the "rating" property.

rating :

The StarredRating instance

value :

The new property value.

starred_rating_set_white_char ()

void                starred_rating_set_white_char       (StarredRating *rating,
                                                         gunichar white_char);

Writes to the "white-char" property.

rating :

The StarredRating instance

white_char :

The new property value.

starred_rating_set_white_icon_name ()

void                starred_rating_set_white_icon_name  (StarredRating *rating,
                                                         const gchar *icon_name);

Writes to the "white-icon-name" property.

rating :

The StarredRating instance

icon_name :

The new property value. [allow-none]

Property Details

The "black-char" property

  "black-char"               guint                 : Read / Write

The character to use for assigned stars.

Default value: 0


The "black-icon-name" property

  "black-icon-name"          gchar*                : Read / Write

The icon to use for assigned stars.

Default value: NULL


The "editable" property

  "editable"                 gboolean              : Read / Write

Whether the rating can be modified by the user.

Default value: FALSE


The "has-frame" property

  "has-frame"                gboolean              : Read / Write

FALSE removes outside bevel from widget.

Default value: TRUE


The "icon-size" property

  "icon-size"                GtkIconSize           : Read / Write

Size of star icons.

Default value: GTK_ICON_SIZE_MENU


The "max-rating" property

  "max-rating"               gint                  : Read / Write

Maximum rating in stars.

Allowed values: >= 1

Default value: 5


The "min-rating" property

  "min-rating"               gint                  : Read / Write

Minimum rating in stars.

Allowed values: [0,1]

Default value: 0


The "rating" property

  "rating"                   gint                  : Read / Write

Rating in stars.

Allowed values: >= 0

Default value: 0


The "white-char" property

  "white-char"               guint                 : Read / Write

The character to use for missing stars.

Default value: 0


The "white-icon-name" property

  "white-icon-name"          gchar*                : Read / Write

The icon to use for missing stars.

Default value: NULL