Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_apps_error.c e_test.c e_widget_textblock.c 


Log Message:


more info on app exiting - translatable strings now. use textblock widget.

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps_error.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- e_apps_error.c      23 Jan 2006 18:53:07 -0000      1.6
+++ e_apps_error.c      25 Jan 2006 10:20:02 -0000      1.7
@@ -34,7 +34,7 @@
          v->advanced.create_widgets = 
_e_app_error_dialog_advanced_create_widgets;
 
          /* Create The Dialog */
-         cfd = e_config_dialog_new(con, _("Run error, wtf?  That sux."), NULL, 
0, v, app);
+         cfd = e_config_dialog_new(con, _("Application Execution Error"), 
NULL, 0, v, app);
          app->error_dialog = cfd;
       }
 }
@@ -42,28 +42,54 @@
 static void 
 _e_app_error_dialog_fill_data(E_App_Autopsy *app, E_Config_Dialog_Data *cfdata)
 {
-   int length;
+   char buf[4096];
 
-   length = strlen(app->app->name);
    if (!cfdata->label)
       {
-         cfdata->label = malloc((length + 20) * sizeof(char));
-         if (cfdata->label)
-            sprintf(cfdata->label, "%s may have crashed.", app->app->name);
+        snprintf(buf, sizeof(buf), _("%s stopped running unexpectedly."), 
+                 app->app->name);
+         cfdata->label = strdup(buf);
       }
 
-   length = strlen(app->app->exe);
    if ((app->del.exited) && (!cfdata->exit))
       {
-         cfdata->exit = malloc((length + 64) * sizeof(char));
-         if (cfdata->exit)
-            sprintf(cfdata->exit, "An exit code of %i was returned from %s", 
app->del.exit_code, app->app->exe);
+        snprintf(buf, sizeof(buf), _("An exit code of %i was returned from 
%s"),
+                 app->del.exit_code, app->app->exe);
+         cfdata->exit = strdup(buf);
       }
    if ((app->del.signalled) && (!cfdata->signal))
       {
-         cfdata->signal = malloc((length + 64) * sizeof(char));
-         if (cfdata->signal)
-            sprintf(cfdata->signal, "%s was interupted by signal %i", 
app->app->exe, app->del.exit_signal);   /* FIXME: add a description of the 
signal. */
+        if (app->del.exit_signal == SIGINT)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by an Interrupt 
Singal"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGQUIT)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Quit Singal"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGABRT)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by an Abort 
Singal"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGFPE)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Floating Point 
Error"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGKILL)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by an 
Uninterruptable Kill Singal"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGSEGV)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Segmentation 
Fault"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGPIPE)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Broken Pipe"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGTERM)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Termination 
Singal"),
+                   app->app->exe, app->del.exit_signal);
+        else if (app->del.exit_signal == SIGBUS)
+          snprintf(buf, sizeof(buf), _("%s was interrupted by a Bus Error"),
+                   app->app->exe, app->del.exit_signal);
+        else
+          snprintf(buf, sizeof(buf), _("%s was interupted by the signal number 
%i"),
+                   app->app->exe, app->del.exit_signal);
+         cfdata->signal = strdup(buf);
 /* FIXME: Add  sigchld_info stuff
  * app->del.data
  *    siginfo_t
@@ -144,14 +170,28 @@
 {
    int i;
    Evas_Object *obj, *os;
+   char *text;
+   int tlen;
 
    os = e_widget_framelist_add(evas, _(title), 0);
 
-   obj = e_widget_tlist_add(evas, NULL);
+   obj = e_widget_textblock_add(evas);
 
+   tlen = 0;
    for (i = 0; lines[i].line != NULL; i++)
-      e_widget_tlist_append(obj, lines[i].line, NULL, NULL, NULL);
-   e_widget_min_size_set(obj, 200, 200);
+     tlen += strlen(lines[i].line) + 1;
+   text = alloca(tlen + 1);
+   if (text)
+     {
+       text[0] = 0;
+       for (i = 0; lines[i].line != NULL; i++)
+         {
+            strcat(text, lines[i].line);
+            strcat(text, "\n");
+         }
+       e_widget_textblock_plain_set(obj, text);
+     }
+   e_widget_min_size_set(obj, 240, 120);
 
    e_widget_framelist_object_append(os, obj);
 
@@ -177,7 +217,7 @@
       error_length = app->error->size;
    if (error_length)
       {
-         os = _e_app_error_dialog_scrolltext_create(evas, "Error", 
app->error->lines);
+         os = _e_app_error_dialog_scrolltext_create(evas, _("Error Logs"), 
app->error->lines);
          e_widget_list_object_append(o, os, 1, 1, 0.5);
       }
    else
@@ -208,7 +248,7 @@
 
    if (cfdata->exit)
       {
-         of = e_widget_framelist_add(evas, _("Exit code"), 0);
+         of = e_widget_framelist_add(evas, _("Error Information"), 0);
          ob = e_widget_label_add(evas, _(cfdata->exit));
          e_widget_framelist_object_append(of, ob);
          e_widget_list_object_append(o, of, 1, 1, 0.5);
@@ -216,7 +256,7 @@
 
    if (cfdata->signal)
       {
-         of = e_widget_framelist_add(evas, _("Signal"), 0);
+         of = e_widget_framelist_add(evas, _("Error Signal Information"), 0);
          ob = e_widget_label_add(evas, _(cfdata->signal));
          e_widget_framelist_object_append(of, ob);
          e_widget_list_object_append(o, of, 1, 1, 0.5);
@@ -227,13 +267,13 @@
 
    if (read_length)
       {
-         of = _e_app_error_dialog_scrolltext_create(evas, "Output", 
app->read->lines);
+         of = _e_app_error_dialog_scrolltext_create(evas, _("Output Data"), 
app->read->lines);
 /* FIXME: Add stdout "start". */
 /* FIXME: Add stdout "end". */
       }
    else
       {
-         of = e_widget_framelist_add(evas, _("Output"), 0);
+         of = e_widget_framelist_add(evas, _("Output Data"), 0);
          ob = e_widget_label_add(evas, _("There was no output."));
          e_widget_framelist_object_append(of, ob);
       }
