Kepp track of the ht resource that created the item. Make the urlbar

useable.
This commit is contained in:
ramiro%netscape.com 1998-10-12 10:19:42 +00:00
parent 6f5429efa5
commit 8b0bffc4af
8 changed files with 132 additions and 12 deletions

View File

@ -20,6 +20,7 @@
Created: Stephen Lamm <slamm@netscape.com>, 13-Aug-1998
*/
#include "BrowserFrame.h"
#include "RDFToolbar.h"
#include "Logo.h"
#include "MozillaApp.h"
@ -46,6 +47,7 @@
#define MAX_CHILD_WIDTH 100
#define LOGO_NAME "logo"
extern "C" {
extern RDF_NCVocab gNavCenter;
extern XmString fe_ConvertToXmString(unsigned char *, int16, fe_Font, XmFontType, XmFontList * );
@ -58,6 +60,14 @@ typedef struct _tbarTooltipCBStruct {
} tbarTooltipCBStruct;
//////////////////////////////////////////////////////////////////////////
//
// XFE_RDFToolbar notifications
//
//////////////////////////////////////////////////////////////////////////
const char *
XFE_RDFToolbar::navigateToUrlNotice = "XFE_RDFToolbar::navigateToUrlNotice";
XFE_RDFToolbar::XFE_RDFToolbar(XFE_Frame * frame,
XFE_Toolbox * toolbox,
HT_View view)
@ -587,7 +597,14 @@ XFE_RDFToolbar::createUrlBar(Widget parent,HT_Resource entry)
XFE_ToolbarUrlBar * urlbar = new XFE_ToolbarUrlBar(_frame,
parent,
"urlBar");
entry,
"toolbarUrlBar");
urlbar->registerInterest(XFE_ToolbarUrlBar::urlBarTextActivatedNotice,
this,
urlBarTextActivatedNotice_cb,
(void *) urlbar);
urlbar->initialize();
return urlbar->getBaseWidget();
@ -713,3 +730,43 @@ XFE_RDFToolbar::docStringCB(Widget w, XtPointer client_data, unsigned char reaso
}
}
//////////////////////////////////////////////////////////////////////////
XFE_CALLBACK_DEFN(XFE_RDFToolbar,urlBarTextActivatedNotice)
(XFE_NotificationCenter * /* obj */,
void * clientData,
void * callData)
{
URL_Struct * url = (URL_Struct *) callData;
XFE_ToolbarUrlBar * urlbar = (XFE_ToolbarUrlBar *) clientData;
XP_ASSERT( _frame != NULL );
XP_ASSERT( url != NULL );
XP_ASSERT( urlbar != NULL );
// Ask the frame to get the new url.
// If successfull, update the urlbar
if (_frame->getURL(url) >= 0)
{
// The way this should work is like this:
//
// 1. XFE_BrowserFrame::XFE_BrowserFrame register a newPageLoading
// notification with its XFE_HTMLView
//
// 2. In that notification, the browser frame tells the toolbox
// that urlbars needs to be updated
//
// 3. The toolbox tells the toolbars that urlbar need to be
// updates
//
// 4. The RDF_Toolbar looks for urlbar and it updates the
// urlbar text with the following mehtod.
//
// Because im a lazy bastard, ill do this later and for
// now ill do the following.
//
// Have a nive day -re
//
urlbar->setTextStringFromURL(url);
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -63,6 +63,13 @@ public:
// Override RDFMenuToolbarBase methods
virtual void notify(HT_Resource n, HT_Event whatHappened);
//////////////////////////////////////////////////////////////////////
// //
// XFE_RDFToolbar notifications //
// //
//////////////////////////////////////////////////////////////////////
static const char * navigateToUrlNotice;
protected:
void setRaised (XP_Bool);
void destroyToolbarWidgets ();
@ -98,6 +105,9 @@ private:
// update the icon appearance
XFE_CALLBACK_DECL(updateIconAppearance)
// Url bar activated
XFE_CALLBACK_DECL(urlBarTextActivatedNotice)
};
#endif /*_xfe_rdftoolbar_*/

View File

@ -42,8 +42,9 @@ XFE_ToolbarButton::doCommandNotice = "XFE_ToolbarButton::doCommandNotice";
//////////////////////////////////////////////////////////////////////////
XFE_ToolbarButton::XFE_ToolbarButton(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name) :
XFE_ToolbarItem(frame,parent,name),
XFE_ToolbarItem(frame,parent,htResource,name),
m_command(NULL),
m_callData(NULL)
{

View File

@ -38,6 +38,7 @@ public:
XFE_ToolbarButton(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name);
virtual ~XFE_ToolbarButton();

View File

@ -34,11 +34,13 @@
//////////////////////////////////////////////////////////////////////////
XFE_ToolbarItem::XFE_ToolbarItem(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name) :
XFE_Component(frame),
m_name(NULL),
m_parent(NULL),
m_ancestorFrame(frame)
m_ancestorFrame(frame),
m_htResource(htResource)
{
XP_ASSERT( XfeIsAlive(parent) );
XP_ASSERT( frame != NULL );
@ -52,6 +54,12 @@ XFE_ToolbarItem::~XFE_ToolbarItem()
{
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Accessors
//
//////////////////////////////////////////////////////////////////////////
const String
XFE_ToolbarItem::getName()
{
@ -80,6 +88,11 @@ XFE_ToolbarItem::getAncestorContext()
return getAncestorFrame()->getContext();
}
//////////////////////////////////////////////////////////////////////////
HT_Resource
XFE_ToolbarItem::getHtResource()
{
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_ToolbarItem::setBaseWidget(Widget w)
{

View File

@ -32,6 +32,7 @@
#include "Component.h"
#include "Frame.h"
#include "htrdf.h"
class XFE_ToolbarItem : public XFE_Component
{
@ -39,15 +40,22 @@ public:
XFE_ToolbarItem(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name);
virtual ~XFE_ToolbarItem();
//////////////////////////////////////////////////////////////////////
// //
// Accessors //
// //
//////////////////////////////////////////////////////////////////////
const String getName();
Widget getParent();
XFE_Frame * getAncestorFrame();
MWContext * getAncestorContext();
HT_Resource getHtResource();
//////////////////////////////////////////////////////////////////////
// //
@ -103,6 +111,7 @@ private:
String m_name;
Widget m_parent;
XFE_Frame * m_ancestorFrame;
HT_Resource m_htResource;
//////////////////////////////////////////////////////////////////////
// //

View File

@ -40,16 +40,14 @@
//
//////////////////////////////////////////////////////////////////////////
const char *
XFE_ToolbarUrlBar::doCommandNotice = "XFE_ToolbarUrlBar::doCommandNotice";
const char *
XFE_ToolbarUrlBar::navigateToUrlNotice = "XFE_ToolbarUrlBar::navigateToUrlNotice";
XFE_ToolbarUrlBar::urlBarTextActivatedNotice = "XFE_ToolbarUrlBar::urlBarTextActivatedNotice";
//////////////////////////////////////////////////////////////////////////
XFE_ToolbarUrlBar::XFE_ToolbarUrlBar(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name) :
XFE_ToolbarItem(frame,parent,name),
XFE_ToolbarItem(frame,parent,htResource,name),
m_proxyIcon(NULL),
m_proxyIconDragSite(NULL)
{
@ -78,6 +76,30 @@ XFE_ToolbarUrlBar::initialize()
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Text string methods
//
//////////////////////////////////////////////////////////////////////////
void
XFE_ToolbarUrlBar::setTextStringFromURL(URL_Struct * url)
{
XP_ASSERT( isAlive() );
XP_ASSERT( url != NULL );
// Update the proxy icon
if (m_proxyIconDragSite != NULL)
{
m_proxyIconDragSite->setDragData(url);
}
// Lots of munging and sanitization need to happen here. See
// URLBar.cpp for the insanity
XfeComboBoxSetTextString(m_widget,url->address);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Widget creation interface
@ -172,7 +194,7 @@ XFE_ToolbarUrlBar::textActivate()
URL_Struct * url = NET_CreateURLStruct(text,NET_DONT_RELOAD);
notifyInterested(XFE_ToolbarUrlBar::navigateToUrlNotice,
notifyInterested(XFE_ToolbarUrlBar::urlBarTextActivatedNotice,
(void *) url);
XtFree(text);

View File

@ -41,6 +41,7 @@ public:
XFE_ToolbarUrlBar(XFE_Frame * frame,
Widget parent,
HT_Resource htResource,
const String name);
virtual ~XFE_ToolbarUrlBar();
@ -52,13 +53,19 @@ public:
//////////////////////////////////////////////////////////////////////
virtual void initialize ();
//////////////////////////////////////////////////////////////////////
// //
// Text string methods //
// //
//////////////////////////////////////////////////////////////////////
void setTextStringFromURL(URL_Struct * url);
//////////////////////////////////////////////////////////////////////
// //
// XFE_ToolbarUrlBar notifications //
// //
//////////////////////////////////////////////////////////////////////
static const char * doCommandNotice;
static const char * navigateToUrlNotice;
static const char * urlBarTextActivatedNotice;
protected: