[Initng-svn] r2730 - in under_construction/initconf/src: . .deps

svn at initng.thinktux.net svn at initng.thinktux.net
Thu Jan 5 10:06:49 CET 2006


Author: danne
Date: Thu Jan  5 10:06:49 2006
New Revision: 2730

Added:
   under_construction/initconf/src/serviceparser.c
   under_construction/initconf/src/serviceparser.h
Modified:
   under_construction/initconf/src/.deps/main.Po
   under_construction/initconf/src/.deps/rlparser.Po
   under_construction/initconf/src/Makefile.am
   under_construction/initconf/src/main.c
   under_construction/initconf/src/rlparser.c
   under_construction/initconf/src/rlparser.h
Log:
Now also with a combobox! ;-)


Modified: under_construction/initconf/src/.deps/main.Po
==============================================================================
--- under_construction/initconf/src/.deps/main.Po	(original)
+++ under_construction/initconf/src/.deps/main.Po	Thu Jan  5 10:06:49 2006
@@ -429,7 +429,7 @@
   /usr/include/libgnomeui-2.0/libgnomeui/gnome-password-dialog.h \
   /usr/include/libgnomeui-2.0/libgnomeui/gnome-help.h \
   /usr/include/libgnomeui-2.0/libgnomeui/gnome-url.h interface.h \
-  support.h rlparser.h
+  support.h rlparser.h serviceparser.h
 
 ../config.h:
 
@@ -1418,3 +1418,5 @@
 support.h:
 
 rlparser.h:
+
+serviceparser.h:

Modified: under_construction/initconf/src/.deps/rlparser.Po
==============================================================================
--- under_construction/initconf/src/.deps/rlparser.Po	(original)
+++ under_construction/initconf/src/.deps/rlparser.Po	Thu Jan  5 10:06:49 2006
@@ -430,7 +430,7 @@
   /usr/include/libgnomeui-2.0/libgnomeui/gnome-help.h \
   /usr/include/libgnomeui-2.0/libgnomeui/gnome-url.h interface.h \
   support.h /usr/include/dirent.h /usr/include/bits/dirent.h \
-  /usr/include/assert.h /usr/include/fnmatch.h
+  /usr/include/fnmatch.h
 
 ../config.h:
 
@@ -1422,6 +1422,4 @@
 
 /usr/include/bits/dirent.h:
 
-/usr/include/assert.h:
-
 /usr/include/fnmatch.h:

Modified: under_construction/initconf/src/Makefile.am
==============================================================================
--- under_construction/initconf/src/Makefile.am	(original)
+++ under_construction/initconf/src/Makefile.am	Thu Jan  5 10:06:49 2006
@@ -12,7 +12,8 @@
 	support.c support.h \
 	interface.c interface.h \
 	callbacks.c callbacks.h \
-	rlparser.c rlparser.h
+	rlparser.c rlparser.h \
+	serviceparser.c serviceparser.h
 
 initconf_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
 

Modified: under_construction/initconf/src/main.c
==============================================================================
--- under_construction/initconf/src/main.c	(original)
+++ under_construction/initconf/src/main.c	Thu Jan  5 10:06:49 2006
@@ -12,6 +12,7 @@
 #include "interface.h"
 #include "support.h"
 #include "rlparser.h"
+#include "serviceparser.h"
 
 int
 main (int argc, char *argv[])
@@ -39,6 +40,7 @@
   gtk_widget_show (initconf_app);
 
   populate_servicelist(initconf_app);
+  populate_runlevelcombo(initconf_app);
 
   gtk_main ();
   return 0;

Modified: under_construction/initconf/src/rlparser.c
==============================================================================
--- under_construction/initconf/src/rlparser.c	(original)
+++ under_construction/initconf/src/rlparser.c	Thu Jan  5 10:06:49 2006
@@ -7,105 +7,35 @@
 #include "interface.h"
 #include "support.h"
 #include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <assert.h>
 #include <fnmatch.h>
-#include <stdio.h>
 
 #define BASEDIR "/etc/initng"
 
