[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Mar 5 08:26:09 PST 2015
vcl/inc/unx/gtk/gtkgdi.hxx | 2 -
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 36 +++++++++++++++++---------
2 files changed, 25 insertions(+), 13 deletions(-)
New commits:
commit db041f15b37255650418b13ad9f85f0938dc1bef
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Mar 5 16:15:38 2015 +0000
Try a different approach to get the style hierarchy right
in order to get the font colors for menus right.
includes revert "set parent styles to fall back to"
This reverts commit 710d034467a96270175d6a1edf8d655a8345a4c3.
Change-Id: Ica73a30a44a5dd61a8310f2bee74068c406f470a
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 549226d..b88220c 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -77,7 +77,7 @@ private:
static GtkStyleContext *mpComboboxStyle;
static GtkStyleContext *mpListboxStyle;
- void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
+ void getStyleContext(GtkStyleContext** style, GtkWidget* widget);
Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
Rectangle NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect );
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index a3948e9..6db5fef 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -1140,7 +1140,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
gtk_widget_path_append_type( pCPath, GTK_TYPE_TEXT_VIEW );
gtk_widget_path_iter_add_class( pCPath, -1, GTK_STYLE_CLASS_VIEW );
gtk_style_context_set_path( pCStyle, pCPath );
- gtk_style_context_set_parent(pCStyle, gtk_widget_get_style_context(mpWindow));
gtk_widget_path_free( pCPath );
GdkRGBA field_background_color;
gtk_style_context_get_background_color(pCStyle, GTK_STATE_FLAG_NORMAL, &field_background_color);
@@ -1428,15 +1427,22 @@ bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP
return false;
}
+static GtkWidget* gCacheWindow;
+static GtkWidget* gDumbContainer;
+
void GtkData::initNWF() {}
-void GtkData::deInitNWF() {}
+
+void GtkData::deInitNWF()
+{
+ if (gCacheWindow)
+ gtk_widget_destroy(gCacheWindow);
+}
void GtkSalGraphics::getStyleContext(GtkStyleContext** style, GtkWidget* widget)
{
+ gtk_container_add(GTK_CONTAINER(gDumbContainer), widget);
*style = gtk_widget_get_style_context(widget);
g_object_ref(*style);
- gtk_style_context_set_parent(*style, gtk_widget_get_style_context(mpWindow));
- gtk_widget_destroy(widget);
}
GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
@@ -1446,14 +1452,22 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
{
m_xTextRenderImpl.reset(new GtkCairoTextRender(*this));
- if (style_loaded)
+ if(style_loaded)
return;
+ GtkWidgetPath* path;
+
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
* too slow */
+ gCacheWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gDumbContainer = gtk_fixed_new();
+ gtk_container_add(GTK_CONTAINER(gCacheWindow), gDumbContainer);
+ gtk_widget_realize(gDumbContainer);
+ gtk_widget_realize(gCacheWindow);
+
getStyleContext(&mpEntryStyle, gtk_entry_new());
getStyleContext(&mpButtonStyle, gtk_button_new());
@@ -1464,15 +1478,14 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
getStyleContext(&mpToolButtonStyle, gtk_button_new());
/* Create a widget path for our toolbutton widget */
- GtkWidgetPath* path = gtk_widget_path_new();
+ path = gtk_widget_path_new();
gtk_widget_path_append_type(path, GTK_TYPE_TOOLBAR);
gtk_widget_path_append_type(path, GTK_TYPE_TOOL_BUTTON);
gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
gtk_widget_path_iter_add_class (path, 0, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
- gtk_widget_path_iter_add_class (path, 1, GTK_STYLE_CLASS_TOOLBAR);
+ gtk_widget_path_iter_add_class (path, 0, GTK_STYLE_CLASS_TOOLBAR);
gtk_widget_path_iter_add_class (path, 2, GTK_STYLE_CLASS_BUTTON);
gtk_style_context_set_path(mpToolButtonStyle, path);
- gtk_style_context_set_parent(mpToolButtonStyle, gtk_widget_get_style_context(mpWindow));
gtk_widget_path_free (path);
getStyleContext(&mpVScrollbarStyle, gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL));
@@ -1483,7 +1496,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
getStyleContext(&mpCheckButtonStyle, gtk_check_button_new());
/* Menu */
- getStyleContext(&mpMenuStyle, gtk_menu_new());
+ GtkWidget *menu = gtk_menu_new();
+ mpMenuStyle = gtk_widget_get_style_context(menu);
+ g_object_ref_sink(menu);
/* Menu Items */
path = gtk_widget_path_new();
@@ -1493,7 +1508,6 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
gtk_widget_path_iter_add_class(path, 1, GTK_STYLE_CLASS_MENUITEM);
mpMenuItemStyle = gtk_style_context_new();
gtk_style_context_set_path(mpMenuItemStyle, path);
- gtk_style_context_set_parent(mpMenuItemStyle, mpMenuStyle);
gtk_widget_path_free(path);
/* Menu bar */
@@ -1506,7 +1520,6 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
/* Combobox */
mpComboboxStyle = gtk_style_context_new();
PrepareComboboxStyle(mpComboboxStyle, true);
- gtk_style_context_set_parent(mpComboboxStyle, gtk_widget_get_style_context(mpWindow));
/* Listbox */
mpListboxStyle = gtk_style_context_new();
@@ -1515,7 +1528,6 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
gtk_widget_path_iter_add_class(path, 1, GTK_STYLE_CLASS_BUTTON);
gtk_style_context_set_path(mpListboxStyle, path);
- gtk_style_context_set_parent(mpListboxStyle, gtk_widget_get_style_context(mpWindow));
gtk_widget_path_free(path);
}
More information about the Libreoffice-commits
mailing list