Subject: [PATCH v2] gnu: Add lxappearance-gtk3-wayland

From: [email-masked]
Date: Mon, 12 Dec 2022 20:58:56 +0000

From: florhizome <[email-masked]>

oops, forgot the patches!!
should I pick some better names?

* gnu/packages/patches/lxappearance-gtk3-01-only-do-x11-on-x11.patch: New file.
* gnu/packages/patches/lxappearance-gtk3-02-set-some-settings-gsettings.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add them here.
* gnu/packages/lxde.scm (lxappearance-gtk3-wayland): New variable.
---
 gnu/local.mk                                  |   2 +
 gnu/packages/lxde.scm                         |  29 +++
 ...ppearence-gtk3-01-only-do-x11-on-x11.patch |  41 ++++
 ...-gtk3-02-set-some-settings-gsettings.patch | 184 ++++++++++++++++++
 4 files changed, 256 insertions(+)
 create mode 100644 gnu/packages/patches/lxappearence-gtk3-01-only-do-x11-on-x11.patch
 create mode 100644 gnu/packages/patches/lxappearence-gtk3-02-set-some-settings-gsettings.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 86eb754352..9404e942eb 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1514,6 +1514,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/lua-5.4-liblua-so.patch			\
   %D%/packages/patches/luit-posix.patch				\
   %D%/packages/patches/lvm2-static-link.patch			\
+  %D%/packages/patches/lxappearance-gtk3-01-set-some-settings-gsettings.patch	\
+  %D%/packages/patches/lxappearance-gtk3-02-only-do-x11-on-x11.patch	\
   %D%/packages/patches/mailutils-variable-lookup.patch		\
   %D%/packages/patches/make-impure-dirs.patch			\
   %D%/packages/patches/mariadb-link-libatomic.patch		\
diff --git a/gnu/packages/lxde.scm b/gnu/packages/lxde.scm
index 0657db6eb8..bc0adc65eb 100644
--- a/gnu/packages/lxde.scm
+++ b/gnu/packages/lxde.scm
@@ -124,6 +124,35 @@ (define-public lxappearance
     (home-page "https://www.lxde.org/")
     (license license:gpl2+)))
 
