summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-10-20 12:12:38 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-10-20 12:15:31 -0200
commit7175c00bc24affd512894899d5054195e84efe37 (patch)
tree1f55066dfaf7297d994895223a0d8ef124c118b7
parent37839e70cf011dce98568a1e350eb5c32acb5369 (diff)
Show errors on popup
Instead of only printing errors to console
-rw-r--r--AUTHORS1
-rw-r--r--src/bin/main.c46
2 files changed, 47 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 818d7af..8bb3fdf 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1,2 @@
1Gustavo Sverzut Barbieri <barbieri@gmail.com> 1Gustavo Sverzut Barbieri <barbieri@gmail.com>
2Bruno Dilly <bdilly@profusion.mobi>
diff --git a/src/bin/main.c b/src/bin/main.c
index 2aa7fcc..7df9f04 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -31,6 +31,7 @@ struct _Zone {
31 Evas_Object *display_pos; 31 Evas_Object *display_pos;
32 Evas_Object *cmdbox; 32 Evas_Object *cmdbox;
33 Evas_Object *help_popup; 33 Evas_Object *help_popup;
34 Evas_Object *error_popup;
34 Ecore_Idler *del_help_popup_idler; 35 Ecore_Idler *del_help_popup_idler;
35 struct { 36 struct {
36 Evas_Object *frame; 37 Evas_Object *frame;
@@ -1435,6 +1436,47 @@ zone_zoom_pre_setup(Zone *zone)
1435} 1436}
1436 1437
1437static void 1438static void
1439_error_popup_hide_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED)
1440{
1441 Zone *zone = data;
1442 evas_object_del(zone->error_popup);
1443 zone->error_popup = NULL;
1444}
1445
1446static void
1447show_error_popup(Zone *zone, const char *str)
1448{
1449 Evas_Object *popup, *msg;
1450
1451 if (zone->error_popup) return;
1452
1453 popup = elm_popup_add(zone->win);
1454 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_MIXED);
1455
1456 elm_object_part_text_set(popup, "title,text", "ERuler");
1457
1458 msg = elm_entry_add(popup);
1459 elm_entry_editable_set(msg, EINA_FALSE);
1460
1461#if (ELM_VERSION_MAJOR >= 1) && (ELM_VERSION_MINOR >= 8)
1462 elm_scroller_policy_set(msg, ELM_SCROLLER_POLICY_OFF,
1463 ELM_SCROLLER_POLICY_AUTO);
1464#else
1465 elm_entry_scrollbar_policy_set(msg, ELM_SCROLLER_POLICY_OFF,
1466 ELM_SCROLLER_POLICY_AUTO);
1467#endif
1468
1469 elm_object_text_set(msg, str);
1470 elm_object_content_set(popup, msg);
1471
1472 elm_popup_timeout_set(popup, 3);
1473 evas_object_smart_callback_add(popup, "timeout", _error_popup_hide_cb, zone);
1474
1475 evas_object_show(popup);
1476 zone->error_popup = popup;
1477}
1478
1479static void
1438_popup_dismiss_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) 1480_popup_dismiss_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED)
1439{ 1481{
1440 Zone *zone = data; 1482 Zone *zone = data;
@@ -1560,11 +1602,15 @@ _create_ruler_cmdbox_activated(void *data, Evas_Object *o, void *event_info EINA
1560 1602
1561 if (sscanf(str, "%d %d %d %d", &x, &y, &w, &h) != 4) 1603 if (sscanf(str, "%d %d %d %d", &x, &y, &w, &h) != 4)
1562 { 1604 {
1605 show_error_popup(zone,
1606 "Error: Invalid creation format. Expected 'x y w h'");
1563 ERR("Invalid creation format. Expected 'x y w h', got '%s'", str); 1607 ERR("Invalid creation format. Expected 'x y w h', got '%s'", str);
1564 goto end; 1608 goto end;
1565 } 1609 }
1566 if (w < 1 || h < 1) 1610 if (w < 1 || h < 1)
1567 { 1611 {
1612 show_error_popup(zone,
1613 "Error: Invalid size. w and h must be positive.");
1568 ERR("Invalid size: %dx%d", w, h); 1614 ERR("Invalid size: %dx%d", w, h);
1569 goto end; 1615 goto end;
1570 } 1616 }