cui/source/customize/eventdlg.cxx     |    1 
 cui/source/customize/macropg.cxx      |   64 ++++++++++++++++++++----
 cui/source/customize/macropg_impl.hxx |    1 
 cui/source/inc/macropg.hxx            |    2 
 cui/uiconfig/ui/eventsconfigpage.ui   |   14 +++++
 cui/uiconfig/ui/macroassignpage.ui    |   90 +++++++++++++++++++---------------
 6 files changed, 125 insertions(+), 47 deletions(-)

New commits:
commit e1de95f72b1e6467510f7c3b32b25d7528c93a75
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Dec 8 16:47:32 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Dec 9 13:53:38 2022 +0000

    Related: tdf#152266 add a remove all button
    
    Change-Id: Ibf6b749089d2d6da71a9ce00779bce8886453856
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143833
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/cui/source/customize/eventdlg.cxx 
b/cui/source/customize/eventdlg.cxx
index 7aa67e3f5a81..755fd16b416a 100644
--- a/cui/source/customize/eventdlg.cxx
+++ b/cui/source/customize/eventdlg.cxx
@@ -44,6 +44,7 @@ SvxEventConfigPage::SvxEventConfigPage(weld::Container* 
pPage, weld::DialogContr
     mpImpl->xEventLB = m_xBuilder->weld_tree_view("events");
     mpImpl->xAssignPB = m_xBuilder->weld_button("macro");
     mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+    mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
     mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
 
     
mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width()
 * 70,
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index 34eb44849d84..3980c8b6c3f7 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -61,21 +61,20 @@ 
MacroEventListBox::MacroEventListBox(std::unique_ptr<weld::TreeView> xTreeView)
 //     and it is not read only
 void SvxMacroTabPage_::EnableButtons()
 {
+    mpImpl->xDeleteAllPB->set_sensitive(m_nAssignedEvents != 0);
     int nEvent = mpImpl->xEventLB->get_selected_index();
-    if (nEvent != -1)
-    {
-        const EventPair* pEventPair = 
LookupEvent(mpImpl->xEventLB->get_id(nEvent));
-        const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
-        mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned);
-        mpImpl->xAssignPB->set_sensitive( !mpImpl->bReadOnly );
-        if( mpImpl->xAssignComponentPB )
-            mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
-    }
+    const EventPair* pEventPair = nEvent == -1 ? nullptr : 
LookupEvent(mpImpl->xEventLB->get_id(nEvent));
+    const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
+    mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned);
+    mpImpl->xAssignPB->set_sensitive(!mpImpl->bReadOnly);
+    if (mpImpl->xAssignComponentPB)
+        mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
 }
 
 SvxMacroTabPage_::SvxMacroTabPage_(weld::Container* pPage, 
weld::DialogController* pController, const OUString& rUIXMLDescription,
     const OString& rID, const SfxItemSet& rAttrSet)
     : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rAttrSet)
+    , m_nAssignedEvents(0)
     , bDocModified(false)
     , bAppEvents(false)
     , bInitialized(false)
@@ -308,6 +307,7 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
 
     mpImpl->xEventLB->freeze();
     mpImpl->xEventLB->clear();
+    m_nAssignedEvents = 0;
     EventsHash* eventsHash;
     Reference< container::XNameReplace> nameReplace;
     if(bAppEvents)
@@ -348,6 +348,9 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
         mpImpl->xEventLB->append(sEventName, displayName);
         mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1);
         mpImpl->xEventLB->set_text(nRow, 
OUString(GetEventDisplayText(eventURL)), 2);
+
+        if (!eventURL.isEmpty())
+            ++m_nAssignedEvents;
     }
 
     mpImpl->xEventLB->thaw();
@@ -427,6 +430,9 @@ void SvxMacroTabPage_::GenericHandler_Impl(const 
weld::Button* pBtn)
         sEventURL = pEventPair->second;
     }
 
+    if (!sEventURL.isEmpty())
+        --m_nAssignedEvents;
+
     bool bDoubleClick = (pBtn == nullptr);
     bool bUNOAssigned = sEventURL.startsWith( aVndSunStarUNO );
     if (pBtn == mpImpl->xDeletePB.get())
@@ -484,6 +490,9 @@ void SvxMacroTabPage_::GenericHandler_Impl(const 
weld::Button* pBtn)
         h_it->second.second = sEventURL;
     }
 
+    if (!sEventURL.isEmpty())
+        ++m_nAssignedEvents;
+
     rListBox.set_image(nEntry, GetEventDisplayImage(sEventURL), 1);
     rListBox.set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2);
 
@@ -493,6 +502,41 @@ void SvxMacroTabPage_::GenericHandler_Impl(const 
weld::Button* pBtn)
     EnableButtons();
 }
 
+IMPL_LINK_NOARG(SvxMacroTabPage_, DeleteAllHdl_Impl, weld::Button&, void)
+{
+    OUString sEventType =  "Script" ;
+    OUString sEmptyString;
+
+    mpImpl->xEventLB->all_foreach([this, &sEventType, 
&sEmptyString](weld::TreeIter& rEntry) {
+        weld::TreeView& rListBox = *mpImpl->xEventLB;
+        OUString sEventName = rListBox.get_id(rEntry);
+        // update the hashes
+        if (bAppEvents)
+        {
+            EventsHash::iterator h_it = m_appEventsHash.find(sEventName);
+            h_it->second.first = sEventType;
+            h_it->second.second = sEmptyString;
+        }
+        else
+        {
+            EventsHash::iterator h_it = m_docEventsHash.find(sEventName);
+            h_it->second.first = sEventType;
+            h_it->second.second = sEmptyString;
+        }
+
+        rListBox.set_image(rEntry, sEmptyString, 1);
+        rListBox.set_text(rEntry, sEmptyString, 2);
+        return false;
+    });
+
+    if (!bAppEvents)
+        bDocModified = true;
+
+    m_nAssignedEvents = 0;
+
+    EnableButtons();
+}
+
 // pass in the XNameReplace.
 // can remove the 3rd arg once issue ?? is fixed
 void SvxMacroTabPage_::InitAndSetHandler( const Reference< 
container::XNameReplace>& xAppEvents, const Reference< 
container::XNameReplace>& xDocEvents, const Reference< util::XModifiable >& 
xModifiable )
@@ -503,6 +547,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< 
container::XNameRepla
     Link<weld::Button&,void>     aLnk(LINK(this, SvxMacroTabPage_, 
AssignDeleteHdl_Impl ));
     mpImpl->xDeletePB->connect_clicked(aLnk);
     mpImpl->xAssignPB->connect_clicked(aLnk);
+    mpImpl->xDeleteAllPB->connect_clicked(LINK(this, SvxMacroTabPage_, 
DeleteAllHdl_Impl));
     if( mpImpl->xAssignComponentPB )
         mpImpl->xAssignComponentPB->connect_clicked( aLnk );
     mpImpl->xEventLB->connect_row_activated( LINK(this, SvxMacroTabPage_, 
DoubleClickHdl_Impl ) );
@@ -596,6 +641,7 @@ SvxMacroTabPage::SvxMacroTabPage(weld::Container* pPage, 
weld::DialogController*
                                        mpImpl->xEventLB->get_height_rows(9));
     mpImpl->xAssignPB = m_xBuilder->weld_button("assign");
     mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+    mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
     mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
 
     SetFrame( _rxDocumentFrame );
diff --git a/cui/source/customize/macropg_impl.hxx 
b/cui/source/customize/macropg_impl.hxx
index 63d2f2ae28e6..1073e4bb36ff 100644
--- a/cui/source/customize/macropg_impl.hxx
+++ b/cui/source/customize/macropg_impl.hxx
@@ -30,6 +30,7 @@ public:
     std::unique_ptr<weld::Button> xAssignPB;
     std::unique_ptr<weld::Button> xAssignComponentPB;
     std::unique_ptr<weld::Button> xDeletePB;
+    std::unique_ptr<weld::Button> xDeleteAllPB;
     std::unique_ptr<weld::TreeView> xEventLB;
     bool                        bReadOnly;
     bool                        bIDEDialogMode;
diff --git a/cui/source/inc/macropg.hxx b/cui/source/inc/macropg.hxx
index 7c934e33799d..cecdf3b55224 100644
--- a/cui/source/inc/macropg.hxx
+++ b/cui/source/inc/macropg.hxx
@@ -55,6 +55,7 @@ class SvxMacroTabPage_ : public SfxTabPage
     DECL_LINK( SelectEvent_Impl, weld::TreeView&, void );
     DECL_LINK( AssignDeleteHdl_Impl, weld::Button&, void );
     DECL_LINK( DoubleClickHdl_Impl, weld::TreeView&, bool );
+    DECL_LINK( DeleteAllHdl_Impl, weld::Button&, void );
 
     void GenericHandler_Impl(const weld::Button* pBtn);
     const EventPair* LookupEvent(const OUString& rEventName);
@@ -66,6 +67,7 @@ protected:
     css::uno::Reference< css::util::XModifiable > m_xModifiable;
     EventsHash m_appEventsHash;
     EventsHash m_docEventsHash;
+    int m_nAssignedEvents;
     bool bDocModified, bAppEvents, bInitialized;
     std::vector< EventDisplayName > aDisplayNames;
 
diff --git a/cui/uiconfig/ui/eventsconfigpage.ui 
b/cui/uiconfig/ui/eventsconfigpage.ui
index c7f52321d43c..acdf91c4df48 100644
--- a/cui/uiconfig/ui/eventsconfigpage.ui
+++ b/cui/uiconfig/ui/eventsconfigpage.ui
@@ -95,6 +95,20 @@
                     <property name="position">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkButton" id="deleteall">
