зеркало из https://github.com/mozilla/pjs.git
New and improved filing of bookmarks to Personal Toolbar.
This commit is contained in:
Родитель
f7cb668143
Коммит
4a35dd0727
|
@ -44,6 +44,7 @@
|
|||
#include "prefapi.h"
|
||||
|
||||
#include <Xfe/ToolItem.h>
|
||||
#include <Xfe/ToolBar.h>
|
||||
|
||||
#define DEFAULT_TOOLBAR_FOLDER_NAME "Personal Toolbar Folder"
|
||||
#define MIN_TOOLBAR_HEIGHT 26
|
||||
|
@ -66,6 +67,8 @@ XFE_PersonalToolbar::XFE_PersonalToolbar(MWContext * bookmarkContext,
|
|||
XFE_ToolboxItem(frame,parent_toolbox),
|
||||
XFE_BookmarkBase(bookmarkContext,frame,False,True),
|
||||
m_toolBarFolder(NULL),
|
||||
m_dropTargetItem(NULL),
|
||||
m_dropTargetLocation(XmINDICATOR_LOCATION_NONE),
|
||||
m_popup(NULL)
|
||||
{
|
||||
XP_ASSERT( name != NULL );
|
||||
|
@ -92,7 +95,7 @@ XFE_PersonalToolbar::XFE_PersonalToolbar(MWContext * bookmarkContext,
|
|||
XmNchildForceHeight, True,
|
||||
XmNchildUsePreferredWidth, True,
|
||||
XmNchildUsePreferredHeight, False,
|
||||
XmNminHeight, MIN_TOOLBAR_HEIGHT,
|
||||
// XmNminHeight, MIN_TOOLBAR_HEIGHT,
|
||||
NULL);
|
||||
|
||||
// Create the logo
|
||||
|
@ -420,6 +423,12 @@ XFE_PersonalToolbar::getToolBarWidget()
|
|||
return m_toolBar;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Widget
|
||||
XFE_PersonalToolbar::getLastItem()
|
||||
{
|
||||
return XfeToolBarGetLastItem(m_toolBar);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_PersonalToolbar::setRaised(XP_Bool state)
|
||||
{
|
||||
|
@ -469,7 +478,7 @@ XFE_PersonalToolbar::destroyToolbarWidgets()
|
|||
{
|
||||
XtUnmanageChildren(children,num_children);
|
||||
|
||||
fe_DestroyWidgetTree(children,num_children);
|
||||
XfeDestroyMenuWidgetTree(children,num_children,True);
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -581,6 +590,52 @@ XFE_PersonalToolbar::getToolbarFolderName()
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// DND feedback methods
|
||||
//
|
||||
Widget
|
||||
XFE_PersonalToolbar::getDropTargetItem()
|
||||
{
|
||||
return m_dropTargetItem;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
unsigned char
|
||||
XFE_PersonalToolbar::getDropTargetLocation()
|
||||
{
|
||||
return m_dropTargetLocation;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_PersonalToolbar::setDropTargetItem(Widget item,int x)
|
||||
{
|
||||
assert( XfeIsAlive(item) );
|
||||
|
||||
m_dropTargetItem = item;
|
||||
|
||||
m_dropTargetLocation = XfeToolBarXYToIndicatorLocation(m_toolBar,
|
||||
m_dropTargetItem,
|
||||
x,0);
|
||||
|
||||
int position = XfeChildGetIndex(m_dropTargetItem);
|
||||
|
||||
XtVaSetValues(m_toolBar,
|
||||
XmNindicatorPosition, position,
|
||||
XmNindicatorLocation, m_dropTargetLocation,
|
||||
NULL);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_PersonalToolbar::clearDropTargetItem()
|
||||
{
|
||||
m_dropTargetItem = NULL;
|
||||
|
||||
XtVaSetValues(m_toolBar,
|
||||
XmNindicatorPosition, XmINDICATOR_DONT_SHOW,
|
||||
NULL);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// Popup menu stuff
|
||||
//
|
||||
|
@ -621,3 +676,4 @@ XFE_PersonalToolbar::handlePopup(Widget w,XEvent * event)
|
|||
// BM_Entry * entry;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -50,12 +50,19 @@ public:
|
|||
|
||||
// Access methods
|
||||
Widget getToolBarWidget ();
|
||||
Widget getLastItem ();
|
||||
|
||||
void setRaised (XP_Bool);
|
||||
|
||||
void addEntry (const char * address,
|
||||
const char * title,
|
||||
BM_Date lastAccess);
|
||||
// DND feedback methods
|
||||
Widget getDropTargetItem ();
|
||||
unsigned char getDropTargetLocation ();
|
||||
|
||||
void setDropTargetItem (Widget item,int x);
|
||||
void clearDropTargetItem ();
|
||||
|
||||
static void setToolbarFolder (BM_Entry * entry,
|
||||
XP_Bool notify);
|
||||
|
@ -85,6 +92,11 @@ private:
|
|||
XFE_PersonalDrop * m_dropSite; // The proxy icon drop site
|
||||
BM_Entry * m_toolBarFolder; // The toolbar folder
|
||||
|
||||
// DND feedback members
|
||||
Widget m_dropTargetItem; // The drop target item
|
||||
unsigned char m_dropTargetLocation; // The drop target location
|
||||
int m_dropTargetPosition; // The drop target position
|
||||
|
||||
void destroyToolbarWidgets ();
|
||||
|
||||
void addDefaultToolbarFolder ();
|
||||
|
|
|
@ -188,7 +188,6 @@ XFE_PersonalDrop::XFE_PersonalDrop(Widget dropWidget,
|
|||
XFE_PersonalToolbar * toolbar) :
|
||||
XFE_ToolbarDrop(dropWidget),
|
||||
_personalToolbar(toolbar),
|
||||
_lastRaisedWidget(NULL),
|
||||
_dropWidget(NULL)
|
||||
{
|
||||
}
|
||||
|
@ -221,6 +220,8 @@ XFE_PersonalDrop::addEntry(const char * address,const char * title)
|
|||
|
||||
XP_ASSERT( guessed_title != NULL );
|
||||
|
||||
unsigned char location = _personalToolbar->getDropTargetLocation();
|
||||
|
||||
// If the drop occurred on a cascade item, then we need to waid for
|
||||
// the drop operation to complete before posting the submenu id and
|
||||
// allowing the user to place the new bookmark. This will happen
|
||||
|
@ -230,17 +231,39 @@ XFE_PersonalDrop::addEntry(const char * address,const char * title)
|
|||
{
|
||||
BM_Entry * entry = (BM_Entry *) XfeUserData(_dropWidget);
|
||||
|
||||
// XP_ASSERT( entry != NULL );
|
||||
// XP_ASSERT( BM_IsHeader(entry) );
|
||||
if (entry != NULL)
|
||||
{
|
||||
if (location == XmINDICATOR_LOCATION_BEGINNING)
|
||||
{
|
||||
_personalToolbar->addEntryBefore(address,
|
||||
guessed_title,
|
||||
lastAccess,
|
||||
entry);
|
||||
|
||||
// Clear drop widget so dropComplete() does not get hosed
|
||||
_dropWidget = NULL;
|
||||
}
|
||||
else if (location == XmINDICATOR_LOCATION_END)
|
||||
{
|
||||
_personalToolbar->addEntryAfter(address,
|
||||
guessed_title,
|
||||
lastAccess,
|
||||
entry);
|
||||
|
||||
// Clear drop widget so dropComplete() does not get hosed
|
||||
_dropWidget = NULL;
|
||||
}
|
||||
else if (location == XmINDICATOR_LOCATION_MIDDLE)
|
||||
{
|
||||
// If the folder is empty, then just add the new bm to it
|
||||
if (entry && BM_IsHeader(entry) && !BM_GetChildren(entry))
|
||||
if (BM_IsHeader(entry) && !BM_GetChildren(entry))
|
||||
{
|
||||
_personalToolbar->addEntryToFolder(address,
|
||||
guessed_title,
|
||||
lastAccess,
|
||||
entry);
|
||||
|
||||
// Clear drop widget so dropComplete() does not get hosed
|
||||
_dropWidget = NULL;
|
||||
}
|
||||
// Otherwise need to popup the bookmark placement gui later
|
||||
|
@ -251,6 +274,8 @@ XFE_PersonalDrop::addEntry(const char * address,const char * title)
|
|||
_personalToolbar->setDropLastAccess(lastAccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the drop occurred on a button, then we add the new bookmark
|
||||
// at the position of the previous item
|
||||
else if (XfeIsButton(_dropWidget))
|
||||
|
@ -258,25 +283,36 @@ XFE_PersonalDrop::addEntry(const char * address,const char * title)
|
|||
BM_Entry * entry = (BM_Entry *) XfeUserData(_dropWidget);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
if (location == XmINDICATOR_LOCATION_BEGINNING)
|
||||
{
|
||||
_personalToolbar->addEntryBefore(address,
|
||||
guessed_title,
|
||||
lastAccess,
|
||||
entry);
|
||||
}
|
||||
else if (location == XmINDICATOR_LOCATION_END)
|
||||
{
|
||||
_personalToolbar->addEntryAfter(address,
|
||||
guessed_title,
|
||||
lastAccess,
|
||||
entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
_personalToolbar->addEntry(address,guessed_title,lastAccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the drop widget so that dropComplete() does not get hosed
|
||||
_dropWidget = NULL;
|
||||
}
|
||||
// If the drop occurred anywhere else on the personal toolbar, then
|
||||
// we simple add the new bookmark at the end of the toolbar.
|
||||
else if (XfeIsToolBar(_dropWidget))
|
||||
// Other toolbar items - should not get here
|
||||
else
|
||||
{
|
||||
_personalToolbar->addEntry(address,guessed_title,lastAccess);
|
||||
// Separators (and maybe other items) are going to be a problem
|
||||
// hmmmm...
|
||||
XP_ASSERT( 0 );
|
||||
|
||||
// Clear the drop widget so that dropComplete() does not get hosed
|
||||
_dropWidget = NULL;
|
||||
|
@ -286,6 +322,8 @@ XFE_PersonalDrop::addEntry(const char * address,const char * title)
|
|||
/* virtual */ void
|
||||
XFE_PersonalDrop::dropComplete()
|
||||
{
|
||||
_personalToolbar->clearDropTargetItem();
|
||||
|
||||
// If the drop widget is still alive and kicking, it means that a drop
|
||||
// occurred on a cascade item. Here we deal with this unique case.
|
||||
if (XfeIsAlive(_dropWidget) && XfeIsSensitive(_dropWidget))
|
||||
|
@ -327,59 +365,37 @@ XFE_PersonalDrop::dragIn()
|
|||
/* virtual */ void
|
||||
XFE_PersonalDrop::dragOut()
|
||||
{
|
||||
_dropWidget = NULL;
|
||||
_dropWidget = _personalToolbar->getDropTargetItem();
|
||||
|
||||
if (XfeIsAlive(_lastRaisedWidget))
|
||||
{
|
||||
XtVaSetValues(_lastRaisedWidget,XmNraised,False,NULL);
|
||||
|
||||
_dropWidget = _lastRaisedWidget;
|
||||
}
|
||||
|
||||
_lastRaisedWidget = NULL;
|
||||
_personalToolbar->clearDropTargetItem();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* virtual */ void
|
||||
XFE_PersonalDrop::dragMotion()
|
||||
{
|
||||
Widget raised = getRaisedWidget();
|
||||
|
||||
if (raised == _lastRaisedWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (XfeIsAlive(_lastRaisedWidget))
|
||||
{
|
||||
XtVaSetValues(_lastRaisedWidget,XmNraised,False,NULL);
|
||||
}
|
||||
|
||||
_lastRaisedWidget = raised;
|
||||
|
||||
if (XfeIsAlive(_lastRaisedWidget))
|
||||
{
|
||||
XtVaSetValues(_lastRaisedWidget,XmNraised,True,NULL);
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Widget
|
||||
XFE_PersonalDrop::getRaisedWidget()
|
||||
{
|
||||
Widget raised = XfeDescendantFindByCoordinates(_widget,
|
||||
Widget target = XfeDescendantFindByCoordinates(_widget,
|
||||
_dropEventX,
|
||||
_dropEventY);
|
||||
|
||||
if (!raised)
|
||||
if (XfeIsAlive(target))
|
||||
{
|
||||
raised = _widget;
|
||||
_personalToolbar->setDropTargetItem(target,_dropEventX - XfeX(target));
|
||||
}
|
||||
else
|
||||
{
|
||||
target = _personalToolbar->getLastItem();
|
||||
|
||||
if (XfeIsAlive(target))
|
||||
{
|
||||
_personalToolbar->setDropTargetItem(target,1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
_personalToolbar->clearDropTargetItem();
|
||||
}
|
||||
}
|
||||
|
||||
if (!XfeIsSensitive(raised))
|
||||
{
|
||||
raised = _widget;
|
||||
}
|
||||
|
||||
return raised;
|
||||
_dropWidget = _personalToolbar->getDropTargetItem();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -80,10 +80,7 @@ protected:
|
|||
private:
|
||||
|
||||
XFE_PersonalToolbar * _personalToolbar;
|
||||
Widget _lastRaisedWidget;
|
||||
Widget _dropWidget;
|
||||
|
||||
Widget getRaisedWidget();
|
||||
};
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче