Пример #1
0
/* returns:
 *            0 on success
 *              1 if data is empty
 *              2 if ConfigWriter cannot be initialized
 *
 */
int
WriteWharfOptions (const char *filename, char *myname,
									 WharfConfig * config, unsigned long flags)
{
	ConfigDef *WharfConfigWriter = NULL;
	FreeStorageElem *Storage = NULL, **tail = &Storage;
	TermDef *folder_term = func2fterm (F_Folder, True);
	int i;

	if (config == NULL)
		return 1;

	folder_term->sub_syntax = &WharfSyntax;

	if ((WharfConfigWriter =
			 InitConfigWriter (myname, &WharfSyntax, CDT_Filename,
												 (void *)filename)) == NULL)
		return 2;

	CopyFreeStorage (&Storage, config->more_stuff);

	if (config->style_defs)
		*tail =
				MyStyleDefinitionsList2free_storage (config->style_defs,
																						 &WharfSyntax);

	if (config->balloon_conf)
		tail = balloon2FreeStorage (&WharfSyntax, tail, config->balloon_conf);

	/* building free storage here */
	/* geometry */
	if (get_flags (config->set_flags, WHARF_GEOMETRY))
		tail =
				Geometry2FreeStorage (&WharfSyntax, tail, &(config->geometry),
															WHARF_Geometry_ID);
	if (get_flags (config->set_flags, WHARF_FORCE_SIZE))
		tail =
				Geometry2FreeStorage (&WharfSyntax, tail, &(config->force_size),
															WHARF_ForceSize_ID);
	/* Integer values : */
	/* rows */
	if (get_flags (config->set_flags, WHARF_ROWS))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL, config->rows,
														 WHARF_Rows_ID);
	/* columns */
	if (get_flags (config->set_flags, WHARF_COLUMNS))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL, config->columns,
														 WHARF_Columns_ID);
	/* withdraw_style */
	if (get_flags (config->set_flags, WHARF_WITHDRAW_STYLE))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL,
														 config->withdraw_style,
														 WHARF_WithdrawStyle_ID);
	/* texture_type  */
	if (get_flags (config->set_flags, WHARF_TEXTURE_TYPE))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL,
														 config->texture_type, WHARF_TextureType_ID);
	/* animate_steps */
	if (get_flags (config->set_flags, WHARF_ANIMATE_STEPS))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL,
														 config->animate_steps, WHARF_AnimateSteps_ID);
	/* animate_steps_main */
	if (get_flags (config->set_flags, WHARF_ANIMATE_STEPS_MAIN))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL,
														 config->animate_steps_main,
														 WHARF_AnimateStepsMain_ID);
	/* animate_delay */
	if (get_flags (config->set_flags, WHARF_ANIMATE_DELAY))
		tail =
				Integer2FreeStorage (&WharfSyntax, tail, NULL,
														 config->animate_delay, WHARF_AnimateDelay_ID);


	/* Flags : */
	tail =
			Flags2FreeStorage (&WharfSyntax, tail, WharfFlags, 0xFFFFFFFF,
												 config->set_flags);

	/* StringValues */
	/* bg_color */
	if (get_flags (config->set_flags, WHARF_BG_COLOR))
		tail =
				String2FreeStorage (&WharfSyntax, tail, config->bg_color,
														WHARF_BgColor_ID);

	/* texture_color */
	if (get_flags (config->set_flags, WHARF_TEXTURE_COLOR))
		tail =
				String2FreeStorage (&WharfSyntax, tail, config->texture_color,
														WHARF_TextureColor_ID);

	/* pixmap name */
	if (get_flags (config->set_flags, WHARF_PIXMAP))
		tail =
				String2FreeStorage (&WharfSyntax, tail, config->pixmap,
														WHARF_Pixmap_ID);

	/* sound */
	if (get_flags (config->set_flags, WHARF_SOUND))
		for (i = 0; i < WHEV_MAX_EVENTS; i++)
			tail =
					String2FreeStorage (&WharfSyntax, tail, config->sounds[i],
															WHARF_Sound_ID);

	/* Writing Wharf Entries : */
	if (config->root_folder)
		tail =
				WharfFolder2FreeStorage (&WharfSyntax, tail, config->root_folder,
																 True);

	/* writing config into the file */
	WriteConfig (WharfConfigWriter, Storage, CDT_Filename,
							 (void **)&filename, flags);
	DestroyFreeStorage (&Storage);
	DestroyConfig (WharfConfigWriter);

	if (Storage) {
		fprintf (stderr,
						 "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...",
						 myname);
		DestroyFreeStorage (&Storage);
		fprintf (stderr, (Storage != NULL) ? " failed." : " success.");
	}
	return 0;
}
Пример #2
0
/* returns:
 *		0 on success
 *		1 if data is empty
 *		2 if ConfigWriter cannot be initialized
 *
 */
