Ticket #8156: workspaces2.patch

File workspaces2.patch, 5.6 KB (added by rq, 12 years ago)

Alternative patch, also removes any "About" functionality

  • src/apps/workspaces/Workspaces.cpp

    diff --git a/src/apps/workspaces/Workspaces.cpp b/src/apps/workspaces/Workspaces.cpp
    index e3415d0..874e982 100644
    a b  
    1414#include <Alert.h>
    1515#include <Application.h>
    1616#include <Catalog.h>
     17#include <Deskbar.h>
    1718#include <Dragger.h>
    1819#include <Entry.h>
    1920#include <File.h>
     
    4041#define B_TRANSLATE_CONTEXT "Workspaces"
    4142
    4243
     44static const char* kDeskbarItemName = "workspaces";
    4345static const char* kSignature = "application/x-vnd.Be-WORK";
     46static const char* kDeskbarSignature = "application/x-vnd.Be-TSKB";
    4447static const char* kScreenPrefletSignature = "application/x-vnd.Haiku-Screen";
    4548static const char* kOldSettingFile = "Workspace_data";
    4649static const char* kSettingsFile = "Workspaces_settings";
    static const uint32 kMsgToggleTitle = 'tgTt';  
    5053static const uint32 kMsgToggleBorder = 'tgBd';
    5154static const uint32 kMsgToggleAutoRaise = 'tgAR';
    5255static const uint32 kMsgToggleAlwaysOnTop = 'tgAT';
     56static const uint32 kMsgToggleLiveInDeskbar = 'tgDb';
    5357
    5458static const float kScreenBorderOffset = 10.0;
    5559
     60extern "C" _EXPORT BView* instantiate_deskbar_item();
    5661
    5762class WorkspacesSettings {
    5863    public:
    class WorkspacesSettings {  
    8994
    9095class WorkspacesView : public BView {
    9196    public:
    92         WorkspacesView(BRect frame);
     97        WorkspacesView(BRect frame, bool showDragger);
    9398        WorkspacesView(BMessage* archive);
    9499        ~WorkspacesView();
    95100
    class WorkspacesView : public BView {  
    106111        virtual void MouseDown(BPoint where);
    107112
    108113    private:
    109         void _AboutRequested();
    110 
    111114        void _UpdateParentClipping();
    112115        void _ExcludeFromParentClipping();
    113116        void _CleanupParentClipping();
    class WorkspacesApp : public BApplication {  
    142145        WorkspacesApp();
    143146        virtual ~WorkspacesApp();
    144147
    145         virtual void AboutRequested();
    146148        virtual void ArgvReceived(int32 argc, char **argv);
    147149        virtual void ReadyToRun();
    148150
    WorkspacesSettings::SetWindowFrame(BRect frame)  
    331333//  #pragma mark -
    332334
    333335
    334 WorkspacesView::WorkspacesView(BRect frame)
     336WorkspacesView::WorkspacesView(BRect frame, bool showDragger=true)
    335337    :
    336     BView(frame, "workspaces", B_FOLLOW_ALL,
     338    BView(frame, kDeskbarItemName, B_FOLLOW_ALL,
    337339        kWorkspacesViewFlag | B_FRAME_EVENTS),
    338340    fParentWhichDrawsOnChildren(NULL),
    339341    fCurrentFrame(frame)
    340342{
    341     frame.OffsetTo(B_ORIGIN);
    342     frame.top = frame.bottom - 7;
    343     frame.left = frame.right - 7;
    344     BDragger* dragger = new BDragger(frame, this,
    345         B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    346     AddChild(dragger);
     343    if(showDragger) {
     344        frame.OffsetTo(B_ORIGIN);
     345        frame.top = frame.bottom - 7;
     346        frame.left = frame.right - 7;
     347        BDragger* dragger = new BDragger(frame, this,
     348            B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
     349        AddChild(dragger);
     350    }
    347351}
    348352
    349353
    WorkspacesView::Archive(BMessage* archive, bool deep) const  
    391395
    392396
    393397void
    394 WorkspacesView::_AboutRequested()
    395 {
    396     BString text = B_TRANSLATE("Workspaces\n"
    397         "written by %1, and %2.\n\n"
    398         "Copyright %3, Haiku.\n\n"
    399         "Send windows behind using the Option key. "
    400         "Move windows to front using the Control key.\n");
    401     text.ReplaceFirst("%1", "François Revol, Axel Dörfler");
    402     text.ReplaceFirst("%2", "Matt Madia");
    403     text.ReplaceFirst("%3", "2002-2008");
    404        
    405     BAlert *alert = new BAlert("about", text.String(), B_TRANSLATE("OK"));
    406     BTextView *view = alert->TextView();
    407     BFont font;
    408 
    409     view->SetStylable(true);
    410 
    411     view->GetFont(&font);
    412     font.SetSize(18);
    413     font.SetFace(B_BOLD_FACE);
    414     view->SetFontAndColor(0, 10, &font);
    415 
    416     alert->Go();
    417 }
    418 
    419 
    420 void
    421398WorkspacesView::AttachedToWindow()
    422399{
    423400    BView* parent = Parent();
    void  
    490467WorkspacesView::MessageReceived(BMessage* message)
    491468{
    492469    switch (message->what) {
    493         case B_ABOUT_REQUESTED:
    494             _AboutRequested();
    495             break;
    496 
    497470        case kMsgChangeCount:
    498471            be_roster->Launch(kScreenPrefletSignature);
    499472            break;
    WorkspacesView::MouseDown(BPoint where)  
    576549            new BMessage(kMsgToggleAutoRaise)));
    577550        if (window->IsAutoRaising())
    578551            item->SetMarked(true);
     552        if (be_roster->IsRunning(kDeskbarSignature)) {
     553            menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"),
     554            new BMessage(kMsgToggleLiveInDeskbar)));
     555            BDeskbar deskbar;
     556            item->SetMarked(deskbar.HasItem(kDeskbarItemName));
     557        }
    579558
    580559        menu->AddSeparatorItem();
    581         menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces"
    582             B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED)));
    583560        menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
    584561            new BMessage(B_QUIT_REQUESTED)));
    585562        menu->SetTargetForItems(window);
    WorkspacesWindow::MessageReceived(BMessage *message)  
    712689            break;
    713690        }
    714691
    715         case B_ABOUT_REQUESTED:
    716             PostMessage(message, ChildAt(0));
    717             break;
    718 
    719692        case kMsgToggleBorder:
    720693        {
    721694            bool enable = false;
    WorkspacesWindow::MessageReceived(BMessage *message)  
    772745            fSettings->SetAlwaysOnTop(enable);
    773746            break;
    774747        }
     748       
     749        case kMsgToggleLiveInDeskbar:
     750        {
     751            BDeskbar deskbar;
     752            if (deskbar.HasItem (kDeskbarItemName))
     753                deskbar.RemoveItem (kDeskbarItemName);
     754            else {
     755                entry_ref ref;
     756                be_roster->FindApp(kSignature, &ref);
     757                deskbar.AddItem(&ref);
     758            }
     759            break;
     760        }
    775761
    776762        default:
    777763            BWindow::MessageReceived(message);
    WorkspacesApp::~WorkspacesApp()  
    820806
    821807
    822808void
    823 WorkspacesApp::AboutRequested()
    824 {
    825     fWindow->PostMessage(B_ABOUT_REQUESTED);
    826 }
    827 
    828 
    829 void
    830809WorkspacesApp::Usage(const char *programName)
    831810{
    832811    printf(B_TRANSLATE("Usage: %s [options] [workspace]\n"
    WorkspacesApp::ArgvReceived(int32 argc, char **argv)  
    904883}
    905884
    906885
     886BView* instantiate_deskbar_item()
     887{
     888    return new WorkspacesView(BRect (0, 0, 75, 15), false);
     889}
     890
     891
    907892void
    908893WorkspacesApp::ReadyToRun()
    909894{