[nautilus/gsoc-2022: 2/2] files-view: Remove templates menu




commit 389b44833661c4393829ea58e916b305e3c2d2d0
Author: utkarshvg2401 <utkarshvg2401 gmail com>
Date:   Mon Aug 8 15:27:22 2022 +0530

    files-view: Remove templates menu
    
    The current implementation of the “New Documents” submenu is a GtkPopoverMenu which has many issues, 
hence it is being replaced by a dialog box for the creation of templates.
    So, the GtkPopoverMenu implementation is to be removed completely from the codebase.

 src/nautilus-files-view.c                          | 424 ---------------------
 src/nautilus-pathbar.c                             |  31 --
 src/nautilus-pathbar.h                             |   3 +-
 src/nautilus-toolbar.c                             |  14 -
 src/nautilus-view.c                                |  29 --
 src/nautilus-view.h                                |  11 +-
 src/nautilus-window-slot.c                         |  62 +--
 src/nautilus-window-slot.h                         |   2 -
 .../ui/nautilus-files-view-context-menus.ui        |   5 -
 src/resources/ui/nautilus-pathbar-context-menu.ui  |   5 -
 10 files changed, 3 insertions(+), 583 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 32f08cce6..4d4b2f4ac 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -148,7 +148,6 @@ enum
     PROP_LOCATION,
     PROP_SEARCH_QUERY,
     PROP_EXTENSIONS_BACKGROUND_MENU,
-    PROP_TEMPLATES_MENU,
     NUM_PROPERTIES
 };
 
@@ -263,7 +262,6 @@ typedef struct
 
     /* Exposed menus, for the path bar etc. */
     GMenuModel *extensions_background_menu;
-    GMenuModel *templates_menu;
 
     /* Non exported menu, only for caching */
     GMenuModel *scripts_menu;
@@ -327,8 +325,6 @@ static void     nautilus_files_view_trash_state_changed_callback (NautilusTrashM
 static void     nautilus_files_view_select_file (NautilusFilesView *view,
                                                  NautilusFile      *file);
 
-static void     update_templates_directory (NautilusFilesView *view);
-
 static void     extract_files (NautilusFilesView *view,
                                GList             *files,
                                GFile             *destination_directory);
@@ -745,16 +741,6 @@ nautilus_files_view_get_toolbar_menu_sections (NautilusView *view)
     return priv->toolbar_menu_sections;
 }
 
-static GMenuModel *
-nautilus_files_view_get_templates_menu (NautilusView *self)
-{
-    GMenuModel *menu;
-
-    g_object_get (self, "templates-menu", &menu, NULL);
-
-    return menu;
-}
-
 static GMenuModel *
 nautilus_files_view_get_extensions_background_menu (NautilusView *self)
 {
@@ -777,25 +763,6 @@ real_get_extensions_background_menu (NautilusView *view)
     return priv->extensions_background_menu;
 }
 
-static GMenuModel *
-real_get_templates_menu (NautilusView *view)
-{
-    NautilusFilesViewPrivate *priv;
-
-    g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
-
-    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
-
-    return priv->templates_menu;
-}
-
-static void
-nautilus_files_view_set_templates_menu (NautilusView *self,
-                                        GMenuModel   *menu)
-{
-    g_object_set (self, "templates-menu", menu, NULL);
-}
-
 static void
 nautilus_files_view_set_extensions_background_menu (NautilusView *self,
                                                     GMenuModel   *menu)
@@ -816,19 +783,6 @@ real_set_extensions_background_menu (NautilusView *view,
     g_set_object (&priv->extensions_background_menu, menu);
 }
 
-static void
-real_set_templates_menu (NautilusView *view,
-                         GMenuModel   *menu)
-{
-    NautilusFilesViewPrivate *priv;
-
-    g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
-
-    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
-
-    g_set_object (&priv->templates_menu, menu);
-}
-
 static gboolean
 showing_trash_directory (NautilusFilesView *view)
 {
@@ -1139,27 +1093,6 @@ script_launch_parameters_free (ScriptLaunchParameters *parameters)
     g_free (parameters);
 }
 
-static CreateTemplateParameters *
-create_template_parameters_new (NautilusFile      *file,
-                                NautilusFilesView *directory_view)
-{
-    CreateTemplateParameters *result;
-
-    result = g_new0 (CreateTemplateParameters, 1);
-    result->directory_view = directory_view;
-    nautilus_file_ref (file);
-    result->file = file;
-
-    return result;
-}
-
-static void
-create_templates_parameters_free (CreateTemplateParameters *parameters)
-{
-    nautilus_file_unref (parameters->file);
-    g_free (parameters);
-}
-
 NautilusWindow *
 nautilus_files_view_get_window (NautilusFilesView *view)
 {
@@ -3136,19 +3069,6 @@ add_directory_to_templates_directory_list (NautilusFilesView *view,
                                      G_CALLBACK (templates_added_or_changed_callback));
 }
 
-static void
-remove_directory_from_templates_directory_list (NautilusFilesView *view,
-                                                NautilusDirectory *directory)
-{
-    NautilusFilesViewPrivate *priv;
-
-    priv = nautilus_files_view_get_instance_private (view);
-
-    remove_directory_from_directory_list (view, directory,
-                                          &priv->templates_directory_list,
-                                          G_CALLBACK (templates_added_or_changed_callback));
-}
-
 static void
 slot_active_changed (NautilusWindowSlot *slot,
                      GParamSpec         *pspec,
@@ -3270,12 +3190,6 @@ nautilus_files_view_dispose (GObject *object)
         remove_directory_from_scripts_directory_list (view, node->data);
     }
 