+                    <property name="label" translatable="yes" 
context="eventsconfigpage|deleteall">Remove _All</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <property name="use-underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/cui/uiconfig/ui/macroassignpage.ui 
b/cui/uiconfig/ui/macroassignpage.ui
index 4503f24c2380..24395c840c6c 100644
--- a/cui/uiconfig/ui/macroassignpage.ui
+++ b/cui/uiconfig/ui/macroassignpage.ui
@@ -181,6 +181,20 @@
                 <property name="position">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="deleteall">
+                <property name="label" translatable="yes" 
context="macroassignpage|deleteall">Remove _All</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
         </child>
         <child type="label">
commit 45449e2fd20b45f9e3e04538c77b9e245a4170d4
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Dec 9 12:17:52 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Dec 9 13:53:24 2022 +0000

    resave with latest glade
    
    Change-Id: Ia9dc0446c2dc69c0e04d67b0d4da30319807a6cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143852
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/cui/uiconfig/ui/macroassignpage.ui 
b/cui/uiconfig/ui/macroassignpage.ui
index 3ecd4ce3d90c..4503f24c2380 100644
--- a/cui/uiconfig/ui/macroassignpage.ui
+++ b/cui/uiconfig/ui/macroassignpage.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkTreeStore" id="liststore3">
@@ -14,41 +14,41 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <!-- n-columns=1 n-rows=1 -->
+  <!-- n-columns=2 n-rows=1 -->
   <object class="GtkGrid" id="MacroAssignPage">
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
+    <property name="can-focus">False</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
-    <property name="row_spacing">12</property>
-    <property name="column_spacing">12</property>
+    <property name="row-spacing">12</property>
+    <property name="column-spacing">12</property>
     <child>
       <object class="GtkFrame" id="frame1">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
-        <property name="label_xalign">0</property>
-        <property name="shadow_type">none</property>
+        <property name="label-xalign">0</property>
+        <property name="shadow-type">none</property>
         <child>
           <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="shadow_type">in</property>
+            <property name="can-focus">True</property>
             <property name="margin-start">12</property>
             <property name="margin-top">6</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="shadow-type">in</property>
             <child>
               <object class="GtkTreeView" id="assignments">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">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">liststore3</property>
-                <property name="search_column">0</property>
-                <property name="show_expanders">False</property>
+                <property name="search-column">0</property>
+                <property name="show-expanders">False</property>
                 <child internal-child="selection">
                   <object class="GtkTreeSelection" id="Macro Library 
List-selection2"/>
                 </child>
@@ -101,7 +101,7 @@
         <child type="label">
           <object class="GtkLabel" id="libraryft1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="label" translatable="yes" 
context="macroassignpage|libraryft1">Assignments</property>
             <attributes>
               <attribute name="weight" value="bold"/>
@@ -110,32 +110,32 @@
         </child>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">0</property>
       </packing>
     </child>
     <child>
       <object class="GtkFrame" id="frame2">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label_xalign">0</property>
-        <property name="shadow_type">none</property>
+        <property name="can-focus">False</property>
+        <property name="label-xalign">0</property>
+        <property name="shadow-type">none</property>
         <child>
           <object class="GtkButtonBox" id="buttonbox1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
-            <property name="layout_style">start</property>
+            <property name="can-focus">False</property>
             <property name="margin-start">12</property>
             <property name="margin-top">6</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <property name="layout-style">start</property>
             <child>
               <object class="GtkButton" id="assign">
                 <property name="label" translatable="yes" 
context="macroassignpage|assign">M_acro...</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
                 <child internal-child="accessible">
                   <object class="AtkObject" id="assign-atkobject">
                     <property name="AtkObject::accessible-description" 
translatable="yes" context="macroassignpage|extended_tip|assign">Opens the 
Macro Selector to assign a macro to the selected event.</property>
@@ -152,9 +152,9 @@
               <object class="GtkButton" id="component">
                 <property name="label" translatable="yes" 
context="macroassignpage|component">Com_ponent...</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -166,9 +166,9 @@
               <object class="GtkButton" id="delete">
                 <property name="label" translatable="yes" 
context="macroassignpage|delete">Remove</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
                 <child internal-child="accessible">
                   <object class="AtkObject" id="delete-atkobject">
                     <property name="AtkObject::accessible-description" 
translatable="yes" context="macroassignpage|extended_tip|delete">Deletes the 
macro or component assignment for the selected event.</property>
@@ -186,7 +186,7 @@
         <child type="label">
           <object class="GtkLabel" id="label1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="label" translatable="yes" 
context="macroassignpage|label1">Assign</property>
             <attributes>
               <attribute name="weight" value="bold"/>
@@ -195,8 +195,8 @@
         </child>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">0</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">0</property>
       </packing>
     </child>
     <child internal-child="accessible">

Reply via email to