int
WriteBaseOptions (const char *filename, char *myname, BaseConfig * config,
									unsigned long flags)
{
	ConfigDef *BaseConfigWriter = NULL;
	FreeStorageElem *Storage = NULL, **tail = &Storage;
	ConfigData cd;

	if (config == NULL)
		return 1;
	cd.filename = filename;
	if ((BaseConfigWriter =
			 InitConfigWriter (myname, &BaseSyntax, CDT_Filename, cd)) == NULL)
		return 2;

	CopyFreeStorage (&Storage, config->more_stuff);

	/* building free storage here */

	/* module_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->module_path,
													BASE_MODULE_PATH_ID);

	/* icon_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->icon_path,
													BASE_ICON_PATH_ID);

	/* pixmap_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->pixmap_path,
													BASE_PIXMAP_PATH_ID);

	/* cursor_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->cursor_path,
													BASE_CURSOR_PATH_ID);

	/* sound_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->sound_path,
													BASE_SOUND_PATH_ID);

	/* myname_path */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->myname_path,
													BASE_MYNAME_PATH_ID);

	/* IconTheme */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->IconTheme,
													BASE_IconTheme_ID);
	/* IconThemePath */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->IconThemePath,
													BASE_IconThemePath_ID);
	/* IconThemeFallback */
	tail =
			String2FreeStorage (&BaseSyntax, tail, config->IconThemeFallback,
													BASE_IconThemeFallback_ID);

	/* desktop_size */
	tail =
			Geometry2FreeStorage (&BaseSyntax, tail, &(config->desktop_size),
														BASE_DESKTOP_SIZE_ID);

	/* desktop_scale */
	tail =
			Integer2FreeStorage (&BaseSyntax, tail, NULL, config->desktop_scale,
													 BASE_DESKTOP_SCALE_ID);

	cd.filename = filename;
	/* writing config into the file */
	WriteConfig (BaseConfigWriter, Storage, CDT_Filename, &cd, flags);
	DestroyFreeStorage (&Storage);
	DestroyConfig (BaseConfigWriter);

	return 0;
}
Пример #3
0
/* returns:
 *            0 on success
 *              1 if data is empty
 *              2 if ConfigWriter cannot be initialized
 *
 */