-    for (node = priv->templates_directory_list; node != NULL; node = next)
-    {
-        next = node->next;
-        remove_directory_from_templates_directory_list (view, node->data);
-    }
-
     while (priv->subdirectory_list != NULL)
     {
         nautilus_files_view_remove_subdirectory (view,
@@ -3357,7 +3271,6 @@ nautilus_files_view_finalize (GObject *object)
     g_clear_object (&priv->selection_menu_model);
     g_clear_object (&priv->toolbar_menu_sections->sort_section);
     g_clear_object (&priv->extensions_background_menu);
-    g_clear_object (&priv->templates_menu);
     g_clear_object (&priv->rename_file_controller);
     g_clear_object (&priv->new_folder_controller);
     g_clear_object (&priv->compress_controller);
@@ -5583,295 +5496,6 @@ update_scripts_menu (NautilusFilesView *view,
     g_set_object (&priv->scripts_menu, G_MENU_MODEL (submenu));
 }
 
-static void
-create_template (GSimpleAction *action,
-                 GVariant      *state,
-                 gpointer       user_data)
-{
-    CreateTemplateParameters *parameters;
-
-    parameters = user_data;
-
-    nautilus_files_view_new_file (parameters->directory_view, NULL, parameters->file);
-}
-
-static void
-add_template_to_templates_menus (NautilusFilesView *view,
-                                 NautilusFile      *file,
-                                 GMenu             *menu)
-{
-    NautilusFilesViewPrivate *priv;
-    char *uri, *name;
-    g_autofree gchar *escaped_uri = NULL;
-    GdkTexture *mimetype_icon;
-    char *action_name, *detailed_action_name;
-    CreateTemplateParameters *parameters;
-    GAction *action;
-    g_autofree char *label = NULL;
-    GMenuItem *menu_item;
-
-    priv = nautilus_files_view_get_instance_private (view);
-    name = nautilus_file_get_display_name (file);
-    uri = nautilus_file_get_uri (file);
-    escaped_uri = g_uri_escape_string (uri, NULL, TRUE);
-    action_name = g_strconcat ("template_", escaped_uri, NULL);
-    action = G_ACTION (g_simple_action_new (action_name, NULL));
-    parameters = create_template_parameters_new (file, view);
-
-    g_signal_connect_data (action, "activate",
-                           G_CALLBACK (create_template),
-                           parameters,
-                           (GClosureNotify) create_templates_parameters_free, 0);
-
-    g_action_map_add_action (G_ACTION_MAP (priv->view_action_group), action);
-
-    detailed_action_name = g_strconcat ("view.", action_name, NULL);
-    label = eel_str_double_underscores (name);
-    menu_item = g_menu_item_new (label, detailed_action_name);
-
-    mimetype_icon = get_menu_icon_for_file (file, GTK_WIDGET (view));
-    if (mimetype_icon != NULL)
-    {
-        g_menu_item_set_icon (menu_item, G_ICON (mimetype_icon));
-        g_object_unref (mimetype_icon);
-    }
-
-    g_menu_append_item (menu, menu_item);
-
-    g_free (name);
-    g_free (uri);
-    g_free (action_name);
-    g_free (detailed_action_name);
-    g_object_unref (action);
-    g_object_unref (menu_item);
-}
-
-static void
-update_templates_directory (NautilusFilesView *view)
-{
-    NautilusFilesViewPrivate *priv;
-    NautilusDirectory *templates_directory;
-    GList *node, *next;
-    char *templates_uri;
-
-    priv = nautilus_files_view_get_instance_private (view);
-
-    for (node = priv->templates_directory_list; node != NULL; node = next)
-    {
-        next = node->next;
-        remove_directory_from_templates_directory_list (view, node->data);
-    }
-
-    if (nautilus_should_use_templates_directory ())
-    {
-        templates_uri = nautilus_get_templates_directory_uri ();
-        templates_directory = nautilus_directory_get_by_uri (templates_uri);
-        g_free (templates_uri);
-        add_directory_to_templates_directory_list (view, templates_directory);
-        nautilus_directory_unref (templates_directory);
-    }
-}
-
-static gboolean
-directory_belongs_in_templates_menu (const char *templates_directory_uri,
-                                     const char *uri)
-{
-    int num_levels;
-    int i;
-
-    if (templates_directory_uri == NULL)
-    {
-        return FALSE;
-    }
-
-    if (!g_str_has_prefix (uri, templates_directory_uri))
-    {
-        return FALSE;
-    }
-
-    num_levels = 0;
-    for (i = strlen (templates_directory_uri); uri[i] != '\0'; i++)
-    {
-        if (uri[i] == '/')
-        {
-            num_levels++;
-        }
-    }
-
-    if (num_levels > MAX_MENU_LEVELS)
-    {
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-static gboolean
-filter_templates_callback (NautilusFile *file,
-                           gpointer      callback_data)
-{
-    gboolean show_hidden = GPOINTER_TO_INT (callback_data);
-
-    if (nautilus_file_is_hidden_file (file))
-    {
-        if (!show_hidden)
-        {
-            return FALSE;
-        }
-
-        if (nautilus_file_is_directory (file))
-        {
-            return FALSE;
-        }
-    }
-
-    return TRUE;
-}
-
-static GList *
-filter_templates (GList    *files,
-                  gboolean  show_hidden)
-{
-    GList *filtered_files;
-    GList *removed_files;
-
-    filtered_files = nautilus_file_list_filter (files,
-                                                &removed_files,
-                                                filter_templates_callback,
-                                                GINT_TO_POINTER (show_hidden));
-    nautilus_file_list_free (removed_files);
-
-    return filtered_files;
-}
-
-static GMenuModel *
-update_directory_in_templates_menu (NautilusFilesView *view,
-                                    NautilusDirectory *directory)
-{
-    NautilusFilesViewPrivate *priv;
-    GList *file_list, *filtered, *node;
-    GMenu *menu;
-    GMenuItem *menu_item;
-    gboolean any_templates;
-    NautilusFile *file;
-    NautilusDirectory *dir;
-    char *uri;
-    char *templates_directory_uri;
-    int num;
-
-    g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
-    g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
-
-    priv = nautilus_files_view_get_instance_private (view);
-
-    file_list = nautilus_directory_get_file_list (directory);
-
-    /*
-     * The nautilus_file_list_filter_hidden() function isn't used here, because
-     * we want to show hidden files, but not directories. This is a compromise
-     * to allow creating hidden files but to prevent content from .git directory
-     * for example. See https://gitlab.gnome.org/GNOME/nautilus/issues/1413.
-     */
-    filtered = filter_templates (file_list, priv->show_hidden_files);
-    nautilus_file_list_free (file_list);
-    templates_directory_uri = nautilus_get_templates_directory_uri ();
-    menu = g_menu_new ();
-
-    filtered = nautilus_file_list_sort_by_display_name (filtered);
-
-    num = 0;
-    any_templates = FALSE;
-    for (node = filtered; num < TEMPLATE_LIMIT && node != NULL; node = node->next, num++)
-    {
-        file = node->data;
-        if (nautilus_file_is_directory (file))
-        {
-            uri = nautilus_file_get_uri (file);
-            if (directory_belongs_in_templates_menu (templates_directory_uri, uri))
-            {
-                g_autoptr (GMenuModel) children_menu = NULL;
-
-                dir = nautilus_directory_get_by_uri (uri);
-                add_directory_to_templates_directory_list (view, dir);
-
-                children_menu = update_directory_in_templates_menu (view, dir);
-
-                if (children_menu != NULL)
-                {
-                    g_autofree char *display_name = NULL;
-                    g_autofree char *label = NULL;
-
-                    display_name = nautilus_file_get_display_name (file);
-                    label = eel_str_double_underscores (display_name);
-                    menu_item = g_menu_item_new_submenu (label, children_menu);
-                    g_menu_append_item (menu, menu_item);
-                    any_templates = TRUE;
-                    g_object_unref (menu_item);
-                }
-
-                nautilus_directory_unref (dir);
-            }
-            g_free (uri);
-        }
-        else if (nautilus_file_can_read (file))
-        {
-            add_template_to_templates_menus (view, file, menu);
-            any_templates = TRUE;
-        }
-    }
-
-    nautilus_file_list_free (filtered);
-    g_free (templates_directory_uri);
-
-    if (!any_templates)
-    {
-        g_object_unref (menu);
-        menu = NULL;
-    }
-
-    return G_MENU_MODEL (menu);
-}
-
-
-
-static void
-update_templates_menu (NautilusFilesView *view,
-                       GtkBuilder        *builder)
-{
-    NautilusFilesViewPrivate *priv;
-    g_autolist (NautilusDirectory) sorted_copy = NULL;
-    g_autoptr (NautilusDirectory) directory = NULL;
-    g_autoptr (GMenuModel) submenu = NULL;
-    g_autofree char *templates_directory_uri = NULL;
-
-    priv = nautilus_files_view_get_instance_private (view);
-
-    if (!nautilus_should_use_templates_directory ())
-    {
-        nautilus_view_set_templates_menu (NAUTILUS_VIEW (view), NULL);
-        return;
-    }
-
-    templates_directory_uri = nautilus_get_templates_directory_uri ();
-    sorted_copy = nautilus_directory_list_sort_by_uri
-                      (nautilus_directory_list_copy (priv->templates_directory_list));
-
-    for (GList *dir_l = sorted_copy; dir_l != NULL; dir_l = dir_l->next)
-    {
-        g_autofree char *uri = nautilus_directory_get_uri (dir_l->data);
-        if (!directory_belongs_in_templates_menu (templates_directory_uri, uri))
-        {
-            remove_directory_from_templates_directory_list (view, dir_l->data);
-        }
-    }
-
-    directory = nautilus_directory_get_by_uri (templates_directory_uri);
-    submenu = update_directory_in_templates_menu (view, directory);
-
-    nautilus_view_set_templates_menu (NAUTILUS_VIEW (view), submenu);
-}
-
-
 static void
 action_open_scripts_folder (GSimpleAction *action,
                             GVariant      *state,
@@ -8204,36 +7828,6 @@ static void
 update_background_menu (NautilusFilesView *view,
                         GtkBuilder        *builder)
 {
-    NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
-    GObject *object;
-    gboolean remove_submenu = TRUE;
-    gint i;
-
-    if (nautilus_files_view_supports_creating_files (view) &&
-        !showing_recent_directory (view) &&
-        !showing_starred_directory (view))
-    {
-        if (!priv->templates_menu_updated)
-        {
-            update_templates_menu (view, builder);
-            priv->templates_menu_updated = TRUE;
-        }
-
-        object = gtk_builder_get_object (builder, "templates-submenu");
-        nautilus_gmenu_set_from_model (G_MENU (object), priv->templates_menu);
-
-        if (priv->templates_menu != NULL)
-        {
-            remove_submenu = FALSE;
-        }
-    }
-
-    i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (priv->background_menu_model),
-                                              "nautilus-menu-item",
-                                              "templates-submenu");
-    nautilus_g_menu_replace_string_in_item (priv->background_menu_model, i,
-                                            "hidden-when",
-                                            remove_submenu ? "action-missing" : NULL);
 }
 
 static void
@@ -9133,13 +8727,6 @@ nautilus_files_view_get_property (GObject    *object,
         }
         break;
 
-        case PROP_TEMPLATES_MENU:
-        {
-            g_value_set_object (value,
-                                real_get_templates_menu (NAUTILUS_VIEW (view)));
-        }
-        break;
-
         default:
         {
             g_assert_not_reached ();
@@ -9207,13 +8794,6 @@ nautilus_files_view_set_property (GObject      *object,
         }
         break;
 
-        case PROP_TEMPLATES_MENU:
-        {
-            real_set_templates_menu (NAUTILUS_VIEW (directory_view),
-                                     g_value_get_object (value));
-        }
-        break;
-
         default:
         {
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -9432,8 +9012,6 @@ nautilus_files_view_iface_init (NautilusViewInterface *iface)
     iface->is_searching = nautilus_files_view_is_searching;
     iface->is_loading = nautilus_files_view_is_loading;
     iface->get_view_id = nautilus_files_view_get_view_id;
-    iface->get_templates_menu = nautilus_files_view_get_templates_menu;
-    iface->set_templates_menu = nautilus_files_view_set_templates_menu;
     iface->get_extensions_background_menu = nautilus_files_view_get_extensions_background_menu;
     iface->set_extensions_background_menu = nautilus_files_view_set_extensions_background_menu;
 }
@@ -9559,7 +9137,6 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
     g_object_class_override_property (oclass, PROP_SELECTION, "selection");
     g_object_class_override_property (oclass, PROP_SEARCH_QUERY, "search-query");
     g_object_class_override_property (oclass, PROP_EXTENSIONS_BACKGROUND_MENU, "extensions-background-menu");
-    g_object_class_override_property (oclass, PROP_TEMPLATES_MENU, "templates-menu");
 
     gtk_widget_class_set_template_from_resource (widget_class,
                                                  "/org/gnome/nautilus/ui/nautilus-files-view.ui");
@@ -9716,7 +9293,6 @@ nautilus_files_view_init (NautilusFilesView *view)
         add_directory_to_templates_directory_list (view, templates_directory);
         nautilus_directory_unref (templates_directory);
     }
-    update_templates_directory (view);
 
     priv->sort_directories_first =
         g_settings_get_boolean (gtk_filechooser_preferences, NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index df95afdef..ef726fb59 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -101,7 +101,6 @@ struct _NautilusPathBar
     GtkWidget *button_menu_popover;
     GMenu *current_view_menu;
     GMenu *extensions_section;
-    GMenu *templates_submenu;
     GMenu *button_menu;
 
     gchar *os_name;
@@ -285,7 +284,6 @@ nautilus_path_bar_init (NautilusPathBar *self)
     /* Add current location menu, which shares features with the view's background context menu */
     self->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, 
"current-view-menu")));
     self->extensions_section = g_object_ref (G_MENU (gtk_builder_get_object (builder, 
"background-extensions-section")));
-    self->templates_submenu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "templates-submenu")));
     self->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER_MENU (gtk_popover_menu_new_from_model 
(NULL)));
 
     g_object_unref (builder);
