From 0aaff23c4b0ef5a1a8b21489fe00f1ac94cfc1f6 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 18 Nov 2008 12:14:35 +0100 Subject: esubtitle.cpp: initialize uninitialized varible... this fixes not working or rarely working dvb subtitles --- lib/gui/esubtitle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/gui') diff --git a/lib/gui/esubtitle.cpp b/lib/gui/esubtitle.cpp index c837afc6..085a749a 100644 --- a/lib/gui/esubtitle.cpp +++ b/lib/gui/esubtitle.cpp @@ -16,6 +16,7 @@ eSubtitleWidget::eSubtitleWidget(eWidget *parent) setBackgroundColor(gRGB(0,0,0,255)); m_page_ok = 0; m_dvb_page_ok = 0; + m_pango_page_ok = 0; CONNECT(m_hide_subtitles_timer->timeout, eSubtitleWidget::clearPage); } -- cgit v1.2.3 From 371e23c22dcec461ee3fbc8c989859cd08717b3d Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 25 Nov 2008 00:34:29 +0100 Subject: fix some refcounting bugs --- lib/base/nconfig.cpp | 1 + lib/dvb/dvb.cpp | 6 ++++-- lib/dvb/epgcache.cpp | 2 +- lib/gui/elistboxcontent.cpp | 17 +++++++++++------ 4 files changed, 17 insertions(+), 9 deletions(-) (limited to 'lib/gui') diff --git a/lib/base/nconfig.cpp b/lib/base/nconfig.cpp index 31b0a36f..106558ac 100644 --- a/lib/base/nconfig.cpp +++ b/lib/base/nconfig.cpp @@ -25,6 +25,7 @@ RESULT ePythonConfigQuery::getConfigValue(const char *key, std::string &value) if (PyString_Check(pRet)) { value.assign(PyString_AS_STRING(pRet)); + Py_DECREF(pRet); return 0; } Py_DECREF(pRet); diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 7e9a39c6..eac4554d 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -1502,7 +1502,7 @@ RESULT eDVBChannel::setCIRouting(const eDVBCIRouting &routing) void eDVBChannel::SDTready(int result) { - ePyObject args = PyTuple_New(2); + ePyObject args = PyTuple_New(2), ret; bool ok=false; if (!result) { @@ -1521,7 +1521,9 @@ void eDVBChannel::SDTready(int result) Py_INCREF(Py_None); Py_INCREF(Py_None); } - PyObject_CallObject(m_tsid_onid_callback, args); + ret = PyObject_CallObject(m_tsid_onid_callback, args); + if (ret) + Py_DECREF(ret); Py_DECREF(args); Py_DECREF(m_tsid_onid_callback); m_tsid_onid_callback = ePyObject(); diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index 0bb6e25b..222cba32 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -1672,7 +1672,7 @@ int handleEvent(eServiceEvent *ptr, ePyObject dest_list, const char* argstring, { fillTuple(convertFuncArgs, argstring, argcount, service, ptr, nowTime, service_name); ePyObject result = PyObject_CallObject(convertFunc, convertFuncArgs); - if (result) + if (!result) { if (service_name) Py_DECREF(service_name); diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index beb12044..69f72a41 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -467,7 +467,8 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, /* type is borrowed */ } else eWarning("eListboxPythonConfigContent: second value of tuple is not a tuple."); - /* value is borrowed */ + if (value) + Py_DECREF(value); } if (selected && (!local_style || !local_style->m_selection)) @@ -622,7 +623,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c painter.clip(itemregion); clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip); - ePyObject items; + ePyObject items, buildfunc_ret; if (m_list && cursorValid()) { @@ -638,7 +639,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c if (PyCallable_Check(m_buildFunc)) // when we have a buildFunc then call it { if (PyTuple_Check(items)) - items = PyObject_CallObject(m_buildFunc, items); + buildfunc_ret = items = PyObject_CallObject(m_buildFunc, items); else eDebug("items is no tuple"); } @@ -983,8 +984,8 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry); error_out: - if (m_buildFunc && PyCallable_Check(m_buildFunc) && items) - Py_DECREF(items); + if (buildfunc_ret) + Py_DECREF(buildfunc_ret); painter.clippop(); } @@ -1015,7 +1016,11 @@ int eListboxPythonMultiContent::currentCursorSelectable() { ePyObject ret = PyObject_CallObject(m_selectableFunc, args); if (ret) - return ret == Py_True; + { + bool retval = ret == Py_True; + Py_DECREF(ret); + return ret; + } eDebug("call m_selectableFunc failed!!! assume not callable"); } else -- cgit v1.2.3 From 5d9ab813e9468a24cc90400e9fb5b0567ec6b12a Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 16 Jan 2009 23:58:55 +0100 Subject: add templated colors --- lib/gui/elistboxcontent.cpp | 71 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'lib/gui') diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index 69f72a41..f1eb4bf7 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -608,6 +608,30 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l } } +static ePyObject lookupColor(ePyObject color, ePyObject data) +{ + if (color == Py_None) + return ePyObject(); + + if ((!color) && (!data)) + return color; + + unsigned int icolor = PyInt_AsLong(color); + + /* check if we have the "magic" template color */ + if ((icolor & 0xFF000000) == 0xFF000000) + { + int index = icolor & 0xFFFFFF; + eDebug("[eListboxPythonMultiContent] template color index: %d", index); + return PyTuple_GetItem(data, index); + } + + if (color == Py_None) + return ePyObject(); + + return color; +} + void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected) { gRegion itemregion(eRect(offset, m_itemsize)); @@ -732,29 +756,17 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c } if (size > 8) - { - pforeColor = PyTuple_GET_ITEM(item, 8); - if (pforeColor == Py_None) - pforeColor=ePyObject(); - } + pforeColor = lookupColor(PyTuple_GET_ITEM(item, 8), data); + if (size > 9) - { - pforeColorSelected = PyTuple_GET_ITEM(item, 9); - if (pforeColorSelected == Py_None) - pforeColorSelected=ePyObject(); - } + pforeColorSelected = lookupColor(PyTuple_GET_ITEM(item, 9), data); + if (size > 10) - { - pbackColor = PyTuple_GET_ITEM(item, 10); - if (pbackColor == Py_None) - pbackColor=ePyObject(); - } + pbackColor = lookupColor(PyTuple_GET_ITEM(item, 10), data); + if (size > 11) - { - pbackColorSelected = PyTuple_GET_ITEM(item, 11); - if (pbackColorSelected == Py_None) - pbackColorSelected=ePyObject(); - } + pbackColorSelected = lookupColor(PyTuple_GET_ITEM(item, 11), data); + if (size > 12) { pborderWidth = PyTuple_GET_ITEM(item, 12); @@ -762,11 +774,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c pborderWidth=ePyObject(); } if (size > 13) - { - pborderColor = PyTuple_GET_ITEM(item, 13); - if (pborderColor == Py_None) - pborderColor=ePyObject(); - } + pborderColor = lookupColor(PyTuple_GET_ITEM(item, 13), data); if (PyInt_Check(pstring) && data) /* if the string is in fact a number, it refers to the 'data' list. */ pstring = PyTuple_GetItem(data, PyInt_AsLong(pstring)); @@ -949,17 +957,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c } if (size > 6) - { - pbackColor = PyTuple_GET_ITEM(item, 6); - if (pbackColor == Py_None) - pbackColor=ePyObject(); - } + pbackColor = lookupColor(PyTuple_GET_ITEM(item, 6), data); + if (size > 7) - { - pbackColorSelected = PyTuple_GET_ITEM(item, 7); - if (pbackColorSelected == Py_None) - pbackColorSelected=ePyObject(); - } + pbackColorSelected = lookupColor(PyTuple_GET_ITEM(item, 7), data); eRect rect(x, y, width, height); painter.clip(rect); -- cgit v1.2.3 From 89c625ba57e6b56052c21832722e545197cd9fa8 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sun, 18 Jan 2009 22:43:08 +0100 Subject: colors should be unsigned long --- lib/gui/elistboxcontent.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/gui') diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index f1eb4bf7..44973af7 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -523,7 +523,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l style.setStyle(painter, eWindowStyle::styleListboxNormal); if (pbackColor) { - int color = PyInt_AsLong(pbackColor); + unsigned int color = PyInt_AsUnsignedLongMask(pbackColor); painter.setBackgroundColor(gRGB(color)); } // transparent background? // if we have a local background color set, use that. @@ -543,7 +543,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l style.setStyle(painter, eWindowStyle::styleListboxSelected); if (pbackColorSelected) { - int color = PyInt_AsLong(pbackColorSelected); + unsigned int color = PyInt_AsUnsignedLongMask(pbackColorSelected); painter.setBackgroundColor(gRGB(color)); } else if (local_style && local_style->m_background_color_selected_set) @@ -560,7 +560,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l style.setStyle(painter, eWindowStyle::styleListboxSelected); if (pbackColorSelected) { - int color = PyInt_AsLong(pbackColorSelected); + unsigned int color = PyInt_AsUnsignedLongMask(pbackColorSelected); painter.setBackgroundColor(gRGB(color)); } else if (local_style && local_style->m_background_color_selected_set) @@ -572,7 +572,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l style.setStyle(painter, eWindowStyle::styleListboxNormal); if (pbackColor) { - int color = PyInt_AsLong(pbackColor); + unsigned int color = PyInt_AsUnsignedLongMask(pbackColor); painter.setBackgroundColor(gRGB(color)); }/* if we have a local background color set, use that. */ else if (local_style && local_style->m_background_color_set) @@ -588,7 +588,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l { if (pforeColorSelected) { - int color = PyInt_AsLong(pforeColorSelected); + unsigned int color = PyInt_AsUnsignedLongMask(pforeColorSelected); painter.setForegroundColor(gRGB(color)); } /* if we have a local foreground color set, use that. */ @@ -599,7 +599,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l { if (pforeColor) { - int color = PyInt_AsLong(pforeColor); + unsigned int color = PyInt_AsUnsignedLongMask(pforeColor); painter.setForegroundColor(gRGB(color)); } /* if we have a local foreground color set, use that. */ @@ -616,7 +616,7 @@ static ePyObject lookupColor(ePyObject color, ePyObject data) if ((!color) && (!data)) return color; - unsigned int icolor = PyInt_AsLong(color); + unsigned int icolor = PyInt_AsUnsignedLongMask(color); /* check if we have the "magic" template color */ if ((icolor & 0xFF000000) == 0xFF000000) @@ -813,7 +813,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c painter.clip(rect); if (pborderColor) { - int color = PyInt_AsLong(pborderColor); + unsigned int color = PyInt_AsUnsignedLongMask(pborderColor); painter.setForegroundColor(gRGB(color)); } -- cgit v1.2.3 From 4621e2ba14ebc9c955e3bf669a5c8799f65f46e1 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 19 Jan 2009 12:55:27 +0100 Subject: make slider orientation configurable into 4 directions --- lib/gui/eslider.cpp | 13 +++++++++---- lib/gui/eslider.h | 4 ++-- skin.py | 10 +++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'lib/gui') diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index dd2aac9e..c8b467c9 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -70,10 +70,14 @@ int eSlider::event(int event, void *data, void *data2) if (m_min < m_max) { - num_pix = pixsize * (m_value - m_start) / (m_max - m_min); - start_pix = pixsize * m_start / (m_max - m_min); + int val_range = m_max - m_min; + num_pix = (pixsize * (m_value - m_start) + val_range - 1) / val_range; /* properly round up */ + start_pix = (pixsize * m_start + val_range - 1) / val_range; + + if (m_orientation_swapped) + start_pix = pixsize - num_pix - start_pix; } - + if (start_pix < 0) { num_pix += start_pix; @@ -113,9 +117,10 @@ void eSlider::setStartEnd(int start, int end) event(evtChangedSlider); } -void eSlider::setOrientation(int orientation) +void eSlider::setOrientation(int orientation, int swapped) { m_orientation = orientation; + m_orientation_swapped = swapped; event(evtChangedSlider); } diff --git a/lib/gui/eslider.h b/lib/gui/eslider.h index c5440726..9a3e8395 100644 --- a/lib/gui/eslider.h +++ b/lib/gui/eslider.h @@ -11,7 +11,7 @@ public: void setStartEnd(int start, int end); void setRange(int min, int max); enum { orHorizontal, orVertical }; - void setOrientation(int orientation); + void setOrientation(int orientation, int swapped = 0); void setBorderWidth(int pixel); void setBorderColor(const gRGB &color); void setPixmap(gPixmap *pixmap); @@ -24,7 +24,7 @@ private: evtChangedSlider = evtUserWidget }; bool m_have_border_color; - int m_min, m_max, m_value, m_start, m_orientation, m_border_width; + int m_min, m_max, m_value, m_start, m_orientation, m_orientation_swapped, m_border_width; ePtr m_pixmap; gRegion m_currently_filled; diff --git a/skin.py b/skin.py index 97954715..dd107905 100644 --- a/skin.py +++ b/skin.py @@ -145,9 +145,13 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1) }[value]) elif attrib == "orientation": # used by eSlider try: - guiObject.setOrientation( - { "orVertical": guiObject.orVertical, - "orHorizontal": guiObject.orHorizontal + guiObject.setOrientation(* + { "orVertical": (guiObject.orVertical, False), + "orTopToBottom": (guiObject.olVertical, False), + "orBottomToTop": (guiObject.orVertical, True), + "orHorizontal": (guiObject.orHorizontal, False), + "orLeftToRight": (guiObject.orHorizontal, False), + "orRightToRight": (guiObject.orHorizontal, True), }[value]) except KeyError: print "oprientation must be either orVertical or orHorizontal!" -- cgit v1.2.3 From 65d256dab9e29d50ab02d1d5bd6319ab8a50dc82 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 19 Jan 2009 13:42:38 +0100 Subject: round up when calculating scrollbar width --- lib/gui/elistbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/gui') diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index 5b05c028..e8a0dada 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -279,7 +279,7 @@ void eListbox::updateScrollBar() if ((pages*m_items_per_page) < entries) ++pages; int start=(m_top*100)/(pages*m_items_per_page); - int vis=(m_items_per_page*100)/(pages*m_items_per_page); + int vis=(m_items_per_page*100+pages*m_items_per_page-1)/(pages*m_items_per_page); if (vis < 3) vis=3; m_scrollbar->setStartEnd(start,start+vis); -- cgit v1.2.3 From b27feca502bf6d074800a5c49583f88bb588de05 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 19 Jan 2009 13:49:58 +0100 Subject: default to non-swapped orientation --- lib/gui/eslider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/gui') diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index c8b467c9..19097ad4 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -1,7 +1,7 @@ #include eSlider::eSlider(eWidget *parent) - :eWidget(parent), m_have_border_color(false), m_start(0), m_orientation(orHorizontal), m_border_width(0) + :eWidget(parent), m_have_border_color(false), m_start(0), m_orientation(orHorizontal), m_orientation_swapped(0), m_border_width(0) { } -- cgit v1.2.3