xed-message-bus: Clean up code styling
This commit is contained in:
parent
909ea55a7c
commit
2bf076e7c5
|
@ -152,7 +152,9 @@ static void
|
||||||
listener_free (Listener *listener)
|
listener_free (Listener *listener)
|
||||||
{
|
{
|
||||||
if (listener->destroy_data)
|
if (listener->destroy_data)
|
||||||
|
{
|
||||||
listener->destroy_data (listener->userdata);
|
listener->destroy_data (listener->userdata);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (listener);
|
g_free (listener);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,9 @@ xed_message_bus_finalize (GObject *object)
|
||||||
XedMessageBus *bus = XED_MESSAGE_BUS (object);
|
XedMessageBus *bus = XED_MESSAGE_BUS (object);
|
||||||
|
|
||||||
if (bus->priv->idle_id != 0)
|
if (bus->priv->idle_id != 0)
|
||||||
|
{
|
||||||
g_source_remove (bus->priv->idle_id);
|
g_source_remove (bus->priv->idle_id);
|
||||||
|
}
|
||||||
|
|
||||||
message_queue_free (bus->priv->message_queue);
|
message_queue_free (bus->priv->message_queue);
|
||||||
|
|
||||||
|
@ -278,9 +282,7 @@ message_new (XedMessageBus *bus,
|
||||||
message->method = g_strdup (method);
|
message->method = g_strdup (method);
|
||||||
message->listeners = NULL;
|
message->listeners = NULL;
|
||||||
|
|
||||||
g_hash_table_insert (bus->priv->messages,
|
g_hash_table_insert (bus->priv->messages, xed_message_type_identifier (object_path, method), message);
|
||||||
xed_message_type_identifier (object_path, method),
|
|
||||||
message);
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,10 +300,14 @@ lookup_message (XedMessageBus *bus,
|
||||||
g_free (identifier);
|
g_free (identifier);
|
||||||
|
|
||||||
if (!message && !create)
|
if (!message && !create)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!message)
|
if (!message)
|
||||||
|
{
|
||||||
message = message_new (bus, object_path, method);
|
message = message_new (bus, object_path, method);
|
||||||
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -390,9 +396,11 @@ dispatch_message_real (XedMessageBus *bus,
|
||||||
Listener *listener = (Listener *)item->data;
|
Listener *listener = (Listener *)item->data;
|
||||||
|
|
||||||
if (!listener->blocked)
|
if (!listener->blocked)
|
||||||
|
{
|
||||||
listener->callback (bus, message, listener->userdata);
|
listener->callback (bus, message, listener->userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_message_bus_dispatch_real (XedMessageBus *bus,
|
xed_message_bus_dispatch_real (XedMessageBus *bus,
|
||||||
|
@ -408,8 +416,10 @@ xed_message_bus_dispatch_real (XedMessageBus *bus,
|
||||||
msg = lookup_message (bus, object_path, method, FALSE);
|
msg = lookup_message (bus, object_path, method, FALSE);
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
|
{
|
||||||
dispatch_message_real (bus, msg, message);
|
dispatch_message_real (bus, msg, message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dispatch_message (XedMessageBus *bus,
|
dispatch_message (XedMessageBus *bus,
|
||||||
|
@ -486,8 +496,7 @@ process_by_match (XedMessageBus *bus,
|
||||||
{
|
{
|
||||||
Listener *listener = (Listener *)item->data;
|
Listener *listener = (Listener *)item->data;
|
||||||
|
|
||||||
if (listener->callback == callback &&
|
if (listener->callback == callback && listener->userdata == userdata)
|
||||||
listener->userdata == userdata)
|
|
||||||
{
|
{
|
||||||
processor (bus, message, item);
|
processor (bus, message, item);
|
||||||
return;
|
return;
|
||||||
|
@ -534,8 +543,7 @@ xed_message_bus_get_default (void)
|
||||||
if (G_UNLIKELY (default_bus == NULL))
|
if (G_UNLIKELY (default_bus == NULL))
|
||||||
{
|
{
|
||||||
default_bus = g_object_new (XED_TYPE_MESSAGE_BUS, NULL);
|
default_bus = g_object_new (XED_TYPE_MESSAGE_BUS, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (default_bus),
|
g_object_add_weak_pointer (G_OBJECT (default_bus), (gpointer) &default_bus);
|
||||||
(gpointer) &default_bus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_bus;
|
return default_bus;
|
||||||
|
@ -636,10 +644,7 @@ xed_message_bus_register (XedMessageBus *bus,
|
||||||
data = g_hash_table_lookup (bus->priv->types, identifier);
|
data = g_hash_table_lookup (bus->priv->types, identifier);
|
||||||
|
|
||||||
va_start (var_args, num_optional);
|
va_start (var_args, num_optional);
|
||||||
message_type = xed_message_type_new_valist (object_path,
|
message_type = xed_message_type_new_valist (object_path, method, num_optional, var_args);
|
||||||
method,
|
|
||||||
num_optional,
|
|
||||||
var_args);
|
|
||||||
va_end (var_args);
|
va_end (var_args);
|
||||||
|
|
||||||
if (message_type)
|
if (message_type)
|
||||||
|
@ -671,7 +676,9 @@ xed_message_bus_unregister_real (XedMessageBus *bus,
|
||||||
xed_message_type_ref (message_type);
|
xed_message_type_ref (message_type);
|
||||||
|
|
||||||
if (!remove_from_store || g_hash_table_remove (bus->priv->types, identifier))
|
if (!remove_from_store || g_hash_table_remove (bus->priv->types, identifier))
|
||||||
|
{
|
||||||
g_signal_emit (bus, message_bus_signals[UNREGISTERED], 0, message_type);
|
g_signal_emit (bus, message_bus_signals[UNREGISTERED], 0, message_type);
|
||||||
|
}
|
||||||
|
|
||||||
xed_message_type_unref (message_type);
|
xed_message_type_unref (message_type);
|
||||||
g_free (identifier);
|
g_free (identifier);
|
||||||
|
@ -738,9 +745,7 @@ xed_message_bus_unregister_all (XedMessageBus *bus,
|
||||||
g_return_if_fail (XED_IS_MESSAGE_BUS (bus));
|
g_return_if_fail (XED_IS_MESSAGE_BUS (bus));
|
||||||
g_return_if_fail (object_path != NULL);
|
g_return_if_fail (object_path != NULL);
|
||||||
|
|
||||||
g_hash_table_foreach_remove (bus->priv->types,
|
g_hash_table_foreach_remove (bus->priv->types, (GHRFunc)unregister_each, &info);
|
||||||
(GHRFunc)unregister_each,
|
|
||||||
&info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -996,15 +1001,16 @@ send_message_real (XedMessageBus *bus,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus->priv->message_queue = g_list_prepend (bus->priv->message_queue,
|
bus->priv->message_queue = g_list_prepend (bus->priv->message_queue, g_object_ref (message));
|
||||||
g_object_ref (message));
|
|
||||||
|
|
||||||
if (bus->priv->idle_id == 0)
|
if (bus->priv->idle_id == 0)
|
||||||
|
{
|
||||||
bus->priv->idle_id = g_idle_add_full (G_PRIORITY_HIGH,
|
bus->priv->idle_id = g_idle_add_full (G_PRIORITY_HIGH,
|
||||||
(GSourceFunc)idle_dispatch,
|
(GSourceFunc)idle_dispatch,
|
||||||
bus,
|
bus,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xed_message_bus_send_message:
|
* xed_message_bus_send_message:
|
||||||
|
@ -1076,8 +1082,7 @@ create_message (XedMessageBus *bus,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xed_message_type_instantiate_valist (message_type,
|
return xed_message_type_instantiate_valist (message_type, var_args);
|
||||||
var_args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue