[Libreoffice-commits] .: Branch 'feature/gtk3' - vcl/inc vcl/unx
Lucas Baudin
lbaudin at kemper.freedesktop.org
Sat Oct 22 09:07:19 PDT 2011
vcl/inc/unx/gtk/gtkgdi.hxx | 13 +++++++------
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 20 +++++++++++++++-----
2 files changed, 22 insertions(+), 11 deletions(-)
New commits:
commit 1d16cd8dbe45c5dbad4539f202728adc374301e5
Author: Lucas Baudin <xapantu at gmail.com>
Date: Sat Oct 22 18:07:07 2011 +0200
gtk3: Use some static variable in GtkSalGraphics in order to avoid re-loading all GtkStylaContexts
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 6ca6c47..4604751 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 a5877dd..fb88bc4 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
More information about the Libreoffice-commits
mailing list