chiark / gitweb /
systemadm: add libgee as dependency and use it for a unit map
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Mar 2011 19:54:01 +0000 (20:54 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Sep 2011 23:06:01 +0000 (01:06 +0200)
Makefile.am
configure.ac
src/systemadm.vala

index ec0f7b5d134d15ff77fd00cf17a2557ce34d7969..07129455324baaafcb94b1ed926f76d7a4a540f4 100644 (file)
@@ -1432,6 +1432,7 @@ systemadm_CFLAGS = \
 systemadm_VALAFLAGS = \
        --pkg=posix \
        --pkg=gtk+-2.0 \
 systemadm_VALAFLAGS = \
        --pkg=posix \
        --pkg=gtk+-2.0 \
+       --pkg=gee-1.0 \
        -g
 
 systemadm_LDADD = \
        -g
 
 systemadm_LDADD = \
index ca07456be64f2d6c02af9ad7c72d5432da0bda55..b2411c937bc4490fad14068b1f99b5d9a98a13fb 100644 (file)
@@ -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
 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)
                 [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
         AC_SUBST(GTK_CFLAGS)
         AC_SUBST(GTK_LIBS)
index 68652d0064cf9c7d9ca9e68e5ea76ca4bab23464..c893da01da1fbc56f765fd70abff7f20c2a5666b 100644 (file)
@@ -79,6 +79,8 @@ public class MainWindow : Window {
         private ListStore unit_model;
         private ListStore job_model;
 
         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;
         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_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);
                 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);
 
                                         "org.freedesktop.systemd1",
                                         i.unit_path);
 
+                        unit_map[i.id] = u;
+
                         unit_model.append(out iter);
                         unit_model.set(iter,
                                        0, i.id,
                         unit_model.append(out iter);
                         unit_model.set(iter,
                                        0, i.id,
@@ -415,6 +421,10 @@ public class MainWindow : Window {
                 return u;
         }
 
                 return u;
         }
 
+        public Unit? get_unit(string id) {
+                return this.unit_map[id];
+        }
+
         public void unit_changed() {
                 Unit u = get_current_unit();
 
         public void unit_changed() {
                 Unit u = get_current_unit();
 
@@ -712,6 +722,8 @@ public class MainWindow : Window {
                                         "org.freedesktop.systemd1",
                                         path);
 
                                         "org.freedesktop.systemd1",
                                         path);
 
+                        unit_map[id] = u;
+
                         update_unit_iter(iter, id, u);
                 } catch (IOError e) {
                         show_error(e.message);
                         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));
                         }
 
                 } while (unit_model.iter_next(ref iter));
+
+                unit_map.unset(id);
         }
 
         public void on_job_removed(uint32 id, ObjectPath path, string res) {
         }
 
         public void on_job_removed(uint32 id, ObjectPath path, string res) {