gedit r6743 - branches/message_system/gedit
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6743 - branches/message_system/gedit
- Date: Sun, 28 Dec 2008 20:19:02 +0000 (UTC)
Author: jessevdk
Date: Sun Dec 28 20:19:01 2008
New Revision: 6743
URL: http://svn.gnome.org/viewvc/gedit?rev=6743&view=rev
Log:
Fixed several minor memory leaks. Fixed some documentation (punctuation and function referencing)
Modified:
branches/message_system/gedit/gedit-message-bus.c
branches/message_system/gedit/gedit-message-type.c
branches/message_system/gedit/gedit-message.c
branches/message_system/gedit/msgtest.c
Modified: branches/message_system/gedit/gedit-message-bus.c
==============================================================================
--- branches/message_system/gedit/gedit-message-bus.c (original)
+++ branches/message_system/gedit/gedit-message-bus.c Sun Dec 28 20:19:01 2008
@@ -11,7 +11,7 @@
* @userdata: the supplied user data when connecting the callback
*
* Callback signature used for connecting callback functions to be called
- * when a message is received (see #gedit_message_bus_connect).
+ * when a message is received (see gedit_message_bus_connect()).
*
*/
@@ -182,8 +182,10 @@
g_source_remove (bus->priv->idle_id);
message_queue_free (bus->priv->message_queue);
+
g_hash_table_destroy (bus->priv->messages);
g_hash_table_destroy (bus->priv->idmap);
+ g_hash_table_destroy (bus->priv->types);
G_OBJECT_CLASS (gedit_message_bus_parent_class)->finalize (object);
}
@@ -516,7 +518,7 @@
/**
* gedit_message_bus_get_default:
*
- * Get the default application #GeditMessageBus
+ * Get the default application #GeditMessageBus.
*
* Return value: the default #GeditMessageBus
*
@@ -539,9 +541,9 @@
/**
* gedit_message_bus_new:
*
- * Create a new message bus. Use #gedit_message_bus_get_default to get the
+ * Create a new message bus. Use gedit_message_bus_get_default() to get the
* default, application wide, message bus. Creating a new bus is useful for
- * associating a specific bus with for instance a #GeditWindow
+ * associating a specific bus with for instance a #GeditWindow.
*
* Return value: a new #GeditMessageBus
*
@@ -571,13 +573,17 @@
const gchar *method)
{
gchar *identifier;
+ GeditMessageType *message_type;
g_return_val_if_fail (GEDIT_IS_MESSAGE_BUS (bus), NULL);
g_return_val_if_fail (object_path != NULL, NULL);
g_return_val_if_fail (method != NULL, NULL);
identifier = gedit_message_type_identifier (object_path, method);
- return g_hash_table_lookup (bus->priv->types, identifier);
+ message_type = GEDIT_MESSAGE_TYPE (g_hash_table_lookup (bus->priv->types, identifier));
+
+ g_free (identifier);
+ return message_type;
}
/**
@@ -590,16 +596,16 @@
*
* Register a message on the bus. A message must be registered on the bus before
* it can be send. This function registers the type arguments for @method at
- * @object_path. The arguments are specified with @... which should contain
- * pairs of const gchar *key and GType terminated by NULL. The last
- * @num_optional arguments are registered as optional (and are thus not
+ * @object_path. The arguments are specified with the variable arguments which
+ * should contain pairs of const gchar *key and GType terminated by %NULL. The
+ * last @num_optional arguments are registered as optional (and are thus not
* required when sending a message).
*
- * This function emits a #GeditMessageBus::registered signal
+ * This function emits a #GeditMessageBus::registered signal.
*
* Return value: the registered #GeditMessageType. The returned reference is
* owned by the bus. If you want to keep it alive after
- * unregistering, use #gedit_message_type_ref
+ * unregistering, use gedit_message_type_ref().
*
*/
GeditMessageType *
@@ -649,7 +655,7 @@
* Unregisters a previously registered message type. This is especially useful
* for plugins which should unregister message types when they are deactivated.
*
- * This function emits the #GeditMessageBus::unregistered signal
+ * This function emits the #GeditMessageBus::unregistered signal.
*
*/
void
@@ -700,7 +706,7 @@
* plugins which should unregister message types when they are deactivated.
*
* This function emits the #GeditMessageBus::unregistered signal for all
- * unregistered message types
+ * unregistered message types.
*
*/
void
@@ -724,7 +730,7 @@
* @method: the method
*
* Check whether a message type @method at @object_path is registered on the
- * bus
+ * bus.
*
* Return value: %TRUE if the @method at @object_path is a registered message
* type on the bus
@@ -789,9 +795,9 @@
/**
* gedit_message_bus_disconnect:
* @bus: a #GeditMessageBus
- * @id: the callback id as returned by #gedit_message_bus_connect
+ * @id: the callback id as returned by gedit_message_bus_connect()
*
- * Disconnects a previously connected message callback
+ * Disconnects a previously connected message callback.
*
*/
void
@@ -813,7 +819,7 @@
*
* Disconnects a previously connected message callback by matching the
* provided callback function and userdata. See also
- * #gedit_message_bus_disconnect
+ * gedit_message_bus_disconnect().
*
*/
void
@@ -834,7 +840,7 @@
* @id: the callback id
*
* Blocks evoking the callback specified by @id. Unblock the callback by
- * using #gedit_message_bus_unblock
+ * using gedit_message_bus_unblock().
*
*/
void
@@ -855,7 +861,7 @@
* @userdata: the userdata with which the callback was connected
*
* Blocks evoking the callback that matches provided @callback and @userdata.
- * Unblock the callback using #gedit_message_unblock_by_func
+ * Unblock the callback using gedit_message_unblock_by_func().
*
*/
void
@@ -875,7 +881,7 @@
* @bus: a #GeditMessageBus
* @id: the callback id
*
- * Unblocks the callback specified by @id
+ * Unblocks the callback specified by @id.
*
*/
void
@@ -895,7 +901,7 @@
* @callback: the callback to block
* @userdata: the userdata with which the callback was connected
*
- * Unblocks the callback that matches provided @callback and @userdata
+ * Unblocks the callback that matches provided @callback and @userdata.
*
*/
void
@@ -948,8 +954,8 @@
* @message: the message to send
*
* This sends the provided @message asynchronously over the bus. To send
- * a message synchronously, use #gedit_message_bus_send_message_sync. The
- * convenience function #gedit_message_bus_send can be used to easily send
+ * a message synchronously, use gedit_message_bus_send_message_sync(). The
+ * convenience function gedit_message_bus_send() can be used to easily send
* a message without constructing the message object explicitly first.
*
*/
@@ -981,8 +987,8 @@
* @message: the message to send
*
* This sends the provided @message synchronously over the bus. To send
- * a message asynchronously, use #gedit_message_bus_send_message. The
- * convenience function #gedit_message_bus_send_sync can be used to easily send
+ * a message asynchronously, use gedit_message_bus_send_message(). The
+ * convenience function gedit_message_bus_send_sync() can be used to easily send
* a message without constructing the message object explicitly first.
*
*/
@@ -1024,9 +1030,9 @@
* @...: NULL terminated list of key/value pairs
*
* This provides a convenient way to quickly send a message @method at
- * @object_path asynchronously over the bus. @... specifies key (string) value
- * pairs used to construct the message arguments. To send a message
- * synchronously use #gedit_message_bus_send_sync
+ * @object_path asynchronously over the bus. The variable argument list
+ * specifies key (string) value pairs used to construct the message arguments.
+ * To send a message synchronously use gedit_message_bus_send_sync().
*
*/
void
@@ -1063,13 +1069,13 @@
* @...: NULL terminated list of key/value pairs
*
* This provides a convenient way to quickly send a message @method at
- * @object_path synchronously over the bus. @... specifies key (string) value
- * pairs used to construct the message arguments. To send a message
- * asynchronously use #gedit_message_bus_send
+ * @object_path synchronously over the bus. The variable argument list
+ * specifies key (string) value pairs used to construct the message
+ * arguments. To send a message asynchronously use gedit_message_bus_send().
*
* Return value: the constructed #GeditMessage. The caller owns a reference
- * to the #GeditMessage and should call g_object_unref when
- * it is no longer needed.
+ * to the #GeditMessage and should call g_object_unref() when
+ * it is no longer needed
*/
GeditMessage *
gedit_message_bus_send_sync (GeditMessageBus *bus,
Modified: branches/message_system/gedit/gedit-message-type.c
==============================================================================
--- branches/message_system/gedit/gedit-message-type.c (original)
+++ branches/message_system/gedit/gedit-message-type.c Sun Dec 28 20:19:01 2008
@@ -58,7 +58,7 @@
* gedit_message_type_ref:
* @message_type: the #GeditMessageType
*
- * Increases the reference count on @message_type
+ * Increases the reference count on @message_type.
*
* Return value: @message_type
*
@@ -77,7 +77,7 @@
* @message_type: the #GeditMessageType
*
* Decreases the reference count on @message_type. When the reference count
- * drops to 0, @message_type is destroyed
+ * drops to 0, @message_type is destroyed.
*
*/
void
@@ -122,7 +122,7 @@
* @object_path: the object path
* @method: the method
*
- * Get the string identifier for @method at @object_path
+ * Get the string identifier for @method at @object_path.
*
* Return value: the identifier for @method at @object_path
*
@@ -138,7 +138,7 @@
* gedit_message_type_is_supported:
* @type: the #GType
*
- * Returns if @type is #GType supported by the message system
+ * Returns if @type is #GType supported by the message system.
*
* Return value: %TRUE if @type is a supported #GType
*
@@ -192,7 +192,7 @@
*
* Create a new #GeditMessageType for @method at @object_path. Argument names
* and values are supplied by the NULL terminated variable argument list.
- * The last @num_optional provided arguments are considered optional
+ * The last @num_optional provided arguments are considered optional.
*
* Return value: the newly constructed #GeditMessageType
*
@@ -208,8 +208,9 @@
g_return_val_if_fail (object_path != NULL, NULL);
g_return_val_if_fail (method != NULL, NULL);
- message_type = g_new(GeditMessageType, 1);
+ message_type = g_new0(GeditMessageType, 1);
+ message_type->ref_count = 1;
message_type->object_path = g_strdup(object_path);
message_type->method = g_strdup(method);
message_type->num_arguments = 0;
@@ -265,7 +266,7 @@
*/
void
gedit_message_type_set (GeditMessageType *message_type,
- guint num_optional,
+ guint num_optional,
...)
{
va_list va_args;
@@ -354,7 +355,7 @@
* @va_args: NULL terminated variable list of key/value pairs
*
* Instantiate a new message from the message type with specific values
- * for the message arguments
+ * for the message arguments.
*
* Return value: the newly created message
*
@@ -379,7 +380,7 @@
* @...: NULL terminated variable list of key/value pairs
*
* Instantiate a new message from the message type with specific values
- * for the message arguments
+ * for the message arguments.
*
* Return value: the newly created message
*
@@ -402,7 +403,7 @@
* gedit_message_type_get_object_path:
* @message_type: the #GeditMessageType
*
- * Get the message type object path
+ * Get the message type object path.
*
* Return value: the message type object path
*
@@ -417,7 +418,7 @@
* gedit_message_type_get_method:
* @message_type: the #GeditMessageType
*
- * Get the message type method
+ * Get the message type method.
*
* Return value: the message type method
*
@@ -433,7 +434,7 @@
* @message_type: the #GeditMessageType
* @key: the argument key
*
- * Get the argument key #GType
+ * Get the argument key #GType.
*
* Return value: the #GType of @key
*
@@ -470,7 +471,7 @@
* @func: the callback function
* @user_data: user data supplied to the callback function
*
- * Calls @func for each argument in the message type
+ * Calls @func for each argument in the message type.
*
*/
void
Modified: branches/message_system/gedit/gedit-message.c
==============================================================================
--- branches/message_system/gedit/gedit-message.c (original)
+++ branches/message_system/gedit/gedit-message.c Sun Dec 28 20:19:01 2008
@@ -125,7 +125,7 @@
/**
* GeditMessage:object_path:
*
- * The messages object path (e.g. /gedit/object/path)
+ * The messages object path (e.g. /gedit/object/path).
*
*/
g_object_class_install_property (object_class, PROP_OBJECT_PATH,
@@ -139,7 +139,7 @@
/**
* GeditMessage:method:
*
- * The messages method
+ * The messages method.
*
*/
g_object_class_install_property (object_class, PROP_METHOD,
@@ -153,7 +153,7 @@
/**
* GeditMEssage:type:
*
- * The message type
+ * The message type.
*
*/
g_object_class_install_property (object_class, PROP_TYPE,
@@ -231,7 +231,7 @@
* gedit_message_get_method:
* @message: the #GeditMessage
*
- * Get the message method
+ * Get the message method.
*
* Return value: the message method
*
@@ -248,7 +248,7 @@
* gedit_message_get_object_path:
* @message: the #GeditMessage
*
- * Get the message object path
+ * Get the message object path.
*
* Return value: the message object path
*
@@ -267,7 +267,7 @@
* @...: a NULL terminated variable list of key/value pairs
*
* Set values of message arguments. The supplied @var_args should contain
- * pairs of keys and argument values
+ * pairs of keys and argument values.
*
*/
void
@@ -289,7 +289,7 @@
* @var_args: a NULL terminated variable list of key/value pairs
*
* Set values of message arguments. The supplied @var_args should contain
- * pairs of keys and argument values
+ * pairs of keys and argument values.
*
*/
void
@@ -338,7 +338,7 @@
* @key: the argument key
* @value: the argument value
*
- * Set value of message argument @key to @value
+ * Set value of message argument @key to @value.
*
*/
void
@@ -395,7 +395,7 @@
*
* Get values of message arguments. The supplied @var_args should contain
* pairs of keys and pointers to variables which are set to the argument
- * value for the specified key
+ * value for the specified key.
*
*/
void
@@ -418,7 +418,7 @@
*
* Get values of message arguments. The supplied @var_args should contain
* pairs of keys and pointers to variables which are set to the argument
- * value for the specified key
+ * value for the specified key.
*
*/
void
@@ -471,7 +471,7 @@
* @value: value return container
*
* Get the value of a specific message argument. @value will be initialized
- * with the correct type
+ * with the correct type.
*
*/
void
@@ -502,7 +502,7 @@
* @message: the #GeditMessage
* @key: the argument key
*
- * Get the type of a message argument
+ * Get the type of a message argument.
*
* Return value: the type of @key
*
@@ -522,7 +522,7 @@
* @message: the #GeditMessage
* @key: the argument key
*
- * Check whether the message has a specific key
+ * Check whether the message has a specific key.
*
* Return value: %TRUE if @message has argument @key
*
@@ -563,7 +563,7 @@
* gedit_message_validate:
* @message: the #GeditMessage
*
- * Validates the message arguments according to the message type
+ * Validates the message arguments according to the message type.
*
* Return value: %TRUE if the message is valid
*
Modified: branches/message_system/gedit/msgtest.c
==============================================================================
--- branches/message_system/gedit/msgtest.c (original)
+++ branches/message_system/gedit/msgtest.c Sun Dec 28 20:19:01 2008
@@ -4,10 +4,13 @@
fb_set_root_cb (GeditMessageBus *bus, GeditMessage *message, gpointer user_data)
{
gchar *uri = NULL;
-
+
gedit_message_get (message, "uri", &uri, NULL);
g_message ("Setting root to: %s", uri);
+ if (gedit_message_has_key (message, "result"))
+ gedit_message_set (message, "result", TRUE, NULL);
+
g_free (uri);
}
@@ -21,17 +24,43 @@
bus = gedit_message_bus_get_default ();
/* registering a new message on the bus */
- GeditMessageType *message_type = gedit_message_bus_register (bus, "/plugins/filebrowser", "set_root", 0, "uri", G_TYPE_STRING, NULL);
+ GeditMessageType *message_type = gedit_message_bus_register (bus,
+ "/plugins/filebrowser", "set_root",
+ 1,
+ "uri", G_TYPE_STRING,
+ "result", G_TYPE_BOOLEAN,
+ NULL);
/* register callback for the message type */
- gedit_message_bus_connect (bus, "/plugins/filebrowser", "set_root", fb_set_root_cb, NULL, NULL);
+ guint id = gedit_message_bus_connect (bus,
+ "/plugins/filebrowser", "set_root",
+ fb_set_root_cb,
+ NULL, NULL);
+
+ gedit_message_bus_send (bus,
+ "/plugins/filebrowser", "set_root",
+ "uri", "/hello/world/async",
+ NULL);
/* sending the set_root message */
- gedit_message_bus_send_sync (bus, "/plugins/filebrowser", "set_root", "uri", "/hello/world", NULL);
+ gboolean result = FALSE;
+ GeditMessage *message = gedit_message_bus_send_sync (bus,
+ "/plugins/filebrowser", "set_root",
+ "uri", "/hello/world",
+ "result", result,
+ NULL);
+
+ gedit_message_get (message, "result", &result, NULL);
+ g_message ("Result: %d", result);
+
+ g_main_context_iteration (NULL, FALSE);
/* unregister message type */
gedit_message_bus_unregister (bus, message_type);
- g_object_unref (bus);
+ gedit_message_bus_disconnect (bus, id);
+ g_object_unref (message);
+ g_object_unref (bus);
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]