@@ -317,7 +315,6 @@ nautilus_path_bar_finalize (GObject *object)
 
     g_clear_object (&self->current_view_menu);
     g_clear_object (&self->extensions_section);
-    g_clear_object (&self->templates_submenu);
     g_clear_object (&self->button_menu);
     g_clear_pointer (&self->button_menu_popover, gtk_widget_unparent);
     g_clear_object (&self->current_view_menu_popover);
@@ -430,34 +427,6 @@ nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *self,
     nautilus_gmenu_set_from_model (self->extensions_section, menu);
 }
 
-void
-nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
-                                      GMenuModel      *menu)
-{
-    gint i;
-
-    g_return_if_fail (NAUTILUS_IS_PATH_BAR (self));
-
-    if (!gtk_widget_is_visible (GTK_WIDGET (self->current_view_menu_popover)))
-    {
-        /* Workaround to avoid leaking duplicated GtkStack pages each time the
-         * templates menu is set. Unbinding the model is the only way to clear
-         * all children. After that's done, on idle, we rebind it.
-         * See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1705 */
-        gtk_popover_menu_set_menu_model (self->current_view_menu_popover, NULL);
-    }
-
-    nautilus_gmenu_set_from_model (self->templates_submenu, menu);
-    g_idle_add ((GSourceFunc) bind_current_view_menu_model_to_popover, self);
-
-    i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (self->current_view_menu),
-                                              "nautilus-menu-item",
-                                              "templates-submenu");
-    nautilus_g_menu_replace_string_in_item (self->current_view_menu, i,
-                                            "hidden-when",
-                                            (menu == NULL) ? "action-missing" : NULL);
-}
-
 /* Public functions and their helpers */
 static void
 nautilus_path_bar_clear_buttons (NautilusPathBar *self)
diff --git a/src/nautilus-pathbar.h b/src/nautilus-pathbar.h
index 1052e4d2d..ae1848007 100644
--- a/src/nautilus-pathbar.h
+++ b/src/nautilus-pathbar.h
@@ -29,6 +29,5 @@ void     nautilus_path_bar_set_path                       (NautilusPathBar *path
 
 void     nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *path_bar,
                                                            GMenuModel      *menu);
-void     nautilus_path_bar_set_templates_menu             (NautilusPathBar *path_bar,
-                                                           GMenuModel      *menu);
+
 void     nautilus_path_bar_show_current_location_menu     (NautilusPathBar *path_bar);
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 555435e6c..3e78b8083 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -597,18 +597,6 @@ slot_on_extensions_background_menu_changed (NautilusToolbar    *self,
                                                       menu);
 }
 
-static void
-slot_on_templates_menu_changed (NautilusToolbar    *self,
-                                GParamSpec         *param,
-                                NautilusWindowSlot *slot)
-{
-    g_autoptr (GMenuModel) menu = NULL;
-
-    menu = nautilus_window_slot_get_templates_menu (slot);
-    nautilus_path_bar_set_templates_menu (NAUTILUS_PATH_BAR (self->path_bar),
-                                          menu);
-}
-
 /* Called from on_window_slot_destroyed(), since bindings and signal handlers
  * are automatically removed once the slot goes away.
  */
@@ -632,8 +620,6 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar    *self,
 
         g_signal_connect_swapped (self->window_slot, "notify::extensions-background-menu",
                                   G_CALLBACK (slot_on_extensions_background_menu_changed), self);
-        g_signal_connect_swapped (self->window_slot, "notify::templates-menu",
-                                  G_CALLBACK (slot_on_templates_menu_changed), self);
         g_signal_connect_swapped (self->window_slot, "notify::searching",
                                   G_CALLBACK (toolbar_update_appearance), self);
     }
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 2463ba632..af48823ee 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -96,17 +96,6 @@ nautilus_view_default_init (NautilusViewInterface *iface)
                                                               "Menu for the background click of extensions",
                                                               G_TYPE_MENU_MODEL,
                                                               G_PARAM_READWRITE));
-    /**
-     * NautilusView::templates-menu:
-     *
-     * Menu of templates
-     */
-    g_object_interface_install_property (iface,
-                                         g_param_spec_object ("templates-menu",
-                                                              "Menu of templates",
-                                                              "Menu of templates",
-                                                              G_TYPE_MENU_MODEL,
-                                                              G_PARAM_READWRITE));
 }
 
 /**
@@ -215,24 +204,6 @@ nautilus_view_set_extensions_background_menu (NautilusView *view,
     NAUTILUS_VIEW_GET_IFACE (view)->set_extensions_background_menu (view, menu);
 }
 
-GMenuModel *
-nautilus_view_get_templates_menu (NautilusView *view)
-{
-    g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu, NULL);
-
-    return NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu (view);
-}
-
-/* Protected */
-void
-nautilus_view_set_templates_menu (NautilusView *view,
-                                  GMenuModel   *menu)
-{
-    g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu);
-
-    NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu (view, menu);
-}
-
 /**
  * nautilus_view_get_search_query:
  * @view: a #NautilusView
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 9a8911e28..f0ebe5076 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -55,13 +55,7 @@ struct _NautilusViewInterface
 
         void     (*set_extensions_background_menu) (NautilusView *view,
                                                     GMenuModel   *menu);
-        /*
-         * Returns the menu for templates.
-         */
-        GMenuModel *   (*get_templates_menu) (NautilusView         *view);
-
-        void     (*set_templates_menu) (NautilusView *view,
-                                        GMenuModel   *menu);
+ 
         /* Current location of the view */
         GFile*                          (*get_location)              (NautilusView         *view);
         void                            (*set_location)              (NautilusView         *view,
@@ -111,9 +105,6 @@ gboolean                       nautilus_view_is_loading                (Nautilus
 
 gboolean                       nautilus_view_is_searching              (NautilusView         *view);
 
-void                           nautilus_view_set_templates_menu        (NautilusView *view,
-                                                                        GMenuModel   *menu);
-GMenuModel *                   nautilus_view_get_templates_menu        (NautilusView *view);
 void                           nautilus_view_set_extensions_background_menu (NautilusView *view,
                                                                              GMenuModel   *menu);
 GMenuModel *                   nautilus_view_get_extensions_background_menu (NautilusView *view);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 21ae9035a..903a0c6f5 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -55,7 +55,6 @@ enum
     PROP_ICON_NAME,
     PROP_TOOLBAR_MENU_SECTIONS,
     PROP_EXTENSIONS_BACKGROUND_MENU,
-    PROP_TEMPLATES_MENU,
     PROP_LOADING,
     PROP_SEARCHING,
     PROP_SELECTION,
@@ -137,13 +136,11 @@ struct _NautilusWindowSlot
 
     /* Menus */
     GMenuModel *extensions_background_menu;
-    GMenuModel *templates_menu;
 
     /* View bindings */
     GBinding *searching_binding;
     GBinding *selection_binding;
     GBinding *extensions_background_menu_binding;
-    GBinding *templates_menu_binding;
     gboolean searching;
     GList *selection;
 };
@@ -179,9 +176,6 @@ static void update_search_information (NautilusWindowSlot *self);
 static void real_set_extensions_background_menu (NautilusWindowSlot *self,
                                                  GMenuModel         *menu);
 static GMenuModel *real_get_extensions_background_menu (NautilusWindowSlot *self);
-static void real_set_templates_menu (NautilusWindowSlot *self,
-                                     GMenuModel         *menu);
-static GMenuModel *real_get_templates_menu (NautilusWindowSlot *self);
 static void nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self);
 
 void
