📄 filestyles.txt
字号:
1999-05-31 Emil Brink gentoo File Styles1. INTRODUCTIONThis file documents the file style subsystem in gentoo. A goodunderstanding of file styles is important in order to maximizeyour comfort in gentoo.2. NEW vs. OLD STYLE SYSTEMIf you've never used gentoo prior to version 0.11.7, you can skipthis section entierly, since it deals with changes to the stylesystem that occured with the mentioned release. As of 0.11.7, file style properties are fully dynamic.This means that there are no "built-in" properties of any kind,neither visual nor action. Prior versions of gentoo featured aset of built-in properties (they were Default, View, Edit, Printand Play). There was a need to support user-defined actions, butI couldn't find a clean way of extending the old code to supportthat. So I tore it all away, designed a style system with fullydynamic properties, and implemented that instead. The style systemin gentoo 0.11.7 is the result. If you want a particular property to be available, justadd it at a suitable point in the style tree. It will be propagatedby inheritance to all styles below the one where you added it. If you want to change the value of an inherited propertyat some point in the tree, just override it. The new value willpropagate downwards. Older versions of gentoo featured a command for each built-in property (the FileDefault, FileView, ... commands). Since I don'twant to dynamically add commands as properties are created, thesecommands have been replaced by the single FileAction command. Ifcalled with no parameters, this command will run the Default actionproperty. If called with an "action=X" argument, it will run theproperty called X.3. WHAT IS A STYLE?A style is an abstract object. Its main purpose is to serve as acontainer for a set of related "properties", and to provide aninheritance hierarchy for these properties. Styles are tightlycoupled to the concept of "types"; each type is always connectedto exactly one style. Styles are arranged in a tree. The tree has a single rootstyle (commonly called "Root", although you can rename it if youwant to) and as many child styles as you need. The tree can haveany depth; you can add child styles to child styles to build thehierarchy up recursively.4. WHAT IS A PROPERTY?Properties are what make styles useful. A property is a named valueof a certain type. Currently, three different types of properties are supportedby gentoo: colors, icons and actions. The two former are usuallyrefered to as "visual" properties. The point of properties is to contain the information gentooneeds to display and handle dirpane rows of various types in a use-ful and correct way.4.1 Property InheritanceThe properties are inherited downwards in the tree, from the firststyle that define them, down to all its children. This means thatif the root style defines a property called "A", all child styles(i.e., all other styles) will also have a property called "A" withthe value defined by the root. At any style, you can override the inherited value of aproperty, thus causing the new value to propagate instead of theold. Using inheritance saves work, and makes maintaining thestyles much easier and less error-prone. Basically, it is a goodthing. :)4.2 Visual PropertiesVisual properties control how gentoo renders the rows of a pane.There are three visual properties in use: background and foregroundcolors, and icon. The two former control the colors used for rowbackground and text (foreground), when the row has not been sel-ected by the user. As soon as a row is selected, it reverts tousing GTK+'s standard selection colors. The icon property containsthe name of the icon graphics to use for the style.4.3 Action PropertiesAction properties specify commands that can operate on files ofa given type. You then use the FileAction command to envoke thesecommands by property name. All styles should have a default action property (typicallycalled "Default"), inherited from the root. The "Default" actionis what is executed when you double click on a row in a pane. Formany styles, it makes sense to make the default action cause thefiles contents to be viewed, by setting the property to "FileActionaction=View" and defining a suitable View action.5. CONFIGURING STYLESTo modify the current style tree, open up gentoo's configurationwindow (execute the builtin command Configure). Then click the tablabelled "File Styles". It might be helpful to have the window openand visible while reading this, since there will be many referencesto various things in the window. The style config page can be divided vertically into fourareas of interest. At the top is the style tree itself. It shows, using a nicetree widget, the current style tree. At the top of the tree is theroot style, and below it are all its children. The connections bet-ween styles are shown with lines.5.1 Name and ParentBelow the style tree are two text entry fields, labelled Name andParent, respectively. The Name entry field shows the name of the currently selectedstyle, and lets you type directly to rename the style. The Parent text field is not editable. When a style isselected, it shows the name of the style's immediate parent. You canclick the button to the right of the field (with the magnifying glass)to pop up a dialog that lets you select a new parent for the style. If the current style has any child styles of its own, theentire branch will be moved if you change the parent.5.2 PropertiesUnderneath the name & parent fields is a frame titled "InheritedProperties". It contains a notebook with two pages: one for visualproperties, and one for the actions.5.2.1 Visual PropertiesThe visual property page contains a little preview, showing you howthe colors and icon look together. It also holds three frames, one for each of the threestandard visual properties (background color, foreground color, andicon). To set a visual property, make sure the "Override Parent's?"check button is checked (depressed). Then click the button below thecheck button, the one with the "Edit..." or "Pick..." label. Thiswill pop up a dialog where you can make the desired changes. To revert back to the parent's value for a given property,simply uncheck the override check button.5.2.2 Action PropertiesThe action property page contains a list of all action propertiesthe current style has. Note that not all of these are actually setin the style itself: the list shows inherited properties as well. To modify an action property's value (its command), justselect it in the list and type the new value in the entry boxlabelled "Command". Clicking the magnifying-glass button to theright of the entry field pops up a dialog where you can choosefrom the currently defined commands. Changing the command of an action property automaticallyoverrides the property, i.e. the new value will be propagated toany child styles, and the inherited one will be ignored from thisstyle on. Note that even if you change it back to the same valueas the parent has, it will remain overridden. You can add a new action property by clicking on thebutton labelled "Add Action...". This will pop up a dialog askingyou for the name of the action to add. I suggest using a singleword, with an uppercase initial (like "Default", "View", "Edit",and so on). Initially, the property will not have a useful valueassigned to it. Select it in the list, and follow the instructionsgiven above to set the value you want. Removing a property you added is simple: just select it,and then click the button labeled "Delete Action" (it's to theright of the "Add Action..." button). This will immediately removethe action from the current style and all its children. If thedelete-button reads "Revert to Inherited Command" rather than"Delete Action", the selected action is an overridden inheritedone. You cannot remove inherited properties, but you can make themassume the inherited value rather than the one set locally in thecurrent style, by clicking this button. If the button is ghosted(drawn greyed out), the property is a normal inherited one, andcan be neither removed nor reverted. This is the normal state,and probably the one you'll see the most often.5.3 Adding and Deleting StylesTo add a new style, first select the style you wish to have asparent for the new one. Then click the "Add" button in the bottomof the page. This will add a new style as a child to the previouslyselected one. To delete a style, select it and click the "Delete" buttonin the bottom-right corner of the page. If the selected style hasany children, deleting it will also remove the children. This mightbe very inconvenient if done to the wrong style, so there will bea confirmation dialog if the style has children.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -