aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2021-09-13 09:43:08 +1000
committerNeil Hodgson <nyamatongwe@gmail.com>2021-09-13 09:43:08 +1000
commit4c33ed1eadb5aae24ca1752a82cf4045a32d8fe0 (patch)
tree7818d298d15325ec10d80454f0137337f280da15
parente1a52e49814cb1ab2efcdbd65dcb9a83976c2a54 (diff)
downloadscintilla-mirror-4c33ed1eadb5aae24ca1752a82cf4045a32d8fe0.tar.gz
Hold onto global GtkSettings object as used multiple times.
-rwxr-xr-xgtk/ScintillaGTK.cxx36
-rwxr-xr-xgtk/ScintillaGTK.h2
2 files changed, 26 insertions, 12 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 0a054c8d1..7b47d6348 100755
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -179,6 +179,18 @@ GdkAtom SelectionOfGSD(GtkSelectionData *sd) noexcept {
return gtk_selection_data_get_selection(sd);
}
+bool SettingGet(GtkSettings *settings, const gchar *name, gpointer value) noexcept {
+ if (!settings) {
+ return false;
+ }
+ if (!g_object_class_find_property(G_OBJECT_GET_CLASS(
+ G_OBJECT(settings)), name)) {
+ return false;
+ }
+ g_object_get(G_OBJECT(settings), name, value, nullptr);
+ return true;
+}
+
}
FontOptions::FontOptions(GtkWidget *widget) noexcept {
@@ -218,6 +230,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
preeditInitialized(false),
im_context(nullptr),
lastNonCommonScript(G_UNICODE_SCRIPT_INVALID_CODE),
+ settings(nullptr),
lastWheelMouseTime(0),
lastWheelMouseDirection(0),
wheelMouseIntensity(0),
@@ -264,6 +277,9 @@ ScintillaGTK::~ScintillaGTK() {
}
ClearPrimarySelection();
wPreedit.Destroy();
+ if (settings) {
+ g_object_unref(settings);
+ }
}
void ScintillaGTK::RealizeThis(GtkWidget *widget) {
@@ -669,20 +685,16 @@ void ScintillaGTK::Init() {
gtk_container_add(GTK_CONTAINER(PWidget(wPreedit)), predrw);
gtk_widget_show(predrw);
+ settings = gtk_settings_get_default();
+
// Set caret period based on GTK settings
gboolean blinkOn = false;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(
- G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink")) {
- g_object_get(G_OBJECT(
- gtk_settings_get_default()), "gtk-cursor-blink", &blinkOn, nullptr);
- }
- if (blinkOn &&
- g_object_class_find_property(G_OBJECT_GET_CLASS(
- G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink-time")) {
- gint value;
- g_object_get(G_OBJECT(
- gtk_settings_get_default()), "gtk-cursor-blink-time", &value, nullptr);
- caret.period = static_cast<int>(value / 1.75);
+ SettingGet(settings, "gtk-cursor-blink", &blinkOn);
+ if (blinkOn) {
+ gint value = 500;
+ if (SettingGet(settings, "gtk-cursor-blink-time", &value)) {
+ caret.period = static_cast<int>(value / 1.75);
+ }
} else {
caret.period = 0;
}
diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h
index 2db733c87..da2f74c90 100755
--- a/gtk/ScintillaGTK.h
+++ b/gtk/ScintillaGTK.h
@@ -62,6 +62,8 @@ class ScintillaGTK : public ScintillaBase {
GtkIMContext *im_context;
GUnicodeScript lastNonCommonScript;
+ GtkSettings *settings;
+
// Wheel mouse support
unsigned int linesPerScroll;
gint64 lastWheelMouseTime;