xapp-gtk-window.c: only do an x11 check once, cache the result.
Michael Webster
6 years ago
68 | 68 | }; |
69 | 69 | |
70 | 70 | G_DEFINE_TYPE_WITH_PRIVATE (XAppGtkWindow, xapp_gtk_window, GTK_TYPE_WINDOW) |
71 | ||
72 | static gboolean | |
73 | is_x11_session (void) | |
74 | { | |
75 | static gboolean running_x11 = FALSE; | |
76 | static gsize once_init_value = 0; | |
77 | ||
78 | if (g_once_init_enter (&once_init_value)) | |
79 | { | |
80 | running_x11 = GDK_IS_X11_DISPLAY(gdk_display_get_default()); | |
81 | g_debug ("XAppGtkWindow: is_x11_session: %s\n", running_x11 ? "TRUE" : "FALSE"); | |
82 | ||
83 | g_once_init_leave (&once_init_value, 1); | |
84 | } | |
85 | ||
86 | return running_x11; | |
87 | } | |
71 | 88 | |
72 | 89 | static void |
73 | 90 | clear_icon_strings (XAppGtkWindowPrivate *priv) |
191 | 208 | XAppGtkWindowPrivate *priv, |
192 | 209 | const gchar *icon_name) |
193 | 210 | { |
194 | if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { | |
211 | if (!is_x11_session ()) { | |
195 | 212 | goto out; |
196 | 213 | } |
197 | 214 | |
228 | 245 | const gchar *file_name, |
229 | 246 | GError **error) |
230 | 247 | { |
231 | if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { | |
248 | if (!is_x11_session ()) { | |
232 | 249 | goto out; |
233 | 250 | } |
234 | 251 | |
263 | 280 | XAppGtkWindowPrivate *priv, |
264 | 281 | gint progress) |
265 | 282 | { |
266 | if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { | |
283 | if (!is_x11_session ()) { | |
267 | 284 | return; |
268 | 285 | } |
269 | 286 | |
302 | 319 | XAppGtkWindowPrivate *priv, |
303 | 320 | gboolean pulse) |
304 | 321 | { |
305 | if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { | |
322 | if (!is_x11_session ()) { | |
306 | 323 | return; |
307 | 324 | } |
308 | 325 |