mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Merge branch 'new-window' into 'master'
sysprof: Implement new-window action See merge request GNOME/sysprof!133
This commit is contained in:
@ -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 },
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<child>
|
||||
<object class="GtkShortcut">
|
||||
<property name="trigger"><ctrl>n</property>
|
||||
<property name="action">action(win.record-capture)</property>
|
||||
<property name="action">action(app.new-window)</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@ -458,7 +458,7 @@
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Record Again…</attribute>
|
||||
<attribute name="action">win.record-capture</attribute>
|
||||
<attribute name="action">app.new-window</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Open Recording…</attribute>
|
||||
|
||||
Reference in New Issue
Block a user