[gnome-text-editor] app: add remove-recent action



commit ff729cffe793c1941799c22bbec5d0bbb1783081
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 28 15:25:14 2021 -0700

    app: add remove-recent action
    
    This allows us to use the remove-recent action without attaching it to the
    widgetry at all. Interestingly, this appears to be even slower than other
    options with regards to action resolution.
    
    Related #192

 src/editor-application-actions.c | 25 +++++++++++++++++++++++++
 src/editor-sidebar-row.c         |  6 +++++-
 2 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/src/editor-application-actions.c b/src/editor-application-actions.c
index 0016247..9f36e81 100644
--- a/src/editor-application-actions.c
+++ b/src/editor-application-actions.c
@@ -232,6 +232,30 @@ editor_application_actions_settings_changed_cb (GSettings     *settings,
     }
 }
 
+static void
+editor_application_actions_remove_recent_cb (GSimpleAction *action,
+                                             GVariant      *param,
+                                             gpointer       user_data)
+{
+  EditorApplication *self = user_data;
+  g_autoptr(GFile) file = NULL;
+  const char *uri;
+  const char *draft_id;
+
+  g_assert (EDITOR_IS_APPLICATION (self));
+  g_assert (g_variant_is_of_type (param, G_VARIANT_TYPE ("(ss)")));
+
+  g_variant_get (param, "(&s&s)", &uri, &draft_id);
+
+  if (uri[0] != 0)
+    file = g_file_new_for_uri (uri);
+
+  if (draft_id[0] == 0)
+    draft_id = NULL;
+
+  _editor_session_forget (EDITOR_SESSION_DEFAULT, file, draft_id);
+}
+
 void
 _editor_application_actions_init (EditorApplication *self)
 {
@@ -241,6 +265,7 @@ _editor_application_actions_init (EditorApplication *self)
     { "help", editor_application_actions_help_cb },
     { "quit", editor_application_actions_quit },
     { "style-scheme", NULL, "s", "''", editor_application_actions_style_scheme_cb },
+    { "remove-recent", editor_application_actions_remove_recent_cb, "(ss)" },
   };
   GAction *action;
 
diff --git a/src/editor-sidebar-row.c b/src/editor-sidebar-row.c
index b2a0c6c..e3e8996 100644
--- a/src/editor-sidebar-row.c
+++ b/src/editor-sidebar-row.c
@@ -262,6 +262,10 @@ _editor_sidebar_row_set_item (EditorSidebarRow  *self,
                                         "(ss)",
                                         uri ? uri : "",
                                         draft_id ? draft_id : "");
-      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->remove), "row.remove");
+      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->remove), "app.remove-recent");
+    }
+  else
+    {
+      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->remove), NULL);
     }
 }


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