Fix some introspection warnings

Adapted from:
b9a3360ee8
This commit is contained in:
JosephMcc 2016-12-26 11:41:29 -08:00
parent c6f5fd5e1d
commit 7a6db1f8c5
10 changed files with 485 additions and 450 deletions

View File

@ -329,7 +329,7 @@ app_weak_notify (gpointer data,
* Returns the #XedApp object. This object is a singleton and * Returns the #XedApp object. This object is a singleton and
* represents the running xed instance. * represents the running xed instance.
* *
* Return value: the #XedApp pointer * Return value: (transfer none): the #XedApp pointer
*/ */
XedApp * XedApp *
xed_app_get_default (void) xed_app_get_default (void)
@ -527,7 +527,7 @@ xed_app_create_window_real (XedApp *app,
* *
* Create a new #XedWindow part of @app. * Create a new #XedWindow part of @app.
* *
* Return value: the new #XedWindow * Return value: (transfer none): the new #XedWindow
*/ */
XedWindow * XedWindow *
xed_app_create_window (XedApp *app, xed_app_create_window (XedApp *app,
@ -566,7 +566,7 @@ _xed_app_restore_window (XedApp *app,
* *
* Returns all the windows currently present in #XedApp. * Returns all the windows currently present in #XedApp.
* *
* Return value: (transfer none): the list of #XedWindows objects. * Return value: (element-type Xed.Window) (transfer none): the list of #XedWindows objects.
* The list should not be freed * The list should not be freed
*/ */
const GList * const GList *
@ -583,7 +583,7 @@ xed_app_get_windows (XedApp *app)
* *
* Retrives the #XedWindow currently active. * Retrives the #XedWindow currently active.
* *
* Return value: the active #XedWindow * Return value: (transfer none): the active #XedWindow
*/ */
XedWindow * XedWindow *
xed_app_get_active_window (XedApp *app) xed_app_get_active_window (XedApp *app)

View File

@ -1036,6 +1036,12 @@ set_uri (XedDocument *doc,
} }
} }
/**
* xed_document_get_location:
* @doc: a #XedDocument
*
* Returns: (allow-none) (transfer full): a new #GFile
*/
GFile * GFile *
xed_document_get_location (XedDocument *doc) xed_document_get_location (XedDocument *doc)
{ {
@ -1736,7 +1742,7 @@ compute_num_of_lines (const gchar *text)
} }
/** /**
* xed_document_set_search_text" * xed_document_set_search_text:
* @doc: * @doc:
* @text: (allow-none): * @text: (allow-none):
* @flags: * @flags:
@ -1835,7 +1841,7 @@ xed_document_get_can_search_again (XedDocument *doc)
* @start: (allow-none): * @start: (allow-none):
* @end: (allow-none): * @end: (allow-none):
* @match_start: (allow-none): * @match_start: (allow-none):
* @match_end: (allow=none): * @match_end: (allow-none):
**/ **/
gboolean gboolean
xed_document_search_forward (XedDocument *doc, xed_document_search_forward (XedDocument *doc,
@ -1920,7 +1926,7 @@ xed_document_search_forward (XedDocument *doc,
* @start: (allow-none): * @start: (allow-none):
* @end: (allow-none): * @end: (allow-none):
* @match_start: (allow-none): * @match_start: (allow-none):
* @match_end: (allow=none): * @match_end: (allow-none):
**/ **/
gboolean gboolean
xed_document_search_backward (XedDocument *doc, xed_document_search_backward (XedDocument *doc,
@ -2130,6 +2136,12 @@ xed_document_set_language (XedDocument *doc,
set_language (doc, lang, TRUE); set_language (doc, lang, TRUE);
} }
/**
* xed_document_get_language:
* @doc:
*
* Return value: (transfer none):
*/
GtkSourceLanguage * GtkSourceLanguage *
xed_document_get_language (XedDocument *doc) xed_document_get_language (XedDocument *doc)
{ {

View File

@ -455,7 +455,7 @@ xed_file_chooser_dialog_new_valist (const gchar *title,
* @action: Open or save mode for the dialog * @action: Open or save mode for the dialog
* @first_button_text: (allow-none): stock ID or text to go in * @first_button_text: (allow-none): stock ID or text to go in
* the first button, or %NULL * the first button, or %NULL
* @Varargs: (allow-none): response ID for the first button, then * @...: (allow-none): response ID for the first button, then
* additional (button, id) pairs, ending with %NULL * additional (button, id) pairs, ending with %NULL
* *
* Creates a new #XedFileChooserDialog. This function is analogous to * Creates a new #XedFileChooserDialog. This function is analogous to

View File

@ -532,7 +532,7 @@ xed_message_bus_init (XedMessageBus *self)
* *
* Get the default application #XedMessageBus. * Get the default application #XedMessageBus.
* *
* Return value: the default #XedMessageBus * Return value: (transfer none): the default #XedMessageBus
* *
*/ */
XedMessageBus * XedMessageBus *
@ -797,7 +797,7 @@ foreach_type (const gchar *key,
/** /**
* xed_message_bus_foreach: * xed_message_bus_foreach:
* @bus: the #XedMessagebus * @bus: the #XedMessagebus
* @func: the callback function * @func: (scope call): the callback function
* @userdata: the user data to supply to the callback function * @userdata: the user data to supply to the callback function
* *
* Calls @func for each message type registered on the bus * Calls @func for each message type registered on the bus
@ -875,7 +875,7 @@ xed_message_bus_disconnect (XedMessageBus *bus,
* @bus: a #XedMessageBus * @bus: a #XedMessageBus
* @object_path: the object path * @object_path: the object path
* @method: the method * @method: the method
* @callback: the connected callback * @callback: (scope call): the connected callback
* @userdata: the userdata with which the callback was connected * @userdata: the userdata with which the callback was connected
* *
* Disconnects a previously connected message callback by matching the * Disconnects a previously connected message callback by matching the
@ -918,7 +918,7 @@ xed_message_bus_block (XedMessageBus *bus,
* @bus: a #XedMessageBus * @bus: a #XedMessageBus
* @object_path: the object path * @object_path: the object path
* @method: the method * @method: the method
* @callback: the callback to block * @callback: (scope call): the callback to block
* @userdata: the userdata with which the callback was connected * @userdata: the userdata with which the callback was connected
* *
* Blocks evoking the callback that matches provided @callback and @userdata. * Blocks evoking the callback that matches provided @callback and @userdata.
@ -959,7 +959,7 @@ xed_message_bus_unblock (XedMessageBus *bus,
* @bus: a #XedMessageBus * @bus: a #XedMessageBus
* @object_path: the object path * @object_path: the object path
* @method: the method * @method: the method
* @callback: the callback to block * @callback: (scope call): the callback to block
* @userdata: the userdata with which the callback was connected * @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.
@ -1134,7 +1134,7 @@ xed_message_bus_send (XedMessageBus *bus,
* specifies key (string) value pairs used to construct the message * specifies key (string) value pairs used to construct the message
* arguments. To send a message asynchronously use xed_message_bus_send(). * arguments. To send a message asynchronously use xed_message_bus_send().
* *
* Return value: the constructed #XedMessage. The caller owns a reference * Return value: (transfer full): the constructed #XedMessage. The caller owns a reference
* to the #XedMessage and should call g_object_unref() when * to the #XedMessage and should call g_object_unref() when
* it is no longer needed * it is no longer needed
*/ */

View File

@ -10,12 +10,12 @@
* the Object Path, Method and Arguments of the message. * the Object Path, Method and Arguments of the message.
* *
* A message type can contain any number of required and optional arguments. * A message type can contain any number of required and optional arguments.
* To instantiate a #XedMessage from a #XedMessageType, use * To instantiate a #XedMessage from a #XedMessageType, use
* xed_message_type_instantiate(). * xed_message_type_instantiate().
* *
* Registering a new message type on a #XedMessageBus with * Registering a new message type on a #XedMessageBus with
* xed_message_bus_register() internally creates a new #XedMessageType. When * xed_message_bus_register() internally creates a new #XedMessageType. When
* then using xed_message_bus_send(), an actual instantiation of the * then using xed_message_bus_send(), an actual instantiation of the
* registered type is internally created and send over the bus. * registered type is internally created and send over the bus.
* *
* <example> * <example>
@ -50,10 +50,10 @@ struct _XedMessageType
gchar *object_path; gchar *object_path;
gchar *method; gchar *method;
guint num_arguments; guint num_arguments;
guint num_required; guint num_required;
GHashTable *arguments; // mapping of key -> ArgumentInfo GHashTable *arguments; // mapping of key -> ArgumentInfo
}; };
@ -71,7 +71,7 @@ xed_message_type_ref (XedMessageType *message_type)
{ {
g_return_val_if_fail (message_type != NULL, NULL); g_return_val_if_fail (message_type != NULL, NULL);
g_atomic_int_inc (&message_type->ref_count); g_atomic_int_inc (&message_type->ref_count);
return message_type; return message_type;
} }
@ -83,30 +83,30 @@ xed_message_type_ref (XedMessageType *message_type)
* drops to 0, @message_type is destroyed. * drops to 0, @message_type is destroyed.
* *
*/ */
void void
xed_message_type_unref (XedMessageType *message_type) xed_message_type_unref (XedMessageType *message_type)
{ {
g_return_if_fail (message_type != NULL); g_return_if_fail (message_type != NULL);
if (!g_atomic_int_dec_and_test (&message_type->ref_count)) if (!g_atomic_int_dec_and_test (&message_type->ref_count))
return; return;
g_free (message_type->object_path); g_free (message_type->object_path);
g_free (message_type->method); g_free (message_type->method);
g_hash_table_destroy (message_type->arguments); g_hash_table_destroy (message_type->arguments);
g_free (message_type); g_free (message_type);
} }
/** /**
* xed_message_type_get_type: * xed_message_type_get_type:
* *
* Retrieves the GType object which is associated with the * Retrieves the GType object which is associated with the
* #XedMessageType class. * #XedMessageType class.
* *
* Return value: the GType associated with #XedMessageType. * Return value: the GType associated with #XedMessageType.
**/ **/
GType GType
xed_message_type_get_type (void) xed_message_type_get_type (void)
{ {
static GType our_type = 0; static GType our_type = 0;
@ -151,17 +151,17 @@ xed_message_type_is_valid_object_path (const gchar *object_path)
{ {
if (!object_path) if (!object_path)
return FALSE; return FALSE;
/* needs to start with / */ /* needs to start with / */
if (*object_path != '/') if (*object_path != '/')
return FALSE; return FALSE;
while (*object_path) while (*object_path)
{ {
if (*object_path == '/') if (*object_path == '/')
{ {
++object_path; ++object_path;
if (!*object_path || !(g_ascii_isalpha (*object_path) || *object_path == '_')) if (!*object_path || !(g_ascii_isalpha (*object_path) || *object_path == '_'))
return FALSE; return FALSE;
} }
@ -169,10 +169,10 @@ xed_message_type_is_valid_object_path (const gchar *object_path)
{ {
return FALSE; return FALSE;
} }
++object_path; ++object_path;
} }
return TRUE; return TRUE;
} }
@ -189,7 +189,7 @@ gboolean
xed_message_type_is_supported (GType type) xed_message_type_is_supported (GType type)
{ {
gint i = 0; gint i = 0;
static const GType type_list[] = static const GType type_list[] =
{ {
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
@ -252,7 +252,7 @@ xed_message_type_new_valist (const gchar *object_path,
g_return_val_if_fail (xed_message_type_is_valid_object_path (object_path), NULL); g_return_val_if_fail (xed_message_type_is_valid_object_path (object_path), NULL);
message_type = g_new0(XedMessageType, 1); message_type = g_new0(XedMessageType, 1);
message_type->ref_count = 1; message_type->ref_count = 1;
message_type->object_path = g_strdup(object_path); message_type->object_path = g_strdup(object_path);
message_type->method = g_strdup(method); message_type->method = g_strdup(method);
@ -288,11 +288,11 @@ xed_message_type_new (const gchar *object_path,
{ {
XedMessageType *message_type; XedMessageType *message_type;
va_list var_args; va_list var_args;
va_start(var_args, num_optional); va_start(var_args, num_optional);
message_type = xed_message_type_new_valist (object_path, method, num_optional, var_args); message_type = xed_message_type_new_valist (object_path, method, num_optional, var_args);
va_end(var_args); va_end(var_args);
return message_type; return message_type;
} }
@ -313,7 +313,7 @@ xed_message_type_set (XedMessageType *message_type,
...) ...)
{ {
va_list va_args; va_list va_args;
va_start (va_args, num_optional); va_start (va_args, num_optional);
xed_message_type_set_valist (message_type, num_optional, va_args); xed_message_type_set_valist (message_type, num_optional, va_args);
va_end (va_args); va_end (va_args);
@ -326,11 +326,11 @@ xed_message_type_set (XedMessageType *message_type,
* @var_args: key/gtype pair variable argument list * @var_args: key/gtype pair variable argument list
* *
* Sets argument names/types supplied by the NULL terminated variable * Sets argument names/types supplied by the NULL terminated variable
* argument list @var_args. The last @num_optional provided arguments are * argument list @var_args. The last @num_optional provided arguments are
* considered optional. * considered optional.
* *
*/ */
void void
xed_message_type_set_valist (XedMessageType *message_type, xed_message_type_set_valist (XedMessageType *message_type,
guint num_optional, guint num_optional,
va_list var_args) va_list var_args)
@ -346,35 +346,35 @@ xed_message_type_set_valist (XedMessageType *message_type,
// get corresponding GType // get corresponding GType
GType gtype = va_arg (var_args, GType); GType gtype = va_arg (var_args, GType);
ArgumentInfo *info; ArgumentInfo *info;
if (!xed_message_type_is_supported (gtype)) if (!xed_message_type_is_supported (gtype))
{ {
g_error ("Message type '%s' is not supported", g_type_name (gtype)); g_error ("Message type '%s' is not supported", g_type_name (gtype));
xed_message_type_unref (message_type); xed_message_type_unref (message_type);
g_free (optional); g_free (optional);
return; return;
} }
info = g_new(ArgumentInfo, 1); info = g_new(ArgumentInfo, 1);
info->type = gtype; info->type = gtype;
info->required = TRUE; info->required = TRUE;
g_hash_table_insert (message_type->arguments, g_strdup (key), info); g_hash_table_insert (message_type->arguments, g_strdup (key), info);
++message_type->num_arguments; ++message_type->num_arguments;
++added; ++added;
if (num_optional > 0) if (num_optional > 0)
{ {
for (i = num_optional - 1; i > 0; --i) for (i = num_optional - 1; i > 0; --i)
optional[i] = optional[i - 1]; optional[i] = optional[i - 1];
*optional = info; *optional = info;
} }
} }
message_type->num_required += added; message_type->num_required += added;
// set required for last num_optional arguments // set required for last num_optional arguments
@ -386,7 +386,7 @@ xed_message_type_set_valist (XedMessageType *message_type,
--message_type->num_required; --message_type->num_required;
} }
} }
g_free (optional); g_free (optional);
} }
@ -398,7 +398,7 @@ xed_message_type_set_valist (XedMessageType *message_type,
* Instantiate a new message from the message type with specific values * 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 * Return value: (transfer full): the newly created message
* *
*/ */
XedMessage * XedMessage *
@ -406,12 +406,12 @@ xed_message_type_instantiate_valist (XedMessageType *message_type,
va_list va_args) va_list va_args)
{ {
XedMessage *message; XedMessage *message;
g_return_val_if_fail (message_type != NULL, NULL); g_return_val_if_fail (message_type != NULL, NULL);
message = XED_MESSAGE (g_object_new (XED_TYPE_MESSAGE, "type", message_type, NULL)); message = XED_MESSAGE (g_object_new (XED_TYPE_MESSAGE, "type", message_type, NULL));
xed_message_set_valist (message, va_args); xed_message_set_valist (message, va_args);
return message; return message;
} }
@ -423,7 +423,7 @@ xed_message_type_instantiate_valist (XedMessageType *message_type,
* Instantiate a new message from the message type with specific values * 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 * Return value: (transfer full): the newly created message
* *
*/ */
XedMessage * XedMessage *
@ -432,11 +432,11 @@ xed_message_type_instantiate (XedMessageType *message_type,
{ {
XedMessage *message; XedMessage *message;
va_list va_args; va_list va_args;
va_start (va_args, message_type); va_start (va_args, message_type);
message = xed_message_type_instantiate_valist (message_type, va_args); message = xed_message_type_instantiate_valist (message_type, va_args);
va_end (va_args); va_end (va_args);
return message; return message;
} }
@ -485,10 +485,10 @@ xed_message_type_lookup (XedMessageType *message_type,
const gchar *key) const gchar *key)
{ {
ArgumentInfo *info = g_hash_table_lookup (message_type->arguments, key); ArgumentInfo *info = g_hash_table_lookup (message_type->arguments, key);
if (!info) if (!info)
return G_TYPE_INVALID; return G_TYPE_INVALID;
return info->type; return info->type;
} }
@ -509,13 +509,13 @@ foreach_gtype (const gchar *key,
/** /**
* xed_message_type_foreach: * xed_message_type_foreach:
* @message_type: the #XedMessageType * @message_type: the #XedMessageType
* @func: the callback function * @func: (scope call): the callback function
* @user_data: user data supplied to 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 void
xed_message_type_foreach (XedMessageType *message_type, xed_message_type_foreach (XedMessageType *message_type,
XedMessageTypeForeach func, XedMessageTypeForeach func,
gpointer user_data) gpointer user_data)

View File

@ -45,7 +45,7 @@ static void
xed_message_finalize (GObject *object) xed_message_finalize (GObject *object)
{ {
XedMessage *message = XED_MESSAGE (object); XedMessage *message = XED_MESSAGE (object);
xed_message_type_unref (message->priv->type); xed_message_type_unref (message->priv->type);
g_hash_table_destroy (message->priv->values); g_hash_table_destroy (message->priv->values);
@ -102,16 +102,16 @@ add_value (XedMessage *message,
{ {
GValue *value; GValue *value;
GType type = xed_message_type_lookup (message->priv->type, key); GType type = xed_message_type_lookup (message->priv->type, key);
if (type == G_TYPE_INVALID) if (type == G_TYPE_INVALID)
return NULL; return NULL;
value = g_new0 (GValue, 1); value = g_new0 (GValue, 1);
g_value_init (value, type); g_value_init (value, type);
g_value_reset (value); g_value_reset (value);
g_hash_table_insert (message->priv->values, g_strdup (key), value); g_hash_table_insert (message->priv->values, g_strdup (key), value);
return value; return value;
} }
@ -119,11 +119,11 @@ static void
xed_message_class_init (XedMessageClass *klass) xed_message_class_init (XedMessageClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS(klass); GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = xed_message_finalize; object_class->finalize = xed_message_finalize;
object_class->get_property = xed_message_get_property; object_class->get_property = xed_message_get_property;
object_class->set_property = xed_message_set_property; object_class->set_property = xed_message_set_property;
/** /**
* XedMessage:object_path: * XedMessage:object_path:
* *
@ -151,7 +151,7 @@ xed_message_class_init (XedMessageClass *klass)
NULL, NULL,
G_PARAM_READABLE | G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/** /**
* XedMEssage:type: * XedMEssage:type:
* *
@ -189,17 +189,17 @@ xed_message_init (XedMessage *self)
} }
static gboolean static gboolean
set_value_real (GValue *to, set_value_real (GValue *to,
const GValue *from) const GValue *from)
{ {
GType from_type; GType from_type;
GType to_type; GType to_type;
from_type = G_VALUE_TYPE (from); from_type = G_VALUE_TYPE (from);
to_type = G_VALUE_TYPE (to); to_type = G_VALUE_TYPE (to);
if (!g_type_is_a (from_type, to_type)) if (!g_type_is_a (from_type, to_type))
{ {
if (!g_value_transform (from, to)) if (!g_value_transform (from, to))
{ {
g_warning ("%s: Unable to make conversion from %s to %s", g_warning ("%s: Unable to make conversion from %s to %s",
@ -208,10 +208,10 @@ set_value_real (GValue *to,
g_type_name (to_type)); g_type_name (to_type));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
g_value_copy (from, to); g_value_copy (from, to);
return TRUE; return TRUE;
} }
@ -222,10 +222,10 @@ value_lookup (XedMessage *message,
gboolean create) gboolean create)
{ {
GValue *ret = (GValue *)g_hash_table_lookup (message->priv->values, key); GValue *ret = (GValue *)g_hash_table_lookup (message->priv->values, key);
if (!ret && create) if (!ret && create)
ret = add_value (message, key); ret = add_value (message, key);
return ret; return ret;
} }
@ -242,7 +242,7 @@ const gchar *
xed_message_get_method (XedMessage *message) xed_message_get_method (XedMessage *message)
{ {
g_return_val_if_fail (XED_IS_MESSAGE (message), NULL); g_return_val_if_fail (XED_IS_MESSAGE (message), NULL);
return xed_message_type_get_method (message->priv->type); return xed_message_type_get_method (message->priv->type);
} }
@ -259,7 +259,7 @@ const gchar *
xed_message_get_object_path (XedMessage *message) xed_message_get_object_path (XedMessage *message)
{ {
g_return_val_if_fail (XED_IS_MESSAGE (message), NULL); g_return_val_if_fail (XED_IS_MESSAGE (message), NULL);
return xed_message_type_get_object_path (message->priv->type); return xed_message_type_get_object_path (message->priv->type);
} }
@ -308,21 +308,21 @@ xed_message_set_valist (XedMessage *message,
GValue *container = value_lookup (message, key, TRUE); GValue *container = value_lookup (message, key, TRUE);
GValue value = {0,}; GValue value = {0,};
gchar *error = NULL; gchar *error = NULL;
if (!container) if (!container)
{ {
g_warning ("%s: Cannot set value for %s, does not exist", g_warning ("%s: Cannot set value for %s, does not exist",
G_STRLOC, G_STRLOC,
key); key);
/* skip value */ /* skip value */
va_arg (var_args, gpointer); va_arg (var_args, gpointer);
continue; continue;
} }
g_value_init (&value, G_VALUE_TYPE (container)); g_value_init (&value, G_VALUE_TYPE (container));
G_VALUE_COLLECT (&value, var_args, 0, &error); G_VALUE_COLLECT (&value, var_args, 0, &error);
if (error) if (error)
{ {
g_warning ("%s: %s", G_STRLOC, error); g_warning ("%s: %s", G_STRLOC, error);
@ -350,25 +350,25 @@ xed_message_set_value (XedMessage *message,
{ {
GValue *container; GValue *container;
g_return_if_fail (XED_IS_MESSAGE (message)); g_return_if_fail (XED_IS_MESSAGE (message));
container = value_lookup (message, key, TRUE); container = value_lookup (message, key, TRUE);
if (!container) if (!container)
{ {
g_warning ("%s: Cannot set value for %s, does not exist", g_warning ("%s: Cannot set value for %s, does not exist",
G_STRLOC, G_STRLOC,
key); key);
return; return;
} }
set_value_real (container, value); set_value_real (container, value);
} }
/** /**
* xed_message_set_valuesv: * xed_message_set_valuesv:
* @message: the #XedMessage * @message: the #XedMessage
* @keys: (array-length=n_values): keys to set values for * @keys: (array length=n_values): keys to set values for
* @values: (array-length=n_values): values to set * @values: (array length=n_values): values to set
* @n_values: number of arguments to set values for * @n_values: number of arguments to set values for
* *
* Set message argument values. * Set message argument values.
@ -381,9 +381,9 @@ xed_message_set_valuesv (XedMessage *message,
gint n_values) gint n_values)
{ {
gint i; gint i;
g_return_if_fail (XED_IS_MESSAGE (message)); g_return_if_fail (XED_IS_MESSAGE (message));
for (i = 0; i < n_values; i++) for (i = 0; i < n_values; i++)
{ {
xed_message_set_value (message, keys[i], &values[i]); xed_message_set_value (message, keys[i], &values[i]);
@ -401,14 +401,14 @@ xed_message_set_valuesv (XedMessage *message,
* value for the specified key. * value for the specified key.
* *
*/ */
void void
xed_message_get (XedMessage *message, xed_message_get (XedMessage *message,
...) ...)
{ {
va_list ap; va_list ap;
g_return_if_fail (XED_IS_MESSAGE (message)); g_return_if_fail (XED_IS_MESSAGE (message));
va_start (ap, message); va_start (ap, message);
xed_message_get_valist (message, ap); xed_message_get_valist (message, ap);
va_end (ap); va_end (ap);
@ -431,7 +431,7 @@ xed_message_get_valist (XedMessage *message,
const gchar *key; const gchar *key;
g_return_if_fail (XED_IS_MESSAGE (message)); g_return_if_fail (XED_IS_MESSAGE (message));
while ((key = va_arg (var_args, const gchar *)) != NULL) while ((key = va_arg (var_args, const gchar *)) != NULL)
{ {
GValue *container; GValue *container;
@ -439,30 +439,30 @@ xed_message_get_valist (XedMessage *message,
gchar *error = NULL; gchar *error = NULL;
container = value_lookup (message, key, FALSE); container = value_lookup (message, key, FALSE);
if (!container) if (!container)
{ {
/* skip value */ /* skip value */
va_arg (var_args, gpointer); va_arg (var_args, gpointer);
continue; continue;
} }
/* copy the value here, to be sure it isn't tainted */ /* copy the value here, to be sure it isn't tainted */
g_value_init (&copy, G_VALUE_TYPE (container)); g_value_init (&copy, G_VALUE_TYPE (container));
g_value_copy (container, &copy); g_value_copy (container, &copy);
G_VALUE_LCOPY (&copy, var_args, 0, &error); G_VALUE_LCOPY (&copy, var_args, 0, &error);
if (error) if (error)
{ {
g_warning ("%s: %s", G_STRLOC, error); g_warning ("%s: %s", G_STRLOC, error);
g_free (error); g_free (error);
/* purposely leak the value here, because it might /* purposely leak the value here, because it might
be in a bad state */ be in a bad state */
continue; continue;
} }
g_value_unset (&copy); g_value_unset (&copy);
} }
} }
@ -477,17 +477,17 @@ xed_message_get_valist (XedMessage *message,
* with the correct type. * with the correct type.
* *
*/ */
void void
xed_message_get_value (XedMessage *message, xed_message_get_value (XedMessage *message,
const gchar *key, const gchar *key,
GValue *value) GValue *value)
{ {
GValue *container; GValue *container;
g_return_if_fail (XED_IS_MESSAGE (message)); g_return_if_fail (XED_IS_MESSAGE (message));
container = value_lookup (message, key, FALSE); container = value_lookup (message, key, FALSE);
if (!container) if (!container)
{ {
g_warning ("%s: Invalid key `%s'", g_warning ("%s: Invalid key `%s'",
@ -495,7 +495,7 @@ xed_message_get_value (XedMessage *message,
key); key);
return; return;
} }
g_value_init (value, G_VALUE_TYPE (container)); g_value_init (value, G_VALUE_TYPE (container));
set_value_real (value, container); set_value_real (value, container);
} }
@ -510,7 +510,7 @@ xed_message_get_value (XedMessage *message,
* Return value: the type of @key * Return value: the type of @key
* *
*/ */
GType GType
xed_message_get_key_type (XedMessage *message, xed_message_get_key_type (XedMessage *message,
const gchar *key) const gchar *key)
{ {
@ -535,14 +535,14 @@ xed_message_has_key (XedMessage *message,
const gchar *key) const gchar *key)
{ {
g_return_val_if_fail (XED_IS_MESSAGE (message), FALSE); g_return_val_if_fail (XED_IS_MESSAGE (message), FALSE);
return value_lookup (message, key, FALSE) != NULL; return value_lookup (message, key, FALSE) != NULL;
} }
typedef struct typedef struct
{ {
XedMessage *message; XedMessage *message;
gboolean valid; gboolean valid;
} ValidateInfo; } ValidateInfo;
static void static void
@ -552,12 +552,12 @@ validate_key (const gchar *key,
ValidateInfo *info) ValidateInfo *info)
{ {
GValue *value; GValue *value;
if (!info->valid || !required) if (!info->valid || !required)
return; return;
value = value_lookup (info->message, key, FALSE); value = value_lookup (info->message, key, FALSE);
if (!value) if (!value)
info->valid = FALSE; info->valid = FALSE;
} }
@ -578,16 +578,16 @@ xed_message_validate (XedMessage *message)
g_return_val_if_fail (XED_IS_MESSAGE (message), FALSE); g_return_val_if_fail (XED_IS_MESSAGE (message), FALSE);
g_return_val_if_fail (message->priv->type != NULL, FALSE); g_return_val_if_fail (message->priv->type != NULL, FALSE);
if (!message->priv->valid) if (!message->priv->valid)
{ {
xed_message_type_foreach (message->priv->type, xed_message_type_foreach (message->priv->type,
(XedMessageTypeForeach)validate_key, (XedMessageTypeForeach)validate_key,
&info); &info);
message->priv->valid = info.valid; message->priv->valid = info.valid;
} }
return message->priv->valid; return message->priv->valid;
} }

View File

@ -36,7 +36,7 @@ struct _XedStatusComboBoxPrivate
GtkWidget *label; GtkWidget *label;
GtkWidget *item; GtkWidget *item;
GtkWidget *arrow; GtkWidget *arrow;
GtkWidget *menu; GtkWidget *menu;
GtkWidget *current_item; GtkWidget *current_item;
}; };
@ -54,10 +54,10 @@ enum
}; };
/* Properties */ /* Properties */
enum enum
{ {
PROP_0, PROP_0,
PROP_LABEL PROP_LABEL
}; };
@ -131,7 +131,7 @@ xed_status_combo_box_changed (XedStatusComboBox *combo,
GtkMenuItem *item) GtkMenuItem *item)
{ {
const gchar *text; const gchar *text;
text = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA); text = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA);
if (text != NULL) if (text != NULL)
@ -155,13 +155,13 @@ xed_status_combo_box_class_init (XedStatusComboBoxClass *klass)
"-GtkWidget-focus-padding : 0;\n" "-GtkWidget-focus-padding : 0;\n"
"padding: 0;\n" "padding: 0;\n"
"}"; "}";
object_class->finalize = xed_status_combo_box_finalize; object_class->finalize = xed_status_combo_box_finalize;
object_class->get_property = xed_status_combo_box_get_property; object_class->get_property = xed_status_combo_box_get_property;
object_class->set_property = xed_status_combo_box_set_property; object_class->set_property = xed_status_combo_box_set_property;
widget_class->destroy = xed_status_combo_box_destroy; widget_class->destroy = xed_status_combo_box_destroy;
klass->changed = xed_status_combo_box_changed; klass->changed = xed_status_combo_box_changed;
signals[CHANGED] = signals[CHANGED] =
@ -172,7 +172,7 @@ xed_status_combo_box_class_init (XedStatusComboBoxClass *klass)
changed), NULL, NULL, changed), NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GTK_TYPE_MENU_ITEM); GTK_TYPE_MENU_ITEM);
g_object_class_install_property (object_class, PROP_LABEL, g_object_class_install_property (object_class, PROP_LABEL,
g_param_spec_string ("label", g_param_spec_string ("label",
"LABEL", "LABEL",
@ -204,7 +204,7 @@ menu_position_func (GtkMenu *menu,
{ {
GtkRequisition request; GtkRequisition request;
GtkAllocation allocation; GtkAllocation allocation;
*push_in = FALSE; *push_in = FALSE;
gtk_widget_get_preferred_size (gtk_widget_get_toplevel (GTK_WIDGET (menu)), &request, NULL); gtk_widget_get_preferred_size (gtk_widget_get_toplevel (GTK_WIDGET (menu)), &request, NULL);
@ -212,13 +212,13 @@ menu_position_func (GtkMenu *menu,
/* get the origin... */ /* get the origin... */
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y); gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y);
gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation); gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
/* make the menu as wide as the widget */ /* make the menu as wide as the widget */
if (request.width < allocation.width) if (request.width < allocation.width)
{ {
gtk_widget_set_size_request (GTK_WIDGET (menu), allocation.width, -1); gtk_widget_set_size_request (GTK_WIDGET (menu), allocation.width, -1);
} }
/* position it above the widget */ /* position it above the widget */
*y -= request.height; *y -= request.height;
} }
@ -310,12 +310,12 @@ xed_status_combo_box_init (XedStatusComboBox *self)
GtkStyleContext *context; GtkStyleContext *context;
self->priv = XED_STATUS_COMBO_BOX_GET_PRIVATE (self); self->priv = XED_STATUS_COMBO_BOX_GET_PRIVATE (self);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE); gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE);
self->priv->frame = gtk_frame_new (NULL); self->priv->frame = gtk_frame_new (NULL);
gtk_widget_show (self->priv->frame); gtk_widget_show (self->priv->frame);
self->priv->button = gtk_toggle_button_new (); self->priv->button = gtk_toggle_button_new ();
gtk_button_set_relief (GTK_BUTTON (self->priv->button), GTK_RELIEF_NONE); gtk_button_set_relief (GTK_BUTTON (self->priv->button), GTK_RELIEF_NONE);
gtk_widget_show (self->priv->button); gtk_widget_show (self->priv->button);
@ -324,27 +324,27 @@ xed_status_combo_box_init (XedStatusComboBox *self)
self->priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3); self->priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_widget_show (self->priv->hbox); gtk_widget_show (self->priv->hbox);
gtk_container_add (GTK_CONTAINER (self), self->priv->frame); gtk_container_add (GTK_CONTAINER (self), self->priv->frame);
gtk_container_add (GTK_CONTAINER (self->priv->frame), self->priv->button); gtk_container_add (GTK_CONTAINER (self->priv->frame), self->priv->button);
gtk_container_add (GTK_CONTAINER (self->priv->button), self->priv->hbox); gtk_container_add (GTK_CONTAINER (self->priv->button), self->priv->hbox);
self->priv->label = gtk_label_new (""); self->priv->label = gtk_label_new ("");
gtk_widget_show (self->priv->label); gtk_widget_show (self->priv->label);
gtk_label_set_single_line_mode (GTK_LABEL (self->priv->label), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (self->priv->label), TRUE);
gtk_widget_set_halign (GTK_WIDGET (self->priv->label), GTK_ALIGN_START); gtk_widget_set_halign (GTK_WIDGET (self->priv->label), GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->label, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->label, FALSE, TRUE, 0);
self->priv->item = gtk_label_new (""); self->priv->item = gtk_label_new ("");
gtk_widget_show (self->priv->item); gtk_widget_show (self->priv->item);
gtk_label_set_single_line_mode (GTK_LABEL (self->priv->item), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (self->priv->item), TRUE);
gtk_widget_set_halign (self->priv->item, GTK_ALIGN_START); gtk_widget_set_halign (self->priv->item, GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->item, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->item, TRUE, TRUE, 0);
self->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); self->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_widget_show (self->priv->arrow); gtk_widget_show (self->priv->arrow);
@ -352,15 +352,15 @@ xed_status_combo_box_init (XedStatusComboBox *self)
gtk_widget_set_valign (self->priv->arrow, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->priv->arrow, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->arrow, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->arrow, FALSE, TRUE, 0);
self->priv->menu = gtk_menu_new (); self->priv->menu = gtk_menu_new ();
gtk_menu_attach_to_widget (GTK_MENU (self->priv->menu), gtk_menu_attach_to_widget (GTK_MENU (self->priv->menu),
GTK_WIDGET (self), GTK_WIDGET (self),
menu_detached); menu_detached);
g_signal_connect (self->priv->button, g_signal_connect (self->priv->button,
"button-press-event", "button-press-event",
G_CALLBACK (button_press_event), G_CALLBACK (button_press_event),
self); self);
g_signal_connect (self->priv->menu, g_signal_connect (self->priv->menu,
"deactivate", "deactivate",
@ -395,13 +395,13 @@ xed_status_combo_box_new (const gchar *label)
* @label: (allow-none): * @label: (allow-none):
*/ */
void void
xed_status_combo_box_set_label (XedStatusComboBox *combo, xed_status_combo_box_set_label (XedStatusComboBox *combo,
const gchar *label) const gchar *label)
{ {
gchar *text; gchar *text;
g_return_if_fail (XED_IS_STATUS_COMBO_BOX (combo)); g_return_if_fail (XED_IS_STATUS_COMBO_BOX (combo));
text = g_strconcat (" ", label, ": ", NULL); text = g_strconcat (" ", label, ": ", NULL);
gtk_label_set_markup (GTK_LABEL (combo->priv->label), text); gtk_label_set_markup (GTK_LABEL (combo->priv->label), text);
g_free (text); g_free (text);
@ -437,7 +437,7 @@ xed_status_combo_box_add_item (XedStatusComboBox *combo,
g_return_if_fail (GTK_IS_MENU_ITEM (item)); g_return_if_fail (GTK_IS_MENU_ITEM (item));
gtk_menu_shell_append (GTK_MENU_SHELL (combo->priv->menu), GTK_WIDGET (item)); gtk_menu_shell_append (GTK_MENU_SHELL (combo->priv->menu), GTK_WIDGET (item));
xed_status_combo_box_set_item_text (combo, item, text); xed_status_combo_box_set_item_text (combo, item, text);
g_signal_connect (item, "activate", G_CALLBACK (item_activated), combo); g_signal_connect (item, "activate", G_CALLBACK (item_activated), combo);
} }
@ -453,6 +453,13 @@ xed_status_combo_box_remove_item (XedStatusComboBox *combo,
GTK_WIDGET (item)); GTK_WIDGET (item));
} }
/**
* xed_status_combo_box_get_items:
* @combo:
*
* Returns: (element-type Gtk.Widget) (transfer container):
*/
GList * GList *
xed_status_combo_box_get_items (XedStatusComboBox *combo) xed_status_combo_box_get_items (XedStatusComboBox *combo)
{ {
@ -466,12 +473,12 @@ xed_status_combo_box_get_item_text (XedStatusComboBox *combo,
GtkMenuItem *item) GtkMenuItem *item)
{ {
const gchar *ret = NULL; const gchar *ret = NULL;
g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL); g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL);
g_return_val_if_fail (GTK_IS_MENU_ITEM (item), NULL); g_return_val_if_fail (GTK_IS_MENU_ITEM (item), NULL);
ret = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA); ret = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA);
return ret; return ret;
} }
@ -481,7 +488,7 @@ xed_status_combo_box_get_item_text (XedStatusComboBox *combo,
* @item: * @item:
* @text: (allow-none): * @text: (allow-none):
*/ */
void void
xed_status_combo_box_set_item_text (XedStatusComboBox *combo, xed_status_combo_box_set_item_text (XedStatusComboBox *combo,
GtkMenuItem *item, GtkMenuItem *item,
const gchar *text) const gchar *text)
@ -489,7 +496,7 @@ xed_status_combo_box_set_item_text (XedStatusComboBox *combo,
g_return_if_fail (XED_IS_STATUS_COMBO_BOX (combo)); g_return_if_fail (XED_IS_STATUS_COMBO_BOX (combo));
g_return_if_fail (GTK_IS_MENU_ITEM (item)); g_return_if_fail (GTK_IS_MENU_ITEM (item));
g_object_set_data_full (G_OBJECT (item), g_object_set_data_full (G_OBJECT (item),
COMBO_BOX_TEXT_DATA, COMBO_BOX_TEXT_DATA,
g_strdup (text), g_strdup (text),
(GDestroyNotify)g_free); (GDestroyNotify)g_free);
@ -509,7 +516,7 @@ GtkLabel *
xed_status_combo_box_get_item_label (XedStatusComboBox *combo) xed_status_combo_box_get_item_label (XedStatusComboBox *combo)
{ {
g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL); g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL);
return GTK_LABEL (combo->priv->item); return GTK_LABEL (combo->priv->item);
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@
* This file is part of xed * This file is part of xed
* *
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
* Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi
* Copyright (C) 2003-2005 Paolo Maggi * Copyright (C) 2003-2005 Paolo Maggi
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,14 +18,14 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, * Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
/* /*
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a * Modified by the xed Team, 1998-2005. See the AUTHORS file for a
* list of people on the xed Team. * list of people on the xed Team.
* See the ChangeLog files for a list of changes. * See the ChangeLog files for a list of changes.
* *
* $Id$ * $Id$
*/ */
@ -74,7 +74,7 @@ xed_utils_uri_has_file_scheme (const gchar *uri)
gfile = g_file_new_for_uri (uri); gfile = g_file_new_for_uri (uri);
res = g_file_has_uri_scheme (gfile, "file"); res = g_file_has_uri_scheme (gfile, "file");
g_object_unref (gfile); g_object_unref (gfile);
return res; return res;
} }
@ -163,7 +163,7 @@ xed_utils_menu_position_under_tree_view (GtkMenu *menu,
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreeIter iter; GtkTreeIter iter;
model = gtk_tree_view_get_model (tree); model = gtk_tree_view_get_model (tree);
g_return_if_fail (model != NULL); g_return_if_fail (model != NULL);
@ -176,16 +176,16 @@ xed_utils_menu_position_under_tree_view (GtkMenu *menu,
GdkRectangle rect; GdkRectangle rect;
widget_get_origin (GTK_WIDGET (tree), x, y); widget_get_origin (GTK_WIDGET (tree), x, y);
path = gtk_tree_model_get_path (model, &iter); path = gtk_tree_model_get_path (model, &iter);
gtk_tree_view_get_cell_area (tree, path, gtk_tree_view_get_cell_area (tree, path,
gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */ gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */
&rect); &rect);
gtk_tree_path_free (path); gtk_tree_path_free (path);
*x += rect.x; *x += rect.x;
*y += rect.y + rect.height; *y += rect.y + rect.height;
if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL)
{ {
GtkRequisition requisition; GtkRequisition requisition;
@ -204,15 +204,22 @@ xed_utils_menu_position_under_tree_view (GtkMenu *menu,
} }
/* FIXME: remove this with gtk 2.12, it has gdk_color_to_string */ /* FIXME: remove this with gtk 2.12, it has gdk_color_to_string */
gchar * gchar *
xed_gdk_color_to_string (GdkColor color) xed_gdk_color_to_string (GdkColor color)
{ {
return g_strdup_printf ("#%04x%04x%04x", return g_strdup_printf ("#%04x%04x%04x",
color.red, color.red,
color.green, color.green,
color.blue); color.blue);
} }
/**
* xed_gtk_button_new_with_stock_icon:
* @label:
* @stock_id:
*
* Returns: (transfer full):
*/
GtkWidget * GtkWidget *
xed_gtk_button_new_with_stock_icon (const gchar *label, xed_gtk_button_new_with_stock_icon (const gchar *label,
const gchar *stock_id) const gchar *stock_id)
@ -227,6 +234,15 @@ xed_gtk_button_new_with_stock_icon (const gchar *label,
return button; return button;
} }
/**
* xed_dialog_add_button:
* @dialog:
* @text:
* @stock_id:
* @response_id:
*
* Returns: (transfer none):
*/
GtkWidget * GtkWidget *
xed_dialog_add_button (GtkDialog *dialog, xed_dialog_add_button (GtkDialog *dialog,
const gchar *text, const gchar *text,
@ -246,7 +262,7 @@ xed_dialog_add_button (GtkDialog *dialog,
gtk_widget_show (button); gtk_widget_show (button);
gtk_dialog_add_action_widget (dialog, button, response_id); gtk_dialog_add_action_widget (dialog, button, response_id);
return button; return button;
} }
@ -254,7 +270,7 @@ xed_dialog_add_button (GtkDialog *dialog,
/* /*
* n: len of the string in bytes * n: len of the string in bytes
*/ */
gboolean gboolean
g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2) g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2)
{ {
gchar *casefold; gchar *casefold;
@ -284,10 +300,10 @@ g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2)
goto finally_2; goto finally_2;
ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0); ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0);
finally_2: finally_2:
g_free (normalized_s1); g_free (normalized_s1);
g_free (normalized_s2); g_free (normalized_s2);
return ret; return ret;
} }
@ -302,7 +318,7 @@ finally_2:
* for a specified gtk widget. * for a specified gtk widget.
*/ */
void void
xed_utils_set_atk_name_description (GtkWidget *widget, xed_utils_set_atk_name_description (GtkWidget *widget,
const gchar *name, const gchar *name,
const gchar *description) const gchar *description)
{ {
@ -330,8 +346,8 @@ xed_utils_set_atk_name_description (GtkWidget *widget,
* between 2 specified widgets. * between 2 specified widgets.
*/ */
void void
xed_utils_set_atk_relation (GtkWidget *obj1, xed_utils_set_atk_relation (GtkWidget *obj1,
GtkWidget *obj2, GtkWidget *obj2,
AtkRelationType rel_type ) AtkRelationType rel_type )
{ {
AtkObject *atk_obj1, *atk_obj2; AtkObject *atk_obj1, *atk_obj2;
@ -359,9 +375,9 @@ xed_utils_uri_exists (const gchar* text_uri)
{ {
GFile *gfile; GFile *gfile;
gboolean res; gboolean res;
g_return_val_if_fail (text_uri != NULL, FALSE); g_return_val_if_fail (text_uri != NULL, FALSE);
xed_debug_message (DEBUG_UTILS, "text_uri: %s", text_uri); xed_debug_message (DEBUG_UTILS, "text_uri: %s", text_uri);
gfile = g_file_new_for_uri (text_uri); gfile = g_file_new_for_uri (text_uri);
@ -439,7 +455,7 @@ xed_utils_unescape_search_text (const gchar *text)
const gchar *cur; const gchar *cur;
const gchar *end; const gchar *end;
const gchar *prev; const gchar *prev;
if (text == NULL) if (text == NULL)
return NULL; return NULL;
@ -450,15 +466,15 @@ xed_utils_unescape_search_text (const gchar *text)
cur = text; cur = text;
end = text + length; end = text + length;
prev = NULL; prev = NULL;
while (cur != end) while (cur != end)
{ {
const gchar *next; const gchar *next;
next = g_utf8_next_char (cur); next = g_utf8_next_char (cur);
if (prev && (*prev == '\\')) if (prev && (*prev == '\\'))
{ {
switch (*cur) switch (*cur)
{ {
case 'n': case 'n':
str = g_string_append (str, "\n"); str = g_string_append (str, "\n");
@ -478,21 +494,21 @@ xed_utils_unescape_search_text (const gchar *text)
str = g_string_append_len (str, cur, next - cur); str = g_string_append_len (str, cur, next - cur);
break; break;
} }
} }
else if (*cur != '\\') else if (*cur != '\\')
{ {
str = g_string_append_len (str, cur, next - cur); str = g_string_append_len (str, cur, next - cur);
} }
else if ((next == end) && (*cur == '\\')) else if ((next == end) && (*cur == '\\'))
{ {
str = g_string_append (str, "\\"); str = g_string_append (str, "\\");
} }
if (!drop_prev) if (!drop_prev)
{ {
prev = cur; prev = cur;
} }
else else
{ {
prev = NULL; prev = NULL;
drop_prev = FALSE; drop_prev = FALSE;
@ -504,19 +520,19 @@ xed_utils_unescape_search_text (const gchar *text)
return g_string_free (str, FALSE); return g_string_free (str, FALSE);
} }
void void
xed_warning (GtkWindow *parent, const gchar *format, ...) xed_warning (GtkWindow *parent, const gchar *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
GtkWidget *dialog; GtkWidget *dialog;
GtkWindowGroup *wg = NULL; GtkWindowGroup *wg = NULL;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
if (parent != NULL) if (parent != NULL)
wg = gtk_window_get_group (parent); wg = gtk_window_get_group (parent);
va_start (args, format); va_start (args, format);
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
@ -532,7 +548,7 @@ xed_warning (GtkWindow *parent, const gchar *format, ...)
if (wg != NULL) if (wg != NULL)
gtk_window_group_add_window (wg, GTK_WINDOW (dialog)); gtk_window_group_add_window (wg, GTK_WINDOW (dialog));
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@ -541,14 +557,14 @@ xed_warning (GtkWindow *parent, const gchar *format, ...)
"response", "response",
G_CALLBACK (gtk_widget_destroy), G_CALLBACK (gtk_widget_destroy),
NULL); NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
/* /*
* Doubles underscore to avoid spurious menu accels. * Doubles underscore to avoid spurious menu accels.
*/ */
gchar * gchar *
xed_utils_escape_underscores (const gchar* text, xed_utils_escape_underscores (const gchar* text,
gssize length) gssize length)
{ {
@ -642,7 +658,7 @@ xed_utils_str_truncate (const gchar *string,
g_utf8_offset_to_pointer (string, num_left_chars) - string); g_utf8_offset_to_pointer (string, num_left_chars) - string);
g_string_append (truncated, delimiter); g_string_append (truncated, delimiter);
} }
return g_string_free (truncated, FALSE); return g_string_free (truncated, FALSE);
} }
@ -695,7 +711,7 @@ xed_utils_make_valid_utf8 (const char *name)
} }
g_string_append (string, remainder); g_string_append (string, remainder);
g_assert (g_utf8_validate (string->str, -1, NULL)); g_assert (g_utf8_validate (string->str, -1, NULL));
return g_string_free (string, FALSE); return g_string_free (string, FALSE);
@ -721,14 +737,14 @@ xed_utils_uri_get_dirname (const gchar *uri)
if ((strlen (str) == 1) && (*str == '.')) if ((strlen (str) == 1) && (*str == '.'))
{ {
g_free (str); g_free (str);
return NULL; return NULL;
} }
res = xed_utils_replace_home_dir_with_tilde (str); res = xed_utils_replace_home_dir_with_tilde (str);
g_free (str); g_free (str);
return res; return res;
} }
@ -827,7 +843,7 @@ xed_utils_replace_home_dir_with_tilde (const gchar *uri)
if (strcmp (uri, home) == 0) if (strcmp (uri, home) == 0)
{ {
g_free (home); g_free (home);
return g_strdup ("~"); return g_strdup ("~");
} }
@ -842,8 +858,8 @@ xed_utils_replace_home_dir_with_tilde (const gchar *uri)
res = g_strdup_printf ("~/%s", uri + strlen (home)); res = g_strdup_printf ("~/%s", uri + strlen (home));
g_free (home); g_free (home);
return res; return res;
} }
g_free (home); g_free (home);
@ -1059,7 +1075,7 @@ xed_utils_is_valid_uri (const gchar *uri)
if (!g_ascii_isxdigit (*p)) if (!g_ascii_isxdigit (*p))
return FALSE; return FALSE;
++p; ++p;
if (!g_ascii_isxdigit (*p)) if (!g_ascii_isxdigit (*p))
return FALSE; return FALSE;
} }
@ -1146,12 +1162,12 @@ xed_utils_get_ui_objects (const gchar *filename,
*error_widget = NULL; *error_widget = NULL;
builder = gtk_builder_new (); builder = gtk_builder_new ();
if (root_objects != NULL) if (root_objects != NULL)
{ {
gtk_builder_add_objects_from_file (builder, gtk_builder_add_objects_from_file (builder,
filename, filename,
root_objects, root_objects,
&error); &error);
} }
else else
@ -1183,8 +1199,8 @@ xed_utils_get_ui_objects (const gchar *filename,
if (!*gobj) if (!*gobj)
{ {
*error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."), *error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."),
name, name,
filename_markup), filename_markup),
ret = FALSE; ret = FALSE;
break; break;
@ -1215,25 +1231,25 @@ xed_utils_get_ui_objects (const gchar *filename,
gchar * gchar *
xed_utils_make_canonical_uri_from_shell_arg (const gchar *str) xed_utils_make_canonical_uri_from_shell_arg (const gchar *str)
{ {
GFile *gfile; GFile *gfile;
gchar *uri; gchar *uri;
g_return_val_if_fail (str != NULL, NULL); g_return_val_if_fail (str != NULL, NULL);
g_return_val_if_fail (*str != '\0', NULL); g_return_val_if_fail (*str != '\0', NULL);
/* Note for the future: /* Note for the future:
* FIXME: is still still relevant? * FIXME: is still still relevant?
* *
* <federico> paolo: and flame whoever tells * <federico> paolo: and flame whoever tells
* you that file:///mate/test_files/hëllò * you that file:///mate/test_files/hëllò
* doesn't work --- that's not a valid URI * doesn't work --- that's not a valid URI
* *
* <paolo> federico: well, another solution that * <paolo> federico: well, another solution that
* does not requires patch to _from_shell_args * does not requires patch to _from_shell_args
* is to check that the string returned by it * is to check that the string returned by it
* contains only ASCII chars * contains only ASCII chars
* <federico> paolo: hmmmm, isn't there * <federico> paolo: hmmmm, isn't there
* mate_vfs_is_uri_valid() or something? * mate_vfs_is_uri_valid() or something?
* <paolo>: I will use xed_utils_is_valid_uri () * <paolo>: I will use xed_utils_is_valid_uri ()
* *
@ -1245,7 +1261,7 @@ xed_utils_make_canonical_uri_from_shell_arg (const gchar *str)
if (xed_utils_is_valid_uri (uri)) if (xed_utils_is_valid_uri (uri))
return uri; return uri;
g_free (uri); g_free (uri);
return NULL; return NULL;
} }
@ -1262,13 +1278,13 @@ xed_utils_file_has_parent (GFile *gfile)
{ {
GFile *parent; GFile *parent;
gboolean ret; gboolean ret;
parent = g_file_get_parent (gfile); parent = g_file_get_parent (gfile);
ret = parent != NULL; ret = parent != NULL;
if (parent) if (parent)
g_object_unref (parent); g_object_unref (parent);
return ret; return ret;
} }
@ -1294,9 +1310,9 @@ xed_utils_basename_for_display (gchar const *uri)
{ {
GFileInfo *info; GFileInfo *info;
info = g_file_query_info (gfile, info = g_file_query_info (gfile,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
NULL, NULL,
NULL); NULL);
if (info) if (info)
@ -1310,7 +1326,7 @@ xed_utils_basename_for_display (gchar const *uri)
/* This is a local file, and therefore we will use /* This is a local file, and therefore we will use
* g_filename_display_basename on the local path */ * g_filename_display_basename on the local path */
gchar *local_path; gchar *local_path;
local_path = g_file_get_path (gfile); local_path = g_file_get_path (gfile);
name = g_filename_display_basename (local_path); name = g_filename_display_basename (local_path);
g_free (local_path); g_free (local_path);
@ -1327,8 +1343,8 @@ xed_utils_basename_for_display (gchar const *uri)
parse_name = g_file_get_parse_name (gfile); parse_name = g_file_get_parse_name (gfile);
base = g_filename_display_basename (parse_name); base = g_filename_display_basename (parse_name);
name = g_uri_unescape_string (base, NULL); name = g_uri_unescape_string (base, NULL);
g_free (base); g_free (base);
g_free (parse_name); g_free (parse_name);
} }
else else
@ -1360,7 +1376,7 @@ xed_utils_basename_for_display (gchar const *uri)
* *
* Filter, modify, unescape and change @uri to make it appropriate * Filter, modify, unescape and change @uri to make it appropriate
* for display to users. * for display to users.
* *
* This function is a convenient wrapper for g_file_get_parse_name * This function is a convenient wrapper for g_file_get_parse_name
* *
* Return value: a string which represents @uri and can be displayed. * Return value: a string which represents @uri and can be displayed.
@ -1383,9 +1399,9 @@ xed_utils_uri_for_display (const gchar *uri)
* @selection_data: the #GtkSelectionData from drag_data_received * @selection_data: the #GtkSelectionData from drag_data_received
* *
* Create a list of valid uri's from a uri-list drop. * Create a list of valid uri's from a uri-list drop.
* *
* Return value: a string array which will hold the uris or %NULL if there * Return value: (transfer full): a string array which will hold the uris or %NULL if there
* were no valid uris. g_strfreev should be used when the * were no valid uris. g_strfreev should be used when the
* string array is no longer used * string array is no longer used
*/ */
gchar ** gchar **
@ -1402,9 +1418,9 @@ xed_utils_drop_get_uris (GtkSelectionData *selection_data)
for (i = 0; uris[i] != NULL; i++) for (i = 0; uris[i] != NULL; i++)
{ {
gchar *uri; gchar *uri;
uri = xed_utils_make_canonical_uri_from_shell_arg (uris[i]); uri = xed_utils_make_canonical_uri_from_shell_arg (uris[i]);
/* Silently ignore malformed URI/filename */ /* Silently ignore malformed URI/filename */
if (uri != NULL) if (uri != NULL)
uri_list[p++] = uri; uri_list[p++] = uri;
@ -1442,7 +1458,7 @@ null_ptr (gchar **ptr)
* scheme, user info, port, host and path. The return value pointer can be * scheme, user info, port, host and path. The return value pointer can be
* %NULL to ignore certain parts of the uri. If the function returns %TRUE, then * %NULL to ignore certain parts of the uri. If the function returns %TRUE, then
* all return value pointers should be freed using g_free * all return value pointers should be freed using g_free
* *
* Return value: %TRUE if the uri could be properly decoded, %FALSE otherwise. * Return value: %TRUE if the uri could be properly decoded, %FALSE otherwise.
*/ */
gboolean gboolean
@ -1454,7 +1470,7 @@ xed_utils_decode_uri (const gchar *uri,
gchar **path gchar **path
) )
{ {
/* Largely copied from glib/gio/gdummyfile.c:_g_decode_uri. This /* Largely copied from glib/gio/gdummyfile.c:_g_decode_uri. This
* functionality should be in glib/gio, but for now we implement it * functionality should be in glib/gio, but for now we implement it
* ourselves (see bug #546182) */ * ourselves (see bug #546182) */
@ -1464,10 +1480,10 @@ xed_utils_decode_uri (const gchar *uri,
/* From RFC 3986 Decodes: /* From RFC 3986 Decodes:
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
*/ */
p = uri; p = uri;
null_ptr (scheme); null_ptr (scheme);
null_ptr (user); null_ptr (user);
null_ptr (port); null_ptr (port);
@ -1494,32 +1510,32 @@ xed_utils_decode_uri (const gchar *uri,
c == '.')) c == '.'))
return FALSE; return FALSE;
} }
if (scheme) if (scheme)
{ {
*scheme = g_malloc (p - uri); *scheme = g_malloc (p - uri);
out = *scheme; out = *scheme;
for (in = uri; in < p - 1; in++) for (in = uri; in < p - 1; in++)
*out++ = g_ascii_tolower (*in); *out++ = g_ascii_tolower (*in);
*out = '\0'; *out = '\0';
} }
hier_part_start = p; hier_part_start = p;
hier_part_end = p + strlen (p); hier_part_end = p + strlen (p);
if (hier_part_start[0] == '/' && hier_part_start[1] == '/') if (hier_part_start[0] == '/' && hier_part_start[1] == '/')
{ {
const char *authority_start, *authority_end; const char *authority_start, *authority_end;
const char *userinfo_start, *userinfo_end; const char *userinfo_start, *userinfo_end;
const char *host_start, *host_end; const char *host_start, *host_end;
const char *port_start; const char *port_start;
authority_start = hier_part_start + 2; authority_start = hier_part_start + 2;
/* authority is always followed by / or nothing */ /* authority is always followed by / or nothing */
authority_end = memchr (authority_start, '/', hier_part_end - authority_start); authority_end = memchr (authority_start, '/', hier_part_end - authority_start);
if (authority_end == NULL) if (authority_end == NULL)
authority_end = hier_part_end; authority_end = hier_part_end;
@ -1528,14 +1544,14 @@ xed_utils_decode_uri (const gchar *uri,
*/ */
userinfo_end = memchr (authority_start, '@', authority_end - authority_start); userinfo_end = memchr (authority_start, '@', authority_end - authority_start);
if (userinfo_end) if (userinfo_end)
{ {
userinfo_start = authority_start; userinfo_start = authority_start;
if (user) if (user)
*user = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL); *user = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL);
if (user && *user == NULL) if (user && *user == NULL)
{ {
if (scheme) if (scheme)
@ -1543,7 +1559,7 @@ xed_utils_decode_uri (const gchar *uri,
return FALSE; return FALSE;
} }
host_start = userinfo_end + 1; host_start = userinfo_end + 1;
} }
else else
@ -1569,6 +1585,6 @@ xed_utils_decode_uri (const gchar *uri,
if (path) if (path)
*path = g_uri_unescape_segment (hier_part_start, hier_part_end, "/"); *path = g_uri_unescape_segment (hier_part_start, hier_part_end, "/");
return TRUE; return TRUE;
} }

View File

@ -3395,7 +3395,7 @@ xed_window_init (XedWindow *window)
* *
* Gets the active #XedView. * Gets the active #XedView.
* *
* Returns: the active #XedView * Returns: (transfer none): the active #XedView
*/ */
XedView * XedView *
xed_window_get_active_view (XedWindow *window) xed_window_get_active_view (XedWindow *window)
@ -3423,7 +3423,7 @@ xed_window_get_active_view (XedWindow *window)
* *
* Gets the active #XedDocument. * Gets the active #XedDocument.
* *
* Returns: the active #XedDocument * Returns: (transfer none): the active #XedDocument
*/ */
XedDocument * XedDocument *
xed_window_get_active_document (XedWindow *window) xed_window_get_active_document (XedWindow *window)
@ -3460,7 +3460,7 @@ _xed_window_get_notebook (XedWindow *window)
* Creates a new #XedTab and adds the new tab to the #XedNotebook. * Creates a new #XedTab and adds the new tab to the #XedNotebook.
* In case @jump_to is %TRUE the #XedNotebook switches to that new #XedTab. * In case @jump_to is %TRUE the #XedNotebook switches to that new #XedTab.
* *
* Returns: a new #XedTab * Returns: (transfer none): a new #XedTab
*/ */
XedTab * XedTab *
xed_window_create_tab (XedWindow *window, xed_window_create_tab (XedWindow *window,
@ -3497,7 +3497,7 @@ xed_window_create_tab (XedWindow *window,
* Whether @create is %TRUE, creates a new empty document if location does * Whether @create is %TRUE, creates a new empty document if location does
* not refer to an existing file * not refer to an existing file
* *
* Returns: a new #XedTab * Returns: (transfer none): a new #XedTab
*/ */
XedTab * XedTab *
xed_window_create_tab_from_uri (XedWindow *window, xed_window_create_tab_from_uri (XedWindow *window,
@ -3536,7 +3536,7 @@ xed_window_create_tab_from_uri (XedWindow *window,
* *
* Gets the active #XedTab in the @window. * Gets the active #XedTab in the @window.
* *
* Returns: the active #XedTab in the @window. * Returns: (transfer none): the active #XedTab in the @window.
*/ */
XedTab * XedTab *
xed_window_get_active_tab (XedWindow *window) xed_window_get_active_tab (XedWindow *window)
@ -3729,7 +3729,7 @@ xed_window_set_active_tab (XedWindow *window,
* *
* Gets the #GtkWindowGroup in which @window resides. * Gets the #GtkWindowGroup in which @window resides.
* *
* Returns: the #GtkWindowGroup * Returns: (transfer none): the #GtkWindowGroup
*/ */
GtkWindowGroup * GtkWindowGroup *
xed_window_get_group (XedWindow *window) xed_window_get_group (XedWindow *window)
@ -3751,7 +3751,7 @@ _xed_window_is_removing_tabs (XedWindow *window)
* *
* Gets the #GtkUIManager associated with the @window. * Gets the #GtkUIManager associated with the @window.
* *
* Returns: the #GtkUIManager of the @window. * Returns: (transfer none): the #GtkUIManager of the @window.
*/ */
GtkUIManager * GtkUIManager *
xed_window_get_ui_manager (XedWindow *window) xed_window_get_ui_manager (XedWindow *window)
@ -3766,7 +3766,7 @@ xed_window_get_ui_manager (XedWindow *window)
* *
* Gets the side #XedPanel of the @window. * Gets the side #XedPanel of the @window.
* *
* Returns: the side #XedPanel. * Returns: (transfer none): the side #XedPanel.
*/ */
XedPanel * XedPanel *
xed_window_get_side_panel (XedWindow *window) xed_window_get_side_panel (XedWindow *window)
@ -3781,7 +3781,7 @@ xed_window_get_side_panel (XedWindow *window)
* *
* Gets the bottom #XedPanel of the @window. * Gets the bottom #XedPanel of the @window.
* *
* Returns: the bottom #XedPanel. * Returns: (transfer none): the bottom #XedPanel.
*/ */
XedPanel * XedPanel *
xed_window_get_bottom_panel (XedWindow *window) xed_window_get_bottom_panel (XedWindow *window)
@ -3796,7 +3796,7 @@ xed_window_get_bottom_panel (XedWindow *window)
* *
* Gets the #XedStatusbar of the @window. * Gets the #XedStatusbar of the @window.
* *
* Returns: the #XedStatusbar of the @window. * Returns: (transfer none): the #XedStatusbar of the @window.
*/ */
GtkWidget * GtkWidget *
xed_window_get_statusbar (XedWindow *window) xed_window_get_statusbar (XedWindow *window)
@ -3809,9 +3809,9 @@ xed_window_get_statusbar (XedWindow *window)
* xed_window_get_searchbar: * xed_window_get_searchbar:
* @window: a #XedWindow * @window: a #XedWindow
* *
* Gets the #XedSearchDialog of the @window. * Gets the #XedSearchbar of the @window.
* *
* Returns: the #XedSearchDialog of the @window. * Returns: (transfer none): the #XedSearchbar of the @window.
*/ */
GtkWidget * GtkWidget *
xed_window_get_searchbar (XedWindow *window) xed_window_get_searchbar (XedWindow *window)
@ -4084,7 +4084,7 @@ xed_window_get_message_bus (XedWindow *window)
* *
* Gets the #XedTab that matches @uri. * Gets the #XedTab that matches @uri.
* *
* Returns: the #XedTab associated with @uri. * Returns: (transfer none): the #XedTab associated with @uri.
* *
* Deprecated: 2.24: Use xed_window_get_tab_from_location() instead. * Deprecated: 2.24: Use xed_window_get_tab_from_location() instead.
*/ */