int
WriteFeelOptions (const char *filename, char *myname,
		  FeelConfig * config, unsigned long flags)
{
	ConfigDef *ConfigWriter = NULL;
    FreeStorageElem *Storage = NULL, **tail = &Storage;
    int i ;

	if (config == NULL)
  		return 1;
	if ((ConfigWriter = InitConfigWriter (myname, &FeelSyntax, CDT_Filename,
			  (void *) filename)) == NULL)
	    return 2;

    CopyFreeStorage (&Storage, config->more_stuff);

	/* building free storage here */
    /* flags : */
    tail = Flags2FreeStorage (&FeelSyntax, tail, FeelFlagsXref, config->feel->flags, config->feel->flags);

    /* integer parameters : */
    if (get_flags (config->feel->set_flags, FEEL_ClickTime))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->ClickTime, FEEL_ClickTime_ID);
    if (get_flags (config->feel->set_flags, FEEL_OpaqueMove))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->OpaqueMove, FEEL_OpaqueMove_ID);
    if (get_flags (config->feel->set_flags, FEEL_OpaqueResize))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->OpaqueResize, FEEL_OpaqueResize_ID);
    if (get_flags (config->feel->set_flags, FEEL_AutoRaise))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->AutoRaiseDelay, FEEL_AutoRaise_ID);
    if (get_flags (config->feel->set_flags, FEEL_AutoReverse))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->AutoReverse, FEEL_AutoReverse_ID);
    if (get_flags (config->feel->set_flags, FEEL_DeskAnimationType))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->DeskAnimationType, FEEL_DeskAnimationType_ID);
    if (get_flags (config->feel->set_flags, FEEL_DeskAnimationSteps))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->DeskAnimationSteps, FEEL_DeskAnimationSteps_ID);
    if (get_flags (config->feel->set_flags, FEEL_ShadeAnimationSteps))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->ShadeAnimationSteps, FEEL_ShadeAnimationSteps_ID);

    if (get_flags (config->feel->set_flags, FEEL_XorValue))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->XorValue, FEEL_XorValue_ID);
    if (get_flags (config->feel->set_flags, FEEL_Xzap))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->Xzap, FEEL_Xzap_ID);
    if (get_flags (config->feel->set_flags, FEEL_Yzap))
        tail = Integer2FreeStorage (&FeelSyntax, tail, NULL, config->feel->Yzap, FEEL_Yzap_ID);

    for( i = 0 ; i < MAX_CURSORS ; i++ )
    {
        if (config->feel->standard_cursors[i] != 0)
            tail = Integer2FreeStorage (&FeelSyntax, tail, &i, config->feel->standard_cursors[i], FEEL_Cursor_ID);
        if (config->feel->custom_cursors[i] != NULL)
            tail = ASCursor2FreeStorage (&FeelSyntax, tail, i, config->feel->custom_cursors[i], FEEL_CustomCursor_ID);
    }

    if (get_flags (config->feel->set_flags, FEEL_ClickToRaise))
        Bitlist2FreeStorage( &FeelSyntax, tail, config->feel->RaiseButtons, FEEL_ClickToRaise_ID);

    if (get_flags (config->feel->set_flags, FEEL_EdgeScroll))
        Integer2FreeStorage( &FeelSyntax, tail, &(config->feel->EdgeScrollX), config->feel->EdgeScrollY, FEEL_EdgeScroll_ID);
    if (get_flags (config->feel->set_flags, FEEL_EdgeResistance))
        Integer2FreeStorage( &FeelSyntax, tail, &(config->feel->EdgeResistanceScroll), config->feel->EdgeResistanceMove, FEEL_EdgeResistance_ID);

    /* complex functions : */
    if( config->feel->funcs_list )
        if( config->feel->funcs_list->items_num )
        {
            ComplexFunction **list ;

            list = safecalloc( config->feel->funcs_list->items_num, sizeof(ComplexFunction*));
            if( (i = sort_hash_items( config->feel->funcs_list, NULL, (void**)list, 0 )) > 0 )
                while ( --i >= 0 )
                    tail = ComplexFunction2FreeStorage( &FeelSyntax, tail, list[i]);
            free( list );
        }
    /* menus */
    /* menus writing require additional work due to the nature of the problem -
     * menus can come from file or directory or from feel file itself.
     * plus there has to be some mechanismus in place in order to preserve
     * .include configuration when menu is saved as directory.
     *          Sasha.
     */
    /* this is preliminary code that only saves menus into feel file itself  - make sure
     * you remove all the other menus from the feel->menus_list prior to calling this */
    if( config->feel->menus_list )
        if( config->feel->menus_list->items_num )
        {
            MenuData **list ;
            register int i ;
            list = safecalloc( config->feel->menus_list->items_num, sizeof(MenuData*));
            if( (i = sort_hash_items( config->feel->menus_list, NULL, (void**)list, 0 )) > 0 )
                while ( --i >= 0 )
                    tail = MenuData2FreeStorage( &FeelSyntax, tail, list[i]);
            free( list );
        }
    /* mouse bindings : */
    for( i = 0 ; i < MAX_MOUSE_BUTTONS+1 ; i++ )
    {
        char btn_id[2] ;
        btn_id[0] = '0'+i ;
        btn_id[1] = '\0' ;
        tail = Contexts2FreeStorage( &FeelSyntax, tail, btn_id, &(config->feel->mouse[i]), FEEL_Mouse_ID );
    }

    /* keyboard bindings : */
    if( config->feel->keyboard )
        if( config->feel->keyboard->items_num > 0 )
        {
            ASHashableValue  *keys;
            ASInputContexts **contexts;
            unsigned int items_num = config->feel->keyboard->items_num ;

            keys = safecalloc( items_num, sizeof(ASHashableValue) );
            contexts = safecalloc( items_num, sizeof(ASInputContexts*) );
            items_num = sort_hash_items( config->feel->keyboard, keys, (void**)contexts, 0 );
            for( i = 0 ; i < items_num ; i++ )
            {
                KeySym keysym = (KeySym)keys[i];
                tail = Contexts2FreeStorage( &FeelSyntax, tail, XKeysymToString(keysym), contexts[i], FEEL_Key_ID );
            }
        }

    /* writing config into the file */
	WriteConfig (ConfigWriter, Storage, CDT_Filename, (void **) &filename, flags);
	DestroyFreeStorage (&Storage);
    DestroyConfig (ConfigWriter);

	if (Storage)
  	{
    	fprintf (stderr,
	  		     "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...",
	      		 myname);
    	DestroyFreeStorage (&Storage);
  		fprintf (stderr, (Storage != NULL) ? " failed." : " success.");
    }
	return 0;
}
Пример #4
0
int
WriteSoundOptions (const char *filename, char *myname, SoundConfig * config, unsigned long flags)
{
	ConfigDef    *SoundConfigWriter = NULL;
	FreeStorageElem *Storage = NULL, **tail = &Storage;
    register int i ;
	ConfigData cd ;

	if (config == NULL)
		return 1;
	cd.filename = filename ;

	if ((SoundConfigWriter = InitConfigWriter (myname, &SoundSyntax, CDT_Filename, cd)) == NULL)
		return 2;
	CopyFreeStorage (&Storage, config->more_stuff);
	/* building free storage here */
	/* PCM Device */
	if( config->pcmdevice )
		tail = String2FreeStorage (&SoundSyntax, tail, config->pcmdevice, SOUND_PCMDEVICE_ID);
		
	if (config->debug)
		tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->debug, SOUND_DEBUG_ID);
	/* delay */
