Exemple #1
0
void
ui_optionmenu_change_label(
    Widget	opmenu,
    STRING	new_str
)
{
    Widget	opmenu_label = NULL;
    XmString	new_xmstr;
    XmString	old_xmstr = NULL;

    opmenu_label = XmOptionButtonGadget(opmenu);
    if ((opmenu_label != NULL) && (new_str != NULL))
    {
	new_xmstr = XmStringCreateLocalized(new_str);
	XtVaGetValues(opmenu_label, XmNlabelString, &old_xmstr, NULL);
	
	/* If the two labels are different, then change
	 * the optionmenu label.
	 */
	if (!XmStringCompare(old_xmstr, new_xmstr))
	{
	    XtVaSetValues(opmenu_label,
                          XmNlabelString, new_xmstr,
                          NULL);
	}
	XmStringFree(new_xmstr);
    }
}
Exemple #2
0
void domainListCb(
  Widget	w,
  XtPointer	client_data,
  XtPointer	call_data)
{
  XmListCallbackStruct	*cbs=(XmListCallbackStruct *) call_data;
  DomainListItem	*newItem;
  HGUDlpListItem	*item;

  /* find and set the selected domain */
  /* loop through domains and display the boundlist */
  globals.currDmnListItem = NULL;
  item = HGUDlpListHead(globals.dmnList);
  while( item ){
    newItem = (DomainListItem *) HGUDlpListEntryGet(globals.dmnList, item);
    if( XmStringCompare(newItem->listStr, cbs->item) == True ){
      globals.currDmnListItem = newItem;
      break;
    }

    item = HGUDlpListNext(globals.dmnList, item);
  }  

  return;
}
Exemple #3
0
int main(int argc, char **argv)
{
 XtAppContext app;
 Widget one;
 XmString s1, s2;
 int i;
 

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

 one = XtVaCreateManagedWidget("Push me",
        xmPushButtonWidgetClass,
        toplevel, NULL);
 
 XtAddCallback(one, XmNactivateCallback, ChangeWindefTitleParameterCB, NULL);
 XtRealizeWidget(toplevel);

 s1 = XmStringCreateLtoR("ala ma pieska", "");
 s2 = XmStringCreateLocalized("ala ma pieska");
 i = XmStringCompare(s1, s2);
 printf("%d\n", i); /* on original Motif should be 1 */

 
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   50,   50,   54,   25, 0,0,0, /* Push me */ 
    };
    PrintDetails( toplevel ,Expected);
};
   LessTifTestMainLoop( toplevel );
   
   exit(0);
}
Exemple #4
0
static void
GoToNewDir(
       FileMgrData * file_mgr_data,
       char * dir_name )
{
   ChangeDirData * change_dir_data;
   int i;
   Boolean found;
   XmString xm_dir_name;

   /* Clear out any selected portion of the old CWD string */
   if (file_mgr_data->cd_select != NULL)
   {
      XtFree(file_mgr_data->cd_select);
      file_mgr_data->cd_select = NULL;
   }

   /* Update the internal copy of the dialog history list */
   if (file_mgr_data->change_dir)
   {
      change_dir_data = (ChangeDirData *) file_mgr_data->change_dir->data;
      xm_dir_name = XmStringCreateLocalized(dir_name);

      /* Add the directory only if not already in the list */
      for (i = 0, found = False; i < change_dir_data->list_count; i++)
      {
         if (XmStringCompare(xm_dir_name, change_dir_data->history_list[i]))
         {
            found = True;
            XmStringFree(xm_dir_name);
            break;
         }
      }

      if (!found)
      {
         change_dir_data->list_count++;
         change_dir_data->history_list = (XmStringTable)
            XtRealloc((char *)change_dir_data->history_list,
                   sizeof(XmStringTable) * (change_dir_data->list_count + 1));
         change_dir_data->history_list[change_dir_data->list_count - 1] =
                xm_dir_name;
         change_dir_data->history_list[change_dir_data->list_count] = NULL;
      }

      /* Update view to display the new directory */
      ShowNewDirectory(file_mgr_data, change_dir_data->host_name, dir_name);
   }
}
Exemple #5
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeComboBoxAddItem(Widget w,XmString item,int position)
{
    XfeComboBoxPart *		cp = _XfeComboBoxPart(w);
/*     XmListPart *			lp = _XfeXmListPart(w); */

	assert( _XfeIsAlive(w) );
	assert( XfeIsComboBox(w) );

	XmListAddItem(cp->list,item,position);


#if 0
    DtComboBoxWidget combo = (DtComboBoxWidget)combo_w;
    DtComboBoxPart *combo_p = (DtComboBoxPart*)&(combo->combo_box);
    XmStringTable list_items = ((XmListWidget)combo_p->list)->list.items;
    int i;

    if (item && ((XmListWidget)combo_p->list)->list.itemCount) {
	for (i = 0; i < combo_p->item_count; i++)
	    if (XmStringCompare(item, list_items[i]))
		break;
	if ((i < combo_p->item_count) && unique)
	    return;
    }

    XmListAddItem(combo_p->list, item, pos);
    SyncWithList(combo_p);

    if (combo_p->label) {
	SetMaximumLabelSize(combo_p);
	if (combo_p->type == XmDROP_DOWN_LIST_BOX) {
	    ClearShadow(combo, TRUE);
	    if (combo_p->recompute_size)
		SetComboBoxSize(combo);
	    LayoutChildren(combo);
	    DrawShadow(combo);
	}
    }
    if (combo_p->type == XmDROP_DOWN_COMBO_BOX)
	SetTextFieldData(combo_p, NULL);
    else
	SetLabelData(combo_p, NULL, FALSE);
#endif

}
Exemple #6
0
Widget
ui_optionmenu_replace_item(
    Widget      opmenu,
    STRING      old_item_str,
    STRING      new_item_str
)
{
    Widget	item = NULL;
    Widget	opmenu_label = NULL;
    XmString	xmstr = NULL;
    XmString    new_item_xmstr = NULL;
    XmString	old_item_xmstr = NULL;

    item = ui_optionmenu_find_item(opmenu, old_item_str);
    if (item != NULL)
    {
	new_item_xmstr = XmStringCreateLocalized(new_item_str);

	/* Check if the item we're replacing is the one
	 * which is currently showing in the optionmenu.
	 * If so, change the string.
	 */
	old_item_xmstr = XmStringCreateLocalized(old_item_str);
	opmenu_label = XmOptionButtonGadget(opmenu);
	XtVaGetValues(opmenu_label, XmNlabelString, &xmstr, NULL);
	if (XmStringCompare(xmstr, old_item_xmstr))
	{
	    XtVaSetValues(opmenu_label, 
			  XmNlabelString, new_item_xmstr, 
			  NULL); 
	}

	/* Change the button label to the new string */
	XtVaSetValues(item, XmNlabelString, new_item_xmstr, NULL);

	XmStringFree(xmstr);
	XmStringFree(old_item_xmstr);
	XmStringFree(new_item_xmstr);
    }
    return (item);
}
Exemple #7
0
void
buttonCB (Widget w, XtPointer data, XtPointer cbs)
{
  Widget list = (Widget) data;
  XmStringTable strTab;
  int numSel;
  int i;
  char *text;
  static int count = 0;


  if (count == 7)
    exit (0);

  XtVaGetValues (list,
		 XmNselectedItems, &strTab,
		 XmNselectedItemCount, &numSel,
		 NULL);
  fprintf (stderr, "Before: num selected = %d", numSel);
  XmStringGetLtoR (strTab[0], XmSTRING_DEFAULT_CHARSET, &text);
  fprintf (stderr, ", text=%s", text);

  for (i = 0; i < 7; i++)
    {
      if (XmStringCompare (strTab[0], xmStrings[i]))
	fprintf (stderr, ", item index=%d", i);
    }
  fprintf (stderr, "\n");

  XtVaSetValues (list,
		 XmNselectedItemCount, 2,
		 XmNselectedItems, &xmStrings[count],
		 NULL);
  count++;

  XtVaGetValues (list,
		 XmNselectedItemCount, &numSel,
		 NULL);

  fprintf (stderr, "...after: num selected: %d\n", numSel);
}
Exemple #8
0
Widget
ui_optionmenu_find_item(
    Widget      opmenu,
    STRING      item_str
)
{
    Widget      cascade_btn = NULL;
    Widget      menu = NULL;
    Widget	found_item = NULL;
    WidgetList	children = NULL;
    XmString    search_item, child = NULL;
    int         i, numChildren = 0;
    BOOL	Found = FALSE;

    if ((cascade_btn = XmOptionButtonGadget(opmenu)) != NULL)
    { 
        XtVaGetValues(cascade_btn, XmNsubMenuId, &menu, NULL);
        if (menu)   
        {
	    search_item = XmStringCreateLocalized(item_str);
	    XtVaGetValues(menu,
                        XmNnumChildren, &numChildren,
                        XmNchildren, &children,
                        NULL);
	    for (i=0; i < numChildren && !Found; i++)
	    {
		XtVaGetValues(children[i], XmNlabelString, &child, NULL);
		if (XmStringCompare(search_item, child))
		{
		    Found = TRUE;
		    found_item = children[i];
		}
	    }
	    XmStringFree(search_item);
	    XmStringFree(child);
	}
    }
    return (found_item);
}
Exemple #9
0
static void motListComboBoxSelectionCallback(Widget w, Ihandle* ih, XmComboBoxCallbackStruct* call_data)
{         
  IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION");
  if (cb)
  {
    int pos = call_data->item_position;
    if (pos==0)
    {
      /* must check if it is really checked or it is for the edit box */
      XmString* items;
      XtVaGetValues(ih->handle, XmNitems, &items, NULL);
      if (!XmStringCompare(call_data->item_or_text, items[0]))
       return;
    }
    pos++;  /* IUP starts at 1 */
    iupListSingleCallActionCb(ih, cb, pos);
  }

  if (!ih->data->has_editbox)
    iupBaseCallValueChangedCb(ih);

  (void)w;
}
Exemple #10
0
/*************************************<->*************************************
 *
 *  wspUpdateWorkspaceList (pPres)
 *
 *
 *  Description:
 *  -----------
 *  Updates the list widget containing all the workspaces.
 *  Sets the ones for this client.
 *
 *  Inputs:
 *  ------
 *  pPres = ptr to presence dialog data
 * 
 *  Outputs:
 *  -------
 *  none
 *
 *  Comments:
 *  ---------
 ******************************<->***********************************/
static void 
wspUpdateWorkspaceList(
        PtrWsPresenceData pPres )
{
    int n;
    XmString xmsTmp, *pxmsSelected;
    WmScreenData *pSD;
    Arg args[5];
    int wsnum, numSelected;

    /* 
     * Update the list of workspaces to -- one may have been
     * renamed since the last time we were up.
     */
    pSD = pPres->pCDforClient->pSD;
    for (wsnum = 0; wsnum < pSD->numWorkspaces; wsnum++)
    {
	xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);

	if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum]))
	{
	    /* 
	     * Replace the string in our local list
	     */
	    XmStringFree (pPres->ItemStrings[wsnum]);
	    pPres->ItemStrings[wsnum] = xmsTmp;

	    /* 
	     * Replace the item in the scrolled list.
	     */
	    XmListDeletePos (pPres->workspaceListW, 1+wsnum);
	    XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);
	}
	else
	{
	    XmStringFree (xmsTmp);
	}
    }

    /*
     * Highlight the workspaces this client resides in
     */
    XmListDeselectAllItems (pPres->workspaceListW);
    pxmsSelected = (XmString *) 
      XtMalloc (pPres->pCDforClient->pSD->numWorkspaces * sizeof (XmString));
    numSelected = 0;
    for (wsnum = 0; wsnum < pPres->pCDforClient->pSD->numWorkspaces; wsnum++)
    {
	if (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum], 
	    pPres->pCDforClient))
	{
	    pxmsSelected[numSelected++] = pPres->ItemStrings[wsnum];
	    pPres->ItemSelected[wsnum] = True;
	}
	else
	{
	    pPres->ItemSelected[wsnum] = False;
	    pPres->pCDforClient->putInAll = False;
	}

	if (pPres->pCDforClient->pSD->pActiveWS->id ==
			pPres->pCDforClient->pSD->pWS[wsnum].id)
	{
	    /* save item number of current workspace */
	    pPres->currentWsItem = 1+wsnum;
	}
    }

    /* set the selected items */
    n = 0;
    XtSetArg (args[n], XmNselectedItems, pxmsSelected);		n++;
    XtSetArg (args[n], XmNselectedItemCount, numSelected);	n++;
    XtSetValues (pPres->workspaceListW, args, n);

    /* set state of all workspaces button */
    n = 0;
    XtSetArg (args[n], XmNset, pPres->pCDforClient->putInAll);	n++;
    XtSetValues (pPres->allWsW, args, n);

    /* set name of window we're popped up for */
    wspSetWindowName (pPres);

    XtFree ((char *) pxmsSelected);
    
} /* END OF FUNCTION   */
Exemple #11
0
void
UpdatePresenceWorkspaces(
        WmScreenData *pSD )
{
    PtrWsPresenceData pPres = &pSD->presence;
    int wsnum;
    XmString xmsTmp;

    if (pPres->shellW)
    {
	if (pPres->numWorkspaces < pSD->numWorkspaces)
	{
	    if (((pPres->ItemStrings = (XmStringTable) XtRealloc 
		    ((char *)pPres->ItemStrings,
		    (pSD->numWorkspaces * sizeof(XmString *)))) == NULL) ||
		((pPres->ItemSelected = (Boolean *) XtRealloc 
		    ((char *)pPres->ItemSelected,
		    (pSD->numWorkspaces * sizeof(Boolean)))) == NULL))
	    {
		Warning (((char *)GETMESSAGE(52, 5, "Insufficient memory to create Occupy Workspace dialog.")));
		pPres->shellW = NULL;
		return;
	    }
	}

	/*
	 * Replace the names in the dialog's list
	 */
	for (wsnum = 0; wsnum < pPres->numWorkspaces; wsnum++)
	{
	    if (wsnum < pSD->numWorkspaces)
	    {
		xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);

		if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum]))
		{
		    /* 
		     * Replace the string in our local list
		     */
		    XmStringFree (pPres->ItemStrings[wsnum]);
		    pPres->ItemStrings[wsnum] = xmsTmp;

		    /* 
		     * Replace the item in the scrolled list.
		     */
		    XmListDeletePos (pPres->workspaceListW, 1+wsnum);
		    XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);
		}
		else
		{
		    XmStringFree (xmsTmp);
		}
	    }
	    else
	    {
		/*
		 * Delete this workspace from the list
		 */
		XmStringFree (pPres->ItemStrings[wsnum]);
		pPres->ItemStrings[wsnum] = NULL;
		XmListDeletePos (pPres->workspaceListW, 1+wsnum);
	    }
	}
	for (; wsnum < pSD->numWorkspaces; wsnum++)
	{
	    /*
	     * Add these workspaces to the list.
	     */
	    xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);
	    pPres->ItemStrings[wsnum] = xmsTmp;
	    XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);

	    if (pPres->pCDforClient && 
	        (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum], 
					pPres->pCDforClient)))
	    {
		XmListSelectPos (pPres->workspaceListW, 1+wsnum, TRUE);
		pPres->ItemSelected[wsnum] = True;
	    }
	    else
	    {
		pPres->ItemSelected[wsnum] = False;
	    }
	}

	pPres->numWorkspaces = pSD->numWorkspaces;
    }

} /* END OF FUNCTION UpdatePresenceWorkspaces */
Exemple #12
0
static void 
wspOkCB(
        Widget buttonW,
        WmScreenData *pSD,
        XtPointer call_data )
{
    Arg args[20];
    int n, j;
    int selectedItemCount;
    XmStringTable selectedItems;
    PtrWsPresenceData pPres = &pSD->presence;
    Boolean bAllSelected;


    /* find the selected workspaces */
    n = 0;
    XtSetArg (args[n], XmNselectedItemCount, &selectedItemCount); n++;
    XtSetArg (args[n], XmNselectedItems, &selectedItems); n++;
    XtGetValues (pPres->workspaceListW, args, n);

    /* find the state of all workspaces button */
    n = 0;
    XtSetArg (args[n], XmNset, &bAllSelected);	n++;
    XtGetValues (pPres->allWsW, args, n);

    if (bAllSelected)
    {
	F_AddToAllWorkspaces(NULL, pPres->pCDforClient, NULL);
    }
    else if (selectedItemCount)
    {
	for (n = 0; n < pSD->numWorkspaces; n++)
	{
	    pPres->ItemSelected[n] = False;
	    for (j = 0; j < selectedItemCount; j++)
	    {
		if (XmStringCompare (selectedItems[j], 
			pPres->ItemStrings[n]))
		{
		    pPres->ItemSelected[n] = True;
		}
	    }

	    if (!pPres->ItemSelected[n]  &&
		ClientInWorkspace (&pSD->pWS[n], pPres->pCDforClient))
	    {
		RemoveClientFromWorkspaces (pPres->pCDforClient, 
		    &pSD->pWS[n].id, 1);
	    }

	    if (pPres->ItemSelected[n] &&
		!ClientInWorkspace (&pSD->pWS[n], pPres->pCDforClient))
	    {
		AddClientToWorkspaces (pPres->pCDforClient, 
			&pSD->pWS[n].id, 1);
	    }
	}
    }

    /* withdraw the dialog */
    wspCancelCB (buttonW, (XtPointer)pSD, call_data);
} /* END OF FUNCTION   */
Exemple #13
0
void appIcon_AddRemoveItem(Widget wList, struct Broadcast_Packet* p_Item, char m_Option, XtPointer xtLabel)
{
	XmString xstr_item;
	XmStringTable xstr_list;
	int mFound = 0;
	int mIdx = 0;
	int mCount;	
	char str_Item[150]; 
	char* text;	
	char* test;

	char str_Count[4];	
			
	if(strlen(p_Item->Handlename) == 0)
	{
		sprintf(str_Item, "%s@%s (%s)", p_Item->Username, p_Item->Hostname, p_Item->IP_Address);
	}
	else
	{
		sprintf(str_Item, "%s@%s (%s)", p_Item->Handlename, p_Item->Hostname, p_Item->IP_Address);
	}
	
  	// Get the current entries (and number of entries) from the List
	XtVaGetValues (wList, XmNitemCount, &mCount,	XmNitems, &xstr_list, NULL);
		
	xstr_item = XmStringCreateLocalized (str_Item);
		
	
	
	if(m_Option == 1)
	{
		while(mCount>mIdx)
		{		
			if(XmStringCompare(xstr_item, xstr_list[mIdx]))
			{
				mFound = 1;
				break;
			}	
			mIdx++;
		}	
		
		if(mFound == 0)
		{
			mIdx = 0;
			while(mCount>mIdx)
			{
				text = (char *) XmStringUnparse (xstr_list[mIdx], NULL,XmCHARSET_TEXT, XmCHARSET_TEXT,NULL, 0, XmOUTPUT_ALL);
			
				if (strcmp (text, str_Item) > 0)
				{
					// str_Item comes before item
					XtFree(text);
					break;
				}
				
				XtFree(text);
				mIdx++;
			}
			
			mCount++;
			XmListAddItemUnselected (wList, xstr_item, mIdx+1);
			if(wList != APPICON_List_Users)
			{
				sprintf(str_Count, "%i", mCount);
				XtVaSetValues(*(Widget*)xtLabel, XmNvalue, str_Count, NULL);				
			}	
		}
	}
	else
	{
		while(mCount>mIdx)
		{		
			text = (char *) XmStringUnparse (xstr_list[mIdx], NULL,XmCHARSET_TEXT, XmCHARSET_TEXT,NULL, 0, XmOUTPUT_ALL);
					
			if ((test = strstr(text, p_Item->IP_Address)) != '\0')
			{
				*(strchr(test,')')) = '\0';
				if(strcmp(test, p_Item->IP_Address) == 0)
				{
					mFound = 1;
					XtFree(text);
					break;
				}
			}		
			
			XtFree(text);						
			mIdx++;
		}	
		
		if(mFound == 1)
		{
			mCount--;
			XmListDeletePos(wList, mIdx+1);	
			if(wList != APPICON_List_Users)
			{
				sprintf(str_Count, "%i", mCount);
				XtVaSetValues(*(Widget*)xtLabel, XmNvalue, str_Count, NULL);
			}	
		}
	}
	
	XmStringFree (xstr_item);	
}
Exemple #14
0
/*ARGSUSED*/
static Boolean 
SetValues(
        Widget ow,
        Widget rw,		/* unused */
        Widget nw,
        ArgList args,		/* unused */
        Cardinal *num_args )	/* unused */
{
            XmCommandWidget old = (XmCommandWidget) ow ;
            XmCommandWidget new_w = (XmCommandWidget) nw ;
            int max;
            Arg             argv[5] ;
            Cardinal        argc ;
/****************/

    /* mustMatch does not apply to command... (it is always false) */
    if (new_w->selection_box.must_match != False) { 
        new_w->selection_box.must_match = False; 
        XmeWarning( (Widget) new_w, WARNING5);
    }

    if (new_w->selection_box.dialog_type != XmDIALOG_COMMAND) {
        new_w->selection_box.dialog_type = XmDIALOG_COMMAND;
        XmeWarning( (Widget) new_w, WARNING1);
    }

    /* check for and change max history items (remove items if needed) */
    if (new_w->command.history_max_items < 1) {
        new_w->command.history_max_items = old->command.history_max_items;
        XmeWarning( (Widget) new_w, WARNING6);
    }
    if (new_w->command.history_max_items < 
        old->command.history_max_items)
    {
        argc = 0 ;
        XtSetArg( argv[argc], XmNitemCount, &max) ; ++argc ;
        XtGetValues( SB_List( new_w), argv, argc) ;

        while (max > new_w->command.history_max_items) {
            XmListDeletePos (new_w->selection_box.list, 1);
            if (new_w->selection_box.list_selected_item_position > 0)
                new_w->selection_box.list_selected_item_position--;
            max--;
        }
    }
    if (old->command.error)
    {
	XmString new_xms, old_xms;
        int new_count = new_w->selection_box.list_item_count;
        int old_count = old->selection_box.list_item_count;

	if (new_count > 2 && old_count > 2)
	{
            XmString new_blank, old_blank, new_error, old_error;
	    
            new_error = new_w->selection_box.list_items[new_count-1];
            old_error = old->selection_box.list_items[new_count-1];
            new_blank = new_w->selection_box.list_items[new_count-2];
            old_blank = old->selection_box.list_items[new_count-2];

	    if (XmStringCompare(new_error, old_error) &&
	        XmStringCompare(new_blank, old_blank))
	    {
                new_w->command.error = FALSE;
#if 0
                XmListDeletePos(SB_List(old), 0);   /* Delete error message.*/
                XmListDeletePos(SB_List(old), 0) ;   /* Delete blank line.*/
                old->command.error = FALSE ;
#endif
	    }
	}
	else new_w->command.error = FALSE;
    }
    
    /* require redisplay */
    return(True);
}