1 /*
2  * This file is generated by gdbus-codegen, do not modify it.
3  *
4  * The license of this code is the same as for the D-Bus interface description
5  * it was derived from. Note that it links to GLib, so must comply with the
6  * LGPL linking clauses.
7  */
8 
9 #ifdef HAVE_CONFIG_H
10 #  include "config.h"
11 #endif
12 
13 #include "xfdesktop-thunar-proxy.h"
14 
15 #include <string.h>
16 #ifdef G_OS_UNIX
17 #  include <gio/gunixfdlist.h>
18 #endif
19 
20 typedef struct
21 {
22   GDBusArgInfo parent_struct;
23   gboolean use_gvariant;
24 } _ExtendedGDBusArgInfo;
25 
26 typedef struct
27 {
28   GDBusMethodInfo parent_struct;
29   const gchar *signal_name;
30   gboolean pass_fdlist;
31 } _ExtendedGDBusMethodInfo;
32 
33 typedef struct
34 {
35   GDBusSignalInfo parent_struct;
36   const gchar *signal_name;
37 } _ExtendedGDBusSignalInfo;
38 
39 typedef struct
40 {
41   GDBusPropertyInfo parent_struct;
42   const gchar *hyphen_name;
43   guint use_gvariant : 1;
44   guint emits_changed_signal : 1;
45 } _ExtendedGDBusPropertyInfo;
46 
47 typedef struct
48 {
49   GDBusInterfaceInfo parent_struct;
50   const gchar *hyphen_name;
51 } _ExtendedGDBusInterfaceInfo;
52 
53 typedef struct
54 {
55   const _ExtendedGDBusPropertyInfo *info;
56   guint prop_id;
57   GValue orig_value; /* the value before the change */
58 } ChangedProperty;
59 
60 static void
_changed_property_free(ChangedProperty * data)61 _changed_property_free (ChangedProperty *data)
62 {
63   g_value_unset (&data->orig_value);
64   g_free (data);
65 }
66 
67 static gboolean
_g_strv_equal0(gchar ** a,gchar ** b)68 _g_strv_equal0 (gchar **a, gchar **b)
69 {
70   gboolean ret = FALSE;
71   guint n;
72   if (a == NULL && b == NULL)
73     {
74       ret = TRUE;
75       goto out;
76     }
77   if (a == NULL || b == NULL)
78     goto out;
79   if (g_strv_length (a) != g_strv_length (b))
80     goto out;
81   for (n = 0; a[n] != NULL; n++)
82     if (g_strcmp0 (a[n], b[n]) != 0)
83       goto out;
84   ret = TRUE;
85 out:
86   return ret;
87 }
88 
89 static gboolean
_g_variant_equal0(GVariant * a,GVariant * b)90 _g_variant_equal0 (GVariant *a, GVariant *b)
91 {
92   gboolean ret = FALSE;
93   if (a == NULL && b == NULL)
94     {
95       ret = TRUE;
96       goto out;
97     }
98   if (a == NULL || b == NULL)
99     goto out;
100   ret = g_variant_equal (a, b);
101 out:
102   return ret;
103 }
104 
105 G_GNUC_UNUSED static gboolean
_g_value_equal(const GValue * a,const GValue * b)106 _g_value_equal (const GValue *a, const GValue *b)
107 {
108   gboolean ret = FALSE;
109   g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
110   switch (G_VALUE_TYPE (a))
111     {
112       case G_TYPE_BOOLEAN:
113         ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
114         break;
115       case G_TYPE_UCHAR:
116         ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
117         break;
118       case G_TYPE_INT:
119         ret = (g_value_get_int (a) == g_value_get_int (b));
120         break;
121       case G_TYPE_UINT:
122         ret = (g_value_get_uint (a) == g_value_get_uint (b));
123         break;
124       case G_TYPE_INT64:
125         ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
126         break;
127       case G_TYPE_UINT64:
128         ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
129         break;
130       case G_TYPE_DOUBLE:
131         {
132           /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
133           gdouble da = g_value_get_double (a);
134           gdouble db = g_value_get_double (b);
135           ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
136         }
137         break;
138       case G_TYPE_STRING:
139         ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
140         break;
141       case G_TYPE_VARIANT:
142         ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
143         break;
144       default:
145         if (G_VALUE_TYPE (a) == G_TYPE_STRV)
146           ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
147         else
148           g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
149         break;
150     }
151   return ret;
152 }
153 
154 /* ------------------------------------------------------------------------
155  * Code for interface org.xfce.Thunar
156  * ------------------------------------------------------------------------
157  */
158 
159 /**
160  * SECTION:XfdesktopThunar
161  * @title: XfdesktopThunar
162  * @short_description: Generated C code for the org.xfce.Thunar D-Bus interface
163  *
164  * This section contains code for working with the <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link> D-Bus interface in C.
165  */
166 
167 /* ---- Introspection data for org.xfce.Thunar ---- */
168 
169 static const _ExtendedGDBusArgInfo _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_working_directory =
170 {
171   {
172     -1,
173     (gchar *) "working_directory",
174     (gchar *) "s",
175     NULL
176   },
177   FALSE
178 };
179 
180 static const _ExtendedGDBusArgInfo _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_filenames =
181 {
182   {
183     -1,
184     (gchar *) "filenames",
185     (gchar *) "as",
186     NULL
187   },
188   FALSE
189 };
190 
191 static const _ExtendedGDBusArgInfo _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_standalone =
192 {
193   {
194     -1,
195     (gchar *) "standalone",
196     (gchar *) "b",
197     NULL
198   },
199   FALSE
200 };
201 
202 static const _ExtendedGDBusArgInfo _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_display =
203 {
204   {
205     -1,
206     (gchar *) "display",
207     (gchar *) "s",
208     NULL
209   },
210   FALSE
211 };
212 
213 static const _ExtendedGDBusArgInfo _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_startup_id =
214 {
215   {
216     -1,
217     (gchar *) "startup_id",
218     (gchar *) "s",
219     NULL
220   },
221   FALSE
222 };
223 
224 static const GDBusArgInfo * const _xfdesktop_thunar_method_info_bulk_rename_IN_ARG_pointers[] =
225 {
226   &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_working_directory.parent_struct,
227   &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_filenames.parent_struct,
228   &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_standalone.parent_struct,
229   &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_display.parent_struct,
230   &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_startup_id.parent_struct,
231   NULL
232 };
233 
234 static const _ExtendedGDBusMethodInfo _xfdesktop_thunar_method_info_bulk_rename =
235 {
236   {
237     -1,
238     (gchar *) "BulkRename",
239     (GDBusArgInfo **) &_xfdesktop_thunar_method_info_bulk_rename_IN_ARG_pointers,
240     NULL,
241     NULL
242   },
243   "handle-bulk-rename",
244   FALSE
245 };
246 
247 static const _ExtendedGDBusMethodInfo _xfdesktop_thunar_method_info_terminate =
248 {
249   {
250     -1,
251     (gchar *) "Terminate",
252     NULL,
253     NULL,
254     NULL
255   },
256   "handle-terminate",
257   FALSE
258 };
259 
260 static const GDBusMethodInfo * const _xfdesktop_thunar_method_info_pointers[] =
261 {
262   &_xfdesktop_thunar_method_info_bulk_rename.parent_struct,
263   &_xfdesktop_thunar_method_info_terminate.parent_struct,
264   NULL
265 };
266 
267 static const GDBusAnnotationInfo _xfdesktop_thunar_annotation_info_0 =
268 {
269   -1,
270   (gchar *) "org.freedesktop.DBus.GLib.CSymbol",
271   (gchar *) "thunar_dbus_service",
272   NULL
273 };
274 
275 static const GDBusAnnotationInfo * const _xfdesktop_thunar_annotation_info_pointers[] =
276 {
277   &_xfdesktop_thunar_annotation_info_0,
278   NULL
279 };
280 
281 static const _ExtendedGDBusInterfaceInfo _xfdesktop_thunar_interface_info =
282 {
283   {
284     -1,
285     (gchar *) "org.xfce.Thunar",
286     (GDBusMethodInfo **) &_xfdesktop_thunar_method_info_pointers,
287     NULL,
288     NULL,
289     (GDBusAnnotationInfo **) &_xfdesktop_thunar_annotation_info_pointers
290   },
291   "thunar",
292 };
293 
294 
295 /**
296  * xfdesktop_thunar_interface_info:
297  *
298  * Gets a machine-readable description of the <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link> D-Bus interface.
299  *
300  * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
301  */
302 GDBusInterfaceInfo *
xfdesktop_thunar_interface_info(void)303 xfdesktop_thunar_interface_info (void)
304 {
305   return (GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct;
306 }
307 
308 /**
309  * xfdesktop_thunar_override_properties:
310  * @klass: The class structure for a #GObject derived class.
311  * @property_id_begin: The property id to assign to the first overridden property.
312  *
313  * Overrides all #GObject properties in the #XfdesktopThunar interface for a concrete class.
314  * The properties are overridden in the order they are defined.
315  *
316  * Returns: The last property id.
317  */
318 guint
xfdesktop_thunar_override_properties(GObjectClass * klass,guint property_id_begin)319 xfdesktop_thunar_override_properties (GObjectClass *klass, guint property_id_begin)
320 {
321   return property_id_begin - 1;
322 }
323 
324 
325 
326 /**
327  * XfdesktopThunar:
328  *
329  * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link>.
330  */
331 
332 /**
333  * XfdesktopThunarIface:
334  * @parent_iface: The parent interface.
335  * @handle_bulk_rename: Handler for the #XfdesktopThunar::handle-bulk-rename signal.
336  * @handle_terminate: Handler for the #XfdesktopThunar::handle-terminate signal.
337  *
338  * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link>.
339  */
340 
341 typedef XfdesktopThunarIface XfdesktopThunarInterface;
G_DEFINE_INTERFACE(XfdesktopThunar,xfdesktop_thunar,G_TYPE_OBJECT)342 G_DEFINE_INTERFACE (XfdesktopThunar, xfdesktop_thunar, G_TYPE_OBJECT)
343 
344 static void
345 xfdesktop_thunar_default_init (XfdesktopThunarIface *iface)
346 {
347   /* GObject signals for incoming D-Bus method calls: */
348   /**
349    * XfdesktopThunar::handle-bulk-rename:
350    * @object: A #XfdesktopThunar.
351    * @invocation: A #GDBusMethodInvocation.
352    * @arg_working_directory: Argument passed by remote caller.
353    * @arg_filenames: Argument passed by remote caller.
354    * @arg_standalone: Argument passed by remote caller.
355    * @arg_display: Argument passed by remote caller.
356    * @arg_startup_id: Argument passed by remote caller.
357    *
358    * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Thunar.BulkRename">BulkRename()</link> D-Bus method.
359    *
360    * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call xfdesktop_thunar_complete_bulk_rename() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
361    *
362    * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
363    */
364   g_signal_new ("handle-bulk-rename",
365     G_TYPE_FROM_INTERFACE (iface),
366     G_SIGNAL_RUN_LAST,
367     G_STRUCT_OFFSET (XfdesktopThunarIface, handle_bulk_rename),
368     g_signal_accumulator_true_handled,
369     NULL,
370     g_cclosure_marshal_generic,
371     G_TYPE_BOOLEAN,
372     6,
373     G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRV, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
374 
375   /**
376    * XfdesktopThunar::handle-terminate:
377    * @object: A #XfdesktopThunar.
378    * @invocation: A #GDBusMethodInvocation.
379    *
380    * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Thunar.Terminate">Terminate()</link> D-Bus method.
381    *
382    * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call xfdesktop_thunar_complete_terminate() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
383    *
384    * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
385    */
386   g_signal_new ("handle-terminate",
387     G_TYPE_FROM_INTERFACE (iface),
388     G_SIGNAL_RUN_LAST,
389     G_STRUCT_OFFSET (XfdesktopThunarIface, handle_terminate),
390     g_signal_accumulator_true_handled,
391     NULL,
392     g_cclosure_marshal_generic,
393     G_TYPE_BOOLEAN,
394     1,
395     G_TYPE_DBUS_METHOD_INVOCATION);
396 
397 }
398 
399 /**
400  * xfdesktop_thunar_call_bulk_rename:
401  * @proxy: A #XfdesktopThunarProxy.
402  * @arg_working_directory: Argument to pass with the method invocation.
403  * @arg_filenames: Argument to pass with the method invocation.
404  * @arg_standalone: Argument to pass with the method invocation.
405  * @arg_display: Argument to pass with the method invocation.
406  * @arg_startup_id: Argument to pass with the method invocation.
407  * @cancellable: (nullable): A #GCancellable or %NULL.
408  * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
409  * @user_data: User data to pass to @callback.
410  *
411  * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Thunar.BulkRename">BulkRename()</link> D-Bus method on @proxy.
412  * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
413  * You can then call xfdesktop_thunar_call_bulk_rename_finish() to get the result of the operation.
414  *
415  * See xfdesktop_thunar_call_bulk_rename_sync() for the synchronous, blocking version of this method.
416  */
417 void
xfdesktop_thunar_call_bulk_rename(XfdesktopThunar * proxy,const gchar * arg_working_directory,const gchar * const * arg_filenames,gboolean arg_standalone,const gchar * arg_display,const gchar * arg_startup_id,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)418 xfdesktop_thunar_call_bulk_rename (
419     XfdesktopThunar *proxy,
420     const gchar *arg_working_directory,
421     const gchar *const *arg_filenames,
422     gboolean arg_standalone,
423     const gchar *arg_display,
424     const gchar *arg_startup_id,
425     GCancellable *cancellable,
426     GAsyncReadyCallback callback,
427     gpointer user_data)
428 {
429   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
430     "BulkRename",
431     g_variant_new ("(s^asbss)",
432                    arg_working_directory,
433                    arg_filenames,
434                    arg_standalone,
435                    arg_display,
436                    arg_startup_id),
437     G_DBUS_CALL_FLAGS_NONE,
438     -1,
439     cancellable,
440     callback,
441     user_data);
442 }
443 
444 /**
445  * xfdesktop_thunar_call_bulk_rename_finish:
446  * @proxy: A #XfdesktopThunarProxy.
447  * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfdesktop_thunar_call_bulk_rename().
448  * @error: Return location for error or %NULL.
449  *
450  * Finishes an operation started with xfdesktop_thunar_call_bulk_rename().
451  *
452  * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
453  */
454 gboolean
xfdesktop_thunar_call_bulk_rename_finish(XfdesktopThunar * proxy,GAsyncResult * res,GError ** error)455 xfdesktop_thunar_call_bulk_rename_finish (
456     XfdesktopThunar *proxy,
457     GAsyncResult *res,
458     GError **error)
459 {
460   GVariant *_ret;
461   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
462   if (_ret == NULL)
463     goto _out;
464   g_variant_get (_ret,
465                  "()");
466   g_variant_unref (_ret);
467 _out:
468   return _ret != NULL;
469 }
470 
471 /**
472  * xfdesktop_thunar_call_bulk_rename_sync:
473  * @proxy: A #XfdesktopThunarProxy.
474  * @arg_working_directory: Argument to pass with the method invocation.
475  * @arg_filenames: Argument to pass with the method invocation.
476  * @arg_standalone: Argument to pass with the method invocation.
477  * @arg_display: Argument to pass with the method invocation.
478  * @arg_startup_id: Argument to pass with the method invocation.
479  * @cancellable: (nullable): A #GCancellable or %NULL.
480  * @error: Return location for error or %NULL.
481  *
482  * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Thunar.BulkRename">BulkRename()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
483  *
484  * See xfdesktop_thunar_call_bulk_rename() for the asynchronous version of this method.
485  *
486  * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
487  */
488 gboolean
xfdesktop_thunar_call_bulk_rename_sync(XfdesktopThunar * proxy,const gchar * arg_working_directory,const gchar * const * arg_filenames,gboolean arg_standalone,const gchar * arg_display,const gchar * arg_startup_id,GCancellable * cancellable,GError ** error)489 xfdesktop_thunar_call_bulk_rename_sync (
490     XfdesktopThunar *proxy,
491     const gchar *arg_working_directory,
492     const gchar *const *arg_filenames,
493     gboolean arg_standalone,
494     const gchar *arg_display,
495     const gchar *arg_startup_id,
496     GCancellable *cancellable,
497     GError **error)
498 {
499   GVariant *_ret;
500   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
501     "BulkRename",
502     g_variant_new ("(s^asbss)",
503                    arg_working_directory,
504                    arg_filenames,
505                    arg_standalone,
506                    arg_display,
507                    arg_startup_id),
508     G_DBUS_CALL_FLAGS_NONE,
509     -1,
510     cancellable,
511     error);
512   if (_ret == NULL)
513     goto _out;
514   g_variant_get (_ret,
515                  "()");
516   g_variant_unref (_ret);
517 _out:
518   return _ret != NULL;
519 }
520 
521 /**
522  * xfdesktop_thunar_call_terminate:
523  * @proxy: A #XfdesktopThunarProxy.
524  * @cancellable: (nullable): A #GCancellable or %NULL.
525  * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
526  * @user_data: User data to pass to @callback.
527  *
528  * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Thunar.Terminate">Terminate()</link> D-Bus method on @proxy.
529  * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
530  * You can then call xfdesktop_thunar_call_terminate_finish() to get the result of the operation.
531  *
532  * See xfdesktop_thunar_call_terminate_sync() for the synchronous, blocking version of this method.
533  */
534 void
xfdesktop_thunar_call_terminate(XfdesktopThunar * proxy,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)535 xfdesktop_thunar_call_terminate (
536     XfdesktopThunar *proxy,
537     GCancellable *cancellable,
538     GAsyncReadyCallback callback,
539     gpointer user_data)
540 {
541   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
542     "Terminate",
543     g_variant_new ("()"),
544     G_DBUS_CALL_FLAGS_NONE,
545     -1,
546     cancellable,
547     callback,
548     user_data);
549 }
550 
551 /**
552  * xfdesktop_thunar_call_terminate_finish:
553  * @proxy: A #XfdesktopThunarProxy.
554  * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfdesktop_thunar_call_terminate().
555  * @error: Return location for error or %NULL.
556  *
557  * Finishes an operation started with xfdesktop_thunar_call_terminate().
558  *
559  * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
560  */
561 gboolean
xfdesktop_thunar_call_terminate_finish(XfdesktopThunar * proxy,GAsyncResult * res,GError ** error)562 xfdesktop_thunar_call_terminate_finish (
563     XfdesktopThunar *proxy,
564     GAsyncResult *res,
565     GError **error)
566 {
567   GVariant *_ret;
568   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
569   if (_ret == NULL)
570     goto _out;
571   g_variant_get (_ret,
572                  "()");
573   g_variant_unref (_ret);
574 _out:
575   return _ret != NULL;
576 }
577 
578 /**
579  * xfdesktop_thunar_call_terminate_sync:
580  * @proxy: A #XfdesktopThunarProxy.
581  * @cancellable: (nullable): A #GCancellable or %NULL.
582  * @error: Return location for error or %NULL.
583  *
584  * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Thunar.Terminate">Terminate()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
585  *
586  * See xfdesktop_thunar_call_terminate() for the asynchronous version of this method.
587  *
588  * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
589  */
590 gboolean
xfdesktop_thunar_call_terminate_sync(XfdesktopThunar * proxy,GCancellable * cancellable,GError ** error)591 xfdesktop_thunar_call_terminate_sync (
592     XfdesktopThunar *proxy,
593     GCancellable *cancellable,
594     GError **error)
595 {
596   GVariant *_ret;
597   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
598     "Terminate",
599     g_variant_new ("()"),
600     G_DBUS_CALL_FLAGS_NONE,
601     -1,
602     cancellable,
603     error);
604   if (_ret == NULL)
605     goto _out;
606   g_variant_get (_ret,
607                  "()");
608   g_variant_unref (_ret);
609 _out:
610   return _ret != NULL;
611 }
612 
613 /**
614  * xfdesktop_thunar_complete_bulk_rename:
615  * @object: A #XfdesktopThunar.
616  * @invocation: (transfer full): A #GDBusMethodInvocation.
617  *
618  * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Thunar.BulkRename">BulkRename()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
619  *
620  * This method will free @invocation, you cannot use it afterwards.
621  */
622 void
xfdesktop_thunar_complete_bulk_rename(XfdesktopThunar * object,GDBusMethodInvocation * invocation)623 xfdesktop_thunar_complete_bulk_rename (
624     XfdesktopThunar *object,
625     GDBusMethodInvocation *invocation)
626 {
627   g_dbus_method_invocation_return_value (invocation,
628     g_variant_new ("()"));
629 }
630 
631 /**
632  * xfdesktop_thunar_complete_terminate:
633  * @object: A #XfdesktopThunar.
634  * @invocation: (transfer full): A #GDBusMethodInvocation.
635  *
636  * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Thunar.Terminate">Terminate()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
637  *
638  * This method will free @invocation, you cannot use it afterwards.
639  */
640 void
xfdesktop_thunar_complete_terminate(XfdesktopThunar * object,GDBusMethodInvocation * invocation)641 xfdesktop_thunar_complete_terminate (
642     XfdesktopThunar *object,
643     GDBusMethodInvocation *invocation)
644 {
645   g_dbus_method_invocation_return_value (invocation,
646     g_variant_new ("()"));
647 }
648 
649 /* ------------------------------------------------------------------------ */
650 
651 /**
652  * XfdesktopThunarProxy:
653  *
654  * The #XfdesktopThunarProxy structure contains only private data and should only be accessed using the provided API.
655  */
656 
657 /**
658  * XfdesktopThunarProxyClass:
659  * @parent_class: The parent class.
660  *
661  * Class structure for #XfdesktopThunarProxy.
662  */
663 
664 struct _XfdesktopThunarProxyPrivate
665 {
666   GData *qdata;
667 };
668 
669 static void xfdesktop_thunar_proxy_iface_init (XfdesktopThunarIface *iface);
670 
671 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
G_DEFINE_TYPE_WITH_CODE(XfdesktopThunarProxy,xfdesktop_thunar_proxy,G_TYPE_DBUS_PROXY,G_ADD_PRIVATE (XfdesktopThunarProxy)G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR,xfdesktop_thunar_proxy_iface_init))672 G_DEFINE_TYPE_WITH_CODE (XfdesktopThunarProxy, xfdesktop_thunar_proxy, G_TYPE_DBUS_PROXY,
673                          G_ADD_PRIVATE (XfdesktopThunarProxy)
674                          G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR, xfdesktop_thunar_proxy_iface_init))
675 
676 #else
677 G_DEFINE_TYPE_WITH_CODE (XfdesktopThunarProxy, xfdesktop_thunar_proxy, G_TYPE_DBUS_PROXY,
678                          G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR, xfdesktop_thunar_proxy_iface_init))
679 
680 #endif
681 static void
682 xfdesktop_thunar_proxy_finalize (GObject *object)
683 {
684   XfdesktopThunarProxy *proxy = XFDESKTOP_THUNAR_PROXY (object);
685   g_datalist_clear (&proxy->priv->qdata);
686   G_OBJECT_CLASS (xfdesktop_thunar_proxy_parent_class)->finalize (object);
687 }
688 
689 static void
xfdesktop_thunar_proxy_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec G_GNUC_UNUSED)690 xfdesktop_thunar_proxy_get_property (GObject      *object,
691   guint         prop_id,
692   GValue       *value,
693   GParamSpec   *pspec G_GNUC_UNUSED)
694 {
695 }
696 
697 static void
xfdesktop_thunar_proxy_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec G_GNUC_UNUSED)698 xfdesktop_thunar_proxy_set_property (GObject      *object,
699   guint         prop_id,
700   const GValue *value,
701   GParamSpec   *pspec G_GNUC_UNUSED)
702 {
703 }
704 
705 static void
xfdesktop_thunar_proxy_g_signal(GDBusProxy * proxy,const gchar * sender_name G_GNUC_UNUSED,const gchar * signal_name,GVariant * parameters)706 xfdesktop_thunar_proxy_g_signal (GDBusProxy *proxy,
707   const gchar *sender_name G_GNUC_UNUSED,
708   const gchar *signal_name,
709   GVariant *parameters)
710 {
711   _ExtendedGDBusSignalInfo *info;
712   GVariantIter iter;
713   GVariant *child;
714   GValue *paramv;
715   gsize num_params;
716   gsize n;
717   guint signal_id;
718   info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct, signal_name);
719   if (info == NULL)
720     return;
721   num_params = g_variant_n_children (parameters);
722   paramv = g_new0 (GValue, num_params + 1);
723   g_value_init (&paramv[0], XFDESKTOP_TYPE_THUNAR);
724   g_value_set_object (&paramv[0], proxy);
725   g_variant_iter_init (&iter, parameters);
726   n = 1;
727   while ((child = g_variant_iter_next_value (&iter)) != NULL)
728     {
729       _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
730       if (arg_info->use_gvariant)
731         {
732           g_value_init (&paramv[n], G_TYPE_VARIANT);
733           g_value_set_variant (&paramv[n], child);
734           n++;
735         }
736       else
737         g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
738       g_variant_unref (child);
739     }
740   signal_id = g_signal_lookup (info->signal_name, XFDESKTOP_TYPE_THUNAR);
741   g_signal_emitv (paramv, signal_id, 0, NULL);
742   for (n = 0; n < num_params + 1; n++)
743     g_value_unset (&paramv[n]);
744   g_free (paramv);
745 }
746 
747 static void
xfdesktop_thunar_proxy_g_properties_changed(GDBusProxy * _proxy,GVariant * changed_properties,const gchar * const * invalidated_properties)748 xfdesktop_thunar_proxy_g_properties_changed (GDBusProxy *_proxy,
749   GVariant *changed_properties,
750   const gchar *const *invalidated_properties)
751 {
752   XfdesktopThunarProxy *proxy = XFDESKTOP_THUNAR_PROXY (_proxy);
753   guint n;
754   const gchar *key;
755   GVariantIter *iter;
756   _ExtendedGDBusPropertyInfo *info;
757   g_variant_get (changed_properties, "a{sv}", &iter);
758   while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
759     {
760       info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct, key);
761       g_datalist_remove_data (&proxy->priv->qdata, key);
762       if (info != NULL)
763         g_object_notify (G_OBJECT (proxy), info->hyphen_name);
764     }
765   g_variant_iter_free (iter);
766   for (n = 0; invalidated_properties[n] != NULL; n++)
767     {
768       info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct, invalidated_properties[n]);
769       g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
770       if (info != NULL)
771         g_object_notify (G_OBJECT (proxy), info->hyphen_name);
772     }
773 }
774 
775 static void
xfdesktop_thunar_proxy_init(XfdesktopThunarProxy * proxy)776 xfdesktop_thunar_proxy_init (XfdesktopThunarProxy *proxy)
777 {
778 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
779   proxy->priv = xfdesktop_thunar_proxy_get_instance_private (proxy);
780 #else
781   proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, XFDESKTOP_TYPE_THUNAR_PROXY, XfdesktopThunarProxyPrivate);
782 #endif
783 
784   g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), xfdesktop_thunar_interface_info ());
785 }
786 
787 static void
xfdesktop_thunar_proxy_class_init(XfdesktopThunarProxyClass * klass)788 xfdesktop_thunar_proxy_class_init (XfdesktopThunarProxyClass *klass)
789 {
790   GObjectClass *gobject_class;
791   GDBusProxyClass *proxy_class;
792 
793   gobject_class = G_OBJECT_CLASS (klass);
794   gobject_class->finalize     = xfdesktop_thunar_proxy_finalize;
795   gobject_class->get_property = xfdesktop_thunar_proxy_get_property;
796   gobject_class->set_property = xfdesktop_thunar_proxy_set_property;
797 
798   proxy_class = G_DBUS_PROXY_CLASS (klass);
799   proxy_class->g_signal = xfdesktop_thunar_proxy_g_signal;
800   proxy_class->g_properties_changed = xfdesktop_thunar_proxy_g_properties_changed;
801 
802 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
803   g_type_class_add_private (klass, sizeof (XfdesktopThunarProxyPrivate));
804 #endif
805 }
806 
807 static void
xfdesktop_thunar_proxy_iface_init(XfdesktopThunarIface * iface)808 xfdesktop_thunar_proxy_iface_init (XfdesktopThunarIface *iface)
809 {
810 }
811 
812 /**
813  * xfdesktop_thunar_proxy_new:
814  * @connection: A #GDBusConnection.
815  * @flags: Flags from the #GDBusProxyFlags enumeration.
816  * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
817  * @object_path: An object path.
818  * @cancellable: (nullable): A #GCancellable or %NULL.
819  * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
820  * @user_data: User data to pass to @callback.
821  *
822  * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link>. See g_dbus_proxy_new() for more details.
823  *
824  * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
825  * You can then call xfdesktop_thunar_proxy_new_finish() to get the result of the operation.
826  *
827  * See xfdesktop_thunar_proxy_new_sync() for the synchronous, blocking version of this constructor.
828  */
829 void
xfdesktop_thunar_proxy_new(GDBusConnection * connection,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)830 xfdesktop_thunar_proxy_new (
831     GDBusConnection     *connection,
832     GDBusProxyFlags      flags,
833     const gchar         *name,
834     const gchar         *object_path,
835     GCancellable        *cancellable,
836     GAsyncReadyCallback  callback,
837     gpointer             user_data)
838 {
839   g_async_initable_new_async (XFDESKTOP_TYPE_THUNAR_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.xfce.Thunar", NULL);
840 }
841 
842 /**
843  * xfdesktop_thunar_proxy_new_finish:
844  * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfdesktop_thunar_proxy_new().
845  * @error: Return location for error or %NULL
846  *
847  * Finishes an operation started with xfdesktop_thunar_proxy_new().
848  *
849  * Returns: (transfer full) (type XfdesktopThunarProxy): The constructed proxy object or %NULL if @error is set.
850  */
851 XfdesktopThunar *
xfdesktop_thunar_proxy_new_finish(GAsyncResult * res,GError ** error)852 xfdesktop_thunar_proxy_new_finish (
853     GAsyncResult        *res,
854     GError             **error)
855 {
856   GObject *ret;
857   GObject *source_object;
858   source_object = g_async_result_get_source_object (res);
859   ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
860   g_object_unref (source_object);
861   if (ret != NULL)
862     return XFDESKTOP_THUNAR (ret);
863   else
864     return NULL;
865 }
866 
867 /**
868  * xfdesktop_thunar_proxy_new_sync:
869  * @connection: A #GDBusConnection.
870  * @flags: Flags from the #GDBusProxyFlags enumeration.
871  * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
872  * @object_path: An object path.
873  * @cancellable: (nullable): A #GCancellable or %NULL.
874  * @error: Return location for error or %NULL
875  *
876  * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link>. See g_dbus_proxy_new_sync() for more details.
877  *
878  * The calling thread is blocked until a reply is received.
879  *
880  * See xfdesktop_thunar_proxy_new() for the asynchronous version of this constructor.
881  *
882  * Returns: (transfer full) (type XfdesktopThunarProxy): The constructed proxy object or %NULL if @error is set.
883  */
884 XfdesktopThunar *
xfdesktop_thunar_proxy_new_sync(GDBusConnection * connection,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GError ** error)885 xfdesktop_thunar_proxy_new_sync (
886     GDBusConnection     *connection,
887     GDBusProxyFlags      flags,
888     const gchar         *name,
889     const gchar         *object_path,
890     GCancellable        *cancellable,
891     GError             **error)
892 {
893   GInitable *ret;
894   ret = g_initable_new (XFDESKTOP_TYPE_THUNAR_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.xfce.Thunar", NULL);
895   if (ret != NULL)
896     return XFDESKTOP_THUNAR (ret);
897   else
898     return NULL;
899 }
900 
901 
902 /**
903  * xfdesktop_thunar_proxy_new_for_bus:
904  * @bus_type: A #GBusType.
905  * @flags: Flags from the #GDBusProxyFlags enumeration.
906  * @name: A bus name (well-known or unique).
907  * @object_path: An object path.
908  * @cancellable: (nullable): A #GCancellable or %NULL.
909  * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
910  * @user_data: User data to pass to @callback.
911  *
912  * Like xfdesktop_thunar_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
913  *
914  * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
915  * You can then call xfdesktop_thunar_proxy_new_for_bus_finish() to get the result of the operation.
916  *
917  * See xfdesktop_thunar_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
918  */
919 void
xfdesktop_thunar_proxy_new_for_bus(GBusType bus_type,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)920 xfdesktop_thunar_proxy_new_for_bus (
921     GBusType             bus_type,
922     GDBusProxyFlags      flags,
923     const gchar         *name,
924     const gchar         *object_path,
925     GCancellable        *cancellable,
926     GAsyncReadyCallback  callback,
927     gpointer             user_data)
928 {
929   g_async_initable_new_async (XFDESKTOP_TYPE_THUNAR_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.xfce.Thunar", NULL);
930 }
931 
932 /**
933  * xfdesktop_thunar_proxy_new_for_bus_finish:
934  * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfdesktop_thunar_proxy_new_for_bus().
935  * @error: Return location for error or %NULL
936  *
937  * Finishes an operation started with xfdesktop_thunar_proxy_new_for_bus().
938  *
939  * Returns: (transfer full) (type XfdesktopThunarProxy): The constructed proxy object or %NULL if @error is set.
940  */
941 XfdesktopThunar *
xfdesktop_thunar_proxy_new_for_bus_finish(GAsyncResult * res,GError ** error)942 xfdesktop_thunar_proxy_new_for_bus_finish (
943     GAsyncResult        *res,
944     GError             **error)
945 {
946   GObject *ret;
947   GObject *source_object;
948   source_object = g_async_result_get_source_object (res);
949   ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
950   g_object_unref (source_object);
951   if (ret != NULL)
952     return XFDESKTOP_THUNAR (ret);
953   else
954     return NULL;
955 }
956 
957 /**
958  * xfdesktop_thunar_proxy_new_for_bus_sync:
959  * @bus_type: A #GBusType.
960  * @flags: Flags from the #GDBusProxyFlags enumeration.
961  * @name: A bus name (well-known or unique).
962  * @object_path: An object path.
963  * @cancellable: (nullable): A #GCancellable or %NULL.
964  * @error: Return location for error or %NULL
965  *
966  * Like xfdesktop_thunar_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
967  *
968  * The calling thread is blocked until a reply is received.
969  *
970  * See xfdesktop_thunar_proxy_new_for_bus() for the asynchronous version of this constructor.
971  *
972  * Returns: (transfer full) (type XfdesktopThunarProxy): The constructed proxy object or %NULL if @error is set.
973  */
974 XfdesktopThunar *
xfdesktop_thunar_proxy_new_for_bus_sync(GBusType bus_type,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GError ** error)975 xfdesktop_thunar_proxy_new_for_bus_sync (
976     GBusType             bus_type,
977     GDBusProxyFlags      flags,
978     const gchar         *name,
979     const gchar         *object_path,
980     GCancellable        *cancellable,
981     GError             **error)
982 {
983   GInitable *ret;
984   ret = g_initable_new (XFDESKTOP_TYPE_THUNAR_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.xfce.Thunar", NULL);
985   if (ret != NULL)
986     return XFDESKTOP_THUNAR (ret);
987   else
988     return NULL;
989 }
990 
991 
992 /* ------------------------------------------------------------------------ */
993 
994 /**
995  * XfdesktopThunarSkeleton:
996  *
997  * The #XfdesktopThunarSkeleton structure contains only private data and should only be accessed using the provided API.
998  */
999 
1000 /**
1001  * XfdesktopThunarSkeletonClass:
1002  * @parent_class: The parent class.
1003  *
1004  * Class structure for #XfdesktopThunarSkeleton.
1005  */
1006 
1007 struct _XfdesktopThunarSkeletonPrivate
1008 {
1009   GValue *properties;
1010   GList *changed_properties;
1011   GSource *changed_properties_idle_source;
1012   GMainContext *context;
1013   GMutex lock;
1014 };
1015 
1016 static void
_xfdesktop_thunar_skeleton_handle_method_call(GDBusConnection * connection G_GNUC_UNUSED,const gchar * sender G_GNUC_UNUSED,const gchar * object_path G_GNUC_UNUSED,const gchar * interface_name,const gchar * method_name,GVariant * parameters,GDBusMethodInvocation * invocation,gpointer user_data)1017 _xfdesktop_thunar_skeleton_handle_method_call (
1018   GDBusConnection *connection G_GNUC_UNUSED,
1019   const gchar *sender G_GNUC_UNUSED,
1020   const gchar *object_path G_GNUC_UNUSED,
1021   const gchar *interface_name,
1022   const gchar *method_name,
1023   GVariant *parameters,
1024   GDBusMethodInvocation *invocation,
1025   gpointer user_data)
1026 {
1027   XfdesktopThunarSkeleton *skeleton = XFDESKTOP_THUNAR_SKELETON (user_data);
1028   _ExtendedGDBusMethodInfo *info;
1029   GVariantIter iter;
1030   GVariant *child;
1031   GValue *paramv;
1032   gsize num_params;
1033   guint num_extra;
1034   gsize n;
1035   guint signal_id;
1036   GValue return_value = G_VALUE_INIT;
1037   info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
1038   g_assert (info != NULL);
1039   num_params = g_variant_n_children (parameters);
1040   num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
1041   n = 0;
1042   g_value_init (&paramv[n], XFDESKTOP_TYPE_THUNAR);
1043   g_value_set_object (&paramv[n++], skeleton);
1044   g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
1045   g_value_set_object (&paramv[n++], invocation);
1046   if (info->pass_fdlist)
1047     {
1048 #ifdef G_OS_UNIX
1049       g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
1050       g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
1051 #else
1052       g_assert_not_reached ();
1053 #endif
1054     }
1055   g_variant_iter_init (&iter, parameters);
1056   while ((child = g_variant_iter_next_value (&iter)) != NULL)
1057     {
1058       _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
1059       if (arg_info->use_gvariant)
1060         {
1061           g_value_init (&paramv[n], G_TYPE_VARIANT);
1062           g_value_set_variant (&paramv[n], child);
1063           n++;
1064         }
1065       else
1066         g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
1067       g_variant_unref (child);
1068     }
1069   signal_id = g_signal_lookup (info->signal_name, XFDESKTOP_TYPE_THUNAR);
1070   g_value_init (&return_value, G_TYPE_BOOLEAN);
1071   g_signal_emitv (paramv, signal_id, 0, &return_value);
1072   if (!g_value_get_boolean (&return_value))
1073     g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
1074   g_value_unset (&return_value);
1075   for (n = 0; n < num_params + num_extra; n++)
1076     g_value_unset (&paramv[n]);
1077   g_free (paramv);
1078 }
1079 
1080 static GVariant *
_xfdesktop_thunar_skeleton_handle_get_property(GDBusConnection * connection G_GNUC_UNUSED,const gchar * sender G_GNUC_UNUSED,const gchar * object_path G_GNUC_UNUSED,const gchar * interface_name G_GNUC_UNUSED,const gchar * property_name,GError ** error,gpointer user_data)1081 _xfdesktop_thunar_skeleton_handle_get_property (
1082   GDBusConnection *connection G_GNUC_UNUSED,
1083   const gchar *sender G_GNUC_UNUSED,
1084   const gchar *object_path G_GNUC_UNUSED,
1085   const gchar *interface_name G_GNUC_UNUSED,
1086   const gchar *property_name,
1087   GError **error,
1088   gpointer user_data)
1089 {
1090   XfdesktopThunarSkeleton *skeleton = XFDESKTOP_THUNAR_SKELETON (user_data);
1091   GValue value = G_VALUE_INIT;
1092   GParamSpec *pspec;
1093   _ExtendedGDBusPropertyInfo *info;
1094   GVariant *ret;
1095   ret = NULL;
1096   info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct, property_name);
1097   g_assert (info != NULL);
1098   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1099   if (pspec == NULL)
1100     {
1101       g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1102     }
1103   else
1104     {
1105       g_value_init (&value, pspec->value_type);
1106       g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1107       ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
1108       g_value_unset (&value);
1109     }
1110   return ret;
1111 }
1112 
1113 static gboolean
_xfdesktop_thunar_skeleton_handle_set_property(GDBusConnection * connection G_GNUC_UNUSED,const gchar * sender G_GNUC_UNUSED,const gchar * object_path G_GNUC_UNUSED,const gchar * interface_name G_GNUC_UNUSED,const gchar * property_name,GVariant * variant,GError ** error,gpointer user_data)1114 _xfdesktop_thunar_skeleton_handle_set_property (
1115   GDBusConnection *connection G_GNUC_UNUSED,
1116   const gchar *sender G_GNUC_UNUSED,
1117   const gchar *object_path G_GNUC_UNUSED,
1118   const gchar *interface_name G_GNUC_UNUSED,
1119   const gchar *property_name,
1120   GVariant *variant,
1121   GError **error,
1122   gpointer user_data)
1123 {
1124   XfdesktopThunarSkeleton *skeleton = XFDESKTOP_THUNAR_SKELETON (user_data);
1125   GValue value = G_VALUE_INIT;
1126   GParamSpec *pspec;
1127   _ExtendedGDBusPropertyInfo *info;
1128   gboolean ret;
1129   ret = FALSE;
1130   info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfdesktop_thunar_interface_info.parent_struct, property_name);
1131   g_assert (info != NULL);
1132   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1133   if (pspec == NULL)
1134     {
1135       g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1136     }
1137   else
1138     {
1139       if (info->use_gvariant)
1140         g_value_set_variant (&value, variant);
1141       else
1142         g_dbus_gvariant_to_gvalue (variant, &value);
1143       g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1144       g_value_unset (&value);
1145       ret = TRUE;
1146     }
1147   return ret;
1148 }
1149 
1150 static const GDBusInterfaceVTable _xfdesktop_thunar_skeleton_vtable =
1151 {
1152   _xfdesktop_thunar_skeleton_handle_method_call,
1153   _xfdesktop_thunar_skeleton_handle_get_property,
1154   _xfdesktop_thunar_skeleton_handle_set_property,
1155   {NULL}
1156 };
1157 
1158 static GDBusInterfaceInfo *
xfdesktop_thunar_skeleton_dbus_interface_get_info(GDBusInterfaceSkeleton * skeleton G_GNUC_UNUSED)1159 xfdesktop_thunar_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1160 {
1161   return xfdesktop_thunar_interface_info ();
1162 }
1163 
1164 static GDBusInterfaceVTable *
xfdesktop_thunar_skeleton_dbus_interface_get_vtable(GDBusInterfaceSkeleton * skeleton G_GNUC_UNUSED)1165 xfdesktop_thunar_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1166 {
1167   return (GDBusInterfaceVTable *) &_xfdesktop_thunar_skeleton_vtable;
1168 }
1169 
1170 static GVariant *
xfdesktop_thunar_skeleton_dbus_interface_get_properties(GDBusInterfaceSkeleton * _skeleton)1171 xfdesktop_thunar_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
1172 {
1173   XfdesktopThunarSkeleton *skeleton = XFDESKTOP_THUNAR_SKELETON (_skeleton);
1174 
1175   GVariantBuilder builder;
1176   guint n;
1177   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1178   if (_xfdesktop_thunar_interface_info.parent_struct.properties == NULL)
1179     goto out;
1180   for (n = 0; _xfdesktop_thunar_interface_info.parent_struct.properties[n] != NULL; n++)
1181     {
1182       GDBusPropertyInfo *info = _xfdesktop_thunar_interface_info.parent_struct.properties[n];
1183       if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
1184         {
1185           GVariant *value;
1186           value = _xfdesktop_thunar_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.xfce.Thunar", info->name, NULL, skeleton);
1187           if (value != NULL)
1188             {
1189               g_variant_take_ref (value);
1190               g_variant_builder_add (&builder, "{sv}", info->name, value);
1191               g_variant_unref (value);
1192             }
1193         }
1194     }
1195 out:
1196   return g_variant_builder_end (&builder);
1197 }
1198 
1199 static void
xfdesktop_thunar_skeleton_dbus_interface_flush(GDBusInterfaceSkeleton * _skeleton)1200 xfdesktop_thunar_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
1201 {
1202 }
1203 
1204 static void xfdesktop_thunar_skeleton_iface_init (XfdesktopThunarIface *iface);
1205 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
G_DEFINE_TYPE_WITH_CODE(XfdesktopThunarSkeleton,xfdesktop_thunar_skeleton,G_TYPE_DBUS_INTERFACE_SKELETON,G_ADD_PRIVATE (XfdesktopThunarSkeleton)G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR,xfdesktop_thunar_skeleton_iface_init))1206 G_DEFINE_TYPE_WITH_CODE (XfdesktopThunarSkeleton, xfdesktop_thunar_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1207                          G_ADD_PRIVATE (XfdesktopThunarSkeleton)
1208                          G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR, xfdesktop_thunar_skeleton_iface_init))
1209 
1210 #else
1211 G_DEFINE_TYPE_WITH_CODE (XfdesktopThunarSkeleton, xfdesktop_thunar_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1212                          G_IMPLEMENT_INTERFACE (XFDESKTOP_TYPE_THUNAR, xfdesktop_thunar_skeleton_iface_init))
1213 
1214 #endif
1215 static void
1216 xfdesktop_thunar_skeleton_finalize (GObject *object)
1217 {
1218   XfdesktopThunarSkeleton *skeleton = XFDESKTOP_THUNAR_SKELETON (object);
1219   g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1220   if (skeleton->priv->changed_properties_idle_source != NULL)
1221     g_source_destroy (skeleton->priv->changed_properties_idle_source);
1222   g_main_context_unref (skeleton->priv->context);
1223   g_mutex_clear (&skeleton->priv->lock);
1224   G_OBJECT_CLASS (xfdesktop_thunar_skeleton_parent_class)->finalize (object);
1225 }
1226 
1227 static void
xfdesktop_thunar_skeleton_init(XfdesktopThunarSkeleton * skeleton)1228 xfdesktop_thunar_skeleton_init (XfdesktopThunarSkeleton *skeleton)
1229 {
1230 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1231   skeleton->priv = xfdesktop_thunar_skeleton_get_instance_private (skeleton);
1232 #else
1233   skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, XFDESKTOP_TYPE_THUNAR_SKELETON, XfdesktopThunarSkeletonPrivate);
1234 #endif
1235 
1236   g_mutex_init (&skeleton->priv->lock);
1237   skeleton->priv->context = g_main_context_ref_thread_default ();
1238 }
1239 
1240 static void
xfdesktop_thunar_skeleton_class_init(XfdesktopThunarSkeletonClass * klass)1241 xfdesktop_thunar_skeleton_class_init (XfdesktopThunarSkeletonClass *klass)
1242 {
1243   GObjectClass *gobject_class;
1244   GDBusInterfaceSkeletonClass *skeleton_class;
1245 
1246   gobject_class = G_OBJECT_CLASS (klass);
1247   gobject_class->finalize = xfdesktop_thunar_skeleton_finalize;
1248 
1249   skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
1250   skeleton_class->get_info = xfdesktop_thunar_skeleton_dbus_interface_get_info;
1251   skeleton_class->get_properties = xfdesktop_thunar_skeleton_dbus_interface_get_properties;
1252   skeleton_class->flush = xfdesktop_thunar_skeleton_dbus_interface_flush;
1253   skeleton_class->get_vtable = xfdesktop_thunar_skeleton_dbus_interface_get_vtable;
1254 
1255 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1256   g_type_class_add_private (klass, sizeof (XfdesktopThunarSkeletonPrivate));
1257 #endif
1258 }
1259 
1260 static void
xfdesktop_thunar_skeleton_iface_init(XfdesktopThunarIface * iface)1261 xfdesktop_thunar_skeleton_iface_init (XfdesktopThunarIface *iface)
1262 {
1263 }
1264 
1265 /**
1266  * xfdesktop_thunar_skeleton_new:
1267  *
1268  * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Thunar.top_of_page">org.xfce.Thunar</link>.
1269  *
1270  * Returns: (transfer full) (type XfdesktopThunarSkeleton): The skeleton object.
1271  */
1272 XfdesktopThunar *
xfdesktop_thunar_skeleton_new(void)1273 xfdesktop_thunar_skeleton_new (void)
1274 {
1275   return XFDESKTOP_THUNAR (g_object_new (XFDESKTOP_TYPE_THUNAR_SKELETON, NULL));
1276 }
1277 
1278