[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] [PATCH] Read-Only e_widget_entry and Stuff



Hi all,

This is a small patch to make the widgets on the window properties menu
reado-only. It's a bit funny being able to type into a widget that has
no effect. In doing so, I added a function to e_widget_entry to be able
to access the property of e_entry that enables and disables. This also
uncovered a bug where even if a window was disabled, you could still
actualled type into it.

Comments et al, you know where to find me.

metrics
Index: e_entry.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_entry.c,v
retrieving revision 1.32
diff -u -r1.32 e_entry.c
--- e_entry.c	21 Sep 2006 19:53:38 -0000	1.32
+++ e_entry.c	20 Oct 2006 16:17:08 -0000
@@ -594,7 +594,7 @@
           }
      }
    /* Otherwise, we insert the corresponding character */
-   else if ((event->string) &&
+   else if ((event->string) && ((sd->enabled)) &&
           ((strlen(event->string) != 1) || (event->string[0] >= 0x20)))
      {
         if (selecting)
Index: e_int_border_prop.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_int_border_prop.c,v
retrieving revision 1.5
diff -u -r1.5 e_int_border_prop.c
--- e_int_border_prop.c	11 Oct 2006 21:20:11 -0000	1.5
+++ e_int_border_prop.c	20 Oct 2006 16:17:16 -0000
@@ -300,6 +300,7 @@
       e_widget_frametable_object_append(of, ob, x, y, 1, 1,    1, 1, 1, 1); \
       ob = e_widget_entry_add(evas, &(cfdata->val)); \
       if (!cfdata->val) e_widget_disabled_set(ob, 1); \
+      e_widget_entry_readonly_set(ob, 1); \
       e_widget_min_size_get(ob, &mw, &mh); \
       e_widget_min_size_set(ob, 160, mh); \
       e_widget_frametable_object_append(of, ob, x + 1, y, 1, 1,    1, 1, 1, 1); \
@@ -309,6 +310,7 @@
       ob = e_widget_label_add(evas, label); \
       e_widget_frametable_object_append(of, ob, x, y, 1, 1,    1, 1, 1, 1); \
       ob = e_widget_check_add(evas, "", &(cfdata->val)); \
+      e_widget_disabled_set(ob, 1); \
       e_widget_frametable_object_append(of, ob, x + 1, y, 1, 1,    1, 1, 1, 1); \
    }
    
Index: e_widget_entry.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_widget_entry.c,v
retrieving revision 1.17
diff -u -r1.17 e_widget_entry.c
--- e_widget_entry.c	23 Aug 2006 10:51:35 -0000	1.17
+++ e_widget_entry.c	20 Oct 2006 16:17:28 -0000
@@ -132,6 +132,27 @@
 }
 
 /**
+ * Sets whether or not the entry widget is user-editable. This still
+ * allows copying and selecting, just no inserting or deleting of text.
+ *
+ * @param entry an entry widget
+ * @param readonly 1 to enable read-only mode, 0 to turn it off
+ */
+EAPI void
+e_widget_entry_readonly_set(Evas_Object *entry, int readonly_mode)
+{
+   E_Widget_Data *wd;
+
+   if (!(entry) || (!(wd = e_widget_data_get(entry))))
+      return;
+
+   if (readonly_mode)
+     e_entry_disable(wd->o_entry);
+   else
+     e_entry_enable(wd->o_entry);
+}
+
+/**
  * Gets the editable object of the entry widget. It will allow you to have
  * better control on the text, the cursor or the selection of the entry with
  * the e_editable_*() functions.
Index: e_widget_entry.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_widget_entry.h,v
retrieving revision 1.6
diff -u -r1.6 e_widget_entry.h
--- e_widget_entry.h	12 Aug 2006 12:21:32 -0000	1.6
+++ e_widget_entry.h	20 Oct 2006 16:17:28 -0000
@@ -11,6 +11,7 @@
 EAPI const char  *e_widget_entry_text_get            (Evas_Object *entry);
 EAPI void         e_widget_entry_clear               (Evas_Object *entry);
 EAPI void         e_widget_entry_password_set        (Evas_Object *entry, int password_mode);
+EAPI void	   e_widget_entry_readonly_set        (Evas_Object *entry, int readonly_mode);
 EAPI Evas_Object *e_widget_entry_editable_object_get (Evas_Object *entry);
 
 #endif