@@ -243,13 +283,13 @@
       error_length = app->error->size;
    if (error_length)
       {
-         of = _e_app_error_dialog_scrolltext_create(evas, "Error", 
app->error->lines);
+         of = _e_app_error_dialog_scrolltext_create(evas, _("Error Logs"), 
app->error->lines);
 /* FIXME: Add stderr "start". */
 /* FIXME: Add stderr "end". */
       }
    else
       {
-         of = e_widget_framelist_add(evas, _("Error"), 0);
+         of = e_widget_framelist_add(evas, _("Error Logs"), 0);
          ob = e_widget_label_add(evas, _("There was no error message."));
          e_widget_framelist_object_append(of, ob);
       }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_test.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- e_test.c    25 Jan 2006 09:28:12 -0000      1.45
+++ e_test.c    25 Jan 2006 10:20:02 -0000      1.46
@@ -546,6 +546,7 @@
    e_dialog_title_set(dia, "A Test Dialog");
    
    o = e_widget_textblock_add(dia->win->evas);
+#if 0
    e_widget_textblock_markup_set(o,
                                 "<title>A title</title>"
                                 "This is some text<br>"
@@ -560,6 +561,15 @@
                                 "Smelly fish on a stick<br>"
                                 "Whatever."
                                 );
+#else
+   e_widget_textblock_plain_set(o,
+                               "And here is some plaintext\n"
+                               "with some newlines & other special 
characters\n"
+                               "that should get escaped like < and >.\n"
+                               "\n"
+                               "\tTabs should become 8 spaces too.\n"
+                               );
+#endif   
    evas_object_show(o);
    
    e_dialog_content_set(dia, o, 160, 160);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_textblock.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_widget_textblock.c        25 Jan 2006 09:28:12 -0000      1.1
+++ e_widget_textblock.c        25 Jan 2006 10:20:02 -0000      1.2
@@ -67,10 +67,64 @@
 EAPI void
 e_widget_textblock_plain_set(Evas_Object *obj, const char *text)
 {
-   /* FIXME: parse text escape anything htmlish, - generate new text, set
-    * as markup
+   char *markup, *p, *d;
+   int mlen;
+
+   if (!text)
+     {
+       e_widget_textblock_markup_set(obj, NULL);
+       return;
+     }
+   mlen = strlen(text);
+   /* need to look for these and replace with a new string (on the right)
+    * '\n' -> "<br>"
+    * '\t' -> "        "
+    * '<'  -> "&lt;"
+    * '>'  -> "&gt;"
+    * '&'  -> "&amp;"
     */
-   e_widget_textblock_markup_set(obj, text);
+   for (p = text; *p != 0; p++)
+     {
+       if (*p == '\n') mlen += 4 - 1;
+       else if (*p == '\t') mlen += 8 - 1;
+       else if (*p == '<') mlen += 4 - 1;
+       else if (*p == '>') mlen += 4 - 1;
+       else if (*p == '&') mlen += 5 - 1;
+     }
+   markup = alloca(mlen + 1);
+   if (!markup) return;
+   markup[0] = 0;
+   for (d = markup, p = text; *p != 0; p++, d++)
+     {
+       if (*p == '\n')
+         {
+            strcpy(d, "<br>");
+            d += 4 - 1;
+         }
+       else if (*p == '\t')
+         {
+            strcpy(d, "        ");
+            d += 8 - 1;
+         }
+       else if (*p == '<')
+         {
+            strcpy(d, "&lt;");
+            d += 4 - 1;
+         }
+       else if (*p == '>')
+         {
+            strcpy(d, "&gt;");
+            d += 4 - 1;
+         }
+       else if (*p == '&')
+         {
+            strcpy(d, "&amp;");
+            d += 5 - 1;
+         }
+       else *d = *p;
+     }
+   *d = 0;
+   e_widget_textblock_markup_set(obj, markup);
 }
 
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to