summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-23 19:14:45 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-24 18:13:57 +0100
commitb004a1bd7bf3885613d52aba70dea79766eae639 (patch)
treed4a624fa76e0b4038c20350e27f4bbbe6c023637
parent0be61adb0771a9bc0386b6e8d90e4bffd8dfa0e7 (diff)
Resolves: tdf#128940 use a normal MenuButton
instead of a split toolbar item Change-Id: I2e706d1a3255dca7a51d323a2bcf750f28b8fd1e Reviewed-on: https://gerrit.libreoffice.org/83581 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--fpicker/source/office/RemoteFilesDialog.cxx40
-rw-r--r--fpicker/source/office/RemoteFilesDialog.hxx7
-rw-r--r--fpicker/uiconfig/ui/remotefilesdialog.ui102
3 files changed, 70 insertions, 79 deletions
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index b0739b49e95c..27ed01464204 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -32,8 +32,7 @@ RemoteFilesDialog::RemoteFilesDialog( weld::Window* pParent, PickerFlags nBits )
, m_xMasterPasswd( PasswordContainer::create( m_xContext ) )
, m_bIsInExecute( false )
, m_xCancel_btn(m_xBuilder->weld_button("cancel"))
- , m_xAddService_bar(m_xBuilder->weld_toolbar("add_service_bar"))
- , m_xAddService_menu(m_xBuilder->weld_menu("service_edit_menu"))
+ , m_xManageServices(m_xBuilder->weld_menu_button("add_service_btn"))
, m_xServices_lb(m_xBuilder->weld_combo_box("services_lb"))
, m_xPathContainer(m_xBuilder->weld_container("breadcrumb_container"))
, m_xNewFolder(m_xBuilder->weld_button("new_folder"))
@@ -42,8 +41,6 @@ RemoteFilesDialog::RemoteFilesDialog( weld::Window* pParent, PickerFlags nBits )
, m_xFilter_lb(m_xBuilder->weld_combo_box("filter_lb"))
, m_xName_ed(new AutocompleteEdit(m_xBuilder->weld_entry("filename")))
{
- m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get());
-
m_eMode = ( nBits & PickerFlags::SaveAs ) ? REMOTEDLG_MODE_SAVE : REMOTEDLG_MODE_OPEN;
m_eType = ( nBits & PickerFlags::PathDialog ) ? REMOTEDLG_TYPE_PATHDLG : REMOTEDLG_TYPE_FILEDLG;
bool bMultiselection = bool( nBits & PickerFlags::MultiSelection );
@@ -112,8 +109,7 @@ RemoteFilesDialog::RemoteFilesDialog( weld::Window* pParent, PickerFlags nBits )
m_xName_ed->connect_focus_in(LINK(this, RemoteFilesDialog, FileNameGetFocusHdl));
m_xName_ed->connect_changed(LINK(this, RemoteFilesDialog, FileNameModifyHdl));
- m_xAddService_bar->connect_clicked(LINK( this, RemoteFilesDialog, AddServiceHdl));
- m_xAddService_menu->connect_activate(LINK(this, RemoteFilesDialog, EditServiceMenuHdl));
+ m_xManageServices->connect_selected(LINK(this, RemoteFilesDialog, EditServiceMenuHdl));
FillServicesListbox();
@@ -167,6 +163,14 @@ RemoteFilesDialog::~RemoteFilesDialog()
batch->commit();
}
+void RemoteFilesDialog::EnableExtraMenuItems(bool bEnable)
+{
+ m_xManageServices->set_item_visible("change_password", bEnable);
+ m_xManageServices->set_item_visible("edit_service", bEnable);
+ m_xManageServices->set_item_visible("delete_service", bEnable);
+ m_xManageServices->set_item_visible("change_password", bEnable);
+}
+
short RemoteFilesDialog::run()
{
if (m_xServices_lb->get_count() > 0)
@@ -177,7 +181,7 @@ short RemoteFilesDialog::run()
if (!m_bIsConnected)
{
m_xServices_lb->set_active(-1);
- m_xAddService_bar->set_item_menu("add_service_btn", nullptr);
+ EnableExtraMenuItems(false);
}
m_bIsInExecute = true;
@@ -287,10 +291,10 @@ void RemoteFilesDialog::FillServicesListbox()
if (m_xServices_lb->get_count() > 0)
{
m_xServices_lb->set_active(nPos);
- m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get());
+ EnableExtraMenuItems(true);
}
else
- m_xAddService_bar->set_item_menu("add_service_btn", nullptr);
+ EnableExtraMenuItems(false);
EnableControls();
}
@@ -401,7 +405,7 @@ void RemoteFilesDialog::EnableControls()
if (m_xServices_lb->get_active() != -1)
{
- m_xAddService_menu->set_sensitive("change_password", false);
+ m_xManageServices->set_item_sensitive("change_password", false);
try
{
@@ -417,7 +421,7 @@ void RemoteFilesDialog::EnableControls()
if( aURLEntries.UserList.hasElements() )
{
- m_xAddService_menu->set_sensitive("change_password", true);
+ m_xManageServices->set_item_sensitive("change_password", true);
}
}
}
@@ -451,14 +455,14 @@ void RemoteFilesDialog::EnableControls()
}
m_xPath->EnableFields( true );
- m_xAddService_bar->set_sensitive(true);
+ m_xManageServices->set_sensitive(true);
}
void RemoteFilesDialog::DisableControls()
{
m_xServices_lb->set_sensitive(false);
m_xFilter_lb->set_sensitive(false);
- m_xAddService_bar->set_sensitive(false);
+ m_xManageServices->set_sensitive(false);
m_xName_ed->set_sensitive(false);
m_xContainer->set_sensitive(false);
m_xOk_btn->set_sensitive(false);
@@ -508,7 +512,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, ListViewHdl, weld::Button&, void )
m_xFileView->SetViewMode( eDetailedList );
}
-IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, const OString&, void )
+void RemoteFilesDialog::AddService()
{
PlaceEditDialog aDlg(m_xDialog.get());
aDlg.ShowPasswordControl();
@@ -536,7 +540,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, const OString&, void )
m_xServices_lb->append_text( sPrefix + newService->GetName() );
m_xServices_lb->set_active( m_xServices_lb->get_count() - 1 );
- m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get());
+ EnableExtraMenuItems(true);
SelectServiceHdl( *m_xServices_lb );
m_bIsUpdated = true;
@@ -558,7 +562,7 @@ IMPL_LINK_NOARG( RemoteFilesDialog, SelectServiceHdl, weld::ComboBox&, void )
if( nPos >= 0 )
{
OUString sURL = m_aServices[nPos]->GetUrl();
- m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get());
+ EnableExtraMenuItems(true);
m_bServiceChanged = true;
OpenURL( sURL );
@@ -648,7 +652,7 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, const OString&, rIdent, void
m_xServices_lb->remove( nSelected );
m_xServices_lb->set_active(-1);
- m_xAddService_bar->set_item_menu("add_service_btn", nullptr);
+ EnableExtraMenuItems(false);
m_bIsUpdated = true;
@@ -699,6 +703,8 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, const OString&, rIdent, void
catch( const Exception& )
{}
}
+ else if( sIdent == "add_service" )
+ AddService();
EnableControls();
}
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index 9972c69d1afd..6a80bc849f70 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -125,8 +125,7 @@ private:
std::unique_ptr<weld::Button> m_xOk_btn;
std::unique_ptr<weld::Button> m_xCancel_btn;
- std::unique_ptr<weld::Toolbar> m_xAddService_bar;
- std::unique_ptr<weld::Menu> m_xAddService_menu;
+ std::unique_ptr<weld::MenuButton> m_xManageServices;
std::unique_ptr<weld::ComboBox> m_xServices_lb;
std::unique_ptr<weld::Container> m_xPathContainer;
std::unique_ptr<Breadcrumb> m_xPath;
@@ -153,13 +152,15 @@ private:
void AddFileExtension();
+ void EnableExtraMenuItems(bool bEnable);
void EnableControls();
void DisableControls();
void SavePassword(const OUString& rURL, const OUString& rUser,
const OUString& rPassword, bool bPersistent);
- DECL_LINK ( AddServiceHdl, const OString&, void );
+ void AddService();
+
DECL_LINK ( SelectServiceHdl, weld::ComboBox&, void );
DECL_LINK ( EditServiceMenuHdl, const OString&, void );
diff --git a/fpicker/uiconfig/ui/remotefilesdialog.ui b/fpicker/uiconfig/ui/remotefilesdialog.ui
index 93c17f05ba27..a069b2fb0c21 100644
--- a/fpicker/uiconfig/ui/remotefilesdialog.ui
+++ b/fpicker/uiconfig/ui/remotefilesdialog.ui
@@ -51,6 +51,42 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkMenu" id="service_edit_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="add_service">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="remotefilesdialog|edit_service">_Add service</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="edit_service">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="remotefilesdialog|edit_service">_Edit service</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="delete_service">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="remotefilesdialog|delete_service">_Delete service</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="change_password">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="remotefilesdialog|change_password">_Change password</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
<object class="GtkDialog" id="RemoteFilesDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
@@ -174,38 +210,16 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkMenuButton" id="add_service_btn">
+ <property name="label" translatable="yes" context="remotefilesdialog|add_service_btn">_Manage services</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="valign">center</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <property name="propagate_natural_width">True</property>
- <property name="propagate_natural_height">True</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="popup">service_edit_menu</property>
+ <property name="use_popover">False</property>
<child>
- <object class="GtkViewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkToolbar" id="add_service_bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuToolButton" id="add_service_btn">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="remotefilesdialog|add_service_btn">Add service</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
+ <placeholder/>
</child>
</object>
<packing>
@@ -454,8 +468,6 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore2</property>
- <property name="pixbuf_column">0</property>
- <property name="text_column">1</property>
</object>
</child>
</object>
@@ -558,32 +570,4 @@
<action-widget response="-5">save</action-widget>
</action-widgets>
</object>
- <object class="GtkMenu" id="service_edit_menu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuItem" id="edit_service">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="remotefilesdialog|edit_service">_Edit service</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="delete_service">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="remotefilesdialog|delete_service">_Delete service</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="change_password">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="remotefilesdialog|change_password">_Change password</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- </object>
</interface>