diff --git a/src/sysprof/sysprof-application.c b/src/sysprof/sysprof-application.c index a437b365..2181da20 100644 --- a/src/sysprof/sysprof-application.c +++ b/src/sysprof/sysprof-application.c @@ -130,6 +130,36 @@ sysprof_application_class_init (SysprofApplicationClass *klass) gtk_app_class->window_added = sysprof_application_window_added; } +static void +sysprof_new_window (GSimpleAction *action, + GVariant *variant, + gpointer user_data) +{ + const GList *windows; + GApplication *app = user_data; + GtkWindow *window; + GtkWidget *greeter; + + g_assert (G_IS_APPLICATION (app)); + g_assert (G_IS_SIMPLE_ACTION (action)); + g_assert (variant == NULL); + + windows = gtk_application_get_windows (GTK_APPLICATION (app)); + + for (const GList *iter = windows; iter != NULL; iter = iter->next) + { + if (SYSPROF_IS_GREETER (iter->data)) + { + gtk_window_present (iter->data); + return; + } + } + + greeter = sysprof_greeter_new (); + gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (greeter)); + gtk_window_present (GTK_WINDOW (greeter)); +} + static void sysprof_quit (GSimpleAction *action, GVariant *variant, @@ -240,6 +270,7 @@ static void sysprof_application_init (SysprofApplication *self) { static const GActionEntry actions[] = { + { "new-window", sysprof_new_window }, { "about", sysprof_about }, { "show-help-overlay", sysprof_show_help_overlay }, { "help", sysprof_help }, diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index cc351836..887e13a4 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -113,8 +113,6 @@ sysprof_window_update_action_state (SysprofWindow *self) if (self->session == NULL) { - gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.open-capture", FALSE); - gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.record-capture", FALSE); gtk_widget_action_set_enabled (GTK_WIDGET (self), "session.zoom-one", FALSE); gtk_widget_action_set_enabled (GTK_WIDGET (self), "session.zoom-out", FALSE); gtk_widget_action_set_enabled (GTK_WIDGET (self), "session.zoom-in", FALSE); @@ -124,8 +122,6 @@ sysprof_window_update_action_state (SysprofWindow *self) } else { - gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.open-capture", TRUE); - gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.record-capture", TRUE); gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.save-capture", TRUE); gtk_widget_action_set_enabled (GTK_WIDGET (self), "session.zoom-in", TRUE); @@ -228,24 +224,6 @@ sysprof_window_open_capture_action (GtkWidget *widget, sysprof_window_open_file (GTK_WINDOW (widget), template); } -static void -sysprof_window_record_capture_action (GtkWidget *widget, - const char *action_name, - GVariant *param) -{ - SysprofWindow *self = (SysprofWindow *)widget; - SysprofGreeter *greeter; - - g_assert (SYSPROF_IS_WINDOW (self)); - - greeter = g_object_new (SYSPROF_TYPE_GREETER, - "transient-for", self, - NULL); - gtk_application_add_window (GTK_APPLICATION (SYSPROF_APPLICATION_DEFAULT), - GTK_WINDOW (greeter)); - gtk_window_present (GTK_WINDOW (greeter)); -} - static void sysprof_window_set_document (SysprofWindow *self, SysprofDocument *document) @@ -628,7 +606,6 @@ sysprof_window_class_init (SysprofWindowClass *klass) gtk_widget_class_bind_template_callback (widget_class, n_filters_to_button_visibility); gtk_widget_class_install_action (widget_class, "win.open-capture", NULL, sysprof_window_open_capture_action); - gtk_widget_class_install_action (widget_class, "win.record-capture", NULL, sysprof_window_record_capture_action); gtk_widget_class_install_action (widget_class, "session.zoom-one", NULL, sysprof_window_session_zoom_one); gtk_widget_class_install_action (widget_class, "session.zoom-out", NULL, sysprof_window_session_zoom_out); gtk_widget_class_install_action (widget_class, "session.zoom-in", NULL, sysprof_window_session_zoom_in); diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index c18b4a47..8f63c8d0 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -29,7 +29,7 @@ <ctrl>n - action(win.record-capture) + action(app.new-window) @@ -458,7 +458,7 @@
_Record Again… - win.record-capture + app.new-window Open Recording…