Enlightenment CVS committal Author : andreas99 Project : e16 Module : tools
Dir : e16/tools/e16menuedit2/src Modified Files: callbacks.c e16menu.c e16menuedit2.c e16menuedit2.h file.c Log Message: initial support for new e16 > 0.16.8 menu structure (try Parameter -e) =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/callbacks.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- callbacks.c 10 Nov 2004 18:20:54 -0000 1.21 +++ callbacks.c 5 Dec 2004 11:12:51 -0000 1.22 @@ -305,11 +305,11 @@ if (help_error == 1) { - print_statusbar ("No help file found!\n"); + print_statusbar (_("No help file found!")); } else if (help_error == 2) { - print_statusbar ("No help application found"); + print_statusbar (_("No help application found")); } } } =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menu.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e16menu.c 10 Nov 2004 13:39:47 -0000 1.4 +++ e16menu.c 5 Dec 2004 11:12:51 -0000 1.5 @@ -23,16 +23,17 @@ * Created by: Andreas Volz <[EMAIL PROTECTED]> * */ - + #include <stdio.h> #include "e16menu.h" #include "file.h" #include "e16menuedit2.h" #include "treeview.h" - + int app_errno; char app_errno_str[APP_ERRNO_STR_LEN]; - +extern char *emenu_path; + GtkTreeModel *load_menus_from_disk (void) { @@ -49,8 +50,16 @@ G_TYPE_STRING, G_TYPE_STRING); - /* currently hardcoded, but not a big issue to change later */ - sprintf (buf, "%s/.enlightenment/file.menu", homedir (getuid ())); + if (!strcmp (emenu_path, ENLIGHTENMENT_MENU)) + sprintf (buf, "%s/%s/file.menu", homedir (getuid ()), emenu_path); + else if (!strcmp (emenu_path, E16_MENU)) + sprintf (buf, "%s/%s/%s/file.menu", homedir (getuid ()), emenu_path, "menus"); + else + { + printf ("unknown menu definition!\n"); + exit (1); + } + menufile = fopen (buf, "r"); if (!menufile) { @@ -58,6 +67,9 @@ "a %s file.\n", buf); gtk_exit (1); } +#ifdef DEBUG + g_print ("Loading menu: %s\n", buf); +#endif /* DEBUG */ while (fgets (s, 4096, menufile)) { @@ -150,22 +162,25 @@ void load_sub_menu_from_disk (char *file_to_load, GtkTreeStore *store, GtkTreeIter *iter) { - FILE *menufile; char buf[1024]; char first = 1; char s[4096]; GtkTreeIter sub_iter; - + if (!file_to_load) return; if (file_to_load[0] != '/') - sprintf (buf, "%s/.enlightenment/%s", homedir (getuid ()), file_to_load); + sprintf (buf, "%s/%s/%s", homedir (getuid ()), emenu_path, file_to_load); else sprintf (buf, "%s", file_to_load); menufile = fopen (buf, "r"); +#ifdef DEBUG + g_print ("Loading submenu: %s\n", buf); +#endif /* DEBUG */ + if (!menufile) return; @@ -225,6 +240,7 @@ return; } +#define WRITE_FILE /* undef this for debugging without writing menus */ gboolean table_save_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { @@ -248,8 +264,6 @@ has_child = gtk_tree_model_iter_has_child (model, iter); depth = gtk_tree_path_get_depth (path) - 1; -#define WRITE_FILE /* undef this for debugging without writing menus */ -#ifdef WRITE_FILE if (depth + 1 >= MAX_RECURSION) { g_print ("maximum menu recursion reached! -> %d\n", MAX_RECURSION); @@ -260,7 +274,7 @@ { /* Tarnation! A relative path */ realfile = g_strjoin ("/", homedir (getuid ()), - ".enlightenment", params, NULL); + emenu_path, params, NULL); } else { @@ -284,57 +298,75 @@ if (has_child) { - menu_ptr2 = fopen (menu_file[depth], "w"); +#ifdef WRITE_FILE + menu_ptr2 = fopen (menu_file[depth], "w"); if (menu_ptr2 == NULL) { printf ("Couldn't save menu to: %s\n", menu_file[depth]); } - //g_print ("write header to \"%s\":\n", menu_file[depth]); +#endif /* WRITE_FILE */ + sprintf (buffer, "\"%s\"\n", description); +#ifdef WRITE_FILE fprintf (menu_ptr2, "%s", g_locale_from_utf8 (buffer, -1, NULL, NULL, NULL)); fclose (menu_ptr2); - - //g_print ("write menu to \"%s\":\n", menu_file[depth-1]); +#else + g_print ("write header to: \"%s\"\n", menu_file[depth]); +#endif /* !WRITE_FILE */ + sprintf (buffer, "\"%s\"\t%s\tmenu\t\"%s\"\n", description[0] == '\0' ? "NULL" : description, icon[0] == '\0' ? "NULL" : icon, params[0] == '\0' ? "" : params); +#ifdef WRITE_FILE fprintf (menu_ptr, "%s", g_locale_from_utf8 (buffer, -1, NULL, NULL, NULL)); +#else + g_print ("write menu to: \"%s\"\n", menu_file[depth-1]); +#endif /* WRITE_FILE */ } else { - //g_print ("write exec to \"%s\":\n", menu_file[depth-1]); sprintf (buffer, "\"%s\"\t%s\texec\t\"%s\"\n", description[0] == '\0' ? "NULL" : description, icon[0] == '\0' ? "NULL" : icon, params[0] == '\0' ? "" : params); - +#ifdef WRITE_FILE fprintf (menu_ptr, "%s", g_locale_from_utf8 (buffer, -1, NULL, NULL, NULL)); +#else + g_print ("write exec to: \"%s\"\n", menu_file[depth-1]); +#endif /*WRITE_FILE */ } +#ifdef WRITE_FILE fclose (menu_ptr); +#endif /*WRITE_FILE */ } else { +#ifdef WRITE_FILE menu_ptr2 = fopen (menu_file[depth], "w"); if (menu_ptr2 == NULL) { printf ("Couldn't save menu to: %s\n", menu_file[depth]); } - //g_print ("write first header to \"%s\":\n", menu_file[depth]); +#endif /*WRITE_FILE */ + sprintf (buffer, "\"%s\"\n", description); +#ifdef WRITE_FILE fprintf (menu_ptr2, "%s", g_locale_from_utf8 (buffer, -1, NULL, NULL, NULL)); fclose (menu_ptr2); +#else + g_print ("write first header to: \"%s\"\n", menu_file[depth]); +#endif /* WRITE_FILE */ } -#endif /* WRITE_FILE */ #ifndef WRITE_FILE g_print ("%s | ", tree_path_str); g_print ("%s %s %s\n", description, icon, params); -#endif /* WRITE_FILE */ +#endif /* !WRITE_FILE */ /* end of filelist to free it later */ menu_file[depth+1] = NULL; @@ -349,7 +381,7 @@ } gboolean table_check_func (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer user_data) + GtkTreeIter *iter, gpointer user_data) { gchar *description, *icon, *params; gchar *tree_path_str; @@ -380,14 +412,14 @@ if (depth > 0) { if (has_child) - { + { /* some checks for submenus */ if (!strcmp (params, "")) { - app_errno = AE_EMPTY_SUBMENU; - strncpy (app_errno_str, tree_path_str, APP_ERRNO_STR_LEN); - - return TRUE; + app_errno = AE_EMPTY_SUBMENU; + strncpy (app_errno_str, tree_path_str, APP_ERRNO_STR_LEN); + + return TRUE; } } else =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menuedit2.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- e16menuedit2.c 10 Nov 2004 13:39:47 -0000 1.14 +++ e16menuedit2.c 5 Dec 2004 11:12:51 -0000 1.15 @@ -37,6 +37,7 @@ int librsvg_cmp; char *browser; char *glade_file; +char *emenu_path; int main (int argc, char *argv[]) { @@ -61,13 +62,14 @@ textdomain (PACKAGE); #endif + parse_options (argc, argv); gtk_init (&argc, &argv); for (i = 0; i < MAX_RECURSION; i++) { menu_file[i] = NULL; } - + glade_file = searchGladeFile ("e16menuedit2.glade"); main_xml = glade_xml_new (glade_file, "main_window", NULL); @@ -117,7 +119,7 @@ } g_free (filename_properties); - + free (emenu_path); gtk_main (); @@ -184,3 +186,71 @@ return FALSE; } + +void parse_options (int argc, char **argv) +{ + poptContext context; + int option; + char *emenu = NULL; + + struct poptOption options[] = + { + {"emenu", 'e', POPT_ARG_STRING, + &emenu, ARG_EMENU, + "Enlightenment menu dir...", + NULL}, + {"version", 'v', POPT_ARG_NONE, NULL, ARG_VERSION, "show version", NULL}, + POPT_AUTOHELP {NULL, '\0', 0, NULL, 0} + }; + + context = poptGetContext ("popt1", argc, (const char **) argv, options, 0); + + /* start option handling */ + while ((option = poptGetNextOpt (context)) > 0) + { + switch (option) + { + case ARG_EMENU: + g_print ("emenu case\n"); + break; + case ARG_VERSION: + show_version (); + exit (0); + break; + } + } + + if (emenu == NULL) + { + emenu_path = malloc (strlen (".enlightenment") + 1); + strcpy (emenu_path, ".enlightenment"); + } + else + { + if (!strcmp (emenu, "enlightenment")) + { + emenu_path = malloc (strlen (ENLIGHTENMENT_MENU) + 1); + strcpy (emenu_path, ENLIGHTENMENT_MENU); + } + else if (!strcmp (emenu, "e16")) + { + emenu_path = malloc (strlen (E16_MENU) + 1); + strcpy (emenu_path, E16_MENU); + } + else + { + g_print ("Sorry, the parameter 'emenu' has only state 'enlightenment'\n" + "for old directory before E-0.16.7.1 and 'e16' for new\n" + "direcory in '.e16/menus'\n"); + exit (0); + } + } +} + +void show_version () +{ + g_print ("Package name: "); + g_print ("%s %s\n", PACKAGE, VERSION); + g_print ("Build information: "); + g_print ("%s %s\n", __DATE__, __TIME__); +} =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menuedit2.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- e16menuedit2.h 10 Nov 2004 13:39:47 -0000 1.7 +++ e16menuedit2.h 5 Dec 2004 11:12:51 -0000 1.8 @@ -32,6 +32,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif +#include <popt.h> #include "nls.h" #include "libglade_support.h" @@ -40,11 +41,20 @@ #define APP_HOME ".e16menuedit2" #define ICON_DIR "icons" +#define DEBUG_OUTPUT printf ("(%s, %d): ", __FILE__, __LINE__); +#define ENLIGHTENMENT_MENU ".enlightenment" +#define E16_MENU ".e16" void print_statusbar (const gchar *format, ...); gboolean browser_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data); +void parse_options (int argc, char **argv); +void show_version (); -#define DEBUG_OUTPUT printf ("(%s, %d): ", __FILE__, __LINE__); +enum +{ + ARG_EMENU, + ARG_VERSION +}; #endif /* _E16MENUEDIT_H */ =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- file.c 10 Nov 2004 13:39:47 -0000 1.9 +++ file.c 5 Dec 2004 11:12:51 -0000 1.10 @@ -341,7 +341,9 @@ gboolean help_missing = TRUE; struct stat buf; - locale = setlocale (LC_ALL, NULL); + locale = setlocale (LC_MESSAGES, NULL); + + printf ("locale: %s\n", locale); params = g_strdup_printf ("%s/%s/%s", help_dir, locale, help_file); ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs