[systemd-devel] [PATCH 07/14] systemadm: add libgee as dependency and use it for a unit map

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Sep 19 04:24:22 PDT 2011


---
 Makefile.am        |   12 ++++++++----
 configure.ac       |    8 +++++++-
 src/systemadm.vala |   14 ++++++++++++++
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ec0f7b5..1a3ac07 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -144,9 +144,10 @@ dist_bin_SCRIPTS = \
 	src/systemd-analyze
 
 if HAVE_GTK
-bin_PROGRAMS += \
-	systemadm \
-	systemd-gnome-ask-password-agent
+bin_PROGRAMS += systemd-gnome-ask-password-agent
+if HAVE_LIBGEE
+bin_PROGRAMS += systemadm
+endif
 endif
 
 rootlibexec_PROGRAMS = \
@@ -1424,6 +1425,7 @@ systemadm_SOURCES = \
 systemadm_CFLAGS = \
 	$(AM_CFLAGS) \
 	$(GTK_CFLAGS) \
+	$(LIBGEE_CFLAGS) \
 	-Wno-unused-variable \
 	-Wno-unused-function \
 	-Wno-shadow \
@@ -1432,10 +1434,12 @@ systemadm_CFLAGS = \
 systemadm_VALAFLAGS = \
 	--pkg=posix \
 	--pkg=gtk+-2.0 \
+	--pkg=gee-1.0 \
 	-g
 
 systemadm_LDADD = \
-	$(GTK_LIBS)
+	$(GTK_LIBS) \
+	$(LIBGEE_LIBS)
 
 systemd_gnome_ask_password_agent_SOURCES = \
 	src/gnome-ask-password-agent.vala
diff --git a/configure.ac b/configure.ac
index ca07456..5e4b483 100644
--- a/configure.ac
+++ b/configure.ac
@@ -348,7 +348,13 @@ AM_CONDITIONAL(LIBNOTIFY07, [ test "$libnotify07" = "yes" ])
 
 AM_PROG_VALAC([0.10])
 AC_SUBST(VAPIDIR)
-AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
+AM_CONDITIONAL(HAVE_VALAC, [ test x"$VALAC" != x"" ])
+
+PKG_CHECK_MODULES(LIBGEE, [ gee-1.0 ])
+PKG_CHECK_EXISTS([ gee-1.0 ], [ libgee=yes ])
+AC_SUBST(LIBGEE_CFLAGS)
+AC_SUBST(LIBGEE_LIBS)
+AM_CONDITIONAL(HAVE_LIBGEE, [ test x"$libgee" = x"yes" ])
 
 AC_PATH_PROG([XSLTPROC], [xsltproc])
 AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
diff --git a/src/systemadm.vala b/src/systemadm.vala
index c4581a2..1c0c99f 100644
--- a/src/systemadm.vala
+++ b/src/systemadm.vala
@@ -79,6 +79,8 @@ public class MainWindow : Window {
         private ListStore unit_model;
         private ListStore job_model;
 
+        private Gee.HashMap<string, Unit> unit_map;
+
         private Button start_button;
         private Button stop_button;
         private Button restart_button;
@@ -180,6 +182,8 @@ public class MainWindow : Window {
                 unit_model = new ListStore(7, typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Unit));
                 job_model = new ListStore(6, typeof(string), typeof(string), typeof(string), typeof(string), typeof(Job), typeof(uint32));
 
+                unit_map = new Gee.HashMap<string, Unit>();
+
                 TreeModelFilter unit_model_filter;
                 unit_model_filter = new TreeModelFilter(unit_model, null);
                 unit_model_filter.set_visible_func(unit_filter);
@@ -355,6 +359,8 @@ public class MainWindow : Window {
                                         "org.freedesktop.systemd1",
                                         i.unit_path);
 
+                        unit_map[i.id] = u;
+
                         unit_model.append(out iter);
                         unit_model.set(iter,
                                        0, i.id,
@@ -415,6 +421,10 @@ public class MainWindow : Window {
                 return u;
         }
 
+        public Unit? get_unit(string id) {
+                return this.unit_map[id];
+        }
+
         public void unit_changed() {
                 Unit u = get_current_unit();
 
@@ -717,6 +727,8 @@ public class MainWindow : Window {
                                         "org.freedesktop.systemd1",
                                         path);
 
+                        unit_map[id] = u;
+
                         update_unit_iter(iter, id, u);
                 } catch (IOError e) {
                         show_error(e.message);
@@ -778,6 +790,8 @@ public class MainWindow : Window {
                         }
 
                 } while (unit_model.iter_next(ref iter));
+
+                unit_map.unset(id);
         }
 
         public void on_job_removed(uint32 id, ObjectPath path, string res) {
-- 
1.7.5.4



More information about the systemd-devel mailing list