Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Oct 2014, 09:54
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Requesting variants of my "wallpaper" program
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 3 of 3 Posts_count   Goto page: Previous 1, 2, 3
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Wed 07 Aug 2013, 01:00    Post_subject:  

Here`s WallPuppy... My complete effort in BaCon, it only took an evening to write.
It`s all in one file ( sorry about that ), but it`s small, and it could be split up.
I didn`t bother to use fancy GTK+ icon buttons, but if there`s interest...

It uses a stand-alone BaCon exec. file I wrote called "stdDlgs", that makes the GTK+ FileDialog and MsgDialog run cli from Bash.

I`ve attached the exec. file.
And included the BaCon Basic code so you can see:
Code:

'###   WallPuppy: Wallpaper setter.   Terry Becker   SunBurnt   Aug. 5  2013

INCLUDE "/root/0_BaCon/BaCon/hug.bac",INIT,DISPLAY,WINDOW,BUTTON,COMBO,IMAGE \
      ,HUGENTRY,FILEDIALOG,ATTACH,CALLBACK,TEXT,GRAB$
INIT

                                    '###   Exit this app.
SUB btnCLOSE
   END
END SUB
                                    '###   Show wallpaper.
SUB IMG
   thumb$ = "/root/.config/wallpaper/thumb.png"
   SYSTEM "picscale -i " & PF$ & " -o " & thumb$ & " 400 200 9"
   TEXT(img_, thumb$)
END SUB
                                    '###   Run FileDialog.
SUB btnFILER
   PF$ = CHOP$(EXEC$("stdDlgs -fo"))
   TEXT(txt_, PF$)
   IMG
END SUB
                                    '###   Show the filer.
SUB btnAPPLY
                              '#   PF$ = Wallpaper: /path/file
   IF NOT(FILEEXISTS(PF$)) THEN EXIT SUB
                                          ' write mode to config.
   SYSTEM "echo " & GRAB$(cbo_) & " > $HOME/.config/wallpaper/backgroundmode"
                                          ' set wallpaper & mode
   SYSTEM "/usr/local/apps/wallpaper-setter/AppRun " & PF$
END SUB

                                          ' read image /path/file
PF$ = CHOP$(EXEC$("cat $HOME/.config/wallpaper/bg_img"))
'=======================================================   Start GUI Code.
winW = 400
winH = 300
win_ = WINDOW("  WallPuppy", winW, winH)

img_ = IMAGE(PF$, winW-20, winH-90) : ATTACH(win_, img_, 10, 10)

txt_ = HUGENTRY(PF$, winW-20, 25) : ATTACH(win_, txt_, 10, winH-70)

Y = winH - 35
btnFiler_ = BUTTON("Filer", 60, 25)
      ATTACH(win_, btnFiler_, 10, Y) : CALLBACK(btnFiler_, btnFILER)

cbo_ = COMBO("Stretch", 100, 25) : ATTACH(win_, cbo_, winW-250, Y)

btnApply_ = BUTTON("Apply", 60, 25)
      ATTACH(win_, btnApply_, winW-140, Y) : CALLBACK(btnApply_, btnAPPLY)

btnClose_ = BUTTON("Close", 60, 25)
      ATTACH(win_, btnClose_, winW-70, Y) : CALLBACK(btnClose_, btnCLOSE)
      
'====================   Fill the rest of the Combo Box items.
TEXT(cbo_, "Centered")
TEXT(cbo_, "Tiled")
TEXT(cbo_, "Scaled")
'===================   SUB to resize image and show in Image Box.
IMG

DISPLAY

It uses vovchik`s picscale to resize the images.
Vovchik, Big_Bass, and Barry K. are all members of the BaCon forum.

BaCon forum: http://basic-converter.proboards.com/

BaCon home page: http://www.basic-converter.org/

### Nathan: I`d like to know how the thumbnail script works.

There is no file: resamplefixedheight
0_WallPuppy.png
 Description   
 Filesize   112.08 KB
 Viewed   276 Time(s)

0_WallPuppy.png

wallpuppy.gz
Description 
gz

 Download 
Filename  wallpuppy.gz 
Filesize  46.63 KB 
Downloaded  126 Time(s) 
Back to top
View user's profile Send_private_message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Wed 07 Aug 2013, 06:12    Post_subject:  

The roxapp is from the old app, so you've got both old and new installed apparently.

EDIT: Looking over the pasted code it would be fairly trivial to rework it a bit to use the new program interface. I'm off to bed shortly, but I'll get back to you sometime soon.

_________________
Bring on the locusts ...

Edited_time_total
Back to top
View user's profile Send_private_message AIM YIM MSNM 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Wed 07 Aug 2013, 06:37    Post_subject:  

OK, looking it over your app is using the old app in it's entirety it would seem. That's OK, but you should know I've rather given up on it.

The thumb for the old app was added by others as the pixmap widget could not be refreshed at the time I wrote the original. What they did, and what I wound up doing as well, is just let gtkdialog handle the resizing by specifying either a width or a height.

However, it's fairly trivial to resize an image using netpbm tools should you care to know a little trick here. The gotcha is that you have to use a pipeline, and the first command will be different depending on the image format.
Start with a png, rescale to a png at 200px wide:
Code:
pngtopnm (file) | pamscale -width=200 | pnmtopng > (outfile)

Starting with a jpeg, output a jpeg at 200px high:
Code:
jpegtopnm (file) | pamscale -height=200 | pnmtojpeg > (outfile)

Starting with an svg, output a png at 200px wide:
Code:
rsvg-convert (file) | pngtopnm | pamscale -width=200 | pnmtopng > (outfile)


Basically it's a lot easier than you might think, and I checked to be sure that all of those particular tools are in Puppy Precise. This is exactly what I was trying to do originally before I realized that gtkdialog would just take care of it for me, and quicker to boot.

I should give a nod to the nice looking gui you created though.

_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Wed 07 Aug 2013, 10:41    Post_subject:  

If you want, I`ll separate the GUI and the background code, and do icon buttons.

The help from vovchik`s picscale, it does lots of input formats, a few output..
Code:
picscale image resizer/converter - v.0.1b by vovchik, Puppy Linux Forum, July 2011

Input formats supported: pnm, pbm, pgm, ppm, tga, xpm, tiff, pcx, gif,
xbm, wmf, icns, bmp, png, jpg and ico.

Output formats supported: png, jpg, bmp, tiff and ico.

Input parameters: -i oldfilename -o newfilename height width quality/compression/depth

Example: picscale -i old.png -o new.png 128 128 9

Quality/compression/depth settings:

   bmp (N/A):               0 - 100
   jpeg (quality):          0 - 100
   png (compression):       0 - 9
   tiff (compression type): 1 - 8
   ico (depth):             16, 24 or 32

Check out BaCon at www.basic-converter.org

Here`s a link to get it at the BaCon site: http://www.basic-converter.org/picscale.bac.html
.
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Thu 08 Aug 2013, 02:39    Post_subject:  

Hey Natan, is there another way to set the wallpaper in Rox?

This works, but it doesn`t do the modes.

rox -p /root/Choices/ROX-Filer/PuppyPin

The XML code is giving BaCon fits.

What are the 2 web addresses in the XML code for?
Back to top
View user's profile Send_private_message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Wed 14 Aug 2013, 15:58    Post_subject:  

Sorry, for some reason I didn't see this until now.

The two addresses in the code, I'm not sure of. The code comes straight from the ROX-Filer manual.

Another thing you could do is parse the xml for the pinboard file and rewrite the contents of the <backdrop> tag along with the "style=" tag attribute. That could be done with a single sed line if well executed. You would have to then restart the pinboard.

The basic problem with that approach is that as far as I can tell there is no way to be sure what pinboard is currently in use, and since ROX-Filer supports multiple pinboards you'd have to either take a stab in the dark or have a config setting for it.

I personally would just keep the actual code for setting the backdrop as an external shell command.

_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Wed 14 Aug 2013, 23:07    Post_subject:  

Yeah, I`m sure Rox did it that way for a good reason.
BaCon has just upgraded the REPLACE command, so it does the XML replacement.

This is the sed fix you speak of:
Code:
### Set Rox wallpaper.
img=$1
mode=$2
pp=/root/Choices/ROX-Filer/PuppyPin
sed -i "s#backdrop style.*\<##;#backdrop style\"$mode\"\>$img\<##" $pp
rox -p $pp
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 3 of 3 Posts_count   Goto page: Previous 1, 2, 3
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1016s ][ Queries: 12 (0.0295s) ][ GZIP on ]