mikshaw
Group: Members
Posts: 4856
Joined: July 2004 |
|
Posted: Feb. 15 2005,21:01 |
|
I've tried it a little...doesn't seem to be much different than xtdesk.
I put together a Lua FLTK script for making icons. The file browser in Lua FLTK seems to be pretty limited...it doesn't seem to have a lot of the options that are available in FLTK. There is apparently no image support, and I don't even think you can change the font.
Code Sample | #!/bin/flua
-- dsl-create_icon.flua -- mikshaw Feb2005
-- DEFAULTS xtdesk_dir = getenv("HOME").."/.xtdesktop/" xtdesk_tmp = "/tmp/xtdeskPIDtmp" w_main_width = 360 w_main_height = 380 b_w = 80 -- button width b_h = 25 -- button height b_vs = b_h+5 -- button vertical spacing b_hs = b_w+30 -- button horizontal spacing Fl_Widget.initializers = {textfont = 15, labelfont = 15, labelcolor = 15} Fl_Input_.initializers = {when = When.changed, color = 0, textcolor = 2, cursor_color = 15, selection_color = 8} Fl_Button.initializers = {box = Boxtype.thin_up, down_box = Boxtype.thin_down, color = 8, labelcolor = 2} Fl_Round_Button.initializers = {box = Boxtype.none, color = 8, labelcolor = 15, selection_color = 2, type = Buttontype.radio, align = Align.right} Fl_Window.initializers = {box = Boxtype.thin_down, color = 0}
function hide_mounts() icon_mount_label:hide() icon_mount:hide() icon_mount_browse:hide() icon_umount_label:hide() icon_umount:hide() icon_umount_browse:hide() icon:show() icon_label:show() icon_browse:show() end
function show_mounts() icon_mount_label:show() icon_mount:show() icon_mount_browse:show() icon_umount_label:show() icon_umount:show() icon_umount_browse:show() icon:hide() icon_label:hide() icon_browse:hide() end
-- BEGIN LAYOUT -- HELP w_help = Window{w_main_width,w_main_height, "help"} help_text = Box{10-w_main_width,0,w_main_width,w_main_height,"link filename: The filename for your *.lnk file,\nlisted with no extension or leading path.\n\n".. "\choose icon: The image file(s) used for your icon.\nFor a mount icon two images are requested, one for \nthe unmounted state and one for the mounted state.\n\n".. "command: The full command which will be run when \nthe icon is clicked.\n\n".. "caption: The text which will be displayed on the \ndesktop next to the icon.\n\n".. "x pos & y pos: The horizontal(X) and vertical(Y) \nlocation of your icon, in pixels.\n\n".. "more: Additional features for the icons. Some features \nmay not work for some versions of xtdesk.\n\n\n\n".. "lua fltk script by mikshaw, 2005";align=Align.right} w_help:end_layout()
w_main = Window{w_main_width,w_main_height, "dsl-create_icon"}
-- NAME OF LNK FILE file_name_label = Box{24,10,100,20,"link filename:"} file_name = Input{30,30,120,20,".lnk";align=Align.right}
-- SPECIFY TYPE OF ICON icon_type1 = Round_Button{200,30,20,20,"program"} function icon_type1.callback() if old_command_value then command.value = old_command_value end if old_extras_value then extras.value = old_extras_value end if old_caption_value then caption.value = old_caption_value end if old_filename_value then file_name.value = old_filename_value end hide_mounts() end icon_type2 = Round_Button{275,30,20,20,"mount"} function icon_type2.callback() if command.value then old_command_value = command.value end command.value = "mount" if extras.value then old_extras_value = extras.value end extras.value = "MenuCommand1: Mount CDROM : mount /dev/cdrom \nMenuCommand2: Umount CDROM : umount /dev/cdrom \nMenuCommand3: Eject CDROM : eject /dev/cdrom \n" if caption.value then old_caption_value = caption.value end caption.value = "/dev/cdrom" if file_name.value then old_filename_value = file_name.value end file_name.value = "cdrom" show_mounts() end icon_type1.value = 1 -- default is 'Program'
-- SPECIFY ICON FILE icon_label = Box{18,50,100,20,"choose icon:"} icon = Input{30,70,280,20} icon_browse = Button{310,70,20,20,"@>";labeltype=Labeltype.symbol} function icon_browse.callback() icon.value = fl_file_chooser("Choose An Icon","*.{jpg,gif,png,xpm}",xtdesk_dir) end
icon_umount_label = Box{39,50,100,20,"choose umount icon:"} icon_umount = Input{30,70,280,20} icon_umount_browse = Button{310,70,20,20,"@>";labeltype=Labeltype.symbol} function icon_umount_browse.callback() icon_umount.value = fl_file_chooser("Choose An Icon For Umounted Drive","*.{jpg,gif,png,xpm}",xtdesk_dir) end
icon_mount_label = Box{36,90,100,20,"choose mount icon:"} icon_mount = Input{30,110,280,20} icon_mount_browse = Button{310,110,20,20,"@>";labeltype=Labeltype.symbol} function icon_mount_browse.callback() icon_mount.value = fl_file_chooser("Choose An Icon For Mounted Drive","*.{jpg,gif,png,xpm}",xtdesk_dir) end
command_label = Box{90,130,100,20,"command (including options, if any):"} command = Input{30,150,280,20} command_browse = Button{310,150,20,20,"@>";labeltype=Labeltype.symbol} function command_browse.callback() command.value = fl_file_chooser("Browse For Application","*","/usr/bin/") end
caption_label = Box{6,170,100,20,"caption:"} caption = Input{30,190,200,20} x_pos_label = Box{220,170,80,20,"x pos:"} x_pos = Int_Input{240,190,40,20;maximum_size=4} y_pos_label = Box{270,170,80,20,"y pos:"} y_pos = Int_Input{290,190,40,20;maximum_size=4}
extras_label = Box{111,220,100,20,"more ( MenuCommand<num>: label : command ):"} extras = Multiline_Input{30,240,300,56}
b_help = Button{30,320,b_w,b_h,"help"} function b_help.callback() w_help:show() end
b_create = Button{w_main_width-b_hs*2,320,b_w,b_h,"CREATE ICON"} function b_create.callback() filename = xtdesk_dir..file_name.value..".lnk" if icon_type2.value == 1 then icontype = "Mount" command.value = "mount" else icontype = "Program" end writeto(filename) write("table Icon\n".. "Type: "..icontype.."\n".. "Caption: "..caption.value.."\n".. "Command: "..command.value.."\n") if icontype == "Program" then write("Icon: "..icon.value.."\n") else write("IconMount: "..icon_mount.value.."\n".. "IconUmount: "..icon_umount.value.."\n") end write("X: "..x_pos.value.."\n".. "Y: "..y_pos.value.."\n".. extras.value.."\nend") execute("pidof xtdesk && echo \"xtdesk_pid = `pidof xtdesk`\" >"..xtdesk_tmp.." || echo \"xtdesk_pid = 0\" >"..xtdesk_tmp) dofile(xtdesk_tmp) remove(xtdesk_tmp) if xtdesk_pid > 0 then execute("killall xtdesk") end fl_message("Some things and stuff has been written to "..filename) if xtdesk_pid > 0 then execute("xtdesk >/dev/null &") end exit(0) end
b_exit = Button{w_main_width-b_hs,320,b_w,b_h,"exit"} function b_exit.callback() exit(0) end
w_main:end_layout() hide_mounts() w_main:show()
|
Be careful about copy and paste here...lines that wrap may paste as multiple lines. You may want to stretch your browser window out a bit until lines no longer wrap
-------------- http://www.tldp.org/LDP/intro-linux/html/index.html
|