## rb-rating-helper

rb-rating-helper — helper functions for displaying song ratings

## Functions

gboolean | rb_rating_render_stars ()
double | rb_rating_get_rating_from_widget ()
void | rb_rating_pixbufs_free ()
void | rb_rating_install_rating_property ()

## Types and Values

| RBRatingPixbufs
#define | RB_RATING_MAX_SCORE

## Description

A few helper functions for dealing with ratings. These are shared between RBRating and RBCellRendererRating.

## Functions

### rb_rating_render_stars ()

    gboolean
    rb_rating_render_stars (GtkWidget *widget,
                            cairo_t *cr,
                            RBRatingPixbufs *pixbufs,
                            int x,
                            int y,
                            int x_offset,
                            int y_offset,
                            gdouble rating,
                            gboolean selected);

Renders a rating as a row of stars. floor(`rating` ) large stars are drawn, followed by 5-floor(`rating` ) small stars.

#### Parameters

widget | a GtkWidget to render on behalf of |
cr | cairo context to render into |
pixbufs | a RBRatingPixbufs structure |
x | source X coordinate within the rating pixbufs (usually 0) |
y | source Y coordinate within the rating pixbufs (usually 0) |
x_offset | destination X coordinate within the window |
y_offset | destination Y coordinate within the window |
rating | the rating to display (between 0.0 and 5.0) |
selected | TRUE if the widget is currently selected for input |

#### Returns

TRUE if the stars were drawn successfully

### rb_rating_get_rating_from_widget ()

    double
    rb_rating_get_rating_from_widget (GtkWidget *widget,
                                      gint widget_x,
                                      gint widget_width,
                                      double current_rating);

Updates the rating for a widget after the user clicks on the rating. If the user clicks on the Nth star, the rating is set to N, unless the rating is already N, in which case the rating is set to N-1. This allows the user to set the rating to 0.

#### Parameters

widget | the GtkWidget displaying the rating |
widget_x | x component of the position to query |
widget_width | width of the widget |
current_rating | the current rating displayed in the widget |

#### Returns

the updated rating

### rb_rating_pixbufs_free ()

    void
    rb_rating_pixbufs_free (RBRatingPixbufs *pixbufs);

Frees a set of rating pixbufs.

#### Parameters

pixbufs | RBRatingPixbufs instance |

### rb_rating_install_rating_property ()

    void
    rb_rating_install_rating_property (GObjectClass *klass,
                                       gulong prop);

Installs a 'rating' property in the specified class.

#### Parameters

klass | a GObjectClass to add the property to |
prop | property index to use |

## Types and Values

### RBRatingPixbufs

    typedef struct _RBRatingPixbufs RBRatingPixbufs;

### RB_RATING_MAX_SCORE

    #define RB_RATING_MAX_SCORE 5