From a1a87b56a1be632b4687d38bbed2ea3942ebb97a Mon Sep 17 00:00:00 2001 From: "Lawrence R. Steeger" Date: Mon, 15 Jan 2024 12:18:38 -0600 Subject: [PATCH 1/2] Update icon-browser for multiple gtk versions gtk4.0 has removed gtkstock.h --- utilities/icon-browser | 75 ++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/utilities/icon-browser b/utilities/icon-browser index 40011a1..58f7234 100755 --- a/utilities/icon-browser +++ b/utilities/icon-browser @@ -1,35 +1,68 @@ #!/bin/bash -get_path_gtk_includes() +get_path_gtk_stock() { - path_gtk_h=$( locate gtk/gtk.h ) - path_gtk="${path_gtk_h%'gtk.h'}" - echo ${path_gtk} + # Notice: 'gtkstock.h' has been completely deprecated and no longer exists as of 'gtk-4.0' + # + local -a path_gtk_h=( $( locate gtk/gtk.h ) ) + for path in "${path_gtk_h[@]}"; do + path_gtk="${path_gtk_h[-1]%'gtk.h'}" + # Use the last gtk version that had gtkstock.h + # + if [[ -e "${path_gtk}gtkstock.h" ]]; then + echo $path_gtk'gtkstock.h' + break + elif [[ -e "${path_gtk}deprecated/gtkstock.h" ]]; then + echo $path_gtk'deprecated/gtkstock.h' + break + fi + unset -v 'path_gtk_h[-1]' + done + echo '' } get_duped_icons() { - path=$(get_path_gtk_includes) - slines=$( grep "#define GTK_STOCK" "${path}gtkstock.h" | grep -P -o '(?<=\")[^\"]+' - ) + slines=$( grep "#define GTK_STOCK" "${gtkStock}" | grep -P -o '(?<=\")[^\"]+' - ) sels=( ${slines} ) - for name in "${sels[@]}"; do + if [[ "${name}" != ')' ]]; then echo "$name $name " + fi done } -dups=$( get_duped_icons ) -dupels=( $dups ) - -yad \ - --title="GTK Icon Browser" \ - --text="\ -Many stock items may be missing. The -missing icons will match the dialog icon." \ - --center --borders=10 \ - --height=600 \ - --list \ - --column="Image":IMG \ - --column="Name":TXT \ - $dups +gtkStock=$(get_path_gtk_stock) + +if [[ -z $gtkStock ]]; then + dups=$( get_duped_icons ) + dupels=( $dups ) + + + yad \ + --title="GTK Icon Browser" \ + --text="\ + Many stock items may be missing. + + The missing icons will match the dialog icon. + + Using [$gtkStock] + " \ + --center --borders=10 \ + --height=600 \ + --list \ + --column="Image":IMG \ + --column="Name":TXT \ + $dups +else + yad \ + --title="GTK Icon Browser" \ + --text="\ +Notice: 'gtkstock.h' has been completely deprecated and no longer exists as of 'gtk-4.0' + " \ + --text-width=75 \ + --center --borders=10 \ + --height=40 \ + --button=yad-quit +fi From f5f6a70a0d67d6df0ed74d0e8db37c0ea442e7a5 Mon Sep 17 00:00:00 2001 From: "Lawrence R. Steeger" Date: Mon, 15 Jan 2024 16:30:14 -0600 Subject: [PATCH 2/2] Fix testing logic --- utilities/icon-browser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/icon-browser b/utilities/icon-browser index 58f7234..5c89917 100755 --- a/utilities/icon-browser +++ b/utilities/icon-browser @@ -34,7 +34,7 @@ get_duped_icons() gtkStock=$(get_path_gtk_stock) -if [[ -z $gtkStock ]]; then +if [[ -n $gtkStock ]]; then dups=$( get_duped_icons ) dupels=( $dups )