@@ -698,13 +692,6 @@ real_set_extensions_background_menu (NautilusWindowSlot *self,
     g_set_object (&self->extensions_background_menu, menu);
 }
 
-static void
-real_set_templates_menu (NautilusWindowSlot *self,
-                         GMenuModel         *menu)
-{
-    g_set_object (&self->templates_menu, menu);
-}
-
 static void
 nautilus_window_slot_set_property (GObject      *object,
                                    guint         property_id,
@@ -745,12 +732,6 @@ nautilus_window_slot_set_property (GObject      *object,
         }
         break;
 
-        case PROP_TEMPLATES_MENU:
-        {
-            real_set_templates_menu (self, g_value_get_object (value));
-        }
-        break;
-
         case PROP_SELECTION:
         {
             nautilus_window_slot_set_selection (self, g_value_get_pointer (value));
@@ -781,22 +762,6 @@ nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self)
     return menu;
 }
 
-static GMenuModel *
-real_get_templates_menu (NautilusWindowSlot *self)
-{
-    return self->templates_menu;
-}
-
-GMenuModel *
-nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self)
-{
-    GMenuModel *menu = NULL;
-
-    g_object_get (self, "templates-menu", &menu, NULL);
-
-    return menu;
-}
-
 static void
 nautilus_window_slot_get_property (GObject    *object,
                                    guint       property_id,
@@ -836,12 +801,6 @@ nautilus_window_slot_get_property (GObject    *object,
         }
         break;
 
-        case PROP_TEMPLATES_MENU:
-        {
-            g_value_set_object (value, real_get_templates_menu (self));
-        }
-        break;
-
         case PROP_LOADING:
         {
             g_value_set_boolean (value, nautilus_window_slot_get_loading (self));
@@ -2721,12 +2680,7 @@ nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self)
 
         file = nautilus_file_get (location);
 
-        if (nautilus_should_use_templates_directory () &&
-            nautilus_file_is_user_special_directory (file, G_USER_DIRECTORY_TEMPLATES))
-        {
-            nautilus_window_slot_show_special_location_bar (self, NAUTILUS_SPECIAL_LOCATION_TEMPLATES);
-        }
-        else if (g_file_equal (location, scripts_file))
+        if (g_file_equal (location, scripts_file))
         {
             nautilus_window_slot_show_special_location_bar (self, NAUTILUS_SPECIAL_LOCATION_SCRIPTS);
         }
@@ -2805,7 +2759,6 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
         g_binding_unbind (self->searching_binding);
         g_binding_unbind (self->selection_binding);
         g_binding_unbind (self->extensions_background_menu_binding);
-        g_binding_unbind (self->templates_menu_binding);
         widget = GTK_WIDGET (self->content_view);
         gtk_box_remove (GTK_BOX (self), widget);
         g_clear_object (&self->content_view);
@@ -2829,13 +2782,9 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
         self->extensions_background_menu_binding = g_object_bind_property (self->content_view, 
"extensions-background-menu",
                                                                            self, 
"extensions-background-menu",
                                                                            G_BINDING_DEFAULT | 
G_BINDING_SYNC_CREATE);
-        self->templates_menu_binding = g_object_bind_property (self->content_view, "templates-menu",
-                                                               self, "templates-menu",
-                                                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]);
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLBAR_MENU_SECTIONS]);
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EXTENSIONS_BACKGROUND_MENU]);
-        g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEMPLATES_MENU]);
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLTIP]);
     }
 
