Enlightenment CVS committal

Author  : andreas99
Project : e16
Module  : tools

Dir     : e16/tools/e16menuedit2/src


Modified Files:
        Makefile.am callbacks.c file.c file.h 


Log Message:
Added support for non-yelp help system. Currently hardcoded on Mozilla.
This should be configurable...

===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- Makefile.am 16 Aug 2004 18:37:04 -0000      1.6
+++ Makefile.am 28 Aug 2004 12:27:57 -0000      1.7
@@ -22,5 +22,5 @@
         libglade_support.c\
         libglade_support.h
 
-e16menuedit2_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
+e16menuedit2_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) 
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/callbacks.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- callbacks.c 16 Aug 2004 18:37:04 -0000      1.12
+++ callbacks.c 28 Aug 2004 12:27:59 -0000      1.13
@@ -286,7 +286,17 @@
 void on_menu_contents_activate (GtkMenuItem *menuitem,
                                 gpointer user_data)
 {
-  /* only yelp execution currenty in lang C
-     other languages and html fallback comes... */
-  run_yelp (PACKAGE".xml");
+  int help_error;
+
+  help_error = run_help ("yelp", YELP_HELP_DIR, PACKAGE".xml");
+
+  if (help_error)
+  {
+    help_error = run_help ("mozilla", PACKAGE_DOC_DIR, PACKAGE".html");
+
+    if (help_error)
+    {
+      g_print ("no help system or help file found!\n");
+    }
+  }
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- file.c      16 Aug 2004 18:37:04 -0000      1.6
+++ file.c      28 Aug 2004 12:27:59 -0000      1.7
@@ -330,35 +330,84 @@
   return locale_dup;
 }
 
-int run_yelp (char *help_name)
+int run_help (char *help_app, char *help_dir, char *help_file)
 {
   gboolean spawn;
   gchar *argv_child[3];
-  char *locale = malloc (30);
-  int help_exist;
-  struct stat *buf;
-
-  strcpy (argv_child[0], "yelp");
-  argv_child[2] = NULL;
+  gchar *params;
+  char *locale;
+  char *locale_fallback;
+  char *locale_tmp;
+  gboolean help_missing = TRUE;
+  struct stat buf;
 
   locale = setlocale (LC_ALL, NULL);
 
-  argv_child[1] = g_strdup_printf ("%s/%s/%s",YELP_HELP_DIR, "C", help_name);
+  params = g_strdup_printf ("%s/%s/%s", help_dir,
+                            locale, help_file);
+  help_missing = stat (params, &buf);
 
-  help_exist = stat (argv_child[1], buf);
+  /* locale fallback 1 */
+  if (help_missing)
+  {
+    locale_fallback = get_fallback_locale (locale);
+    g_free (params);
+    params = g_strdup_printf ("%s/%s/%s", help_dir,
+                              locale_fallback, help_file);
+    help_missing = stat (params, &buf);
+
+    /* locale fallback 2 */
+    if (help_missing)
+    {
+      locale_tmp = strdup (locale_fallback);
+      g_free (locale_fallback);
+      locale_fallback = get_fallback_locale (locale_tmp);
+      g_free (locale_tmp);
+      g_free (params);
+      params = g_strdup_printf ("%s/%s/%s", help_dir,
+                                locale_fallback, help_file);
+      help_missing = stat (params, &buf);
+
+      /* locale fallback 3 */
+      if (help_missing)
+      {
+        locale_tmp = strdup (locale_fallback);
+        g_free (locale_fallback);
+        locale_fallback = get_fallback_locale (locale_tmp);
+        g_free (locale_tmp);
+        g_free (params);
+        params = g_strdup_printf ("%s/%s/%s", help_dir,
+                                  locale_fallback, help_file);
+        help_missing = stat (params, &buf);
+      }
+    }
+  }
 
-  if (!help_exist)
+  if (help_missing)
   {
-    spawn = g_spawn_async (NULL, argv_child, NULL,
-                           G_SPAWN_SEARCH_PATH, NULL,
-                           NULL, NULL, NULL);
+    /* no yelp files found */
+    return 1;
   }
   else
   {
-    g_print ("help doesn't exist for locale %s\n", locale);
-  }
+    argv_child[0] = help_app;
+    argv_child[1] = params;
+    argv_child[2] = NULL;
+
+    spawn = g_spawn_async (NULL, argv_child, NULL,
+                           G_SPAWN_SEARCH_PATH, NULL,
+                           NULL, NULL, NULL);
 
-  g_free (argv_child[1]);
+    if (!spawn)
+    {
+      /* no yelp application found */
+      return 2;
+    }
+
+    //g_free (argv_child[0]);
+    g_free (params);
+    g_free (locale_fallback);
+  }
 
   return 0;
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- file.h      16 Aug 2004 18:37:04 -0000      1.5
+++ file.h      28 Aug 2004 12:27:59 -0000      1.6
@@ -51,6 +51,6 @@
 int version_cmp (char *ver1, char *ver2);
 char *pkg_config_version (char *package);
 char *get_fallback_locale (char *locale);
-int run_yelp (char *help_name);
+int run_help (char *help_app, char* help_dir, char *help_file);
 
 #endif /* _FILE_H */




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to