thanks to marco - disable cut/paste if not editable, add ability to toally
authorCarsten Haitzler <raster@rasterman.com>
Sun, 11 Oct 2009 05:48:24 +0000 (05:48 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Sun, 11 Oct 2009 05:48:24 +0000 (05:48 +0000)
disable the menu

SVN revision: 43011

src/lib/Elementary.h.in
src/lib/elm_entry.c

index 51cf0bacabf341e031e18f65e71e0abb0942b017..cf860eeb221407d6b3f2805e4be207f90d00de6a 100644 (file)
@@ -479,6 +479,8 @@ extern "C" {
    EAPI void         elm_entry_select_all(Evas_Object *obj);
    EAPI void         elm_entry_context_menu_clear(Evas_Object *obj);
    EAPI void         elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data);
+   EAPI void         elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled);
+   EAPI Eina_Bool    elm_entry_context_menu_disabled_get(Evas_Object *obj);
    EAPI char        *elm_entry_markup_to_utf8(const char *s);
    EAPI char        *elm_entry_utf8_to_markup(const char *s);
 
index 6638d90f0b6fadd0ae8d2cd8a4af278c42cf2c8a..a482c7536f647207d71a1e5ea068ef1b8302af2a 100644 (file)
@@ -27,6 +27,7 @@ struct _Widget_Data
    Eina_Bool selmode : 1;
    Eina_Bool deferred_cur : 1;
    Eina_Bool disabled : 1;
+   Eina_Bool context_menu : 1;
 };
 
 struct _Elm_Entry_Context_Menu_Item
@@ -352,14 +353,16 @@ _long_press(void *data)
      {
        elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE, 
                               _select, data);
-       elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE, 
-                              _paste, data);
+        if (wd->editable)
+          elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE, 
+                                _paste, data);
      }
    else
      {
        elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE, 
                               _copy, data);
-       elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE, 
+        if (wd->editable)
+          elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE, 
                               _cut, data);
        elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE, 
                               _cancel, data);
@@ -1022,9 +1025,10 @@ elm_entry_add(Evas_Object *parent)
    elm_widget_disable_hook_set(obj, _disable_hook);
    elm_widget_can_focus_set(obj, 1);
 
-   wd->linewrap = EINA_TRUE;
-   wd->editable = EINA_TRUE;
-   wd->disabled = EINA_FALSE;
+   wd->linewrap     = EINA_TRUE;
+   wd->editable     = EINA_TRUE;
+   wd->disabled     = EINA_FALSE;
+   wd->context_menu = EINA_TRUE;
 
    wd->ent = edje_object_add(e);
    evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
@@ -1264,6 +1268,34 @@ elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char
    it->data = (void *)data;
 }
 
+EAPI void
+elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->context_menu == !disabled) return;
+   wd->context_menu = !disabled;
+   
+   if (wd->context_menu)
+     {
+        evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, obj);
+        evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP, _mouse_up, obj);
+     }
+   else
+     {
+        evas_object_event_callback_del(wd->ent, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down);
+        evas_object_event_callback_del(wd->ent, EVAS_CALLBACK_MOUSE_UP, _mouse_up);
+     }
+}
+
+EAPI Eina_Bool
+elm_entry_context_menu_disabled_get(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return !wd->context_menu;
+}
+
 EAPI char *
 elm_entry_markup_to_utf8(const char *s)
 {