forked from AuroraMiddleware/gtk
Merge branch 'fix.nonunix.builds' into 'master'
Fix non-portal (UNIX) builds See merge request GNOME/gtk!1252
This commit is contained in:
commit
0546fd7c8a
@ -24,6 +24,9 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
|
||||
#include <gio/gunixfdlist.h>
|
||||
|
||||
#ifndef O_PATH
|
||||
@ -353,3 +356,5 @@ file_transfer_portal_retrieve_files_finish (GAsyncResult *result,
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* G_OS_UNIX */
|
||||
|
@ -691,6 +691,7 @@ string_deserializer (GdkContentDeserializer *deserializer)
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
portal_finish (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@ -777,6 +778,7 @@ portal_file_deserializer (GdkContentDeserializer *deserializer)
|
||||
deserializer);
|
||||
g_object_unref (output);
|
||||
}
|
||||
#endif /* G_OS_UNIX */
|
||||
|
||||
static void
|
||||
file_uri_deserializer_finish (GObject *source,
|
||||
@ -852,7 +854,6 @@ init (void)
|
||||
static gboolean initialized = FALSE;
|
||||
GSList *formats, *f;
|
||||
const char *charset;
|
||||
gboolean has_portal;
|
||||
|
||||
if (initialized)
|
||||
return;
|
||||
@ -905,24 +906,31 @@ init (void)
|
||||
|
||||
g_slist_free (formats);
|
||||
|
||||
has_portal = file_transfer_portal_available ();
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean has_portal = file_transfer_portal_available ();
|
||||
if (has_portal)
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
GDK_TYPE_FILE_LIST,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_deserializer ("text/uri-list",
|
||||
GDK_TYPE_FILE_LIST,
|
||||
file_uri_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
if (has_portal)
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
G_TYPE_FILE,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_deserializer ("text/uri-list",
|
||||
G_TYPE_FILE,
|
||||
file_uri_deserializer,
|
||||
|
@ -702,6 +702,7 @@ file_serializer_finish (GObject *source,
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
portal_ready (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@ -758,6 +759,7 @@ portal_file_serializer (GdkContentSerializer *serializer)
|
||||
file_transfer_portal_register_files ((const char **)files->pdata, TRUE, portal_ready, serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, files, (GDestroyNotify)g_ptr_array_unref);
|
||||
}
|
||||
#endif /* G_OS_UNIX */
|
||||
|
||||
static void
|
||||
file_uri_serializer (GdkContentSerializer *serializer)
|
||||
@ -866,7 +868,6 @@ init (void)
|
||||
static gboolean initialized = FALSE;
|
||||
GSList *formats, *f;
|
||||
const char *charset;
|
||||
gboolean has_portal;
|
||||
|
||||
if (initialized)
|
||||
return;
|
||||
@ -922,7 +923,8 @@ init (void)
|
||||
|
||||
g_slist_free (formats);
|
||||
|
||||
has_portal = file_transfer_portal_available ();
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean has_portal = file_transfer_portal_available ();
|
||||
|
||||
if (has_portal)
|
||||
gdk_content_register_serializer (G_TYPE_FILE,
|
||||
@ -930,6 +932,8 @@ init (void)
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_serializer (G_TYPE_FILE,
|
||||
"text/uri-list",
|
||||
file_uri_serializer,
|
||||
@ -940,12 +944,16 @@ init (void)
|
||||
file_text_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
if (has_portal)
|
||||
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
|
||||
"application/vnd.portal.files",
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
|
||||
"text/uri-list",
|
||||
file_uri_serializer,
|
||||
|
@ -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 ();
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user