[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 16:21:24 PDT 2011


On 09/19/2011 07:49 PM, Maciej Marcin Piechotka wrote:
> On Mon, 2011-09-19 at 13:24 +0200, Zbigniew Jędrzejewski-Szmek wrote:
>> 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)
>
> I don't think you should:
>
>   - Hard autodetect. Soft autodetection is usually considered fine - such
> as in gtk (soft autodetection - --enable-gtk forces build, --disable-gtk
> disables it and lack of it dis/enables feature automatically). It may
> cause problems for example on Gentoo and may make the life of packagers
> in other systems harder.
>   - Rename HAVE_GTK to HAVE_LIBGEE
>
> Probably the easiest way is to add the entries to change:
>
> -        PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0>  2.26 gio-unix-2.0
> ],
> +        PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0>  2.26 gio-unix-2.0
> libgee-1.0 ],

Hi,
HAVE_LIBGEE was added to distinguish different dependencies of systemadm 
and gnome-ask-password-agent. But I guess that indeed having a separate 
HAVE_LIBGEE is not worth the trouble. An improved patch which just makes 
HAVE_GTK dependent on libgee is below.

Best,
Zbyszek

---
  Makefile.am        |    1 +
  configure.ac       |    2 +-
  src/systemadm.vala |   14 ++++++++++++++
  3 files changed, 16 insertions(+), 1 deletions(-)

diff --git Makefile.am Makefile.am
index ec0f7b5..0712945 100644
--- Makefile.am
+++ Makefile.am
@@ -1432,6 +1432,7 @@ systemadm_CFLAGS = \
  systemadm_VALAFLAGS = \
  	--pkg=posix \
  	--pkg=gtk+-2.0 \
+	--pkg=gee-1.0 \
  	-g

  systemadm_LDADD = \
diff --git configure.ac configure.ac
index ca07456..b2411c9 100644
--- configure.ac
+++ configure.ac
@@ -327,7 +327,7 @@ AM_CONDITIONAL(ENABLE_LOCALED, [test "$have_localed" 
= "yes"])
  have_gtk=no
  AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
  if test "x$enable_gtk" != "xno"; then
-        PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 ],
+        PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 
gee-1.0],
                  [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) 
have_gtk=yes], have_gtk=no)
          AC_SUBST(GTK_CFLAGS)
          AC_SUBST(GTK_LIBS)
diff --git src/systemadm.vala src/systemadm.vala
index 68652d0..c893da0 100644
--- src/systemadm.vala
+++ 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();

@@ -712,6 +722,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);
@@ -773,6 +785,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.6



More information about the systemd-devel mailing list