Enlightenment CVS committal Author : codewarrior Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_apps.c e_eap_editor.c e_eap_editor.h e_int_menus.c Log Message: - add ability to create new eaps (based on engrave's approach) - change edit's gui a bit - add some callbacks to editor =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v retrieving revision 1.94 retrieving revision 1.95 diff -u -3 -r1.94 -r1.95 --- e_apps.c 24 Oct 2005 21:52:31 -0000 1.94 +++ e_apps.c 25 Oct 2005 01:03:50 -0000 1.95 @@ -2,7 +2,7 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "e.h" - +#include <errno.h> /* TODO List: * * - We assume only .eap files in 'all', no subdirs @@ -43,6 +43,7 @@ static void _e_app_free (E_App *a); static E_App *_e_app_subapp_file_find (E_App *a, const char *file); +static int _e_app_new_save (E_App *a); static void _e_app_change (E_App *a, E_App_Change ch); static int _e_apps_cb_exit (void *data, int type, void *event); static void _e_app_cb_monitor (void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path); @@ -71,6 +72,42 @@ static char *_e_apps_path_trash = NULL; static Evas_List *_e_apps_start_pending = NULL; +#define EAP_EDC_TMPL \ +"images {\n" \ +" image: \"%s\" COMP;\n" \ +"}\n" \ +"collections {\n" \ +" group {\n" \ +" name: \"icon\";\n" \ +" max: %s %s;\n" \ +" parts {\n" \ +" part {\n" \ +" name: \"image\";\n" \ +" type: IMAGE;\n" \ +" mouse_events: 0;\n" \ +" description {\n" \ +" state: \"default\" 0.00;\n" \ +" visible: 1;\n" \ +" aspect: 1.00 1.00;\n" \ +" rel1 {\n" \ +" relative: 0.00 0.00;\n" \ +" offset: 0 0;\n" \ +" }\n" \ +" rel2 {\n" \ +" relative: 1.00 1.00;\n" \ +" offset: -1 -1;\n" \ +" }\n" \ +" image {\n" \ +" normal: \"%s\";\n" \ +" }\n" \ +" }\n" \ +" }\n" \ +" }\n" \ +" }\n" \ +"}\n" + + + /* externally accessible functions */ int e_app_init(void) @@ -243,7 +280,8 @@ a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free); a->image = NULL; - a->path = strdup(path); + if(path) + a->path = strdup(path); return a; } @@ -961,22 +999,26 @@ char *str, *v; char *lang; int size; - unsigned char tmp[1]; - + unsigned char tmp[1]; + int img; + + if(!ecore_file_exists(a->path)) + { + _e_app_new_save(a); + img = 0; + } + else + img = 1; + /* get our current language */ lang = getenv("LANG"); /* if its "C" its the default - so drop it */ if ((lang) && (!strcmp(lang, "C"))) lang = NULL; - if(ecore_file_exists(a->path)) + ef = eet_open(a->path, EET_FILE_MODE_READ_WRITE); - else - ef = eet_open(a->path, EET_FILE_MODE_WRITE); if (!ef) return; - - - printf("opened %s\n", a->path); - + if(a->name) { /*if (lang) snprintf(buf, sizeof(buf), "app/info/name[%s]", lang); @@ -1023,7 +1065,7 @@ tmp[0] = 0; eet_write(ef, "app/info/wait_exit", tmp, 1, 0); - if(a->image) + if(a->image && img) { int alpha; Ecore_Evas *buf; @@ -1156,6 +1198,78 @@ /* local subsystem functions */ + +/* write out a new eap, code borrowed from Engrave */ +static int +_e_app_new_save(E_App *a) +{ + static char tmpn[1024]; + int fd = 0, ret = 0; + char cmd[2048]; + char ipart[512]; + FILE *out = NULL; + char *start, *end, *imgdir; + int i; + + if(!a->path) + return 0; + + strcpy(tmpn, "/tmp/eapp_edit_cc.edc-tmp-XXXXXX"); + fd = mkstemp(tmpn); + if (fd < 0) { + fprintf(stderr, "Unable to create tmp file: %s\n", strerror(errno)); + return 0; + } + close(fd); + + out = fopen(tmpn, "w"); + if (!out) + { + printf("can't open %s for writing\n", tmpn); + return 0; + } + + i = 0; + start = strchr(a->image, '/'); + end = strrchr(a->image ,'/'); + + if (start == end) + { + imgdir = strdup("/");; + } + else if ((!start) || (!end)) + { + imgdir = strdup(""); + } + else + { + imgdir = malloc((end - start + 1)); + if (imgdir) + { + memcpy(imgdir, start, end - start); + imgdir[end - start] = 0; + } + } + + if (imgdir) snprintf(ipart, sizeof(ipart), "-id %s", imgdir); + else ipart[0] = '\0'; + + fprintf(out, EAP_EDC_TMPL, a->image, "48", "48", a->image); + fclose(out); + + snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn, a->path); + ret = system(cmd); + + if (ret < 0) { + fprintf(stderr, "Unable to execute edje_cc on tmp file: %s\n", + strerror(errno)); + return 0; + } + + unlink(tmpn); + return 1; +} + static void _e_app_free(E_App *a) { =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_eap_editor.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_eap_editor.c 24 Oct 2005 23:08:20 -0000 1.1 +++ e_eap_editor.c 25 Oct 2005 01:03:50 -0000 1.2 @@ -4,7 +4,7 @@ static void _e_eap_edit_save_cb(void *data, E_Dialog *dia); static void _e_eap_edit_cancel_cb(void *data, E_Dialog *dia); -static void _e_eap_edit_browse_cb(void *data, E_Dialog *dia); +static void _e_eap_edit_browse_cb(void *data1, void *data2); static void _e_eap_edit_free(E_App_Edit *app); @@ -33,73 +33,79 @@ ol = e_widget_list_add(app->evas, 0, 0); o = e_widget_table_add(app->evas, _("Eap Info"), 0); + + e_widget_table_object_append(o, e_widget_button_add(app->evas, "Set Icon", + NULL, _e_eap_edit_browse_cb, + app, NULL), + 1, 0, 1, 1, + 0, 0, 0, 0); e_widget_table_object_append(o, e_widget_label_add(app->evas, "App name"), - 0, 0, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1); { Evas_Object *entry; entry = e_widget_entry_add(app->evas, NULL); e_widget_min_size_set(entry, 100, 1); e_widget_table_object_append(o, entry, - 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1); } e_widget_table_object_append(o, e_widget_label_add(app->evas, "Generic Info"), - 0, 1, 1, 1, + 0, 2, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Comments"), - 0, 2, 1, 1, + 0, 3, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 2, 1, 1, + 1, 3, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Executable"), - 0, 3, 1, 1, + 0, 4, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 3, 1, 1, + 1, 4, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Window Name"), - 0, 4, 1, 1, + 0, 5, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 4, 1, 1, + 1, 5, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Window Class"), - 0, 5, 1, 1, + 0, 6, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 5, 1, 1, + 1, 6, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Path"), - 0, 6, 1, 1, + 0, 7, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_entry_add(app->evas, NULL), - 1, 6, 1, 1, + 1, 7, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Startup notify"), - 0, 7, 1, 1, + 0, 8, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_check_add(app->evas, "", NULL), - 1, 7, 1, 1, + 1, 8, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_label_add(app->evas, "Wait exit"), - 0, 8, 1, 1, + 0, 9, 1, 1, 1, 1, 1, 1); e_widget_table_object_append(o, e_widget_check_add(app->evas, "", NULL), - 1, 8, 1, 1, + 1, 9, 1, 1, 1, 1, 1, 1); e_widget_list_object_append(ol, o, 1, 1, 0.5); @@ -120,7 +126,13 @@ static void _e_eap_edit_save_cb(void *data, E_Dialog *dia) -{} +{ + E_App_Edit *app; + E_App *a; + + app = data; + a = app->eap; +} static void _e_eap_edit_cancel_cb(void *data, E_Dialog *dia) @@ -129,7 +141,7 @@ } static void -_e_eap_edit_browse_cb(void *data, E_Dialog *dia) +_e_eap_edit_browse_cb(void *data1, void *data2) {} static void _e_eap_edit_free(E_App_Edit *app) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_eap_editor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_eap_editor.h 24 Oct 2005 23:08:20 -0000 1.1 +++ e_eap_editor.h 25 Oct 2005 01:03:50 -0000 1.2 @@ -18,6 +18,18 @@ E_Dialog *dia; E_App *eap; + + struct { + char *name; + char *generic; + char *comments; + char *exe; + char *wname; + char *wclass; + char *path; + int startup_notify; + int wait_exit; + } data; }; E_App_Edit *e_eap_edit_show(E_Container *con, E_App *a); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_int_menus.c,v retrieving revision 1.109 retrieving revision 1.110 diff -u -3 -r1.109 -r1.110 --- e_int_menus.c 24 Oct 2005 23:08:20 -0000 1.109 +++ e_int_menus.c 25 Oct 2005 01:03:50 -0000 1.110 @@ -617,7 +617,7 @@ E_App_Edit *eap_edit; E_App *a; - a = e_app_empty_new("/tmp/foo.eap"); + a = e_app_empty_new(NULL); eap_edit = e_eap_edit_show(m->zone->container, a); } ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs