Ticket #13463: 0004-BFilePanel-Add-setter-AlwaysEnableDefaultButton.patch

File 0004-BFilePanel-Add-setter-AlwaysEnableDefaultButton.patch, 3.1 KB (added by owenca, 8 years ago)
  • headers/os/storage/FilePanel.h

    From 8944545a3f86d4e2cb3e01b3758d18522fcf8372 Mon Sep 17 00:00:00 2001
    From: Owen <owenca@users.noreply.github.com>
    Date: Sat, 29 Apr 2017 19:45:53 +0000
    Subject: [PATCH 4/4] BFilePanel: Add setter AlwaysEnableDefaultButton().
    
    The default button (e.g., Save/Open) is enabled/disabled by Tracker
    depending on whether or not any items are selected. With this new
    setter, the default button can be kept enabled even if no items are
    selected.
    
    Fixes #13463.
    ---
     headers/os/storage/FilePanel.h     |  2 ++
     src/kits/tracker/FilePanel.cpp     | 11 +++++++++++
     src/kits/tracker/FilePanelPriv.cpp | 16 ++++++++++++++--
     src/kits/tracker/FilePanelPriv.h   |  3 +++
     4 files changed, 30 insertions(+), 2 deletions(-)
    
    diff --git a/headers/os/storage/FilePanel.h b/headers/os/storage/FilePanel.h
    index ded44de..4e39186 100644
    a b class BFilePanel {  
    8282        void            Rewind();
    8383        status_t        GetNextSelectedRef(entry_ref* ref);
    8484
     85        void            AlwaysEnableDefaultButton();
     86
    8587    private:
    8688        virtual void    _ReservedFilePanel1();
    8789        virtual void    _ReservedFilePanel2();
  • src/kits/tracker/FilePanel.cpp

    diff --git a/src/kits/tracker/FilePanel.cpp b/src/kits/tracker/FilePanel.cpp
    index 539b7ea..466a3eb 100644
    a b BFilePanel::SelectionChanged()  
    386386{
    387387    // hook function
    388388}
     389
     390
     391void
     392BFilePanel::AlwaysEnableDefaultButton()
     393{
     394    AutoLock<BWindow> lock(fWindow);
     395    if (!lock)
     396        return;
     397
     398    static_cast<TFilePanel*>(fWindow)->AlwaysEnableDefaultButton();
     399}
  • src/kits/tracker/FilePanelPriv.cpp

    diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp
    index 7a367e3..9ac07c9 100644
    a b TFilePanel::TFilePanel(file_panel_mode mode, BMessenger* target,  
    167167    fSelectionIterator(0),
    168168    fMessage(NULL),
    169169    fHideWhenDone(hideWhenDone),
    170     fIsTrackingMenu(false)
     170    fIsTrackingMenu(false),
     171    fAlwaysEnableDefaultButton(false)
    171172{
    172173    InitIconPreloader();
    173174
    TFilePanel::SetClientObject(BFilePanel* panel)  
    553554
    554555
    555556void
     557TFilePanel::AlwaysEnableDefaultButton()
     558{
     559    fAlwaysEnableDefaultButton = true;
     560
     561    BButton* button = dynamic_cast<BButton*>(FindView("default button"));
     562    if (button != NULL)
     563        button->SetEnabled(true);
     564}
     565
     566
     567void
    556568TFilePanel::AdjustButton()
    557569{
    558570    // adjust button state
    TFilePanel::AdjustButton()  
    613625    }
    614626
    615627    button->SetLabel(buttonText.String());
    616     button->SetEnabled(enabled);
     628    button->SetEnabled(fAlwaysEnableDefaultButton || enabled);
    617629}
    618630
    619631
  • src/kits/tracker/FilePanelPriv.h

    diff --git a/src/kits/tracker/FilePanelPriv.h b/src/kits/tracker/FilePanelPriv.h
    index 22acfd7..99b9150 100644
    a b public:  
    102102
    103103    bool TrackingMenu() const;
    104104
     105    void AlwaysEnableDefaultButton();
     106
    105107protected:
    106108    BPoseView* NewPoseView(Model* model, uint32);
    107109    virtual void Init(const BMessage* message = NULL);
    private:  
    151153    BString fButtonText;
    152154    bool fHideWhenDone;
    153155    bool fIsTrackingMenu;
     156    bool fAlwaysEnableDefaultButton;
    154157
    155158    typedef BContainerWindow _inherited;
    156159};