GTK3: Get Style Class Property

I am trying to get the text color of a GTK class. I have a GtkStyleContext with widgets and classes that I want to get with my properties.

GtkWidgetPath* widgetPath = gtk_widget_path_new (); gtk_widget_path_append_type(widgetPath, GTK_TYPE_WINDOW); gtk_widget_path_iter_set_name(widgetPath, -1 , "UnityPanelWidget"); GtkStyleContext *context = gtk_style_context_new(); gtk_style_context_set_path(context, widgetPath); gtk_style_context_add_class(context, "gnome-panel-menu-bar"); gtk_style_context_add_class(context, "unity-panel"); 

I used gtk_style_context_lookup_color, and it got the usual text color, but not the color of the text in the gnome-panel-panel menu panel or panel panel.

I tried using GtkCssProvider, but it got a generic style without added classes.

I use it in a Qt application to get the look of GTK3. This code works great in a GTK application.

Thanks!

+1
source share
1 answer

As far as I know, you cannot use the code above because Qt uses Gtk2, not Gtk3. This means that you will receive a kernel dump with a message similar to:

 Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported 

You may be able to do something hacked by accessing the Gtk 3 libs from the diff process, but it is a hack.

0
source

All Articles