示例#1
0
static Status
sm_new_client (SmsConn        sms_conn,
               SmPointer      manager_data,
               unsigned long *mask,
               SmsCallbacks  *callbacks,
               char         **failure_reason)
{
  XfsmManager *manager = XFSM_MANAGER (manager_data);
  XfsmClient  *client;
  gchar       *error = NULL;

  xfsm_verbose ("ICE connection fd = %d, received NEW CLIENT\n\n",
                IceConnectionNumber (SmsGetIceConnection (sms_conn)));

  client = xfsm_manager_new_client (manager, sms_conn, &error);
  if (client == NULL)
    {
      xfsm_verbose ("NEW CLIENT failed: %s\n", error);

#ifdef HAVE_STRDUP
      *failure_reason = strdup (error);
#else
      *failure_reason = (char *) malloc (strlen (error) + 1);
      if (*failure_reason != NULL)
        strcpy (*failure_reason, error);
#endif

      return False;
    }

  SET_CALLBACK (callbacks, register_client, client);
  SET_CALLBACK (callbacks, interact_request, client);
  SET_CALLBACK (callbacks, interact_done, client);
  SET_CALLBACK (callbacks, save_yourself_request, client);
  SET_CALLBACK (callbacks, save_yourself_phase2_request, client);
  SET_CALLBACK (callbacks, save_yourself_done, client);
  SET_CALLBACK (callbacks, close_connection, client);
  SET_CALLBACK (callbacks, set_properties, client);
  SET_CALLBACK (callbacks, delete_properties, client);
  SET_CALLBACK (callbacks, get_properties, client);

  *mask = SmsRegisterClientProcMask | SmsInteractRequestProcMask
    | SmsInteractDoneProcMask | SmsSaveYourselfRequestProcMask
    | SmsSaveYourselfP2RequestProcMask | SmsSaveYourselfDoneProcMask
    | SmsCloseConnectionProcMask | SmsSetPropertiesProcMask
    | SmsDeletePropertiesProcMask | SmsGetPropertiesProcMask;

  g_object_set_data (G_OBJECT (client), "--xfsm-manager", manager);

  return True;
}
示例#2
0
tview_t* html_tv_init(const char *fn, const char *fn_fa, const char *samples)
	{
	char* colstr=getenv("COLUMNS");
	html_tview_t *tv = (html_tview_t*)calloc(1, sizeof(html_tview_t));
	tview_t* base=(tview_t*)tv;
	if(tv==0)
		{
		fprintf(stderr,"Calloc failed\n");
		return 0;
		}
	tv->row_count=0;
	tv->screen=NULL;
	tv->out=stdout;
	tv->attributes=0;
	base_tv_init(base,fn,fn_fa,samples);
	/* initialize callbacks */
#define SET_CALLBACK(fun) base->my_##fun=html_##fun;
	SET_CALLBACK(destroy);
	SET_CALLBACK(mvprintw);
	SET_CALLBACK(mvaddch);
	SET_CALLBACK(attron);
	SET_CALLBACK(attroff);
	SET_CALLBACK(clear);
	SET_CALLBACK(colorpair);
	SET_CALLBACK(drawaln);
	SET_CALLBACK(loop);
	SET_CALLBACK(underline);
#undef SET_CALLBACK

	
	if(colstr!=0)
		{
		base->mcol=atoi(colstr);
		if(base->mcol<10) base->mcol=80;
		}
	base->mrow=99999;
	
/*
	init_pair(tv,1, "blue", "white");
	init_pair(tv,2, "green", "white");
	init_pair(tv,3, "yellow", "white");
	init_pair(tv,4, "white", "white");
	init_pair(tv,5, "green", "white");
	init_pair(tv,6, "cyan", "white");
	init_pair(tv,7, "yellow", "white");
	init_pair(tv,8, "red", "white");
	init_pair(tv,9, "blue", "white");
	*/
	return base;
	}
示例#3
0
/*!
    \fn
    \brief    Sets the mouse-button callback for the current window.
    \ingroup  input
    \param    callback    Client hook for mouse-buttons.

              Whenever a mouse button is pressed or released in an OpenGLUT
              window, OpenGLUT checks if that window has a mouse-button
              (Mouse) callback registered.  If so, OpenGLUT gives the
              event to the handler.  \a button is the button number,
              starting from 0.  \a state is \a GLUT_UP or \a GLUT_DOWN
              to indicate the button's new state.  The other parameters
              are the mouse coordinates.

              Mouse wheel motion can be reported as buttons.  If you
              do not request otherwise, a wheel spun forward will
              act like a button clicking down, immediately followed
              by clicking up.  Spinning the same wheel backward
              will act like a different button clicking.  Mouse wheel
              pseudo-buttons are added after all real buttons.

              While the button is held and the mouse is dragged,
              you receive mouse-motion events (glutMotionFunc()),
              even if the mouse is dragged out of the window.

              This callback is bound to the <i>current window</i>.

    \note     Reporting the wheel as buttons is actually inherited from X.
              freeglut added code to support this on WIN32.  OpenGLUT
              inherited that support from freeglut.
    \note     Old GLUT defines the symbols \a GLUT_LEFT_BUTTON,
              \a GLUT_RIGHT_BUTTON, and \a GLUT_MIDDLE_BUTTON.
              However, mice can have more than 3 buttons, so these
              symbols are deprecated.
    \note     Windows created via glutCreateMenuWindow() always cascade
              keyboard and mouse events to their parent.
    \see      glutMotionFunc(), glutPassiveMotionFunc(), glutMouseWheelFunc()
*/
void OGAPIENTRY glutMouseFunc(
    void( *callback )( int button, int state, int x, int y )
)
{
    if( !ogStructure.Window->IsClientMenu )
        SET_CALLBACK( Mouse );
}
示例#4
0
/*
 * Sets the spaceball button callback for the current window
 */
