~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to widgets/gossip-cell-renderer-expander.c

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
typedef struct _GossipCellRendererExpanderPriv GossipCellRendererExpanderPriv;
69
69
 
70
70
struct _GossipCellRendererExpanderPriv {
71
 
        GtkStateFlags        style_flags;
72
71
        gint                 expander_size;
73
72
 
74
73
        guint                activatable : 1;
 
74
        GtkExpanderStyle     expander_style;
75
75
};
76
76
 
77
77
G_DEFINE_TYPE (GossipCellRendererExpander, gossip_cell_renderer_expander, GTK_TYPE_CELL_RENDERER)
83
83
 
84
84
        priv = GET_PRIV (expander);
85
85
 
86
 
        priv->style_flags = 0;
87
86
        priv->expander_size = 12;
88
87
        priv->activatable = TRUE;
89
88
 
153
152
 
154
153
        switch (param_id) {
155
154
        case PROP_EXPANDER_STYLE:
156
 
                g_value_set_enum (value, priv->style_flags & GTK_STATE_FLAG_ACTIVE ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED);
 
155
                g_value_set_enum (value, priv->expander_style);
157
156
                break;
158
157
 
159
158
        case PROP_EXPANDER_SIZE:
184
183
 
185
184
        switch (param_id) {
186
185
        case PROP_EXPANDER_STYLE:
187
 
                if (g_value_get_enum (value) == GTK_EXPANDER_EXPANDED) {
188
 
                        priv->style_flags |= GTK_STATE_FLAG_ACTIVE;
189
 
                } else {
190
 
                        priv->style_flags &= ~(GTK_STATE_FLAG_ACTIVE);
191
 
                }
 
186
                priv->expander_style = g_value_get_enum (value);
192
187
                break;
193
188
 
194
189
        case PROP_EXPANDER_SIZE:
271
266
        GtkStyleContext                *style_context;
272
267
        gint                            x_offset, y_offset;
273
268
        gint                            xpad, ypad;
 
269
        GtkStateFlags                   state;
274
270
 
275
271
        expander = (GossipCellRendererExpander*) cell;
276
272
        priv = GET_PRIV (expander);
281
277
        gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
282
278
 
283
279
        style_context = gtk_widget_get_style_context (widget);
284
 
        gtk_style_context_set_state (style_context, priv->style_flags);
285
 
 
286
 
        gtk_render_expander (gtk_widget_get_style_context (widget),
 
280
 
 
281
        gtk_style_context_save (style_context);
 
282
        gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_EXPANDER);
 
283
 
 
284
        state = gtk_cell_renderer_get_state (cell, widget, flags);
 
285
 
 
286
        if (priv->expander_style == GTK_EXPANDER_COLLAPSED) {
 
287
                state |= GTK_STATE_FLAG_NORMAL;
 
288
        } else {
 
289
                state |= GTK_STATE_FLAG_ACTIVE;
 
290
        }
 
291
 
 
292
        gtk_style_context_set_state (style_context, state);
 
293
 
 
294
        gtk_render_expander (style_context,
287
295
                             cr,
288
296
                             cell_area->x + x_offset + xpad,
289
297
                             cell_area->y + y_offset + ypad,
290
298
                             priv->expander_size,
291
299
                             priv->expander_size);
 
300
 
 
301
        gtk_style_context_restore (style_context);
292
302
}
293
303
 
294
304
static gboolean
333
343
 
334
344
        if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) {
335
345
                gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path);
336
 
                priv->style_flags &= ~(GTK_STATE_FLAG_ACTIVE);
337
346
        } else {
338
347
                gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE);
339
 
                priv->style_flags |= ~(GTK_STATE_FLAG_ACTIVE);
340
348
        }
341
349
 
342
350
        gtk_tree_path_free (path);