[gnome-builder/wip/gtk4-port: 1067/1774] plugins/sysprof: add save action for sysprof pages




commit a00fcbb99e722fe5ea53fcf8ddd8b7d15fb109a8
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 18 17:55:21 2022 -0700

    plugins/sysprof: add save action for sysprof pages

 src/plugins/sysprof/gbp-sysprof-page.c    | 14 ++++++++++++++
 src/plugins/sysprof/gtk/keybindings.json  |  1 +
 src/plugins/sysprof/sysprof.gresource.xml |  1 +
 3 files changed, 16 insertions(+)
---
diff --git a/src/plugins/sysprof/gbp-sysprof-page.c b/src/plugins/sysprof/gbp-sysprof-page.c
index 8d5b54928..1824b614b 100644
--- a/src/plugins/sysprof/gbp-sysprof-page.c
+++ b/src/plugins/sysprof/gbp-sysprof-page.c
@@ -133,8 +133,22 @@ record_again_action (GSimpleAction *action,
   ide_workspace_add_page (workspace, IDE_PAGE (new_page), position);
 }
 
+static void
+save_as_action (GSimpleAction *action,
+                GVariant      *param,
+                gpointer       user_data)
+{
+  GbpSysprofPage *self = user_data;
+
+  g_assert (G_IS_SIMPLE_ACTION (action));
+
+  if (sysprof_display_get_can_save (self->display))
+    sysprof_display_save (self->display);
+}
+
 static const GActionEntry actions[] = {
   { "record-again", record_again_action },
+  { "save-as", save_as_action },
 };
 
 static void
diff --git a/src/plugins/sysprof/gtk/keybindings.json b/src/plugins/sysprof/gtk/keybindings.json
new file mode 100644
index 000000000..93e393d69
--- /dev/null
+++ b/src/plugins/sysprof/gtk/keybindings.json
@@ -0,0 +1 @@
+{ "trigger" : "<Control>s", "action" : "sysprof.save-as", "when" : "inPageWithTypeName(\"GbpSysprofPage\")", 
"phase" : "capture" },
diff --git a/src/plugins/sysprof/sysprof.gresource.xml b/src/plugins/sysprof/sysprof.gresource.xml
index 909302258..ab5e8c9b5 100644
--- a/src/plugins/sysprof/sysprof.gresource.xml
+++ b/src/plugins/sysprof/sysprof.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/plugins/sysprof">
     <file>sysprof.plugin</file>
     <file>gtk/menus.ui</file>
+    <file>gtk/keybindings.json</file>
   </gresource>
 </gresources>


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