Elm entry: Fixed 'Paste' to only show if there clipboard isn't empty.
authorTom Hacohen <tom@stosb.com>
Mon, 8 Aug 2011 07:51:02 +0000 (07:51 +0000)
committerTom Hacohen <tom@stosb.com>
Mon, 8 Aug 2011 07:51:02 +0000 (07:51 +0000)
SVN revision: 62193

src/lib/elm_cnp_helper.c
src/lib/elm_entry.c
src/lib/elm_widget.h

index ee9511c..cddb58a 100644 (file)
@@ -390,6 +390,16 @@ static Ecore_Event_Handler *handler_status = NULL;
 static const char *text_uri;
 
 Eina_Bool
+elm_selection_selection_has_owner(void)
+{
+#ifdef HAVE_ELEMENTARY_X
+   return !!ecore_x_selection_owner_get(clipboard_atom);
+#else
+   return EINA_FALSE;
+#endif
+}
+
+Eina_Bool
 elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *selbuf)
 {
 #ifdef HAVE_ELEMENTARY_X
index 851c202..03bde8b 100644 (file)
@@ -1078,7 +1078,7 @@ _menu_press(Evas_Object *obj)
                          elm_hoversel_item_add(wd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
                                                _select, obj);
                     }
-                  if (1) // need way to detect if someone has a selection
+                  if (elm_selection_selection_has_owner())
                     {
                        if (wd->editable)
                          elm_hoversel_item_add(wd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
index fb90163..24c7936 100644 (file)
@@ -673,6 +673,7 @@ struct _Elm_Selection_Data
 Eina_Bool            elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *buf);
 Eina_Bool            elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget);
 Eina_Bool            elm_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata);
+Eina_Bool            elm_selection_selection_has_owner(void);
 Eina_Bool            elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_Drop_Cb, void *);
 Eina_Bool            elm_drop_target_del(Evas_Object *widget);
 Eina_Bool            elm_drag_start(Evas_Object *, Elm_Sel_Format, const char *, void (*)(void *,Evas_Object*),void*);