Tie selections to the rdf backend and hookup the context menu
git-svn-id: svn://10.0.0.236/trunk@3114 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -152,7 +152,7 @@ XFE_RDFView::XFE_RDFView(XFE_Component *toplevel, Widget parent,
|
||||
: XFE_View(toplevel, parent_view, context)
|
||||
{
|
||||
m_rdfview = NULL;
|
||||
|
||||
m_popup = NULL;
|
||||
|
||||
|
||||
if (!my_commands)
|
||||
@@ -198,13 +198,19 @@ XFE_RDFView::XFE_RDFView(XFE_Component *toplevel, Widget parent,
|
||||
XtAddCallback(m_widget, XmNactivateCallback, activate_cb, this);
|
||||
XtAddCallback(m_widget, XmNresizeCallback, resize_cb, this);
|
||||
XtAddCallback(m_widget, XmNeditCallback, edit_cell_cb, this);
|
||||
XtAddCallback(m_widget, XmNselectCallback, select_cb, this);
|
||||
XtAddCallback(m_widget, XmNdeselectCallback, deselect_cb, this);
|
||||
//XtInsertEventHandler(m_widget, ButtonPressMask, False, button_eh, this, XtListTail);
|
||||
XtAddCallback(m_widget, XmNpopupCallback, popup_cb, this);
|
||||
|
||||
//fe_AddTipStringCallback(outline, XFE_Outliner::tip_cb, this);
|
||||
|
||||
}
|
||||
|
||||
XFE_RDFView::~XFE_RDFView()
|
||||
{
|
||||
//xxx what to delete?
|
||||
if (m_popup)
|
||||
delete m_popup;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +392,51 @@ XFE_RDFView::edit_cell(XtPointer callData)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFView::select_cb(Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
XFE_RDFView *obj = (XFE_RDFView*)clientData;
|
||||
XmLGridCallbackStruct *cbs = (XmLGridCallbackStruct *)callData;
|
||||
|
||||
D(fprintf(stderr,"select_cb(%d)\n",cbs->row););
|
||||
|
||||
obj->select_row(cbs->row);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFView::select_row(int row)
|
||||
{
|
||||
HT_Resource node = HT_GetNthItem(m_rdfview, row);
|
||||
|
||||
if (!node) return;
|
||||
|
||||
HT_SetSelection(node);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFView::deselect_cb(Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
XFE_RDFView *obj = (XFE_RDFView*)clientData;
|
||||
XmLGridCallbackStruct *cbs = (XmLGridCallbackStruct *)callData;
|
||||
|
||||
D(fprintf(stderr,"deselect_cb(%d)\n",cbs->row););
|
||||
|
||||
obj->deselect_row(cbs->row);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFView::deselect_row(int row)
|
||||
{
|
||||
HT_Resource node = HT_GetNthItem(m_rdfview, row);
|
||||
|
||||
if (!node) return;
|
||||
|
||||
HT_SetSelectedState(node,False);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_RDFView::notify(HT_Notification ns, HT_Resource n,
|
||||
@@ -459,32 +510,6 @@ XFE_RDFView::setRDFView(HT_View htview)
|
||||
fill_tree();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_RDFView::doPopup(XEvent *event)
|
||||
{
|
||||
HT_Cursor menu_cursor = HT_NewContextualMenuCursor(m_rdfview,
|
||||
(PRBool)FALSE,
|
||||
(PRBool)FALSE/*bgcmds*/);
|
||||
if (menu_cursor)
|
||||
{
|
||||
// We have a cursor. Attempt to iterate
|
||||
HT_MenuCmd menu_command;
|
||||
while (HT_NextContextMenuItem(menu_cursor, &menu_command))
|
||||
{
|
||||
char* menu_name = HT_GetMenuCmdName(menu_command);
|
||||
if (menu_command == HT_CMD_SEPARATOR)
|
||||
{
|
||||
D(fprintf(stderr,"RDF popup: Seperator\n"););
|
||||
}
|
||||
else
|
||||
{
|
||||
D(fprintf(stderr,"RDF popup: Add command(%s)\n",menu_name););
|
||||
}
|
||||
}
|
||||
HT_DeleteCursor(menu_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFView::fill_tree()
|
||||
{
|
||||
@@ -781,3 +806,66 @@ XFE_RDFView::activate_cb(Widget,
|
||||
obj->activate_row(cbs->row);
|
||||
}
|
||||
|
||||
//
|
||||
// Popup menu stuff
|
||||
//
|
||||
void
|
||||
XFE_RDFView::popup_cb(Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
XFE_RDFView *obj = (XFE_RDFView*)clientData;
|
||||
XmLGridCallbackStruct *cbs = (XmLGridCallbackStruct *)callData;
|
||||
|
||||
if (cbs->rowType != XmCONTENT)
|
||||
return;
|
||||
|
||||
obj->doPopup(cbs->event);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_RDFView::doPopup(XEvent * event)
|
||||
{
|
||||
if (m_popup)
|
||||
{
|
||||
delete m_popup; //destroy the old one first
|
||||
}
|
||||
m_popup = new XFE_RDFPopupMenu("popup",
|
||||
//getFrame(),
|
||||
FE_GetToplevelWidget(),
|
||||
m_rdfview,
|
||||
FALSE, // not isWorkspace
|
||||
FALSE); // no background commands for now
|
||||
|
||||
m_popup->position(event);
|
||||
m_popup->show();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
XFE_RDFPopupMenu::XFE_RDFPopupMenu(String name, Widget parent,
|
||||
HT_View view,
|
||||
Boolean isWorkspace, Boolean isBackground)
|
||||
: XFE_SimplePopupMenu(name, parent)
|
||||
{
|
||||
m_pane = HT_GetPane(view);
|
||||
|
||||
HT_Cursor cursor = HT_NewContextualMenuCursor(view, isWorkspace, isBackground);
|
||||
HT_MenuCmd command;
|
||||
while(HT_NextContextMenuItem(cursor, &command))
|
||||
{
|
||||
if (command == HT_CMD_SEPARATOR)
|
||||
addSeparator();
|
||||
else
|
||||
addPushButton(HT_GetMenuCmdName(command), (XtPointer)command,
|
||||
HT_IsMenuCmdEnabled(m_pane, command));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_RDFPopupMenu::PushButtonActivate(Widget w, XtPointer userData)
|
||||
{
|
||||
HT_DoMenuCmd(m_pane, (HT_MenuCmd)userData);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,20 @@
|
||||
#include "IconGroup.h"
|
||||
#include "htrdf.h"
|
||||
|
||||
//#include "PopupMenu.h"
|
||||
#include "PopupMenu.h"
|
||||
|
||||
class XFE_RDFPopupMenu : public XFE_SimplePopupMenu
|
||||
{
|
||||
public:
|
||||
XFE_RDFPopupMenu(String name, Widget parent,
|
||||
HT_View view,
|
||||
Boolean isWorkspace, Boolean isBackground);
|
||||
|
||||
void PushButtonActivate(Widget w, XtPointer userData);
|
||||
|
||||
protected:
|
||||
HT_Pane m_pane;
|
||||
};
|
||||
|
||||
class XFE_RDFView : public XFE_View
|
||||
{
|
||||
@@ -65,7 +78,7 @@ private:
|
||||
//HT_Pane m_Pane; // The pane that owns this view
|
||||
HT_View m_rdfview; // The view as registered in the hypertree
|
||||
|
||||
//XFE_PopupMenu *m_popup;
|
||||
XFE_RDFPopupMenu *m_popup;
|
||||
|
||||
// icons for use in the bookmark window.
|
||||
static fe_icon bookmark;
|
||||
@@ -89,6 +102,8 @@ private:
|
||||
void activate_row(int row);
|
||||
void resize(XtPointer);
|
||||
void edit_cell(XtPointer);
|
||||
void select_row(int row);
|
||||
void deselect_row(int row);
|
||||
|
||||
static void expand_row_cb(Widget, XtPointer, XtPointer);
|
||||
static void collapse_row_cb(Widget, XtPointer, XtPointer);
|
||||
@@ -96,12 +111,14 @@ private:
|
||||
static void activate_cb(Widget, XtPointer, XtPointer);
|
||||
static void resize_cb(Widget, XtPointer, XtPointer);
|
||||
static void edit_cell_cb(Widget, XtPointer, XtPointer);
|
||||
static void deselect_cb(Widget, XtPointer, XtPointer);
|
||||
static void select_cb(Widget, XtPointer, XtPointer);
|
||||
static void popup_cb(Widget, XtPointer, XtPointer);
|
||||
|
||||
#ifdef NOTYET
|
||||
void dropfunc(Widget dropw, fe_dnd_Event type, fe_dnd_Source *source, XEvent *event);
|
||||
static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
|
||||
fe_dnd_Source *source, XEvent* event);
|
||||
//void doPopup(XEvent *event);
|
||||
|
||||
static fe_icon mailBookmark;
|
||||
static fe_icon newsBookmark;
|
||||
|
||||
Reference in New Issue
Block a user