changeset 27647:98478619a22c

Add a m_property_flag_ro function for the default behaviour of a read-only flag.
author reimar
date Wed, 01 Oct 2008 17:05:18 +0000
parents 7327f61a0a4f
children 427fec163870
files m_property.c m_property.h
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/m_property.c	Wed Oct 01 06:47:26 2008 +0000
+++ b/m_property.c	Wed Oct 01 17:05:18 2008 +0000
@@ -245,6 +245,17 @@
     return m_property_int_range(prop,action,arg,var);
 }
 
+int m_property_flag_ro(const m_option_t* prop,int action,
+                       void* arg,int var) {
+    switch(action) {
+    case M_PROPERTY_PRINT:
+        if(!arg) return 0;
+        *(char**)arg = strdup((var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
+        return 1;
+    }
+    return m_property_int_ro(prop,action,arg,var);
+}
+
 int m_property_flag(const m_option_t* prop,int action,
                     void* arg,int* var) {
     switch(action) {
@@ -253,9 +264,7 @@
         *var = *var == prop->min ? prop->max : prop->min;
         return 1;
     case M_PROPERTY_PRINT:
-        if(!arg) return 0;
-        *(char**)arg = strdup((*var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
-        return 1;
+        return m_property_flag_ro(prop, action, arg, *var);
     }
     return m_property_int_range(prop,action,arg,var);
 }
--- a/m_property.h	Wed Oct 01 06:47:26 2008 +0000
+++ b/m_property.h	Wed Oct 01 17:05:18 2008 +0000
@@ -169,6 +169,9 @@
 int m_property_choice(const m_option_t* prop,int action,
                       void* arg,int* var);
 
+int m_property_flag_ro(const m_option_t* prop,int action,
+                    void* arg,int var);
+
 /// Switch betwen min and max.
 int m_property_flag(const m_option_t* prop,int action,
                     void* arg,int* var);