diff options
Diffstat (limited to 'src/customcellrendererstate.c')
| -rw-r--r-- | src/customcellrendererstate.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/customcellrendererstate.c b/src/customcellrendererstate.c index 8c02358..52fcade 100644 --- a/src/customcellrendererstate.c +++ b/src/customcellrendererstate.c @@ -2,6 +2,19 @@ #include "customcellrendererstate.h" +/* Private class member */ +#define PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUSTOM_TYPE_CELL_RENDERER_STATE, \ + CustomCellRendererStatePrivate)) + +typedef struct _CustomCellRendererStatePrivate CustomCellRendererStatePrivate; + +struct _CustomCellRendererStatePrivate +{ + gint state; +}; + static void custom_cell_renderer_state_get_property(GObject* object, guint param_id, GValue* value, @@ -14,15 +27,15 @@ static void custom_cell_renderer_state_set_property(GObject* object, static void update_state(CustomCellRendererState* cell_state, gint state); enum { - PROP_0, - PROP_STATE, + PROP_0, + PROP_STATE, }; G_DEFINE_TYPE(CustomCellRendererState, custom_cell_renderer_state, GTK_TYPE_CELL_RENDERER_PIXBUF) static void custom_cell_renderer_state_init(CustomCellRendererState* cell_state) { - update_state(cell_state, cell_state->state); + update_state(cell_state, PRIVATE(cell_state)->state); } static void custom_cell_renderer_state_class_init(CustomCellRendererStateClass *cell_state_class) @@ -33,6 +46,9 @@ static void custom_cell_renderer_state_class_init(CustomCellRendererStateClass * object_class = G_OBJECT_CLASS(cell_state_class); /* cell_renderer_class = GTK_CELL_RENDERER_CLASS(cell_state_class); */ + g_type_class_add_private(object_class, + sizeof(CustomCellRendererStatePrivate)); + object_class->set_property = custom_cell_renderer_state_set_property; object_class->get_property = custom_cell_renderer_state_get_property; @@ -62,7 +78,7 @@ void custom_cell_renderer_state_get_property(GObject* object, switch (param_id) { case PROP_STATE: - g_value_set_int(value, state->state); + g_value_set_int(value, PRIVATE(state)->state); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -83,9 +99,9 @@ void custom_cell_renderer_state_set_property(GObject* object, { gint state_value = g_value_get_int(value); - if (state->state != state_value) + if (PRIVATE(state)->state != state_value) { - state->state = state_value; + PRIVATE(state)->state = state_value; changed = TRUE; } break; @@ -96,7 +112,7 @@ void custom_cell_renderer_state_set_property(GObject* object, if (changed) { - update_state(state, state->state); + update_state(state, PRIVATE(state)->state); } } @@ -105,16 +121,16 @@ void update_state(CustomCellRendererState* cell_state, gint state) switch ((state_t)state) { case STATE_DEAD: - g_object_set(cell_state, "stock-id", GTK_STOCK_CLOSE, NULL); + g_object_set(cell_state, "icon-name", "media-playback-stop", NULL); break; case STATE_ACTIVE: - g_object_set(cell_state, "stock-id", GTK_STOCK_YES, NULL); + g_object_set(cell_state, "icon-name", "media-playback-start", NULL); break; case STATE_REHASH: - g_object_set(cell_state, "stock-id", GTK_STOCK_REFRESH, NULL); + g_object_set(cell_state, "icon-name", "view-refresh", NULL); break; case STATE_HASHFAILED: - g_object_set(cell_state, "stock-id", GTK_STOCK_NO, NULL); + g_object_set(cell_state, "stock-id", "dialog-warning", NULL); break; default: g_assert(FALSE); |
