listboxcontent: fix alignment on empty label
[enigma2.git] / lib / gui / elistboxcontent.cpp
index d72b21bcd05a3a1e2ea1930245a6893f4a3c62e7..5421f2529555720b1a7f744111a4cd4894fdd579 100644 (file)
@@ -260,6 +260,7 @@ eListboxPythonStringContent::eListboxPythonStringContent()
 
 eListboxPythonStringContent::~eListboxPythonStringContent()
 {
+       Py_XDECREF(m_list);
 }
 
 void eListboxPythonStringContent::cursorHome()
@@ -423,12 +424,16 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
                                /* handle left part. get item from tuple, convert to string, display. */
                                
                        text = PyTuple_GET_ITEM(item, 0);
-//                     text = PyObject_Str(text); /* creates a new object - old object was borrowed! */
+                       text = PyObject_Str(text); /* creates a new object - old object was borrowed! */
                        const char *string = (text && PyString_Check(text)) ? PyString_AsString(text) : "<not-a-string>";
                        eSize item_left = eSize(m_seperation, m_itemsize.height());
                        eSize item_right = eSize(m_itemsize.width() - m_seperation, m_itemsize.height());
                        painter.renderText(eRect(offset, item_left), string, gPainter::RT_HALIGN_LEFT);
-//                     Py_XDECREF(text);
+                       Py_XDECREF(text);
+                       
+                               /* when we have no label, align value to the left. (FIXME: 
+                                  don't we want to specifiy this individually?) */
+                       int value_alignment_left = !*string;
                        
                                /* now, handle the value. get 2nd part from tuple*/
                        value = PyTuple_GET_ITEM(item, 1);
@@ -461,7 +466,7 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
                                                PyObject *pvalue = PyTuple_GET_ITEM(value, 1);
                                                const char *value = (pvalue && PyString_Check(pvalue)) ? PyString_AsString(pvalue) : "<not-a-string>";
                                                painter.setFont(fnt2);
-                                               painter.renderText(eRect(offset + eSize(m_seperation, 0), item_right), value, gPainter::RT_HALIGN_RIGHT);
+                                               painter.renderText(eRect(offset + eSize(m_seperation, 0), item_right), value, value_alignment_left ? gPainter::RT_HALIGN_LEFT : gPainter::RT_HALIGN_RIGHT);
 
                                                        /* pvalue is borrowed */
                                        } else if (!strcmp(atype, "slider"))
@@ -490,7 +495,7 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
                                                ePtr<eTextPara> para = new eTextPara(eRect(offset + eSize(m_seperation, 0), item_right));
                                                para->setFont(fnt2);
                                                para->renderString(text, 0);
-                                               para->realign(eTextPara::dirRight);
+                                               para->realign(value_alignment_left ? eTextPara::dirLeft : eTextPara::dirRight);
                                                int glyphs = para->size();
                                                
                                                PyObject *plist = 0;