summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-05 16:15:38 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-03-05 16:25:37 +0000
commitdb041f15b37255650418b13ad9f85f0938dc1bef (patch)
tree815f56a149551dd320f3e99d97cf7906cd24688b /vcl/unx/gtk3
parent7d8cf47d62ca380d4b25c5c92e68ad25b951b06e (diff)
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
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx36
1 files changed, 24 insertions, 12 deletions
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index a3948e9610b2..6db5fef0040e 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);
}