only freeze/thaw if we have to
because gtk will relayout and things jump around confusingly and unnecessarily Change-Id: I817e803f8ad7e523e5855326fc097f8798ddb679 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88526 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -851,6 +851,7 @@ SbTreeListBox::SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Win
|
|||||||
: m_xControl(std::move(xControl))
|
: m_xControl(std::move(xControl))
|
||||||
, m_xIter(m_xControl->make_iterator())
|
, m_xIter(m_xControl->make_iterator())
|
||||||
, m_pTopLevel(pTopLevel)
|
, m_pTopLevel(pTopLevel)
|
||||||
|
, m_bFreezeOnFirstAddRemove(false)
|
||||||
, m_aNotifier(*this)
|
, m_aNotifier(*this)
|
||||||
{
|
{
|
||||||
m_xControl->connect_row_activated(LINK(this, SbTreeListBox, OpenCurrentHdl));
|
m_xControl->connect_row_activated(LINK(this, SbTreeListBox, OpenCurrentHdl));
|
||||||
@@ -880,7 +881,6 @@ void SbTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation
|
|||||||
// can be called multiple times for updating!
|
// can be called multiple times for updating!
|
||||||
|
|
||||||
// actually test if basic's in the tree already?!
|
// actually test if basic's in the tree already?!
|
||||||
m_xControl->freeze();
|
|
||||||
// level 1: BasicManager (application, document, ...)
|
// level 1: BasicManager (application, document, ...)
|
||||||
bool bDocumentRootEntry = FindRootEntry(rDocument, eLocation, *m_xIter);
|
bool bDocumentRootEntry = FindRootEntry(rDocument, eLocation, *m_xIter);
|
||||||
if (bDocumentRootEntry && m_xControl->get_row_expanded(*m_xIter))
|
if (bDocumentRootEntry && m_xControl->get_row_expanded(*m_xIter))
|
||||||
@@ -891,7 +891,6 @@ void SbTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation
|
|||||||
OUString aImage(GetRootEntryBitmaps(rDocument));
|
OUString aImage(GetRootEntryBitmaps(rDocument));
|
||||||
AddEntry(aRootName, aImage, nullptr, true, std::make_unique<DocumentEntry>(rDocument, eLocation));
|
AddEntry(aRootName, aImage, nullptr, true, std::make_unique<DocumentEntry>(rDocument, eLocation));
|
||||||
}
|
}
|
||||||
m_xControl->thaw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const ScriptDocument& rDocument, LibraryLocation eLocation)
|
void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const ScriptDocument& rDocument, LibraryLocation eLocation)
|
||||||
@@ -1259,6 +1258,12 @@ void SbTreeListBox::UpdateEntries()
|
|||||||
// Removes the entry from the tree.
|
// Removes the entry from the tree.
|
||||||
void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
|
void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
|
||||||
{
|
{
|
||||||
|
if (m_bFreezeOnFirstAddRemove)
|
||||||
|
{
|
||||||
|
m_xControl->freeze();
|
||||||
|
m_bFreezeOnFirstAddRemove = false;
|
||||||
|
}
|
||||||
|
|
||||||
// removing the associated user data
|
// removing the associated user data
|
||||||
Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
|
Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
|
||||||
delete pBasicEntry;
|
delete pBasicEntry;
|
||||||
@@ -1329,6 +1334,11 @@ void SbTreeListBox::AddEntry(
|
|||||||
std::unique_ptr<Entry>&& rUserData,
|
std::unique_ptr<Entry>&& rUserData,
|
||||||
weld::TreeIter* pRet)
|
weld::TreeIter* pRet)
|
||||||
{
|
{
|
||||||
|
if (m_bFreezeOnFirstAddRemove)
|
||||||
|
{
|
||||||
|
m_xControl->freeze();
|
||||||
|
m_bFreezeOnFirstAddRemove= false;
|
||||||
|
}
|
||||||
OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
|
OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
|
||||||
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand, pRet);
|
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand, pRet);
|
||||||
}
|
}
|
||||||
|
@@ -246,6 +246,10 @@ void TreeListBox::ScanAllEntries()
|
|||||||
|
|
||||||
void SbTreeListBox::ScanAllEntries()
|
void SbTreeListBox::ScanAllEntries()
|
||||||
{
|
{
|
||||||
|
// instead of always freezing, freeze on the first add/remove, which keeps gtk
|
||||||
|
// from relayouting the tree if its not necessary
|
||||||
|
m_bFreezeOnFirstAddRemove = true;
|
||||||
|
|
||||||
ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
|
ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
|
||||||
ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
|
ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
|
||||||
|
|
||||||
@@ -255,6 +259,11 @@ void SbTreeListBox::ScanAllEntries()
|
|||||||
if ( doc.isAlive() )
|
if ( doc.isAlive() )
|
||||||
ScanEntry(doc, LIBRARY_LOCATION_DOCUMENT);
|
ScanEntry(doc, LIBRARY_LOCATION_DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_bFreezeOnFirstAddRemove)
|
||||||
|
m_xControl->thaw(); // m_bFreezeOnFirstAddRemove was changed, so control was frozen
|
||||||
|
else
|
||||||
|
m_bFreezeOnFirstAddRemove = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
|
SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
|
||||||
|
@@ -245,6 +245,7 @@ private:
|
|||||||
std::unique_ptr<weld::TreeView> m_xControl;
|
std::unique_ptr<weld::TreeView> m_xControl;
|
||||||
std::unique_ptr<weld::TreeIter> m_xIter;
|
std::unique_ptr<weld::TreeIter> m_xIter;
|
||||||
weld::Window* m_pTopLevel;
|
weld::Window* m_pTopLevel;
|
||||||
|
bool m_bFreezeOnFirstAddRemove;
|
||||||
BrowseMode nMode;
|
BrowseMode nMode;
|
||||||
DocumentEventNotifier m_aNotifier;
|
DocumentEventNotifier m_aNotifier;
|
||||||
void SetEntryBitmaps(const weld::TreeIter& rIter, const OUString& rImage);
|
void SetEntryBitmaps(const weld::TreeIter& rIter, const OUString& rImage);
|
||||||
|
Reference in New Issue
Block a user