static ThemeImage * match_theme_image (GtkStyle *style, ThemeMatchData *match_data) { GList *tmp_list; tmp_list = PIXBUF_RC_STYLE (style->rc_style)->img_list; while (tmp_list) { guint flags; ThemeImage *image = tmp_list->data; tmp_list = tmp_list->next; if (match_data->function != image->match_data.function) continue; flags = match_data->flags & image->match_data.flags; if (flags != image->match_data.flags) /* Required components not present */ continue; if ((flags & THEME_MATCH_STATE) && match_data->state != image->match_data.state) continue; if ((flags & THEME_MATCH_SHADOW) && match_data->shadow != image->match_data.shadow) continue; if ((flags & THEME_MATCH_ARROW_DIRECTION) && match_data->arrow_direction != image->match_data.arrow_direction) continue; if ((flags & THEME_MATCH_ORIENTATION) && match_data->orientation != image->match_data.orientation) continue; if ((flags & THEME_MATCH_GAP_SIDE) && match_data->gap_side != image->match_data.gap_side) continue; if ((flags & THEME_MATCH_EXPANDER_STYLE) && match_data->expander_style != image->match_data.expander_style) continue; if ((flags & THEME_MATCH_WINDOW_EDGE) && match_data->window_edge != image->match_data.window_edge) continue; if (image->match_data.detail && (!match_data->detail || strcmp (match_data->detail, image->match_data.detail) != 0)) continue; return image; } return NULL; }
static void pixbuf_rc_style_finalize (GObject *object) { PixbufRcStyle *rc_style = PIXBUF_RC_STYLE (object); g_list_foreach (rc_style->img_list, (GFunc) theme_image_unref, NULL); g_list_free (rc_style->img_list); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void pixbuf_rc_style_merge (GtkRcStyle *dest, GtkRcStyle *src) { if (PIXBUF_IS_RC_STYLE (src)) { PixbufRcStyle *pixbuf_dest = PIXBUF_RC_STYLE (dest); PixbufRcStyle *pixbuf_src = PIXBUF_RC_STYLE (src); GList *tmp_list1, *tmp_list2; if (pixbuf_src->img_list) { /* Copy src image list and append to dest image list */ tmp_list2 = g_list_last (pixbuf_dest->img_list); tmp_list1 = pixbuf_src->img_list; while (tmp_list1) { if (tmp_list2) { tmp_list2->next = g_list_alloc(); tmp_list2->next->data = tmp_list1->data; tmp_list2->next->prev = tmp_list2; tmp_list2 = tmp_list2->next; } else { pixbuf_dest->img_list = g_list_append (NULL, tmp_list1->data); tmp_list2 = pixbuf_dest->img_list; } theme_image_ref (tmp_list1->data); tmp_list1 = tmp_list1->next; } } } parent_class->merge (dest, src); }
static guint pixbuf_rc_style_parse (GtkRcStyle *rc_style, GtkSettings *settings, GScanner *scanner) { static GQuark scope_id = 0; PixbufRcStyle *pixbuf_style = PIXBUF_RC_STYLE (rc_style); guint old_scope; guint token; gint i; ThemeImage *img; /* Set up a new scope in this scanner. */ if (!scope_id) scope_id = g_quark_from_string("pixbuf_theme_engine"); /* If we bail out due to errors, we *don't* reset the scope, so the * error messaging code can make sense of our tokens. */ old_scope = g_scanner_set_scope(scanner, scope_id); /* Now check if we already added our symbols to this scope * (in some previous call to theme_parse_rc_style for the * same scanner. */ if (!g_scanner_lookup_symbol(scanner, theme_symbols[0].name)) { for (i = 0; i < G_N_ELEMENTS (theme_symbols); i++) g_scanner_scope_add_symbol(scanner, scope_id, theme_symbols[i].name, GINT_TO_POINTER(theme_symbols[i].token)); } /* We're ready to go, now parse the top level */ token = g_scanner_peek_next_token(scanner); while (token != G_TOKEN_RIGHT_CURLY) { switch (token) { case TOKEN_IMAGE: img = NULL; token = theme_parse_image(settings, scanner, pixbuf_style, &img); break; default: g_scanner_get_next_token(scanner); token = G_TOKEN_RIGHT_CURLY; break; } if (token != G_TOKEN_NONE) return token; else pixbuf_style->img_list = g_list_append(pixbuf_style->img_list, img); token = g_scanner_peek_next_token(scanner); } g_scanner_get_next_token(scanner); g_scanner_set_scope(scanner, old_scope); return G_TOKEN_NONE; }