示例#1
0
文件: Stroke.c 项目: idunham/dtextra
static void 
CompileTranslations(StrokeStatePtr State)
{
	StrokeMapPtr NewMap;
	String StrokeName;
	String ActionName;
	int BytesRead;
	char *tmp;
	int i;

	i = 0;
	tmp = State->translations;
	StrokeName = XtNewString(tmp);
	ActionName = XtNewString(tmp);
	while (strlen(tmp) > 0)
	{
		StrokeName[0] = '\0';
		ActionName[0] = '\0';
		BytesRead = 0;
		sscanf(tmp, "%s %[^, \t]%n%*[, \t\n]%n", StrokeName, ActionName, &BytesRead, &BytesRead);
		NewMap = XtNew(StrokeMap);
		NewMap->Stroke = XtNewString(StrokeName);
		NewMap->Action = XtNewString(ActionName);
		State->Map = (StrokeMapPtr *) XtRealloc((char *)State->Map, (i + 2) * sizeof(StrokeMapPtr));
		State->Map[i] = NewMap;
		State->Map[i + 1] = NULL;
		tmp += BytesRead;
		i++;
	}
	XtFree(StrokeName);
	XtFree(ActionName);
}
示例#2
0
int
xf86renameInput(XF86ConfigPtr config, XF86ConfInputPtr input, char *name)
{
    XF86ConfLayoutPtr lay = config->conf_layout_lst;

    if (config == NULL || input == NULL || name == NULL || *name == '\0')
	return (False);

    while (lay != NULL) {
	XF86ConfInputrefPtr iref = lay->lay_input_lst;

	while (iref != NULL) {
	    if (strcasecmp(input->inp_identifier, iref->iref_inputdev_str) == 0) {
		XtFree(iref->iref_inputdev_str);
		iref->iref_inputdev_str = XtNewString(name);
	    }
	    iref = (XF86ConfInputrefPtr)(iref->list.next);
	}
	lay = (XF86ConfLayoutPtr)(lay->list.next);
    }

    XtFree(input->inp_identifier);
    input->inp_identifier = XtNewString(name);

    return (True);
}
示例#3
0
/*ARGSUSED*/
static void
XawLabelInitialize(Widget request, Widget cnew,
		   ArgList args, Cardinal *num_args)
{
    LabelWidget lw = (LabelWidget)cnew;

    if (!lw->label.font) XtError("Aborting: no font found\n");
    if (lw->simple.international && !lw->label.fontset)
	XtError("Aborting: no fontset found\n");

    if (lw->label.label == NULL)
	lw->label.label = XtNewString(lw->core.name);
    else
	lw->label.label = XtNewString(lw->label.label);

    GetNormalGC(lw);
    GetGrayGC(lw);

    SetTextWidthAndHeight(lw);

    if (XtHeight(lw) == 0)
	XtHeight(lw) = lw->label.label_height + 2 * lw->label.internal_height;

    set_bitmap_info(lw);		/* need core.height */

    if (XtWidth(lw) == 0)		/* need label.lbm_width */
	XtWidth(lw) = lw->label.label_width + 2 * lw->label.internal_width +
		      LEFT_OFFSET(lw);

    lw->label.label_x = lw->label.label_y = 0;
    (*XtClass(cnew)->core_class.resize)((Widget)lw);
}
示例#4
0
/*ARGSUSED*/
static void
UpdateOption(Widget w, XtPointer user_data, XtPointer call_data)
{
/*    xf86removeOption(options, option_str);
    AddOption(w, user_data, call_data);
    UpdateOptionList();*/

    Arg args[1];
    char *nam, *val;
    XF86OptionPtr option;

    XtSetArg(args[0], XtNstring, &nam);
    XtGetValues(name, args, 1);
    XtSetArg(args[0], XtNstring, &val);
    XtGetValues(value, args, 1);
    if ((option = xf86findOption(*options, option_str)) == NULL)
	return;
    XtFree(option->opt_name);
    option->opt_name = option_str = XtNewString(nam);
    XtFree(option->opt_val);
    if (val && strlen(val))
	option->opt_val = XtNewString(val);
    else
	option->opt_val = NULL;

    UpdateOptionList();
    XawListHighlight(list, option_index);
    XtSetArg(args[0], XtNstring, option->opt_name);
    XtSetValues(name, args, 1);
    XtSetArg(args[0], XtNstring, option->opt_val);
    XtSetValues(value, args, 1);

    XtSetSensitive(remov, True);
    XtSetSensitive(update, True);
}
示例#5
0
/*
 * Implementation
 */
static char *
get_os_name(void)
{
#ifdef OS_NAME
    return XtNewString(OS_NAME);
#else
    FILE *f = NULL;

#ifdef USE_UNAME
    struct utsname utss;

    if (uname (&utss) >= 0) {
        char *os_name;
        int len = strlen(utss.sysname) + 1;
#ifndef hpux				/* because of hostname length crock */
        len += 2 + strlen(utss.release);
#endif
        os_name = XtMalloc (len);
        strcpy (os_name, utss.sysname);
#ifndef hpux
        strcat (os_name, " ");
        strcat (os_name, utss.release);
#endif
        return os_name;
    }
#endif

#ifdef X_OS_FILE
    f = fopen(X_OS_FILE, "r");
    if (!f)
#endif
#ifdef MOTD_FILE
        f = fopen(MOTD_FILE, "r");
#endif
    if (f) {
        char motd[512];
        motd[0] = '\0';
        (void) fgets(motd, 511, f);
        fclose(f);
        motd[511] = '\0';
        if (motd[0] != '\0') {
            int len = strlen(motd);
            if (motd[len - 1] == '\n')
                motd[len - 1] = '\0';
            return XtNewString(motd);
        }
    }

#ifdef sun
    return XtNewString("SunOS");
#else
# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix))
    return XtNewString("BSD");
# else
    return NULL;
# endif
#endif

#endif /*OS_NAME*/
}
示例#6
0
/* Function Name:
 *   PrintSetValuesError
 *
 * Description:
 *   Allow the SetValues error to be printed.
 *
 * Arguments:
 *   event - the set values call that caused this event.
 *
 * Returns:
 *   str - a string contining the errors.
 *
 * Calls:
 *   FindNode - utils.c
 *   AddString - utils.c
 */
