Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


This patch cleans up the GTK+ module a bit, fixing theming bugs in corner cases by using ONE way to 
get screen and settings, the different variants were either wrong or needlessly confusing.

ciao,
    Christian
From 56349903b4f4b3350499263cb150346ff407471a Mon Sep 17 00:00:00 2001
From: Christian Dywan <christian@twotoasts.de>
Date: Thu, 28 Apr 2011 19:30:22 +0200
Subject: [PATCH] Clean up GtkSettings use in GTK+ platform module

---
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |   39 ++++++++---------------------
 1 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 9a81fd7..981d1be 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -3246,6 +3246,12 @@ void printStyleColors( GtkStyle* pStyle )
 
 void GtkSalGraphics::updateSettings( AllSettings& rSettings )
 {
+    GdkScreen* pScreen = gtk_widget_get_screen( m_pWindow );
+    gtk_widget_ensure_style( m_pWindow );
+    GtkStyle* pStyle = gtk_widget_get_style( m_pWindow );
+    GtkSettings* pSettings = gtk_widget_get_settings( m_pWindow );
+    StyleSettings aStyleSet = rSettings.GetStyleSettings();
+
     // get the widgets in place
     NWEnsureGTKMenu( m_nScreen );
     NWEnsureGTKMenubar( m_nScreen );
@@ -3253,11 +3259,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     NWEnsureGTKEditBox( m_nScreen );
     NWEnsureGTKTooltip( m_nScreen );
 
-    gtk_widget_ensure_style( m_pWindow );
-    GtkStyle* pStyle = gtk_widget_get_style( m_pWindow );
-
-    StyleSettings aStyleSet = rSettings.GetStyleSettings();
-
 #if OSL_DEBUG_LEVEL > 2
     printStyleColors( pStyle );
 #endif
@@ -3479,7 +3480,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     aStyleSet.SetFloatTitleFont( aFont );
 
     // get cursor blink time
-    GtkSettings *pSettings = gtk_widget_get_settings( gWidgetData[m_nScreen].gEditBoxWidget );
     gboolean blink = false;
 
     g_object_get( pSettings, "gtk-cursor-blink", &blink, (char *)NULL );
@@ -3512,7 +3512,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     rSettings.SetMouseSettings( aMouseSettings );
 
     gboolean showmenuicons = true;
-    pSettings = gtk_widget_get_settings( gWidgetData[m_nScreen].gImageMenuItem );
     g_object_get( pSettings, "gtk-menu-images", &showmenuicons, (char *)NULL );
     aStyleSet.SetPreferredUseImagesInMenus( showmenuicons );
 
@@ -3533,45 +3532,29 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
 
     // preferred icon style
     gchar* pIconThemeName = NULL;
-    g_object_get( gtk_settings_get_default(), "gtk-icon-theme-name", &pIconThemeName, (char *)NULL 
);
+    g_object_get( pSettings, "gtk-icon-theme-name", &pIconThemeName, (char *)NULL );
     aStyleSet.SetPreferredSymbolsStyleName( OUString::createFromAscii( pIconThemeName ) );
     g_free( pIconThemeName );
 
        aStyleSet.SetToolbarIconSize( STYLE_TOOLBAR_ICONSIZE_LARGE );
 
     const cairo_font_options_t* pNewOptions = NULL;
-    if( GdkScreen* pScreen = gdk_display_get_screen( gdk_display_get_default(), m_nScreen ) )
-    {
 #if !GTK_CHECK_VERSION(2,9,0)
     static cairo_font_options_t* (*gdk_screen_get_font_options)(GdkScreen*) =
         (cairo_font_options_t*(*)(GdkScreen*))osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, 
"gdk_screen_get_font_options" );
     if( gdk_screen_get_font_options != NULL )
 #endif
         pNewOptions = gdk_screen_get_font_options( pScreen );
-    }
     aStyleSet.SetCairoFontOptions( pNewOptions );
 
     // finally update the collected settings
     rSettings.SetStyleSettings( aStyleSet );
 
+    gchar* pThemeName = NULL;
+    g_object_get( pSettings, "gtk-theme-name", &pThemeName, (char *)NULL );
     #if OSL_DEBUG_LEVEL > 1
-    {
-        GtkSettings* pGtkSettings = gtk_settings_get_default();
-        GValue aValue;
-        memset( &aValue, 0, sizeof(GValue) );
-        g_value_init( &aValue, G_TYPE_STRING );
-        g_object_get_property( G_OBJECT(pGtkSettings), "gtk-theme-name", &aValue );
-        const gchar* pThemeName = g_value_get_string( &aValue );
-        std::fprintf( stderr, "Theme name is \"%s\"\n", pThemeName );
-        g_value_unset( &aValue );
-    }
+    std::fprintf( stderr, "Theme name is \"%s\"\n", pThemeName );
     #endif
-    GtkSettings* pGtkSettings = gtk_settings_get_default();
-    GValue aValue;
-    memset( &aValue, 0, sizeof(GValue) );
-    g_value_init( &aValue, G_TYPE_STRING );
-    g_object_get_property( G_OBJECT(pGtkSettings), "gtk-theme-name", &aValue );
-    const gchar* pThemeName = g_value_get_string( &aValue );
 
     // default behaviour
     bNeedPixmapPaint = bGlobalNeedPixmapPaint;
@@ -3596,7 +3579,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
         }
     }
     // clean up
-    g_value_unset( &aValue );
+    g_free (pThemeName);
 }
 
 
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.