mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 22:50:54 +00:00
window: add screenshot action
Shows the screenshot (textual representation) of the descendants tree in a new window/textview.
This commit is contained in:
@ -41,6 +41,12 @@
|
|||||||
<attribute name="action">win.save-capture</attribute>
|
<attribute name="action">win.save-capture</attribute>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
|
<section id="gear-menu-screenshot-section">
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Screenshot</attribute>
|
||||||
|
<attribute name="action">win.screenshot</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
<section id="gear-menu-close-section">
|
<section id="gear-menu-close-section">
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">Close</attribute>
|
<attribute name="label" translatable="yes">Close</attribute>
|
||||||
|
|||||||
@ -279,6 +279,7 @@ sp_window_set_state (SpWindow *self,
|
|||||||
sp_window_set_profiler (self, profiler);
|
sp_window_set_profiler (self, profiler);
|
||||||
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
||||||
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
||||||
|
sp_window_action_set (self, "screenshot", "enabled", FALSE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SP_WINDOW_STATE_RECORDING:
|
case SP_WINDOW_STATE_RECORDING:
|
||||||
@ -293,6 +294,7 @@ sp_window_set_state (SpWindow *self,
|
|||||||
sp_callgraph_view_set_profile (self->callgraph_view, NULL);
|
sp_callgraph_view_set_profile (self->callgraph_view, NULL);
|
||||||
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
||||||
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
||||||
|
sp_window_action_set (self, "screenshot", "enabled", FALSE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SP_WINDOW_STATE_PROCESSING:
|
case SP_WINDOW_STATE_PROCESSING:
|
||||||
@ -300,6 +302,7 @@ sp_window_set_state (SpWindow *self,
|
|||||||
gtk_label_set_label (self->subtitle, _("Building profile…"));
|
gtk_label_set_label (self->subtitle, _("Building profile…"));
|
||||||
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "close-capture", "enabled", FALSE, NULL);
|
||||||
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
sp_window_action_set (self, "save-capture", "enabled", FALSE, NULL);
|
||||||
|
sp_window_action_set (self, "screenshot", "enabled", FALSE, NULL);
|
||||||
sp_window_build_profile (self);
|
sp_window_build_profile (self);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -314,6 +317,7 @@ sp_window_set_state (SpWindow *self,
|
|||||||
sp_window_update_subtitle (self);
|
sp_window_update_subtitle (self);
|
||||||
sp_window_action_set (self, "close-capture", "enabled", TRUE, NULL);
|
sp_window_action_set (self, "close-capture", "enabled", TRUE, NULL);
|
||||||
sp_window_action_set (self, "save-capture", "enabled", TRUE, NULL);
|
sp_window_action_set (self, "save-capture", "enabled", TRUE, NULL);
|
||||||
|
sp_window_action_set (self, "screenshot", "enabled", TRUE, NULL);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -601,6 +605,47 @@ sp_window_record_button_clicked (SpWindow *self,
|
|||||||
sp_window_start_recording (self);
|
sp_window_start_recording (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sp_window_screenshot (GSimpleAction *action,
|
||||||
|
GVariant *variant,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
SpWindow *self = user_data;
|
||||||
|
g_autofree gchar *str = NULL;
|
||||||
|
GtkWindow *window;
|
||||||
|
GtkScrolledWindow *scroller;
|
||||||
|
GtkTextView *text_view;
|
||||||
|
|
||||||
|
g_assert (G_IS_SIMPLE_ACTION (action));
|
||||||
|
g_assert (SP_IS_WINDOW (self));
|
||||||
|
|
||||||
|
if (NULL == (str = sp_callgraph_view_screenshot (self->callgraph_view)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
window = g_object_new (GTK_TYPE_WINDOW,
|
||||||
|
"title", "Sysprof",
|
||||||
|
"default-width", 800,
|
||||||
|
"default-height", 600,
|
||||||
|
"transient-for", self,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
|
||||||
|
"visible", TRUE,
|
||||||
|
NULL);
|
||||||
|
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (scroller));
|
||||||
|
|
||||||
|
text_view = g_object_new (GTK_TYPE_TEXT_VIEW,
|
||||||
|
"editable", FALSE,
|
||||||
|
"monospace", TRUE,
|
||||||
|
"visible", TRUE,
|
||||||
|
NULL);
|
||||||
|
gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (text_view));
|
||||||
|
|
||||||
|
gtk_text_buffer_set_text (gtk_text_view_get_buffer (text_view), str, -1);
|
||||||
|
|
||||||
|
gtk_window_present (window);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sp_window_destroy (GtkWidget *widget)
|
sp_window_destroy (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@ -679,6 +724,7 @@ sp_window_init (SpWindow *self)
|
|||||||
{ "close-capture", sp_window_close_capture },
|
{ "close-capture", sp_window_close_capture },
|
||||||
{ "open-capture", sp_window_open_capture },
|
{ "open-capture", sp_window_open_capture },
|
||||||
{ "save-capture", sp_window_save_capture },
|
{ "save-capture", sp_window_save_capture },
|
||||||
|
{ "screenshot", sp_window_screenshot },
|
||||||
};
|
};
|
||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
GMenu *menu;
|
GMenu *menu;
|
||||||
|
|||||||
Reference in New Issue
Block a user