[libnma/lr/gtk-4.0: 1/23] private: add more Gtk3/Gtk4 compatibility wrappers




commit 640dbd38a605d12b1ce8de05ecc987c3405c797c
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Oct 7 10:57:56 2021 +0200

    private: add more Gtk3/Gtk4 compatibility wrappers
    
    This allows code written to utilize Gtk4 to work with Gtk3 reasonably well.

 src/nma-private.h    | 22 ++++++++++++++++++----
 src/tests/bar-code.c |  6 +-----
 2 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/nma-private.h b/src/nma-private.h
index 6a6f25b6..f58e1112 100644
--- a/src/nma-private.h
+++ b/src/nma-private.h
@@ -3,15 +3,29 @@
  *
  * Lubomir Rintel <lkundrak v3 sk>
  *
- * Copyright (C) 2019 Red Hat, Inc.
+ * Copyright (C) 2019 - 2021 Red Hat, Inc.
  */
 
 #ifndef NMA_PRIVATE_H
 
 #if !GTK_CHECK_VERSION(3,96,0)
-#define gtk_editable_set_text(editable,text)             gtk_entry_set_text(GTK_ENTRY(editable), (text))
-#define gtk_editable_get_text(editable)                  gtk_entry_get_text(GTK_ENTRY(editable))
-#define gtk_editable_set_width_chars(editable, n_chars)  gtk_entry_set_width_chars(GTK_ENTRY(editable), 
(n_chars))
+#define gtk_editable_set_text(editable,text)           gtk_entry_set_text(GTK_ENTRY(editable), (text))
+#define gtk_editable_get_text(editable)                        gtk_entry_get_text(GTK_ENTRY(editable))
+#define gtk_editable_set_width_chars(editable, n_chars)        
gtk_entry_set_width_chars(GTK_ENTRY(editable), (n_chars))
+#define gtk_box_append(box, widget)                    gtk_container_add(GTK_CONTAINER(box), (widget))
+#define gtk_box_remove(box, widget)                    gtk_container_remove(GTK_CONTAINER(box), (widget))
+#define gtk_window_destroy(window)                     gtk_widget_destroy(GTK_WIDGET (window))
+#define gtk_check_button_get_active(button)            
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))
+#define gtk_check_button_set_active(button, active)    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active)
+#define gtk_window_set_child(window, child)            gtk_container_add(GTK_CONTAINER (window), child)
+#define gtk_image_new_from_icon_name(name)             gtk_image_new_from_icon_name((name), 
GTK_ICON_SIZE_BUTTON)
+#define gtk_button_set_child(button, widget)           gtk_container_add(GTK_CONTAINER(button), (widget))
+#define gtk_init()                                     gtk_init(&argc, &argv)
+#define gtk_window_new()                               gtk_window_new(GTK_WINDOW_TOPLEVEL)
+#define gtk_widget_get_root(widget)                    gtk_widget_get_toplevel(widget)
+#define gtk_window_set_hide_on_close(window, hide)     g_signal_connect(dialog, "delete-event", G_CALLBACK 
(gtk_widget_hide_on_delete), NULL)
+
+typedef void GtkRoot;
 #endif
 
 
diff --git a/src/tests/bar-code.c b/src/tests/bar-code.c
index f85a0cfa..8eb6fabe 100644
--- a/src/tests/bar-code.c
+++ b/src/tests/bar-code.c
@@ -106,13 +106,9 @@ main (int argc, char *argv[])
        nm_connection_add_setting (connection,
                                   nm_setting_wireless_new ());
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
-       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       w = gtk_window_new ();
        gtk_widget_show (w);
        gtk_window_set_default_size (GTK_WINDOW (w), 800, 680);
        g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);


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