-int filefilter(const struct dirent* entry) {
-  if(strcmp(entry->d_name, ".") && strcmp(entry->d_name, ".."))
+int rlfilefilter(const struct dirent* entry) {
+  if(!fnmatch("*.runlevel", entry->d_name, 0))
     return 1;
   else
     return 0;
 }
 
-void recursive_scan(char* path, GtkListStore *store) {
-  GtkTreeIter iter;
+void populate_runlevelcombo(GtkWidget * any_widget) {
+  GtkWidget *RunlevelCombo;
   
+  RunlevelCombo = lookup_widget(GTK_WIDGET(any_widget), "RunlevelCombo");
+
   struct dirent **namelist;
-  int n = scandir(path, &namelist, &filefilter, alphasort);
+  int n = scandir(BASEDIR, &namelist, &rlfilefilter, alphasort);
   if(n < 0)
     perror("Unable to read directory");
-  else {
-    while(n--) {
-      struct stat buff;
-      char *fullpath = malloc(strlen(path) + strlen(namelist[n]->d_name) + 2);
-      sprintf(fullpath, "%s/%s", path, namelist[n]->d_name);
-      if(lstat(fullpath, &buff)<0)
-        perror("Strange fault!");
-      if(S_ISDIR(buff.st_mode))
-        recursive_scan(fullpath, store);
-      else if(!fnmatch("*.i", namelist[n]->d_name, 0)) {
-        FILE *file;              /* File descriptor for file */
-        struct stat stat_buf;
-        int res;                    /* Result of read */
-
-        file = fopen(fullpath, "rt");   /* Open file. */
-
-        if (file == NULL) 
-          continue;
-
-        /* Allocate a file buffer */
-        char* buffer = malloc(255); //UGLY!
-
-        /* Read whole file */
-        while(fgets(buffer, 255, file) > 0) {
-          if(strstr(buffer, "daemon") == buffer || 
-             strstr(buffer, "service") == buffer) {
-            printf("Splitting %s\n", buffer);
-            char *tok = strtok(buffer, " ");
-            tok = strtok(NULL, " ");
-            printf("Adding token %s\n", tok);
-            gtk_list_store_append (store, &iter);
-            gtk_list_store_set (store, &iter, 0, tok, -1);
-            printf("Que?\n");
-
-            /*char *str, *token;
-            int j;
-            for (j = 1, str = buffer; ; j++, str = NULL) {
-              printf("1 %s\n", buffer);
-              token = strtok(str, " ");
-              printf("2\n");
-              if (str == NULL)
-                break;
-              printf("3 %s\n", str);
-              if(strstr(str, "/") != NULL) {
-                gtk_list_store_append (store, &iter);
-                gtk_list_store_set (store, &iter, 0, token, -1);               
-              }
-            }*/
-          }
-        }
-
-        fclose(file);
-        free(buffer);
-      }
-      free(namelist[n]);
-      free(fullpath);
-    }
-    free(namelist);
-  }
-}
 
-void populate_servicelist(GtkWidget * any_widget) {
+  gtk_combo_box_new_text();
+  while(n--) {
+    namelist[n]->d_name[strlen(namelist[n]->d_name)-9] = 0;
+    gtk_combo_box_append_text(GTK_COMBO_BOX(RunlevelCombo),
+                              namelist[n]->d_name);
+    free(namelist[n]);
+  }
+  free(namelist);
 
-  GtkWidget *servicelist;
-  GtkCellRenderer *renderer;
-  GtkTreeModel *model;
-  GtkListStore  *store = gtk_list_store_new (1, G_TYPE_STRING);
-
-  renderer = gtk_cell_renderer_text_new();
-  servicelist = lookup_widget(GTK_WIDGET(any_widget), "servicelist");
-  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(servicelist),
-                                              -1, "system",
-					      renderer, "text", 0,
-					      NULL);
-
-  recursive_scan(BASEDIR, store);
-  model = GTK_TREE_MODEL(store);
-  gtk_tree_view_set_model(GTK_TREE_VIEW(servicelist), model);
-  g_object_unref(model);
+  //g_object_unref(RunlevelCombo);
 }

Modified: under_construction/initconf/src/rlparser.h
==============================================================================
--- under_construction/initconf/src/rlparser.h	(original)
+++ under_construction/initconf/src/rlparser.h	Thu Jan  5 10:06:49 2006
@@ -1 +1 @@
-void populate_servicelist(GtkWidget * any_widget);
+void populate_runlevelcombo(GtkWidget * any_widget);


More information about the Initng-svn mailing list