GNOME Bugzilla – Bug 636501
Port to the new gtk+ 3.0 GtkStyleContext
Last modified: 2011-01-11 01:28:53 UTC
gtk+ 2.91.6+ has changed API. GTK+ branch gtk-style-context has been merged to master and porting is required to GtkStyleContext. See: http://git.gnome.org/browse/gtk+/commit/?id=f8a874abb1d1d8925b0f841e95bbef6cdcb21ac4 build failure (from git master): ephy-location-entry.c: In function 'ephy_location_entry_style_set': ephy-location-entry.c:139:2: warning: implicit declaration of function 'gtk_widget_get_style' ephy-location-entry.c:139:2: warning: nested extern declaration of 'gtk_widget_get_style' ephy-location-entry.c:139:49: error: invalid type argument of '->' (have 'int') make[4]: Leaving directory `/home/Oxyde/gnome/epiphany/lib/widgets' make[3]: Leaving directory `/home/Oxyde/gnome/epiphany/lib' make[2]: Leaving directory `/home/Oxyde/gnome/epiphany/lib' make[1]: Leaving directory `/home/Oxyde/gnome/epiphany' ephy-location-entry.c: In function 'favicon_create_drag_surface': ephy-location-entry.c:790:8: warning: assignment makes pointer from integer without a cast ephy-location-entry.c: In function 'textcell_data_func': ephy-location-entry.c:1081:9: warning: assignment makes pointer from integer without a cast ephy-location-entry.c: In function 'ephy_location_entry_set_secure': ephy-location-entry.c:1570:3: warning: implicit declaration of function 'gtk_widget_modify_text' ephy-location-entry.c:1570:3: warning: nested extern declaration of 'gtk_widget_modify_text' ephy-location-entry.c:1571:3: warning: implicit declaration of function 'gtk_widget_modify_base' ephy-location-entry.c:1571:3: warning: nested extern declaration of 'gtk_widget_modify_base'
Confirming.
I'm working on this.
Created attachment 176435 [details] [review] egg: update from master Bug #636501
Created attachment 176436 [details] [review] Port to gtk+ master's GtkStyleContext Updates all our uses of GtkStyle stuff to the newer GtkStyleContext API. ephy-web-view porting done by Matthias Clasen <mclasen@redhat.com> Bug #636501
This two patches should be enough. Notice that the code to make the location bar change color when the website is secure is not having any effect, apparently due to the fallout of GtkStyleContext. It is supposed to just work when GTK+ stabilizes.
Review of attachment 176436 [details] [review]: ::: embed/ephy-web-view.c @@ +1198,3 @@ + priv->text_rectangle.width, + priv->text_rectangle.height); + gtk_style_context_restore (context); Why do you restore the context before gtk_render_layout? I would just set the normal state, render layot and then restore the context. ::: lib/widgets/ephy-location-entry.c @@ +156,2 @@ + if (fg_color != NULL) + priv->secure_fg_color = *fg_color; fg_color should be freed here with gdk_rgba_free() @@ +161,2 @@ + if (bg_color != NULL) + priv->secure_bg_color = *bg_color; The same here, free bg_color ::: src/ephy-notebook.c @@ +628,3 @@ + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider() takes a reference, so you should unref() the provider after add_provider().
Created attachment 176463 [details] [review] Port to gtk+ master's GtkStyleContext Updates all our uses of GtkStyle stuff to the newer GtkStyleContext API. ephy-web-view porting done by Matthias Clasen <mclasen@redhat.com> Bug #636501
Review of attachment 176463 [details] [review]: Looks good to me too, thanks for the review Carlos.
Done! Thanks for your help Carlos :) Attachment 176435 [details] pushed as f6ffd60 - egg: update from master Attachment 176463 [details] pushed as 43a776e - Port to gtk+ master's GtkStyleContext
Review of attachment 176463 [details] [review]: ::: lib/widgets/ephy-location-entry.c @@ +91,3 @@ +static const GdkRGBA fallback_bg_color = { 0, 0xf7f7, 0xf7f7, 0xbebe }; /* yellow-ish */ +static const GdkRGBA fallback_fg_color = { 0, 0, 0, 0 }; /* black */ This seems wrong to me; the bg color should be { 0xf7f7 / 65535, 0xf7f7 / 65535, 0xbebe / 65535, 1 } and black { 0, 0, 0, 1 }, as GdkRGBA uses double values in the [0, 1] interval to hold color values, and the last member is the alpha channel.
(In reply to comment #5) > Notice that the code to make the location bar change color when the website is > secure is not having any effect, apparently due to the fallout of > GtkStyleContext. It is supposed to just work when GTK+ stabilizes. Reopening, as this might be happening because of what I mentioned in my last comment.
(In reply to comment #10) > Review of attachment 176463 [details] [review]: > > ::: lib/widgets/ephy-location-entry.c > @@ +91,3 @@ > > +static const GdkRGBA fallback_bg_color = { 0, 0xf7f7, 0xf7f7, 0xbebe }; /* > yellow-ish */ > +static const GdkRGBA fallback_fg_color = { 0, 0, 0, 0 }; /* black */ > > This seems wrong to me; the bg color should be { 0xf7f7 / 65535, 0xf7f7 / > 65535, 0xbebe / 65535, 1 } and black { 0, 0, 0, 1 }, as GdkRGBA uses double > values in the [0, 1] interval to hold color values, and the last member is the > alpha channel. You are right about the range values, but I've tested this and it does not seem to fix the issue. You can commit anyway.
Building git master against GTK+ master still fails with this error for me: make[4]: Entering directory `/home/uws/Projects/Gnome/Development/src/epiphany/src' CCLD epiphany ./.libs/libephymain.a(libephymain_la-ephy-notebook.o): In function `tab_label_style_set_cb': /home/uws/Projects/Gnome/Development/src/epiphany/src/ephy-notebook.c:565: undefined reference to `gtk_style_context_get_font' ../lib/widgets/.libs/libephywidgets.a(libephywidgets_la-ephy-location-entry.o): In function `favicon_create_drag_surface': /home/uws/Projects/Gnome/Development/src/epiphany/lib/widgets/ephy-location-entry.c:794: undefined reference to `gtk_style_context_get_font' collect2: ld returned 1 exit status make[4]: *** [epiphany] Error 1 make[4]: Leaving directory `/home/uws/Projects/Gnome/Development/src/epiphany/src' Any clue?
Created attachment 177435 [details] [review] ephy-location-entry: fix secure bg/fg colors GdkRGBA elements are double type, also we need to pass "0" as GtkStateFlag for the override functions, otherwise our colors are never applied. Bug #636501
Created attachment 177826 [details] [review] ephy-location-entry: fix secure bg/fg colors GdkRGBA elements are doubles. Also, we need to pass GTK_STATE_FLAG_NORMAL as GtkStateFlag for the override functions, otherwise our colors are never applied. Bug #636501
Created attachment 177827 [details] [review] Use the new GTK_STATE_FLAG_NORMAL flag Until 2.99.0 GtkStyleContext didn't have a "normal" flag, the closest thing was GTK_STATE_FLAG_ACTIVE, but it is not necessarily correct. Bug #636501
Attachment 177827 [details] pushed as b2bbeb1 - Use the new GTK_STATE_FLAG_NORMAL flag