diff options
author | Gordon Norman Squash <gordsqsh@protonmail.com> | 2021-02-25 18:56:24 -0500 |
---|---|---|
committer | Gordon Norman Squash <gordsqsh@protonmail.com> | 2021-02-25 18:56:24 -0500 |
commit | 3a2cf548586f45051b2ebe095151ed36f2005d60 (patch) | |
tree | 102b5b85b397cf7edcc1f8b2df361ade29abcade | |
parent | First commit to STLWRT-ian GTK Modules repository (diff) | |
download | sgm-3a2cf548586f45051b2ebe095151ed36f2005d60.tar.gz sgm-3a2cf548586f45051b2ebe095151ed36f2005d60.tar.bz2 sgm-3a2cf548586f45051b2ebe095151ed36f2005d60.zip |
-rw-r--r-- | README.md | 83 | ||||
-rw-r--r-- | meson.build | 9 | ||||
-rw-r--r-- | sgm-flexible-mnemonics.c | 9 | ||||
-rw-r--r-- | sgm-overlay-scrolling-override.c | 144 |
4 files changed, 58 insertions, 187 deletions
@@ -7,7 +7,7 @@ this repository only contains the code for the "sgm-flexible-mnemonics" module, but more are planned to follow. Similarly, this module is known not to work with GTK 4 yet, but support for GTK 4 should come eventually too, as long as the community doesn't drag their feet in adopting GTK 4 -but that's a different story). +(but that's a different story). ### sgm-flexible-mnemonics @@ -20,37 +20,6 @@ GTK+ 3.9.8, the latter mode is always used no matter the setting of `gtk-auto-mnemonics`. This module restores the classic mnemonic behavior to GTK+ 3.9.8 and later versions of GTK. -### sgm-overlay-scrolling **(COMING SOON)** - -Traditionally, scrollbars have appeared to the side of scrolled content. -In GTK+ 3.15.0, a new means of displaying scrollbars was introduced: -*overlay scrolling*. When overlay scrolling is enabled, scrollbars do not -initially appear; instead they wait for mouse movement before appearing, -and even then appear *on top* of scrolled content instead of *to the side* -of said content. This is good for users with little screen space, and it -would be tolerable to other users if there were an easy way to disable it; -however, until GTK+ 3.24.9 there was only an environment variable to -disable overlay scrolling globally. An environment variable is tolerable, -but it needs to be set every time a GTK application is run, or else overlay -scrolling will be enabled again. In GTK+ 3.24.9, a new setting was -introduced to disable overlay scrolling globally, `gtk-overlay-scrolling`. -But this setting left users of older versions of GTK in the lurch; even -today, some users continue to use GTK versions as old as 3.18 because that -is the latest version shipped by their distributor for an old Long Term -Support release of their distribution. This module adds the -`gtk-overlay-scrolling` setting to GTK versions prior to 3.24.9, so that -conservative themes can universally set the `gtk-overlay-scrolling` -property to `false` to disable overlay scrolling -- even on GTK versions -prior to 3.24.9. - -I created this module not so much because doing so is a necessity; it -is mostly because I admittedly have a big, fat mouth and told a friend of -mine that I could write a module for this. But it's also good to have a -module that brings the GTK+ 3.24.9-and-later behavior to older versions -of GTK, I suppose. Either way, my fat mouth has cost me and you're seeing -the fruits of my embarassing talkativeness. But that's enough on the -topic of my fat mouth. - ### Planned modules for the future * A "GTK Inspector"-like tool for GTK+ 2 would be quite cool and useful. @@ -66,6 +35,56 @@ issue on this repository! Pull requests are also welcome. If you find an issue in one of these modules, please start an issue for that, too. +### Building the code + +Building the code couldn't be much easier. You just need: + + - Meson + - Ninja + - GTK: currently only version 3.8 or later will suffice, not version 4. + +To build the modules in this package: + + 1. Clone this repository, or obtain a source tarball of this repository and + extract the tarball. + + 2. Change directory into the location where your copy of the code is stored. + + 3. Make a build directory, then change directory into that: + mkdir .build; cd .build + + 4. Run the setup: + meson .. + + 5. Compile the code: + ninja + + 6. Install the modules: + sudo ninja install + +To actually use the modules, you'll need to inform GTK about their existence +and, more importantly, that you want to use them. On GTK+ 3 you can create +a file `~/.config/gtk-3.0/settings.ini` that contains: + + [Settings] + gtk-modules = [list of modules separated by colons] + +Do *not* surround the list of modules with quotes! This has unintended side +effects including presentation of cryptic `Gtk-Message`s about failing to +find module *x* or *y*. + +On GTK 4, use the same method as on GTK+ 3, but change the `gtk-3.0` above to +`gtk-4.0`. + +On GTK+ 2 (few modules here are useful for GTK+ 2), create a file +`~/.config/gtk-2.0/gtkrc` which contains the following: + + gtk-modules = [quoted list of modules separated by colons] + +It is important to *surround the list of modules with double quotes on GTK+ 2*. +Otherwise, the modules will not load. Yes, it's inconsistent. But it's not +my fault. + *** Thanks for checking out (pun intended) this repository! diff --git a/meson.build b/meson.build index 291f0b0..19ac169 100644 --- a/meson.build +++ b/meson.build @@ -13,15 +13,6 @@ modules_install_dir = join_paths(gtk_dep.get_variable( default_value: get_option('libdir')), modules_subdir) -# Don't enable this until the module is ready to go. -#shared_module('sgm-overlay-scrolling-override', -# sources: [ -# 'sgm-overlay-scrolling-override.c', -# ], -# dependencies: [ gtk_dep ], -# install_dir: modules_install_dir, -# install: true, -#) shared_module('sgm-flexible-mnemonics', sources: [ diff --git a/sgm-flexible-mnemonics.c b/sgm-flexible-mnemonics.c index 8249c95..a7290b8 100644 --- a/sgm-flexible-mnemonics.c +++ b/sgm-flexible-mnemonics.c @@ -50,6 +50,10 @@ #include <glib.h> +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "SGM-Flexible-Mnemonics-Module" + + static void (*original_gtk_label_size_allocate) (GtkWidget *widget, GtkAllocation *allocation); @@ -68,8 +72,9 @@ g_module_check_init (GModule *module) */ if (gtk_check_version (3,9,8) != NULL) { - return "Your version of GTK+ is old enough that this module is redundant.\n" - "This module will therefore not load."; + g_warning ("\n Your version of GTK+ is old enough that this module is redundant.\n" + " This module will therefore not load."); + return ""; } /* diff --git a/sgm-overlay-scrolling-override.c b/sgm-overlay-scrolling-override.c deleted file mode 100644 index 13116af..0000000 --- a/sgm-overlay-scrolling-override.c +++ /dev/null @@ -1,144 +0,0 @@ -#include <gtk/gtk.h> -#include <glib.h> - - -enum -{ - /* - * In GTK+ 3.24.9 and later, the "overlay-scrolling" property is assigned - * a property number of 85. We might as well follow that convention here - * and avoid any property number collisions. - */ - PROP_OVERLAY_SCROLLING = 85 -}; - - -static gboolean overlay_scrolling_enabled = TRUE; - -static GParamSpec * gtk_overlay_scrolling_pspec; - - -static void (*original_gtk_settings_set_property) (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static void (*original_gtk_settings_get_property) (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - - -static void overridden_gtk_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static void overridden_gtk_settings_get_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - - -G_MODULE_EXPORT const char * -g_module_check_init (GModule *module) -{ - /* - * Exit immediately on GTK+ versions prior to 3.15.0, since overlay - * scrolling hadn't been introduced yet! - */ - if (gtk_check_version (3,15,0) != NULL) - { - return "Your version of GTK+ is too old to support overlay scrolling.\n" - "This module is thus unnecessary and you should remove it."; - } - - /* - * Similarly, a property was introduced in GTK+ 3.24.9 to disable overlay - * scrolling globally, making this module redundant. - */ - else if (gtk_check_version (3,24,9) == NULL) - { - return "Your version of GTK+ already supports globally disabling overlay scrolling.\n" - "This module is thus redundant and you should remove it."; - } - - /* - * Otherwise, this module is useful for the current version of GTK+, so - * proceed with loading it. - */ - else - { - g_module_make_resident (module); - return NULL; - } -} - -G_MODULE_EXPORT int -gtk_module_init (gint * argc, char *** argv) -{ - GtkSettingsClass *gtk_settings_class; - GtkScrolledWindowClass *gtk_scrolled_window_class; - - (void) argc; - (void) argv; - - gtk_settings_class = g_type_class_ref (GTK_TYPE_SETTINGS); - - gtk_overlay_scrolling_pspec = g_param_spec_boolean ("gtk-overlay-scrolling", - "Overlay Scrolling", - "Whether to enable overlay scrolling mode globally", - overlay_scrolling_enabled, - G_PARAM_READWRITE); - - g_object_class_install_property (gtk_settings_class, - PROP_OVERLAY_SCROLLING, - gtk_overlay_scrolling_pspec); - - original_gtk_settings_set_property = G_OBJECT_CLASS (gtk_settings_class)->set_property; - G_OBJECT_CLASS (gtk_settings_class)->set_property = overridden_gtk_settings_class_set_property; - - original_gtk_settings_get_property = G_OBJECT_CLASS (gtk_settings_class)->get_property; - G_OBJECT_CLASS (gtk_settings_class)->get_property = overridden_gtk_settings_class_get_property; - - g_type_class_unref (gtk_settings_class); - - - - - return 0; -} - - -static void overridden_gtk_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_OVERLAY_SCROLLING: - overlay_scrolling_enabled = g_value_get_boolean (value); - break; - - default: - original_gtk_settings_set_property (object, property_id, value, pspec); - } -} - - -static void overridden_gtk_settings_get_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_OVERLAY_SCROLLING: - g_value_set_boolean (value, overlay_scrolling_enabled); - break; - - default: - original_gtk_settings_get_property (object, property_id, value, pspec); - } -} |