[network-manager-applet/lr/gtk4: 143/143] build: allow building a GTK4 flavor of libnma



commit f635b49ed7c1c5b5fabb61395dc8771fca2f78f0
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Apr 30 19:25:36 2018 +0200

    build: allow building a GTK4 flavor of libnma
    
    This is EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL. GTK4 is not released yet
    and things will change in incompatible ways.
    
    A new library called "libnma-gtk4" is added. The non-libnma parts
    (applet, editor) are not ported.
    
    There are few reasons for merging this early and none of them is
    shipping the library to the users at this point:
    
    * To allow bringup of GTK4-enabled VPN plugins
    * Do not block GTK4 enablement of GNOME Control Center
    * Help avoid using features that will be difficult to port from GTK3
    
    All the test programs work, they emit a fair amount of warnings about
    properties that were removed in GTK4. To deal with those, we'd need to
    build different GResources for GTK3 and GTK4. The differencies seem
    small enough to the point the conversion could be automated. TODO,
    doesn't block testing.
    
    Tested to build with gtk+-4.0 = 3.94.0, but even the pkg-config name
    changed since in GTK4 git master. Did I say this is EXPERIMENTAL and
    there will be incompatible changes?

 .gitignore                    |   8 ++
 Makefile.am                   | 220 ++++++++++++++++++++++++++++++++++++++++++
 NEWS                          |   8 ++
 config.h.meson                |   3 +
 configure.ac                  |  25 +++++
 meson.build                   |  25 ++++-
 meson_options.txt             |   1 +
 src/libnma/libnma-gtk4.pc.in  |  11 +++
 src/libnma/meson.build        |  92 ++++++++++++------
 src/libnma/nma-cert-chooser.c |   2 +-
 src/libnma/nma-wifi-dialog.c  |   4 +
 src/libnma/tests/meson.build  |  69 +++++--------
 12 files changed, 392 insertions(+), 76 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 423955b1..6534dcb4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,16 +51,24 @@ src/connection-editor/nm-connection-editor-service-glue.h
 src/connection-editor/ce-resources.c
 src/connection-editor/ce-resources.h
 src/libnma/libnma.pc
+src/libnma/libnma-gtk4.pc
 src/libnma/NMA-1.0.gir
 src/libnma/NMA-1.0.typelib
+src/libnma/NMA4-1.0.gir
+src/libnma/NMA4-1.0.typelib
 src/libnma/nma-resources.c
 src/libnma/nma-resources.h
 src/libnma/nma-version.h
 src/libnma/tests/mobile-wizard
+src/libnma/tests/mobile-wizard-gtk4
 src/libnma/tests/run-vpn
+src/libnma/tests/run-vpn-gtk4
 src/libnma/tests/vpn-password-dialog
+src/libnma/tests/vpn-password-dialog-gtk4
 src/libnma/tests/wifi-dialog
+src/libnma/tests/wifi-dialog-gtk4
 src/libnma/tests/wifi-dialog-secrets
+src/libnma/tests/wifi-dialog-secrets-gtk4
 src/libnm-gtk/libnm-gtk.pc
 src/libnm-gtk/NMGtk-1.0.gir
 src/libnm-gtk/NMGtk-1.0.typelib
diff --git a/Makefile.am b/Makefile.am
index 5769b957..c5580f48 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -212,6 +212,26 @@ src_utils_libutils_libnm_glib_la_LIBADD = \
 
 endif
 
+if WITH_LIBNMA_GTK4
+
+noinst_LTLIBRARIES += src/utils/libutils-libnm-gtk4.la
+
+src_utils_libutils_libnm_gtk4_la_CPPFLAGS = \
+       "-I$(srcdir)/shared" \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS)
+
+src_utils_libutils_libnm_gtk4_la_SOURCES = \
+       $(shared_files) \
+       src/utils/utils.c \
+       src/utils/utils.h
+
+src_utils_libutils_libnm_gtk4_la_LIBADD = \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS)
+
+endif
+
 check_programs += src/utils/tests/test-utils
 
 src_utils_tests_test_utils_SOURCES = src/utils/tests/test-utils.c
