diff options
author | Lucas Baudin <xapantu@gmail.com> | 2011-10-22 18:07:07 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2011-10-25 13:41:59 +0100 |
commit | 9d0f5c8a0cacc7b109bc9aa7684a336b4b24221d (patch) | |
tree | 0f5e72fd79186e68c52cb2565298d2018d14eabc /vcl | |
parent | 82746a387519e426f533c49c79b60a9846f99863 (diff) |
gtk3: Use some static variable in GtkSalGraphics in order to avoid re-loading all GtkStylaContexts
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 13 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 20 |
2 files changed, 22 insertions, 11 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 6ca6c47dbe66..46047515d8cb 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -66,16 +66,17 @@ public: void updateSettings( AllSettings& rSettings ); private: GtkWidget *mpWindow; - GtkStyleContext *mpButtonStyle; - GtkStyleContext *mpEntryStyle; - GtkStyleContext *mpScrollbarStyle; - GtkStyleContext *mpToolbarStyle; - GtkStyleContext *mpToolButtonStyle; - GtkStyleContext *mpCheckButtonStyle; + static GtkStyleContext *mpButtonStyle; + static GtkStyleContext *mpEntryStyle; + static GtkStyleContext *mpScrollbarStyle; + static GtkStyleContext *mpToolbarStyle; + static GtkStyleContext *mpToolButtonStyle; + static GtkStyleContext *mpCheckButtonStyle; void renderAreaToPix( cairo_t* cr, cairo_rectangle_t* rect ); void drawStyleContext( GtkStyleContext* style, GtkStateFlags flags, const Rectangle& rControlRegion, bool render_background = true ); void getStyleContext( GtkStyleContext** style, GtkWidget* widget ); + static bool style_loaded; }; #else diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index a5877dd0841c..fb88bc4ceb60 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -34,6 +34,13 @@ #include <unx/gtk/gtkinst.hxx> #include <unx/gtk/gtkgdi.hxx> +GtkStyleContext* GtkSalGraphics::mpButtonStyle = NULL; +GtkStyleContext* GtkSalGraphics::mpEntryStyle = NULL; +GtkStyleContext* GtkSalGraphics::mpScrollbarStyle = NULL; +GtkStyleContext* GtkSalGraphics::mpToolbarStyle = NULL; +GtkStyleContext* GtkSalGraphics::mpToolButtonStyle = NULL; +GtkStyleContext* GtkSalGraphics::mpCheckButtonStyle = NULL; +bool GtkSalGraphics::style_loaded = false; /************************************************************************ * State conversion ************************************************************************/ @@ -107,11 +114,11 @@ void GtkSalGraphics::drawStyleContext( GtkStyleContext* style, GtkStateFlags fla */ gtk_render_background(gtk_widget_get_style_context(mpWindow), cr, - -2, -2, - rControlRegion.GetWidth() + 6, rControlRegion.GetHeight() + 6); + 1, -2, + rControlRegion.GetWidth(), rControlRegion.GetHeight() + 6); gtk_render_background(mpToolbarStyle, cr, - -4, -4, - rControlRegion.GetWidth() + 8, rControlRegion.GetHeight() + 8); + 1, -4, + rControlRegion.GetWidth(), rControlRegion.GetHeight() + 8); } gtk_style_context_set_state(style, flags); @@ -556,7 +563,7 @@ void GtkSalGraphics::getStyleContext(GtkStyleContext** style, GtkWidget* widget) { *style = gtk_widget_get_style_context(widget); g_object_ref(*style); - //gtk_widget_destroy(widget); + gtk_widget_destroy(widget); } GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) @@ -565,6 +572,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) mpWindow( pWindow ) { + if(style_loaded) + return; + style_loaded = true; gtk_init(NULL, NULL); /* Load the GtkStyleContexts, it might be a bit slow, but usually, * gtk apps create a lot of widgets at startup, so, it shouldn't be |