diff --git a/AUTHORS b/AUTHORS index 818d7af..8bb3fdf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,2 @@ Gustavo Sverzut Barbieri +Bruno Dilly 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 { Evas_Object *display_pos; Evas_Object *cmdbox; Evas_Object *help_popup; + Evas_Object *error_popup; Ecore_Idler *del_help_popup_idler; struct { Evas_Object *frame; @@ -1434,6 +1435,47 @@ zone_zoom_pre_setup(Zone *zone) zone->zoom.ready = EINA_FALSE; } +static void +_error_popup_hide_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) +{ + Zone *zone = data; + evas_object_del(zone->error_popup); + zone->error_popup = NULL; +} + +static void +show_error_popup(Zone *zone, const char *str) +{ + Evas_Object *popup, *msg; + + if (zone->error_popup) return; + + popup = elm_popup_add(zone->win); + elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_MIXED); + + elm_object_part_text_set(popup, "title,text", "ERuler"); + + msg = elm_entry_add(popup); + elm_entry_editable_set(msg, EINA_FALSE); + +#if (ELM_VERSION_MAJOR >= 1) && (ELM_VERSION_MINOR >= 8) + elm_scroller_policy_set(msg, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_AUTO); +#else + elm_entry_scrollbar_policy_set(msg, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_AUTO); +#endif + + elm_object_text_set(msg, str); + elm_object_content_set(popup, msg); + + elm_popup_timeout_set(popup, 3); + evas_object_smart_callback_add(popup, "timeout", _error_popup_hide_cb, zone); + + evas_object_show(popup); + zone->error_popup = popup; +} + static void _popup_dismiss_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) { @@ -1560,11 +1602,15 @@ _create_ruler_cmdbox_activated(void *data, Evas_Object *o, void *event_info EINA if (sscanf(str, "%d %d %d %d", &x, &y, &w, &h) != 4) { + show_error_popup(zone, + "Error: Invalid creation format. Expected 'x y w h'"); ERR("Invalid creation format. Expected 'x y w h', got '%s'", str); goto end; } if (w < 1 || h < 1) { + show_error_popup(zone, + "Error: Invalid size. w and h must be positive."); ERR("Invalid size: %dx%d", w, h); goto end; }