免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 925 | 回复: 0
打印 上一主题 下一主题

FvwmButtons [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-21 18:23 |只看该作者 |倒序浏览
FvwmButtons, also known as GoodStuff, is sometimes overlooked by new fvwm users, despite being the most powerful software for creating desktop panels available today.
I've written this guide to introduce FvwmButtons to new users, and take anyone interested step by step through creating a simple panel. Hopefully this will help get you started a little quicker than the man page alone .
This is the panel I am going to create.



It's very simple, has a set of nine buttons that can be bound to applications or window controls. It also has an xclock along the top.
Of course, FvwmButtons has many, many features I havn't mentioned here, but this should be enough to get started.

Step 1: Planning
Fvwm uses a flat text based configuration, which is not an intuitive method for designing user interfaces. The solution is to use a graphics package to create a template to work from. You can use any package you like, The GIMP, xpaint, dia, or even xfig.
Here is a screenshot of me planning this panel in dia..


As you can see I have an outline and the approximate layout of the buttons all plotted in dia. Don't worry about this template being perfect, we are just going to use it to estimate the dimensions in the next step.
Step 2: Dimensions
Now that you have a template to work from, you can calculate what the minimum grid size you will need in order to contain your buttons.
This is a lot simpler than it sounds, we just need to know how many rows and columns we should split our panel into. Each button can take up any whole number of grid squares, so we just have to make sure we have enough.


As you can see, we need a minimum grid of 7 rows and 3 columns so that each button occupies a whole number of grid squares. The top button requires one row and 3 columns, the other buttons need 2 rows and 1 columns.
Step 3: Create Buttons
Now that we have the dimensions needed, we can make an absolute minimum FvwmButtons configuration to test the dimensions.
You can tweak the button geometries and grid size until everything looks right.
Code:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1) ##3 表示列, 1 表示行.
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
As you can see, each configuration line for our panel starts with an asterisk, then the panel alias. Lines that dont use brackets are settings, lines that do are button definitons. The buttons defined here only have one setting, how many rows and columns they need.
You can enter this in your fvwm2rc and restart, or paste it into an FvwmConsole. I've used DestroyModuleConfig so that if you paste the configuration into FvwmConsole twice, fvwm knows that you are not trying to continue the same configuration.
Now lets try starting the panel, enter the following into your FvwmConsole
Code:
Module FvwmButtons -g 178x207 LaunchTime
The -g specifies the Geometry, it tells FvwmButtons how big you want the panel to be (and also where you want it to appear).
Hopefully, you should see a window like this


Not very exciting yet, but don't worry, move on to the next step where we will configure the buttons and add the bindings.
Step 4: Fill in the blanks
Swallowing is what FvwmButtons calls Reparenting, it basically means any application window can be used as a button on your panel. So lets use this concept to swallow an xclock into our new panel.
First lets find a command line for xclock that looks suitable for our panel.
Code:
xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'
This is what I have used. Now lets tell our panel how to start the clock.
Code:
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
The first setting is the Rows and Columns we want, then the Swallow command. the next argument is the name of the window FvwmButtons should look out for, followed by the Fvwm command needed to start the window.
Here is our new Panel:
Code:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Enter the configuration into your FvwmConsole, and start the panel to make sure everything has worked, hopefully you will see a window like this:


Now for the next button, Let's make it a launcher for The GIMP.
Code:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png)
As you can see, we have the dimensions, a Title and an Icon. All we need now is to define an Action. Actions are responses to Clicks, so lets say we want the first mouse button to start the gimp.
Code:
Action(Mouse 1) `Exec gimp`
Lets enter this into the button definition.
Code:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png, Action(Mouse 1) `Exec gimp`)
The configuration should now look like this:
Code:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png, Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Test out the panel, if everything looks okay fill in the rest of the buttons.
Code:
DestroyModuleConfig LaunchTime: *                                    
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png, Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1) `Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1) `Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png, Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse 1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1) `Pick WindowShade True`)
Start the panel and you should see something like:


Step 5: Finalise Panel
Test all your buttons, make sure everything is working, Hopefully it is and you can setup Colorsets, Fonts, Frames, Padding and any other setting you want!
Code:
Colorset 30 fg black, bg #c6c3c6, RootTransparent buffer, Tint #efebef 65
DestroyModuleConfig LaunchTime: *                                    
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: Font "xft:Bitstream Vera Sans Mono:style=Roman:size=8"
*LaunchTime: Colorset 30
*LaunchTime: Frame 1
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png, Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1) `Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1) `Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png, Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec "gvim" gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse 1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1) `Pick WindowShade True`)
Try out the new Panel!
Code:
Module FvwmButtons -g 178x207 LaunchTime
Hopefully you should see something similar to this:

Now all you have to do is set any Style options you want, and decide how to start your panel. Did you notice the extra argument to Exec on the gvim button? Try pressing it, notice the button will stay down until a window called gvim appears! You can do this for all the buttons, if you like it.
Maybe you would like LaunchTime to always be visible?
Code:
Style LaunchTime StaysOnTop
And lets start it everytime we login
Code:
AddToFunc StartFunction
+ I Module FvwmButtons -g 178x207 LaunchTime
And finally, lets add it to a menu:
Code:
AddToMenu MyRootMenu
+ "Start LaunchTime" Module FvwmButtons -g 178x207 LaunchTime

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/6165/showart_69720.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP