diff --git a/xed/xed-app.c b/xed/xed-app.c index 867ea89..5ca4f3c 100644 --- a/xed/xed-app.c +++ b/xed/xed-app.c @@ -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) diff --git a/xed/xed-document.c b/xed/xed-document.c index 502631c..36bd176 100644 --- a/xed/xed-document.c +++ b/xed/xed-document.c @@ -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) { diff --git a/xed/xed-file-chooser-dialog.c b/xed/xed-file-chooser-dialog.c index abffce8..8c906f4 100644 --- a/xed/xed-file-chooser-dialog.c +++ b/xed/xed-file-chooser-dialog.c @@ -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 diff --git a/xed/xed-message-bus.c b/xed/xed-message-bus.c index 5972ee7..6a51955 100644 --- a/xed/xed-message-bus.c +++ b/xed/xed-message-bus.c @@ -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 */ diff --git a/xed/xed-message-type.c b/xed/xed-message-type.c index 1ab1aa5..0211c22 100644 --- a/xed/xed-message-type.c +++ b/xed/xed-message-type.c @@ -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. * * @@ -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) diff --git a/xed/xed-message.c b/xed/xed-message.c index 13dd947..24a2979 100644 --- a/xed/xed-message.c +++ b/xed/xed-message.c @@ -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; } diff --git a/xed/xed-status-combo-box.c b/xed/xed-status-combo-box.c index b2b5bf3..bad9537 100644 --- a/xed/xed-status-combo-box.c +++ b/xed/xed-status-combo-box.c @@ -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); } diff --git a/xed/xed-tab.c b/xed/xed-tab.c index ddf6c7a..3a09ff4 100644 --- a/xed/xed-tab.c +++ b/xed/xed-tab.c @@ -2,7 +2,7 @@ * xed-tab.c * This file is part of xed * - * Copyright (C) 2005 - Paolo Maggi + * Copyright (C) 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 @@ -16,14 +16,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, + * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ - + /* - * Modified by the xed Team, 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, 2005. See the AUTHORS file for a + * list of people on the xed Team. + * See the ChangeLog files for a list of changes. */ #ifdef HAVE_CONFIG_H @@ -52,7 +52,7 @@ struct _XedTabPrivate { XedTabState state; - + GtkWidget *view; GtkWidget *view_scrolled_window; @@ -67,7 +67,7 @@ struct _XedTabPrivate /* tmp data for loading */ gint tmp_line_pos; const XedEncoding *tmp_encoding; - + GTimer *timer; guint times_called; @@ -75,7 +75,7 @@ struct _XedTabPrivate gint auto_save_interval; guint auto_save_timeout; - + gint not_editable : 1; gint auto_save : 1; @@ -105,7 +105,7 @@ install_auto_save_timeout (XedTab *tab) g_return_if_fail (tab->priv->auto_save_timeout <= 0); g_return_if_fail (tab->priv->auto_save); g_return_if_fail (tab->priv->auto_save_interval > 0); - + g_return_if_fail (tab->priv->state != XED_TAB_STATE_LOADING); g_return_if_fail (tab->priv->state != XED_TAB_STATE_SAVING); g_return_if_fail (tab->priv->state != XED_TAB_STATE_REVERTING); @@ -128,7 +128,7 @@ install_auto_save_timeout_if_needed (XedTab *tab) XedDocument *doc; xed_debug (DEBUG_TAB); - + g_return_val_if_fail (tab->priv->auto_save_timeout <= 0, FALSE); g_return_val_if_fail ((tab->priv->state == XED_TAB_STATE_NORMAL) || (tab->priv->state == XED_TAB_STATE_SHOWING_PRINT_PREVIEW) || @@ -139,15 +139,15 @@ install_auto_save_timeout_if_needed (XedTab *tab) doc = xed_tab_get_document (tab); - if (tab->priv->auto_save && + if (tab->priv->auto_save && !xed_document_is_untitled (doc) && !xed_document_get_readonly (doc)) - { + { install_auto_save_timeout (tab); - + return TRUE; } - + return FALSE; } @@ -157,9 +157,9 @@ remove_auto_save_timeout (XedTab *tab) xed_debug (DEBUG_TAB); /* FIXME: check sugli stati */ - + g_return_if_fail (tab->priv->auto_save_timeout > 0); - + g_source_remove (tab->priv->auto_save_timeout); tab->priv->auto_save_timeout = 0; } @@ -181,7 +181,7 @@ xed_tab_get_property (GObject *object, case PROP_STATE: g_value_set_enum (value, xed_tab_get_state (tab)); - break; + break; case PROP_AUTO_SAVE: g_value_set_boolean (value, xed_tab_get_auto_save_enabled (tab)); @@ -192,7 +192,7 @@ xed_tab_get_property (GObject *object, break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + break; } } @@ -216,7 +216,7 @@ xed_tab_set_property (GObject *object, break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + break; } } @@ -236,7 +236,7 @@ xed_tab_finalize (GObject *object) G_OBJECT_CLASS (xed_tab_parent_class)->finalize (object); } -static void +static void xed_tab_class_init (XedTabClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -244,7 +244,7 @@ xed_tab_class_init (XedTabClass *klass) object_class->finalize = xed_tab_finalize; object_class->get_property = xed_tab_get_property; object_class->set_property = xed_tab_set_property; - + g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", @@ -299,7 +299,7 @@ XedTabState xed_tab_get_state (XedTab *tab) { g_return_val_if_fail (XED_IS_TAB (tab), XED_TAB_STATE_NORMAL); - + return tab->priv->state; } @@ -403,27 +403,27 @@ xed_tab_set_state (XedTab *tab, set_cursor_according_to_state (GTK_TEXT_VIEW (tab->priv->view), state); - g_object_notify (G_OBJECT (tab), "state"); + g_object_notify (G_OBJECT (tab), "state"); } -static void +static void document_uri_notify_handler (XedDocument *document, GParamSpec *pspec, XedTab *tab) { xed_debug (DEBUG_TAB); - + /* Notify the change in the URI */ g_object_notify (G_OBJECT (tab), "name"); } -static void +static void document_shortname_notify_handler (XedDocument *document, GParamSpec *pspec, XedTab *tab) { xed_debug (DEBUG_TAB); - + /* Notify the change in the shortname */ g_object_notify (G_OBJECT (tab), "name"); } @@ -454,9 +454,9 @@ set_message_area (XedTab *tab, tab->priv->message_area, FALSE, FALSE, - 0); + 0); - g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area), + g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area), (gpointer *)&tab->priv->message_area); } @@ -470,7 +470,7 @@ remove_tab (XedTab *tab) xed_notebook_remove_tab (notebook, tab); } -static void +static void io_loading_error_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) @@ -530,26 +530,26 @@ io_loading_error_message_area_response (GtkWidget *message_area, g_free (uri); } -static void +static void file_already_open_warning_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) { XedView *view; - + view = xed_tab_get_view (tab); - + if (response_id == GTK_RESPONSE_YES) { tab->priv->not_editable = FALSE; - + gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE); } gtk_widget_destroy (message_area); - gtk_widget_grab_focus (GTK_WIDGET (view)); + gtk_widget_grab_focus (GTK_WIDGET (view)); } static void @@ -558,19 +558,19 @@ load_cancelled (GtkWidget *area, XedTab *tab) { g_return_if_fail (XED_IS_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); - + g_object_ref (tab); xed_document_load_cancel (xed_tab_get_document (tab)); - g_object_unref (tab); + g_object_unref (tab); } -static void +static void unrecoverable_reverting_error_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) { XedView *view; - + xed_tab_set_state (tab, XED_TAB_STATE_NORMAL); @@ -579,8 +579,8 @@ unrecoverable_reverting_error_message_area_response (GtkWidget *message_a view = xed_tab_get_view (tab); gtk_widget_grab_focus (GTK_WIDGET (view)); - - install_auto_save_timeout_if_needed (tab); + + install_auto_save_timeout_if_needed (tab); } #define MAX_MSG_LENGTH 100 @@ -601,7 +601,7 @@ show_loading_message_area (XedTab *tab) return; xed_debug (DEBUG_TAB); - + doc = xed_tab_get_document (tab); g_return_if_fail (doc != NULL); @@ -637,7 +637,7 @@ show_loading_message_area (XedTab *tab) * we have a title long 99 + 20, but I think it's a rare enough * case to be acceptable. It's justa darn title afterall :) */ - dirname = xed_utils_str_middle_truncate (str, + dirname = xed_utils_str_middle_truncate (str, MAX (20, MAX_MSG_LENGTH - len)); g_free (str); } @@ -660,10 +660,10 @@ show_loading_message_area (XedTab *tab) } else { - msg = g_strdup_printf (_("Reverting %s"), + msg = g_strdup_printf (_("Reverting %s"), name_markup); } - + area = xed_progress_message_area_new (GTK_STOCK_REVERT_TO_SAVED, msg, TRUE); @@ -683,7 +683,7 @@ show_loading_message_area (XedTab *tab) } else { - msg = g_strdup_printf (_("Loading %s"), + msg = g_strdup_printf (_("Loading %s"), name_markup); } @@ -696,7 +696,7 @@ show_loading_message_area (XedTab *tab) "response", G_CALLBACK (load_cancelled), tab); - + gtk_widget_show (area); set_message_area (tab, area); @@ -721,12 +721,12 @@ show_saving_message_area (XedTab *tab) gint len; g_return_if_fail (tab->priv->tmp_save_uri != NULL); - + if (tab->priv->message_area != NULL) return; - + xed_debug (DEBUG_TAB); - + doc = xed_tab_get_document (tab); g_return_if_fail (doc != NULL); @@ -739,7 +739,7 @@ show_saving_message_area (XedTab *tab) */ if (len > MAX_MSG_LENGTH) { - from = xed_utils_str_middle_truncate (short_name, + from = xed_utils_str_middle_truncate (short_name, MAX_MSG_LENGTH); g_free (short_name); } @@ -751,10 +751,10 @@ show_saving_message_area (XedTab *tab) to = xed_utils_uri_for_display (tab->priv->tmp_save_uri); - str = xed_utils_str_middle_truncate (to, + str = xed_utils_str_middle_truncate (to, MAX (20, MAX_MSG_LENGTH - len)); g_free (to); - + to = str; } @@ -801,12 +801,12 @@ message_area_set_progress (XedTab *tab, xed_debug_message (DEBUG_TAB, "%" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, size, total_size); g_return_if_fail (XED_IS_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); - + if (total_size == 0) { if (size != 0) xed_progress_message_area_pulse ( - XED_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); + XED_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); else xed_progress_message_area_set_fraction ( XED_PROGRESS_MESSAGE_AREA (tab->priv->message_area), @@ -820,7 +820,7 @@ message_area_set_progress (XedTab *tab, xed_progress_message_area_set_fraction ( XED_PROGRESS_MESSAGE_AREA (tab->priv->message_area), - frac); + frac); } } @@ -906,7 +906,7 @@ document_loaded (XedDocument *document, error->code == G_IO_ERROR_CANCELLED) { /* remove the tab, but in an idle handler, since - * we are in the handler of doc loaded and we + * we are in the handler of doc loaded and we * don't want doc and tab to be finalized now. */ g_idle_add ((GSourceFunc) remove_tab_idle, tab); @@ -930,7 +930,7 @@ document_loaded (XedDocument *document, else { g_return_if_fail (tab->priv->state == XED_TAB_STATE_REVERTING_ERROR); - + emsg = xed_unrecoverable_reverting_error_message_area_new (uri, error); @@ -1000,7 +1000,7 @@ document_loaded (XedDocument *document, for (l = all_documents; l != NULL; l = g_list_next (l)) { XedDocument *d = XED_DOCUMENT (l->data); - + if (d != document) { GFile *loc; @@ -1034,7 +1034,7 @@ document_loaded (XedDocument *document, g_object_unref (loc); break; } - + if (loc != NULL) g_object_unref (loc); } @@ -1043,7 +1043,7 @@ document_loaded (XedDocument *document, g_list_free (all_documents); xed_tab_set_state (tab, XED_TAB_STATE_NORMAL); - + install_auto_save_timeout_if_needed (tab); tab->priv->ask_if_externally_modified = TRUE; @@ -1099,32 +1099,32 @@ end_saving (XedTab *tab) g_free (tab->priv->tmp_save_uri); tab->priv->tmp_save_uri = NULL; tab->priv->tmp_encoding = NULL; - + install_auto_save_timeout_if_needed (tab); } -static void +static void unrecoverable_saving_error_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) { XedView *view; - + if (tab->priv->print_preview != NULL) xed_tab_set_state (tab, XED_TAB_STATE_SHOWING_PRINT_PREVIEW); else xed_tab_set_state (tab, XED_TAB_STATE_NORMAL); end_saving (tab); - + set_message_area (tab, NULL); view = xed_tab_get_view (tab); - gtk_widget_grab_focus (GTK_WIDGET (view)); + gtk_widget_grab_focus (GTK_WIDGET (view)); } -static void +static void no_backup_error_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) @@ -1147,7 +1147,7 @@ no_backup_error_message_area_response (GtkWidget *message_area, tab->priv->save_flags |= XED_DOCUMENT_SAVE_IGNORE_BACKUP; g_return_if_fail (tab->priv->auto_save_timeout <= 0); - + /* Force saving */ xed_document_save (doc, tab->priv->save_flags); } @@ -1170,7 +1170,7 @@ externally_modified_error_message_area_response (GtkWidget *message_area, doc = xed_tab_get_document (tab); g_return_if_fail (XED_IS_DOCUMENT (doc)); - + set_message_area (tab, NULL); g_return_if_fail (tab->priv->tmp_save_uri != NULL); @@ -1179,21 +1179,21 @@ externally_modified_error_message_area_response (GtkWidget *message_area, xed_tab_set_state (tab, XED_TAB_STATE_SAVING); g_return_if_fail (tab->priv->auto_save_timeout <= 0); - + /* ignore mtime should not be persisted in save flags across saves */ /* Force saving */ xed_document_save (doc, tab->priv->save_flags | XED_DOCUMENT_SAVE_IGNORE_MTIME); } else - { + { unrecoverable_saving_error_message_area_response (message_area, response_id, tab); } } -static void +static void recoverable_saving_error_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) @@ -1202,11 +1202,11 @@ recoverable_saving_error_message_area_response (GtkWidget *message_area, doc = xed_tab_get_document (tab); g_return_if_fail (XED_IS_DOCUMENT (doc)); - + if (response_id == GTK_RESPONSE_OK) { const XedEncoding *encoding; - + encoding = xed_conversion_error_message_area_get_encoding ( GTK_WIDGET (message_area)); @@ -1215,22 +1215,22 @@ recoverable_saving_error_message_area_response (GtkWidget *message_area, set_message_area (tab, NULL); g_return_if_fail (tab->priv->tmp_save_uri != NULL); - + xed_tab_set_state (tab, XED_TAB_STATE_SAVING); - + tab->priv->tmp_encoding = encoding; xed_debug_message (DEBUG_TAB, "Force saving with URI '%s'", tab->priv->tmp_save_uri); - + g_return_if_fail (tab->priv->auto_save_timeout <= 0); - + xed_document_save_as (doc, tab->priv->tmp_save_uri, tab->priv->tmp_encoding, tab->priv->save_flags); } else - { + { unrecoverable_saving_error_message_area_response (message_area, response_id, tab); @@ -1247,25 +1247,25 @@ document_saved (XedDocument *document, g_return_if_fail (tab->priv->state == XED_TAB_STATE_SAVING); g_return_if_fail (tab->priv->tmp_save_uri != NULL); - g_return_if_fail (tab->priv->tmp_encoding != NULL); + g_return_if_fail (tab->priv->tmp_encoding != NULL); g_return_if_fail (tab->priv->auto_save_timeout <= 0); - + g_timer_destroy (tab->priv->timer); tab->priv->timer = NULL; tab->priv->times_called = 0; - + set_message_area (tab, NULL); - + if (error != NULL) { xed_tab_set_state (tab, XED_TAB_STATE_SAVING_ERROR); - + if (error->domain == XED_DOCUMENT_ERROR && error->code == XED_DOCUMENT_ERROR_EXTERNALLY_MODIFIED) { /* This error is recoverable */ emsg = xed_externally_modified_saving_error_message_area_new ( - tab->priv->tmp_save_uri, + tab->priv->tmp_save_uri, error); g_return_if_fail (emsg != NULL); @@ -1283,7 +1283,7 @@ document_saved (XedDocument *document, { /* This error is recoverable */ emsg = xed_no_backup_saving_error_message_area_new ( - tab->priv->tmp_save_uri, + tab->priv->tmp_save_uri, error); g_return_if_fail (emsg != NULL); @@ -1303,10 +1303,10 @@ document_saved (XedDocument *document, _xed_recent_remove (XED_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), tab->priv->tmp_save_uri); - emsg = xed_unrecoverable_saving_error_message_area_new (tab->priv->tmp_save_uri, + emsg = xed_unrecoverable_saving_error_message_area_new (tab->priv->tmp_save_uri, error); g_return_if_fail (emsg != NULL); - + set_message_area (tab, emsg); g_signal_connect (emsg, @@ -1353,12 +1353,12 @@ document_saved (XedDocument *document, xed_tab_set_state (tab, XED_TAB_STATE_NORMAL); tab->priv->ask_if_externally_modified = TRUE; - + end_saving (tab); } } -static void +static void externally_modified_notification_message_area_response (GtkWidget *message_area, gint response_id, XedTab *tab) @@ -1483,7 +1483,7 @@ xed_tab_init (XedTab *tab) gtk_orientable_set_orientation (GTK_ORIENTABLE (tab), GTK_ORIENTATION_VERTICAL); - + /* Create the scrolled window */ sw = gtk_scrolled_window_new (NULL, NULL); tab->priv->view_scrolled_window = sw; @@ -1563,12 +1563,12 @@ _xed_tab_new (void) return GTK_WIDGET (g_object_new (XED_TYPE_TAB, NULL)); } -/* 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 */ GtkWidget * _xed_tab_new_from_uri (const gchar *uri, const XedEncoding *encoding, - gint line_pos, + gint line_pos, gboolean create) { XedTab *tab; @@ -1584,7 +1584,7 @@ _xed_tab_new_from_uri (const gchar *uri, create); return GTK_WIDGET (tab); -} +} /** * xed_tab_get_view: @@ -1592,7 +1592,7 @@ _xed_tab_new_from_uri (const gchar *uri, * * Gets the #XedView inside @tab. * - * Returns: the #XedView inside @tab + * Returns: (transfer none): the #XedView inside @tab */ XedView * xed_tab_get_view (XedTab *tab) @@ -1606,7 +1606,7 @@ xed_tab_get_view (XedTab *tab) * * Gets the #XedDocument associated to @tab. * - * Returns: the #XedDocument associated to @tab + * Returns: (transfer none): the #XedDocument associated to @tab */ XedDocument * xed_tab_get_document (XedTab *tab) @@ -1637,23 +1637,23 @@ _xed_tab_get_name (XedTab *tab) if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc))) { tab_name = g_strdup_printf ("*%s", docname); - } - else + } + else { - #if 0 - if (xed_document_get_readonly (doc)) + #if 0 + if (xed_document_get_readonly (doc)) { - tab_name = g_strdup_printf ("%s [%s]", docname, + tab_name = g_strdup_printf ("%s [%s]", docname, /*Read only*/ _("RO")); - } - else + } + else { tab_name = g_strdup_printf ("%s", docname); } #endif tab_name = g_strdup (docname); } - + g_free (docname); g_free (name); @@ -1686,7 +1686,7 @@ _xed_tab_get_tooltips (XedTab *tab) gchar *content_type; gchar *mime_type; gchar *content_description; - gchar *content_full_description; + gchar *content_full_description; gchar *encoding; const XedEncoding *enc; @@ -1698,12 +1698,12 @@ _xed_tab_get_tooltips (XedTab *tab) case XED_TAB_STATE_REVERTING_ERROR: tip = g_strdup_printf (_("Error reverting file %s"), ruri_markup); - break; + break; case XED_TAB_STATE_SAVING_ERROR: tip = g_strdup_printf (_("Error saving file %s"), ruri_markup); - break; + break; default: content_type = xed_document_get_content_type (doc); mime_type = xed_document_get_mime_type (doc); @@ -1712,7 +1712,7 @@ _xed_tab_get_tooltips (XedTab *tab) if (content_description == NULL) content_full_description = g_strdup (mime_type); else - content_full_description = g_strdup_printf ("%s (%s)", + content_full_description = g_strdup_printf ("%s (%s)", content_description, mime_type); g_free (content_type); @@ -1739,9 +1739,9 @@ _xed_tab_get_tooltips (XedTab *tab) break; } - g_free (ruri); + g_free (ruri); g_free (ruri_markup); - + return tip; } @@ -1751,28 +1751,28 @@ resize_icon (GdkPixbuf *pixbuf, { gint width, height; - width = gdk_pixbuf_get_width (pixbuf); + width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); /* if the icon is larger than the nominal size, scale down */ - if (MAX (width, height) > size) + if (MAX (width, height) > size) { GdkPixbuf *scaled_pixbuf; - - if (width > height) + + if (width > height) { height = height * size / width; width = size; - } - else + } + else { width = width * size / height; height = size; } - - scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, - width, - height, + + scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, + width, + height, GDK_INTERP_BILINEAR); g_object_unref (pixbuf); pixbuf = scaled_pixbuf; @@ -1782,21 +1782,21 @@ resize_icon (GdkPixbuf *pixbuf, } static GdkPixbuf * -get_stock_icon (GtkIconTheme *theme, +get_stock_icon (GtkIconTheme *theme, const gchar *stock, gint size) { GdkPixbuf *pixbuf; - + pixbuf = gtk_icon_theme_load_icon (theme, stock, size, 0, NULL); if (pixbuf == NULL) return NULL; - + return resize_icon (pixbuf, size); } static GdkPixbuf * -get_icon (GtkIconTheme *theme, +get_icon (GtkIconTheme *theme, GFile *location, gint size) { @@ -1809,10 +1809,10 @@ get_icon (GtkIconTheme *theme, return get_stock_icon (theme, GTK_STOCK_FILE, size); /* FIXME: Doing a sync stat is bad, this should be fixed */ - info = g_file_query_info (location, - G_FILE_ATTRIBUTE_STANDARD_ICON, - G_FILE_QUERY_INFO_NONE, - NULL, + info = g_file_query_info (location, + G_FILE_ATTRIBUTE_STANDARD_ICON, + G_FILE_QUERY_INFO_NONE, + NULL, NULL); if (info == NULL) return get_stock_icon (theme, GTK_STOCK_FILE, size); @@ -1826,17 +1826,17 @@ get_icon (GtkIconTheme *theme, } icon_info = gtk_icon_theme_lookup_by_gicon (theme, gicon, size, 0); - g_object_unref (info); - + g_object_unref (info); + if (icon_info == NULL) return get_stock_icon (theme, GTK_STOCK_FILE, size); - + pixbuf = gtk_icon_info_load_icon (icon_info, NULL); gtk_icon_info_free (icon_info); - + if (pixbuf == NULL) return get_stock_icon (theme, GTK_STOCK_FILE, size); - + return resize_icon (pixbuf, size); } @@ -1862,33 +1862,33 @@ _xed_tab_get_icon (XedTab *tab) switch (tab->priv->state) { case XED_TAB_STATE_LOADING: - pixbuf = get_stock_icon (theme, - GTK_STOCK_OPEN, + pixbuf = get_stock_icon (theme, + GTK_STOCK_OPEN, icon_size); break; case XED_TAB_STATE_REVERTING: - pixbuf = get_stock_icon (theme, - GTK_STOCK_REVERT_TO_SAVED, - icon_size); + pixbuf = get_stock_icon (theme, + GTK_STOCK_REVERT_TO_SAVED, + icon_size); break; case XED_TAB_STATE_SAVING: - pixbuf = get_stock_icon (theme, - GTK_STOCK_SAVE, + pixbuf = get_stock_icon (theme, + GTK_STOCK_SAVE, icon_size); break; case XED_TAB_STATE_PRINTING: - pixbuf = get_stock_icon (theme, - GTK_STOCK_PRINT, + pixbuf = get_stock_icon (theme, + GTK_STOCK_PRINT, icon_size); break; case XED_TAB_STATE_PRINT_PREVIEWING: - case XED_TAB_STATE_SHOWING_PRINT_PREVIEW: - pixbuf = get_stock_icon (theme, - GTK_STOCK_PRINT_PREVIEW, + case XED_TAB_STATE_SHOWING_PRINT_PREVIEW: + pixbuf = get_stock_icon (theme, + GTK_STOCK_PRINT_PREVIEW, icon_size); break; @@ -1896,8 +1896,8 @@ _xed_tab_get_icon (XedTab *tab) case XED_TAB_STATE_REVERTING_ERROR: case XED_TAB_STATE_SAVING_ERROR: case XED_TAB_STATE_GENERIC_ERROR: - pixbuf = get_stock_icon (theme, - GTK_STOCK_DIALOG_ERROR, + pixbuf = get_stock_icon (theme, + GTK_STOCK_DIALOG_ERROR, icon_size); break; @@ -1931,17 +1931,17 @@ _xed_tab_get_icon (XedTab *tab) * * Gets the #XedTab associated with @doc. * - * Returns: the #XedTab associated with @doc + * Returns: (transfer none): the #XedTab associated with @doc */ XedTab * xed_tab_get_from_document (XedDocument *doc) { gpointer res; - + g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL); - + res = g_object_get_data (G_OBJECT (doc), XED_TAB_KEY); - + return (res != NULL) ? XED_TAB (res) : NULL; } @@ -2049,11 +2049,11 @@ _xed_tab_save (XedTab *tab) /* uri used in error messages, will be freed in document_saved */ tab->priv->tmp_save_uri = xed_document_get_uri (doc); - tab->priv->tmp_encoding = xed_document_get_encoding (doc); + tab->priv->tmp_encoding = xed_document_get_encoding (doc); if (tab->priv->auto_save_timeout > 0) remove_auto_save_timeout (tab); - + xed_document_save (doc, save_flags); } @@ -2063,12 +2063,12 @@ xed_tab_auto_save (XedTab *tab) XedDocument *doc; xed_debug (DEBUG_TAB); - + g_return_val_if_fail (tab->priv->tmp_save_uri == NULL, FALSE); g_return_val_if_fail (tab->priv->tmp_encoding == NULL, FALSE); - + doc = xed_tab_get_document (tab); - + g_return_val_if_fail (!xed_document_is_untitled (doc), FALSE); g_return_val_if_fail (!xed_document_get_readonly (doc), FALSE); @@ -2082,7 +2082,7 @@ xed_tab_auto_save (XedTab *tab) return TRUE; } - + if ((tab->priv->state != XED_TAB_STATE_NORMAL) && (tab->priv->state != XED_TAB_STATE_SHOWING_PRINT_PREVIEW)) { @@ -2101,12 +2101,12 @@ xed_tab_auto_save (XedTab *tab) /* Returns FALSE so the old timeout is "destroyed" */ return FALSE; } - + xed_tab_set_state (tab, XED_TAB_STATE_SAVING); /* uri used in error messages, will be freed in document_saved */ tab->priv->tmp_save_uri = xed_document_get_uri (doc); - tab->priv->tmp_encoding = xed_document_get_encoding (doc); + tab->priv->tmp_encoding = xed_document_get_encoding (doc); /* Set auto_save_timeout to 0 since the timeout is going to be destroyed */ tab->priv->auto_save_timeout = 0; @@ -2116,9 +2116,9 @@ xed_tab_auto_save (XedTab *tab) error happens while saving, the last backup is not preserved since the user expressed his willing of saving the file */ xed_document_save (doc, tab->priv->save_flags | XED_DOCUMENT_SAVE_PRESERVE_BACKUP); - + xed_debug_message (DEBUG_TAB, "Done"); - + /* Returns FALSE so the old timeout is "destroyed" */ return FALSE; } @@ -2245,7 +2245,7 @@ printing_cb (XedPrintJob *job, XedPrintJobStatus status, XedTab *tab) { - g_return_if_fail (XED_IS_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); + g_return_if_fail (XED_IS_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); gtk_widget_show (tab->priv->message_area); @@ -2368,9 +2368,9 @@ print_preview_destroyed (GtkWidget *preview, * preview. In this case let us continue whithout changing * the state and show the document. See bug #352658 */ gtk_widget_show (tab->priv->view_scrolled_window); - + g_return_if_fail (tab->priv->state == XED_TAB_STATE_PRINTING); - } + } } #endif @@ -2397,7 +2397,7 @@ show_preview_cb (XedPrintJob *job, g_signal_connect (tab->priv->print_preview, "destroy", G_CALLBACK (print_preview_destroyed), - tab); + tab); */ xed_tab_set_state (tab, XED_TAB_STATE_SHOWING_PRINT_PREVIEW); } @@ -2410,7 +2410,7 @@ set_print_preview (XedTab *tab, { if (tab->priv->print_preview == print_preview) return; - + if (tab->priv->print_preview != NULL) gtk_widget_destroy (tab->priv->print_preview); @@ -2420,7 +2420,7 @@ set_print_preview (XedTab *tab, tab->priv->print_preview, TRUE, TRUE, - 0); + 0); gtk_widget_grab_focus (tab->priv->print_preview); @@ -2438,17 +2438,17 @@ preview_finished_cb (GtkSourcePrintJob *pjob, XedTab *tab) g_return_if_fail (XED_IS_PROGRESS_MESSAGE_AREA (tab->priv->message_area)); set_message_area (tab, NULL); /* destroy the message area */ - + gjob = gtk_source_print_job_get_print_job (pjob); - preview = xed_print_job_preview_new (gjob); + preview = xed_print_job_preview_new (gjob); g_object_unref (gjob); - + set_print_preview (tab, preview); - + gtk_widget_show (preview); g_object_unref (pjob); - + xed_tab_set_state (tab, XED_TAB_STATE_SHOWING_PRINT_PREVIEW); } @@ -2485,7 +2485,7 @@ show_printing_message_area (XedTab *tab, gboolean preview) "response", G_CALLBACK (print_cancelled), tab); - + set_message_area (tab, area); } @@ -2508,7 +2508,7 @@ xed_tab_print_or_print_preview (XedTab *tab, is_preview = (print_action == GTK_PRINT_OPERATION_ACTION_PREVIEW); tab->priv->print_job = xed_print_job_new (view); - g_object_add_weak_pointer (G_OBJECT (tab->priv->print_job), + g_object_add_weak_pointer (G_OBJECT (tab->priv->print_job), (gpointer *) &tab->priv->print_job); show_printing_message_area (tab, is_preview); @@ -2552,7 +2552,7 @@ xed_tab_print_or_print_preview (XedTab *tab, } } -void +void _xed_tab_print (XedTab *tab) { g_return_if_fail (XED_IS_TAB (tab)); @@ -2578,12 +2578,12 @@ _xed_tab_print_preview (XedTab *tab) GTK_PRINT_OPERATION_ACTION_PREVIEW); } -void +void _xed_tab_mark_for_closing (XedTab *tab) { g_return_if_fail (XED_IS_TAB (tab)); g_return_if_fail (tab->priv->state == XED_TAB_STATE_NORMAL); - + xed_tab_set_state (tab, XED_TAB_STATE_CLOSING); } @@ -2607,7 +2607,7 @@ _xed_tab_can_close (XedTab *tab) /* Do not close tab with saving errors */ if (ts == XED_TAB_STATE_SAVING_ERROR) return FALSE; - + doc = xed_tab_get_document (tab); /* TODO: we need to save the file also if it has been externally @@ -2620,9 +2620,9 @@ _xed_tab_can_close (XedTab *tab) /** * xed_tab_get_auto_save_enabled: * @tab: a #XedTab - * + * * Gets the current state for the autosave feature - * + * * Return value: %TRUE if the autosave is enabled, else %FALSE **/ gboolean @@ -2639,12 +2639,12 @@ xed_tab_get_auto_save_enabled (XedTab *tab) * xed_tab_set_auto_save_enabled: * @tab: a #XedTab * @enable: enable (%TRUE) or disable (%FALSE) auto save - * + * * Enables or disables the autosave feature. It does not install an * autosave timeout if the document is new or is read-only **/ void -xed_tab_set_auto_save_enabled (XedTab *tab, +xed_tab_set_auto_save_enabled (XedTab *tab, gboolean enable) { XedDocument *doc = NULL; @@ -2659,7 +2659,7 @@ xed_tab_set_auto_save_enabled (XedTab *tab, tab->priv->auto_save = enable; - if (enable && + if (enable && (tab->priv->auto_save_timeout <=0) && !xed_document_is_untitled (doc) && !xed_document_get_readonly (doc)) @@ -2675,30 +2675,30 @@ xed_tab_set_auto_save_enabled (XedTab *tab, } /* else: the timeout will be installed when loading/saving/reverting will terminate */ - + return; } - + if (!enable && (tab->priv->auto_save_timeout > 0)) { remove_auto_save_timeout (tab); - - return; - } - g_return_if_fail ((!enable && (tab->priv->auto_save_timeout <= 0)) || - xed_document_is_untitled (doc) || xed_document_get_readonly (doc)); + return; + } + + g_return_if_fail ((!enable && (tab->priv->auto_save_timeout <= 0)) || + xed_document_is_untitled (doc) || xed_document_get_readonly (doc)); } /** * xed_tab_get_auto_save_interval: * @tab: a #XedTab - * + * * Gets the current interval for the autosaves - * + * * Return value: the value of the autosave **/ -gint +gint xed_tab_get_auto_save_interval (XedTab *tab) { xed_debug (DEBUG_TAB); @@ -2712,20 +2712,20 @@ xed_tab_get_auto_save_interval (XedTab *tab) * xed_tab_set_auto_save_interval: * @tab: a #XedTab * @interval: the new interval - * + * * Sets the interval for the autosave feature. It does nothing if the * interval is the same as the one already present. It removes the old * interval timeout and adds a new one with the autosave passed as * argument. **/ -void -xed_tab_set_auto_save_interval (XedTab *tab, +void +xed_tab_set_auto_save_interval (XedTab *tab, gint interval) { XedDocument *doc = NULL; - + xed_debug (DEBUG_TAB); - + g_return_if_fail (XED_IS_TAB (tab)); doc = xed_tab_get_document(tab); @@ -2737,7 +2737,7 @@ xed_tab_set_auto_save_interval (XedTab *tab, return; tab->priv->auto_save_interval = interval; - + if (!tab->priv->auto_save) return; diff --git a/xed/xed-utils.c b/xed/xed-utils.c index 600ff50..5fb81c1 100644 --- a/xed/xed-utils.c +++ b/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? * - * paolo: and flame whoever tells - * you that file:///mate/test_files/hëllò + * paolo: and flame whoever tells + * you that file:///mate/test_files/hëllò * doesn't work --- that's not a valid URI * - * federico: well, another solution that - * does not requires patch to _from_shell_args - * is to check that the string returned by it + * 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 - * paolo: hmmmm, isn't there + * paolo: hmmmm, isn't there * mate_vfs_is_uri_valid() or something? * : 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; } diff --git a/xed/xed-window.c b/xed/xed-window.c index 1b50c99..545b4b1 100644 --- a/xed/xed-window.c +++ b/xed/xed-window.c @@ -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. */