mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
notebook: fix discovery of empty displays
This commit is contained in:
@ -331,52 +331,39 @@ sysprof_notebook_close_current (SysprofNotebook *self)
|
|||||||
gtk_notebook_remove_page (priv->notebook, page);
|
gtk_notebook_remove_page (priv->notebook, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
find_empty_display_cb (GtkWidget *widget,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkWidget **display = user_data;
|
|
||||||
|
|
||||||
g_assert (GTK_IS_WIDGET (widget));
|
|
||||||
g_assert (display != NULL);
|
|
||||||
|
|
||||||
if (*display != NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SYSPROF_IS_DISPLAY (widget) &&
|
|
||||||
sysprof_display_is_empty (SYSPROF_DISPLAY (widget)))
|
|
||||||
*display = widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sysprof_notebook_open (SysprofNotebook *self,
|
sysprof_notebook_open (SysprofNotebook *self,
|
||||||
GFile *file)
|
GFile *file)
|
||||||
{
|
{
|
||||||
SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
|
SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
|
||||||
GtkWidget *display = NULL;
|
SysprofDisplay *display = NULL;
|
||||||
gint page;
|
int page;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_NOTEBOOK (self));
|
g_return_if_fail (SYSPROF_IS_NOTEBOOK (self));
|
||||||
g_return_if_fail (g_file_is_native (file));
|
g_return_if_fail (g_file_is_native (file));
|
||||||
|
|
||||||
for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (priv->notebook));
|
for (page = 0; page < sysprof_notebook_get_n_pages (self); page++)
|
||||||
child && !display;
|
{
|
||||||
child = gtk_widget_get_next_sibling (child))
|
SysprofDisplay *child = sysprof_notebook_get_nth_page (self, page);
|
||||||
find_empty_display_cb (child, &display);
|
|
||||||
|
if (sysprof_display_is_empty (child))
|
||||||
|
{
|
||||||
|
display = child;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
{
|
{
|
||||||
|
display = SYSPROF_DISPLAY (sysprof_display_new ());
|
||||||
display = sysprof_display_new ();
|
page = sysprof_notebook_append (self, display);
|
||||||
page = gtk_notebook_insert_page (priv->notebook, display, NULL, -1);
|
|
||||||
gtk_widget_show (display);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
page = gtk_notebook_page_num (priv->notebook, display);
|
page = gtk_notebook_page_num (priv->notebook, GTK_WIDGET (display));
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_notebook_set_current_page (priv->notebook, page);
|
sysprof_notebook_set_current_page (self, page);
|
||||||
|
|
||||||
sysprof_display_open (SYSPROF_DISPLAY (display), file);
|
sysprof_display_open (SYSPROF_DISPLAY (display), file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user