summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-05-14 20:18:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-05-15 15:23:31 +0200
commit7354ae9449bf9e325eb96eaa18d35ee68d304295 (patch)
tree1c104b879aa7689c28a33e7419ee96045d3a81c7 /vcl
parent9b4a3fb16f2db09a61a4b53f40f1b3c15540b123 (diff)
gtk4: get cursor size and text selection color
Change-Id: Ic24b5bdce9a868dc5e00da4ad2431108c5b0aceb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115634 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/salnativewidgets-gtk.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index f7e31591793c..b6ab49a34485 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -361,6 +361,7 @@ static GtkWidget* gSpinBox;
#if GTK_CHECK_VERSION(4, 0, 0)
static GtkWidget* gVScrollbar;
static GtkWidget* gHScrollbar;
+static GtkWidget* gTextView;
#endif
static GtkWidget* gEntryBox;
static GtkWidget* gComboBox;
@@ -2384,14 +2385,17 @@ bool GtkSalGraphics::updateSettings(AllSettings& rSettings)
}
#endif
-#if !GTK_CHECK_VERSION(4, 0, 0)
GdkRGBA color;
{
+#if !GTK_CHECK_VERSION(4, 0, 0)
// construct style context for text view
GtkWidgetPath *pCPath = gtk_widget_path_new();
gtk_widget_path_append_type( pCPath, GTK_TYPE_TEXT_VIEW );
gtk_widget_path_iter_add_class( pCPath, -1, GTK_STYLE_CLASS_VIEW );
GtkStyleContext *pCStyle = makeContext( pCPath, nullptr );
+#else
+ GtkStyleContext *pCStyle = gtk_widget_get_style_context(gTextView);
+#endif
aContextState.save(pCStyle);
// highlighting colors
@@ -2415,11 +2419,16 @@ bool GtkSalGraphics::updateSettings(AllSettings& rSettings)
// This baby is the default page/paper color
aStyleSet.SetWindowColor( aBackFieldColor );
+#if GTK_CHECK_VERSION(4, 0, 0)
+ double caretAspectRatio = 0.04f;
+ g_object_get(pSettings, "gtk-cursor-aspect-ratio", &caretAspectRatio, nullptr);
+#else
// Cursor width
gfloat caretAspectRatio = 0.04f;
gtk_style_context_get_style( pCStyle, "cursor-aspect-ratio", &caretAspectRatio, nullptr );
+#endif
// Assume 20px tall for the ratio computation, which should give reasonable results
- aStyleSet.SetCursorSize( 20 * caretAspectRatio + 1 );
+ aStyleSet.SetCursorSize(20 * caretAspectRatio + 1);
// Dark shadow color
style_context_set_state(pCStyle, GTK_STATE_FLAG_INSENSITIVE);
@@ -2435,13 +2444,14 @@ bool GtkSalGraphics::updateSettings(AllSettings& rSettings)
aStyleSet.SetShadowColor(aShadowColor);
aContextState.restore();
+#if !GTK_CHECK_VERSION(4, 0, 0)
g_object_unref( pCStyle );
+#endif
// Tab colors
aStyleSet.SetActiveTabColor( aBackFieldColor ); // same as the window color.
aStyleSet.SetInactiveTabColor( aBackColor );
}
-#endif
// menu disabled entries handling
aStyleSet.SetSkipDisabledInMenus( true );
@@ -2898,6 +2908,10 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
gtk_fixed_put(GTK_FIXED(gDumbContainer), gHScrollbar, 0, 0);
gtk_widget_show(gHScrollbar);
mpHScrollbarStyle = gtk_widget_get_style_context(gHScrollbar);
+
+ gTextView = gtk_text_view_new();
+ gtk_fixed_put(GTK_FIXED(gDumbContainer), gTextView, 0, 0);
+ gtk_widget_show(gTextView);
#else
mpVScrollbarStyle = createStyleContext(GtkControlPart::ScrollbarVertical);
mpVScrollbarContentsStyle = createStyleContext(GtkControlPart::ScrollbarVerticalContents);