[gnome-talos] Make it a plain executable
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-talos] Make it a plain executable
- Date: Sun, 25 Sep 2011 23:08:10 +0000 (UTC)
commit e5f622a23eee99199981b6e77ee232de22539b38
Author: Colin Walters <walters verbum org>
Date: Sat Sep 24 15:18:49 2011 -0400
Make it a plain executable
Makefile-src.am | 8 +++---
src/{gnome-talos-session.c => gnome-talos.c} | 36 ++++++++++++++++++++++---
2 files changed, 35 insertions(+), 9 deletions(-)
---
diff --git a/Makefile-src.am b/Makefile-src.am
index 1a79992..7215a65 100644
--- a/Makefile-src.am
+++ b/Makefile-src.am
@@ -8,12 +8,12 @@ gnome-talos-session-%.desktop: src/gnome-talos-session.desktop.in
sed -e s,@BINDIR\@,$(bindir), \
-e s,@TYPE\@,$(patsubst gnome-talos-session-%.desktop,%,$@), $< > $ tmp && mv $ tmp $@
-bin_PROGRAMS += gnome-talos-session
-gnome_talos_session_SOURCES = src/gnome-talos-session.c \
+bin_PROGRAMS += gnome-talos
+gnome_talos_SOURCES = src/gnome-talos.c \
src/gnome-talos-procinfo.c \
src/gnome-talos-procinfo.h \
src/gnome-talos-meta.c \
src/gnome-talos-meta.h
-gnome_talos_session_CPPFLAGS = $(GIO_UNIX_CFLAGS)
-gnome_talos_session_LDADD = $(GIO_UNIX_LIBS)
+gnome_talos_CPPFLAGS = $(GIO_UNIX_CFLAGS)
+gnome_talos_LDADD = $(GIO_UNIX_LIBS)
diff --git a/src/gnome-talos-session.c b/src/gnome-talos.c
similarity index 75%
rename from src/gnome-talos-session.c
rename to src/gnome-talos.c
index 40989cc..6cd083a 100644
--- a/src/gnome-talos-session.c
+++ b/src/gnome-talos.c
@@ -28,6 +28,8 @@
#include "gnome-talos-procinfo.h"
#include "gnome-talos-meta.h"
+static gint timeout = 5;
+
GVariant *
gather_snapshot (void)
{
@@ -75,16 +77,24 @@ print_variant (GVariant *variant)
g_free (str);
}
+typedef struct {
+ GMainLoop *loop;
+} GnomeTalosApp;
+
static gboolean
timeout_gather_data (gpointer user_data)
{
+ GnomeTalosApp *app = user_data;
GVariant *snapshot;
snapshot = gather_snapshot ();
print_variant (snapshot);
g_variant_unref (snapshot);
- g_timeout_add_seconds (5, timeout_gather_data, NULL);
+ if (timeout > 0)
+ g_timeout_add_seconds (timeout, timeout_gather_data, NULL);
+ else
+ g_main_loop_quit (app->loop);
return FALSE;
}
@@ -93,20 +103,36 @@ int
main (int argc,
char **argv)
{
+ GnomeTalosApp app;
GVariant *sysinfo;
- GMainLoop *loop;
+ GError *error = NULL;
+ GOptionContext *context;
+ static const GOptionEntry options[] = {
+ { "timeout", 0, 0, G_OPTION_ARG_INT, &timeout, "Time between data snapshots, in seconds (default=5)", "seconds" },
+ { NULL }
+ };
g_type_init ();
+
+ context = g_option_context_new (NULL);
+
+ g_option_context_add_main_entries (context, options, NULL);
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ g_printerr ("%s", error->message);
+ return 1;
+ }
sysinfo = gnome_talos_acquire_meta ();
print_variant (sysinfo);
g_variant_unref (sysinfo);
- loop = g_main_loop_new (NULL, TRUE);
+ app.loop = g_main_loop_new (NULL, TRUE);
- g_idle_add (timeout_gather_data, NULL);
+ g_idle_add (timeout_gather_data, &app);
- g_main_loop_run (loop);
+ g_main_loop_run (app.loop);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]