Re: gtk_widget_class_install_style_property
- From: Murray Cumming <murrayc murrayc com>
- To: Kent Bolton <kaboltongtkmm gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: gtk_widget_class_install_style_property
- Date: Wed, 24 May 2006 18:56:41 +0200
On Wed, 2006-05-24 at 10:22 -0500, Kent Bolton wrote:
> I am working on an application where I would like to specify some
> additional style information in the rc file. From looking at the GTK+
> documentation it appears that using
> gtk_widget_class_install_style_property() is the way to do this.
> However, I can't seem to find much about doing this in GTKmm.
>
> It doesn't appear that gtk_widget_class_install_style_property() is
> wrapped in GTKmm. So, I'm having a little trouble figuring out how to
> use it. First, one of the parameters to this function is of type
> GtkWidgetClass. How do you get the GtkWidgetClass from a c++ Gtkmm
> class? What about a class (say FooButton) that is derived from
> Gtk::Button?
That is a very GTK+ kind of thing, used to implement GTypes. For a
Gtk::Button it would be an intance of Gtk::Button_Class. That's declared
in gtkmm/gtk/private_p.h. These *_Class types are also typedefed in each
gtkmm widget class as CppClassType.
Gtk::Button's instance of that class, button_class_, is private, which
kind of makes sense to me - an application shouldn't be changing how
Buttons all over the system behave.
To take advantage of this per-GType style information, I guess you have
to define a new GType. gtkmm has some clever ways of doing this, but
everything results in one g_type_register_static() function to register
the GType.
HOWEVER, I suspect it will be enough to call the Glib::ObjectBase
constructor with your custom GType name, like in this unrelated example,
which uses the result of typeid() to get a typename string, because it
also needs its own GType:
http://cvs.gnome.org/viewcvs/gtkmm/examples/cellrenderercustom/cellrendererlist.cc?view=markup
So you'd do
class MyButton : public Gtk::Button
{
}
MyButton::MyButton()
: Glib::ObjectBase("kentswidgets_mybutton"),
Gtk::Button()
{
//This might give you the typename:
std::cout << "gtypename: " <<G_OBJECT_TYPE_NAME(gobj() << std::endl;
//This might tell you whether it's still a GtkButton:
std::cout << "Gtype is a GtkButton?:" << GTK_IS_BUTTON(gobj()) <<
std::endl;
}
I haven't tried compiling that.
> This thread answers some of my other questions but not quite
> everything.
> http://mail.gnome.org/archives/gtk-devel-list/2002-August/msg00129.html
>
> An example of how this is all done in GTKmm would be greatly
> appreciated.
If you don't have any luck then I'll try to create an example when I
have a chance, or maybe someone has already done this in some open
source code.
Is this in order to make some aspect of your custom widget themeable, or
in order to achieve some other effect that only seems to be possible via
the RC file?
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]