/*
	if( get_flags(config->set_flags, SOUND_SET_DELAY) )
    	tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->delay, SOUND_DELAY_ID);
*/
	/* rplay_host */
//	if (get_flags(config->set_flags, SOUND_SET_RPLAY_HOST) && config->rplay_host)
//        tail = String2FreeStorage (&SoundSyntax, tail, config->rplay_host, SOUND_RPLAY_HOST_ID);

	/* rplay_priority */
//	if (get_flags(config->set_flags, SOUND_SET_RPLAY_PRIORITY))
//        tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->rplay_priority, SOUND_RPLAY_PRI_ID);

	/* rplay_volume */
//	if( get_flags(config->set_flags, SOUND_SET_RPLAY_VOLUME) )
//        tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->rplay_volume, SOUND_RPLAY_VOL_ID);

	/* line structure */
    for( i = EVENT_ID_END-EVENT_ID_START-1 ; i >=0 ; i-- )
        if( config->sounds[i] )
        {
            FreeStorageElem **dtail = tail ;

            tail = Flag2FreeStorage (&SoundSyntax, tail, SOUND_SOUND_ID);
            if( *dtail )
                Path2FreeStorage (&SoundEventsSyntax, &((*dtail)->sub), NULL, config->sounds[i], EVENT_ID_START + i);
        }

    /* writing config into the file */
	WriteConfig (SoundConfigWriter, Storage, CDT_Filename, &cd, flags);
	DestroyFreeStorage (&Storage);
	DestroyConfig (SoundConfigWriter);

	if (Storage)
	{
		fprintf (stderr, "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...", myname);
		DestroyFreeStorage (&Storage);
		fprintf (stderr, (Storage != NULL) ? " failed." : " success.");
	}
	return 0;
}