diff options
-rw-r--r-- | include/core/option.h | 11 | ||||
-rw-r--r-- | metadata/screenshot.xml.in | 1 | ||||
-rw-r--r-- | plugins/scale/scale.cpp | 2 | ||||
-rw-r--r-- | src/option.cpp | 103 |
4 files changed, 104 insertions, 13 deletions
diff --git a/include/core/option.h b/include/core/option.h index 0ee362e..b9f47c5 100644 --- a/include/core/option.h +++ b/include/core/option.h @@ -98,6 +98,17 @@ class CompOption { bool operator!= (const Value& val); Value & operator= (const Value &val); + operator bool (); + operator int (); + operator float(); + operator unsigned short * (); + operator CompString (); + operator CompMatch & (); + operator CompAction & (); + operator CompAction * (); + operator Type (); + operator Vector & (); + private: PrivateValue *priv; }; diff --git a/metadata/screenshot.xml.in b/metadata/screenshot.xml.in index d7b528e..eeb0cb5 100644 --- a/metadata/screenshot.xml.in +++ b/metadata/screenshot.xml.in @@ -11,6 +11,7 @@ <option name="directory" type="string"> <_short>Directory</_short> <_long>Put screenshot images in this directory</_long> + <hints>directory;</hints> <default>Desktop</default> </option> <option name="launch_app" type="string"> diff --git a/plugins/scale/scale.cpp b/plugins/scale/scale.cpp index 84d2cf1..2ae42a8 100644 --- a/plugins/scale/scale.cpp +++ b/plugins/scale/scale.cpp @@ -371,7 +371,7 @@ bool PrivateScaleWindow::compareWindowsDistance (ScaleWindow *w1, ScaleWindow *w2) { - return w2->priv->distance < w1->priv->distance; + return w1->priv->distance < w2->priv->distance; } void diff --git a/src/option.cpp b/src/option.cpp index f50b452..009cdd6 100644 --- a/src/option.cpp +++ b/src/option.cpp @@ -186,11 +186,32 @@ CompOption::Value::set (CompOption::Type type, const Vector& l) } +static bool +checkIsAction (CompOption::Type type) +{ + switch (type) { + case CompOption::TypeAction: + case CompOption::TypeKey: + case CompOption::TypeButton: + case CompOption::TypeEdge: + case CompOption::TypeBell: + return true; + default: + break; + } + + return false; +} + + bool CompOption::Value::b () { if (priv->type != CompOption::TypeBool) + { + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a bool"); return false; + } return priv->value.b; } @@ -198,7 +219,10 @@ int CompOption::Value::i () { if (priv->type != CompOption::TypeInt) + { + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an int"); return 0; + } return priv->value.i; } @@ -206,7 +230,10 @@ float CompOption::Value::f () { if (priv->type != CompOption::TypeFloat) + { + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a float"); return 0.0; + } return priv->value.f; } @@ -216,40 +243,103 @@ unsigned short* CompOption::Value::c () { if (priv->type != CompOption::TypeColor) + { + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a color"); return reinterpret_cast<unsigned short *> (&defaultColor); + } return priv->value.c; } CompString CompOption::Value::s () { + if (priv->type != CompOption::TypeString) + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a string"); return priv->string; } CompMatch & CompOption::Value::match () { + if (priv->type != CompOption::TypeMatch) + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a match"); return priv->match; } CompAction & CompOption::Value::action () { + if (!checkIsAction(priv->type)) + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an action"); return priv->action; } CompOption::Type CompOption::Value::listType () { + if (priv->type != CompOption::TypeList) + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list"); return priv->listType; } CompOption::Value::Vector & CompOption::Value::list () { + if (priv->type != CompOption::TypeList) + compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list"); return priv->list; } +CompOption::Value::operator bool () +{ + return b(); +} + +CompOption::Value::operator int () +{ + return i(); +} + +CompOption::Value::operator float() +{ + return f(); +} + +CompOption::Value::operator unsigned short * () +{ + return c(); +} + +CompOption::Value::operator CompString () +{ + return s(); +} + +CompOption::Value::operator CompMatch & () +{ + return match(); +} + +CompOption::Value::operator CompAction & () +{ + return action(); +} + +CompOption::Value::operator CompAction * () +{ + return &action(); +} + +CompOption::Value::operator Type () +{ + return listType(); +} + +CompOption::Value::operator Vector & () +{ + return list(); +} + bool CompOption::Value::operator== (const CompOption::Value &val) { @@ -664,18 +754,7 @@ CompOption::set (CompOption::Value &val) bool CompOption::isAction () { - switch (priv->type) { - case CompOption::TypeAction: - case CompOption::TypeKey: - case CompOption::TypeButton: - case CompOption::TypeEdge: - case CompOption::TypeBell: - return true; - default: - break; - } - - return false; + return checkIsAction (priv->type); } CompOption & |