char
*PrintSetValuesError(Event *event)
{
  char           *errors = NULL;
  WNode          *node;
  int            i;
  SetValuesEvent *sv_event = (SetValuesEvent*)event;
  char           buf[BUFSIZ];


  if (sv_event->num_entries == 0)
    {
      /* "SetValues was Successful." */
      if (global_mode == MODE_BATCHRES)
	{
	  return(NULL);
	}
      else
	{
	  if (res_labels[39])
	    return(XtNewString(res_labels[39]));
	  else
	    return(XtNewString("SetValues was Successful."));
	}
    }

  for (i = 0 ; i < (int)sv_event->num_entries ; i++)
    {
      node = FindNode(global_tree_info->top_node,
		      sv_event->info[i].widgets.ids, 
		      sv_event->info[i].widgets.num_widgets);

      if (node == NULL)
	{
	  if (res_labels[16])
	    {
	      sprintf(buf,
		      res_labels[16]);
	    }
	  else
	    {
	      sprintf(buf,
		      "Editres Internal Error: Unable to FindNode.\n");
	    }
	  AddString(&errors,
		    buf); 
	  continue;
	}   /* if (node == NULL) */

      sprintf(buf,
	      "%s(0x%lx) - %s\n",
	      node->name, node->id,
	      sv_event->info[i].message);
      AddString(&errors,
		buf);
    }   /* for (all selected nodes) */

    return(errors);

}   /* PrintSetValuesError()  */
示例#7
0
void makeObjectButton(AppSpecRec *awi, int objType, char *buffer, unsigned long len)
{
 AppList *applist;
 AppRec *app;
 UserObjectRec *obj = &usrObjects.obj[objType];
 FILE *fo;
 String filename;
 char label[LABELLEN + 3];
 int i, c;

 if (!len)  return;

 if (!(filename = crtObjFileName(awi->win.aw->shell, obj->atom_name)))
     return;

 if (!(fo = fopen(filename, "w")))
     error(awi->win.aw->shell, "Could not open file for writing:", filename);
 else
 {
     if (len != fwrite(buffer, 1, len, fo))
	 error(awi->win.aw->shell, "Error saving dropped data", NULL);
     else
     {
	 applist = (AppList *) XtMalloc(sizeof(AppList));
	 *applist = app = (AppRec *) XtMalloc(sizeof(AppRec));
	 if (strcmp(obj->label, "CONTENTS"))
	     sprintf(label, "<%s>", obj->label);
	 else if (len <= LABELLEN)
	     sprintf(label, "<%s>", buffer);
	 else
	 {
	     strcpy(label, "<");
	     strncpy(&label[1], buffer, LABELLEN - 2);
	     strcpy(&label[LABELLEN - 1], "..>");
	 }
	 i = 0;
	 while (( c = label[i]))
	 {
	     if (c == ':' || c == '\n' || c == '\\')
		 label[i] = '_';
	     i++;
	 }
	 app->name = XtNewString(label);
	 app->directory = XtNewString(resources.obj_dir);
	 app->fname = filename;
	 app->icon = XtNewString(obj->icon);
	 app->push_action = XtNewString(obj->atom_name);
	 app->drop_action = XtNewString("");
	 app->remove_file = True;
	 app->objType = objType;
	 insertNewApp(awi->win.aw, awi->item, applist, 1);
     }
 }
 if (fo)  fclose(fo);
 chdir(user.home);
}
示例#8
0
void fileOpenCb(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
 FileWindowRec *fw;
 FileRec *file;
 int item;
 char path[MAXPATHLEN];
 String *argv, push_action;

 if (!(fw = findFileWidget(w, &item)))  return;
 zzz();
 file = fw->files[item];
 strcpy(path, fw->directory);
 if (path[strlen(path)-1] != '/')  strcat(path, "/");
 strcat(path, file->name);
 if (S_ISDIR(file->stats.st_mode))
 {
     contractPath(path);
     chFileDir(fw, path);
 }
 else if (file->stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
 {
     String arguments = XtNewString(file->name);
     String action = (String) XtMalloc((strlen(path) + 6) * sizeof(char));

     strcat(strcpy(action, "exec "), path);
     argv = makeArgv(action, 1, &arguments);
     executeApplication(user.shell, fw->directory, argv);
     XTFREE(action);
     freeArgv(argv);
 }
 else if (file->type)
 {
     if (*(push_action = file->type->push_action))
     {
	 if (!(strcmp(push_action, "EDIT")))
	     doEdit(fw->directory, file->name);
	 else if (!(strcmp(push_action, "VIEW")))
	     doView(fw->directory, file->name);
	 else if (!(strcmp(push_action, "LOAD")))
	 {
	     zzz();
	     newApplicationWindow(path, NULL);
	     wakeUp();
	 }
	 else
	 {
	     argv = (String *) XtMalloc(sizeof(String));
	     argv[0] = XtNewString(file->name);
	     performAction(fw->shell, file->type->icon_pm.bm, push_action, fw->directory, 1, argv);
	     XTFREE(argv);
	 }
     }
 }
 else doEdit(fw->directory, file->name);
 wakeUp();
}
示例#9
0
/*
 * Uncompress a file and return the new file name, if the file doesn't
 * appear to be compressed or the uncompression fails, the original
 * file name will be returned.  In all cases, the return value is
 * allocated with XtNewString().
 *
 * We use "system()" in here to avoid the hassle of converting the
 * decompression commands from strings to argv's but this means that
 * some kludging is needed to grab the error output.  This would be
 * "cleaner" (in some sense) if pipe/dup2/fork/exec/XtAppAddInput
 * were used instead but sometimes laziness is good.
 */
char *
mgv_unmangle(MGV *m, char *file)
{
#	define  CMD_FMT "%s <%s >%s 2>%s"
	char    *cmd, *out, *tmp, *s;
	int     t, cmd_size;
	MGV_APP *r = mgv_appres(m->main);

	if((t = filetype(file)) == FT_NORM
	|| (tempdir == NULL && !mk_tmp(r->temp_dir)))
		return XtNewString(file);

	if((s = strrchr(file, '/')) == NULL)
		s = file;
	else
		++s;

	out = XtCalloc(strlen(tempdir) + 1 + strlen(s) + 1 + 64 + 1, 1);
	tmp = XtCalloc(strlen(tempdir) + 1 + 64 + 1 + 1, 1);

	sprintf(out, "%s/%s.%ld.%d", tempdir, s,
				(long)XtWindow(m->main), m->inst_num);
	sprintf(tmp, "%s/%ld.%d", tempdir, (long)getpid(), m->inst_num);

	cmd_size = strlen(file) + strlen(out) + strlen(tmp) + sizeof(CMD_FMT);

	switch(t) {
	case FT_GZIP:
		cmd = XtCalloc(cmd_size + strlen(r->gunzip), 1);
		sprintf(cmd, "%s <%s >%s 2>%s", r->gunzip, file, out, tmp);
		break;
	case FT_BZIP:
		cmd = XtCalloc(cmd_size + strlen(r->bunzip), 1);
		sprintf(cmd, "%s <%s >%s 2>%s", r->bunzip, file, out, tmp);
		break;
	default:
		assert("mgv_unmangle(): confused by file type!" != NULL);
		XtFree(out);
		XtFree(tmp);
		return XtNewString(file);
		break;
	}

	errno = 0;
	if(system(cmd) != 0 && errno != 0) {
		XtFree(out);
		out = XtNewString(file);
	}
	showmsg(m, file, &tmp[0]);

	XtFree(tmp);
	XtFree(cmd);

	return out;
#	undef CMD_FMT
}
示例#10
0
void 
TrashHelpRequestCB(
        Widget w,
        XtPointer clientData,
        XtPointer callData )

{
   Arg args[5];
   char *vol;
   char *locId;

   /* Refresh the display */
   XmUpdateDisplay(w);

   /* printf ("topic = %s\n", clientData); */

   /* Check for item help */
   if (strcmp(clientData, HELP_HELP_MODE_STR) == 0)
   {
      if( ! ProcessItemHelp(trashShell) )
      {
        char *tmpStr, *title, *msg;

        tmpStr = GetSharedMessage(ITEM_HELP_ERROR_TITLE);
        title = XtNewString(tmpStr);

        tmpStr = GetSharedMessage( ITEM_HELP_ERROR ),
        msg = XtNewString(tmpStr);

        _DtMessage(trashShell, title, msg, NULL,
                   HelpRequestCB);
        XtFree(title);
        XtFree(msg);
      }
      return;
   }

   /* Special check for 'Using Help'; required different volume */
   locId = (char *)clientData;
   if ((w == *usingHelpTrash) && (strcmp(locId, HELP_HOME_TOPIC) == 0))
      vol = "Help4Help";
   else
      vol = DTFILE_HELP_NAME;

   if (primaryTrashHelpDialog)
   {
      ReusePrimaryHelpWindow(primaryTrashHelpDialog,
                             clientData, vol, NULL, NULL, DtHELP_TYPE_TOPIC);
   }
   else
   {
      /* Create the main help window for this view */
      ShowTrashHelpDialog(trashShell, MAIN_HELP_DIALOG, NULL, clientData, 
                          vol);
   }
}
示例#11
0
文件: Host.c 项目: idunham/dtextra
static Boolean
set_values(Widget old, Widget request, Widget new_w, ArgList args, Cardinal *num_args)
{
    Boolean ReConnect = False;

    /*
       printf("set_values()\n");
     */
    if (Host_Terminator(new_w) == NULL)
    {
	Host_Terminator(new_w) = XtNewString("\r\n");
    }
    if (Host_Name(new_w) == NULL)
    {
	Host_Name(new_w) = XtNewString("localhost");
    }
    if (Host_Port(new_w) == NULL)
    {
	String Name;
	String Class;

	XtGetApplicationNameAndClass(XtDisplay(XtParent(new_w)), &Name, &Class);
	Host_Port(new_w) = XtNewString(Name);
    }
    if (strcmp(Host_Name(old), Host_Name(new_w)) != 0)
    {
	ReConnect = True;
    }
    if (strcmp(Host_Port(old), Host_Port(new_w)) != 0)
    {
	ReConnect = True;
    }
    if (Host_Type(old) != Host_Type(new_w))
    {
	ReConnect = True;
    }
    if (Host_Terminator(new_w) != Host_Terminator(old))
    {
    	XtFree(Host_Terminator(old));
    }
    if (Host_Name(new_w) != Host_Name(old))
    {
    	XtFree(Host_Name(old));
    }
    if (Host_Port(new_w) != Host_Port(old))
    {
    	XtFree(Host_Port(old));
    }
    if (ReConnect)
    {
	Disconnect(new_w);
	Connect(new_w);
    }
    return (False);
}
示例#12
0
static void
_DtCmdInitializeErrorMessages( void )
{

    /*
     * Non-Fatal -> Abort the request
     */
    errorChdir = strdup (((char *)Dt11GETMESSAGE(3, 2, "An attempt to change to the following directory:\n\n  %s\n\nfrom host \"%s\" failed.\n\nCheck the spelling and permissions and make sure the directory exists.")));

    errorSpawn = strdup (((char *)Dt11GETMESSAGE(3, 5, "An attempt to execute the following command on host\n\"%s\" failed:\n\n  %s\n\nCheck that the program exists, has the correct\npermissions and is executable.")));

    errorExec = strdup (((char *)Dt11GETMESSAGE(3, 6, "An attempt to execute the following command failed:\n\n  %s\n\nCheck that the program exists, has the correct\npermissions and is executable.")));

    cmd_Globals.error_terminal = strdup (((char *)Dt11GETMESSAGE(3, 7, "This action cannot be started because the following\nterminal emulator cannot be executed:\n\n  %s\n\nCheck that the program exists, has the correct permissions\nand is executable.  This problem may have occurred because the\nprogram is not in your \"PATH\".")));

    errorLength = strdup (((char *)Dt11GETMESSAGE(3, 9, "The total number of characters in this action exceeds the limit of \"%d\".\n\nYou may need to break the action into more than one action.")));

    errorFork = strdup (((char *)Dt11GETMESSAGE(3, 11, "An attempt to start a new process on host \"%s\" failed.\n\nTo continue, you may need to stop an unneeded process on this host.")));

    errorRequest = strdup (((char *)Dt11GETMESSAGE(3, 17, "This action's WINDOW_TYPE \"%s\" is un-recognized.\n\nThe WINDOW_TYPE should be one of the following:\n\n  %s, %s, %s,\n   %s, %s, or %s\n")));

    cmd_Globals.error_subprocess = strdup (((char *)Dt11GETMESSAGE(3, 18, "This action cannot be started because the DT subprocess program:\n\n   %s\n\ncannot be executed.  Check that the program has the correct\npermissions and is executable.")));

    errorRemoteSubprocess = strdup (((char *)Dt11GETMESSAGE(3, 20, "This action cannot be executed on host \"%s\"\nbecause the following required program either\ndoes not exist or it is not executable:\n\n   %s\n")));

    /*
     * The following errors may occur when a SPC
     * channel is opened.
     */
    errorUnknownHost = XtNewString (((char *)Dt11GETMESSAGE(3, 24, "This action cannot be executed because\nhost \"%s\" cannot be reached.")));

    errorBadConnect = XtNewString (((char *)Dt11GETMESSAGE(3, 25, "This action cannot be executed on host \"%s\" because the\n\"%s\" service is not properly configured on this host.")));

    errorBadService = XtNewString (((char *)Dt11GETMESSAGE(3, 26, "This action cannot be executed because the \"%s\"\nservice is not configured on host \"%s\".")));

    errorRegisterHandshake = XtNewString (((char *)Dt11GETMESSAGE(3, 27, "This action cannot be executed on host \"%s\" because user\n\"%s\" has a user id of \"%d\" on host \"%s\" and this does\nnot match the username and user id on the action\ninvocation host \"%s\".")));

    errorRegisterUsername = XtNewString (((char *)Dt11GETMESSAGE(3, 28, "This action cannot be executed on host \"%s\" because\nuser \"%s\" does not have an account on this host.")));

    errorRegisterNetrc = XtNewString (((char *)Dt11GETMESSAGE(3, 29, "This action cannot be executed on host \"%s\" because\na pathname to the authentication file cannot be created.")));

    errorRegisterOpen = XtNewString (((char *)Dt11GETMESSAGE(3, 30, "This action cannot be executed on host \"%s\" because\nthe authentication file on this host cannot be opened.\n\nThis may be caused by your network home not being\nproperly configured.")));

    errorEnvTooBig = XtNewString (((char *)Dt11GETMESSAGE(3, 31, "This action cannot be executed on host \"%s\" because\nthe environment exceeds \"%d\" bytes.")));

    errorInetSecurity = XtNewString (((char *)Dt11GETMESSAGE(3, 32, "This action cannot be executed on host \"%s\" because\nhost \"%s\" is not authorized to use the \"%s\" service.\n\nTo fix this, add host \"%s\" to the \"%s\" service\nentry in file \"%s\" on host \"%s\".")));

    /*
     * Do not post a dialog, write to the error log file only.
     */

    errorSpcTerminator = strdup (((char *)Dt11GETMESSAGE(3, 15, "An attempt to register the output log from a remote host failed.\n\nTo continue, you may need to stop an existing process.")));

    successHost = strdup (((char *)Dt11GETMESSAGE(3, 21, "The action \"%s\" was successfully executed on host \"%s\".")));

    cmd_Globals.error_directory_name_map = strdup (((char *)Dt11GETMESSAGE(3, 22, "The directory \"%s\" on host \"%s\"\ncould not be converted to a network path.\n(%s)")));

}
示例#13
0
static void
QueueRequest (
    SPC_Channel_Ptr channel,
    char *context,
    char *execHost,
    char *execString,
    char **argv,
    int  winType,
    unsigned long requestNum,
    DtSvcMsgContext replyContext,
    DtCmdInvExecuteProc success_proc,
    void *success_data,
    DtCmdInvExecuteProc failure_proc,
    void *failure_data)

{
    Cmd_RequestQueue *pNode;
    Cmd_RequestQueue *pNewNode;

    pNewNode = (Cmd_RequestQueue *) XtMalloc (sizeof (Cmd_RequestQueue));

    pNewNode->next = (Cmd_RequestQueue *) NULL;
    pNewNode->channel = channel;
    pNewNode->context = XtNewString (context);
    pNewNode->exec_host = XtNewString (execHost);
    pNewNode->exec_string = XtNewString (execString);
    pNewNode->argv = argv;
    pNewNode->winType = winType;
    pNewNode->request_num = requestNum;
    if (replyContext == NULL)
        pNewNode->replyContext = NULL;
    else
        pNewNode->replyContext = replyContext;
    pNewNode->success_proc = success_proc;
    pNewNode->success_data = success_data;
    pNewNode->failure_proc = failure_proc;
    pNewNode->failure_data = failure_data;

    if (requestQueue == NULL)
    {
        requestQueue = pNewNode;
        return;
    }

    /*
     * Find the End Of the Queue and link in the NewNode.
     */
    for (pNode = requestQueue; pNode->next != NULL; pNode = pNode->next);

    pNode->next = pNewNode;

}
示例#14
0
int dupObject(Widget shell, AppRec *dest, AppRec *src)
{
 FILE *fin, *fout;
 char buffer[BUFSIZ];
 size_t nr;

 if (chdir(src->directory))
     return -1;
 if (!(fin = fopen(src->fname, "r")))
 {
     chdir(user.home);
     return -1;
 }
 chdir(user.home);
 if (!(dest->fname = crtObjFileName(shell, usrObjects.obj[src->objType].atom_name)))
 {
     fclose(fin);
     return -1;
 }
 if (!(fout = fopen(dest->fname, "w")))
 {
     XTFREE(dest->fname);
     fclose(fin);
     return -1;
 }
 do
 {
     nr = fread(buffer, 1, BUFSIZ, fin);
     if (nr != fwrite(buffer, 1, nr, fout))
     {
	 fclose(fin);
	 fclose(fout);
	 chdir(src->directory);
	 unlink(dest->fname);
	 chdir(user.home);
	 XTFREE(dest->fname);
	 return -1;
     }
 } while (nr);
 fclose(fin);
 fclose(fout);
 dest->name = XtNewString(src->name);
 dest->directory = XtNewString(src->directory);
 dest->icon = XtNewString(src->icon);
 dest->push_action = XtNewString(src->push_action);
 dest->drop_action = XtNewString(src->drop_action);
 dest->objType = src->objType;
 dest->remove_file = True;
 return 0;
}
示例#15
0
static Boolean
IsMenuWidget(
   Widget w,
   FileMgrRec * fileMgrRec,
   FileMgrData * fileMgrData,
   String * aName,
   String * ftName )

{
   int i;
   CompositeWidget action_pane = (CompositeWidget)fileMgrRec->action_pane;
   String actionName;
   Arg args[2];

   if (action_pane == NULL)
      return(False);

   /* First, check if this is a menubar item */
   for (i = 0; i < action_pane->composite.num_children; i++)
   {
      if (w == action_pane->composite.children[i])
      {
         XtSetArg(args[0], XmNuserData, &actionName);
         XtGetValues(w, args, 1);
         *aName = XtNewString(actionName);

         /* Get the filetype from the active item */
         *ftName = XtNewString(
                     fileMgrData->selection_list[0]->file_data->logical_type);
         return (True);
      }
   }

   /* Secondly, check if this is a fileMgr popup item */
   if (XtParent(w) == fileMgrPopup.menu)
   {
      XtSetArg(args[0], XmNuserData, &actionName);
      XtGetValues(w, args, 1);
      *aName = XtNewString(actionName);

      /* Get the filetype from the active item */
      *ftName = XtNewString(
                  fileMgrData->popup_menu_icon->file_data->logical_type);
      fileMgrData->popup_menu_icon = NULL;
      return (True);
   }

   /* This was not a menu item */
   return(False);
}
示例#16
0
Bool
XawAddPixmapLoader(String type, String ext, XawPixmapLoader loader)
{
  XawPixmapLoaderInfo *info;
  int i;

  if (!loader)
    return (False);

  i = _XawFindPixmapLoaderIndex(type, ext);

  if (i >= 0)
    {
      loader_info[i]->loader = loader;
      if (loader_info[i]->type)
	XtFree(loader_info[i]->type);
      if (loader_info[i]->ext)
	XtFree(loader_info[i]->ext);
      loader_info[i]->type = type ? XtNewString(type) : NULL;
      loader_info[i]->ext = ext ? XtNewString(ext) : NULL;
      return (True);
    }

  if ((info = (XawPixmapLoaderInfo *)XtMalloc(sizeof(XawPixmapLoaderInfo)))
      == NULL)
    return (False);

  info->loader = loader;
  info->type = type ? XtNewString(type) : NULL;
  info->ext = ext ? XtNewString(ext) : NULL;

  if (!loader_info)
    {
      num_loader_info = 1;
      loader_info = (XawPixmapLoaderInfo**)
	XtMalloc(sizeof(XawPixmapLoaderInfo*));
    }
  else
    {
      ++num_loader_info;
      loader_info = (XawPixmapLoaderInfo**)
	XtRealloc((char *)loader_info,
		  sizeof(XawPixmapLoaderInfo) * num_loader_info);
    }
  loader_info[num_loader_info - 1] = info;

  return (True);
}
示例#17
0
/*ARGSUSED*/
static void
SelectModuleCallback(Widget w, XtPointer user_data, XtPointer call_data)
{
    xf86cfgModuleOptions *mod = module_options;
    XawListReturnStruct *info = (XawListReturnStruct *)call_data;

    while (mod) {
	if (strcmp(mod->name, info->string) == 0)
	    break;
	mod = mod->next;
    }

    if (mod) {
	Arg args[2];
	char **list = NULL, **old;
	OptionInfoPtr opts = mod->option;
	int num = 0, oldnum;

	module_sel = mod->name;
	XtSetArg(args[0], XtNlist, &old);
	XtSetArg(args[1], XtNnumberStrings, &oldnum);
	XtGetValues(optList, args, 2);
	while (opts && opts->name) {
	    ++num;
	    list = (char**)XtRealloc((XtPointer)list, sizeof(char*) * num);
	    list[num - 1] = XtNewString(opts->name);
	    ++opts;
	}
	if (num == 0) {
	    list = (char**)XtMalloc(sizeof(char*));
	    list[0] = XtNewString("");
	    num = 1;
	}
	XtSetArg(args[0], XtNlist, list);
	XtSetArg(args[1], XtNnumberStrings, num);
	XtSetValues(optList, args, 2);
	while (--oldnum >= 0)
	    XtFree(old[oldnum]);
	XtFree((XtPointer)old);

	XtVaSetValues(desc, XtNstring, "", NULL);
	XawListUnhighlight(optList);

	/* force relayout */
	XtUnmanageChild(optList);
	XtManageChild(optList);
    }
}
示例#18
0
文件: Xmos.c 项目: att/uwin
static String
convertTwiddle(char *dir)
{
    String ptr, ptr1;
    String newdir, home;

    for (ptr = dir; *ptr && isspace(*ptr); ptr++)
    {
    }
    ptr++;			/* to get by twiddle */

    ptr1 = strchr(ptr, '/');
    if (ptr == ptr1)
    {
	home = XtNewString(_XmOSGetHomeDirName());
    }
    else
    {
	String name, ptr2;
#if defined(HAVE_GETPWNAM)
	struct passwd *pw;
#endif

    	name = XtNewString(ptr);
      ptr2=strchr(name, '/');
      if (ptr2)
         *ptr2='\0';
#if defined(HAVE_GETPWNAM)
    	pw = getpwnam(name);
    	if (pw)
    	{
	    home = XtNewString(pw->pw_dir);
    	}
    	else
#endif
    	{
	    home = XtNewString("/");
    	}
    	XtFree(name);
    }
    newdir = XtMalloc(strlen(home) + strlen(ptr1) + 1);
    strcpy(newdir, home);
    strcat(newdir, ptr1);
    
    XtFree(home);

    return newdir;
}
示例#19
0
static void
UpdateOptionList(void)
{
    Arg args[2];
    char **ops, **oldops;
    int nops, oldnops;
    XF86OptionPtr opt;

    ops = NULL;
    nops = 0;
    XawListUnhighlight(list);
    XtSetArg(args[0], XtNlist, &oldops);
    XtSetArg(args[1], XtNnumberStrings, &oldnops);
    XtGetValues(list, args, 2);
    opt = *options;
    while (opt != NULL) {
	if (nops % 16 == 0)
	    ops = (char**)XtRealloc((XtPointer)ops, (nops + 16) *
				    sizeof(char*));
	ops[nops++] = XtNewString(opt->opt_name);
	opt = (XF86OptionPtr)(opt->list.next);
    }
    if (nops == 0) {
	ops = (char**)XtMalloc(sizeof(char*));
	ops[0] = XtNewString("");
	nops = 1;
    }
    XtSetArg(args[0], XtNlist, ops);
    XtSetArg(args[1], XtNnumberStrings, nops);
    XtSetValues(list, args, 2);
    if (oldnops > 0 &&
	(oldnops != 1 || XtName(list) != oldops[0])) {
	while (--oldnops >= 0)
	    XtFree(oldops[oldnops]);
	XtFree((XtPointer)oldops);
    }

    XtSetArg(args[0], XtNstring, "");
    XtSetValues(name, args, 1);
    XtSetValues(value, args, 1);

    /* force relayout */
    XtUnmanageChild(list);
    XtManageChild(list);

    XtSetSensitive(remov, False);
    XtSetSensitive(update, False);
}
示例#20
0
static void ChildPrintToFile(String display_name, 
		      XPContext pcontext,
		      FILE *file,
		      char *file_name,
		      int pipe,
		      String application_name, 
		      String application_class)
{
  FileDescRec *file_desc;
  XtAppContext app_context;
  int argc = 0;
  String argv[] = { NULL };
  Display *display;

  file_desc = (FileDescRec *) XtMalloc(sizeof(FileDescRec));
  file_desc->file_name = XtNewString(file_name);
  file_desc->file = file;
  file_desc->pipe = pipe;

  app_context = XtCreateApplicationContext();
  if ((display = XtOpenDisplay(app_context, display_name, 
			       application_name, application_class,
			       NULL, 0, &argc, argv)) == NULL) {
    _exit(1);
  }

  XpGetDocumentData(display, pcontext,
		    PrintToFileProc, FinishProc, 
		    (XPointer) file_desc);

  XtAppMainLoop(app_context);

  _exit(0);
}
示例#21
0
static void
ChooseSessionFailSafeXtProc(Widget w, XtPointer client_data, 
			    XtPointer callData)
{
    /*
     * Pop down choice of sessions, and start the fail safe session.
     */

    CheckDeleteCancel ();
    CheckBreakLockCancel ();

    XtPopdown (chooseSessionPopup);

    if (session_name)
	XtFree (session_name);

    session_name = XtNewString (FAILSAFE_SESSION_NAME);

    FreeSessionNames (sessionNameCount,
	sessionNamesShort, sessionNamesLong, sessionsLocked);


    /*
     * We don't need to check return value of StartSession in this case,
     * because we are using the default session, and StartSession will
     * not try to lock the session at this time.  It will try to lock
     * it as soon as the user gives the session a name.
     */

    StartSession (session_name,
	True /* Use ~/.xsmstartup if found, else system.xsm */);
}
示例#22
0
void  ui_edit_newSite (Widget w, struct SimpleListType *listDescriptorPtr, 
     caddr_t call)

{
    ui_xStringFromAsciiWidget(ui_edit_siteNameWidget, ui_edit_siteName, 
			      MAX_NAME_LENGTH);
    ui_correctName(ui_edit_siteName);
    if ((strlen(ui_edit_siteName) == 0) OR (strlen(ui_edit_siteFuncName) == 0)) {
	ui_confirmOk("Invalid name or function!");
	return;
    }

    ui_checkError(krui_createSiteTableEntry(ui_edit_siteName, 
					    ui_edit_siteFuncName));
    if (ui_kernelError >= 0) {
	if (ui_list_noOfSites++ == 0) {
	    /* first entry is "*** no sites ***" */
	    free((listDescriptorPtr->listPtr)[0]);
	    (listDescriptorPtr->listPtr)[0] = 
		XtNewString(ui_edit_siteName);
	} else
	    ui_xAddListEntry(listDescriptorPtr, ui_edit_siteName);
	XawListChange(listDescriptorPtr->listWidget, listDescriptorPtr->listPtr, 
		      listDescriptorPtr->noOfItems, 0, True);
    }
}
示例#23
0
/*
 * Inserts a string into correct sorted position in a list.
 */
    static void
add_to_list(char **buf, char *item, int *count)
{
    int	i;
    int j;

    if (*count == MAX_ENTRIES_IN_LIST)
	return;

    /* avoid duplication */
    for (i = 0; i < *count; ++i)
    {
	if (!strcmp(buf[i], item))
	    return;
    }

    /* find order place, but make sure that wild card comes first */
    if (!strcmp(item, wild))
	i = 0;
    else
	for (i = 0; i < *count; ++i)
	    if (strcmp(buf[i], item) > 0 && strcmp(buf[i], wild))
		break;

    /* now insert the item */
    for (j = *count; j > i; --j)
	buf[j] = buf[j-1];
    buf[i] = XtNewString(item);

    ++(*count);
}
示例#24
0
static void placeDTIcon(DTIconRec *dticon)
{
 Dimension width;
 XmString labelstr;
 String icon_pos;

 if (x0 == -1)
 {
     /* Seems to be necessary at least under HP-UX: */
     icon_pos = XtNewString(resources.icon_pos);
     sscanf(icon_pos, "%d%d", &x0, &y0);
     XTFREE(icon_pos);
     if (x0 < 0)  x0 += winInfo.rootWidth - DTICONWIDTH;
     if (y0 < 0)  y0 += winInfo.rootHeight - DTICONHEIGHT;
 }
 dticon->x = x0;
 dticon->y = y0;
 dticon->width = dticon->app.icon_pm.width;
 dticon->height = dticon->app.icon_pm.height;
 labelstr = XmStringCreateLocalized(dticon->app.name);
 width = XmStringWidth((XmFontList) resources.icon_font, labelstr) + 2;
 dticon->height += XmStringWidth((XmFontList) resources.icon_font, labelstr) + 4;
 if (width > dticon->width)
     dticon->width = width;
 dticon->height += 2 * MARGIN;
 dticon->width += 2 * MARGIN;
 while (!tryPosition(dticon));
 dticon->x += MARGIN;
 dticon->y += MARGIN;
}
示例#25
0
void  ui_edit_ftypeDeleteSite (Widget w, 
	struct SimpleListType *listDescriptorPtr, caddr_t call)

{
    XawListReturnStruct   *listStructPtr;
    int                   i;

    listStructPtr = XawListShowCurrent(listDescriptorPtr->listWidget);

    if ((listStructPtr->list_index == XAW_LIST_NONE) OR
	(ui_list_noOfFTypeSites <= 0))
	return; /* no site selected */

    /* remove this entry from the array */
    free((listDescriptorPtr->listPtr)[listStructPtr->list_index]);
    for (i = listStructPtr->list_index + 1; 
	 i <= listDescriptorPtr->noOfItems - 1; i++)
	(listDescriptorPtr->listPtr)[i-1] = (listDescriptorPtr->listPtr)[i];
    if (ui_list_noOfFTypeSites-- == 1) { /* last site deleted */
	(listDescriptorPtr->listPtr)[0] = XtNewString("*** no sites");
    XawListChange(listDescriptorPtr->listWidget, 
		  listDescriptorPtr->listPtr, 
		  1, 0, True);
    } else
	XawListChange(listDescriptorPtr->listWidget, 
		      listDescriptorPtr->listPtr, 
		      --listDescriptorPtr->noOfItems, 0, True);
}
示例#26
0
XmTab
XmTabCreate(float value,
	    unsigned char units,
	    XmOffsetModel offset_model,
	    unsigned char alignment,
	    char *decimal)
{
  XmTab 	tab;

  _XmProcessLock();
  tab = (XmTab)XtMalloc(sizeof(_XmTabRec));
  
  _XmTabMark(tab) = FALSE;
  if (value >= 0) 
    {
      _XmTabValue(tab) = value;
    }
  else 
    {
      _XmTabValue(tab) = 0.0;
      XmeWarning(NULL, NEGATIVE_VALUE_MSG);
    }
  _XmTabUnits(tab) = units;
  _XmTabModel(tab) = offset_model;
  _XmTabAlign(tab) = alignment;
  _XmTabDecimal(tab) = XtNewString(decimal);

  _XmProcessUnlock();
  return(tab);
}
示例#27
0
文件: lock.c 项目: aosm/X11
char *
GetLockId(char *session_name)
{
    char *path;
    FILE *fp;
    char lock_file[PATH_MAX];
    char buf[256];
    char *ret;

    path = GetPath ();

    sprintf (lock_file, "%s/.XSMlock-%s", path, session_name);

    if ((fp = fopen (lock_file, "r")) == NULL)
    {
	return (NULL);
    }

    buf[0] = '\0';
    fscanf (fp, "%s\n", buf);
    ret = XtNewString (buf);

    fclose (fp);

    return (ret);
}
示例#28
0
void selectBlockCb(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
 FileWindowRec *fw;
 SelectionRec *sel;
 int i, first, last, k;

 if ((fw = findFileWidget(w, &i)))
 {
     sel = &fw->selected;
     if (sel->n_sel == 1)
     {
	 if ((k = sel->file[0].nr) < i)
	 {
	     first = k + 1;  last = i;
	 }
	 else
	 {
	     first = i;  last = k - 1;
	 }
	 for (i = first; i <= last; i++)
	 {
	     if ((k = sel->n_sel++) >= sel->n_alloc)
		 sel->file = (FileSpec *) XTREALLOC(sel->file, (sel->n_alloc += 10) * sizeof(FileSpec));
	     sel->file[k].nr = i;
	     sel->file[k].name = XtNewString(fw->files[i]->name);
	     sel->n_bytes += fw->files[i]->stats.st_size;
	     XtVaSetValues(fw->files[i]->form, XmNborderColor, resources.select_color, NULL);
	 }
	 updateStatus(fw);
     }
 }
}
示例#29
0
void selectAdd(FileWindowRec *fw, String pattern, Boolean replace_sel)
{
 SelectionRec *sel = &fw->selected;
 FileRec *file;
 int i, j;
 Boolean changed = False;

 if (replace_sel && fw->selected.n_sel)
 {
     unselectAll(fw);
     changed = True;
 }

 for (i=0; i < fw->n_files; i++)
 {
     if ((replace_sel || getSelNr(fw, i) == -1) && fnmultimatch(pattern, (file = fw->files[i])->name))
     {
	 changed = True;
	 if ((j = sel->n_sel++) >= sel->n_alloc)
	     sel->file = (FileSpec *) XTREALLOC(sel->file, (sel->n_alloc += 10) * sizeof(FileSpec));
	 sel->file[j].nr = i;
	 sel->file[j].name = XtNewString(file->name);
	 sel->n_bytes += file->stats.st_size;
	 XtVaSetValues(file->form, XmNborderColor, resources.select_color, NULL);
     }
 }
 if (changed)  updateStatus(fw);
 XTFREE(pattern);
}
示例#30
0
void renameFileProc(XtPointer fsel, int conf)
{
 SelFileNamesRec *fnames = (SelFileNamesRec *) fsel;
 struct stat stats;
 char to[MAXPATHLEN];

 if (conf != YES)
 {
     freeSelFiles(fnames);
     return;
 }
 if (chdir(fnames->directory))
 {
     sysError(fnames->shell, "System error:");
     freeSelFiles(fnames);
     return;
 }
 chdir(user.home);
 if (fnames->target[0] != '/' && fnames->target[0] != '~' && fnames->target != 0)
 {
     strcpy(to, fnames->directory);
     if (to[strlen(to)-1] != '/')  strcat(to, "/");
 }
 else to[0] = 0;
 strcat(to, fnames->target);
 fnexpand(to);
 XTFREE(fnames->target);
 fnames->target = XtNewString(to);
 if (!(stat(to, &stats)) && S_ISDIR(stats.st_mode))
     renameDialog(fnames);
 else moveFilesProc(fsel, YES);
}