progress: fix the build for Gtk+ without X11

This commit is contained in:
Pierre Pronchery 2025-02-12 23:56:49 +01:00
parent 8dfd76956c
commit db30d6b002

View File

@ -43,7 +43,9 @@
#include <libintl.h> #include <libintl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
# if defined(GDK_WINDOWING_X11)
# include <gtk/gtkx.h> # include <gtk/gtkx.h>
# endif
#endif #endif
#include "../config.h" #include "../config.h"
#define _(string) gettext(string) #define _(string) gettext(string)
@ -193,12 +195,14 @@ static int _progress(Prefs * prefs, char * argv[])
g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK( g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK(
_progress_closex), p.window); _progress_closex), p.window);
} }
#if defined(GDK_WINDOWING_X11)
else else
{ {
p.window = gtk_plug_new(0); p.window = gtk_plug_new(0);
g_signal_connect_swapped(p.window, "embedded", G_CALLBACK( g_signal_connect_swapped(p.window, "embedded", G_CALLBACK(
_progress_embedded), &p); _progress_embedded), &p);
} }
#endif
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
@ -333,6 +337,7 @@ static int _progress(Prefs * prefs, char * argv[])
if((prefs->flags & PREFS_x) == 0) if((prefs->flags & PREFS_x) == 0)
/* show the window */ /* show the window */
gtk_widget_show(p.window); gtk_widget_show(p.window);
#if defined(GDK_WINDOWING_X11)
else else
{ {
/* print the window ID and force a flush */ /* print the window ID and force a flush */
@ -340,6 +345,7 @@ static int _progress(Prefs * prefs, char * argv[])
printf("%lu\n", id); printf("%lu\n", id);
fclose(stdout); fclose(stdout);
} }
#endif
gtk_main(); gtk_main();
close(p.fd); close(p.fd);
close(p.fds[1]); close(p.fds[1]);