diff --git a/data/meson.build b/data/meson.build index 2df5a226c3440eaa3752f4ff8d3a18b3a0e87e70..953b81408374ed145f1c2d47972f67fea54ac0d7 100644 --- a/data/meson.build +++ b/data/meson.build @@ -135,4 +135,5 @@ if appstream_util.found() endif subdir('ontology') +subdir('templates') subdir('tracker') diff --git a/data/templates/document.odt b/data/templates/document.odt new file mode 100644 index 0000000000000000000000000000000000000000..2a9ef52dea635c13fe1be2a50b958263d7032059 Binary files /dev/null and b/data/templates/document.odt differ diff --git a/data/templates/meson.build b/data/templates/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..1b00e15ab129e29098a4fd5ba6e86bddb2c50ddc --- /dev/null +++ b/data/templates/meson.build @@ -0,0 +1,9 @@ +templates_data = files( + 'document.odt', + 'spreadsheet.ods', + 'presentation.odp' +) + +install_data(templates_data, + install_dir: join_paths(datadir, 'nautilus', 'templates') +) \ No newline at end of file diff --git a/data/templates/presentation.odp b/data/templates/presentation.odp new file mode 100644 index 0000000000000000000000000000000000000000..6095afffb06def8fa0eed3cc7d639af5980fe9b9 Binary files /dev/null and b/data/templates/presentation.odp differ diff --git a/data/templates/spreadsheet.ods b/data/templates/spreadsheet.ods new file mode 100644 index 0000000000000000000000000000000000000000..16d4f2348424352a11bd5bc1b3c8e2f45413cce5 Binary files /dev/null and b/data/templates/spreadsheet.ods differ diff --git a/po/POTFILES.in b/po/POTFILES.in index 6bea74b3765d85492ec85f15afa93650841659b4..61c9239401498ee90de2016c6fa9ad80097da94c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -39,6 +39,7 @@ src/nautilus-list-view.c src/nautilus-location-entry.c src/nautilus-main.c src/nautilus-mime-actions.c +src/nautilus-new-file-dialog-controller.c src/nautilus-new-folder-dialog-controller.c src/nautilus-operations-ui-manager.c src/nautilus-pathbar.c @@ -69,6 +70,7 @@ src/resources/ui/nautilus-app-chooser.ui src/resources/ui/nautilus-batch-rename-dialog.ui src/resources/ui/nautilus-column-chooser.ui src/resources/ui/nautilus-compress-dialog.ui +src/resources/ui/nautilus-create-file-dialog.ui src/resources/ui/nautilus-create-folder-dialog.ui src/resources/ui/nautilus-file-conflict-dialog.ui src/resources/ui/nautilus-file-properties-change-permissions.ui diff --git a/src/meson.build b/src/meson.build index e682b99bad3d1ed1805e9c9aa734afcca7d73bb5..a866a2e9a9c63d441141f0b7b82b607bbdcb494c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -178,6 +178,8 @@ libnautilus_sources = [ 'nautilus-rename-file-popover-controller.h', 'nautilus-templates-dialog.c', 'nautilus-templates-dialog.h', + 'nautilus-new-file-dialog-controller.c', + 'nautilus-new-file-dialog-controller.h', 'nautilus-new-folder-dialog-controller.c', 'nautilus-new-folder-dialog-controller.h', 'nautilus-compress-dialog-controller.c', diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 4d4b2f4ac1d6f28e926b602d9c0ae696af396455..d65d4cf582a5065b2aded17142c5b4dd4ba00aa7 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -75,6 +75,8 @@ #include "nautilus-metadata.h" #include "nautilus-mime-actions.h" #include "nautilus-module.h" +#include "nautilus-templates-dialog.h" +#include "nautilus-new-file-dialog-controller.h" #include "nautilus-new-folder-dialog-controller.h" #include "nautilus-previewer.h" #include "nautilus-profile.h" @@ -165,6 +167,7 @@ typedef struct NautilusWindowSlot *slot; NautilusDirectory *model; + NautilusDirectory *templates_directory; NautilusFile *directory_as_file; GFile *location; guint dir_merge_id; @@ -172,6 +175,8 @@ typedef struct NautilusQuery *search_query; NautilusRenameFilePopoverController *rename_file_controller; + NautilusTemplatesDialog *templates_dialog; + NautilusNewFileDialogController *new_file_controller; NautilusNewFolderDialogController *new_folder_controller; NautilusCompressDialogController *compress_controller; @@ -234,6 +239,8 @@ typedef struct gboolean metadata_for_directory_as_file_pending; gboolean metadata_for_files_in_directory_pending; + gboolean has_templates; + GList *subdirectory_list; GMenu *selection_menu_model; @@ -343,6 +350,11 @@ static void set_search_query_internal (NautilusFilesView *files_view, static gboolean nautilus_files_view_is_read_only (NautilusFilesView *view); +static void nautilus_files_view_new_file (NautilusFilesView *directory_view, + const char *parent_uri, + const char *target_filename, + NautilusFile *source); + G_DEFINE_TYPE_WITH_CODE (NautilusFilesView, nautilus_files_view, ADW_TYPE_BIN, @@ -2041,6 +2053,62 @@ new_folder_dialog_controller_on_cancelled (NautilusNewFolderDialogController *co g_clear_object (&priv->new_folder_controller); } +static void +templates_dialog_on_response (GtkDialog *dialog, + int response_id, + gpointer *user_data) +{ + NautilusFilesView *view; + NautilusFilesViewPrivate *priv; + + view = NAUTILUS_FILES_VIEW (user_data); + priv = nautilus_files_view_get_instance_private (view); + + gtk_window_destroy (GTK_WINDOW (dialog)); + priv->templates_dialog = NULL; +} + +static void +new_file_dialog_controller_on_name_accepted (NautilusFileNameWidgetController *controller, + NautilusFilesView *self) +{ + NautilusFilesViewPrivate *priv; + gchar *template_name = NULL; + g_autofree gchar *template_path = NULL; + g_autoptr (GFile) template_location = NULL; + g_autofree gchar *name = NULL; + g_autoptr (NautilusFile) file = NULL; + + priv = nautilus_files_view_get_instance_private (self); + + template_name = nautilus_new_file_dialog_controller_get_template_name (NAUTILUS_NEW_FILE_DIALOG_CONTROLLER (controller)); + name = nautilus_file_name_widget_controller_get_new_name (controller); + + if (template_name != NULL) + { + template_path = g_build_filename (NAUTILUS_DATADIR, "templates", template_name, NULL); + template_location = g_file_new_for_path (template_path); + file = nautilus_file_get (template_location); + } + + nautilus_files_view_new_file (self, NULL, name, file); + + g_clear_object (&priv->new_file_controller); + + gtk_widget_grab_focus (GTK_WIDGET (self)); +} + +static void +new_file_dialog_controller_on_cancelled (NautilusNewFileDialogController *controller, + NautilusFilesView *self) +{ + NautilusFilesViewPrivate *priv; + + priv = nautilus_files_view_get_instance_private (self); + + g_clear_object (&priv->new_file_controller); +} + static void nautilus_files_view_new_folder_dialog_new (NautilusFilesView *view, gboolean with_selection) @@ -2382,6 +2450,7 @@ nautilus_files_view_new_file_with_initial_contents (NautilusFilesView *view, static void nautilus_files_view_new_file (NautilusFilesView *directory_view, const char *parent_uri, + const char *target_filename, NautilusFile *source) { NewFolderData *data; @@ -2399,7 +2468,7 @@ nautilus_files_view_new_file (NautilusFilesView *directory_view, { nautilus_files_view_new_file_with_initial_contents (directory_view, parent_uri != NULL ? parent_uri : container_uri, - NULL, + target_filename, NULL, 0); g_free (container_uri); @@ -2412,7 +2481,7 @@ nautilus_files_view_new_file (NautilusFilesView *directory_view, nautilus_file_operations_new_file_from_template (GTK_WIDGET (directory_view), parent_uri != NULL ? parent_uri : container_uri, - NULL, + target_filename, source_uri, new_folder_done, data); @@ -2420,6 +2489,83 @@ nautilus_files_view_new_file (NautilusFilesView *directory_view, g_free (container_uri); } +static void +templates_changed_cb (NautilusDirectory *directory, + NautilusFilesView *files_view, + gpointer callback_data) +{ + NautilusFilesViewPrivate *priv; + NautilusFilesView *view; + + view = NAUTILUS_FILES_VIEW (callback_data); + + g_assert (NAUTILUS_IS_FILES_VIEW (view)); + + priv = nautilus_files_view_get_instance_private (view); + + priv->has_templates = nautilus_directory_is_not_empty (directory); +} + +static void +action_new_file (GSimpleAction *action, + GVariant *state, + gpointer user_data) +{ + g_autoptr (NautilusDirectory) containing_directory = NULL; + NautilusFilesView *view; + NautilusFilesViewPrivate *priv; + g_autofree char *uri = NULL; + g_autofree char *templates_uri = NULL; + + g_assert (NAUTILUS_IS_FILES_VIEW (user_data)); + + view = NAUTILUS_FILES_VIEW (user_data); + priv = nautilus_files_view_get_instance_private (view); + uri = nautilus_files_view_get_backing_uri (view); + containing_directory = nautilus_directory_get_by_uri (uri); + + if (!priv->has_templates) /* if the XDG Templates directory is empty */ + { + if (priv->new_file_controller != NULL) + { + return; + } + + priv->new_file_controller = + nautilus_new_file_dialog_controller_new (nautilus_files_view_get_containing_window (view), + containing_directory); + + g_signal_connect_object (priv->new_file_controller, + "name-accepted", + G_CALLBACK (new_file_dialog_controller_on_name_accepted), + view, + 0); + g_signal_connect_object (priv->new_file_controller, + "cancelled", + G_CALLBACK (new_file_dialog_controller_on_cancelled), + view, + 0); + } + else + { + if (priv->templates_dialog != NULL) + { + return; + } + + + priv->templates_dialog = + nautilus_templates_dialog_new (nautilus_files_view_get_containing_window (view)); + gtk_window_present (GTK_WINDOW (priv->templates_dialog)); + + g_signal_connect_object (priv->templates_dialog, + "response", + G_CALLBACK (templates_dialog_on_response), + view, + 0); + } +} + static void action_new_folder (GSimpleAction *action, GVariant *state, @@ -3196,6 +3342,13 @@ nautilus_files_view_dispose (GObject *object) priv->subdirectory_list->data); } + if (priv->templates_directory != NULL) + { + nautilus_directory_file_monitor_remove (priv->templates_directory, view); + g_object_unref (priv->templates_directory); + priv->templates_directory = NULL; + } + remove_update_context_menus_timeout_callback (view); remove_update_status_idle_callback (view); @@ -3272,6 +3425,7 @@ nautilus_files_view_finalize (GObject *object) g_clear_object (&priv->toolbar_menu_sections->sort_section); g_clear_object (&priv->extensions_background_menu); g_clear_object (&priv->rename_file_controller); + g_clear_object (&priv->new_file_controller); g_clear_object (&priv->new_folder_controller); g_clear_object (&priv->compress_controller); /* We don't own the slot, so no unref */ @@ -6695,6 +6849,7 @@ const GActionEntry view_entries[] = { "show-hidden-files", NULL, NULL, "true", action_show_hidden_files }, /* Background menu */ { "new-folder", action_new_folder }, + { "new-file", action_new_file }, { "select-all", action_select_all }, { "paste", action_paste_files }, { "copy-current-location", action_copy_current_location }, @@ -7414,6 +7569,9 @@ real_update_actions_state (NautilusFilesView *view) action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "new-folder"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files); + action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), + "new-file"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files); action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "paste"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), @@ -9289,9 +9447,20 @@ nautilus_files_view_init (NautilusFilesView *view) { templates_uri = nautilus_get_templates_directory_uri (); templates_directory = nautilus_directory_get_by_uri (templates_uri); + priv->templates_directory = templates_directory; g_free (templates_uri); add_directory_to_templates_directory_list (view, templates_directory); - nautilus_directory_unref (templates_directory); + + /* Monitor templates directory */ + + nautilus_directory_file_monitor_add (templates_directory, view, + FALSE, NAUTILUS_FILE_ATTRIBUTE_INFO, + (NautilusDirectoryCallback) templates_changed_cb, view); + + g_signal_connect_object (templates_directory, "files-added", + G_CALLBACK (templates_changed_cb), view, 0); + g_signal_connect_object (templates_directory, "files-changed", + G_CALLBACK (templates_changed_cb), view, 0); } priv->sort_directories_first = diff --git a/src/nautilus-new-file-dialog-controller.c b/src/nautilus-new-file-dialog-controller.c new file mode 100644 index 0000000000000000000000000000000000000000..e66d541e99334d3f807e0a42dd4e6e7d451f8049 --- /dev/null +++ b/src/nautilus-new-file-dialog-controller.c @@ -0,0 +1,298 @@ +/* nautilus-new-file-dialog-controller.c + * + * Copyright 2022 Ignacy Kuchciński + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "nautilus-new-file-dialog-controller.h" + +#include + +#include "nautilus-application.h" + +struct _NautilusNewFileDialogController +{ + NautilusFileNameWidgetController parent_instance; + + GtkDialog *new_file_dialog; + GtkLabel *extension_label; + + gchar *template_name; + gchar *extension; +}; + +G_DEFINE_TYPE (NautilusNewFileDialogController, nautilus_new_file_dialog_controller, NAUTILUS_TYPE_FILE_NAME_WIDGET_CONTROLLER) + +static gboolean +nautilus_new_file_dialog_controller_name_is_valid (NautilusFileNameWidgetController *self, + gchar *name, + gchar **error_message) +{ + gboolean is_valid; + + is_valid = TRUE; + if (strlen (name) == 0) + { + is_valid = FALSE; + } + else if (strstr (name, "/") != NULL) + { + is_valid = FALSE; + *error_message = _("File names cannot contain “/“."); + } + else if (strcmp (name, ".") == 0) + { + is_valid = FALSE; + *error_message = _("A file cannot be called “.“."); + } + else if (strcmp (name, "..") == 0) + { + is_valid = FALSE; + *error_message = _("A file cannot be called “..“."); + } + else if (nautilus_file_name_widget_controller_is_name_too_long (self, name)) + { + is_valid = FALSE; + *error_message = _("File name is too long."); + } + else if (g_str_has_prefix (name, ".")) + { + /* We must warn about the side effect */ + *error_message = _("Files with “.“ at the beginning of their name are hidden."); + } + + return is_valid; +} + +static gchar * +nautilus_new_file_dialog_controller_get_new_name (NautilusFileNameWidgetController *controller) +{ + NautilusNewFileDialogController *self; + g_autofree gchar *basename = NULL; + + self = NAUTILUS_NEW_FILE_DIALOG_CONTROLLER (controller); + + basename = NAUTILUS_FILE_NAME_WIDGET_CONTROLLER_CLASS (nautilus_new_file_dialog_controller_parent_class)->get_new_name (controller); + + if (g_str_has_suffix (basename, self->extension)) + { + return g_strdup (basename); + } + + return g_strconcat (basename, self->extension, NULL); +} + + +gchar * +nautilus_new_file_dialog_controller_get_template_name (NautilusNewFileDialogController *self) +{ + return self->template_name; +} + +static void +new_file_dialog_controller_on_response (GtkDialog *dialog, + int response, + NautilusNewFileDialogController *self) +{ + if (response != GTK_RESPONSE_OK) + { + g_signal_emit_by_name (self, "cancelled"); + } +} + +static void +text_action_row_on_activated (GtkCheckButton *check_button, + NautilusNewFileDialogController *self) +{ + self->template_name = NULL; + self->extension = ".txt"; + gtk_label_set_text (self->extension_label, ".txt"); +} + +static void +document_action_row_on_activated (GtkCheckButton *check_button, + NautilusNewFileDialogController *self) +{ + self->template_name = "document.odt"; + self->extension = ".odt"; + gtk_label_set_text (self->extension_label, ".odt"); +} + +static void +spreadsheet_action_row_on_activated (GtkCheckButton *check_button, + NautilusNewFileDialogController *self) +{ + self->template_name = "spreadsheet.ods"; + self->extension = ".ods"; + gtk_label_set_text (self->extension_label, ".ods"); +} + +static void +presentation_action_row_on_activated (GtkCheckButton *check_button, + NautilusNewFileDialogController *self) +{ + self->template_name = "presentation.odp"; + self->extension = ".odp"; + gtk_label_set_text (self->extension_label, ".odp"); +} + +NautilusNewFileDialogController * +nautilus_new_file_dialog_controller_new (GtkWindow *parent_window, + NautilusDirectory *destination_directory) +{ + NautilusNewFileDialogController *self; + g_autoptr (GtkBuilder) builder = NULL; + GtkDialog *new_file_dialog; + GtkLabel *extension_label; + GtkRevealer *error_revealer; + GtkLabel *error_label; + AdwEntryRow *name_entry; + GtkButton *activate_button; + GList *recommended_apps; + AdwActionRow *text_action_row; + AdwActionRow *document_action_row; + AdwActionRow *spreadsheet_action_row; + AdwActionRow *presentation_action_row; + gboolean not_sandboxed; + + builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-create-file-dialog.ui"); + new_file_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "create_file_dialog")); + extension_label = GTK_LABEL (gtk_builder_get_object (builder, "extension_label")); + error_revealer = GTK_REVEALER (gtk_builder_get_object (builder, "error_revealer")); + error_label = GTK_LABEL (gtk_builder_get_object (builder, "error_label")); + name_entry = ADW_ENTRY_ROW (gtk_builder_get_object (builder, "name_entry")); + activate_button = GTK_BUTTON (gtk_builder_get_object (builder, "ok_button")); + text_action_row = ADW_ACTION_ROW (gtk_builder_get_object (builder, "text_action_row")); + document_action_row = ADW_ACTION_ROW (gtk_builder_get_object (builder, "document_action_row")); + spreadsheet_action_row = ADW_ACTION_ROW (gtk_builder_get_object (builder, "spreadsheet_action_row")); + presentation_action_row = ADW_ACTION_ROW (gtk_builder_get_object (builder, "presentation_action_row")); + + gtk_window_set_transient_for (GTK_WINDOW (new_file_dialog), parent_window); + + self = g_object_new (NAUTILUS_TYPE_NEW_FILE_DIALOG_CONTROLLER, + "error-revealer", error_revealer, + "error-label", error_label, + "name-entry", name_entry, + "activate-button", activate_button, + "containing-directory", destination_directory, NULL); + + self->new_file_dialog = new_file_dialog; + self->extension_label = extension_label; + + g_signal_connect_object (new_file_dialog, + "response", + G_CALLBACK (new_file_dialog_controller_on_response), + self, + 0); + + g_signal_connect_object (text_action_row, + "activated", + G_CALLBACK (text_action_row_on_activated), + self, + 0); + + g_signal_connect_object (document_action_row, + "activated", + G_CALLBACK (document_action_row_on_activated), + self, + 0); + + g_signal_connect_object (spreadsheet_action_row, + "activated", + G_CALLBACK (spreadsheet_action_row_on_activated), + self, + 0); + + g_signal_connect_object (presentation_action_row, + "activated", + G_CALLBACK (presentation_action_row_on_activated), + self, + 0); + + recommended_apps = g_app_info_get_recommended_for_type ("application/vnd.oasis.opendocument.presentation"); + not_sandboxed = !nautilus_application_is_sandboxed (); + + if (recommended_apps == NULL && not_sandboxed) + { + gtk_widget_set_visible (GTK_WIDGET (presentation_action_row), FALSE); + } + else + { + g_list_free_full (recommended_apps, g_object_unref); + } + + recommended_apps = g_app_info_get_recommended_for_type ("application/vnd.oasis.opendocument.spreadsheet"); + + if (recommended_apps == NULL && not_sandboxed) + { + gtk_widget_set_visible (GTK_WIDGET (spreadsheet_action_row), FALSE); + } + else + { + g_list_free_full (recommended_apps, g_object_unref); + } + + recommended_apps = g_app_info_get_recommended_for_type ("application/vnd.oasis.opendocument.text"); + + if (recommended_apps == NULL && not_sandboxed) + { + gtk_widget_set_visible (GTK_WIDGET (document_action_row), FALSE); + } + else + { + g_list_free_full (recommended_apps, g_object_unref); + } + + adw_action_row_activate (text_action_row); + + gtk_widget_show (GTK_WIDGET (new_file_dialog)); + + return self; +} + +static void +nautilus_new_file_dialog_controller_init (NautilusNewFileDialogController *self) +{ +} + +static void +nautilus_new_file_dialog_controller_finalize (GObject *gobject) +{ + NautilusNewFileDialogController *self; + + self = NAUTILUS_NEW_FILE_DIALOG_CONTROLLER (gobject); + + if (self->new_file_dialog != NULL) + { + gtk_window_destroy (GTK_WINDOW (self->new_file_dialog)); + self->new_file_dialog = NULL; + } + + G_OBJECT_CLASS (nautilus_new_file_dialog_controller_parent_class)->finalize (gobject); +} + +static void +nautilus_new_file_dialog_controller_class_init (NautilusNewFileDialogControllerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NautilusFileNameWidgetControllerClass *parent_class = NAUTILUS_FILE_NAME_WIDGET_CONTROLLER_CLASS (klass); + + object_class->finalize = nautilus_new_file_dialog_controller_finalize; + + parent_class->name_is_valid = nautilus_new_file_dialog_controller_name_is_valid; + parent_class->get_new_name = nautilus_new_file_dialog_controller_get_new_name; +} diff --git a/src/nautilus-new-file-dialog-controller.h b/src/nautilus-new-file-dialog-controller.h new file mode 100644 index 0000000000000000000000000000000000000000..f2153f1980b3e6786e71044bc0074d52cfc842da --- /dev/null +++ b/src/nautilus-new-file-dialog-controller.h @@ -0,0 +1,45 @@ +/* nautilus-new-file-dialog-controller.h + * + * Copyright 2022 Ignacy Kuchciński + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include + +#include "nautilus-file-name-widget-controller.h" +#include "nautilus-directory.h" + +G_BEGIN_DECLS + +#define NAUTILUS_TYPE_NEW_FILE_DIALOG_CONTROLLER (nautilus_new_file_dialog_controller_get_type ()) + +G_DECLARE_FINAL_TYPE (NautilusNewFileDialogController, nautilus_new_file_dialog_controller, NAUTILUS, NEW_FILE_DIALOG_CONTROLLER, NautilusFileNameWidgetController) + +NautilusNewFileDialogController * nautilus_new_file_dialog_controller_new (GtkWindow *parent_window, + NautilusDirectory *destination_directory); + +/** + * nautilus_new_file_dialog_controller_get_template_name: + * + * Returns: the filename of the chosen blank template, or NULL if the chosen + * file type is a text file + */ +gchar * nautilus_new_file_dialog_controller_get_template_name (NautilusNewFileDialogController *self); + +G_END_DECLS diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml index 2866224ffbe799e216385cd3452c42202ed2bd61..56b5697da801c5aaab24e3ca9d7316c6cf35be56 100644 --- a/src/resources/nautilus.gresource.xml +++ b/src/resources/nautilus.gresource.xml @@ -13,6 +13,7 @@ ui/nautilus-column-chooser.ui ui/nautilus-list-view-column-editor.ui ui/nautilus-templates-dialog.ui + ui/nautilus-create-file-dialog.ui ui/nautilus-create-folder-dialog.ui ui/nautilus-compress-dialog.ui ui/nautilus-rename-file-popover.ui diff --git a/src/resources/ui/nautilus-create-file-dialog.ui b/src/resources/ui/nautilus-create-file-dialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..af3a19972bcc94c7291b94ff25f4faa9a5ff4ebd --- /dev/null +++ b/src/resources/ui/nautilus-create-file-dialog.ui @@ -0,0 +1,130 @@ + + + + New File + True + 1 + 500 + 450 + + + + + 18 + 18 + 18 + 18 + + + vertical + 12 + + + + + File Name + + + .txt + + + + + + + + + + + + + + + 0 + + + + + + + + + text-x-generic-symbolic + _Text File + true + + + True + + + text_check_button + + + + + x-office-document-symbolic + _Document + true + + + text_check_button + + + document_check_button + + + + + x-office-spreadsheet-symbolic + _Spreadsheet + true + + + text_check_button + + + spreadsheet_check_button + + + + + x-office-presentation-symbolic + _Presentation + true + + + text_check_button + + + presentation_check_button + + + + + + + + + + + + + _Cancel + true + + + + + C_reate + true + False + + + + ok_button + cancel_button + + + diff --git a/src/resources/ui/nautilus-files-view-context-menus.ui b/src/resources/ui/nautilus-files-view-context-menus.ui index 1bcd861b0bef606e283837b36fa20363c96b569e..c51170e771b76a66df17e605a3d4fa0a8f910018 100644 --- a/src/resources/ui/nautilus-files-view-context-menus.ui +++ b/src/resources/ui/nautilus-files-view-context-menus.ui @@ -6,6 +6,11 @@ New _Folder… view.new-folder + + _New File + view.new-file + action-disabled + Open _With… view.open-current-directory-with-other-application