mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
display: port to GTK 4
This commit is contained in:
@ -95,10 +95,7 @@ update_title_child_property (SysprofDisplay *self)
|
|||||||
if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) && GTK_IS_NOTEBOOK (parent))
|
if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) && GTK_IS_NOTEBOOK (parent))
|
||||||
{
|
{
|
||||||
g_autofree gchar *title = sysprof_display_dup_title (self);
|
g_autofree gchar *title = sysprof_display_dup_title (self);
|
||||||
|
gtk_notebook_set_menu_label_text (GTK_NOTEBOOK (parent), GTK_WIDGET (self), title);
|
||||||
gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
|
|
||||||
"menu-label", title,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
|
||||||
@ -318,19 +315,17 @@ sysprof_display_notify_selection_cb (SysprofDisplay *self,
|
|||||||
/* Opportunistically load pages */
|
/* Opportunistically load pages */
|
||||||
if (priv->reader != NULL)
|
if (priv->reader != NULL)
|
||||||
{
|
{
|
||||||
GList *pages = gtk_container_get_children (GTK_CONTAINER (priv->pages));
|
for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (priv->pages));
|
||||||
|
child;
|
||||||
for (const GList *iter = pages; iter; iter = iter->next)
|
child = gtk_widget_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
if (SYSPROF_IS_PAGE (iter->data))
|
if (SYSPROF_IS_PAGE (child))
|
||||||
sysprof_page_load_async (iter->data,
|
sysprof_page_load_async (SYSPROF_PAGE (child),
|
||||||
priv->reader,
|
priv->reader,
|
||||||
selection,
|
selection,
|
||||||
priv->filter,
|
priv->filter,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (pages);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +546,7 @@ sysprof_display_add_group (SysprofDisplay *self,
|
|||||||
if (priv->reader != NULL)
|
if (priv->reader != NULL)
|
||||||
_sysprof_visualizer_group_set_reader (group, priv->reader);
|
_sysprof_visualizer_group_set_reader (group, priv->reader);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->visualizers), GTK_WIDGET (group));
|
sysprof_visualizers_frame_add_group (priv->visualizers, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -566,10 +561,7 @@ sysprof_display_add_page (SysprofDisplay *self,
|
|||||||
g_return_if_fail (SYSPROF_IS_PAGE (page));
|
g_return_if_fail (SYSPROF_IS_PAGE (page));
|
||||||
|
|
||||||
title = sysprof_page_get_title (page);
|
title = sysprof_page_get_title (page);
|
||||||
|
gtk_stack_add_titled (priv->pages, GTK_WIDGET (page), NULL, title);
|
||||||
gtk_container_add_with_properties (GTK_CONTAINER (priv->pages), GTK_WIDGET (page),
|
|
||||||
"title", title,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
selection = sysprof_visualizers_frame_get_selection (priv->visualizers);
|
selection = sysprof_visualizers_frame_get_selection (priv->visualizers);
|
||||||
|
|
||||||
@ -932,7 +924,6 @@ sysprof_display_load_scan_cb (GObject *object,
|
|||||||
SysprofCaptureReader *reader;
|
SysprofCaptureReader *reader;
|
||||||
SysprofSelection *selection;
|
SysprofSelection *selection;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GList *pages;
|
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_DISPLAY (self));
|
g_assert (SYSPROF_IS_DISPLAY (self));
|
||||||
g_assert (G_IS_ASYNC_RESULT (result));
|
g_assert (G_IS_ASYNC_RESULT (result));
|
||||||
@ -955,17 +946,17 @@ sysprof_display_load_scan_cb (GObject *object,
|
|||||||
sysprof_details_page_set_reader (priv->details, reader);
|
sysprof_details_page_set_reader (priv->details, reader);
|
||||||
|
|
||||||
/* Opportunistically load pages */
|
/* Opportunistically load pages */
|
||||||
pages = gtk_container_get_children (GTK_CONTAINER (priv->pages));
|
for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (priv->pages));
|
||||||
for (const GList *iter = pages; iter; iter = iter->next)
|
child;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
if (SYSPROF_IS_PAGE (iter->data))
|
if (SYSPROF_IS_PAGE (child))
|
||||||
sysprof_page_load_async (iter->data,
|
sysprof_page_load_async (SYSPROF_PAGE (child),
|
||||||
reader,
|
reader,
|
||||||
selection,
|
selection,
|
||||||
priv->filter,
|
priv->filter,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
g_list_free (pages);
|
|
||||||
|
|
||||||
gtk_stack_set_visible_child_name (priv->stack, "view");
|
gtk_stack_set_visible_child_name (priv->stack, "view");
|
||||||
}
|
}
|
||||||
@ -1079,6 +1070,7 @@ sysprof_display_open (SysprofDisplay *self,
|
|||||||
|
|
||||||
if (!(reader = sysprof_capture_reader_new_with_error (path, &error)))
|
if (!(reader = sysprof_capture_reader_new_with_error (path, &error)))
|
||||||
{
|
{
|
||||||
|
GtkWidget *parent;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
|
||||||
@ -1096,12 +1088,16 @@ sysprof_display_open (SysprofDisplay *self,
|
|||||||
error->message);
|
error->message);
|
||||||
g_signal_connect (dialog,
|
g_signal_connect (dialog,
|
||||||
"response",
|
"response",
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
G_CALLBACK (gtk_window_destroy),
|
||||||
NULL);
|
NULL);
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
gtk_window_present (GTK_WINDOW (dialog));
|
||||||
gtk_widget_destroy (GTK_WIDGET (self));
|
|
||||||
|
if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) &&
|
||||||
|
GTK_IS_NOTEBOOK (parent))
|
||||||
|
gtk_notebook_remove_page (GTK_NOTEBOOK (parent),
|
||||||
|
gtk_notebook_page_num (GTK_NOTEBOOK (parent), GTK_WIDGET (self)));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1199,36 +1195,21 @@ sysprof_display_new_for_profiler (SysprofProfiler *profiler)
|
|||||||
return GTK_WIDGET (g_steal_pointer (&self));
|
return GTK_WIDGET (g_steal_pointer (&self));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
sysprof_display_save (SysprofDisplay *self)
|
on_save_response_cb (SysprofDisplay *self,
|
||||||
|
int res,
|
||||||
|
GtkFileChooserNative *chooser)
|
||||||
{
|
{
|
||||||
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
|
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
|
||||||
g_autoptr(GFile) file = NULL;
|
g_autoptr(GFile) file = NULL;
|
||||||
GtkFileChooserNative *native;
|
|
||||||
GtkWindow *parent;
|
|
||||||
gint res;
|
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_DISPLAY (self));
|
g_assert (SYSPROF_IS_DISPLAY (self));
|
||||||
g_return_if_fail (priv->reader != NULL);
|
g_assert (GTK_IS_FILE_CHOOSER_NATIVE (chooser));
|
||||||
|
|
||||||
parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
|
||||||
|
|
||||||
native = gtk_file_chooser_native_new (_("Save Recording"),
|
|
||||||
parent,
|
|
||||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
||||||
_("Save"),
|
|
||||||
_("Cancel"));
|
|
||||||
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (native), TRUE);
|
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (native), TRUE);
|
|
||||||
gtk_file_chooser_set_create_folders (GTK_FILE_CHOOSER (native), TRUE);
|
|
||||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (native), "capture.syscap");
|
|
||||||
|
|
||||||
res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
|
|
||||||
|
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case GTK_RESPONSE_ACCEPT:
|
case GTK_RESPONSE_ACCEPT:
|
||||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (chooser));
|
||||||
|
|
||||||
if (g_file_is_native (file))
|
if (g_file_is_native (file))
|
||||||
{
|
{
|
||||||
@ -1238,17 +1219,24 @@ sysprof_display_save (SysprofDisplay *self)
|
|||||||
if (!sysprof_capture_reader_save_as_with_error (priv->reader, path, &error))
|
if (!sysprof_capture_reader_save_as_with_error (priv->reader, path, &error))
|
||||||
{
|
{
|
||||||
GtkWidget *msg;
|
GtkWidget *msg;
|
||||||
|
GtkNative *root;
|
||||||
|
|
||||||
msg = gtk_message_dialog_new (parent,
|
root = gtk_widget_get_native (GTK_WIDGET (self));
|
||||||
|
msg = gtk_message_dialog_new (GTK_WINDOW (root),
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
GTK_BUTTONS_CLOSE,
|
GTK_BUTTONS_CLOSE,
|
||||||
_("Failed to save recording: %s"),
|
_("Failed to save recording: %s"),
|
||||||
error->message);
|
error->message);
|
||||||
gtk_window_present (GTK_WINDOW (msg));
|
gtk_window_present (GTK_WINDOW (msg));
|
||||||
g_signal_connect (msg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
g_signal_connect (msg, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_autofree char *uri = g_file_get_uri (file);
|
||||||
|
g_warning ("%s is not native, cannot open", uri);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1257,7 +1245,35 @@ sysprof_display_save (SysprofDisplay *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
|
||||||
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (chooser));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sysprof_display_save (SysprofDisplay *self)
|
||||||
|
{
|
||||||
|
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
|
||||||
|
GtkFileChooserNative *native;
|
||||||
|
GtkNative *root;
|
||||||
|
|
||||||
|
g_return_if_fail (SYSPROF_IS_DISPLAY (self));
|
||||||
|
g_return_if_fail (priv->reader != NULL);
|
||||||
|
|
||||||
|
root = gtk_widget_get_native (GTK_WIDGET (self));
|
||||||
|
native = gtk_file_chooser_native_new (_("Save Recording"),
|
||||||
|
GTK_WINDOW (root),
|
||||||
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
_("Save"),
|
||||||
|
_("Cancel"));
|
||||||
|
gtk_file_chooser_set_create_folders (GTK_FILE_CHOOSER (native), TRUE);
|
||||||
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (native), "capture.syscap");
|
||||||
|
|
||||||
|
g_signal_connect_object (native,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (on_save_response_cb),
|
||||||
|
self,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user