tree: start on massive tree refactor

The big thing going on here is that we are going to split up the libraries
a bit better, and remove GObject from the capture library. The libsysprof
library will bring in the capture library statically, so we can export the
symbols we want.

Eventually, we will bump the version to sysprof-3, but not yet.
This commit is contained in:
Christian Hergert
2019-05-07 20:52:05 -07:00
parent 5323cffdb3
commit 1708ad1b48
193 changed files with 1400 additions and 1136 deletions

View File

@ -0,0 +1,96 @@
#include <sysprof.h>
#include <sysprof-ui.h>
#include <string.h>
static GtkWidget *list;
static GtkWidget *
create_row (gpointer item,
gpointer user_data)
{
return sp_process_model_row_new (item);
}
static gboolean
filter_cb (GObject *object,
gpointer user_data)
{
const gchar *needle = user_data;
const gchar *command = sp_process_model_item_get_command_line (SP_PROCESS_MODEL_ITEM (object));
return !!strstr (command, needle);
}
static void
on_entry_changed (GtkEntry *entry,
SpModelFilter *filter)
{
const gchar *text;
g_assert (GTK_IS_ENTRY (entry));
g_assert (SP_IS_MODEL_FILTER (filter));
text = gtk_entry_get_text (entry);
sp_model_filter_set_filter_func (filter, filter_cb, g_strdup (text), g_free);
//gtk_list_box_bind_model (GTK_LIST_BOX (list), G_LIST_MODEL (filter), create_row, NULL, NULL);
}
gint
main (gint argc,
gchar *argv[])
{
SpProcessModel *model;
SpModelFilter *filter;
GtkWidget *window;
GtkWidget *box;
GtkWidget *scroller;
GtkWidget *entry;
gtk_init (&argc, &argv);
window = g_object_new (GTK_TYPE_WINDOW,
"title", "Sysprof Process List",
"default-height", 700,
"default-width", 300,
NULL);
box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_VERTICAL,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (window), box);
entry = g_object_new (GTK_TYPE_ENTRY,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (box), entry);
scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
"expand", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (box), scroller);
list = g_object_new (GTK_TYPE_LIST_BOX,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (scroller), list);
model = sp_process_model_new ();
filter = sp_model_filter_new (G_LIST_MODEL (model));
gtk_list_box_bind_model (GTK_LIST_BOX (list), G_LIST_MODEL (filter), create_row, NULL, NULL);
g_signal_connect (entry,
"changed",
G_CALLBACK (on_entry_changed),
filter);
gtk_window_present (GTK_WINDOW (window));
g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
gtk_main ();
g_object_unref (model);
return 0;
}