ASFlagType
ParseAlignOptions( FreeStorageElem * options )
{
    ASFlagType align = 0 ;
    while( options )
	{
        LOCAL_DEBUG_OUT( "options(%p)->keyword(\"%s\")", options, options->term->keyword );
        if (options->term != NULL)
		{
			switch( options->term->id )
			{
				case ALIGN_Center_ID :
					set_flags( align, ALIGN_CENTER );
				    break ;
				case ALIGN_HCenter_ID :
					set_flags( align, ALIGN_HCENTER );
				    break ;
				case ALIGN_VCenter_ID :
					set_flags( align, ALIGN_VCENTER );
				    break ;
				default:
            		ReadFlagItem (NULL, &align, options, AlignFlagsXref);
			}
		}
        options = options->next;
    }
    return align;
}
ASFlagType
ParseBevelOptions( FreeStorageElem * options )
{
    ASFlagType bevel = 0 ;
    while( options )
	{
        LOCAL_DEBUG_OUT( "options(%p)->keyword(\"%s\")", options, options->term->keyword );
        if (options->term != NULL)
            ReadFlagItem (NULL, &bevel, options, BevelFlagsXref);
        options = options->next;
    }
    return bevel;
}
Exemple #3
0
WharfConfig *ParseWharfOptions (const char *filename, char *myname)
{
	ConfigData cd;
	ConfigDef *ConfigReader;
	WharfConfig *config = CreateWharfConfig ();
	FreeStorageElem *Storage = NULL, *pCurr;
	ConfigItem item;
	TermDef *folder_term = func2fterm (F_Folder, False);

	cd.filename = filename;
	ConfigReader =
			InitConfigReader (myname, &WharfSyntax, CDT_Filename, cd,
												NULL /*WharfSpecialFunc */ );
	if (!ConfigReader)
		return config;

	folder_term->sub_syntax = &WharfSyntax;

	item.memory = NULL;
	PrintConfigReader (ConfigReader);
	ParseConfig (ConfigReader, &Storage);

	/* getting rid of all the crap first */
	StorageCleanUp (&Storage, &(config->more_stuff), CF_DISABLED_OPTION);
	config->balloon_conf =
			Process_balloonOptions (Storage, NULL, BALLOON_ID_START);
	config->style_defs = free_storage2MyStyleDefinitionsList (Storage);

	for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
		if (pCurr->term == NULL)
			continue;
		if (ReadFlagItem
				(&(config->set_flags), &(config->flags), pCurr, WharfFlags)) {
			continue;
		}
		if (!ReadConfigItem (&item, pCurr))
			continue;
		switch (pCurr->term->id) {
		case WHARF_Wharf_ID:
			item.ok_to_free = 1;
			ParseWharfFolder (&pCurr, &(config->root_folder));
			break;
		case WHARF_Geometry_ID:
			set_flags (config->set_flags, WHARF_GEOMETRY);
			config->geometry = item.data.geometry;
			break;
		case WHARF_Rows_ID:
			set_flags (config->set_flags, WHARF_ROWS);
			config->rows = item.data.integer;
			break;
		case WHARF_Columns_ID:
			set_flags (config->set_flags, WHARF_COLUMNS);
			clear_flags (config->set_flags, WHARF_ROWS);
			config->columns = item.data.integer;
			break;
		case WHARF_WithdrawStyle_ID:
			set_flags (config->set_flags, WHARF_WITHDRAW_STYLE);
			config->withdraw_style = item.data.integer;
			break;
		case WHARF_ForceSize_ID:
			set_flags (config->set_flags, WHARF_FORCE_SIZE);
			config->force_size = item.data.geometry;
			/* errorneous value check */
			if (!(config->force_size.flags & WidthValue))
				config->force_size.width = 64;
			if (!(config->force_size.flags & HeightValue))
				config->force_size.height = 64;
			config->force_size.flags = WidthValue | HeightValue;
			break;
		case WHARF_TextureType_ID:
			set_flags (config->set_flags, WHARF_TEXTURE_TYPE);
			config->texture_type = item.data.integer;
			break;
		case WHARF_BgColor_ID:
			set_string_value (&(config->bg_color), item.data.string,
												&(config->set_flags), WHARF_BG_COLOR);
			break;
		case WHARF_TextureColor_ID:
			set_string_value (&(config->texture_color), item.data.string,
												&(config->set_flags), WHARF_TEXTURE_COLOR);
			break;
		case WHARF_Pixmap_ID:
			set_string_value (&(config->pixmap), item.data.string,
												&(config->set_flags), WHARF_PIXMAP);
			break;
		case WHARF_AnimateStepsMain_ID:
			set_flags (config->set_flags, WHARF_ANIMATE_STEPS_MAIN);
			config->animate_steps_main = item.data.integer;
			break;
		case WHARF_AnimateSteps_ID:
			set_flags (config->set_flags, WHARF_ANIMATE_STEPS);
			config->animate_steps = item.data.integer;
			break;
		case WHARF_AnimateDelay_ID:
			set_flags (config->set_flags, WHARF_ANIMATE_DELAY);
			config->animate_delay = item.data.integer;
			break;
		case WHARF_Sound_ID:
			if (pCurr->sub == NULL) {
				if (pCurr->argc > 0) {
					register char *sound = mystrdup (pCurr->argv[pCurr->argc - 1]);

					set_string_value (&(config->sounds[WHEV_PUSH]), sound,
														&(config->set_flags), WHARF_SOUND);
				}
			} else if (pCurr->sub->argc > 0) {
				register char *sound = mystrdup (pCurr->sub->argv[0]);

				set_string_value (&
													(config->
													 sounds[WHEV_Id2Code (pCurr->sub->term->id)]),
													sound, &(config->set_flags), WHARF_SOUND);
			}
			item.ok_to_free = 1;
			break;
			ASCF_HANDLE_INTEGER_KEYWORD_CASE (WHARF, config, item,
																				LabelLocation);
			ASCF_HANDLE_ALIGN_KEYWORD_CASE (WHARF, config, pCurr, AlignContents);
			ASCF_HANDLE_BEVEL_KEYWORD_CASE (WHARF, config, pCurr, Bevel);
			ASCF_HANDLE_SUBSYNTAX_KEYWORD_CASE (WHARF, config, pCurr, ShowHints,
																					BalloonContents);
			ASCF_HANDLE_INTEGER_KEYWORD_CASE (WHARF, config, item,
																				CompositionMethod);
			ASCF_HANDLE_INTEGER_KEYWORD_CASE (WHARF, config, item, FolderOffset);
			ASCF_HANDLE_INTEGER_KEYWORD_CASE (WHARF, config, item,
																				OrthogonalFolderOffset);
		default:
			if (pCurr->term->type != TT_FLAG)
				item.ok_to_free = 1;
		}
	}
	if (get_flags (config->set_flags, WHARF_Bevel))
		clear_flags (config->flags, WHARF_NO_BORDER);


	ReadConfigItem (&item, NULL);
	SHOW_CHECKPOINT;
	DestroyConfig (ConfigReader);
	SHOW_CHECKPOINT;
	DestroyFreeStorage (&Storage);
	SHOW_CHECKPOINT;
	return config;
}
Exemple #4
0
ASWindowBox *
ProcessWindowBoxOptions (FreeStorageElem * options)
{
	ConfigItem    item;
    ASWindowBox  *aswbox = NULL ;

	item.memory = NULL;

	for (; options; options = options->next)
	{
		if (options->term == NULL)
			continue;
        LOCAL_DEBUG_OUT( "WindowBox(%p)->options(%p)->keyword(\"%s\")", aswbox, options, options->term->keyword );
		if (options->term->id < WINDOWBOX_ID_START || options->term->id > WINDOWBOX_ID_END)
			continue;

		if (options->term->type == TT_FLAG)
		{
            if( aswbox != NULL  )
            {
                if( options->term->id == WINDOWBOX_DONE_ID )
                    break;                     /* for loop */
		        if (ReadFlagItem (&(aswbox->set_flags), &(aswbox->flags), options, WindowBoxFlagsXref))
        		    continue;
            }
            continue;
        }

		if (!ReadConfigItem (&item, options))
        {
            LOCAL_DEBUG_OUT( "ReadConfigItem has failed%s","");
			continue;
        }
		if( options->term->id == WINDOWBOX_START_ID )
		{
			if( aswbox != NULL )
			{
				show_error( "Unterminated WindowBox found - will be ignored" );
                destroy_aswindow_box( aswbox, False );
                aswbox = NULL ;
			}
			aswbox = create_aswindow_box( item.data.string );
			item.ok_to_free = 1;
		}else if( aswbox != NULL )
		{
			switch( options->term->id )
			{
				case WINDOWBOX_Area_ID   	  	  :
					aswbox->area = item.data.geometry;
		            set_flags( aswbox->set_flags, ASA_AreaSet);
			    break ;
                case WINDOWBOX_MinWidth_ID        :
                    aswbox->min_width = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MinWidthSet);
                    break ;
                case WINDOWBOX_MinHeight_ID      :
                    aswbox->min_height = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MinHeightSet);
                    break ;
                case WINDOWBOX_MaxWidth_ID        :
                    aswbox->max_width = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MaxWidthSet);
                    break ;
                case WINDOWBOX_MaxHeight_ID      :
                    aswbox->max_height = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MaxHeightSet);
                    break ;
                case WINDOWBOX_FirstTry_ID        :
					if( options->sub != NULL && options->sub->term->id >= FEEL_PLACEMENT_START_ID ) 
					{	
                    	aswbox->main_strategy = options->sub->term->id - FEEL_PLACEMENT_START_ID ;
                    	set_flags( aswbox->set_flags, ASA_MainStrategySet);
					}
                    break ;
                case WINDOWBOX_ThenTry_ID         :
					if( options->sub != NULL && options->sub->term->id >= FEEL_PLACEMENT_START_ID ) 
					{	
                    	aswbox->backup_strategy = options->sub->term->id - FEEL_PLACEMENT_START_ID ;
                    	set_flags( aswbox->set_flags, ASA_BackupStrategySet);
					}
                    break ;
                case WINDOWBOX_Desk_ID            :
                    aswbox->desk = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_DesktopSet);
                    break ;
                case WINDOWBOX_MinLayer_ID        :
                    aswbox->min_layer = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MinLayerSet);
                    break ;
                case WINDOWBOX_MaxLayer_ID        :
                    aswbox->max_layer = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_MaxLayerSet);
                    break ;
                case WINDOWBOX_XSpacing_ID        :
                    aswbox->x_spacing = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_XSpacingSet);
                    break ;
                case WINDOWBOX_YSpacing_ID        :
                    aswbox->y_spacing = item.data.integer ;
                    set_flags( aswbox->set_flags, ASA_YSpacingSet);
                    break ;
                default:
					item.ok_to_free = 1;
                    show_warning( "Unexpected WindowBox definition keyword \"%s\" . Ignoring.", options->term->keyword );
			}
		}
    }
    LOCAL_DEBUG_OUT("done parsing WindowBox: [%s]", aswbox->name);
    ReadConfigItem (&item, NULL);
	return aswbox;
}
Exemple #5
0
FeelConfig *
ParseFeelOptions (const char *filename, char *myname)
{
    ConfigData cd ; 
	ConfigDef *ConfigReader;
    FeelConfig *config = CreateFeelConfig ();
	FreeStorageElem *Storage = NULL, *pCurr;
    ConfigItem item;

	cd.filename = filename ; 
	ConfigReader = InitConfigReader (myname, &FeelSyntax, CDT_Filename, cd, BindingSpecialFunc);
	if (!ConfigReader)
  		return config;

    item.memory = NULL;
	PrintConfigReader (ConfigReader);
	ParseConfig (ConfigReader, &Storage);

	/* getting rid of all the crap first */
    StorageCleanUp (&Storage, &(config->more_stuff), CF_DISABLED_OPTION);

	for (pCurr = Storage; pCurr; pCurr = pCurr->next)
  	{
  	    if (pCurr->term == NULL)
			continue;
        if (ReadFlagItem (NULL, &(config->feel->flags), pCurr, FeelFlagsXref))
            continue;
        if (!ReadConfigItem (&item, pCurr))
			continue;
        switch (pCurr->term->id)
		{
            case FEEL_ClickTime_ID          :
                config->feel->ClickTime = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_ClickTime);
                break ;
            case FEEL_OpaqueMove_ID         :
                config->feel->OpaqueMove = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_OpaqueMove);
                break ;
            case FEEL_OpaqueResize_ID       :
                config->feel->OpaqueResize = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_OpaqueResize);
                break ;
            case FEEL_AutoRaise_ID          :
                config->feel->AutoRaiseDelay = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_AutoRaise);
                break ;
            case FEEL_AutoReverse_ID        :
                config->feel->AutoReverse = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_AutoReverse);
                break ;
            case FEEL_ShadeAnimationSteps_ID :
                config->feel->ShadeAnimationSteps = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_ShadeAnimationSteps);
                break ;

            case FEEL_XorValue_ID           :
                config->feel->XorValue = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_XorValue);
                break ;
            case FEEL_Xzap_ID               :
                config->feel->Xzap = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_Xzap);
                break ;
            case FEEL_Yzap_ID               :
                config->feel->Yzap = item.data.integer;
                set_flags (config->feel->set_val_flags, FEEL_Yzap);
                break ;

            case FEEL_Cursor_ID             :                   /* TT_INTEGER */
				/* TODO: backport from as-devel : */
                /*if ( item.index  > 0 && item.index < MAX_CURSORS)
                    config->feel->standard_cursors[item.index] = item.data.integer ;
				 */
                break ;
            case FEEL_CustomCursor_ID       :                   /* TT_BUTTON  */
				/* TODO: backport from as-devel : */
				/*
					if ( item.index  > 0 && item.index < MAX_CURSORS)
                	{
                    	if( config->feel->custom_cursors[item.index] )
                        	destroy_ascursor( &(config->feel->custom_cursors[item.index]));
                    	config->feel->custom_cursors[item.index] = item.data.cursor ;
                	}
				 */
                break ;

            case FEEL_ClickToRaise_ID       :                   /* TT_BITLIST */
                config->feel->RaiseButtons = item.data.integer ;
                set_flags (config->feel->set_val_flags, FEEL_ClickToRaise);
                set_flags (config->feel->set_flags, ClickToRaise);
				set_flags (config->feel->flags, ClickToRaise);
                break ;

            case FEEL_EdgeScroll_ID         :                   /* TT_INTARRAY*/
				item.ok_to_free = 1;
                if( item.data.int_array.size > 0 )
                {
                    config->feel->EdgeScrollX = item.data.int_array.array[0];
                    if( item.data.int_array.size > 1 )
                        config->feel->EdgeScrollY = item.data.int_array.array[1];
                    set_flags (config->feel->set_val_flags, FEEL_EdgeScroll );
                }
                break ;
            case FEEL_EdgeResistance_ID     :                   /* TT_INTARRAY*/
				item.ok_to_free = 1;
                if( item.data.int_array.size > 0 )
                {
                    config->feel->EdgeResistanceScroll = item.data.int_array.array[0];
                    if( item.data.int_array.size > 1 )
                        config->feel->EdgeResistanceMove = item.data.int_array.array[1];
                    set_flags (config->feel->set_val_flags, FEEL_EdgeResistance );
                }
                break ;

            case FEEL_Popup_ID              :
				/* TODO: backport from as-devel : */
                /* FreeStorage2MenuData( pCurr, &item, config->feel->Popups ); */
                break ;
            case FEEL_Function_ID           :
                FreeStorage2ComplexFunction( pCurr, &item, config->feel->ComplexFunctions );
                break ;
            case FEEL_Mouse_ID              :
                if( item.data.binding.sym )
                    if( isdigit( (int)item.data.binding.sym[0] ) && pCurr->sub )
                    {
                        int button_num = item.data.binding.sym[0] - '0' ;
                        if( button_num >= 0 && button_num <= MAX_MOUSE_BUTTONS &&
                            pCurr->sub->term->type == TT_FUNCTION )
                        {
                            ConfigItem func_item ;
                            func_item.memory = NULL ;
                            if( ReadConfigItem( &func_item, pCurr->sub ) )
							{
								MouseButton *tmp = safecalloc( 1, sizeof(MouseButton) );
								tmp->Button = button_num ;
								tmp->Modifier = item.data.binding.mods ;
								tmp->Context = item.data.binding.context ;
								tmp->fdata = func_item.data.function ;
								func_item.data.function = NULL ;
								tmp->NextButton = config->feel->MouseButtonRoot ;
								config->feel->MouseButtonRoot = tmp ;
							}
                            if( func_item.data.function )
                            {
                                func_item.ok_to_free = 1;
                                ReadConfigItem( &func_item, NULL );
                            }
                        }
                    }
                item.ok_to_free = 1;
                break ;
            case FEEL_Key_ID                :
                ParseKeyBinding( &item, pCurr->sub, &(config->feel->FuncKeyRoot) );
                break ;
          default:
				item.ok_to_free = 1;
		}
    }
	ReadConfigItem (&item, NULL);

	DestroyConfig (ConfigReader);
	DestroyFreeStorage (&Storage);
	return config;
}
Exemple #6
0
BaseConfig *ParseBaseOptions (const char *filename, char *myname)
{
	BaseConfig *config = CreateBaseConfig ();
	FreeStorageElem *Storage = NULL, *pCurr;
	ConfigItem item;

	Storage =
			file2free_storage (filename, myname, &BaseSyntax, NULL,
												 &(config->more_stuff));
	if (Storage == NULL)
		return config;

	item.memory = NULL;

	for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
		if (pCurr->term == NULL)
			continue;
		if (ReadFlagItem
				(&(config->set_flags), &(config->flags), pCurr, BaseFlags))
			continue;
		if (!ReadConfigItem (&item, pCurr))
			continue;
		switch (pCurr->term->id) {
		case BASE_MODULE_PATH_ID:
			set_string (&(config->module_path), item.data.string);
			break;
		case BASE_SOUND_PATH_ID:
			set_string (&(config->sound_path), item.data.string);
			break;
		case BASE_ICON_PATH_ID:
			set_string (&(config->icon_path), item.data.string);
			break;
		case BASE_PIXMAP_PATH_ID:
			set_string (&(config->pixmap_path), item.data.string);
			break;
		case BASE_FONT_PATH_ID:
			set_string (&(config->font_path), item.data.string);
			break;
		case BASE_CURSOR_PATH_ID:
			set_string (&(config->cursor_path), item.data.string);
			break;
		case BASE_MYNAME_PATH_ID:
			set_string (&(config->myname_path), item.data.string);
			break;
		case BASE_GTKRC_PATH_ID:
			set_string (&(config->gtkrc_path), item.data.string);
			break;
		case BASE_GTKRC20_PATH_ID:
			set_string (&(config->gtkrc20_path), item.data.string);
			break;
		case BASE_DESKTOP_SIZE_ID:
			set_flags (config->set_flags, BASE_DESKTOP_SIZE_SET);
			config->desktop_size = item.data.geometry;
			/* errorneous value check */
			if (!(config->desktop_size.flags & WidthValue))
				config->desktop_size.width = 1;
			if (!(config->desktop_size.flags & HeightValue))
				config->desktop_size.height = 1;
			config->desktop_size.flags = WidthValue | HeightValue;
			break;
		case BASE_DESKTOP_SCALE_ID:
			set_flags (config->set_flags, BASE_DESKTOP_SCALE_SET);
			config->desktop_scale = item.data.integer;
			/* errorneous value check */
			if (config->desktop_scale < 1)
				config->desktop_scale = 1;
			break;
		case BASE_NoModuleNameCollisions_ID:
			set_flags (config->set_flags, BASE_NoModuleNameCollisions_SET);
			config->NoModuleNameCollisions = item.data.integer;
			break;
		case BASE_TermCommand_ID:
			if (item.index < MAX_TOOL_COMMANDS && item.index >= 0)
				set_string (&(config->term_command[item.index]), item.data.string);
			else
				item.ok_to_free = 1;
			break;
		case BASE_BrowserCommand_ID:
			if (item.index < MAX_TOOL_COMMANDS && item.index >= 0)
				set_string (&(config->browser_command[item.index]),
										item.data.string);
			else
				item.ok_to_free = 1;
			break;
		case BASE_EditorCommand_ID:
			if (item.index < MAX_TOOL_COMMANDS && item.index >= 0)
				set_string (&(config->editor_command[item.index]),
										item.data.string);
			else
				item.ok_to_free = 1;
			break;
		case BASE_IconTheme_ID:
			set_string (&(config->IconTheme), item.data.string);
			break;
		case BASE_IconThemePath_ID:
			set_string (&(config->IconThemePath), item.data.string);
			break;
		case BASE_IconThemeFallback_ID:
			set_string (&(config->IconThemeFallback), item.data.string);
			break;
		default:
			item.ok_to_free = 1;
		}
	}
	ReadConfigItem (&item, NULL);

	DestroyFreeStorage (&Storage);
	return config;
}