@@ -332,6 +352,33 @@ $(src_wireless_security_libwireless_security_libnm_glib_la_OBJECTS): $(wireless_
 
 endif
 
+if WITH_LIBNMA_GTK4
+
+noinst_LTLIBRARIES += src/wireless-security/libwireless-security-libnm-gtk4.la
+
+src_wireless_security_libwireless_security_libnm_gtk4_la_SOURCES = \
+       $(wireless_security_c_real)
+
+nodist_src_wireless_security_libwireless_security_libnm_gtk4_la_SOURCES = \
+       $(wireless_security_c_gen)
+
+src_wireless_security_libwireless_security_libnm_gtk4_la_CPPFLAGS = \
+       "-I$(srcdir)/shared" \
+       "-I$(srcdir)/src/utils" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS)
+
+src_wireless_security_libwireless_security_libnm_gtk4_la_LIBADD = \
+       src/utils/libutils-libnm-gtk4.la \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS)
+
+$(src_wireless_security_libwireless_security_libnm_gtk4_la_OBJECTS): $(wireless_security_h_gen)
+
+endif
+
 EXTRA_DIST += \
        src/wireless-security/eap-method-fast.ui \
        src/wireless-security/eap-method-leap.ui \
@@ -696,9 +743,182 @@ src_libnma_tests_run_vpn_LDADD = \
        $(LIBNM_LIBS) \
        src/libnma/libnma.la
 
+if WITH_LIBNMA_GTK4
+
+lib_LTLIBRARIES += src/libnma/libnma-gtk4.la
+
+src_libnma_libnma_gtk4_la_SOURCES = \
+       $(libnma_h_priv_real) \
+       $(libnma_c_real)
+
+if WITH_GCR_GTK4
+src_libnma_libnma_gtk4_la_SOURCES += \
+       $(libnma_h_priv_gcr) \
+       $(libnma_c_gcr)
+endif
+
+nodist_src_libnma_libnma_gtk4_la_SOURCES = \
+       $(libnma_h_priv_gen) \
+       $(libnma_c_gen)
+
+src_libnma_libnma_gtk4_la_CFLAGS = \
+       -DICONDIR=\""$(datadir)/icons"\" \
+       -DBINDIR=\""$(bindir)"\" \
+       -DSYSCONFDIR=\""$(sysconfdir)"\" \
+       -DLIBEXECDIR=\""$(libexecdir)"\" \
+       -DDATADIR=\""$(datadir)"\" \
+       -DAUTOSTARTDIR=\""$(sysconfdir)/xdg/autostart"\" \
+       -DNMALOCALEDIR=\"$(datadir)/locale\" \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+       "-I$(srcdir)/shared" \
+       "-I$(srcdir)/src/utils" \
+       "-I$(srcdir)/src/wireless-security" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       $(GUDEV_CFLAGS) \
+       $(GCR_GCR4_CFLAGS)
+
+src_libnma_libnma_gtk4_la_LIBADD = \
+       src/wireless-security/libwireless-security-libnm-gtk4.la \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       $(GUDEV_LIBS) \
+       $(GCR_GCR4_LIBS)
+
+EXTRA_src_libnma_libnma_gtk4_la_DEPENDENCIES = src/libnma/libnma.ver
+
+src_libnma_libnma_gtk4_la_LDFLAGS = \
+       -Wl,-no-undefined \
+       -Wl,--version-script=$(srcdir)/src/libnma/libnma.ver
+
+
+pkgconfig_DATA += src/libnma/libnma-gtk4.pc
+
+if HAVE_INTROSPECTION
+src/libnma/NMA4-1.0.gir: src/libnma/libnma-gtk4.la
+src_libnma_NMA4_1_0_gir_INCLUDES = NM-1.0 Gtk-4.0
+src_libnma_NMA4_1_0_gir_EXPORT_PACKAGES = libnma-gtk4
+src_libnma_NMA4_1_0_gir_CFLAGS = $(src_libnma_libnma_gtk4_la_CFLAGS)
+src_libnma_NMA4_1_0_gir_LIBS = src/libnma/libnma-gtk4.la
+src_libnma_NMA4_1_0_gir_FILES = \
+       $(libnma_h_pub) \
+       $(libnma_c_real)
+if WITH_GCR_GTK4
+src_libnma_NMA4_1_0_gir_FILES += \
+       $(libnma_c_gcr)
+endif
+src_libnma_NMA4_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NMA --symbol-prefix=nma
+INTROSPECTION_GIRS += src/libnma/NMA4-1.0.gir
+endif
+
+check_PROGRAMS_norun += src/libnma/tests/mobile-wizard-gtk4
+
+src_libnma_tests_mobile_wizard_gtk4_SOURCES = \
+       src/libnma/tests/mobile-wizard.c
+
+src_libnma_tests_mobile_wizard_gtk4_CPPFLAGS = \
+       $(dflt_cppflags) \
+       $(GLIB_CFLAGS) \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       "-I$(srcdir)/shared/" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma
+
+src_libnma_tests_mobile_wizard_gtk4_LDADD = \
+       $(GLIB_LIBS) \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       src/libnma/libnma-gtk4.la
+
+check_PROGRAMS_norun += src/libnma/tests/vpn-password-dialog-gtk4
+
+src_libnma_tests_vpn_password_dialog_gtk4_SOURCES = \
+       src/libnma/tests/vpn-password-dialog.c
+
+src_libnma_tests_vpn_password_dialog_gtk4_CPPFLAGS = \
+       $(dflt_cppflags) \
+       $(GLIB_CFLAGS) \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       "-I$(srcdir)/shared/" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma
+
+src_libnma_tests_vpn_password_dialog_gtk4_LDADD = \
+       $(GLIB_LIBS) \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       src/libnma/libnma-gtk4.la
+
+check_PROGRAMS_norun += src/libnma/tests/wifi-dialog-gtk4
+
+src_libnma_tests_wifi_dialog_gtk4_SOURCES = \
+       src/libnma/tests/wifi-dialog.c
+
+src_libnma_tests_wifi_dialog_gtk4_CPPFLAGS = \
+       $(dflt_cppflags) \
+       $(GLIB_CFLAGS) \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       "-I$(srcdir)/shared/" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma
+
+src_libnma_tests_wifi_dialog_gtk4_LDADD = \
+       $(GLIB_LIBS) \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       src/libnma/libnma-gtk4.la
+
+check_PROGRAMS_norun += src/libnma/tests/wifi-dialog-secrets-gtk4
+
+src_libnma_tests_wifi_dialog_secrets_gtk4_SOURCES = \
+       src/libnma/tests/wifi-dialog-secrets.c
+
+src_libnma_tests_wifi_dialog_secrets_gtk4_CPPFLAGS = \
+       $(dflt_cppflags) \
+       $(GLIB_CFLAGS) \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       "-I$(srcdir)/shared/" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma
+
+src_libnma_tests_wifi_dialog_secrets_gtk4_LDADD = \
+       $(GLIB_LIBS) \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       src/libnma/libnma-gtk4.la
+
+check_PROGRAMS_norun += src/libnma/tests/run-vpn-gtk4
+
+src_libnma_tests_run_vpn_gtk4_SOURCES = \
+       src/libnma/tests/run-vpn.c
+
+src_libnma_tests_run_vpn_gtk4_CPPFLAGS = \
+       $(dflt_cppflags) \
+       $(GLIB_CFLAGS) \
+       $(GTK4_CFLAGS) \
+       $(LIBNM_CFLAGS) \
+       "-I$(srcdir)/shared/" \
+       "-I$(srcdir)/src/libnma" \
+       -Isrc/libnma
+
+src_libnma_tests_run_vpn_gtk4_LDADD = \
+       $(GLIB_LIBS) \
+       $(GTK4_LIBS) \
+       $(LIBNM_LIBS) \
+       src/libnma/libnma-gtk4.la
+
+endif
+
 EXTRA_DIST += \
        src/libnma/nma-version.h.in \
        src/libnma/libnma.pc.in \
+       src/libnma/libnma-gtk4.pc.in \
        src/libnma/libnma.ver \
        src/libnma/wifi.ui \
        src/libnma/nma-mobile-wizard.ui \
diff --git a/NEWS b/NEWS
index d7d1369a..dd8c1f22 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+=======================================================
+network-manager-applet-1.8.22
+Overview of changes since network-manager-applet-1.8.20
+=======================================================
+
+* Add EXPERIMENTAL libnma-gtk4 library for use with GTK4.
+  Not recommended for production use.
+
 =======================================================
 network-manager-applet-1.8.20
 Overview of changes since network-manager-applet-1.8.18
diff --git a/config.h.meson b/config.h.meson
index c3ca560e..41246fc0 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -50,6 +50,9 @@
 /* Define if Gcr is available */
 #mesondefine WITH_GCR
 
+/* Define if GTK4 Gcr is available */
+#mesondefine WITH_GCR_GTK4
+
 /* Define if Jansson is available */
 #mesondefine WITH_JANSSON
 
diff --git a/configure.ac b/configure.ac
index 42a49716..6dc4f340 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,20 @@ PKG_CHECK_MODULES(NOTIFY, [libnotify >= 0.4.3])
 PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.10)
 GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_10 
-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_10"
 
+AC_ARG_WITH(libnma-gtk4, AS_HELP_STRING([--with-libnma-gtk4], [build EXPERIMENTAL libnma-gtk4 library for 
use with GTK4]))
+if test "$with_libnma_gtk4" == yes; then
+       PKG_CHECK_MODULES(GTK4, gtk+-4.0 >= 3.94)
+       GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_94 
-DGTK_VERSION_MAX_ALLOWED=GTK_VERSION_3_94"
+else
+       with_libnma_gtk4=no
+fi
+AM_CONDITIONAL(WITH_LIBNMA_GTK4, test "$with_libnma_gtk4" != "no")
+
+# No such thing yet, just same lame duck placeholders.
+# it may actually end up being called differently.
+AC_DEFINE(WITH_GCR_GTK4, 0, [Define if GTK4 Gcr is available])
+AM_CONDITIONAL(WITH_GCR_GTK4, false)
+
 AC_ARG_WITH([appindicator],
             AS_HELP_STRING([--with-appindicator=no|yes|auto|ayatana|ubuntu], [Build with 
lib(ayatana-)appindicator support in addition to xembed systray support.]),
             [], [with_appindicator=no])
@@ -318,6 +332,15 @@ NM_COMPILER_WARNINGS(CFLAGS, [yes])
 NM_LTO
 NM_LD_GC
 
