gboolean file_exists_and_is_not_folder;
GFile *parent_file;
GFile *file;
- gchar *name;
};
static void
else
{
gtk_widget_set_sensitive (priv->new_folder_create_button, TRUE);
-
- // If file doesn't exist, warn if string begins or ends with whitespace
- if (g_ascii_isspace (data->name[0]))
- gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label),
- "Folder names should not begin with a space");
-
- else if (g_ascii_isspace (data->name[strlen (data->name) - 1]))
- gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label),
- "Folder names should not end with a space");
-
- else
- gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label), "");
+ /* Don't clear the label here, it may contain a warning */
}
out:
g_object_unref (impl);
g_object_unref (data->file);
g_object_unref (data->parent_file);
- g_free (data->name);
g_free (data);
g_object_unref (cancellable);
}
GFile *file;
GError *error = NULL;
+ gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label), "");
+
file = g_file_get_child_for_display_name (priv->current_folder, name, &error);
if (file == NULL)
{
{
struct FileExistsData *data;
- gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label), "");
+ /* Warn the user about questionable names that are technically valid */
+ if (g_ascii_isspace (name[0]))
+ gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label),
+ _("Folder names should not begin with a space"));
+
+ else if (g_ascii_isspace (name[strlen (name) - 1]))
+ gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label),
+ _("Folder names should not end with a space"));
+ else if (name[0] == '.')
+ gtk_label_set_text (GTK_LABEL (priv->new_folder_error_label),
+ _("Folder names starting with a “.” are hidden"));
data = g_new0 (struct FileExistsData, 1);
data->impl = g_object_ref (impl);
data->parent_file = g_object_ref (priv->current_folder);
data->file = g_object_ref (file);
- data->name = g_strdup(name);
if (priv->file_exists_get_info_cancellable)
g_cancellable_cancel (priv->file_exists_get_info_cancellable);
g_object_unref (data->impl);
g_object_unref (data->file);
g_object_unref (data->parent_file);
- g_free (data->name);
g_free (data);
g_object_unref (cancellable);
g_object_unref (impl);
g_object_unref (data->file);
g_object_unref (data->parent_file);
- g_free (data->name);
g_free (data);
}