Пример #1
0
/************************************************************************
*									*
* gen_pullright() is called in the following order:			*
*   Pullright menu needs to be displayed. (MENU_PULLRIGHT)		*
*   Menu is about to be dismissed (MENU_DISPLAY_DONE)			*
*      User made a selection (before menu notify function)		*
*      After the notify routine has been called.			*
* The above order is done whether or not the user makes a		*
* menu selection.							*
* Always return newly created menu.					*
*									*/
static Menu
gen_pullright(Menu_item mi, Menu_generate op)
{
   Menu menu;
   Menu_item new_item, old_item = mi;
   char buf[MAXPATHLEN];

   if (op == MENU_DISPLAY)
   {
      menu = (Menu)xv_get(old_item, MENU_PARENT);
      (void)sprintf(buf, "%s/%s",
            xv_get(menu, MENU_CLIENT_DATA), xv_get(old_item, MENU_STRING));

      /* get old menu and free it -- we're going to build another */
      if (menu = (Menu)xv_get(old_item, MENU_PULLRIGHT))
      {
	 int j;
	 Menu_item item;

         free((char *)xv_get(menu, MENU_CLIENT_DATA));
         
	 /* Destroy all items in the menu 			    */
	 /* Note that these codes are needed because XView DOES NOT */
	 /* destroy all items in a menu although XView manual	    */
	 /* says it does.					    */
	 for (j=(int)xv_get(menu, MENU_NITEMS); j>0; j--)
	 {
	    item = (Menu_item)xv_get(menu, MENU_NTH_ITEM, j);
	    xv_set(menu, MENU_REMOVE, j, NULL);
	    xv_destroy(item);
	 }

         xv_destroy(menu);
      }
      if (new_item = add_path_to_menu(buf, 
	   (u_long)xv_get(old_item, XV_KEY_DATA, KEY_ADDR_DATA)))
      {
          menu = (Menu)xv_get(new_item, MENU_PULLRIGHT);
          xv_destroy(new_item);
          return menu;
      }
   }
   if (!(menu = (Menu)xv_get(old_item, MENU_PULLRIGHT)))
   {
      menu = (Menu)xv_create(NULL, MENU,
              MENU_STRINGS, "Couldn't build a menu.", NULL,
              NULL);
   }
   return menu;
}
Пример #2
0
static void
do_sigchld(int sig)
{
  pid_t pid, pgid;
  int status;
  xvect dying_jobs;
  size_t i, j;

  xv_init(&dying_jobs, sizeof(pid_t));

  while ((pid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
    if (WIFSTOPPED(status)) {
      post_job_suspend(getpgid(pid), 1);
    }
    else {
      pgid = getpgid(pid);
      xv_push(&dying_jobs, &pgid);
    }
  }

  for (i = 0; i < xv_size(&dying_jobs); ++i) {
    pgid = *(pid_t *)xv_get(&dying_jobs, i);
    if (waitpid(-pgid, &status, WNOHANG | WUNTRACED) == -1 && errno == ECHILD) { /* if the job of pgid is completely dead */
      for (j = 0; j < xv_size(&bg_jobs); ++j) {
        if (((bg_job *)xv_get(&bg_jobs, j))->pgid == pgid) {
          break;
        }
      }
      if (j != xv_size(&bg_jobs)) {
        xv_splice(&bg_jobs, j, 1);
      }
    }
  }

  xv_destroy(&dying_jobs);
}
Пример #3
0
void
exec_fini(void)
{
  xv_destroy(&bg_jobs);
}
Пример #4
0
/************************************************************************
*									*
*  This function will starts a pull-right menu from a specified		*
*  directory.  It lists all files in a menu.				*
*									*/
Menu
filelist_menu_pullright(Menu_item /*mi*/, Menu_generate op,
			u_long callback_func, char *start_dirpath)
{
   static Menu menu=NULL;

   //fprintf(stderr,"filelist_menu_pullright(): mi=%d, op=%d\n", mi, op);/*CMP*/
   if (op == MENU_DISPLAY)
   {
      Menu_item item;
      char *dirpath;

      if (start_dirpath == NULL)
	 dirpath = ".";			/* Use current directory */
      else
	 dirpath = start_dirpath;	/* Use a specified directory */

      //
      // Don't destroy old menus, may still be in use by pinned-up menus.
      // ***********************************************************
      // 		THIS IS A MEMORY LEAK
      // ***********************************************************
      // Have to figure out how to tell a menu is no longer needed.
      // Or, better, rewrite the pinnable, popup menus as popup panels
      // and then restore this commented put stuff.
      //
      //if (menu)
      //{
      //   int j;
      //   free((char *)xv_get(menu, MENU_CLIENT_DATA));
 
         /* Destroy all items in the menu				*/
         /* Note that these codes are needed because XView DOES NOT	*/
         /* destroy all items in a menu although XView manual		*/
         /* says it does.						*/
      //   for (j=(int)xv_get(menu, MENU_NITEMS); j>0; j--)
      //   {
      //      item = (Menu_item)xv_get(menu, MENU_NTH_ITEM, j);
      //      xv_set(menu, MENU_REMOVE, j, NULL);
      //      xv_destroy(item);
      //   }
      //   xv_destroy(menu);
      //} 

      if (item = add_path_to_menu(dirpath, callback_func))
      {
         menu = (Menu)xv_get(item, MENU_PULLRIGHT);
 
         /* Destroy the item since we already get its pullrigh menu	*/
         xv_destroy(item);
      }
      else
      {
         menu = xv_create(NULL, MENU,
                MENU_TITLE_ITEM,        strcpy(title, dirpath),
                MENU_STRINGS,   "<No such directory>", NULL,
                NULL);
      }
   }
   return(menu);
}