LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-19-2005, 12:06 PM   #1
cbranje
LQ Newbie
 
Registered: Jan 2005
Posts: 14

Rep: Reputation: 0
Angry Segmentation fault on toplevel = XtVaAppInitialize(&app, "Email", NULL, 0, &argc,


toplevel = XtVaAppInitialize(&app, "Email", NULL, 0, &argc, argv, NULL, NULL);

This line is giving my a segmentation fault on the lab computers, not when I log in remotely from home?!?!?!?

Here is my code, sorry for the mess (notice the first line in main that seg faults)

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <stdio.h>
#include <Xm/List.h>
#include <Xm/LabelG.h>
#include <Xm/Label.h>
#include <Xm/RowColumn.h>
#include <Xm/PanedW.h>
#include <Xm/TextF.h>
#include <Xm/PushB.h>
#include <Xm/BulletinB.h>
#include <X11/Shell.h>
#include <string.h>
#include <stddef.h>
#include <sys/types.h>
#include <dirent.h>

#define TRUE 1
#define FALSE 0

//Widget toplevel;
XmStringCharSet charset = XmSTRING_DEFAULT_CHARSET;
XtAppContext app;

XmString lastItemSelected;
XmString label;
Pixel pixel1, pixel2, pixel3;
XColor alloc_color;
Colormap cmap;
Display *display;
Widget toplevel;
Widget rowcol;
Widget rowcol2;
Widget message;
Widget to;
Widget cc;
Widget subject;
Widget send;
Widget receive;
Widget help;
Widget quit;
Widget sendMessage;
Widget compose_shell;
Widget compose;
Widget receive_shell;
Widget folder_shell;
Widget receiveList;
Widget folder;
Widget folderList;
Widget deleteMessageButton;
Widget replyMessageButton;
Widget folders;
Arg args[10];
unsigned short red, green, blue;
int position;
char *messageVal;
char *toVal;
char *ccVal;
char *subjectVal;
char *lastMessage;
char *getlogin();
char *mailLocation;
char *username;
char location[999999];


void add_item();
void search_item();
void drawComposeWin();
void drawReceiveWin();
void drawFoldersWin();
void drawHelpWin();
void sendMsg();
void messageSelected();
void deleteMessage();
void button_help();
void button_send();
void button_receive();
void button_folders();
void button_quit();

int main(argc, argv)
char *argv[];
{




toplevel = XtVaAppInitialize(&app, "Email", NULL, 0, &argc, argv, NULL, NULL);

display = XtDisplay(toplevel);
XtVaGetValues(toplevel, XtNcolormap, &cmap, NULL);

alloc_color.red = red;
alloc_color.blue = blue;
alloc_color.green = green;
alloc_color.flags = DoRed|DoGreen|DoBlue;

XAllocColor(display, cmap, &alloc_color);

red = 0;
blue = 65535;
green = 0;
alloc_color.red = red;
alloc_color.blue = blue;
alloc_color.green = green;
alloc_color.flags = DoRed|DoGreen|DoBlue;
XAllocColor(display, cmap, &alloc_color);
pixel1 = alloc_color.pixel;

red = 65535;
blue = 0;
green = 0;

alloc_color.red = red;
alloc_color.blue = blue;
alloc_color.green = green;
alloc_color.flags = DoRed|DoGreen|DoBlue;

XAllocColor(display, cmap, &alloc_color);
pixel2 = alloc_color.pixel;

red = 0;
blue = 0;
green = 65535;

alloc_color.red = red;
alloc_color.blue = blue;
alloc_color.green = green;
alloc_color.flags = DoRed|DoGreen|DoBlue;

XAllocColor(display, cmap, &alloc_color);
pixel3 = alloc_color.pixel;


rowcol2 = XtVaCreateManagedWidget("rowcol2", xmBulletinBoardWidgetClass, toplevel, XmNbackground, pixel1,NULL);


XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 20);
XtSetArg(args[3], XmNy, 30);
send = XtCreateManagedWidget("Compose", xmPushButtonWidgetClass, rowcol2, args, 4);
XtAddCallback(send, XmNactivateCallback, button_send, NULL);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 80);
XtSetArg(args[3], XmNy, 30);
receive = XtCreateManagedWidget("Receive", xmPushButtonWidgetClass, rowcol2, args, 4);
XtAddCallback(receive, XmNactivateCallback, button_receive, NULL);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 140);
XtSetArg(args[3], XmNy, 30);
folders = XtCreateManagedWidget("Folders", xmPushButtonWidgetClass, rowcol2, args, 4);
XtAddCallback(folders, XmNactivateCallback, button_folders, NULL);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 200);
XtSetArg(args[3], XmNy, 30);
help = XtCreateManagedWidget("Help", xmPushButtonWidgetClass, rowcol2, args, 4);
XtAddCallback(help, XmNactivateCallback, button_help, NULL);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 260);
XtSetArg(args[3], XmNy, 30);
quit = XtCreateManagedWidget("Quit", xmPushButtonWidgetClass, rowcol2, args, 4);
XtAddCallback(quit, XmNactivateCallback, button_quit, NULL);







if ((username = getlogin()) == NULL) {
fprintf(stderr, "Who are you?\n");
exit(1);
}
strcpy(location, "/usr/mail/");
strcat(location, username);


XtRealizeWidget(toplevel);
XtAppMainLoop(app);
return 0;

}


void replyMessage(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
char *replyTo;
char *tempItem;

XtPopdown(receive_shell);
receive_shell = NULL;
drawComposeWin();

XmStringGetLtoR(lastItemSelected, XmSTRING_DEFAULT_CHARSET, &tempItem);
XmTextFieldSetString(to, tempItem);

}
void deleteMessage(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{


int foundMessage = FALSE;
int atEndofMessage = FALSE;
int onDeleteMessage = FALSE;
FILE *fp;
char *temp;
char line[1000000];
char newMailFile[1000000];
int line_length = 9999;
XmString messages[999];
int numOfMessages = 0;
XmString tempXmString[999];
int i;
int num=0;

strcpy(line, "");
strcpy(temp, "");


fp = fopen(location, "r");
while(fgets(temp, 99999999, fp) != NULL ){
if(temp[0] == 'F' && temp[1] == 'r' && temp[2] == 'o' && temp[3] == 'm' && temp[4] != ':' && temp[5] != 'M' && temp[6] != 'A' && temp[7] != 'I' && temp[8] != 'L' && temp[9] != 'E' && temp[10] != 'R'){
numOfMessages++;

}
if(numOfMessages != position){
strcat(newMailFile, temp);
}
}

fclose(fp);


fp = fopen(location, "w");

XmListDeleteAllItems(receiveList);
fclose(fp);
fp = fopen(location, "r");
while( fgets(temp, 99999999, fp) != NULL ){
if(temp[0] == 'F' && temp[1] == 'r' && temp[2] == 'o' && temp[3] == 'm' && temp[4] != ':' && temp[5] != 'M' && temp[6] != 'A' && temp[7] != 'I' && temp[8] != 'L' && temp[9] != 'E' && temp[10] != 'R'){
if(atEndofMessage == FALSE && foundMessage == FALSE){
num++;
numOfMessages++;
foundMessage = TRUE;
atEndofMessage = FALSE;
for(i=5; temp[i] != ' '; i++){
temp[-5+i] = temp[i];

}
temp[i-5] = '\0';


tempXmString[0] = XmStringCreateSimple(temp);
XmListAddItems(receiveList, tempXmString, 1, numOfMessages - 1);

}
else if(foundMessage == TRUE){
atEndofMessage = TRUE;
for(i=5; temp[i] != ' '; i++){
temp[-5+i] = temp[i];

}
temp[i-5] = '\0';

tempXmString[0] = XmStringCreateSimple(temp);
XmListAddItems(receiveList, tempXmString, 1, numOfMessages - 1);
}
}

if(foundMessage == TRUE && atEndofMessage == FALSE){
strcat(line, temp);

}
if(atEndofMessage == TRUE){
strcat(line, "\n------------------------------------------------------------------\n");
strcpy(line, "");
atEndofMessage = FALSE;
strcat(line, temp);
}

}
XmTextSetString(message, "");
fclose(fp);

}

void messageSelected(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmListCallbackStruct *call_data;
{
int foundMessage = FALSE;
int atEndofMessage = FALSE;
FILE *fp;
char temp[100];
char line[1000000];
int line_length = 9999;
XmString messages[999];
int numOfMessages = 0;
int num = 0;
XmString tempXmString[999];
position = call_data->item_position;
lastItemSelected = call_data->item;



strcpy(line, "");
strcpy(temp, "");


fp = fopen(location, "r");
while(fgets(temp, 99999999, fp) != NULL ){
if(temp[0] == 'F' && temp[1] == 'r' && temp[2] == 'o' && temp[3] == 'm' && temp[4] != ':' && temp[5] != 'M' && temp[6] != 'A' && temp[7] != 'I' && temp[8] != 'L' && temp[9] != 'E' && temp[10] != 'R'){

atEndofMessage = TRUE;
foundMessage = FALSE;

}
if(temp[0] == 'X' && temp[1] == '-' && temp[2] == 'U' && temp[3] == 'I'){
fgets(temp, 99999, fp);
if(temp[0] == '\n'){

num++;
numOfMessages++;
foundMessage = TRUE;
atEndofMessage = FALSE;
strcpy(line, "");
}

}
if(temp[0] == 'X' && temp[1] == '-' && temp[2] == 'O' && temp[3] == 'r' && temp[4] == 'c'){
fgets(temp, 99999, fp);
if(temp[0] == '\n'){
num++;
numOfMessages++;

foundMessage = TRUE;
atEndofMessage = FALSE;
strcpy(line, "");
}
}
if(atEndofMessage == FALSE && foundMessage == TRUE){

if((position) == numOfMessages){

XmTextSetString(message, "");
XmTextSetString(message, line);
atEndofMessage = FALSE;

}

}
if(foundMessage == TRUE && atEndofMessage == FALSE){
strcat(line, temp);


}

}
lastMessage = XmTextGetString(message);

fclose(fp);


;
}
void folderSelected(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmListCallbackStruct *call_data;
{
int foundMessage = FALSE;
int atEndofMessage = FALSE;
FILE *fp;
char temp[100];
char line[1000000];
char *tempDirectory;
char *directory;
char *home;
int line_length = 9999;
XmString messages[999];
int numOfMessages = 0;
XmString tempXmString[999];


home = getenv("HOME");
XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &tempDirectory);


XtFree(directory);
XtFree(tempDirectory);


;
}
void button_folders(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
drawFoldersWin();
}
void button_receive(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
drawReceiveWin();
}
void button_send(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
drawComposeWin();
}
void button_help(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
drawHelpWin();
}
void button_quit(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
exit(1);
}
void sendMsg(w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
FILE *fp;
int pid, pipefds[2];
char *username, *getlogin();

XtVaGetValues(message, XmNvalue, &messageVal, NULL);
XtVaGetValues(to, XmNvalue, &toVal, NULL);
XtVaGetValues(cc, XmNvalue, &ccVal, NULL);
XtVaGetValues(subject, XmNvalue, &subjectVal, NULL);


if (pipe(pipefds) < 0) {
perror("pipe");
exit(1);
}

if ((pid = fork()) < 0) {
perror("fork");
exit(1);
}

if (pid == 0) {
close(0);
dup(pipefds[0]);
close(pipefds[0]);
close(pipefds[1]);
execl("/bin/mail", "mail", "-s", subjectVal, toVal, 0);
perror("exec");

}

close(pipefds[0]);


fp = fdopen(pipefds[1], "w");

fprintf(fp, "%s", messageVal);
fclose(fp);

while (wait((int *) 0) != pid);

XtVaSetValues(message, XmNvalue, "", NULL);
XtVaSetValues(to, XmNvalue, "", NULL);
XtVaSetValues(cc, XmNvalue, "", NULL);
XtVaSetValues(subject, XmNvalue, "", NULL);

}
void drawHelpWin(){
int foundMessage = FALSE;
int atEndofMessage = FALSE;
FILE *fp;
char temp[100];
char helpFile[1000000];
int line_length = 9999;
XmString messages[999];
int numOfMessages;
XmString tempXmString[999];
int i;
char home[99999];

XtVaGetValues(toplevel, XtNcolormap, &cmap, NULL);
compose_shell = XtCreatePopupShell("Compose Message Window", transientShellWidgetClass, toplevel, NULL, 0);
compose = XtCreateManagedWidget("compose", xmRowColumnWidgetClass, compose_shell, NULL, 0);
XtVaSetValues(compose, XmNbackground, pixel1, NULL);

rowcol = XtVaCreateWidget("rowcol", xmBulletinBoardWidgetClass, compose, XmNbackground, pixel1, NULL);




label = XmStringCreateSimple("Help:");
XtVaCreateManagedWidget("message_label", xmLabelWidgetClass, rowcol,
XmNx, 0,
XmNy, 10,
XmNlabelString, label,
NULL);

XmStringFree(label);
XtSetArg(args[0], XmNrows, 50);
XtSetArg(args[1], XmNcolumns, 80);
XtSetArg(args[2], XmNeditable, True);
XtSetArg(args[3], XmNeditMode, XmMULTI_LINE_EDIT);
XtSetArg(args[4], XmNx, 0);
XtSetArg(args[5], XmNy, 30);

message = XmCreateScrolledText(rowcol, "message", args, (Cardinal *)6);
XtManageChild(message);

XtVaSetValues(compose_shell,
XmNx, 100,
XmNy, 100,
XmNwidth, 600,
XmNheight, 700,
XmNbackground, pixel1,
NULL);

fp = fopen("./help", "r");
while( fgets(temp, 99999999, fp) != NULL ){
strcat(helpFile, temp);

}
XmTextSetString(message, helpFile);
XtPopup(compose_shell, XtGrabExclusive);
XtManageChild(rowcol);
XtRealizeWidget(compose_shell);
}
void drawComposeWin(){

XtVaGetValues(toplevel, XtNcolormap, &cmap, NULL);
compose_shell = XtCreatePopupShell("Compose Message Window", transientShellWidgetClass, toplevel, NULL, 0);
compose = XtCreateManagedWidget("compose", xmRowColumnWidgetClass, compose_shell, NULL, 0);
XtVaSetValues(compose, XmNbackground, pixel1, NULL);

rowcol = XtVaCreateWidget("rowcol", xmBulletinBoardWidgetClass, compose, XmNbackground, pixel1, NULL);

label = XmStringCreateSimple("To:");
XtVaCreateManagedWidget(
"to",
xmLabelWidgetClass, rowcol,
XmNlabelString, label,
XmNx, 0,
XmNy, 0,
NULL);

XmStringFree(label);

to = XtVaCreateManagedWidget("to",
xmTextFieldWidgetClass, rowcol,
XmNx, 0,
XmNy, 30,
NULL);


label = XmStringCreateSimple("CC:");
XtVaCreateManagedWidget("search_label", xmLabelWidgetClass, rowcol,
XmNlabelString, label,
XmNx, 0,
XmNy, 60,
NULL);
XmStringFree(label);

cc = XtVaCreateManagedWidget("cc",
xmTextFieldWidgetClass, rowcol,
XmNcolumns, 25,
XmNx, 0,
XmNy, 80,
NULL);


label = XmStringCreateSimple("Subject:");
XtVaCreateManagedWidget("search_label", xmLabelWidgetClass, rowcol,
XmNlabelString, label,
XmNx, 0,
XmNy, 110,
NULL);
XmStringFree(label);
subject = XtVaCreateManagedWidget("subject",
xmTextFieldWidgetClass, rowcol,
XmNx, 0,
XmNy, 130,
XmNcolumns, 25,
NULL);



label = XmStringCreateSimple("Message:");
XtVaCreateManagedWidget("message_label", xmLabelWidgetClass, rowcol,
XmNx, 0,
XmNy, 160,
XmNlabelString, label,
NULL);

XmStringFree(label);
XtSetArg(args[0], XmNrows, 30);
XtSetArg(args[1], XmNcolumns, 80);
XtSetArg(args[2], XmNeditable, True);
XtSetArg(args[3], XmNeditMode, XmMULTI_LINE_EDIT);
XtSetArg(args[4], XmNx, 0);
XtSetArg(args[5], XmNy, 180);

message = XmCreateScrolledText(rowcol, "message", args, (Cardinal *)6);
XtManageChild(message);


XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 200);
XtSetArg(args[3], XmNy, 30);

sendMessage = XtCreateManagedWidget("Send", xmPushButtonWidgetClass, rowcol, args, (Cardinal *)4);
XtAddCallback(sendMessage, XmNactivateCallback, sendMsg, NULL);


XtVaSetValues(compose_shell,
XmNx, 100,
XmNy, 100,
XmNwidth, 600,
XmNheight, 700,
XmNbackground, pixel1,
NULL);

XtPopup(compose_shell, XtGrabExclusive);
XtManageChild(rowcol);
XtRealizeWidget(compose_shell);
}
void drawReceiveWin(){

int foundMessage = FALSE;
int atEndofMessage = FALSE;
FILE *fp;
char temp[10000];
char line[1000000];
int line_length = 9999;
XmString messages[999];
int numOfMessages;
XmString tempXmString[999];
int i;
int num=0;

XtVaGetValues(toplevel, XtNcolormap, &cmap, NULL);

receive_shell = XtCreatePopupShell("Receive Mail Window", transientShellWidgetClass, toplevel, NULL, 0);

receive = XtCreateManagedWidget("compose"
, xmRowColumnWidgetClass, receive_shell,
NULL, 0);

XtVaSetValues(receive, XmNbackground, pixel2, NULL);

rowcol = XtVaCreateWidget("rowcol",
xmBulletinBoardWidgetClass, receive,
XmNbackground, pixel2,
NULL);

label = XmStringCreateSimple("Messages: ");
XtVaCreateManagedWidget("messagesLabel", xmLabelWidgetClass, rowcol,
XmNlabelString, label,
XmNx, 0,
XmNy, 0,
NULL);
XmStringFree(label);
label = XmStringCreateSimple("Message Text: ");
XtVaCreateManagedWidget("message_label", xmLabelWidgetClass, rowcol,
XmNx, 220,
XmNy, 0,
XmNlabelString, label,
NULL);
XmStringFree(label);

XtSetArg(args[0], XmNrows, 30);
XtSetArg(args[1], XmNcolumns, 80);
XtSetArg(args[2], XmNeditable, True);
XtSetArg(args[3], XmNeditMode, XmMULTI_LINE_EDIT);
XtSetArg(args[4], XmNx, 220);
XtSetArg(args[5], XmNy, 50);
XtSetArg(args[6], XmNwidth, 300);


message = XmCreateScrolledText(rowcol, "message", args, 7);
XtManageChild(message);

receiveList = XtVaCreateManagedWidget("receiveList",
xmListWidgetClass, rowcol,
XmNx, 0,
XmNy, 50,
XmNwidth, 200,
XmNheight, 500,
XmNlistSizePolicy, XmCONSTANT,
XmNselectionPolicy, XmEXTENDED_SELECT,

NULL);
XtAddCallback(receiveList, XmNextendedSelectionCallback, messageSelected, NULL);
XtAddCallback(receiveList, XmNdefaultActionCallback, messageSelected, NULL);



fp = fopen(location, "r");

while( fgets(temp, 99999999, fp) != NULL ){

if(temp[0] == 'F' && temp[1] == 'r' && temp[2] == 'o' && temp[3] == 'm' && temp[4] != ':' && temp[5] != 'M' && temp[6] != 'A' && temp[7] != 'I' && temp[8] != 'L' && temp[9] != 'E' && temp[10] != 'R'){

if(atEndofMessage == FALSE && foundMessage == FALSE){
num++;
numOfMessages++;
foundMessage = TRUE;
atEndofMessage = FALSE;
for(i=5; temp[i] != ' '; i++){
temp[-5+i] = temp[i];

}
temp[i-5] = '\0';
tempXmString[0] = XmStringCreateSimple(temp);
XmListAddItems(receiveList, tempXmString, 1, numOfMessages - 1);

}
else if(foundMessage == TRUE){
atEndofMessage = TRUE;
for(i=5; temp[i] != ' '; i++){
temp[-5+i] = temp[i];

}
temp[i-5] = '\0';

tempXmString[0] = XmStringCreateSimple(temp);
XmListAddItems(receiveList, tempXmString, 1, numOfMessages - 1);

}
}

if(foundMessage == TRUE && atEndofMessage == FALSE){
strcat(line, temp);

}
if(atEndofMessage == TRUE){

strcat(line, "\n------------------------------------------------------------------\n");

strcpy(line, "");
atEndofMessage = FALSE;
strcat(line, temp);

}


}

fclose(fp);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 525);
XtSetArg(args[3], XmNy, 50);

deleteMessageButton = XtCreateManagedWidget("Delete", xmPushButtonWidgetClass, rowcol, args, (Cardinal *)4);
XtAddCallback(deleteMessageButton, XmNactivateCallback, deleteMessage, NULL);

XtSetArg(args[0], XmNwidth, 50);
XtSetArg(args[1], XmNheight, 30);
XtSetArg(args[2], XmNx, 525);
XtSetArg(args[3], XmNy, 90);

replyMessageButton = XtCreateManagedWidget("Reply", xmPushButtonWidgetClass, rowcol, args, (Cardinal *)4);
XtAddCallback(replyMessageButton, XmNactivateCallback, replyMessage, NULL);
XtVaSetValues(receive_shell,
XmNx, 100,
XmNy, 100,
XmNwidth, 600,
XmNheight, 700,
NULL);
XtPopup(receive_shell, XtGrabExclusive);
XtManageChild(rowcol);
XtRealizeWidget(receive_shell);
}
void drawFoldersWin(){

int foundMessage = FALSE;
int atEndofMessage = FALSE;
char temp[100];
char line[10000];
int line_length = 9999;
XmString messages[999];
int numOfMessages;
XmString tempXmString[999];
int i;
char home[99999]; DIR *dp;
struct dirent *ep;

strcpy(home, getenv("HOME"));



strcat(home, "/mail");
dp = opendir (home);


XtVaGetValues(toplevel, XtNcolormap, &cmap, NULL);

folder_shell = XtCreatePopupShell("Receive Mail Window", transientShellWidgetClass, toplevel, NULL, 0);
XtVaSetValues(folder_shell,
XmNx, 100,
XmNy, 100,
XmNwidth, 750,
XmNheight, 700,
XmNbackground, pixel3,
NULL);

folder = XtCreateManagedWidget("folder"
, xmRowColumnWidgetClass, folder_shell,
NULL, 0);

XtVaSetValues(folder, XmNbackground, pixel3, NULL);

rowcol = XtVaCreateWidget("rowcol",
xmBulletinBoardWidgetClass, folder,
XmNbackground, pixel3,
NULL);

label = XmStringCreateSimple("Folders: ");
XtVaCreateManagedWidget("foldersLabel", xmLabelWidgetClass, rowcol,
XmNlabelString, label,
XmNx, 0,
XmNy, 0,
NULL);
XmStringFree(label);

label = XmStringCreateSimple("Message Text: ");
XtVaCreateManagedWidget("message_label", xmLabelWidgetClass, rowcol,
XmNx, 440,
XmNy, 0,
XmNlabelString, label,
NULL);
XmStringFree(label);

XtSetArg(args[0], XmNrows, 30);
XtSetArg(args[1], XmNcolumns, 40);
XtSetArg(args[2], XmNeditable, True);
XtSetArg(args[3], XmNeditMode, XmMULTI_LINE_EDIT);
XtSetArg(args[4], XmNx, 440);
XtSetArg(args[5], XmNy, 50);

message = XmCreateScrolledText(rowcol, "message", args, (Cardinal *)6);
XtManageChild(message);

folderList = XtVaCreateManagedWidget("folderList",
xmListWidgetClass, rowcol,
XmNx, 0,
XmNy, 50,
XmNwidth, 200,
XmNheight, 500,
XmNlistSizePolicy, XmCONSTANT,
XmNselectionPolicy, XmEXTENDED_SELECT,

NULL);
XtAddCallback(folderList, XmNextendedSelectionCallback, folderSelected, NULL);
XtAddCallback(folderList, XmNdefaultActionCallback, folderSelected, NULL);

if (dp != NULL)
{
while (ep = readdir (dp)){
tempXmString[0] = XmStringCreateSimple(ep->d_name);
XmListAddItems(folderList, tempXmString, 1, numOfMessages - 1);
}
(void) closedir (dp);
}
else{
perror ("Couldn't open the directory");
}


receiveList = XtVaCreateManagedWidget("receiveList",
xmListWidgetClass, rowcol,
XmNx, 225,
XmNy, 50,
XmNwidth, 200,
XmNheight, 500,
XmNlistSizePolicy, XmCONSTANT,
XmNselectionPolicy, XmEXTENDED_SELECT,

NULL);
XtAddCallback(receiveList, XmNextendedSelectionCallback, messageSelected, NULL);
XtAddCallback(receiveList, XmNdefaultActionCallback, messageSelected, NULL);




XtPopup(folder_shell, XtGrabExclusive);
XtManageChild(rowcol);
XtRealizeWidget(folder_shell);


}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GCC Compiling (Linux), "Segmentation Fault" Kenji Miyamoto Programming 2 01-13-2005 01:44 AM
why iam getting problems like "...too many files opened" or "segmentation fault" naren_0101bits Linux - Newbie 2 07-19-2004 12:20 PM
"Segmentation Fault" error message when trying to run Yahoo Messenger on Linux 8.0 niranjanpage Linux - Software 6 10-27-2003 01:21 AM
f-prot anti-virus "Segmentation fault" error and other weird stuff dalek Linux - Software 9 10-22-2003 07:37 PM
CSH: "cmd >& file" or "cmd </dev/null >& file" stefanlasiewski Programming 1 09-08-2003 04:19 PM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration