diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-07-18 16:26:37 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-07-18 16:26:37 (GMT) |
commit | cc79dc6e2bbf78acd146b618df246a7936a0e4ae (patch) | |
tree | 6ac416090b100ca3f4748c40dab4aa01d29dfed7 /src/glibext | |
parent | e5b5f9f4df06fbf08b60c039cf6dbdc4dce48784 (diff) |
Built Pango markups from CSS theme items.
Diffstat (limited to 'src/glibext')
-rw-r--r-- | src/glibext/linesegment.c | 100 |
1 files changed, 2 insertions, 98 deletions
diff --git a/src/glibext/linesegment.c b/src/glibext/linesegment.c index 373d744..02c6691 100644 --- a/src/glibext/linesegment.c +++ b/src/glibext/linesegment.c @@ -36,6 +36,7 @@ #include "../common/extstr.h" #include "../common/fnv1a.h" #include "../core/paths.h" +#include "../gtkext/rendering.h" @@ -88,24 +89,6 @@ static const char *_segment_names[RTT_COUNT] = { /* Propriétés de rendu */ - -typedef struct _rendering_color_t -{ - GdkRGBA color; /* Couleur de rendu */ - bool has_color; /* Définition en place ? */ - -} rendering_color_t; - -typedef struct _rendering_pattern_t -{ - rendering_color_t foreground; /* Couleur d'impression */ - rendering_color_t inverted; /* Couleur inversée pour sél. */ - - cairo_font_slant_t slant; /* Style d'impression */ - cairo_font_weight_t weight; /* Poids de la police */ - -} rendering_pattern_t; - typedef struct _segment_rendering { rendering_color_t selection_bg; /* Fond d'impression */ @@ -192,8 +175,6 @@ bool selection_list_has_segment_content(const segcnt_list *, const line_segment bool load_segment_rendering_parameters(void) { - GtkStyleContext *context; /* Contexte pour les styles */ - GtkWidgetPath *path; /* Chemin d'accès aux thèmes */ gchar *filename; /* Accès à une image 1x1 */ cairo_font_slant_t s; /* Boucle de parcours #1 */ cairo_font_weight_t w; /* Boucle de parcours #2 */ @@ -202,15 +183,6 @@ bool load_segment_rendering_parameters(void) cairo_text_extents_t extents; /* Couverture des caractères */ RenderingTagType i; /* Boucle de parcours */ - /* Création d'un contexte d'accès */ - - path = gtk_widget_path_new(); - gtk_widget_path_append_type(path, G_TYPE_OBJECT); - - context = gtk_style_context_new(); - gtk_style_context_set_path(context, path); - gtk_style_context_set_screen(context, gdk_screen_get_default()); - /* Contextes pour les mesures initiales */ filename = find_pixmap_file("nil.png"); @@ -245,76 +217,8 @@ bool load_segment_rendering_parameters(void) /* Chargement des définitions utiles */ - void define_rendering_pattern(GtkStyleContext *ctx, const char *name, rendering_pattern_t *pattern) - { - GdkRGBA *tmp_color; /* Description d'une couleur */ - PangoFontDescription *font_desc; /* Description d'une police */ - - gtk_style_context_save(ctx); - - gtk_style_context_add_class(context, name); - - gtk_style_context_get(ctx, GTK_STATE_NORMAL, GTK_STYLE_PROPERTY_COLOR, &tmp_color, NULL); - - pattern->foreground.has_color = true; - pattern->foreground.color = *tmp_color; - - pattern->inverted.has_color = true; - pattern->inverted.color.red = 1.0 - tmp_color->red; - pattern->inverted.color.green = 1.0 - tmp_color->green; - pattern->inverted.color.blue = 1.0 - tmp_color->blue; - pattern->inverted.color.alpha = tmp_color->alpha; - - gdk_rgba_free(tmp_color); - - gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL); - - switch (pango_font_description_get_style(font_desc)) - { - case PANGO_STYLE_NORMAL: - pattern->slant = CAIRO_FONT_SLANT_NORMAL; - break; - case PANGO_STYLE_ITALIC: - pattern->slant = CAIRO_FONT_SLANT_ITALIC; - break; - case PANGO_STYLE_OBLIQUE: - pattern->slant = CAIRO_FONT_SLANT_OBLIQUE; - break; - } - - switch (pango_font_description_get_weight(font_desc)) - { - case PANGO_WEIGHT_THIN: - case PANGO_WEIGHT_ULTRALIGHT: - case PANGO_WEIGHT_LIGHT: - case PANGO_WEIGHT_SEMILIGHT: - case PANGO_WEIGHT_BOOK: - case PANGO_WEIGHT_NORMAL: - case PANGO_WEIGHT_MEDIUM: - pattern->weight = CAIRO_FONT_WEIGHT_NORMAL; - break; - case PANGO_WEIGHT_SEMIBOLD: - case PANGO_WEIGHT_BOLD: - case PANGO_WEIGHT_ULTRABOLD: - case PANGO_WEIGHT_HEAVY: - case PANGO_WEIGHT_ULTRAHEAVY: - pattern->weight = CAIRO_FONT_WEIGHT_BOLD; - break; - } - - pango_font_description_free(font_desc); - - gtk_style_context_restore(context); - - } - for (i = 0; i < RTT_COUNT; i++) - define_rendering_pattern(context, _segment_names[i], &_seg_params.patterns[i]); - - /* Nettoyages finaux... */ - - gtk_widget_path_free(path); - g_object_unref(context); + load_rendering_pattern(_segment_names[i], &_seg_params.patterns[i]); return true; |