2570
2596
application->priv->busy_count--;
2572
2598
if (application->priv->busy_count == 0)
2573
g_application_impl_set_busy_state (application->priv->impl, FALSE);
2600
g_application_impl_set_busy_state (application->priv->impl, FALSE);
2601
g_object_notify (G_OBJECT (application), "is-busy");
2606
* g_application_get_is_busy:
2607
* @application: a #GApplication
2609
* Gets the application's current busy state, as set through
2610
* g_application_mark_busy() or g_application_bind_busy_property().
2612
* Returns: %TRUE if @application is currenty marked as busy
2617
g_application_get_is_busy (GApplication *application)
2619
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
2621
return application->priv->busy_count > 0;
2576
2624
/* Notifications {{{1 */
2711
2759
* g_application_bind_busy_property:
2712
2760
* @application: a #GApplication
2713
* @object: a #GObject
2714
* @property: (allow-none): the name of a boolean property of @object
2761
* @object: (type GObject.Object): a #GObject
2762
* @property: the name of a boolean property of @object
2716
2764
* Marks @application as busy (see g_application_mark_busy()) while
2717
2765
* @property on @object is %TRUE.
2719
* Multiple such bindings can exist, but only one property can be bound
2720
* per object. Calling this function again for the same object replaces
2721
* a previous binding. If @property is %NULL, the binding is destroyed.
2723
2767
* The binding holds a reference to @application while it is active, but
2724
2768
* not to @object. Instead, the binding is destroyed when @object is
2731
2775
gpointer object,
2732
2776
const gchar *property)
2734
GClosure *closure = NULL;
2779
GQuark property_quark;
2781
GApplicationBusyBinding *binding;
2784
g_return_if_fail (G_IS_APPLICATION (application));
2785
g_return_if_fail (G_IS_OBJECT (object));
2786
g_return_if_fail (property != NULL);
2788
notify_id = g_signal_lookup ("notify", G_TYPE_OBJECT);
2789
property_quark = g_quark_from_string (property);
2790
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property);
2792
g_return_if_fail (pspec != NULL && pspec->value_type == G_TYPE_BOOLEAN);
2794
if (g_signal_handler_find (object, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC,
2795
notify_id, property_quark, NULL, g_application_notify_busy_binding, NULL) > 0)
2797
g_critical ("%s: '%s' is already bound to the busy state of the application", G_STRFUNC, property);
2801
binding = g_slice_new (GApplicationBusyBinding);
2802
binding->app = g_object_ref (application);
2803
binding->is_busy = FALSE;
2805
closure = g_cclosure_new (G_CALLBACK (g_application_notify_busy_binding), binding,
2806
g_application_busy_binding_destroy);
2807
g_signal_connect_closure_by_id (object, notify_id, property_quark, closure, FALSE);
2809
/* fetch the initial value */
2810
g_application_notify_busy_binding (object, pspec, binding);
2814
* g_application_unbind_busy_property:
2815
* @application: a #GApplication
2816
* @object: (type GObject.Object): a #GObject
2817
* @property: the name of a boolean property of @object
2819
* Destroys a binding between @property and the busy state of
2820
* @application that was previously created with
2821
* g_application_bind_busy_property().
2826
g_application_unbind_busy_property (GApplication *application,
2828
const gchar *property)
2831
GQuark property_quark;
2736
2832
gulong handler_id;
2738
2834
g_return_if_fail (G_IS_APPLICATION (application));
2739
2835
g_return_if_fail (G_IS_OBJECT (object));
2836
g_return_if_fail (property != NULL);
2741
2838
notify_id = g_signal_lookup ("notify", G_TYPE_OBJECT);
2839
property_quark = g_quark_from_string (property);
2743
if (property != NULL)
2841
handler_id = g_signal_handler_find (object, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC,
2842
notify_id, property_quark, NULL, g_application_notify_busy_binding, NULL);
2843
if (handler_id == 0)
2746
GApplicationBusyBinding *binding;
2748
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property);
2749
g_return_if_fail (pspec != NULL && pspec->value_type == G_TYPE_BOOLEAN);
2751
binding = g_slice_new (GApplicationBusyBinding);
2752
binding->app = g_object_ref (application);
2753
binding->is_busy = FALSE;
2755
/* fetch the initial value */
2756
g_application_notify_busy_binding (object, pspec, binding);
2758
closure = g_cclosure_new (G_CALLBACK (g_application_notify_busy_binding), binding,
2759
g_application_busy_binding_destroy);
2845
g_critical ("%s: '%s' is not bound to the busy state of the application", G_STRFUNC, property);
2762
/* unset a previous binding after fetching the new initial value, so
2763
* that we don't switch to FALSE for a brief moment when both the
2764
* old and the new property are set to TRUE
2766
handler_id = g_signal_handler_find (object, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC, notify_id,
2767
0, NULL, g_application_notify_busy_binding, NULL);
2769
g_signal_handler_disconnect (object, handler_id);
2772
g_signal_connect_closure_by_id (object, notify_id, g_quark_from_string (property), closure, FALSE);
2849
g_signal_handler_disconnect (object, handler_id);
2775
2852
/* Epilogue {{{1 */