Requesting variants of my "wallpaper" program

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#21 Post by Nathan F »

Didn't realize list was deprecated. If memory serves the swap to tree should be straightforward though.

As for the .pot file, I intend to support more than just Puppy. Puppy is a target audience of course.

ROX-Filer backend works. I just need to create a handy way to switch between them (and any other backends that get cobbled up). It's starting to be fun.
Bring on the locusts ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#22 Post by sunburnt »

Hi Nathan; It`s been quite awhile.

My main thought is that I`m glad you made your wallpaper app a RoxApp.
It`s my favorite wallpaper setter, the std. Puppy one really sucks badly.

Most folks here know why RoxApps and SFS files are better than Pets.

# I would hope that this becomes a trend for Puppy and Linux in general.


Also a good idea would be to not use GtkDialog as it`s only Puppy.
But if the background code is a separate file from the gui, then it`s not bad.

The BaCon Basic language compiles to exec. files, so it`s more portable.
It can make GTK+ guis, however the guis are more limited than GtkDialog.
But it can also import GTK+ code which adds lots of GTK+ capability.
.

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#23 Post by Nathan F »

Hi Sunburnt, yes it's been quite a long time. Glad to hear from you though.

I'd like to get this part over with and just say, I never really meant to leave, or to abandon Grafpup for that matter. My personal life fell apart. Not going into details other than to say it has taken me from '08 until just recently to achieve any sort of stability again, but things are much better now and I'm feeling an itch to contribute again.

I understand the spirit of what you said about gtkdialog, but I tend to disagree a bit. Puppy may have been the distro that truly embraced gtkdialog, but it compiles anywhere and I installed it in Arch via a package in the AUR. As a matter of fact a number of people use pBurn on other distros. I'm a strong advocate FOR gtkdialog. I believe Zigbert in particular has shown that amazingly complex apps can be build using this simple tool.

I personally have no interest in coding anything matching the complexity of something like pBurn, but what I would like to do is design a few more simple, elegant, and useful apps.

I am also just beginning to investigate gtk-server and it looks very promising. I may try and cobble a few simple things together using it soon.

As for BaCon, I understand it's place but for me, personally, I'd just as soon dive right into C programming as take the time to learn Basic.

I will include a roxapp in the distribution of the new wallpaper setter, and possibly even a "make roxapp" target to put all of the code in a roxapp. But the primary distribution method I'm going to support will be installation via the included Makefile, which makes it more attractive for someone wanting to package it for another distribution or os.
Bring on the locusts ...

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#24 Post by Nathan F »

I just posted the first alpha tarball - see thread. Further discussion of the new program should go there of course.

Thanks to all who chimed in.
Bring on the locusts ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#25 Post by sunburnt »

Further thoughts; Basic is just that, very basic and simple to learn.

Interestingly... GtkServer is by Peter who is the author of BaCon.!
And yes, GtkServer is very interesting and very portable also.

A "compile and build RoxApp" is a clever idea, I`ll look into it a bit...


# Is your wallpaper setter`s background code separate from the GUI.?

If so, I`ll make a BaCon-HUG GUI for it so it can be tested for portability.

Bash script is pretty portable, so GtkServer is too, as is BaCon I think.
.

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#26 Post by Nathan F »

It's partially separate from the gui. There's a script called in <prefix>/lib/wallpaper that sources the appropriate backend and mode and actually sets the wallpaper. It should be trivial to add other backends as well.

When I think about it, I bet a different gui could be used without too much tweaking. Heck, I could probably tie my wallpaper setting pipemenu into the same set of functions. Right now it uses a config file, but it could very well use any backends made for this program. Food for thought anyway.
Bring on the locusts ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#27 Post by sunburnt »

Separate code and gui are how I`ve always written my gui apps.
Except in BaCon, I`ve done most in a single file, but bigger apps. I`ll do separate.

And config. files are no problem and a really good idea.

# To make it simple for me, can you verify cli examples of the script`s commands.?

The menu bar [File] is actually the slideshow. Not too important, or use buttons.

# Looks like the commands list would be:

Apply
Clear
Edit
View
File

And the image filter radio buttons. Only Apply and File are really needed.
.

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#28 Post by Nathan F »

