Link to home
Start Free TrialLog in
Avatar of dml12
dml12

asked on

ruby gtk3 entry problem

I have a Ruby application that I have migrated to gtk3. Most things are working but changing the background color does not work for Entry's . I It works fine for buttons. The commands are of the form:

color = Gdk::RGBA.parse("lightblue1")
 widget.override_background_color(0, color)

gtk3 wants RGBA colors. Another report of this problem  said they only got it working using css . This requires using style & providers. Are there any examples of how to do this in Ruby.
Avatar of dml12
dml12

ASKER

It appears that it is a problem with backgound-color. I found an example using  css provider that I modified. All the settings work except background-color. The css code follows where numeric_control is a widget name.

         provider1 = Gtk::CssProvider.new
         provider1.load :data => '#numeric_controll1 {
             color: green;
             background-color: black;
             border-style: solid;
             border-width: 16px;
             border-color: red;
         }'

         styleContext = Gtk::StyleContext.new
         styleContext.add_provider provider1, GLib::MAXUINT

         apply_css(self, provider1)

     def apply_css(widget, provider)
         widget.style_context.add_provider(provider, GLib::MAXUINT)
         if widget.is_a?(Gtk::Container)
             widget.each_all do |child|
                 apply_css(child, provider)
             end
         end
     end
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.