+# Disable extra compiler warning until GTK4 doesn't trigger it via graphene
+# https://github.com/ebassi/graphene/issues/134
+if test "$with_libnma_gtk4" == yes; then
+       _CFLAGS_SAVED="$CFLAGS"
+       CFLAGS="$CFLAGS $GTK4_CFLAGS"
+       NM_COMPILER_WARNING([_CFLAGS], [float-equal], [#include <gtk/gtk.h>])
+       CFLAGS="$_CFLAGS_SAVED $_CFLAGS"
+fi
+
 AC_ARG_WITH(more-asserts,
             AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (default: 0)]),
             [more_asserts=${with_more_asserts}],
@@ -336,6 +359,7 @@ AC_CONFIG_FILES([
 Makefile
 src/libnm-gtk/libnm-gtk.pc
 src/libnma/libnma.pc
+src/libnma/libnma-gtk4.pc
 po/Makefile.in
 man/nm-applet.1
 man/nm-connection-editor.1
@@ -346,6 +370,7 @@ AC_OUTPUT
 
 echo ""
 echo "  Build legacy library libnm-gtk: --with-libnm-gtk=${with_libnm_gtk}"
+echo "  Build EXPERIMENTAL libnma-gtk4 library for use with GTK4: --with-libnma-gtk4=${with_libnma_gtk4}"
 echo "  GCR: --with-gcr=$have_gcr"
 echo "  LTO: --enable-lto=$enable_lto"
 echo "  Linker garbage collection: --enable-ld-gc=$enable_ld_gc"
diff --git a/meson.build b/meson.build
index 6ce657c3..41056e6a 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,6 @@ nma_micro_version = version_array[2].to_int()
 nma_gir_version = '1.0'
 nma_gir_prefix = 'NMA'
 
-nma_gir_ns = 'NMA'
 nma_gtk_gir_ns = 'NMGtk'
 
 nma_prefix = get_option('prefix')
@@ -77,10 +76,21 @@ if enable_ld_gc
   common_ldflags += test_ldflags
 endif
 
+enable_libnma_gtk4 = get_option('libnma_gtk4')
+if enable_libnma_gtk4
+  gtk4_ext_dep = dependency('gtk+-4.0', version: '>= 3.94')
+  gtk4_dep = declare_dependency(
+    dependencies: gtk4_ext_dep,
+    compile_args: [
+      '-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_94',
+      '-DGTK_VERSION_MAX_ALLOWED=GTK_VERSION_3_94'
+    ]
+  )
+endif
+
 if nma_debug
   test_cflags = [
     '-Wdeclaration-after-statement',
-    '-Wfloat-equal',
     '-Wformat=2',
     '-Wimplicit-fallthrough',
     '-Winit-self',
@@ -100,6 +110,12 @@ if nma_debug
     '-Wvla',
   ]
 
+  # Disable extra compiler warning until GTK4 doesn't trigger it via graphene
+  # https://github.com/ebassi/graphene/issues/134
+  if not enable_libnma_gtk4 or cc.compiles('#include <gtk/gtk.h>', dependencies: gtk4_ext_dep, args: 
['-Werror=float-equal'])
+    test_cflags += '-Wfloat-equal'
+  endif
+
   common_flags += cc.get_supported_arguments(test_cflags)
 endif
 
@@ -206,6 +222,10 @@ if enable_libnm_gtk
   )
 endif
 
+# No such thing yet, just same lame duck placeholders.
+# it may actually end up being called differently.
+config_h.set10('WITH_GCR_GTK4', false)
+
 enable_appindicator = get_option('appindicator')
 if enable_appindicator == 'auto' or enable_appindicator == 'yes'
   appindicator_dep = dependency('ayatana-appindicator3-0.1', required: false)
@@ -504,6 +524,7 @@ meson.add_install_script(
 )
 
 output = '\n  Build legacy library libnm-gtk: ' + enable_libnm_gtk.to_string() + '\n'
+output += '  Build EXPERIMENTAL library libnm-gtk4 for use with GTK4: ' + enable_libnma_gtk4.to_string() + 
'\n'
 output += '  GCR: ' + enable_gcr.to_string() + '\n'
 output += '  LTO: ' + get_option('b_lto').to_string() + '\n'
 output += '  Linker garbage collection: ' + enable_ld_gc.to_string() + '\n'
diff --git a/meson_options.txt b/meson_options.txt
index 5a13c793..eadec332 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,5 @@
 option('libnm_gtk', type: 'boolean', value: false, description: 'build legacy library libnm-gtk which 
depends on libnm-glib/libnm-util/dbus-glib')
+option('libnma_gtk4', type: 'boolean', value: false, description: 'build EXPERIMENTAL library libnma-gtk4 
for use with GTK4')
 option('appindicator', type: 'string', value: 'no', description: 'Build with lib(ayatana-)appindicator 
support in addition to xembed systray support (no|yes|auto|ayatana|ubuntu). Default is "no", "yes" is an 
alias for "auto".')
 option('wwan', type: 'boolean', value: true, description: 'Enable WWAN support.')
 option('selinux', type: 'boolean', value: true, description: 'Enable support for adjusting SELinux labels in 
configuration editor.')
diff --git a/src/libnma/libnma-gtk4.pc.in b/src/libnma/libnma-gtk4.pc.in
new file mode 100644
index 00000000..a2cf2b49
--- /dev/null
+++ b/src/libnma/libnma-gtk4.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: libnma
+Description: NetworkManager UI utilities (gtk4 version)
+Version: @PACKAGE_VERSION@
+Requires: libnm
+Cflags: -I${includedir}/libnma
+Libs: -L${libdir} -lnma-gtk4
diff --git a/src/libnma/meson.build b/src/libnma/meson.build
index 879e1b84..d2ad90f3 100644
--- a/src/libnma/meson.build
+++ b/src/libnma/meson.build
@@ -1,5 +1,3 @@
-lib_name = 'libnma'
-
 cert_chooser_headers = files('nma-cert-chooser.h')
 
 cert_chooser_sources = files(
@@ -27,11 +25,9 @@ gir_headers = cert_chooser_headers + files(
   'nma-wifi-dialog.h'
 )
 
-headers = gir_headers + files('nma-cert-chooser-private.h')
-
 install_headers(
   gir_headers,
-  subdir: lib_name
+  subdir: 'libnma'
 )
 
 gir_sources = [version_header] + cert_chooser_sources + files(
@@ -52,7 +48,6 @@ incs = [
 ]
 
 deps = [
-  gtk_dep,
   gudev_dep,
   libnm_dep,
   libutils_libnm_dep,
@@ -71,29 +66,24 @@ cflags = [
 
 symbol_map = join_paths(meson.current_source_dir(), 'libnma.ver')
 
+nma_deps = [ deps, gtk_dep ]
+nma_sources = [ gir_sources, built_sources ]
 if enable_gcr
-  headers += files(
-    'nma-cert-chooser-button.h',
-    'nma-pkcs11-cert-chooser-dialog.h',
-    'nma-pkcs11-token-login-dialog.h'
-  )
-
-  gir_sources += files(
+  nma_sources += files(
     'nma-cert-chooser-button.c',
     'nma-pkcs11-cert-chooser.c',
     'nma-pkcs11-cert-chooser-dialog.c',
     'nma-pkcs11-token-login-dialog.c'
   )
-
-  deps += gcr_dep
+  nma_deps += gcr_dep
 endif
 
 libnma = shared_library(
   'nma',
-  sources: gir_sources + built_sources,
+  sources: nma_sources,
   version: libversion,
   include_directories: incs,
-  dependencies: deps,
+  dependencies: nma_deps,
   c_args: cflags,
   link_args: '-Wl,--version-script,' + symbol_map,
   link_depends: symbol_map,
@@ -107,26 +97,56 @@ libnma_dep = declare_dependency(
   include_directories: libnma_inc
 )
 
+if enable_libnma_gtk4
+  libnma_gtk4 = shared_library(
+    'nma-gtk4',
+    sources: gir_sources + built_sources,
+    version: libversion,
+    include_directories: incs,
+    dependencies: [ deps, gtk4_dep ],
+    c_args: cflags,
+    link_args: ldflags,
+    link_depends: symbol_map,
+    link_whole: libwireless_security_libnm,
+    install: true,
+    install_dir: nma_libdir
+  )
+
+  libnma_gtk4_dep = declare_dependency(
+    link_with: libnma_gtk4,
+    include_directories: libnma_inc
+  )
+endif
+
 subdir('tests')
 
 pkg.generate(
   libraries: libnma,
   version: nma_version,
-  name: lib_name,
+  name: 'libnma',
   description: 'NetworkManager UI utilities (libnm version)',
-  filebase: lib_name,
-  subdirs: lib_name,
+  filebase: 'libnma',
+  subdirs: 'libnma',
   requires: 'libnm',
   variables: 'exec_prefix=' + nma_prefix,
   install_dir: join_paths(nma_libdir, 'pkgconfig')
 )
 
-if enable_introspection
-  gir_incs = [
-    'Gtk-3.0',
-    'NM-1.0'
-  ]
+if enable_libnma_gtk4
+  pkg.generate(
+    libraries: libnma_gtk4,
+    version: nma_version,
+    name: 'libnma-gtk4',
+    description: 'NetworkManager UI utilities (gtk4 version)',
+    filebase: 'libnma-gtk4',
+    subdirs: 'libnma',
+    requires: 'libnm',
+    variables: 'exec_prefix=' + nma_prefix,
+    install_dir: join_paths(nma_libdir, 'pkgconfig')
+  )
+endif
 
+if enable_introspection
   gir_dir = join_paths(nma_datadir, 'gir-' + nma_gir_version)
   typelib_dir = join_paths(nma_libdir, 'girepository-' + nma_gir_version)
 
@@ -134,13 +154,29 @@ if enable_introspection
     libnma,
     sources: gir_sources + gir_headers,
     nsversion: nma_gir_version,
-    namespace: nma_gir_ns,
-    includes: gir_incs,
+    namespace: 'NMA',
+    includes: [ 'Gtk-3.0', 'NM-1.0' ],
     identifier_prefix: nma_gir_prefix,
     symbol_prefix: nma_gir_prefix.to_lower(),
-    export_packages: lib_name,
+    export_packages: 'libnma',
     install: true,
     install_dir_gir: gir_dir,
     install_dir_typelib: typelib_dir
   )
+
+  if enable_libnma_gtk4
+    gnome.generate_gir(
+      libnma,
+      sources: gir_sources + gir_headers,
+      nsversion: nma_gir_version,
+      namespace: 'NMA4',
+      includes: [ 'Gtk-4.0', 'NM-1.0' ],
+      identifier_prefix: nma_gir_prefix,
+      symbol_prefix: nma_gir_prefix.to_lower(),
+      export_packages: 'libnma',
+      install: true,
+      install_dir_gir: gir_dir,
+      install_dir_typelib: typelib_dir
+    )
+  endif
 endif
diff --git a/src/libnma/nma-cert-chooser.c b/src/libnma/nma-cert-chooser.c
index a20cd8fc..aea7551a 100644
--- a/src/libnma/nma-cert-chooser.c
+++ b/src/libnma/nma-cert-chooser.c
@@ -611,7 +611,7 @@ constructor (GType type, guint n_construct_properties, GObjectConstructParam *co
                        flags |= g_value_get_uint (construct_properties[i].value);
        }
        priv->vtable = &nma_cert_chooser_vtable_file;
-#if LIBNM_BUILD && WITH_GCR
+#if LIBNM_BUILD && (GTK_CHECK_VERSION(3,90,0) ? WITH_GCR_GTK4 : WITH_GCR)
        if ((flags & NMA_CERT_CHOOSER_FLAG_PEM) == 0)
                priv->vtable = &nma_cert_chooser_vtable_pkcs11;
 #endif
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
index a90b20d7..1b5e5f69 100644
--- a/src/libnma/nma-wifi-dialog.c
+++ b/src/libnma/nma-wifi-dialog.c
@@ -1097,7 +1097,11 @@ internal_init (NMAWifiDialog *self,
 
        gtk_window_set_icon_name (GTK_WINDOW (self), icon_name);
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image1"));
+#if GTK_CHECK_VERSION(3,90,0)
+       gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name);
+#else
        gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, GTK_ICON_SIZE_DIALOG);
+#endif
 
        gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);
 
diff --git a/src/libnma/tests/meson.build b/src/libnma/tests/meson.build
index 4ac1543f..ee303fcb 100644
--- a/src/libnma/tests/meson.build
+++ b/src/libnma/tests/meson.build
@@ -1,50 +1,29 @@
-deps = [
-  gtk_dep,
-  libnm_dep,
-  libnma_dep
-]
-
-executable(
+tests = [
   'mobile-wizard',
-  'mobile-wizard.c',
-  include_directories: incs,
-  dependencies: deps,
-  c_args: cflags,
-  install: false
-)
-
-executable(
   'run-vpn',
-  'run-vpn.c',
-  include_directories: incs,
-  dependencies: deps,
-  c_args: cflags,
-  install: false
-)
-
-executable(
   'vpn-password-dialog',
-  'vpn-password-dialog.c',
-  include_directories: incs,
-  dependencies: deps,
-  c_args: cflags,
-  install: false
-)
-
-executable(
   'wifi-dialog',
-  'wifi-dialog.c',
-  include_directories: incs,
-  dependencies: deps,
-  c_args: cflags,
-  install: false
-)
-
-executable(
   'wifi-dialog-secrets',
-  'wifi-dialog-secrets.c',
-  include_directories: incs,
-  dependencies: deps,
-  c_args: cflags,
-  install: false
-)
+]
+
+foreach tst : tests
+  executable(
+    tst,
+    tst + '.c',
+    include_directories: incs,
+    dependencies: [ gtk_dep, libnm_dep, libnma_dep ],
+    c_args: cflags,
+    install: false
+  )
+
+  if enable_libnma_gtk4
+    executable(
+      tst + '-gtk4',
+      tst + '.c',
+      include_directories: incs,
+      dependencies: [ gtk4_dep, libnm_dep, libnma_gtk4_dep ],
+      c_args: cflags,
+      install: false
+    )
+  endif
+endforeach


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]