[gtk/fix.nonunix.builds: 2/2] tests/: Revert bbb56d8 for non-UNIX
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix.nonunix.builds: 2/2] tests/: Revert bbb56d8 for non-UNIX
- Date: Mon, 16 Dec 2019 16:42:22 +0000 (UTC)
commit 3fd98a03806e89287e1f5c94fe52a0bfab770cc3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Dec 16 18:03:24 2019 +0800
tests/: Revert bbb56d8 for non-UNIX
The portal bits are only supported on *nix, so use the old code on
non-*nix.
tests/simple.c | 27 ++++++++++++++++++++++++---
tests/testclipboard2.c | 25 +++++++++++++++++++++++++
2 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/tests/simple.c b/tests/simple.c
index 39db8a41db..7cd8d52d68 100644
--- a/tests/simple.c
+++ b/tests/simple.c
@@ -19,6 +19,7 @@
#include <gtk/gtk.h>
+#ifdef G_OS_UNIX
void
copy (void)
{
@@ -68,10 +69,21 @@ clipboard_changed (GdkClipboard *clipboard)
g_print ("clipboard contents now: %s, local: %d\n", s, gdk_clipboard_is_local (clipboard));
}
+#else /* G_OS_UNIX */
+
+void
+hello (void)
+{
+ g_print ("hello world\n");
+}
+
+#endif /* !G_OS_UNIX */
+
int
main (int argc, char *argv[])
{
- GtkWidget *window, *button, *box;
+ GtkWidget *window, *box;
+ GtkWidget *button = NULL;
GdkClipboard *clipboard;
gtk_init ();
@@ -88,9 +100,10 @@ main (int argc, char *argv[])
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
button = gtk_button_new ();
+
+#ifdef G_OS_UNIX /* portal usage is supported on *nix only */
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_button_set_label (GTK_BUTTON (button), "copy");
g_signal_connect (button, "clicked", G_CALLBACK (copy), NULL);
gtk_container_add (GTK_CONTAINER (box), button);
@@ -105,6 +118,14 @@ main (int argc, char *argv[])
clipboard = gdk_display_get_clipboard (gdk_display_get_default ());
g_signal_connect (clipboard, "changed", G_CALLBACK (clipboard_changed), NULL);
+#else /* G_OS_UNIX -- original non-portal-enabled code */
+
+ gtk_button_set_label (GTK_BUTTON (button), "hello world");
+ g_signal_connect (button, "clicked", G_CALLBACK (hello), NULL);
+ gtk_container_add (GTK_CONTAINER (window), button);
+
+#endif /* !G_OS_UNIX */
+
gtk_widget_show (window);
gtk_main ();
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index f296cd5ac9..432cbfc4bf 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -103,6 +103,8 @@ visible_child_changed_cb (GtkWidget *stack,
}
}
+#ifdef G_OS_UNIX /* portal usage supported on *nix only */
+
static GSList *
get_file_list (const char *dir)
{
@@ -129,6 +131,29 @@ get_file_list (const char *dir)
return g_slist_reverse (list);
}
+#else /* G_OS_UNIX -- original non-portal-enabled code */
+
+static GList *
+get_file_list (const char *dir)
+{
+ GFileEnumerator *enumerator;
+ GFile *file;
+ GList *list = NULL;
+
+ file = g_file_new_for_path (dir);
+ enumerator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
+ g_object_unref (file);
+ if (enumerator == NULL)
+ return NULL;
+
+ while (g_file_enumerator_iterate (enumerator, NULL, &file, NULL, NULL) && file != NULL)
+ list = g_list_prepend (list, g_object_ref (file));
+
+ return g_list_reverse (list);
+}
+
+#endif /* !G_OS_UNIX */
+
static void
format_list_add_row (GtkWidget *list,
const char *format_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]