void FGAPIENTRY glutSpaceballButtonFunc( FGCBSpaceButton callback )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
    fgInitialiseSpaceball();

    SET_CALLBACK( SpaceButton );
}
示例#5
0
/*
 * Sets the joystick callback and polling rate for the current window
 */
void FGAPIENTRY glutJoystickFunc( void (* callback)
                                  ( unsigned int, int, int, int ),
                                  int pollInterval )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
    fgInitialiseJoysticks ();

    if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
           !FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) &&  /* Joystick callback was disabled */
         ( callback && ( pollInterval >= 0 ) ) )               /* but is now enabled */
        ++fgState.NumActiveJoysticks;
    else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
                FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) &&  /* Joystick callback was enabled */
              ( !callback || ( pollInterval < 0 ) ) )              /* but is now disabled */
        --fgState.NumActiveJoysticks;

    SET_CALLBACK( Joystick );
    fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;

    fgStructure.CurrentWindow->State.JoystickLastPoll =
        fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;

    if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
        fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
}
示例#6
0
/*
 * Sets the joystick callback and polling rate for the current window
 */
void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
    fgInitialiseJoysticks ();

    if ( (
           fgStructure.CurrentWindow->State.JoystickPollRate <= 0 ||        /* Joystick callback was disabled */
           !FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
         ) &&
         ( 
           callback && ( pollInterval > 0 )                                 /* but is now enabled */
         ) )
        ++fgState.NumActiveJoysticks;
    else if ( ( 
                fgStructure.CurrentWindow->State.JoystickPollRate > 0 &&    /* Joystick callback was enabled */
                FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
              ) &&  
              ( 
                !callback || ( pollInterval <= 0 )                          /* but is now disabled */
              ) )
        --fgState.NumActiveJoysticks;

    SET_CALLBACK( Joystick );
    fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;

    /* set last poll time such that joystick will be polled asap */
    fgStructure.CurrentWindow->State.JoystickLastPoll = fgElapsedTime();
    if (fgStructure.CurrentWindow->State.JoystickLastPoll < pollInterval)
        fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
    else
        fgStructure.CurrentWindow->State.JoystickLastPoll -= pollInterval;
}
示例#7
0
/*
 * Sets the spaceball rotate callback for the current window
 */
void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
    fgInitialiseSpaceball();

    SET_CALLBACK( SpaceRotation );
}
示例#8
0
/*!
    \fn
    \brief    Sets the mouse wheel callback for the current window.
    \ingroup  input
    \param    callback    Client hook for mouse wheel events.

              If the mouse wheel is spun over your (sub)window,
              OpenGLUT will, in theory, report this via the MouseWheel
              callback.  \a wheel is the wheel number, \a direction
              is +/- 1, and \a x and \a y are the mouse coordinates.

              If you do not register a wheel callback, wheel events will
              be reported as mouse buttons.

              This callback is bound to the <i>current window</i>.

    \note     Due to lack of information about the mouse, it is impossible
              to implement this correctly on X at this time.  Use of this
              function limits the portability of your application.  (This
              feature <b>does</b> work on X, just not reliably.)  You are
              encouraged to use the standard, reliable mouse-button
              reporting, rather than wheel events.
    \note     Windows created via glutCreateMenuWindow() always cascade
              keyboard and mouse events to their parent.
    \see      glutMouseFunc()
*/
void OGAPIENTRY glutMouseWheelFunc(
    void( *callback )( int wheel, int direction, int x, int y )
)
{
    if( !ogStructure.Window->IsClientMenu )
        SET_CALLBACK( MouseWheel );
}
示例#9
0
/*!
    \fn
    \brief    Sets the special key release callback for the current window
    \ingroup  input
    \param    callback    Client hook for special key releases.

              This function provides a way to detect the release of
              a keyboard \a key.
              The keys are reported exactly as with
              glutSpecialFunc(), save that the \a callback registered
              via this function is used to report the event.

              This callback is bound to the <i>current window</i>.

    \note     Windows created via glutCreateMenuWindow() always cascade
              keyboard and mouse events to their parent.
    \see      glutSpecialFunc(), glutKeyboardUpFunc()
*/
void OGAPIENTRY glutSpecialUpFunc(
    void( *callback )( int key, int x, int y )
)
{
    if( !ogStructure.Window->IsClientMenu )
        SET_CALLBACK( SpecialUp );
}
示例#10
0
/*!
    \fn
    \brief    Sets the keyboard key release callback for the current window.
    \ingroup  input
    \param    callback    Client hook for ASCII key releases.

              This function provides a way to detect the release of
              a keyboard key.
              The keys are reported exactly as with
              glutKeyboardFunc(), save that the \a callback registered
              via this function is used to report the event.

              This callback is bound to the <i>current window</i>.

    \note     Windows created via glutCreateMenuWindow() always cascade
              keyboard and mouse events to their parent.
    \see      glutKeyboardFunc(), glutSpecialUpFunc()
*/
void OGAPIENTRY glutKeyboardUpFunc(
    void( *callback )( unsigned char key, int x, int y )
)
{
    if( !ogStructure.Window->IsClientMenu )
        SET_CALLBACK( KeyboardUp );
}
示例#11
0
/*
 * Sets the Display callback for the current window
 */