The new version is almost a scratch rewrite after all, so forget any assumptions based on the old app.

I will double check to make sure the backend can be used truly independent of the gui, and if not I will change things to where it can. Once I've done that I'll post specific details. Expect it sometime in the afternoon (USA Eastern) as I'm off work and off to bed in a couple hours.

And yeah, separate frontend/backend is my preference too. Before Grafpup went kaput I had the package manager functioning quite nicely in that fashion, always wished Puppy had followed suit.
Bring on the locusts ...

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#29 Post by Nathan F »

OK Sunburnt, here's the lowdown on the backend usage for the new version. There may be more to come at a later date, but I'll commit to keeping the following stable.

The backend script that sets the background is <prefix>/lib/wallpaper/set-wallpaper.sh. It takes the mode as arg1 and the image file as arg2. The modes are Stretch Scale Center and Tile, which are then remapped to the appropriate commands by the plugin scripts for each backend.

The userconfig directory is the same as the old program - $HOME/.config/wallpaper. The gui saves a list of directories that the user has chosen in <configdir>/wp-dirs. The previously selected directory is saved as <configdir>/wp-dir. The chosen backend is saved as <configdir>/backend. Those 3 files are just plain text single line files, easy to parse. My feeling is it would be appropriate for any secondary gui to use the same, so that if a user tried out more than one gui their selections would persist from session to session.

Any questions or comments fire away and I'll get back to you. Note that it's stripped -waay- down from what the old program offered and that this is quite intentional, but feel free to create something with more options if that's what floats your boat - I'm sure a lot of people would like that. The only things I may add back in personally are the slideshow feature and a launcher for external programs, both in the Options tab so as to keep the main program window nice and clean looking.
Bring on the locusts ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#30 Post by sunburnt »

I got your setup to load a new wallpaper.

But while I was in: /usr/local/apps I noticed the RoxApp "wallpaper-setter".
I think it`s the back-end for the Rox right-click menu item [ Set as wallpaper ]
Right-click is always easy to use, but it doesn`t show an image preview.

It looks very simple:

Code: Select all

#!/bin/sh

# Determine the path to this application.
CURDIR="`pwd`"
APPDIR=`dirname "$0"`
cd "${APPDIR}"
APPDIR="`pwd`"
cd "${CURDIR}"
IMAGE="$1"

[ "$1" = "-clear" ] && IMAGE=""

MODE="`cat $HOME/.config/wallpaper/backgroundmode`"
[ "$MODE" = "" ] && MODE="Stretch"
[ "$MODE" = "Centred" ] && MODE="Centre"
[ "$MODE" = "Scaled" ] && MODE="Scale"

rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <SetBackdrop>
   <Filename>$IMAGE</Filename>
   <Style>$MODE</Style>
  </SetBackdrop>
 </env:Body>
</env:Envelope>

EOF

echo "$IMAGE" > $HOME/.config/wallpaper/bg_img
The wallpaper and mode are set by the xml code, as is yours.
Wallpaper is a coomade argument, and the mode is from the config. file.

The wallpaper`s config. file: $HOME/.config/wallpaper/bg_img
The Mode`s config. file: $HOME/.config/wallpaper/backgroundmode
.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#31 Post by sunburnt »

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: Select all

'###	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
Attachments
0_WallPuppy.png
(112.08 KiB) Downloaded 304 times
wallpuppy.gz
(46.63 KiB) Downloaded 196 times

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#32 Post by Nathan F »

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.
Last edited by Nathan F on Wed 07 Aug 2013, 10:40, edited 1 time in total.
Bring on the locusts ...

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#33 Post by Nathan F »

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: Select all

pngtopnm (file) | pamscale -width=200 | pnmtopng > (outfile)
Starting with a jpeg, output a jpeg at 200px high:

Code: Select all

jpegtopnm (file) | pamscale -height=200 | pnmtojpeg > (outfile)
Starting with an svg, output a png at 200px wide:

Code: Select all

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 ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#34 Post by sunburnt »

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: Select all

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
.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#35 Post by sunburnt »

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?

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#36 Post by Nathan F »

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 ...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#37 Post by sunburnt »

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: Select all

### 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

Post Reply