+(define-public lxappearance-gtk3-wayland
+  (package
+    (inherit lxappearance)
+    (name "lxappearance-gtk3-wayland")
+    (version "0.6.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "mirror://sourceforge/lxde/"
+                       "LXAppearance/lxappearance-" version ".tar.xz"))
+       (sha256
+        (base32 "0f4bjaamfxxdr9civvy55pa6vv9dx1hjs522gjbbgx7yp1cdh8kj"))
+       (patches
+        (search-patches
+         ;;patches are created from github issues
+         "lxappearence-gtk3-01-only-do-x11-on-x11.patch"
+         "lxappearence-gtk3-02-set-some-settings-gsettings.patch"))))
+    (build-system gnu-build-system)
+    (inputs (list gtk+ dbus dbus-glib))
+    (arguments '(#:configure-flags '("--enable-gtk3=yes" "--enable-dbus=yes")))
+    (synopsis "LXDE GTK+ theme switcher")
+    (description "LXAppearance is a desktop-independent GTK+ theme switcher
+able to change themes, icons, and fonts used by GTK+ applications.
+This version is configured for supporting GTK+3 and dbus, and applies
+patches from LXDE's github to work on wayland as well.")
+    (home-page "https://lxde.github.io")
+    (license license:gpl2+)))
+
 (define-public lxrandr
   (package
     (name "lxrandr")
diff --git a/gnu/packages/patches/lxappearence-gtk3-01-only-do-x11-on-x11.patch b/gnu/packages/patches/lxappearence-gtk3-01-only-do-x11-on-x11.patch
new file mode 100644
index 0000000000..01e7e18fc3
--- /dev/null
+++ b/gnu/packages/patches/lxappearence-gtk3-01-only-do-x11-on-x11.patch
@@ -0,0 +1,41 @@
+From a066e5136692a909b62f29158c4a4b0f007e2b22 Mon Sep 17 00:00:00 2001
+From: wb9688 <[email-masked]>
+Date: Mon, 1 Mar 2021 16:40:34 +0100
+Subject: [PATCH] Only do X11-specific stuff on X11
+
+---
+ src/lxappearance.c | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/src/lxappearance.c b/src/lxappearance.c
+index f31e794..4bd438a 100644
+--- a/src/lxappearance.c
++++ b/src/lxappearance.c
+@@ -117,16 +117,20 @@ static gboolean check_lxde_dbus()
+ 
+ static void check_lxsession()
+ {
+-    lxsession_atom = XInternAtom( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_LXSESSION", True );
+-    if( lxsession_atom != None )
++    GdkDisplay *display = gdk_display_get_default();
++    if (GDK_IS_X11_DISPLAY(display))
+     {
+-        XGrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
+-        if( XGetSelectionOwner( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), lxsession_atom ) )
++        lxsession_atom = XInternAtom( GDK_DISPLAY_XDISPLAY(display), "_LXSESSION", True );
++        if( lxsession_atom != None )
+         {
+-            app.use_lxsession = TRUE;
+-            lxsession_name = g_getenv("DESKTOP_SESSION");
++            XGrabServer( GDK_DISPLAY_XDISPLAY(display) );
++            if( XGetSelectionOwner( GDK_DISPLAY_XDISPLAY(display), lxsession_atom ) )
++            {
++                app.use_lxsession = TRUE;
++                lxsession_name = g_getenv("DESKTOP_SESSION");
++            }
++            XUngrabServer( GDK_DISPLAY_XDISPLAY(display) );
+         }
+-        XUngrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
+     }
+ 
+     /* Check Lxsession also with dbus */
diff --git a/gnu/packages/patches/lxappearence-gtk3-02-set-some-settings-gsettings.patch b/gnu/packages/patches/lxappearence-gtk3-02-set-some-settings-gsettings.patch
new file mode 100644
index 0000000000..00996b9f28
--- /dev/null
+++ b/gnu/packages/patches/lxappearence-gtk3-02-set-some-settings-gsettings.patch
@@ -0,0 +1,184 @@
+From 35a6bd68317972b7bfccf546de04060e09dbab93 Mon Sep 17 00:00:00 2001
+From: wb9688 <[email-masked]>
+Date: Tue, 2 Mar 2021 14:00:48 +0100
+Subject: [PATCH 1/2] Set some settings in GSettings as well
+
+---
+ src/lxappearance.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 94 insertions(+)
+
+diff --git a/src/lxappearance.c b/src/lxappearance.c
+index f31e794..18ba471 100644
+--- a/src/lxappearance.c
++++ b/src/lxappearance.c
+@@ -462,6 +462,97 @@ static void lxappearance_save_gtkrc()
+     g_free(file_path);
+ }
+ 
++#if GLIB_CHECK_VERSION(2, 40, 0)
++static void lxappearance_save_gsettings()
++{
++    GSettingsSchemaSource *source = g_settings_schema_source_get_default();
++    if (!source)
++        return;
++
++    GSettingsSchema *schema = g_settings_schema_source_lookup(source, "org.gnome.desktop.interface", TRUE);
++    if (!schema)
++        return;
++
++    GSettings *settings = g_settings_new("org.gnome.desktop.interface");
++
++    if (app.widget_theme && g_settings_schema_has_key(schema, "gtk-theme"))
++        g_settings_set_string(settings, "gtk-theme", app.widget_theme);
++
++    if (app.icon_theme && g_settings_schema_has_key(schema, "icon-theme"))
++        g_settings_set_string(settings, "icon-theme", app.icon_theme);
++
++    if (app.default_font && g_settings_schema_has_key(schema, "font-name"))
++        g_settings_set_string(settings, "font-name", app.default_font);
++
++    if (app.cursor_theme && g_settings_schema_has_key(schema, "cursor-theme"))
++        g_settings_set_string(settings, "cursor-theme", app.cursor_theme);
++
++    if (g_settings_schema_has_key(schema, "cursor-size"))
++        g_settings_set_int(settings, "cursor-size", app.cursor_theme_size);
++
++    if (app.font_rgba && g_settings_schema_has_key(schema, "font-antialiasing") && g_settings_schema_has_key(schema, "font-rgba-order"))
++    {
++        if (!app.enable_antialising)
++            g_settings_set_string(settings, "font-antialiasing", "none");
++        else if (strcmp(app.font_rgba, "none") == 0)
++            g_settings_set_string(settings, "font-antialiasing", "grayscale");
++        else
++        {
++            g_settings_set_string(settings, "font-antialiasing", "rgba");
++            if (strcmp(app.font_rgba, "rgb") == 0)
++                g_settings_set_string(settings, "font-rgba-order", "rgb");
++            else if (strcmp(app.font_rgba, "bgr") == 0)
++                g_settings_set_string(settings, "font-rgba-order", "bgr");
++            else if (strcmp(app.font_rgba, "vrgb") == 0)
++                g_settings_set_string(settings, "font-rgba-order", "vrgb");
++            else if (strcmp(app.font_rgba, "vbgr") == 0)
++                g_settings_set_string(settings, "font-rgba-order", "vbgr");
++        }
++    }
++
++    if (app.hinting_style && g_settings_schema_has_key(schema, "font-hinting"))
++    {
++        if (!app.enable_hinting || strcmp(app.hinting_style, "hintnone") == 0)
++            g_settings_set_string(settings, "font-hinting", "none");
++        else if (strcmp(app.hinting_style, "hintslight") == 0)
++            g_settings_set_string(settings, "font-hinting", "slight");
++        else if (strcmp(app.hinting_style, "hintmedium") == 0)
++            g_settings_set_string(settings, "font-hinting", "medium");
++        else if (strcmp(app.hinting_style, "hintfull") == 0)
++            g_settings_set_string(settings, "font-hinting", "full");
++    }
++
++    if (g_settings_schema_has_key(schema, "menus-have-icons"))
++        g_settings_set_boolean(settings, "menus-have-icons", app.menu_images);
++
++    if (g_settings_schema_has_key(schema, "buttons-have-icons"))
++        g_settings_set_boolean(settings, "buttons-have-icons", app.button_images);
++
++    if (g_settings_schema_has_key(schema, "toolbar-style"))
++    {
++        if (app.toolbar_style == 0)
++            g_settings_set_string(settings, "toolbar-style", "icons");
++        else if (app.toolbar_style == 1)
++            g_settings_set_string(settings, "toolbar-style", "text");
++        else if (app.toolbar_style == 2)
++            g_settings_set_string(settings, "toolbar-style", "both");
++        else if (app.toolbar_style == 3)
++            g_settings_set_string(settings, "toolbar-style", "both-horiz");
++    }
++
++    if (g_settings_schema_has_key(schema, "toolbar-icons-size"))
++    {
++        if (app.toolbar_icon_size == 2)
++            g_settings_set_string(settings, "toolbar-icons-size", "small");
++        else if (app.toolbar_icon_size == 3)
++            g_settings_set_string(settings, "toolbar-icons-size", "large");
++    }
++
++    g_settings_schema_unref(schema);
++    g_object_unref(settings);
++}
++#endif
++
+ static void lxappearance_save_lxsession()
+ {
+     char* rel_path = g_strconcat("lxsession/", lxsession_name, "/desktop.conf", NULL);
+@@ -532,6 +623,9 @@ static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
+         if(app.use_lxsession)
+             lxappearance_save_lxsession();
+         lxappearance_save_gtkrc();
++#if GLIB_CHECK_VERSION(2, 40, 0)
++        lxappearance_save_gsettings();
++#endif
+ 
+         reload_all_programs();
+ 
+
+From 703accd389b9dc6e9f5ed4fc3ffc23aacf893bc1 Mon Sep 17 00:00:00 2001
+From: wb9688 <[email-masked]>
+Date: Tue, 16 Mar 2021 19:20:08 +0100
+Subject: [PATCH 2/2] Remove toolbar icon size options other than large and
+ small
+
+---
+ data/ui/lxappearance.glade | 12 ------------
+ src/other.c                |  4 ++--
+ 2 files changed, 2 insertions(+), 14 deletions(-)
+
+diff --git a/data/ui/lxappearance.glade b/data/ui/lxappearance.glade
+index 19554cc..892c46d 100644
+--- a/data/ui/lxappearance.glade
++++ b/data/ui/lxappearance.glade
+@@ -2125,24 +2125,12 @@
+       <column type="gchararray"/>
+     </columns>
+     <data>
+-      <row>
+-        <col id="0" translatable="yes">Same as menu items</col>
+-      </row>
+       <row>
+         <col id="0" translatable="yes">Small toolbar icon</col>
+       </row>
+       <row>
+         <col id="0" translatable="yes">Large toolbar icon</col>
+       </row>
+-      <row>
+-        <col id="0" translatable="yes">Same as buttons</col>
+-      </row>
+-      <row>
+-        <col id="0" translatable="yes">Same as drag icons</col>
+-      </row>
+-      <row>
+-        <col id="0" translatable="yes">Same as dialogs</col>
+-      </row>
+     </data>
+   </object>
+   <object class="GtkListStore" id="tb_style_store">
+diff --git a/src/other.c b/src/other.c
+index d79b28d..aaaeb41 100644
+--- a/src/other.c
++++ b/src/other.c
+@@ -30,7 +30,7 @@ static void on_tb_style_changed(GtkComboBox* combo, gpointer user_data)
+ 
+ static void on_tb_icon_size_changed(GtkComboBox* combo, gpointer user_data)
+ {
+-    app.toolbar_icon_size = gtk_combo_box_get_active(combo) + GTK_ICON_SIZE_MENU;
++    app.toolbar_icon_size = gtk_combo_box_get_active(combo) + GTK_ICON_SIZE_SMALL_TOOLBAR;
+     lxappearance_changed();
+ }
+ 
+@@ -72,7 +72,7 @@ void other_init(GtkBuilder* b)
+     g_signal_connect(app.tb_style_combo, "changed", G_CALLBACK(on_tb_style_changed), NULL);
+ 
+     app.tb_icon_size_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_icon_size"));
+-    idx = app.toolbar_icon_size - GTK_ICON_SIZE_MENU;
++    idx = app.toolbar_icon_size - GTK_ICON_SIZE_SMALL_TOOLBAR;
+     gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_icon_size_combo), idx);
+     g_signal_connect(app.tb_icon_size_combo, "changed", G_CALLBACK(on_tb_icon_size_changed), NULL);
+ 

base-commit: 0ce1f82e5aaac951b21d579eb46bf75cfe6713c0
prerequisite-patch-id: 36ae907c0ae2cbc001f774c0514ab217855270c2
prerequisite-patch-id: 2c99b804c1a929fc9d74b4c3d92263cbd296f785
prerequisite-patch-id: 2525aea715c2eb5be5f61e2e14296a36898413ca
prerequisite-patch-id: f7afbf36e2776eced1e69090ec127a40456efca4
prerequisite-patch-id: ba73cf06ab2610e36d03df1f6b6a1c4b8f271cda
prerequisite-patch-id: 9ac4b32603488e776af63831ff13406c649a8686
prerequisite-patch-id: 1cec3e6ed7a13938c53c24f816056d98b2b005c7
prerequisite-patch-id: 011ca6e0eaf4ea7077787d7030f193836c30aa82
prerequisite-patch-id: 4243cf3f6370445e6d583f03231e87921f541cc2
prerequisite-patch-id: 6c88bfec7b2fa53face9523329de4a9102149772
prerequisite-patch-id: d1bed6e8da46c3d6f4017546f7a00c001e814fe1
prerequisite-patch-id: 1ff1bcd9503a2b38ca7cc59ebdcebb45f970cf1a
prerequisite-patch-id: cb8f4f83e84db03ffa3c6be6c6b0df2ef0b59422
prerequisite-patch-id: 709b4522fd225f3c28bb2721e5dd9a20014ce131
prerequisite-patch-id: a02e8c00e53bf941c9049360c58959d2ebcf9608
prerequisite-patch-id: ba6a99be5ee43b2dd1cd45f73e9b04864187b1e4
prerequisite-patch-id: fc6e006241c41b19b4020981417823fd7a8cf931
-- 
2.38.1