Re: [gtkmm] switching styles impossible?



Hi,

* RevX gmx at <RevX gmx at> [2002-07-26 18:36:30]:
> > 
> >     Gdk_Color color("white");
> >     Gtk::Style *style = Gtk::Style::create();
> >     style->set_fg(GTK_STATE_NORMAL, color);
> >     button.set_style(*style);
> 
> I tried this (already) with 
> Style *style = Style::create();
> but it still segfaults as long as button->show() is
> processed first.

It would be a lot easier if you showed the exact code you are having
problems with. I can't make it segfault here.

> Have you tried your example above or is there
> some 'important' code before this I should know?

Yes, I have used it successfully on a Gtk::Label.

The below code makes the background of the button red, I was not able to
change the color of the text in my few attempts, but the example might
lead you closer to the solution.


#include <gtk--/window.h>
#include <gtk--/button.h>
#include <gtk--/style.h>
#include <gtk--/main.h>

class AppWindow : public Gtk::Window
{
public:
    AppWindow();
    virtual ~AppWindow() { }

protected:
    Gtk::Button _button;
};

AppWindow::AppWindow()
    : _button("Click me")
{
    add(_button);
    _button.show();
    Gdk_Color color("red");
    Gtk::Style *style = Gtk::Style::create();
    style->set_bg(GTK_STATE_NORMAL, color);
    _button.set_style(*style);
    show_all();
}

int main (int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);

    AppWindow window;
    window.show();
    kit.run();

    return 0;
}

  - Morten.

--
http://wtf.dk/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]