From fcef1adabfb53716563957a6f987949ff9d899db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Tue, 27 Dec 2022 22:15:50 +0100 Subject: [PATCH] Application.MiddleClickPaste is a new property that tells if middle click should paste. [GB.GTK] * NEW: Application.MiddleClickPaste is a new property that tells if middle click should paste. The global GTK+ settings is taken into account at application startup. [GB.GTK3] * NEW: Application.MiddleClickPaste is a new property that tells if middle click should paste. The global GTK+ settings is taken into account at application startup. [GB.QT4] * NEW: Application.MiddleClickPaste is a new property that tells if middle click should paste. [GB.QT5] * NEW: Application.MiddleClickPaste is a new property that tells if middle click should paste. --- gb.gtk/src/CScreen.cpp | 20 ++++++++++++++++++++ gb.gtk/src/gapplication.cpp | 13 +++++++++++++ gb.gtk/src/gapplication.h | 4 +++- gb.qt4/src/CScreen.cpp | 12 ++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/gb.gtk/src/CScreen.cpp b/gb.gtk/src/CScreen.cpp index f0e183e7a..613159815 100644 --- a/gb.gtk/src/CScreen.cpp +++ b/gb.gtk/src/CScreen.cpp @@ -50,6 +50,7 @@ static CSCREEN *_screens[MAX_SCREEN] = { NULL }; static bool _animations = FALSE; static bool _shadows = FALSE; +static bool _middle_click_paste = TRUE; //------------------------------------------------------------------------- @@ -261,6 +262,16 @@ BEGIN_PROPERTY(Application_Animations) END_PROPERTY +BEGIN_PROPERTY(Application_MiddleClickPaste) + + if (READ_PROPERTY) + GB.ReturnBoolean(_middle_click_paste); + else + _middle_click_paste = VPROP(GB_BOOLEAN); + +END_PROPERTY + + BEGIN_PROPERTY(Application_Shadows) if (READ_PROPERTY) @@ -287,6 +298,13 @@ BEGIN_PROPERTY(Application_MainWindow) END_PROPERTY +BEGIN_METHOD_VOID(Application_init) + + _middle_click_paste = gApplication::hasMiddleClickPaste(); + +END_METHOD + + BEGIN_METHOD_VOID(Application_exit) GB.FreeString(&CAPPLICATION_Theme); @@ -523,6 +541,7 @@ GB_DESC ApplicationDesc[] = { GB_DECLARE("Application", 0), GB_VIRTUAL_CLASS(), + GB_STATIC_METHOD("_init", NULL, Application_init, 0), GB_STATIC_METHOD("_exit", NULL, Application_exit, 0), GB_STATIC_PROPERTY("Font", "Font", Application_Font), @@ -534,6 +553,7 @@ GB_DESC ApplicationDesc[] = GB_STATIC_PROPERTY("ShowTooltips", "b", Application_ShowTooltips), GB_STATIC_PROPERTY("Animations", "b", Application_Animations), GB_STATIC_PROPERTY("Shadows", "b", Application_Shadows), + GB_STATIC_PROPERTY("MiddleClickPaste", "b", Application_MiddleClickPaste), GB_STATIC_PROPERTY("Embedder", "i", Application_Embedder), GB_STATIC_PROPERTY("Theme", "s", Application_Theme), GB_STATIC_PROPERTY_READ("DarkTheme", "s", Application_DarkTheme), diff --git a/gb.gtk/src/gapplication.cpp b/gb.gtk/src/gapplication.cpp index 7f957a351..96790e5c7 100644 --- a/gb.gtk/src/gapplication.cpp +++ b/gb.gtk/src/gapplication.cpp @@ -1808,3 +1808,16 @@ bool gApplication::eventsPending() return gtk_events_pending(); } + +bool gApplication::hasMiddleClickPaste() +{ + gboolean enabled; + GtkSettings *settings; + + settings = gtk_settings_get_default(); + + g_object_get(settings, "gtk-enable-primary-paste", &enabled, (char *)NULL); + + return enabled; +} + diff --git a/gb.gtk/src/gapplication.h b/gb.gtk/src/gapplication.h index 9563a6494..61153fe6d 100644 --- a/gb.gtk/src/gapplication.h +++ b/gb.gtk/src/gapplication.h @@ -52,8 +52,10 @@ public: static void setActiveControl(gControl *control, bool on); static void finishFocus(); - static void enableTooltips(bool vl); static bool areTooltipsEnabled(); + static void enableTooltips(bool vl); + + static bool hasMiddleClickPaste(); static int dblClickTime(); diff --git a/gb.qt4/src/CScreen.cpp b/gb.qt4/src/CScreen.cpp index 08ce5fd66..c5ff06561 100644 --- a/gb.qt4/src/CScreen.cpp +++ b/gb.qt4/src/CScreen.cpp @@ -74,6 +74,7 @@ static CSCREEN *_screens[MAX_SCREEN] = { NULL }; static bool _animations = FALSE; static bool _shadows = FALSE; +static bool _middle_click_paste = TRUE; static CSCREEN *get_screen(int num) { @@ -276,6 +277,16 @@ BEGIN_PROPERTY(Application_Animations) END_PROPERTY +BEGIN_PROPERTY(Application_MiddleClickPaste) + + if (READ_PROPERTY) + GB.ReturnBoolean(_middle_click_paste); + else + _middle_click_paste = VPROP(GB_BOOLEAN); + +END_PROPERTY + + BEGIN_PROPERTY(Application_Shadows) if (READ_PROPERTY) @@ -574,6 +585,7 @@ GB_DESC ApplicationDesc[] = GB_STATIC_PROPERTY("Busy", "i", Application_Busy), GB_STATIC_PROPERTY("ShowTooltips", "b", Application_ShowTooltips), GB_STATIC_PROPERTY("Animations", "b", Application_Animations), + GB_STATIC_PROPERTY("MiddleClickPaste", "b", Application_MiddleClickPaste), GB_STATIC_PROPERTY("Shadows", "b", Application_Shadows), GB_STATIC_PROPERTY("Embedder", "i", Application_Embedder), GB_STATIC_PROPERTY("Theme", "s", Application_Theme),