void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
    if( !callback )
        fgError( "Fatal error in program.  NULL display callback not "
                 "permitted in GLUT 3.0+ or freeglut 2.0.1+" );
    SET_CALLBACK( Display );
}
示例#12
0
/*
 * Sets the Display callback for the current window
 */
void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
{
    if( !callback )
        fgError( "Fatal error in program.  NULL display callback not "
                 "permitted in GLUT 3.0+ or FreeGLUT|ES 1.0+\n" );
    SET_CALLBACK( Display );
    fgStructure.Window->State.Redisplay = GL_TRUE;
}
示例#13
0
void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
    
    if( !callback )
        callback = fghDefaultReshape;

    SET_CALLBACK( Reshape );
}
示例#14
0
/*!
    \fn
    \brief    Sets the Visibility callback for the current window.
    \ingroup  deprecated
    \param    callback    Client hook for visibility changes.

              OpenGLUT may call this function when your window's
              visbility status has changed.  \a status can take
              on two values: \a GLUT_NOT_VISIBLE or \a GLUT_VISIBLE .
              If any pixel of your window (including descendants) is
              visible, your window is \a GLUT_VISIBLE .

              The callback is bound to the <i>current window</i>.

    \note     This is not a polling mechanism.  You are only informed
              of transitions that OpenGLUT observes while your
              callback is in place.
    \note     This function appears to be superceded by
              glutWindowStatusFunc().
    \note     This callback is mutually exclusive of glutWindowStatusFunc().
    \see      glutWindowStatusFunc()
*/
void OGAPIENTRY glutVisibilityFunc( void( *callback )( int status ) )
{
    SET_CALLBACK( Visibility );

    if( callback )
        glutWindowStatusFunc( oghVisibility );
    else
        glutWindowStatusFunc( NULL );
}
示例#15
0
void FGAPIENTRY glutVisibilityFunc( FGCBVisibility callback )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
    SET_CALLBACK( Visibility );

    if( callback )
        glutWindowStatusFunc( fghVisibility );
    else
        glutWindowStatusFunc( NULL );
}
示例#16
0
/*!
    \fn
    \brief    Sets the Display callback for the current window.
    \ingroup  windowcallback
    \param    callback    Client function for normal redisplay event.

              Sets the display callback for the <i>current window</i>.
              All windows, including subwindows, <b>must</b> have
              a display callback registered.  OpenGLUT will call
              the \a callback function whenever it thinks that the
              window may require updating.

              This callback is bound to the <i>current window</i>.

    \note     Unlike most callbacks, it is illegal to try to disable
              the display callback by setting it to \a NULL .
    \note     Multiple redisplays may be coalesced into a single
              event for invoking the \a callback only once.
    \see      glutPostRedisplay(), glutOverlayDisplayFunc()
*/
void OGAPIENTRY glutDisplayFunc( void( *callback )( void ) )
{
    if( !callback )
        ogError(
            "Fatal error in program.  NULL display callback not "
            "permitted in GLUT 3.0+, freeglut 2.0.1+, "
            "or any version of OpenGLUT."
        );
    SET_CALLBACK( Display );
}
示例#17
0
tview_t* curses_tv_init(const char *fn, const char *fn_fa, const char *samples,
                        const htsFormat *fmt)
    {
    curses_tview_t *tv = (curses_tview_t*)calloc(1, sizeof(curses_tview_t));
    tview_t* base=(tview_t*)tv;
    if(tv==0)
        {
        fprintf(stderr,"Calloc failed\n");
        return 0;
        }

    base_tv_init(base,fn,fn_fa,samples,fmt);
    /* initialize callbacks */
#define SET_CALLBACK(fun) base->my_##fun=curses_##fun;
    SET_CALLBACK(destroy);
    SET_CALLBACK(mvprintw);
    SET_CALLBACK(mvaddch);
    SET_CALLBACK(attron);
    SET_CALLBACK(attroff);
    SET_CALLBACK(clear);
    SET_CALLBACK(colorpair);
    SET_CALLBACK(drawaln);
    SET_CALLBACK(loop);
    SET_CALLBACK(underline);
#undef SET_CALLBACK

    initscr();
    keypad(stdscr, TRUE);
    clear();
    noecho();
    cbreak();

    getmaxyx(stdscr, base->mrow, base->mcol);
    tv->wgoto = newwin(3, TV_MAX_GOTO + 10, 10, 5);
    tv->whelp = newwin(30, 40, 5, 5);

    start_color();
    curses_init_colors(0);
    return base;
    }
示例#18
0
/*
 * Sets the joystick callback and polling rate for the current window
 */
void FGAPIENTRY glutJoystickFunc( void (* callback)
                                  ( unsigned int, int, int, int ),
                                  int pollInterval )
{
    SET_CALLBACK( Joystick );
    fgStructure.Window->State.JoystickPollRate = pollInterval;

    fgStructure.Window->State.JoystickLastPoll =
        fgElapsedTime() - fgStructure.Window->State.JoystickPollRate;

    if( fgStructure.Window->State.JoystickLastPoll < 0 )
        fgStructure.Window->State.JoystickLastPoll = 0;
}
示例#19
0
MapButton::MapButton (WComposite &parent,
                      const UAS_Pointer<UAS_Common> &doc_ptr,
		      MapButton *ancestor)
: f_form (parent, "form"),
  f_doc_ptr (doc_ptr),
  f_expanded (FALSE)
{
  ON_DEBUG (printf ("MapButton::MapButton (%s)\n", (char*)f_doc_ptr->title()));
  static bool expandable_tree =
    window_system().get_boolean_default ("ExpandableMap");
  UAS_List<UAS_Common> kids (f_doc_ptr->children());
  UAS_String t = f_doc_ptr->title();
  if (kids.length() > 0 && expandable_tree)
    {
      f_arrow = WXmArrowButton (f_form, "expand", WAutoManage);
      ON_ACTIVATE (f_arrow,expand);
      f_button =
	WXmPushButton (f_form, t, WAutoManage,
		       WArgList (XmNrightWidget, (XtArgVal) ((Widget) f_arrow),
				 XmNrightAttachment, XmATTACH_WIDGET,
				 NULL));
    }
  else
    {
      f_button = WXmPushButton (f_form, t, WAutoManage);
    }

  ON_ACTIVATE (f_button,activate);
  SET_CALLBACK (f_form,Destroy,destroy);

  f_form.ShadowThickness (0);
  // f_form.Realize();

  // Add to the list so that we can manage 'em all at once. 
  if (f_num_kids + 1 > f_kids_size)
    {
      f_kids_size *= 2;
      f_kids = (Widget *) realloc (f_kids, sizeof (Widget) * f_kids_size);
    }
  f_kids[f_num_kids++] = (Widget) f_form;
  ON_DEBUG (printf ("Form managed = %d\n", XtIsManaged (f_form)));
    
  if (ancestor != NULL)
    {
      CXawTree form (f_form);
      WArgList args;

      form.TreeParent (ancestor->f_form, args);
      form.Set (args.Args(), args.NumArgs());
    }
}
示例#20
0
/*!
    \fn
    \brief    Reports joystick state for the current window.
    \ingroup  input
    \param    callback      Client function for joystick events
    \param    pollInterval  Approximate (minimum) millisecond interval

              The callback is called roughly every \a pollinterval
              milliseconds, and will give the joystick status.

              The \a buttons bitmask is a bit-wise \a OR of:
              - GLUT_JOYSTICK_BUTTON_A
              - GLUT_JOYSTICK_BUTTON_B
              - GLUT_JOYSTICK_BUTTON_C
              - GLUT_JOYSTICK_BUTTON_D

              The axis values are in the range [-1000,1000].

*/
void OGAPIENTRY glutJoystickFunc(
    void( *callback )( unsigned int buttons, int xaxis, int yaxis, int zaxis ),
    int pollInterval
)
{
    ogJoystickInit( );

    SET_CALLBACK( Joystick );
    ogStructure.Window->State.JoystickPollRate = pollInterval;

    ogStructure.Window->State.JoystickLastPoll =
        ogElapsedTime() - ogStructure.Window->State.JoystickPollRate;

    if( ogStructure.Window->State.JoystickLastPoll < 0 )
        ogStructure.Window->State.JoystickLastPoll = 0;
}
示例#21
0
/*
 * Sets the joystick callback and polling rate for the current window
 */
void FGAPIENTRY glutJoystickFunc( void (* callback)
                                  ( unsigned int, int, int, int ),
                                  int pollInterval )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
    fgInitialiseJoysticks ();

    SET_CALLBACK( Joystick );
    fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;

    fgStructure.CurrentWindow->State.JoystickLastPoll =
        fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;

    if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
        fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
}
示例#22
0
/*
 * Sets the multi-pointer passive motion callback for the current window
 */
void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
    SET_CALLBACK( MultiPassive );
}
示例#23
0
/*
 * Sets the tablet buttons callback for the current window
 */
void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
    SET_CALLBACK( TabletButton );
}
示例#24
0
/*
 * Sets the Keyboard callback for the current window
 */
void FGAPIENTRY glutKeyboardFunc( void (* callback)
                                  ( unsigned char, int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
    SET_CALLBACK( Keyboard );
}
示例#25
0
/*
 * Sets the Reshape callback for the current window
 */
void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
    SET_CALLBACK( Reshape );
}
示例#26
0
/*
 * Sets the Special callback for the current window
 */
void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
    SET_CALLBACK( Special );
}
示例#27
0
  bool
  FLACInputStream::initialize(FilePtr file) {
    m_file = file;

    // initialize the decoder
    m_decoder = FLAC__seekable_stream_decoder_new();
    if (!m_decoder) {
      m_file = 0;
      return false;
    }

#define SET_CALLBACK(name)                                   \
  FLAC__seekable_stream_decoder_set_##name##_callback(       \
    m_decoder,                                               \
    name##_callback)

    // set callbacks
    FLAC__seekable_stream_decoder_set_client_data      (m_decoder, this);
    SET_CALLBACK(read);
    SET_CALLBACK(seek);
    SET_CALLBACK(tell);
    SET_CALLBACK(length);
    SET_CALLBACK(eof);
    SET_CALLBACK(write);
    SET_CALLBACK(metadata);
    SET_CALLBACK(error);

    FLAC__SeekableStreamDecoderState state =
      FLAC__seekable_stream_decoder_init(m_decoder);
    if (state != FLAC__SEEKABLE_STREAM_DECODER_OK) {
      FLAC__seekable_stream_decoder_finish(m_decoder);
      FLAC__seekable_stream_decoder_delete(m_decoder);
      m_decoder = 0;
      m_file = 0;
      return false;
    }

    // make sure we have metadata before we return!
    if (!FLAC__seekable_stream_decoder_process_until_end_of_metadata(m_decoder)) {
      FLAC__seekable_stream_decoder_finish(m_decoder);
      FLAC__seekable_stream_decoder_delete(m_decoder);
      m_decoder = 0;
      m_file = 0;
      return false;
    }

    // process one frame so we can do something!
    if (!FLAC__seekable_stream_decoder_process_single(m_decoder)) {
      FLAC__seekable_stream_decoder_finish(m_decoder);
      FLAC__seekable_stream_decoder_delete(m_decoder);
      m_decoder = 0;
      m_file = 0;
      return false;
    }

    // get info about the flac file
    m_channel_count = FLAC__seekable_stream_decoder_get_channels(m_decoder);
    m_sample_rate   = FLAC__seekable_stream_decoder_get_sample_rate(m_decoder);
    int bps         = FLAC__seekable_stream_decoder_get_bits_per_sample(m_decoder);
    if (bps == 16) {
      m_sample_format = SF_S16;
    } else if (bps == 8) {
      m_sample_format = SF_U8;
    } else {
      return false;
    }

    return true;
  }
示例#28
0
文件: ScopeMenu.C 项目: juddy/edcde
void
ScopeMenu::fill_menu()
{
  int position = 0;
  Wait_Cursor bob;

  // Create toggle buttons for each scope.
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);
  bool old_read_only = TRUE;

  // Set the current scope to the first entry
  //  (Current Section or Information Library) 
  f_current_scope = s.item();

  ON_DEBUG(cerr << "Scope Popup" << endl);

  int first = TRUE;
  for (; s != 0; s++)
    {
      
      // in case we are not using Current Section
      if (f_current_scope == NULL)
	f_current_scope = s.item();

      ON_DEBUG(cerr << "\t" << f_current_scope->name() << endl);
//    ON_DEBUG(f_current_scope->dump_items());

      // Add a separator when they change from read only to changable. 
      if (old_read_only != s.item()->read_only())
	{
	  DECLM (WXmSeparator, sep1, f_pull_menu, "separator");
          sep1.PositionIndex (position++);
	  old_read_only = FALSE;
	}
      DECLM (WXmPushButtonGadget, scope, f_pull_menu, s.item()->name());
      if (first && !f_use_current_section)
	{
	  first = FALSE;
	  scope.Unmanage();
	  // Reset current scope so that it is set to Library on next pass.
	  f_current_scope = NULL;
	}
      scope.UserData (s.item());
      scope.PositionIndex (position++);

      WCallback *cb = SET_CALLBACK(scope,Activate,set_scope);
      SET_CALLBACK_D (scope,Destroy,destroy_scope,cb);
      if (f_current_scope == s.item())
	{
	  Arg args[1];
	  int n = 0;
	  XtSetArg(args[n], XmNmenuHistory, (Widget)scope); n++;
	  XtSetValues(f_option_menu, args, n);
	}
    }

  //UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this);
}
示例#29
0
void
PrefAgent::create_ui()
{
  // Create main preferences window.

  XmStringLocalized mtfstring;
  String	    string;
  int		    decorations=MWM_DECOR_BORDER  |
                                MWM_DECOR_RESIZEH |
                                MWM_DECOR_TITLE   |
                                MWM_DECOR_MENU;

  f_shell = WTopLevelShell (window_system().toplevel(), WPopup, "preferences");
  window_system().register_shell(&f_shell);

  string = CATGETS(Set_PrefAgent, 1, "Dtinfo: Preferences");
  XtVaSetValues((Widget)f_shell,
                XmNtitle, string,
                XmNmwmDecorations, decorations,
                NULL);

  DECL  (WXmForm,         form,         f_shell,      "form");
  DECLMC(WXmOptionMenu,   options,      form,         "options");
  DECLC (WXmPulldownMenu, options_menu, form,         "options_menu");

  mtfstring = CATGETS(Set_AgentLabel, 186, "Preferences for");
  XtVaSetValues(options, XmNlabelString, (XmString)mtfstring, NULL);

  ASSNM (WXmPushButton,   f_ok,         form,         "ok");
  ASSNM (WXmPushButton,   f_apply,      form,         "apply");
  ASSNM (WXmPushButton,   f_reset,      form,         "reset");
  DECLM (WXmPushButton,   cancel,       form,         "cancel");
  DECLM (WXmPushButton,   help,         form,         "help");

  mtfstring = CATGETS(Set_AgentLabel, 161, "OK");
  XtVaSetValues(f_ok, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 201, "Apply");
  XtVaSetValues(f_apply, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 202, "Reset");
  XtVaSetValues(f_reset, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 162, "Cancel");
  XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 48, "Help");
  XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL);

  SET_CALLBACK (f_ok,Activate,ok);
  SET_CALLBACK (f_apply,Activate,apply);
  SET_CALLBACK (f_reset,Activate,reset);
  SET_CALLBACK (cancel,Activate,cancel);
  help_agent().add_activate_help (help, (char*)"preferences_help");

  DECLM (WXmFrame,        frame,        form,         "frame");
  DECL  (WXmForm,         container,    frame,        "container");

  // Create browsing preferences.
  DECLM (WXmPushButton,   browse,          options_menu,  "browse");

  DECL  (WXmForm,         browse_form,     container,     "browse_prefs");
  DECLM (WXmLabel,        browse_label,    browse_form,   "browse_label");
  DECLM (WXmPushButton,   get_browse_geo,  browse_form,   "get_browse_geo");
  ASSNM (WXmTextField,    f_browse_geo,    browse_form,   "browse_geo");
  DECLM (WXmLabel,        fs_label,        browse_form,   "fs_label");
  DECL  (WXmForm,         fs_form,         browse_form,   "fs_form");
  ASSNM (WXmTextField,    f_fs_field,      fs_form,       "scale_field");
  DECLM (WXmArrowButton,  scale_up,        fs_form,       "scale_up");
  DECLM (WXmArrowButton,  scale_down,      fs_form,       "scale_down");
  DECLM (WXmLabel,        lock_label,      browse_form,   "lock_label");
  ASSNM (WXmToggleButton, f_lock_toggle,   browse_form,   "lock_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 187, "Browsing");
  XtVaSetValues(browse, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 190, "Browser Geometry");
  XtVaSetValues(browse_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 270, "...");
  XtVaSetValues(get_browse_geo, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 192, "Font Scale");
  XtVaSetValues(fs_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 193, "Pin Window");
  XtVaSetValues(lock_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_lock_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  Dimension height;
  ChangeData *inc, *dec;

  // Assume that the fields are taller than the labels.  If the user
  // changes the font resources and violates this assumtion he's screwed
  // and that's the way we like it.

  height = f_fs_field.Height();

  browse_label.Height (height);
  fs_label.Height (height);
  scale_up.Height (height/2);
  scale_down.Height (height/2);

  f_lock_toggle.LabelType (XmPIXMAP);
  lock_label.Height (height);

  fs_form.Manage();
  browse_form.Manage();
  f_top_panel = browse_form;

  SET_CALLBACK_D (browse,Activate,switch_to_window,(Widget)browse_form);
  SET_CALLBACK_D (get_browse_geo,Activate,get_geometry,(Widget)f_browse_geo);
  SET_CALLBACK (f_browse_geo,ValueChanged,something_changed);
  SET_CALLBACK (f_fs_field,ValueChanged,something_changed);
  SET_CALLBACK (f_lock_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_lock_toggle,ValueChanged,lock_toggle);

  inc = new ChangeData(f_fs_field, scale_up, scale_down, 1, 5);
  dec = new ChangeData(f_fs_field, scale_up, scale_down, -1, -2);
  SET_CALLBACK_D (scale_up,Activate,change_cb,inc);
  SET_CALLBACK_D (scale_up,Arm,arm_arrow,inc);
  SET_CALLBACK  (scale_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (scale_down,Activate,change_cb,dec);
  SET_CALLBACK_D (scale_down,Arm,arm_arrow,dec);
  SET_CALLBACK  (scale_down,Disarm,disarm_arrow);

  // Create map window preferences
  DECLM (WXmPushButton,   map,             options_menu,  "map");
  DECLM (WXmForm,         map_form,        container,     "map_prefs");
  DECLM (WXmLabel,        map_label,       map_form,      "map_label");
  DECLM (WXmPushButton,   get_map_geo,     map_form,      "get_map_geo");
  ASSNM (WXmTextField,    f_map_geo,       map_form,      "map_geo");
  DECLM (WXmLabel,        update_label,    map_form,      "update_label");
  ASSNM (WXmToggleButton, f_update_toggle, map_form,      "update_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 188, "Map");
  XtVaSetValues(map, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 195, "Map Geometry");
  XtVaSetValues(map_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 270, "...");
  XtVaSetValues(get_map_geo, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 196, "Auto Update");
  XtVaSetValues(update_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_update_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_map_geo.Height();
  map_label.Height (height);
  update_label.Height (height);
  
  SET_CALLBACK_D (get_map_geo,Activate,get_geometry,(Widget)f_map_geo);
  SET_CALLBACK_D (map,Activate,switch_to_window,(Widget)map_form);
  SET_CALLBACK (f_map_geo,ValueChanged,something_changed);
  SET_CALLBACK (f_update_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_update_toggle,ValueChanged,update_toggle);

  map_form.Manage();

  // Create history preferences 
  DECLM (WXmPushButton,   history,      options_menu, "history");

  mtfstring = CATGETS(Set_AgentLabel, 260, "History");
  XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL);

  DECL  (WXmForm,         hist_form,     container,     "history_prefs");
  DECLM (WXmLabel,        nh_label,      hist_form,     "nh_label");
  DECL  (WXmForm,         nh_form,       hist_form,     "nh_form");
  ASSNM (WXmTextField,    f_nh_field,    nh_form,       "nh_field");
  DECLM (WXmArrowButton,  nh_up,         nh_form,       "nh_up");
  DECLM (WXmArrowButton,  nh_down,       nh_form,       "nh_down");
  DECLM (WXmLabel,        sh_label,      hist_form,     "sh_label");
  DECL  (WXmForm,         sh_form,       hist_form,     "sh_form");
  ASSNM (WXmTextField,    f_sh_field,    sh_form,       "sh_field");
  DECLM (WXmArrowButton,  sh_up,         sh_form,       "sh_up");
  DECLM (WXmArrowButton,  sh_down,       sh_form,       "sh_down");

  mtfstring = CATGETS(Set_AgentLabel, 197, "Section History Size");
  XtVaSetValues(nh_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 198, "Search History Size");
  XtVaSetValues(sh_label, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_nh_field.Height();
  nh_label.Height (height);
  nh_up.Height (height/2);
  nh_down.Height (height/2);

  height = f_sh_field.Height();
  sh_label.Height (height);
  sh_up.Height (height/2);
  sh_down.Height (height/2);

  nh_form.Manage();
  sh_form.Manage();
  hist_form.Manage();
  
  SET_CALLBACK_D (history,Activate,switch_to_window,(Widget)hist_form);
  SET_CALLBACK (f_nh_field,ValueChanged,something_changed);
  SET_CALLBACK (f_sh_field,ValueChanged,something_changed);

  inc = new ChangeData (f_nh_field, nh_up, nh_down, 10, 1000);
  dec = new ChangeData (f_nh_field, nh_up, nh_down, -10, 10);
  SET_CALLBACK_D (nh_up,Activate,change_cb,inc);
  SET_CALLBACK_D (nh_up,Arm,arm_arrow,inc);
  SET_CALLBACK (nh_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (nh_down,Activate,change_cb,dec);
  SET_CALLBACK_D (nh_down,Arm,arm_arrow,dec);
  SET_CALLBACK (nh_down,Disarm,disarm_arrow);

  inc = new ChangeData (f_sh_field, sh_up, sh_down, 10, 1000);
  dec = new ChangeData (f_sh_field, sh_up, sh_down, -10, 10);
  SET_CALLBACK_D (sh_up,Activate,change_cb,inc);
  SET_CALLBACK_D (sh_up,Arm,arm_arrow,inc);
  SET_CALLBACK (sh_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (sh_down,Activate,change_cb,dec);
  SET_CALLBACK_D (sh_down,Arm,arm_arrow,dec);
  SET_CALLBACK (sh_down,Disarm,disarm_arrow);

  // Create Search preferences.

  DECLM (WXmPushButton,   search,            options_menu,  "search");

  mtfstring = CATGETS(Set_AgentLabel, 189, "Searching");
  XtVaSetValues(search, XmNlabelString, (XmString)mtfstring, NULL);

  DECL  (WXmForm,         search_form,       container,     "search_prefs");
  DECLM (WXmLabel,        max_hits_label,    search_form,   "max_hits");
  DECL  (WXmForm,         hits_form,         search_form,   "hits_form");
  ASSNM (WXmTextField,    f_max_hits_field,  hits_form,     "hits_field");
  DECLM (WXmArrowButton,  hits_up,           hits_form,     "hits_up");
  DECLM (WXmArrowButton,  hits_down,         hits_form,     "hits_down");
  DECLM (WXmLabel,        adisplay_label,    search_form,   "adisplay_label");
  ASSNM (WXmToggleButton, f_adisplay_toggle, search_form,   "adisplay_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 199, "Maximum Search Hits");
  XtVaSetValues(max_hits_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 200, "Auto Display First Hit");
  XtVaSetValues(adisplay_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_adisplay_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_max_hits_field.Height();
  max_hits_label.Height (height);
  hits_up.Height (height/2);
  hits_down.Height (height/2);
  adisplay_label.Height (height);

  hits_form.Manage();
  search_form.Manage();

  SET_CALLBACK_D (search,Activate,switch_to_window,(Widget)search_form);
  SET_CALLBACK (f_max_hits_field,ValueChanged,something_changed);

  inc = new ChangeData (f_max_hits_field, hits_up, hits_down, 10, 500);
  dec = new ChangeData (f_max_hits_field, hits_up, hits_down, -10, 10);
  SET_CALLBACK_D (hits_up,Activate,change_cb,inc);
  SET_CALLBACK_D (hits_up,Arm,arm_arrow,inc);
  SET_CALLBACK (hits_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (hits_down,Activate,change_cb,dec);
  SET_CALLBACK_D (hits_down,Arm,arm_arrow,dec);
  SET_CALLBACK (hits_down,Disarm,disarm_arrow);
  SET_CALLBACK (f_adisplay_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_adisplay_toggle,ValueChanged,adisplay_toggle);

  /* -------- node history size, search history size -------- */

  options.SubMenuId (options_menu);

  container.Manage();
  form.DefaultButton (f_ok);
  form.ShadowThickness (0);
  form.Manage();

  f_shell.Realize();
  Dimension width;
  f_shell.Get (WArgList (XmNheight, (XtArgVal) &height,
			 XmNwidth, &width,
			 NULL));
  f_shell.Set (WArgList (XmNminHeight, height,
			 XmNmaxHeight, height,
			 XmNminWidth,  width,
			 XmNmaxWidth,  width,
			 NULL));

  map_form.Unmanage();
  hist_form.Unmanage();
  search_form.Unmanage();

  // Values get displayed when reset() is called on dialog display. 
  init_values();
}
示例#30
0
文件: ScopeMenu.C 项目: juddy/edcde
void
ScopeMenu::receive (ScopeCreated &msg, void *client_data)
{
  int position = 0;
  const char *scope_name = msg.f_search_scope->name();
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);
  bool need_sep = TRUE;

  int n;
  Arg args[2];
  WidgetList kids;
  Cardinal num_kids;

  n = 0;
  XtSetArg(args[n], XmNnumChildren, &num_kids); n++;
  XtSetArg(args[n], XmNchildren, &kids); n++;
  XtGetValues(f_pull_menu, args, n);

  UAS_SearchScope *scope;

  if (msg.f_search_scope->read_only())
  {
    // insert read-only scopes at the start; reserve position 0
    // for "Current Section" scope and position 1 for
    // the "All Libraries" scope
    position = 2;
    need_sep = FALSE;
  }
  else
  {
    // Scan the current menu to find the correct insertion position. 
    for (; s != 0; s++, position++)
    {
      scope = s.item();
      if (need_sep != scope->read_only())
      {
        position++;  // skip separator
        need_sep = FALSE;
      }
      if (scope->read_only())
	continue;
      // Find the first item that the new entry belongs after.
      ON_DEBUG (printf ("Scope strcmp to <%s>\n", scope->name()));
      if (strcmp (scope_name, scope->name()) < 0)
	break;
    }
  }

  ON_DEBUG (printf ("Final position = %d\n", position));

  // Add a separator if this is the first user-defined entry. 
  if (need_sep == TRUE)
  {
    DECLM (WXmSeparator, separator, f_pull_menu, "separator");
    separator.PositionIndex (position);
    position++;
  }

  // Create the new toggle button. 
  DECLM (WXmPushButtonGadget, scope_btn, f_pull_menu, scope_name);
  scope_btn.PositionIndex (position);
  scope_btn.UserData (msg.f_search_scope);
  WCallback *cb = SET_CALLBACK(scope_btn,Activate,set_scope);
  SET_CALLBACK_D(scope_btn,Destroy,destroy_scope,cb);
}