Author: akv
Date: 2012-04-17 18:05:55 +0200 (Tue, 17 Apr 2012)
New Revision: 4179

Modified:
   branches/4175-enfuse/src/rs-actions.c
   branches/4175-enfuse/src/rs-enfuse.c
   branches/4175-enfuse/src/rs-enfuse.h
Log:
Only enabling Enfuse menu if enfuse is available - currently checks for v. 4.0.

Modified: branches/4175-enfuse/src/rs-actions.c
===================================================================
--- branches/4175-enfuse/src/rs-actions.c       2012-04-17 15:00:12 UTC (rev 
4178)
+++ branches/4175-enfuse/src/rs-actions.c       2012-04-17 16:05:55 UTC (rev 
4179)
@@ -111,6 +111,7 @@
        rs_core_action_group_set_sensivity("RotateCounterClockwise", 
RS_IS_PHOTO(rs->photo));
        rs_core_action_group_set_sensivity("Flip", RS_IS_PHOTO(rs->photo));
        rs_core_action_group_set_sensivity("Mirror", RS_IS_PHOTO(rs->photo));
+       rs_core_action_group_set_sensivity("Enfuse", rs_has_enfuse(4,0));
 #ifndef EXPERIMENTAL
        rs_core_action_group_set_visibility("Group", FALSE);
        rs_core_action_group_set_visibility("Ungroup", FALSE);

Modified: branches/4175-enfuse/src/rs-enfuse.c
===================================================================
--- branches/4175-enfuse/src/rs-enfuse.c        2012-04-17 15:00:12 UTC (rev 
4178)
+++ branches/4175-enfuse/src/rs-enfuse.c        2012-04-17 16:05:55 UTC (rev 
4179)
@@ -180,3 +180,57 @@
   enfuse_images(aligned_names, fullpath->str);
   return fullpath->str;
 }
+
+gboolean rs_has_enfuse (gint major, gint minor)
+{
+  FILE *fp;
+  char line1[128];
+  char line2[128];
+  int _major = 0, _minor = 0;
+  gboolean retval = FALSE;
+
+  fp = popen("enfuse -V","r"); /* enfuse 4.0-753b534c819d */
+  if (fgets(line1, sizeof line1, fp) == NULL)
+    {
+      g_warning("fgets returned: %d\n", retval);
+      return FALSE;
+    }
+  pclose(fp);
+
+  fp = popen("enfuse -h","r"); /* ==== enfuse, version 3.2 ==== */
+  if (fgets(line2, sizeof line2, fp) == NULL)
+    {
+      g_warning("fgets returned: %d\n", retval);
+      return FALSE;
+    }
+  pclose(fp);
+
+  GRegex *regex;
+  gchar **tokens;
+
+  regex = g_regex_new("(enfuse|.* enfuse, version) ([0-9])\x2E([0-9]+).*", 0, 
0, NULL);
+  tokens = g_regex_split(regex, line1, 0);
+  if (tokens)
+    {
+      g_regex_unref(regex);
+    }
+  else 
+    {
+      tokens = g_regex_split(regex, line2, 0);
+      g_regex_unref(regex);
+      if (!tokens)
+       return FALSE;
+    }
+
+  _major = atoi(tokens[2]);
+  _minor = atoi(tokens[3]);
+
+  if (_major > major) {
+    retval = TRUE;
+  } else if (_major == major) {
+    if (_minor >= minor) {
+      retval = TRUE;
+    }
+  }
+  return retval;
+}

Modified: branches/4175-enfuse/src/rs-enfuse.h
===================================================================
--- branches/4175-enfuse/src/rs-enfuse.h        2012-04-17 15:00:12 UTC (rev 
4178)
+++ branches/4175-enfuse/src/rs-enfuse.h        2012-04-17 16:05:55 UTC (rev 
4179)
@@ -23,5 +23,6 @@
 #include "application.h"
 
 extern gchar * rs_enfuse(GList *files);
+extern gboolean rs_has_enfuse (gint major, gint minor);
 
 #endif /* RS_ENFUSE_H  */


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to