@@ -2886,9 +2835,7 @@ nautilus_window_slot_dispose (GObject *object)
     g_clear_pointer (&self->searching_binding, g_binding_unbind);
     g_clear_pointer (&self->selection_binding, g_binding_unbind);
     g_clear_pointer (&self->extensions_background_menu_binding, g_binding_unbind);
-    g_clear_pointer (&self->templates_menu_binding, g_binding_unbind);
 
-    g_clear_object (&self->templates_menu);
     g_clear_object (&self->extensions_background_menu);
 
     if (self->content_view)
@@ -3026,13 +2973,6 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
                              G_TYPE_MENU_MODEL,
                              G_PARAM_READWRITE);
 
-    properties[PROP_TEMPLATES_MENU] =
-        g_param_spec_object ("templates-menu",
-                             "Templates menu",
-                             "Proxy property from the view for the templates menu",
-                             G_TYPE_MENU_MODEL,
-                             G_PARAM_READWRITE);
-
     properties[PROP_LOCATION] =
         g_param_spec_object ("location",
                              "Current location visible on the slot",
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 364c63728..6b29f178e 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -86,8 +86,6 @@ const gchar*   nautilus_window_slot_get_tooltip                  (NautilusWindow
 
 NautilusToolbarMenuSections * nautilus_window_slot_get_toolbar_menu_sections (NautilusWindowSlot *slot);
 
-GMenuModel* nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self);
-
 GMenuModel* nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self);
 
 gboolean nautilus_window_slot_get_active                   (NautilusWindowSlot *slot);
diff --git a/src/resources/ui/nautilus-files-view-context-menus.ui 
b/src/resources/ui/nautilus-files-view-context-menus.ui
index 46cd7bdcf..1bcd861b0 100644
--- a/src/resources/ui/nautilus-files-view-context-menus.ui
+++ b/src/resources/ui/nautilus-files-view-context-menus.ui
@@ -6,11 +6,6 @@
       <attribute name="label" translatable="yes">New _Folder…</attribute>
       <attribute name="action">view.new-folder</attribute>
     </item>
-    <item>
-      <attribute name="label" translatable="yes">New _Document</attribute>
-      <attribute name="nautilus-menu-item">templates-submenu</attribute>
-      <link name="submenu" id="templates-submenu"/>
-    </item>
     <item>
       <attribute name="label" translatable="yes">Open _With…</attribute>
       <attribute name="action">view.open-current-directory-with-other-application</attribute>
diff --git a/src/resources/ui/nautilus-pathbar-context-menu.ui 
b/src/resources/ui/nautilus-pathbar-context-menu.ui
index fea4f2cf9..f7f5ec6c1 100644
--- a/src/resources/ui/nautilus-pathbar-context-menu.ui
+++ b/src/resources/ui/nautilus-pathbar-context-menu.ui
@@ -20,11 +20,6 @@
       <attribute name="label" translatable="yes">New _Folder…</attribute>
       <attribute name="action">view.new-folder</attribute>
     </item>
-    <item>
-      <attribute name="label" translatable="yes">New _Document</attribute>
-      <attribute name="nautilus-menu-item">templates-submenu</attribute>
-      <link name="submenu" id="templates-submenu"/>
-    </item>
     <item>
       <attribute name="label" translatable="yes">Open _With…</attribute>
       <attribute name="action">view.open-current-directory-with-other-application</attribute>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]