...
 
Commits (2)
......@@ -61,6 +61,8 @@ typedef struct
GtkStackSwitcher *stack_switcher;
guint busy;
guint needs_fit : 1;
} SysprofCaptureViewPrivate;
typedef struct
......@@ -94,6 +96,17 @@ load_async_free (gpointer data)
}
}
static gboolean
do_best_fit_in_idle (gpointer user_data)
{
SysprofCaptureView *self = user_data;
if (gtk_widget_get_visible (GTK_WIDGET (self)))
sysprof_capture_view_fit_to_width (self);
return G_SOURCE_REMOVE;
}
SysprofMarkStat *
_sysprof_mark_stat_new (const gchar *name)
{
......@@ -471,6 +484,8 @@ sysprof_capture_view_scan_finish (SysprofCaptureView *self,
add_marks_to_details (self);
priv->needs_fit = TRUE;
return g_task_propagate_boolean (G_TASK (result), error);
}
......@@ -716,17 +731,6 @@ set_use_underline_cb (GtkWidget *widget,
}
}
static gboolean
do_best_fit_in_idle (gpointer user_data)
{
SysprofCaptureView *self = user_data;
if (gtk_widget_get_visible (GTK_WIDGET (self)))
sysprof_capture_view_fit_to_width (self);
return G_SOURCE_REMOVE;
}
static void
sysprof_capture_view_map (GtkWidget *widget)
{
......@@ -737,7 +741,7 @@ sysprof_capture_view_map (GtkWidget *widget)
GTK_WIDGET_CLASS (sysprof_capture_view_parent_class)->map (widget);
if (priv->reader != NULL)
if (priv->needs_fit)
g_timeout_add_full (G_PRIORITY_LOW,
25,
do_best_fit_in_idle,
......@@ -950,11 +954,22 @@ sysprof_capture_view_fit_to_width (SysprofCaptureView *self)
g_return_if_fail (SYSPROF_IS_CAPTURE_VIEW (self));
if (priv->reader == NULL)
return;
duration = priv->features.end_time - priv->features.begin_time;
g_print ("DURATION: %ld\n", duration);
if (duration <= 0)
return;
priv->needs_fit = FALSE;
/* Trim a bit off the width to avoid drawing past edges */
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
width = MAX (100, alloc.width - 25);
duration = priv->features.end_time - priv->features.begin_time;
zoom = sysprof_zoom_manager_fit_zoom_for_duration (priv->zoom_manager, duration, width);
sysprof_zoom_manager_set_zoom (priv->zoom_manager, zoom);
}
......
......@@ -21,6 +21,7 @@
#include "config.h"
#include <fcntl.h>
#include <glib-unix.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <signal.h>
......@@ -32,42 +33,26 @@
static GMainLoop *main_loop;
static SysprofProfiler *profiler;
static int efd = -1;
static int exit_code = EXIT_SUCCESS;
static void
signal_handler (int signum)
{
gint64 val = 1;
write (efd, &val, sizeof val);
}
static gboolean
dispatch (GSource *source,
GSourceFunc callback,
gpointer callback_data)
sigint_handler (gpointer user_data)
{
sysprof_profiler_stop (profiler);
g_main_loop_quit (main_loop);
return G_SOURCE_REMOVE;
}
static GSourceFuncs source_funcs = {
NULL, NULL, dispatch, NULL
};
static void
profiler_stopped (SysprofProfiler *profiler_,
GMainLoop *main_loop_)
GMainLoop *main_loop_)
{
g_main_loop_quit (main_loop_);
}
static void
profiler_failed (SysprofProfiler *profiler_,
const GError *reason,
GMainLoop *main_loop_)
profiler_failed (SysprofProfiler *profiler_,
const GError *reason,
GMainLoop *main_loop_)
{
g_assert (SYSPROF_IS_PROFILER (profiler_));
g_assert (reason != NULL);
......@@ -86,7 +71,6 @@ main (gint argc,
GOptionContext *context;
const gchar *filename = "capture.syscap";
GError *error = NULL;
GSource *gsource;
gchar *command = NULL;
gboolean no_memory = FALSE;
gboolean no_cpu = FALSE;
......@@ -107,6 +91,9 @@ main (gint argc,
sysprof_clock_init ();
g_unix_signal_add (SIGINT, sigint_handler, main_loop);
g_unix_signal_add (SIGTERM, sigint_handler, main_loop);
context = g_option_context_new (_("[CAPTURE_FILE] — Sysprof"));
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
......@@ -135,14 +122,8 @@ main (gint argc,
return EXIT_FAILURE;
}
efd = eventfd (0, O_CLOEXEC);
main_loop = g_main_loop_new (NULL, FALSE);
gsource = g_source_new (&source_funcs, sizeof (GSource));
g_source_add_unix_fd (gsource, efd, G_IO_IN);
g_source_attach (gsource, NULL);
profiler = sysprof_local_profiler_new ();
g_signal_connect (profiler,
......@@ -233,9 +214,6 @@ main (gint argc,
sysprof_profiler_add_pid (profiler, pid);
}
signal (SIGINT, signal_handler);
signal (SIGTERM, signal_handler);
sysprof_profiler_start (profiler);
/* Restore the process if we stopped it */
......@@ -250,7 +228,7 @@ main (gint argc,
while (g_main_context_pending (main_context))
g_main_context_iteration (main_context, FALSE);
close (efd);
sysprof_capture_writer_flush (writer);
g_clear_pointer (&writer, sysprof_capture_writer_unref);
g_clear_object (&profiler);
......