Commit 60ddd53d authored by claes's avatar claes

Connect function via X selection implemented

parent 0a7e2802
......@@ -156,6 +156,7 @@ struct s_foe_ctx
struct s_widgets widgets ;
int set_focus_disabled;
XtIntervalId focus_timerid;
Atom objid_atom;
};
/* Methods */
......
......@@ -2201,6 +2201,7 @@ static foe_ctx foe_create_window(
(XtCallbackProc)foe_activate_quit, foectx);
}
wow_GetAtoms( foectx->cp.parent_wid, 0, &foectx->objid_atom, 0);
/* SG 09.02.91 a top level should always be realized !
* ML 16.03.94 changed Realize to Popup
......
This diff is collapsed.
......@@ -43,6 +43,7 @@ extern "C" {
#include "wb_wnav.h"
#include "wb_wnav_brow.h"
#include "wb_wnav_item.h"
#include "co_wow.h"
static char null_str[] = "";
......@@ -82,6 +83,7 @@ WAttNav::WAttNav(
wattnav_init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
wow_GetAtoms( form_widget, 0, &objid_atom, 0);
// Create the root item
*w = form_widget;
......@@ -564,6 +566,35 @@ static int wattnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
;
}
break;
case flow_eEvent_MB1DoubleClickCtrl:
switch ( event->object.object_type)
{
case flow_eObjectType_Node:
brow_GetUserData( event->object.object, (void **)&item);
switch( item->type) {
case wnav_eItemType_Attr:
case wnav_eItemType_AttrArrayElem: {
WItemBaseAttr *item_attr = (WItemBaseAttr *)item;
char str[200];
int sts;
if ( item_attr->type_id == pwr_eType_Objid) {
sts = wow_GetSelection( wattnav->form_widget, str, sizeof(str), wattnav->objid_atom);
if ( EVEN(sts))
sts = wow_GetSelection( wattnav->form_widget, str, sizeof(str), XA_STRING);
}
if ( ODD(sts))
wattnav->set_attr_value( item_attr->node, item_attr->attr, str);
break;
}
default:
;
}
break;
default:
;
}
break;
case flow_eEvent_Radiobutton:
{
switch ( event->object.object_type)
......@@ -833,6 +864,8 @@ void WAttNav::enable_events()
wattnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB1DoubleClick, flow_eEventType_CallBack,
wattnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB1DoubleClickCtrl, flow_eEventType_CallBack,
wattnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_SelectClear, flow_eEventType_CallBack,
wattnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_ObjectDeleted, flow_eEventType_CallBack,
......
......@@ -70,6 +70,7 @@ class WAttNav {
void (*change_value_cb)( void *);
wb_eUtility utility;
int displayed;
Atom objid_atom;
void start_trace( pwr_tObjid Objid, char *object_str);
int set_attr_value( brow_tObject node, char *name, char *value_str);
......
......@@ -113,7 +113,12 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
}
case pwr_eType_Char:
{
if ( sscanf( value_str, "%c", (char *)buffer_ptr) != 1)
pwr_tChar c;
if ( strcmp( value_str, "") == 0) {
c = '\0';
memcpy( buffer_ptr, &c, sizeof(c));
}
else if ( sscanf( value_str, "%c", (char *)buffer_ptr) != 1)
return WNAV__INPUT_SYNTAX;
break;
}
......@@ -181,13 +186,17 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
strncpy( (char *)buffer_ptr, value_str, min(attr_size, buff_size));
break;
}
case pwr_eType_ObjDId:
case pwr_eType_Objid:
{
pwr_tObjid objid;
sts = ldh_NameToObjid ( ldhses, &objid, value_str);
if (EVEN(sts)) return WNAV__OBJNOTFOUND;
memcpy( buffer_ptr, &objid, sizeof(objid));
if ( strcmp( value_str, "") == 0)
objid = pwr_cNObjid;
else {
sts = ldh_NameToObjid ( ldhses, &objid, value_str);
if (EVEN(sts)) return WNAV__OBJNOTFOUND;
}
memcpy( buffer_ptr, &objid, sizeof(objid));
break;
}
case pwr_eType_ClassId:
......@@ -365,9 +374,16 @@ void wnav_attrvalue_to_string( ldh_tSesContext ldhses, int type_id, void *value
}
case pwr_eType_Objid:
{
ldh_sVolumeInfo info;
ldh_GetVolumeInfo( ldh_SessionToVol( ldhses), &info);
objid = *(pwr_tObjid *)value_ptr;
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_Hierarchy,
str, sizeof(str), len);
if ( objid.vid == info.Volume)
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_Hierarchy,
str, sizeof(str), len);
else
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_VolPath,
str, sizeof(str), len);
if (EVEN(sts))
{
strcpy( str, "");
......@@ -379,9 +395,15 @@ void wnav_attrvalue_to_string( ldh_tSesContext ldhses, int type_id, void *value
case pwr_eType_AttrRef:
{
char *name_p;
ldh_sVolumeInfo info;
ldh_GetVolumeInfo( ldh_SessionToVol( ldhses), &info);
attrref = (pwr_sAttrRef *) value_ptr;
sts = ldh_AttrRefToName( ldhses, attrref, ldh_eName_Aref, &name_p, len);
if ( attrref->Objid.vid == info.Volume)
sts = ldh_AttrRefToName( ldhses, attrref, ldh_eName_Aref, &name_p, len);
else
sts = ldh_AttrRefToName( ldhses, attrref, ldh_eName_ArefVol, &name_p, len);
if (EVEN(sts))
{
strcpy( str, "");
......@@ -586,6 +608,7 @@ WNav::WNav(
// Create the root item
*w = form_widget;
wow_GetAtoms( form_widget, &graph_atom, &objid_atom, &attrref_atom);
gbl.load_config( this);
if ( root_menu && !ldhses)
......@@ -1154,7 +1177,9 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
if ( wnav->closing_down)
return 1;
wnav->message( ' ', null_str);
if ( event->event != flow_eEvent_ObjectDeleted)
wnav->message( ' ', null_str);
switch ( event->event)
{
case flow_eEvent_Key_Up:
......@@ -1594,6 +1619,52 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
;
}
break;
case flow_eEvent_MB1DoubleClickCtrl:
switch ( event->object.object_type) {
case flow_eObjectType_Node:
brow_GetUserData( event->object.object, (void **)&item);
switch( item->type) {
case wnav_eItemType_Attr:
case wnav_eItemType_AttrArrayElem: {
WItemBaseAttr *item_attr = (WItemBaseAttr *)item;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt = 0;
char str[200];
int size;
if ( item_attr->type_id == pwr_eType_Objid) {
if ( wnav->get_global_select_cb)
sts = (wnav->get_global_select_cb)( wnav->parent_ctx, &sel_list,
&sel_is_attr, &sel_cnt);
if ( sel_cnt > 1) {
wnav->message( 'E', "Select one object");
break;
}
else if ( sel_cnt) {
sts = ldh_ObjidToName( wnav->ldhses, sel_list[0].Objid, ldh_eName_VolPath, str,
sizeof(str), &size);
if ( EVEN(sts)) return sts;
}
else {
sts = wow_GetSelection( wnav->form_widget, str, sizeof(str), wnav->objid_atom);
if ( EVEN(sts))
sts = wow_GetSelection( wnav->form_widget, str, sizeof(str), XA_STRING);
}
if ( ODD(sts))
wnav->set_attr_value( item_attr->node, item_attr->objid, str);
break;
}
}
default:
;
}
break;
default:
;
}
break;
case flow_eEvent_MB1Click:
{
// Select
......@@ -1702,6 +1773,11 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SetSelectInverse( wnav->brow->ctx);
break;
case flow_eEvent_MB3Down:
{
brow_SetClickSensitivity( wnav->brow->ctx, flow_mSensitivity_MB3Press);
break;
}
case flow_eEvent_MB3Press:
{
// Popup menu
......@@ -3018,7 +3094,7 @@ void WNav::enable_events( WNavBrow *brow)
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB1DoubleClick, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB1DoubleClickShiftCtrl, flow_eEventType_CallBack,
brow_EnableEvent( brow->ctx, flow_eEvent_MB1DoubleClickCtrl, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB1Click, flow_eEventType_CallBack,
wnav_brow_cb);
......@@ -3066,6 +3142,8 @@ void WNav::enable_events( WNavBrow *brow)
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB3Press, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_MB3Down, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Map, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Radiobutton, flow_eEventType_CallBack,
......@@ -3153,11 +3231,25 @@ static Boolean wnav_sel_convert_cb(
if (*target == XA_STRING ||
*target == XA_TEXT(flow_Display(wnav->brow_widget)) ||
*target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)))
*target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)) ||
*target == wnav->graph_atom ||
*target == wnav->objid_atom ||
*target == wnav->attrref_atom)
{
brow_tNode *node_list;
int node_count;
wnav_eSelectionFormat format;
if ( *target == wnav->graph_atom)
format = wnav_eSelectionFormat_Graph;
else if ( *target == wnav->objid_atom)
format = wnav_eSelectionFormat_Objid;
else if ( *target == wnav->attrref_atom)
format = wnav_eSelectionFormat_Attrref;
else
format = wnav_eSelectionFormat_User;
brow_GetSelectedNodes( wnav->brow->ctx, &node_list, &node_count);
if ( !node_count)
return FALSE;
......@@ -3179,7 +3271,7 @@ static Boolean wnav_sel_convert_cb(
sts = ldh_NameToAttrRef( wnav->ldhses, attr_str, &attrref);
if ( EVEN(sts)) return FALSE;
sts = (wnav->format_selection_cb)( wnav->parent_ctx, attrref,
value_return, length_return, 0, 1);
value_return, length_return, 0, 1, format);
if ( !sts) return FALSE;
// sts = ldh_AttrRefToName( wnav->ldhses, &attrref, ldh_eName_Aref,
// &name_p, &size);
......@@ -3190,7 +3282,7 @@ static Boolean wnav_sel_convert_cb(
memset( &attrref, 0, sizeof(attrref));
attrref.Objid = item->objid;
sts = (wnav->format_selection_cb)( wnav->parent_ctx, attrref,
value_return, length_return, 0, 0);
value_return, length_return, 0, 0, format);
if ( !sts) return FALSE;
break;
default:
......@@ -3200,7 +3292,10 @@ static Boolean wnav_sel_convert_cb(
}
free( node_list);
if ( *target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)))
if ( *target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)) ||
*target == wnav->graph_atom ||
*target == wnav->objid_atom ||
*target == wnav->attrref_atom)
*type_return = *target;
else
*type_return = XA_STRING;
......
......@@ -59,6 +59,13 @@ extern "C" {
#define wnav_cSymbolFile "pwrp_login:wtt_symbols.pwr_com"
#define WNAV_BROW_MAX 25
typedef enum {
wnav_eSelectionFormat_User,
wnav_eSelectionFormat_Graph,
wnav_eSelectionFormat_Objid,
wnav_eSelectionFormat_Attrref
} wnav_eSelectionFormat;
typedef enum {
wnav_mOpen_All = ~0,
wnav_mOpen_Children = 1 << 0,
......@@ -226,7 +233,7 @@ class WNav {
void (*save_cb)( void *);
void (*revert_cb)( void *, int confirm);
pwr_tBoolean (*format_selection_cb)( void *, pwr_sAttrRef, XtPointer *,
unsigned long *, pwr_tBoolean, pwr_tBoolean);
unsigned long *, pwr_tBoolean, pwr_tBoolean, wnav_eSelectionFormat);
int (*get_global_select_cb)( void *, pwr_sAttrRef **,
int **, int *);
int (*global_unselect_objid_cb)( void *, pwr_tObjid objid);
......@@ -264,6 +271,9 @@ class WNav {
int init_help;
int avoid_deadlock;
XtIntervalId deadlock_timerid;
Atom graph_atom;
Atom objid_atom;
Atom attrref_atom;
int create_object_item( pwr_tObjid objid,
brow_tNode dest, flow_eDest dest_code, void **item,
......
......@@ -33,6 +33,9 @@ extern "C" {
#include <Xm/SeparatoG.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include <X11/Xatom.h>
#include <X11/Xmu/Atoms.h>
#include <X11/Xmu/StdSel.h>
#include "flow.h"
#include "flow_browctx.h"
......@@ -47,6 +50,7 @@ extern "C" {
extern "C" {
#include "co_api.h"
#include "co_wow.h"
}
#define MENU_BAR 1
......@@ -178,8 +182,8 @@ static Widget wnav_build_menu(
return MenuType == MENU_POPUP ? Menu : Cascade;
}
Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid)
Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid,
void (*message_cb)(void *, char, char *))
{
pwr_tStatus sts;
int i;
......@@ -194,6 +198,8 @@ Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid)
if (mcp == NULL)
mcp = (ldh_sMenuCall *)XtCalloc(1, sizeof(ldh_sMenuCall));
mcp->message_cb = message_cb;
if ( cid != pwr_cNCid) {
// Popup in palette
mcp->EditorContext = (void *)wtt;
......@@ -268,6 +274,25 @@ Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid)
mcp->Selected[1].Objid = pwr_cNObjid;
mcp->SelectCount = 1;
}
else {
// Get primary selection
char str[200];
sts = wow_GetSelection( wtt->wnav_form, str, sizeof(str), wtt->wnav->objid_atom);
if ( EVEN(sts))
sts = wow_GetSelection( wtt->wnav_form, str, sizeof(str), XA_STRING);
if ( ODD(sts)) {
sts = ldh_NameToObjid( mcp->PointedSession, &objid, str);
if ( ODD(sts)) {
XtFree( (char *) mcp->Selected);
mcp->Selected = (pwr_sAttrRef *) XtCalloc( 2, sizeof (pwr_sAttrRef));
mcp->SelectedSet = ldh_eMenuSet_Object;
mcp->Selected[0].Objid = objid;
mcp->Selected[1].Objid = pwr_cNObjid;
mcp->SelectCount = 1;
}
}
}
}
}
......
This diff is collapsed.
......@@ -52,6 +52,8 @@ extern "C" {
#include "co_wow.h"
#endif
class WPkg;
typedef enum {
wtt_eNoEdit_Save,
wtt_eNoEdit_Revert,
......@@ -205,7 +207,7 @@ class Wtt {
Widget menu_change_value_w;
Widget menu_edit_w;
uted_ctx utedctx;
void *distrwctx;
WPkg *wpkg;
WNav *input_wnav;
brow_tObject input_node;
pwr_tObjid input_objid;
......@@ -215,7 +217,8 @@ class Wtt {
void (*open_project_volume_cb)(void *ctx);
int (*time_to_exit_cb)(void *ctx);
int set_focus_disabled;
XtIntervalId focus_timerid;
XtIntervalId disfocus_timerid;
XtIntervalId selection_timerid;
int avoid_deadlock;
XtIntervalId deadlock_timerid;
int clock_cursor;
......@@ -253,7 +256,8 @@ class Wtt {
~Wtt();
};
Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid);
Widget wtt_create_popup_menu( Wtt *wtt, pwr_tObjid objid, pwr_tCid cid,
void (*message_cb)(void *, char, char *));
#if defined __cplusplus
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment