[Libreoffice-commits] core.git: basctl/source basctl/uiconfig
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Feb 7 20:59:25 UTC 2019
basctl/source/basicide/basides1.cxx | 4
basctl/source/dlged/managelang.cxx | 107 +++++++++++--------------
basctl/source/inc/managelang.hxx | 23 ++---
basctl/uiconfig/basicide/ui/managelanguages.ui | 52 ++++++++++--
4 files changed, 106 insertions(+), 80 deletions(-)
New commits:
commit 9170c8eeb6f47772f0c3e91f0cfb47b5bd2fd3ed
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 7 16:17:30 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 7 21:58:59 2019 +0100
weld ManageLanguageDialog
Change-Id: I70cabe6c028cdfae06d0f677979937f18249917a
Reviewed-on: https://gerrit.libreoffice.org/67513
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index d9a9adecaa3a..25dc3e5a4e17 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -742,8 +742,8 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
{
std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
rReq.Ignore(); // the 'old' request is not relevant any more
- auto pDlg = VclPtr<ManageLanguageDialog>::Create(pCurWin, m_pCurLocalizationMgr);
- pDlg->StartExecuteAsync([=](sal_Int32 /*nResult*/){
+ std::shared_ptr<ManageLanguageDialog> xDlg(new ManageLanguageDialog(pCurWin ? pCurWin->GetFrameWeld() : nullptr, m_pCurLocalizationMgr));
+ weld::DialogController::runAsync(xDlg, [=](sal_Int32 /*nResult*/){
pRequest->Done();
});
}
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index 81a74b030f71..d6ab5d30e4ac 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -56,37 +56,27 @@ bool localesAreEqual( const Locale& rLocaleLeft, const Locale& rLocaleRight )
return bRet;
}
-ManageLanguageDialog::ManageLanguageDialog(vcl::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
- : ModalDialog(pParent, "ManageLanguagesDialog", "modules/BasicIDE/ui/managelanguages.ui")
+ManageLanguageDialog::ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
+ : GenericDialogController(pParent, "modules/BasicIDE/ui/managelanguages.ui", "ManageLanguagesDialog")
, m_xLocalizationMgr(xLMgr)
, m_sDefLangStr(IDEResId(RID_STR_DEF_LANG))
, m_sCreateLangStr(IDEResId(RID_STR_CREATE_LANG))
+ , m_xLanguageLB(m_xBuilder->weld_tree_view("treeview"))
+ , m_xAddPB(m_xBuilder->weld_button("add"))
+ , m_xDeletePB(m_xBuilder->weld_button("delete"))
+ , m_xMakeDefPB(m_xBuilder->weld_button("default"))
{
- get(m_pLanguageLB, "treeview");
- m_pLanguageLB->set_height_request(m_pLanguageLB->GetTextHeight() * 10);
- m_pLanguageLB->set_width_request(m_pLanguageLB->approximate_char_width() * 50);
- get(m_pAddPB, "add");
- get(m_pDeletePB, "delete");
- get(m_pMakeDefPB, "default");
+ m_xLanguageLB->set_size_request(m_xLanguageLB->get_approximate_digit_width() * 42,
+ m_xLanguageLB->get_height_rows(10));
Init();
FillLanguageBox();
- SelectHdl( *m_pLanguageLB );
+ SelectHdl( *m_xLanguageLB );
}
ManageLanguageDialog::~ManageLanguageDialog()
{
- disposeOnce();
-}
-
-void ManageLanguageDialog::dispose()
-{
ClearLanguageBox();
- m_pLanguageLB.clear();
- m_pAddPB.clear();
- m_pDeletePB.clear();
- m_pMakeDefPB.clear();
- ModalDialog::dispose();
}
void ManageLanguageDialog::Init()
@@ -95,16 +85,16 @@ void ManageLanguageDialog::Init()
Shell* pShell = GetShell();
const OUString& sLibName = pShell->GetCurLibName();
// set dialog title with library name
- OUString sText = GetText();
+ OUString sText = m_xDialog->get_title();
sText = sText.replaceAll("$1", sLibName);
- SetText( sText );
+ m_xDialog->set_title(sText);
// set handler
- m_pAddPB->SetClickHdl( LINK( this, ManageLanguageDialog, AddHdl ) );
- m_pDeletePB->SetClickHdl( LINK( this, ManageLanguageDialog, DeleteHdl ) );
- m_pMakeDefPB->SetClickHdl( LINK( this, ManageLanguageDialog, MakeDefHdl ) );
- m_pLanguageLB->SetSelectHdl( LINK( this, ManageLanguageDialog, SelectHdl ) );
+ m_xAddPB->connect_clicked( LINK( this, ManageLanguageDialog, AddHdl ) );
+ m_xDeletePB->connect_clicked( LINK( this, ManageLanguageDialog, DeleteHdl ) );
+ m_xMakeDefPB->connect_clicked( LINK( this, ManageLanguageDialog, MakeDefHdl ) );
+ m_xLanguageLB->connect_changed( LINK( this, ManageLanguageDialog, SelectHdl ) );
- m_pLanguageLB->EnableMultiSelection( true );
+ m_xLanguageLB->set_selection_mode(SelectionMode::Multiple);
}
void ManageLanguageDialog::FillLanguageBox()
@@ -126,28 +116,28 @@ void ManageLanguageDialog::FillLanguageBox()
{
sLanguage += " " + m_sDefLangStr;
}
- const sal_Int32 nPos = m_pLanguageLB->InsertEntry( sLanguage );
- m_pLanguageLB->SetEntryData( nPos, new LanguageEntry( pLocale[i], bIsDefault ) );
+ LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
+ m_xLanguageLB->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sLanguage);
}
}
else
- m_pLanguageLB->InsertEntry( m_sCreateLangStr );
+ m_xLanguageLB->append_text(m_sCreateLangStr);
}
void ManageLanguageDialog::ClearLanguageBox()
{
- const sal_Int32 nCount = m_pLanguageLB->GetEntryCount();
- for ( sal_Int32 i = 0; i < nCount; ++i )
+ const sal_Int32 nCount = m_xLanguageLB->n_children();
+ for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = static_cast<LanguageEntry*>(m_pLanguageLB->GetEntryData(i));
+ LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(i).toInt64());
delete pEntry;
}
- m_pLanguageLB->Clear();
+ m_xLanguageLB->clear();
}
-IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, Button*, void)
+IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, weld::Button&, void)
{
- std::shared_ptr<SetDefaultLanguageDialog> xDlg(new SetDefaultLanguageDialog(GetFrameWeld(), m_xLocalizationMgr));
+ std::shared_ptr<SetDefaultLanguageDialog> xDlg(new SetDefaultLanguageDialog(m_xDialog.get(), m_xLocalizationMgr));
weld::DialogController::runAsync(xDlg, [xDlg,this](sal_Int32 nResult)
{
if (!nResult )
@@ -164,20 +154,21 @@ IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, Button*, void)
});
}
-IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, Button*, void)
+IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
{
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/BasicIDE/ui/deletelangdialog.ui"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/BasicIDE/ui/deletelangdialog.ui"));
std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("DeleteLangDialog"));
if (xQBox->run() == RET_OK)
{
- sal_Int32 nCount = m_pLanguageLB->GetSelectedEntryCount();
- sal_Int32 nPos = m_pLanguageLB->GetSelectedEntryPos();
+ std::vector<int> aSelection = m_xLanguageLB->get_selected_rows();
+ int nCount = aSelection.size();
+ int nPos = m_xLanguageLB->get_selected_index();
// remove locales
Sequence< Locale > aLocaleSeq( nCount );
- for ( sal_Int32 i = 0; i < nCount; ++i )
+ for (int i = 0; i < nCount; ++i)
{
- const sal_Int32 nSelPos = m_pLanguageLB->GetSelectedEntryPos(i);
- LanguageEntry* pEntry = static_cast<LanguageEntry*>(m_pLanguageLB->GetEntryData( nSelPos ));
+ const sal_Int32 nSelPos = aSelection[i];
+ LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64());
if ( pEntry )
aLocaleSeq[i] = pEntry->m_aLocale;
}
@@ -186,19 +177,19 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, Button*, void)
ClearLanguageBox();
FillLanguageBox();
// reset selection
- nCount = m_pLanguageLB->GetEntryCount();
- if ( nCount <= nPos )
+ nCount = m_xLanguageLB->n_children();
+ if (nCount <= nPos)
nPos = nCount - 1;
- m_pLanguageLB->SelectEntryPos( nPos );
- SelectHdl( *m_pLanguageLB );
+ m_xLanguageLB->select(nPos);
+ SelectHdl( *m_xLanguageLB );
}
}
-IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, Button*, void)
+IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, weld::Button&, void)
{
- const sal_Int32 nPos = m_pLanguageLB->GetSelectedEntryPos();
- LanguageEntry* pSelectEntry = static_cast<LanguageEntry*>(m_pLanguageLB->GetEntryData( nPos ));
- if ( pSelectEntry && !pSelectEntry->m_bIsDefault )
+ const sal_Int32 nPos = m_xLanguageLB->get_selected_index();
+ LanguageEntry* pSelectEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nPos).toInt64());
+ if (pSelectEntry && !pSelectEntry->m_bIsDefault)
{
// set new default entry
m_xLocalizationMgr->handleSetDefaultLocale( pSelectEntry->m_aLocale );
@@ -206,21 +197,21 @@ IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, Button*, void)
ClearLanguageBox();
FillLanguageBox();
// reset selection
- m_pLanguageLB->SelectEntryPos( nPos );
- SelectHdl( *m_pLanguageLB );
+ m_xLanguageLB->select(nPos);
+ SelectHdl( *m_xLanguageLB );
}
}
-IMPL_LINK_NOARG(ManageLanguageDialog, SelectHdl, ListBox&, void)
+IMPL_LINK_NOARG(ManageLanguageDialog, SelectHdl, weld::TreeView&, void)
{
- const sal_Int32 nCount = m_pLanguageLB->GetEntryCount();
+ const sal_Int32 nCount = m_xLanguageLB->n_children();
bool bEmpty = ( !nCount ||
- m_pLanguageLB->GetEntryPos( m_sCreateLangStr ) != LISTBOX_ENTRY_NOTFOUND );
- bool bSelect = ( m_pLanguageLB->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND );
+ m_xLanguageLB->find_text(m_sCreateLangStr) != -1 );
+ bool bSelect = ( m_xLanguageLB->get_selected_index() != -1 );
bool bEnable = !bEmpty && bSelect;
- m_pDeletePB->Enable(bEnable);
- m_pMakeDefPB->Enable(bEnable && nCount > 1 && m_pLanguageLB->GetSelectedEntryCount() == 1);
+ m_xDeletePB->set_sensitive(bEnable);
+ m_xMakeDefPB->set_sensitive(bEnable && nCount > 1 && m_xLanguageLB->count_selected_rows() == 1);
}
// class SetDefaultLanguageDialog -----------------------------------------------
diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx
index 243ea35605d9..e040aaee1a1d 100644
--- a/basctl/source/inc/managelang.hxx
+++ b/basctl/source/inc/managelang.hxx
@@ -46,32 +46,31 @@ struct LanguageEntry
extern bool localesAreEqual( const css::lang::Locale& rLocaleLeft,
const css::lang::Locale& rLocaleRight );
-class ManageLanguageDialog : public ModalDialog
+class ManageLanguageDialog : public weld::GenericDialogController
{
private:
- VclPtr<ListBox> m_pLanguageLB;
- VclPtr<PushButton> m_pAddPB;
- VclPtr<PushButton> m_pDeletePB;
- VclPtr<PushButton> m_pMakeDefPB;
-
std::shared_ptr<LocalizationMgr> m_xLocalizationMgr;
OUString m_sDefLangStr;
OUString m_sCreateLangStr;
+ std::unique_ptr<weld::TreeView> m_xLanguageLB;
+ std::unique_ptr<weld::Button> m_xAddPB;
+ std::unique_ptr<weld::Button> m_xDeletePB;
+ std::unique_ptr<weld::Button> m_xMakeDefPB;
+
void Init();
void FillLanguageBox();
void ClearLanguageBox();
- DECL_LINK(AddHdl, Button*, void);
- DECL_LINK(DeleteHdl, Button*, void);
- DECL_LINK(MakeDefHdl, Button*, void);
- DECL_LINK(SelectHdl, ListBox&, void);
+ DECL_LINK(AddHdl, weld::Button&, void);
+ DECL_LINK(DeleteHdl, weld::Button&, void);
+ DECL_LINK(MakeDefHdl, weld::Button&, void);
+ DECL_LINK(SelectHdl, weld::TreeView&, void);
public:
- ManageLanguageDialog( vcl::Window* pParent, std::shared_ptr<LocalizationMgr> const & _pLMgr );
+ ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & _pLMgr);
virtual ~ManageLanguageDialog() override;
- virtual void dispose() override;
};
class SetDefaultLanguageDialog : public weld::GenericDialogController
diff --git a/basctl/uiconfig/basicide/ui/managelanguages.ui b/basctl/uiconfig/basicide/ui/managelanguages.ui
index eac660761fda..b00c355bea03 100644
--- a/basctl/uiconfig/basicide/ui/managelanguages.ui
+++ b/basctl/uiconfig/basicide/ui/managelanguages.ui
@@ -1,13 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="basctl">
<requires lib="gtk+" version="3.18"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="ManageLanguagesDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="managelanguages|ManageLanguagesDialog">Manage User Interface Languages [$1]</property>
<property name="resizable">False</property>
+ <property name="modal">True</property>
<property name="type_hint">normal</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -65,10 +77,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="managelanguages|label1">Present languages:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">treeview:border</property>
+ <property name="mnemonic_widget">treeview</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -79,10 +91,10 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="managelanguages|label2">The default language is used if no localization for a user interface locale is present. Furthermore all strings from the default language are copied to resources of newly added languages.</property>
<property name="wrap">True</property>
<property name="max_width_chars">68</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -153,14 +165,38 @@
</packing>
</child>
<child>
- <object class="GtkTreeView" id="treeview:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="width_request">-1</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="search_column">1</property>
+ <property name="enable_tree_lines">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
More information about the Libreoffice-commits
mailing list