parent
c6f5fd5e1d
commit
7a6db1f8c5
|
@ -329,7 +329,7 @@ app_weak_notify (gpointer data,
|
|||
* Returns the #XedApp object. This object is a singleton and
|
||||
* represents the running xed instance.
|
||||
*
|
||||
* Return value: the #XedApp pointer
|
||||
* Return value: (transfer none): the #XedApp pointer
|
||||
*/
|
||||
XedApp *
|
||||
xed_app_get_default (void)
|
||||
|
@ -527,7 +527,7 @@ xed_app_create_window_real (XedApp *app,
|
|||
*
|
||||
* Create a new #XedWindow part of @app.
|
||||
*
|
||||
* Return value: the new #XedWindow
|
||||
* Return value: (transfer none): the new #XedWindow
|
||||
*/
|
||||
XedWindow *
|
||||
xed_app_create_window (XedApp *app,
|
||||
|
@ -566,7 +566,7 @@ _xed_app_restore_window (XedApp *app,
|
|||
*
|
||||
* 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
|
||||
*/
|
||||
const GList *
|
||||
|
@ -583,7 +583,7 @@ xed_app_get_windows (XedApp *app)
|
|||
*
|
||||
* Retrives the #XedWindow currently active.
|
||||
*
|
||||
* Return value: the active #XedWindow
|
||||
* Return value: (transfer none): the active #XedWindow
|
||||
*/
|
||||
XedWindow *
|
||||
xed_app_get_active_window (XedApp *app)
|
||||
|
|
|
@ -1036,6 +1036,12 @@ set_uri (XedDocument *doc,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_document_get_location:
|
||||
* @doc: a #XedDocument
|
||||
*
|
||||
* Returns: (allow-none) (transfer full): a new #GFile
|
||||
*/
|
||||
GFile *
|
||||
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:
|
||||
* @text: (allow-none):
|
||||
* @flags:
|
||||
|
@ -1835,7 +1841,7 @@ xed_document_get_can_search_again (XedDocument *doc)
|
|||
* @start: (allow-none):
|
||||
* @end: (allow-none):
|
||||
* @match_start: (allow-none):
|
||||
* @match_end: (allow=none):
|
||||
* @match_end: (allow-none):
|
||||
**/
|
||||
gboolean
|
||||
xed_document_search_forward (XedDocument *doc,
|
||||
|
@ -1920,7 +1926,7 @@ xed_document_search_forward (XedDocument *doc,
|
|||
* @start: (allow-none):
|
||||
* @end: (allow-none):
|
||||
* @match_start: (allow-none):
|
||||
* @match_end: (allow=none):
|
||||
* @match_end: (allow-none):
|
||||
**/
|
||||
gboolean
|
||||
xed_document_search_backward (XedDocument *doc,
|
||||
|
@ -2130,6 +2136,12 @@ xed_document_set_language (XedDocument *doc,
|
|||
set_language (doc, lang, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_document_get_language:
|
||||
* @doc:
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
*/
|
||||
GtkSourceLanguage *
|
||||
xed_document_get_language (XedDocument *doc)
|
||||
{
|
||||
|
|
|
@ -455,7 +455,7 @@ xed_file_chooser_dialog_new_valist (const gchar *title,
|
|||
* @action: Open or save mode for the dialog
|
||||
* @first_button_text: (allow-none): stock ID or text to go in
|
||||
* 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
|
||||
*
|
||||
* Creates a new #XedFileChooserDialog. This function is analogous to
|
||||
|
|
|
@ -532,7 +532,7 @@ xed_message_bus_init (XedMessageBus *self)
|
|||
*
|
||||
* Get the default application #XedMessageBus.
|
||||
*
|
||||
* Return value: the default #XedMessageBus
|
||||
* Return value: (transfer none): the default #XedMessageBus
|
||||
*
|
||||
*/
|
||||
XedMessageBus *
|
||||
|
@ -797,7 +797,7 @@ foreach_type (const gchar *key,
|
|||
/**
|
||||
* xed_message_bus_foreach:
|
||||
* @bus: the #XedMessagebus
|
||||
* @func: the callback function
|
||||
* @func: (scope call): the callback function
|
||||
* @userdata: the user data to supply to the callback function
|
||||
*
|
||||
* Calls @func for each message type registered on the bus
|
||||
|
@ -875,7 +875,7 @@ xed_message_bus_disconnect (XedMessageBus *bus,
|
|||
* @bus: a #XedMessageBus
|
||||
* @object_path: the object path
|
||||
* @method: the method
|
||||
* @callback: the connected callback
|
||||
* @callback: (scope call): the connected callback
|
||||
* @userdata: the userdata with which the callback was connected
|
||||
*
|
||||
* Disconnects a previously connected message callback by matching the
|
||||
|
@ -918,7 +918,7 @@ xed_message_bus_block (XedMessageBus *bus,
|
|||
* @bus: a #XedMessageBus
|
||||
* @object_path: the object path
|
||||
* @method: the method
|
||||
* @callback: the callback to block
|
||||
* @callback: (scope call): the callback to block
|
||||
* @userdata: the userdata with which the callback was connected
|
||||
*
|
||||
* Blocks evoking the callback that matches provided @callback and @userdata.
|
||||
|
@ -959,7 +959,7 @@ xed_message_bus_unblock (XedMessageBus *bus,
|
|||
* @bus: a #XedMessageBus
|
||||
* @object_path: the object path
|
||||
* @method: the method
|
||||
* @callback: the callback to block
|
||||
* @callback: (scope call): the callback to block
|
||||
* @userdata: the userdata with which the callback was connected
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* it is no longer needed
|
||||
*/
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
* the Object Path, Method and Arguments of the message.
|
||||
*
|
||||
* 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().
|
||||
*
|
||||
* Registering a new message type on a #XedMessageBus with
|
||||
* 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.
|
||||
*
|
||||
* <example>
|
||||
|
@ -50,10 +50,10 @@ struct _XedMessageType
|
|||
|
||||
gchar *object_path;
|
||||
gchar *method;
|
||||
|
||||
|
||||
guint num_arguments;
|
||||
guint num_required;
|
||||
|
||||
|
||||
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_atomic_int_inc (&message_type->ref_count);
|
||||
|
||||
|
||||
return message_type;
|
||||
}
|
||||
|
||||
|
@ -83,30 +83,30 @@ xed_message_type_ref (XedMessageType *message_type)
|
|||
* drops to 0, @message_type is destroyed.
|
||||
*
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_message_type_unref (XedMessageType *message_type)
|
||||
{
|
||||
g_return_if_fail (message_type != NULL);
|
||||
|
||||
if (!g_atomic_int_dec_and_test (&message_type->ref_count))
|
||||
return;
|
||||
|
||||
|
||||
g_free (message_type->object_path);
|
||||
g_free (message_type->method);
|
||||
|
||||
|
||||
g_hash_table_destroy (message_type->arguments);
|
||||
g_free (message_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_message_type_get_type:
|
||||
*
|
||||
*
|
||||
* Retrieves the GType object which is associated with the
|
||||
* #XedMessageType class.
|
||||
*
|
||||
*
|
||||
* Return value: the GType associated with #XedMessageType.
|
||||
**/
|
||||
GType
|
||||
GType
|
||||
xed_message_type_get_type (void)
|
||||
{
|
||||
static GType our_type = 0;
|
||||
|
@ -151,17 +151,17 @@ xed_message_type_is_valid_object_path (const gchar *object_path)
|
|||
{
|
||||
if (!object_path)
|
||||
return FALSE;
|
||||
|
||||
|
||||
/* needs to start with / */
|
||||
if (*object_path != '/')
|
||||
return FALSE;
|
||||
|
||||
|
||||
while (*object_path)
|
||||
{
|
||||
if (*object_path == '/')
|
||||
{
|
||||
++object_path;
|
||||
|
||||
|
||||
if (!*object_path || !(g_ascii_isalpha (*object_path) || *object_path == '_'))
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -169,10 +169,10 @@ xed_message_type_is_valid_object_path (const gchar *object_path)
|
|||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
++object_path;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ gboolean
|
|||
xed_message_type_is_supported (GType type)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
|
||||
static const GType type_list[] =
|
||||
{
|
||||
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);
|
||||
|
||||
message_type = g_new0(XedMessageType, 1);
|
||||
|
||||
|
||||
message_type->ref_count = 1;
|
||||
message_type->object_path = g_strdup(object_path);
|
||||
message_type->method = g_strdup(method);
|
||||
|
@ -288,11 +288,11 @@ xed_message_type_new (const gchar *object_path,
|
|||
{
|
||||
XedMessageType *message_type;
|
||||
va_list var_args;
|
||||
|
||||
|
||||
va_start(var_args, num_optional);
|
||||
message_type = xed_message_type_new_valist (object_path, method, num_optional, var_args);
|
||||
va_end(var_args);
|
||||
|
||||
|
||||
return message_type;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ xed_message_type_set (XedMessageType *message_type,
|
|||
...)
|
||||
{
|
||||
va_list va_args;
|
||||
|
||||
|
||||
va_start (va_args, num_optional);
|
||||
xed_message_type_set_valist (message_type, num_optional, 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
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_message_type_set_valist (XedMessageType *message_type,
|
||||
guint num_optional,
|
||||
va_list var_args)
|
||||
|
@ -346,35 +346,35 @@ xed_message_type_set_valist (XedMessageType *message_type,
|
|||
// get corresponding GType
|
||||
GType gtype = va_arg (var_args, GType);
|
||||
ArgumentInfo *info;
|
||||
|
||||
|
||||
if (!xed_message_type_is_supported (gtype))
|
||||
{
|
||||
g_error ("Message type '%s' is not supported", g_type_name (gtype));
|
||||
|
||||
xed_message_type_unref (message_type);
|
||||
g_free (optional);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
info = g_new(ArgumentInfo, 1);
|
||||
info->type = gtype;
|
||||
info->required = TRUE;
|
||||
|
||||
g_hash_table_insert (message_type->arguments, g_strdup (key), info);
|
||||
|
||||
|
||||
++message_type->num_arguments;
|
||||
++added;
|
||||
|
||||
|
||||
if (num_optional > 0)
|
||||
{
|
||||
for (i = num_optional - 1; i > 0; --i)
|
||||
optional[i] = optional[i - 1];
|
||||
|
||||
|
||||
*optional = info;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message_type->num_required += added;
|
||||
|
||||
// set required for last num_optional arguments
|
||||
|
@ -386,7 +386,7 @@ xed_message_type_set_valist (XedMessageType *message_type,
|
|||
--message_type->num_required;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
* for the message arguments.
|
||||
*
|
||||
* Return value: the newly created message
|
||||
* Return value: (transfer full): the newly created message
|
||||
*
|
||||
*/
|
||||
XedMessage *
|
||||
|
@ -406,12 +406,12 @@ xed_message_type_instantiate_valist (XedMessageType *message_type,
|
|||
va_list va_args)
|
||||
{
|
||||
XedMessage *message;
|
||||
|
||||
|
||||
g_return_val_if_fail (message_type != NULL, NULL);
|
||||
|
||||
|
||||
message = XED_MESSAGE (g_object_new (XED_TYPE_MESSAGE, "type", message_type, NULL));
|
||||
xed_message_set_valist (message, va_args);
|
||||
|
||||
|
||||
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
|
||||
* for the message arguments.
|
||||
*
|
||||
* Return value: the newly created message
|
||||
* Return value: (transfer full): the newly created message
|
||||
*
|
||||
*/
|
||||
XedMessage *
|
||||
|
@ -432,11 +432,11 @@ xed_message_type_instantiate (XedMessageType *message_type,
|
|||
{
|
||||
XedMessage *message;
|
||||
va_list va_args;
|
||||
|
||||
|
||||
va_start (va_args, message_type);
|
||||
message = xed_message_type_instantiate_valist (message_type, va_args);
|
||||
va_end (va_args);
|
||||
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
@ -485,10 +485,10 @@ xed_message_type_lookup (XedMessageType *message_type,
|
|||
const gchar *key)
|
||||
{
|
||||
ArgumentInfo *info = g_hash_table_lookup (message_type->arguments, key);
|
||||
|
||||
|
||||
if (!info)
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
|
||||
return info->type;
|
||||
}
|
||||
|
||||
|
@ -509,13 +509,13 @@ foreach_gtype (const gchar *key,
|
|||
/**
|
||||
* xed_message_type_foreach:
|
||||
* @message_type: the #XedMessageType
|
||||
* @func: the callback function
|
||||
* @func: (scope call): the callback function
|
||||
* @user_data: user data supplied to the callback function
|
||||
*
|
||||
* Calls @func for each argument in the message type.
|
||||
*
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_message_type_foreach (XedMessageType *message_type,
|
||||
XedMessageTypeForeach func,
|
||||
gpointer user_data)
|
||||
|
|
|
@ -45,7 +45,7 @@ static void
|
|||
xed_message_finalize (GObject *object)
|
||||
{
|
||||
XedMessage *message = XED_MESSAGE (object);
|
||||
|
||||
|
||||
xed_message_type_unref (message->priv->type);
|
||||
g_hash_table_destroy (message->priv->values);
|
||||
|
||||
|
@ -102,16 +102,16 @@ add_value (XedMessage *message,
|
|||
{
|
||||
GValue *value;
|
||||
GType type = xed_message_type_lookup (message->priv->type, key);
|
||||
|
||||
|
||||
if (type == G_TYPE_INVALID)
|
||||
return NULL;
|
||||
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
g_value_init (value, type);
|
||||
g_value_reset (value);
|
||||
|
||||
g_hash_table_insert (message->priv->values, g_strdup (key), value);
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -119,11 +119,11 @@ static void
|
|||
xed_message_class_init (XedMessageClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
|
||||
object_class->finalize = xed_message_finalize;
|
||||
object_class->get_property = xed_message_get_property;
|
||||
object_class->set_property = xed_message_set_property;
|
||||
|
||||
|
||||
/**
|
||||
* XedMessage:object_path:
|
||||
*
|
||||
|
@ -151,7 +151,7 @@ xed_message_class_init (XedMessageClass *klass)
|
|||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
||||
/**
|
||||
* XedMEssage:type:
|
||||
*
|
||||
|
@ -189,17 +189,17 @@ xed_message_init (XedMessage *self)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
set_value_real (GValue *to,
|
||||
set_value_real (GValue *to,
|
||||
const GValue *from)
|
||||
{
|
||||
GType from_type;
|
||||
GType to_type;
|
||||
|
||||
|
||||
from_type = G_VALUE_TYPE (from);
|
||||
to_type = G_VALUE_TYPE (to);
|
||||
|
||||
if (!g_type_is_a (from_type, to_type))
|
||||
{
|
||||
{
|
||||
if (!g_value_transform (from, to))
|
||||
{
|
||||
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));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
g_value_copy (from, to);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -222,10 +222,10 @@ value_lookup (XedMessage *message,
|
|||
gboolean create)
|
||||
{
|
||||
GValue *ret = (GValue *)g_hash_table_lookup (message->priv->values, key);
|
||||
|
||||
|
||||
if (!ret && create)
|
||||
ret = add_value (message, key);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ const gchar *
|
|||
xed_message_get_method (XedMessage *message)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_MESSAGE (message), NULL);
|
||||
|
||||
|
||||
return xed_message_type_get_method (message->priv->type);
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ const gchar *
|
|||
xed_message_get_object_path (XedMessage *message)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_MESSAGE (message), NULL);
|
||||
|
||||
|
||||
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 value = {0,};
|
||||
gchar *error = NULL;
|
||||
|
||||
|
||||
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,
|
||||
key);
|
||||
|
||||
|
||||
/* skip value */
|
||||
va_arg (var_args, gpointer);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
g_value_init (&value, G_VALUE_TYPE (container));
|
||||
G_VALUE_COLLECT (&value, var_args, 0, &error);
|
||||
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
|
@ -350,25 +350,25 @@ xed_message_set_value (XedMessage *message,
|
|||
{
|
||||
GValue *container;
|
||||
g_return_if_fail (XED_IS_MESSAGE (message));
|
||||
|
||||
|
||||
container = value_lookup (message, key, TRUE);
|
||||
|
||||
|
||||
if (!container)
|
||||
{
|
||||
g_warning ("%s: Cannot set value for %s, does not exist",
|
||||
G_STRLOC,
|
||||
g_warning ("%s: Cannot set value for %s, does not exist",
|
||||
G_STRLOC,
|
||||
key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
set_value_real (container, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_message_set_valuesv:
|
||||
* @message: the #XedMessage
|
||||
* @keys: (array-length=n_values): keys to set values for
|
||||
* @values: (array-length=n_values): values to set
|
||||
* @keys: (array length=n_values): keys to set values for
|
||||
* @values: (array length=n_values): values to set
|
||||
* @n_values: number of arguments to set values for
|
||||
*
|
||||
* Set message argument values.
|
||||
|
@ -381,9 +381,9 @@ xed_message_set_valuesv (XedMessage *message,
|
|||
gint n_values)
|
||||
{
|
||||
gint i;
|
||||
|
||||
|
||||
g_return_if_fail (XED_IS_MESSAGE (message));
|
||||
|
||||
|
||||
for (i = 0; i < n_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.
|
||||
*
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_message_get (XedMessage *message,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
g_return_if_fail (XED_IS_MESSAGE (message));
|
||||
|
||||
|
||||
va_start (ap, message);
|
||||
xed_message_get_valist (message, ap);
|
||||
va_end (ap);
|
||||
|
@ -431,7 +431,7 @@ xed_message_get_valist (XedMessage *message,
|
|||
const gchar *key;
|
||||
|
||||
g_return_if_fail (XED_IS_MESSAGE (message));
|
||||
|
||||
|
||||
while ((key = va_arg (var_args, const gchar *)) != NULL)
|
||||
{
|
||||
GValue *container;
|
||||
|
@ -439,30 +439,30 @@ xed_message_get_valist (XedMessage *message,
|
|||
gchar *error = NULL;
|
||||
|
||||
container = value_lookup (message, key, FALSE);
|
||||
|
||||
|
||||
if (!container)
|
||||
{
|
||||
{
|
||||
/* skip value */
|
||||
va_arg (var_args, gpointer);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* copy the value here, to be sure it isn't tainted */
|
||||
g_value_init (©, G_VALUE_TYPE (container));
|
||||
g_value_copy (container, ©);
|
||||
|
||||
|
||||
G_VALUE_LCOPY (©, var_args, 0, &error);
|
||||
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
g_free (error);
|
||||
|
||||
|
||||
/* purposely leak the value here, because it might
|
||||
be in a bad state */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
g_value_unset (©);
|
||||
}
|
||||
}
|
||||
|
@ -477,17 +477,17 @@ xed_message_get_valist (XedMessage *message,
|
|||
* with the correct type.
|
||||
*
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_message_get_value (XedMessage *message,
|
||||
const gchar *key,
|
||||
GValue *value)
|
||||
{
|
||||
GValue *container;
|
||||
|
||||
|
||||
g_return_if_fail (XED_IS_MESSAGE (message));
|
||||
|
||||
|
||||
container = value_lookup (message, key, FALSE);
|
||||
|
||||
|
||||
if (!container)
|
||||
{
|
||||
g_warning ("%s: Invalid key `%s'",
|
||||
|
@ -495,7 +495,7 @@ xed_message_get_value (XedMessage *message,
|
|||
key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
g_value_init (value, G_VALUE_TYPE (container));
|
||||
set_value_real (value, container);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ xed_message_get_value (XedMessage *message,
|
|||
* Return value: the type of @key
|
||||
*
|
||||
*/
|
||||
GType
|
||||
GType
|
||||
xed_message_get_key_type (XedMessage *message,
|
||||
const gchar *key)
|
||||
{
|
||||
|
@ -535,14 +535,14 @@ xed_message_has_key (XedMessage *message,
|
|||
const gchar *key)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_MESSAGE (message), FALSE);
|
||||
|
||||
|
||||
return value_lookup (message, key, FALSE) != NULL;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
XedMessage *message;
|
||||
gboolean valid;
|
||||
gboolean valid;
|
||||
} ValidateInfo;
|
||||
|
||||
static void
|
||||
|
@ -552,12 +552,12 @@ validate_key (const gchar *key,
|
|||
ValidateInfo *info)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
|
||||
if (!info->valid || !required)
|
||||
return;
|
||||
|
||||
|
||||
value = value_lookup (info->message, key, FALSE);
|
||||
|
||||
|
||||
if (!value)
|
||||
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 (message->priv->type != NULL, FALSE);
|
||||
|
||||
|
||||
if (!message->priv->valid)
|
||||
{
|
||||
xed_message_type_foreach (message->priv->type,
|
||||
xed_message_type_foreach (message->priv->type,
|
||||
(XedMessageTypeForeach)validate_key,
|
||||
&info);
|
||||
|
||||
message->priv->valid = info.valid;
|
||||
}
|
||||
|
||||
|
||||
return message->priv->valid;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct _XedStatusComboBoxPrivate
|
|||
GtkWidget *label;
|
||||
GtkWidget *item;
|
||||
GtkWidget *arrow;
|
||||
|
||||
|
||||
GtkWidget *menu;
|
||||
GtkWidget *current_item;
|
||||
};
|
||||
|
@ -54,10 +54,10 @@ enum
|
|||
};
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
|
||||
PROP_LABEL
|
||||
};
|
||||
|
||||
|
@ -131,7 +131,7 @@ xed_status_combo_box_changed (XedStatusComboBox *combo,
|
|||
GtkMenuItem *item)
|
||||
{
|
||||
const gchar *text;
|
||||
|
||||
|
||||
text = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA);
|
||||
|
||||
if (text != NULL)
|
||||
|
@ -155,13 +155,13 @@ xed_status_combo_box_class_init (XedStatusComboBoxClass *klass)
|
|||
"-GtkWidget-focus-padding : 0;\n"
|
||||
"padding: 0;\n"
|
||||
"}";
|
||||
|
||||
|
||||
object_class->finalize = xed_status_combo_box_finalize;
|
||||
object_class->get_property = xed_status_combo_box_get_property;
|
||||
object_class->set_property = xed_status_combo_box_set_property;
|
||||
|
||||
widget_class->destroy = xed_status_combo_box_destroy;
|
||||
|
||||
|
||||
klass->changed = xed_status_combo_box_changed;
|
||||
|
||||
signals[CHANGED] =
|
||||
|
@ -172,7 +172,7 @@ xed_status_combo_box_class_init (XedStatusComboBoxClass *klass)
|
|||
changed), NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
|
||||
GTK_TYPE_MENU_ITEM);
|
||||
|
||||
|
||||
g_object_class_install_property (object_class, PROP_LABEL,
|
||||
g_param_spec_string ("label",
|
||||
"LABEL",
|
||||
|
@ -204,7 +204,7 @@ menu_position_func (GtkMenu *menu,
|
|||
{
|
||||
GtkRequisition request;
|
||||
GtkAllocation allocation;
|
||||
|
||||
|
||||
*push_in = FALSE;
|
||||
|
||||
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... */
|
||||
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y);
|
||||
gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
|
||||
|
||||
|
||||
/* make the menu as wide as the widget */
|
||||
if (request.width < allocation.width)
|
||||
{
|
||||
gtk_widget_set_size_request (GTK_WIDGET (menu), allocation.width, -1);
|
||||
}
|
||||
|
||||
|
||||
/* position it above the widget */
|
||||
*y -= request.height;
|
||||
}
|
||||
|
@ -310,12 +310,12 @@ xed_status_combo_box_init (XedStatusComboBox *self)
|
|||
GtkStyleContext *context;
|
||||
|
||||
self->priv = XED_STATUS_COMBO_BOX_GET_PRIVATE (self);
|
||||
|
||||
|
||||
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE);
|
||||
|
||||
self->priv->frame = gtk_frame_new (NULL);
|
||||
gtk_widget_show (self->priv->frame);
|
||||
|
||||
|
||||
self->priv->button = gtk_toggle_button_new ();
|
||||
gtk_button_set_relief (GTK_BUTTON (self->priv->button), GTK_RELIEF_NONE);
|
||||
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);
|
||||
gtk_widget_show (self->priv->hbox);
|
||||
|
||||
|
||||
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->button), self->priv->hbox);
|
||||
|
||||
|
||||
self->priv->label = gtk_label_new ("");
|
||||
gtk_widget_show (self->priv->label);
|
||||
|
||||
|
||||
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_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->label, FALSE, TRUE, 0);
|
||||
|
||||
|
||||
self->priv->item = gtk_label_new ("");
|
||||
gtk_widget_show (self->priv->item);
|
||||
|
||||
|
||||
gtk_label_set_single_line_mode (GTK_LABEL (self->priv->item), TRUE);
|
||||
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);
|
||||
|
||||
|
||||
self->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
|
||||
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_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->arrow, FALSE, TRUE, 0);
|
||||
|
||||
|
||||
self->priv->menu = gtk_menu_new ();
|
||||
gtk_menu_attach_to_widget (GTK_MENU (self->priv->menu),
|
||||
GTK_WIDGET (self),
|
||||
menu_detached);
|
||||
|
||||
g_signal_connect (self->priv->button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (button_press_event),
|
||||
g_signal_connect (self->priv->button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (button_press_event),
|
||||
self);
|
||||
g_signal_connect (self->priv->menu,
|
||||
"deactivate",
|
||||
|
@ -395,13 +395,13 @@ xed_status_combo_box_new (const gchar *label)
|
|||
* @label: (allow-none):
|
||||
*/
|
||||
void
|
||||
xed_status_combo_box_set_label (XedStatusComboBox *combo,
|
||||
xed_status_combo_box_set_label (XedStatusComboBox *combo,
|
||||
const gchar *label)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
g_return_if_fail (XED_IS_STATUS_COMBO_BOX (combo));
|
||||
|
||||
|
||||
text = g_strconcat (" ", label, ": ", NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (combo->priv->label), 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));
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (combo->priv->menu), GTK_WIDGET (item));
|
||||
|
||||
|
||||
xed_status_combo_box_set_item_text (combo, item, text);
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xed_status_combo_box_get_items:
|
||||
* @combo:
|
||||
*
|
||||
* Returns: (element-type Gtk.Widget) (transfer container):
|
||||
*/
|
||||
GList *
|
||||
xed_status_combo_box_get_items (XedStatusComboBox *combo)
|
||||
{
|
||||
|
@ -466,12 +473,12 @@ xed_status_combo_box_get_item_text (XedStatusComboBox *combo,
|
|||
GtkMenuItem *item)
|
||||
{
|
||||
const gchar *ret = NULL;
|
||||
|
||||
|
||||
g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL);
|
||||
g_return_val_if_fail (GTK_IS_MENU_ITEM (item), NULL);
|
||||
|
||||
|
||||
ret = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -481,7 +488,7 @@ xed_status_combo_box_get_item_text (XedStatusComboBox *combo,
|
|||
* @item:
|
||||
* @text: (allow-none):
|
||||
*/
|
||||
void
|
||||
void
|
||||
xed_status_combo_box_set_item_text (XedStatusComboBox *combo,
|
||||
GtkMenuItem *item,
|
||||
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 (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,
|
||||
g_strdup (text),
|
||||
(GDestroyNotify)g_free);
|
||||
|
@ -509,7 +516,7 @@ GtkLabel *
|
|||
xed_status_combo_box_get_item_label (XedStatusComboBox *combo)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_STATUS_COMBO_BOX (combo), NULL);
|
||||
|
||||
|
||||
return GTK_LABEL (combo->priv->item);
|
||||
}
|
||||
|
||||
|
|
400
xed/xed-tab.c
400
xed/xed-tab.c
File diff suppressed because it is too large
Load Diff
208
xed/xed-utils.c
208
xed/xed-utils.c
|
@ -3,8 +3,8 @@
|
|||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||
* Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi
|
||||
* Copyright (C) 2003-2005 Paolo Maggi
|
||||
* Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi
|
||||
* Copyright (C) 2003-2005 Paolo Maggi
|
||||
*
|
||||
* 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
|
||||
|
@ -18,14 +18,14 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ xed_utils_uri_has_file_scheme (const gchar *uri)
|
|||
|
||||
gfile = g_file_new_for_uri (uri);
|
||||
res = g_file_has_uri_scheme (gfile, "file");
|
||||
|
||||
|
||||
g_object_unref (gfile);
|
||||
return res;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ xed_utils_menu_position_under_tree_view (GtkMenu *menu,
|
|||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
|
||||
|
||||
model = gtk_tree_view_get_model (tree);
|
||||
g_return_if_fail (model != NULL);
|
||||
|
||||
|
@ -176,16 +176,16 @@ xed_utils_menu_position_under_tree_view (GtkMenu *menu,
|
|||
GdkRectangle rect;
|
||||
|
||||
widget_get_origin (GTK_WIDGET (tree), x, y);
|
||||
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
gtk_tree_view_get_cell_area (tree, path,
|
||||
gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */
|
||||
&rect);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
|
||||
*x += rect.x;
|
||||
*y += rect.y + rect.height;
|
||||
|
||||
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
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 */
|
||||
gchar *
|
||||
gchar *
|
||||
xed_gdk_color_to_string (GdkColor color)
|
||||
{
|
||||
return g_strdup_printf ("#%04x%04x%04x",
|
||||
color.red,
|
||||
color.red,
|
||||
color.green,
|
||||
color.blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_gtk_button_new_with_stock_icon:
|
||||
* @label:
|
||||
* @stock_id:
|
||||
*
|
||||
* Returns: (transfer full):
|
||||
*/
|
||||
GtkWidget *
|
||||
xed_gtk_button_new_with_stock_icon (const gchar *label,
|
||||
const gchar *stock_id)
|
||||
|
@ -227,6 +234,15 @@ xed_gtk_button_new_with_stock_icon (const gchar *label,
|
|||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_dialog_add_button:
|
||||
* @dialog:
|
||||
* @text:
|
||||
* @stock_id:
|
||||
* @response_id:
|
||||
*
|
||||
* Returns: (transfer none):
|
||||
*/
|
||||
GtkWidget *
|
||||
xed_dialog_add_button (GtkDialog *dialog,
|
||||
const gchar *text,
|
||||
|
@ -246,7 +262,7 @@ xed_dialog_add_button (GtkDialog *dialog,
|
|||
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_dialog_add_action_widget (dialog, button, response_id);
|
||||
gtk_dialog_add_action_widget (dialog, button, response_id);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
@ -254,7 +270,7 @@ xed_dialog_add_button (GtkDialog *dialog,
|
|||
/*
|
||||
* n: len of the string in bytes
|
||||
*/
|
||||
gboolean
|
||||
gboolean
|
||||
g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2)
|
||||
{
|
||||
gchar *casefold;
|
||||
|
@ -284,10 +300,10 @@ g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2)
|
|||
goto finally_2;
|
||||
|
||||
ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0);
|
||||
|
||||
|
||||
finally_2:
|
||||
g_free (normalized_s1);
|
||||
g_free (normalized_s2);
|
||||
g_free (normalized_s2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -302,7 +318,7 @@ finally_2:
|
|||
* for a specified gtk widget.
|
||||
*/
|
||||
void
|
||||
xed_utils_set_atk_name_description (GtkWidget *widget,
|
||||
xed_utils_set_atk_name_description (GtkWidget *widget,
|
||||
const gchar *name,
|
||||
const gchar *description)
|
||||
{
|
||||
|
@ -330,8 +346,8 @@ xed_utils_set_atk_name_description (GtkWidget *widget,
|
|||
* between 2 specified widgets.
|
||||
*/
|
||||
void
|
||||
xed_utils_set_atk_relation (GtkWidget *obj1,
|
||||
GtkWidget *obj2,
|
||||
xed_utils_set_atk_relation (GtkWidget *obj1,
|
||||
GtkWidget *obj2,
|
||||
AtkRelationType rel_type )
|
||||
{
|
||||
AtkObject *atk_obj1, *atk_obj2;
|
||||
|
@ -359,9 +375,9 @@ xed_utils_uri_exists (const gchar* text_uri)
|
|||
{
|
||||
GFile *gfile;
|
||||
gboolean res;
|
||||
|
||||
|
||||
g_return_val_if_fail (text_uri != NULL, FALSE);
|
||||
|
||||
|
||||
xed_debug_message (DEBUG_UTILS, "text_uri: %s", 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 *end;
|
||||
const gchar *prev;
|
||||
|
||||
|
||||
if (text == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -450,15 +466,15 @@ xed_utils_unescape_search_text (const gchar *text)
|
|||
cur = text;
|
||||
end = text + length;
|
||||
prev = NULL;
|
||||
|
||||
while (cur != end)
|
||||
|
||||
while (cur != end)
|
||||
{
|
||||
const gchar *next;
|
||||
next = g_utf8_next_char (cur);
|
||||
|
||||
if (prev && (*prev == '\\'))
|
||||
if (prev && (*prev == '\\'))
|
||||
{
|
||||
switch (*cur)
|
||||
switch (*cur)
|
||||
{
|
||||
case '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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (*cur != '\\')
|
||||
}
|
||||
else if (*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, "\\");
|
||||
}
|
||||
|
||||
|
||||
if (!drop_prev)
|
||||
{
|
||||
prev = cur;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
prev = NULL;
|
||||
drop_prev = FALSE;
|
||||
|
@ -504,19 +520,19 @@ xed_utils_unescape_search_text (const gchar *text)
|
|||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
xed_warning (GtkWindow *parent, const gchar *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
gchar *str;
|
||||
GtkWidget *dialog;
|
||||
GtkWindowGroup *wg = NULL;
|
||||
|
||||
|
||||
g_return_if_fail (format != NULL);
|
||||
|
||||
if (parent != NULL)
|
||||
wg = gtk_window_get_group (parent);
|
||||
|
||||
|
||||
va_start (args, format);
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
@ -532,7 +548,7 @@ xed_warning (GtkWindow *parent, const gchar *format, ...)
|
|||
|
||||
if (wg != NULL)
|
||||
gtk_window_group_add_window (wg, GTK_WINDOW (dialog));
|
||||
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
|
@ -541,14 +557,14 @@ xed_warning (GtkWindow *parent, const gchar *format, ...)
|
|||
"response",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
/*
|
||||
* Doubles underscore to avoid spurious menu accels.
|
||||
*/
|
||||
gchar *
|
||||
gchar *
|
||||
xed_utils_escape_underscores (const gchar* text,
|
||||
gssize length)
|
||||
{
|
||||
|
@ -642,7 +658,7 @@ xed_utils_str_truncate (const gchar *string,
|
|||
g_utf8_offset_to_pointer (string, num_left_chars) - string);
|
||||
g_string_append (truncated, delimiter);
|
||||
}
|
||||
|
||||
|
||||
return g_string_free (truncated, FALSE);
|
||||
}
|
||||
|
||||
|
@ -695,7 +711,7 @@ xed_utils_make_valid_utf8 (const char *name)
|
|||
}
|
||||
|
||||
g_string_append (string, remainder);
|
||||
|
||||
|
||||
g_assert (g_utf8_validate (string->str, -1, NULL));
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
|
@ -721,14 +737,14 @@ xed_utils_uri_get_dirname (const gchar *uri)
|
|||
if ((strlen (str) == 1) && (*str == '.'))
|
||||
{
|
||||
g_free (str);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = xed_utils_replace_home_dir_with_tilde (str);
|
||||
|
||||
g_free (str);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -827,7 +843,7 @@ xed_utils_replace_home_dir_with_tilde (const gchar *uri)
|
|||
if (strcmp (uri, home) == 0)
|
||||
{
|
||||
g_free (home);
|
||||
|
||||
|
||||
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));
|
||||
|
||||
g_free (home);
|
||||
|
||||
return res;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
g_free (home);
|
||||
|
@ -1059,7 +1075,7 @@ xed_utils_is_valid_uri (const gchar *uri)
|
|||
if (!g_ascii_isxdigit (*p))
|
||||
return FALSE;
|
||||
|
||||
++p;
|
||||
++p;
|
||||
if (!g_ascii_isxdigit (*p))
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1146,12 +1162,12 @@ xed_utils_get_ui_objects (const gchar *filename,
|
|||
*error_widget = NULL;
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
|
||||
|
||||
if (root_objects != NULL)
|
||||
{
|
||||
gtk_builder_add_objects_from_file (builder,
|
||||
filename,
|
||||
root_objects,
|
||||
gtk_builder_add_objects_from_file (builder,
|
||||
filename,
|
||||
root_objects,
|
||||
&error);
|
||||
}
|
||||
else
|
||||
|
@ -1183,8 +1199,8 @@ xed_utils_get_ui_objects (const gchar *filename,
|
|||
|
||||
if (!*gobj)
|
||||
{
|
||||
*error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."),
|
||||
name,
|
||||
*error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."),
|
||||
name,
|
||||
filename_markup),
|
||||
ret = FALSE;
|
||||
break;
|
||||
|
@ -1215,25 +1231,25 @@ xed_utils_get_ui_objects (const gchar *filename,
|
|||
|
||||
gchar *
|
||||
xed_utils_make_canonical_uri_from_shell_arg (const gchar *str)
|
||||
{
|
||||
{
|
||||
GFile *gfile;
|
||||
gchar *uri;
|
||||
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
g_return_val_if_fail (*str != '\0', NULL);
|
||||
|
||||
/* Note for the future:
|
||||
|
||||
/* Note for the future:
|
||||
* FIXME: is still still relevant?
|
||||
*
|
||||
* <federico> paolo: and flame whoever tells
|
||||
* you that file:///mate/test_files/hëllò
|
||||
* <federico> paolo: and flame whoever tells
|
||||
* you that file:///mate/test_files/hëllò
|
||||
* doesn't work --- that's not a valid URI
|
||||
*
|
||||
* <paolo> federico: well, another solution that
|
||||
* does not requires patch to _from_shell_args
|
||||
* is to check that the string returned by it
|
||||
* <paolo> federico: well, another solution that
|
||||
* does not requires patch to _from_shell_args
|
||||
* is to check that the string returned by it
|
||||
* contains only ASCII chars
|
||||
* <federico> paolo: hmmmm, isn't there
|
||||
* <federico> paolo: hmmmm, isn't there
|
||||
* mate_vfs_is_uri_valid() or something?
|
||||
* <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))
|
||||
return uri;
|
||||
|
||||
|
||||
g_free (uri);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1262,13 +1278,13 @@ xed_utils_file_has_parent (GFile *gfile)
|
|||
{
|
||||
GFile *parent;
|
||||
gboolean ret;
|
||||
|
||||
|
||||
parent = g_file_get_parent (gfile);
|
||||
ret = parent != NULL;
|
||||
|
||||
|
||||
if (parent)
|
||||
g_object_unref (parent);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1294,9 +1310,9 @@ xed_utils_basename_for_display (gchar const *uri)
|
|||
{
|
||||
GFileInfo *info;
|
||||
info = g_file_query_info (gfile,
|
||||
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL,
|
||||
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (info)
|
||||
|
@ -1310,7 +1326,7 @@ xed_utils_basename_for_display (gchar const *uri)
|
|||
/* This is a local file, and therefore we will use
|
||||
* g_filename_display_basename on the local path */
|
||||
gchar *local_path;
|
||||
|
||||
|
||||
local_path = g_file_get_path (gfile);
|
||||
name = g_filename_display_basename (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);
|
||||
base = g_filename_display_basename (parse_name);
|
||||
name = g_uri_unescape_string (base, NULL);
|
||||
|
||||
g_free (base);
|
||||
|
||||
g_free (base);
|
||||
g_free (parse_name);
|
||||
}
|
||||
else
|
||||
|
@ -1360,7 +1376,7 @@ xed_utils_basename_for_display (gchar const *uri)
|
|||
*
|
||||
* Filter, modify, unescape and change @uri to make it appropriate
|
||||
* for display to users.
|
||||
*
|
||||
*
|
||||
* This function is a convenient wrapper for g_file_get_parse_name
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
* were no valid uris. g_strfreev should be used when the
|
||||
*
|
||||
* 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
|
||||
* string array is no longer used
|
||||
*/
|
||||
gchar **
|
||||
|
@ -1402,9 +1418,9 @@ xed_utils_drop_get_uris (GtkSelectionData *selection_data)
|
|||
for (i = 0; uris[i] != NULL; i++)
|
||||
{
|
||||
gchar *uri;
|
||||
|
||||
|
||||
uri = xed_utils_make_canonical_uri_from_shell_arg (uris[i]);
|
||||
|
||||
|
||||
/* Silently ignore malformed URI/filename */
|
||||
if (uri != NULL)
|
||||
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
|
||||
* %NULL to ignore certain parts of the uri. If the function returns %TRUE, then
|
||||
* all return value pointers should be freed using g_free
|
||||
*
|
||||
*
|
||||
* Return value: %TRUE if the uri could be properly decoded, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
|
@ -1454,7 +1470,7 @@ xed_utils_decode_uri (const gchar *uri,
|
|||
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
|
||||
* ourselves (see bug #546182) */
|
||||
|
||||
|
@ -1464,10 +1480,10 @@ xed_utils_decode_uri (const gchar *uri,
|
|||
|
||||
/* From RFC 3986 Decodes:
|
||||
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
|
||||
*/
|
||||
*/
|
||||
|
||||
p = uri;
|
||||
|
||||
|
||||
null_ptr (scheme);
|
||||
null_ptr (user);
|
||||
null_ptr (port);
|
||||
|
@ -1494,32 +1510,32 @@ xed_utils_decode_uri (const gchar *uri,
|
|||
c == '.'))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (scheme)
|
||||
{
|
||||
*scheme = g_malloc (p - uri);
|
||||
out = *scheme;
|
||||
|
||||
|
||||
for (in = uri; in < p - 1; in++)
|
||||
*out++ = g_ascii_tolower (*in);
|
||||
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
|
||||
hier_part_start = p;
|
||||
hier_part_end = p + strlen (p);
|
||||
|
||||
|
||||
if (hier_part_start[0] == '/' && hier_part_start[1] == '/')
|
||||
{
|
||||
const char *authority_start, *authority_end;
|
||||
const char *userinfo_start, *userinfo_end;
|
||||
const char *host_start, *host_end;
|
||||
const char *port_start;
|
||||
|
||||
|
||||
authority_start = hier_part_start + 2;
|
||||
/* authority is always followed by / or nothing */
|
||||
authority_end = memchr (authority_start, '/', hier_part_end - authority_start);
|
||||
|
||||
|
||||
if (authority_end == NULL)
|
||||
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);
|
||||
|
||||
|
||||
if (userinfo_end)
|
||||
{
|
||||
userinfo_start = authority_start;
|
||||
|
||||
|
||||
if (user)
|
||||
*user = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL);
|
||||
|
||||
|
||||
if (user && *user == NULL)
|
||||
{
|
||||
if (scheme)
|
||||
|
@ -1543,7 +1559,7 @@ xed_utils_decode_uri (const gchar *uri,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
host_start = userinfo_end + 1;
|
||||
}
|
||||
else
|
||||
|
@ -1569,6 +1585,6 @@ xed_utils_decode_uri (const gchar *uri,
|
|||
|
||||
if (path)
|
||||
*path = g_uri_unescape_segment (hier_part_start, hier_part_end, "/");
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3395,7 +3395,7 @@ xed_window_init (XedWindow *window)
|
|||
*
|
||||
* Gets the active #XedView.
|
||||
*
|
||||
* Returns: the active #XedView
|
||||
* Returns: (transfer none): the active #XedView
|
||||
*/
|
||||
XedView *
|
||||
xed_window_get_active_view (XedWindow *window)
|
||||
|
@ -3423,7 +3423,7 @@ xed_window_get_active_view (XedWindow *window)
|
|||
*
|
||||
* Gets the active #XedDocument.
|
||||
*
|
||||
* Returns: the active #XedDocument
|
||||
* Returns: (transfer none): the active #XedDocument
|
||||
*/
|
||||
XedDocument *
|
||||
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.
|
||||
* In case @jump_to is %TRUE the #XedNotebook switches to that new #XedTab.
|
||||
*
|
||||
* Returns: a new #XedTab
|
||||
* Returns: (transfer none): a new #XedTab
|
||||
*/
|
||||
XedTab *
|
||||
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
|
||||
* not refer to an existing file
|
||||
*
|
||||
* Returns: a new #XedTab
|
||||
* Returns: (transfer none): a new #XedTab
|
||||
*/
|
||||
XedTab *
|
||||
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.
|
||||
*
|
||||
* Returns: the active #XedTab in the @window.
|
||||
* Returns: (transfer none): the active #XedTab in the @window.
|
||||
*/
|
||||
XedTab *
|
||||
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.
|
||||
*
|
||||
* Returns: the #GtkWindowGroup
|
||||
* Returns: (transfer none): the #GtkWindowGroup
|
||||
*/
|
||||
GtkWindowGroup *
|
||||
xed_window_get_group (XedWindow *window)
|
||||
|
@ -3751,7 +3751,7 @@ _xed_window_is_removing_tabs (XedWindow *window)
|
|||
*
|
||||
* Gets the #GtkUIManager associated with the @window.
|
||||
*
|
||||
* Returns: the #GtkUIManager of the @window.
|
||||
* Returns: (transfer none): the #GtkUIManager of the @window.
|
||||
*/
|
||||
GtkUIManager *
|
||||
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.
|
||||
*
|
||||
* Returns: the side #XedPanel.
|
||||
* Returns: (transfer none): the side #XedPanel.
|
||||
*/
|
||||
XedPanel *
|
||||
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.
|
||||
*
|
||||
* Returns: the bottom #XedPanel.
|
||||
* Returns: (transfer none): the bottom #XedPanel.
|
||||
*/
|
||||
XedPanel *
|
||||
xed_window_get_bottom_panel (XedWindow *window)
|
||||
|
@ -3796,7 +3796,7 @@ xed_window_get_bottom_panel (XedWindow *window)
|
|||
*
|
||||
* Gets the #XedStatusbar of the @window.
|
||||
*
|
||||
* Returns: the #XedStatusbar of the @window.
|
||||
* Returns: (transfer none): the #XedStatusbar of the @window.
|
||||
*/
|
||||
GtkWidget *
|
||||
xed_window_get_statusbar (XedWindow *window)
|
||||
|
@ -3809,9 +3809,9 @@ xed_window_get_statusbar (XedWindow *window)
|
|||
* xed_window_get_searchbar:
|
||||
* @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 *
|
||||
xed_window_get_searchbar (XedWindow *window)
|
||||
|
@ -4084,7 +4084,7 @@ xed_window_get_message_bus (XedWindow *window)
|
|||
*
|
||||
* 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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue