c++ - New Symbolic Color in Pango Span Text -
first time poster; long time admirer of stack overflow angels.
i'm having issue colors in span text controlled pango.
long version:
i'm updating old ui program has c++ code guts gtk, xml (written glade), , rc stylesheet handling graphics. of our colored markup text hard-coded in xml. of dynamically set in c++ code. problem is, when program runs on our older systems, color referenced span text 'green' shows #00ff00. on our newer systems, 'green' showing #008000. example of code printing label widget:
gtk_label_set_markup((gtklabel *) titlebarlabel, "<span color='green'>orbital cannon positioning</span>");
i'm pango in control of span text markup. found difference between greens difference between x11 , w3c color lists (https://en.wikipedia.org/wiki/x11_color_names#clashes_between_web_and_x11_colors). seems our old systems using x11 , our new ones using w3c, makes sense.
i replace instances of 'green' '#00ff00' if wanted change colors in future, we'd have go through whole thing again. i'd rather have colors changeable through stylesheet instead of baked code.
c++ code:
gtkwidget * titlebarlabel; titlebarlabel = gtk_widget (get_builder_object (builder, "titlebarlabel")); gtk_label_set_markup((gtklabel *) titlebarlabel, "<span color='#00ff00'>death ray power status</span>");
i can create gdkcolor @ run-time , gdk_color_parse values config file, , use gtk_widget_modify_text() apply color label widgets. doesn't work of hard-coded span text in xml. also, have pleanty of labels bits of text colored differently inside same line.
c++ code:
gdkcolor pass_color; gdk_color_parse("#00ff00", &pass_color); gtk_widget_modify_text(titlebarlabel, gtk_state_normal, &pass_color);
i can make style in rc file each color , link every single label use color @ run-time. we'd have remove markup coloring , add lots of code grabbing widgets never bothered before , code setting names of widgets instead of printing them new span text. gets desired result of having colors changeable in stylesheet it's massive undertaking , it's not intuitive our veteran engineers used using color attributes.
rc file:
style "pass_color" { fg[normal] = #00ff00 } widget "*titlebarlabel_pass" style "pass_color"
c++ code:
gtk_widget_set_name(titlebarlabel, "titlebarlabel_pass");
short version:
ideally, able make new color @ run-time can link span text in such faction:
<span color='mynewcolor'>weather manipulation settings</span>
or maybe create new tag applies specific attributes, like:
<span><mynewcolor>shark tank ph balance</mynewcolor></span>
but doubt that's possible.
i tried playing around pango_attr_type_register(), pango_attr_foreground_new(), , friends, couldn't figure out how attributes work of if thought did. after research, looks 'attribute' one-time setting on single string of text. , not new value can called in line span text, hoped.
is remotely possible without rebuilding of pango?
there different work around me stylesheet setup?
@ point, i'm open suggestions.
version specs:
computers showing green #00ff00
os: linux slackware 13.37 , below
gtk: 2.24.4
pango: 1.28.4
computers showing green #008000
os: linux slackware 14.1
gtk: 2.24.20
pango: 1.34.1
if able use gtk 3.x, suggest doing that, easier using css. there way use multiple css styles different regions in same label, though awkward.
in gtk 2, noted, can reference widgets name
property in rc file:
widget "shark-tank-ph-label" style "green-text" style "green-text" { text[normal] = #008000 }
i recommend taking approach if it's not you're used to. refactoring once remove hardcoded colors labels make easier next time have change this, , make code closer how things work in gtk 3.x should decide make port in future.
Comments
Post a Comment