Ticket #3825: PeopleUrlFix.patch

File PeopleUrlFix.patch, 1.9 KB (added by kitallis, 14 years ago)

This sort of fixes up the verify feature of the URL. Clicking on the "URL" label text will launch the URL inside the field

  • BFSBackup/haiku/haiku/src/apps/people/TTextControl.h

     
    2222        ~TTextControl();
    2323
    2424        virtual void AttachedToWindow(void);
     25        virtual void MouseDown(BPoint);
    2526
    2627        bool Changed(void);
    2728        void Revert(void);
    2829        void Update(void);
     30        void LoadURLField(const char*);
    2931
    3032    private:
    3133        char    *fOriginal;
  • BFSBackup/haiku/haiku/src/apps/people/TTextControl.cpp

     
    1010    This file may be used under the terms of the Be Sample Code License.
    1111*/
    1212
     13#include <Roster.h>
     14#include <StorageKit.h>
     15#include <support/String.h>
     16
    1317#include <string.h>
    1418#include <malloc.h>
    1519#include <Font.h>
     
    5761}
    5862
    5963
     64void
     65TTextControl::MouseDown(BPoint linkagePosition)
     66{
     67    if ((linkagePosition.x > 60 && linkagePosition.x < 85)
     68            && (linkagePosition.y > 5 && linkagePosition.y < 15))
     69        LoadURLField(this->Text());
     70}
     71
     72
    6073bool
    6174TTextControl::Changed(void)
    6275{
     
    7891    fOriginal = (char *)realloc(fOriginal, strlen(Text()) + 1);
    7992    strcpy(fOriginal, Text());
    8093}
     94
     95
     96void
     97TTextControl::LoadURLField(const char *fUrl)
     98{
     99    BString argument(fUrl);
     100   
     101    if (argument.IFindLast("www",3) == 0)
     102        argument.Prepend("http://");
     103       
     104    const char *largs[] = {argument.String(), 0};
     105
     106    if (argument.IFindFirst("http://") == 0) {
     107        BString mimeType = "application/x-vnd.Be.URL.";
     108        mimeType.Append(argument, argument.FindFirst(':'));
     109        if (!BMimeType::IsValid(mimeType.String()))
     110            return;
     111        be_roster->Launch(mimeType.String(), 1, const_cast<char **>(largs));
     112    }
     113}
     114