Kaydet (Commit) 40f1cfa6 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld GotoLineDialog

Change-Id: Ibf040e9b48a5545550e1ee830852a75ca82262e7
Reviewed-on: https://gerrit.libreoffice.org/52695Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 49eb02f0
...@@ -1010,13 +1010,15 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) ...@@ -1010,13 +1010,15 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq)
break; break;
case SID_GOTOLINE: case SID_GOTOLINE:
{ {
ScopedVclPtrInstance< GotoLineDialog > aGotoDlg(this); GotoLineDialog aGotoDlg(GetFrameWeld());
if (aGotoDlg->Execute()) if (aGotoDlg.run() == RET_OK)
if (sal_Int32 const nLine = aGotoDlg->GetLineNumber()) {
if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
{ {
TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0)); TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
GetEditView()->SetSelection(aSel); GetEditView()->SetSelection(aSel);
} }
}
break; break;
} }
} }
......
...@@ -392,39 +392,30 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool ...@@ -392,39 +392,30 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool
} }
// GotoLineDialog // GotoLineDialog
GotoLineDialog::GotoLineDialog(vcl::Window * pParent ) GotoLineDialog::GotoLineDialog(weld::Window* pParent )
: ModalDialog(pParent, "GotoLineDialog", : GenericDialogController(pParent, "modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
"modules/BasicIDE/ui/gotolinedialog.ui") , m_xEdit(m_xBuilder->weld_entry("entry"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
{ {
get(m_pEdit, "entry"); m_xEdit->grab_focus();
get(m_pOKButton, "ok"); m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
m_pEdit->GrabFocus();
m_pOKButton->SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler));
} }
GotoLineDialog::~GotoLineDialog() GotoLineDialog::~GotoLineDialog()
{ {
disposeOnce();
}
void GotoLineDialog::dispose()
{
m_pEdit.clear();
m_pOKButton.clear();
ModalDialog::dispose();
} }
sal_Int32 GotoLineDialog::GetLineNumber() const sal_Int32 GotoLineDialog::GetLineNumber() const
{ {
return m_pEdit->GetText().toInt32(); return m_xEdit->get_text().toInt32();
} }
IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, Button*, void) IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
{ {
if ( GetLineNumber() ) if (GetLineNumber())
EndDialog(1); m_xDialog->response(RET_OK);
else else
m_pEdit->SetText(m_pEdit->GetText(), Selection(0, m_pEdit->GetText().getLength())); m_xEdit->select_region(0, -1);
} }
// ExportDialog // ExportDialog
......
...@@ -60,15 +60,14 @@ public: ...@@ -60,15 +60,14 @@ public:
} }
}; };
class GotoLineDialog : public ModalDialog class GotoLineDialog : public weld::GenericDialogController
{ {
VclPtr<Edit> m_pEdit; std::unique_ptr<weld::Entry> m_xEdit;
VclPtr<OKButton> m_pOKButton; std::unique_ptr<weld::Button> m_xOKButton;
DECL_LINK(OkButtonHandler, Button*, void); DECL_LINK(OkButtonHandler, weld::Button&, void);
public: public:
explicit GotoLineDialog(vcl::Window * pParent); explicit GotoLineDialog(weld::Window* pParent);
virtual ~GotoLineDialog() override; virtual ~GotoLineDialog() override;
virtual void dispose() override;
sal_Int32 GetLineNumber() const; sal_Int32 GetLineNumber() const;
}; };
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.20.4 -->
<interface domain="basctl"> <interface domain="basctl">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="GotoLineDialog"> <object class="GtkDialog" id="GotoLineDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="gotolinedialog|GotoLineDialog">Go to Line</property> <property name="title" translatable="yes" context="gotolinedialog|GotoLineDialog">Go to Line</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
...@@ -81,10 +84,10 @@ ...@@ -81,10 +84,10 @@
<object class="GtkLabel" id="area"> <object class="GtkLabel" id="area">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="gotolinedialog|area">_Line number:</property> <property name="label" translatable="yes" context="gotolinedialog|area">_Line number:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">entry</property> <property name="mnemonic_widget">entry</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -96,6 +99,7 @@ ...@@ -96,6 +99,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="activates_default">True</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -114,6 +118,10 @@ ...@@ -114,6 +118,10 @@
<action-widgets> <action-widgets>
<action-widget response="-5">ok</action-widget> <action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget> <action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets> </action-widgets>
<child>
<placeholder/>
</child>
</object> </object>
</interface> </interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment