sysprof: allow passing program path to sysprof

If the path provided to us is an executable program (instead of a syscap
file) then we can setup the path as the binary to execute in the profiler
assistant and save the user a couple clicks.
This commit is contained in:
Christian Hergert
2020-01-23 11:59:07 -08:00
parent 599ecaebe1
commit 731b6dd379
3 changed files with 33 additions and 3 deletions

View File

@ -1032,10 +1032,19 @@ sysprof_display_open (SysprofDisplay *self,
g_return_if_fail (g_file_is_native (file));
g_return_if_fail (sysprof_display_is_empty (self));
g_set_object (&priv->file, file);
path = g_file_get_path (file);
/* If the file is executable, just set the path to the binary
* in the profiler assistant.
*/
if (g_file_test (path, G_FILE_TEST_IS_EXECUTABLE))
{
sysprof_profiler_assistant_set_executable (priv->assistant, path);
return;
}
g_set_object (&priv->file, file);
if (!(reader = sysprof_capture_reader_new (path, &error)))
g_warning ("Failed to open capture: %s", error->message);
else

View File

@ -455,3 +455,22 @@ _sysprof_profiler_assistant_focus_record (SysprofProfilerAssistant *self)
gtk_widget_grab_focus (GTK_WIDGET (self->record_button));
}
void
sysprof_profiler_assistant_set_executable (SysprofProfilerAssistant *self,
const gchar *path)
{
g_return_if_fail (SYSPROF_IS_PROFILER_ASSISTANT (self));
if (path == NULL || path[0] == 0)
{
gtk_entry_set_text (GTK_ENTRY (self->command_line), "");
gtk_switch_set_active (self->launch_switch, FALSE);
}
else
{
gtk_entry_set_text (GTK_ENTRY (self->command_line), path);
gtk_switch_set_active (self->launch_switch, TRUE);
gtk_widget_grab_focus (GTK_WIDGET (self->command_line));
}
}

View File

@ -30,6 +30,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofProfilerAssistant, sysprof_profiler_assistant, SYSPROF, PROFILER_ASSISTANT, GtkBin)
GtkWidget *sysprof_profiler_assistant_new (void);
GtkWidget *sysprof_profiler_assistant_new (void);
void sysprof_profiler_assistant_set_executable (SysprofProfilerAssistant *self,
const gchar *path);
G_END_DECLS