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
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#16 Post by Karl Godt »

Somehow I don't really like the gettext approach .
It makes code reading much more difficult in my opinion .
I would at least prefer to

Code: Select all

alias gettext='_g'
to reduce the code a little bit .

See alias for gettext :http://en.wikipedia.org/wiki/Gettext
printf(gettext("My name is %s.\n"), my_name);

would become:

printf(_("My name is %s.\n"), my_name);
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

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

#17 Post by Nathan F »

zigbert wrote:Hello Nathan
I haven't looked into the code, but want to mention that it is not necessary to use imagemagic or something else to resize images. gtkdialog does that internally. Maybe you have other reasons for keeping a separate buffer of all previews...

This code is taken from pMusic - how it shows the album art. Basically, it is the same as what you want.

Code: Select all

<hbox height-request="90">
	<eventbox tooltip-text="'$(gettext 'Show track-info window')'" above-child="true" visible-window="true" spacing="0" space-expand="false" space-fill="false">
		<pixmap>
			<variable>ARTWORK</variable>
			<input file>'$WORKDIR'/albumart.jpg</input>
			<height>90</height>
		</pixmap>
		<action signal="enter-notify-event">disable:ARTWORK</action>
		<action signal="leave-notify-event">enable:ARTWORK</action>
		<action signal="button-release-event">trackinfo</action>
	</eventbox>
<hbox>
Putting the pixmap inside an eventbox, makes it clickable and it gives a fake prelight.
The <height> defines the resizing, while the height-request defines the widget height in the gui. I see that you don't rely on Puppy, but I find it cruel :) to depend on imagemagic just for a wallpaper switcher.


Sigmund
Sigmund, that's awesome, thank you. Does that work for width as well? If so it's exactly what I need.

As for relying on imagemagick, there was as of late last night both an imagemagick and netpbm backend. Of which the netpbm backend is (drumroll...) insanely faster, and so would have been automatically selected if all the tools were on the host system had I gotten that far.

It's been a while since I messed with gtkdialog so I'm a bit rusty. Tips such as that are extremely helpful. Yesterday I fought with getting the right signal sent from the list widget for quite some time until I figured out the magic combination was simply "selection-changed". Until then, it had been returning the previously selected item. But I have to say, the improvements to gtkdialog are most welcome.
Bring on the locusts ...

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

#18 Post by Nathan F »

And it works fine, after figuring out one idiosyncrasy. Turns out gtkdialog was sending out the selection changed signal twice, once for leaving the previously selected list item and once for entering the newly selected item. So the first way I tried to do it this

Code: Select all

ln -sf \$WP_DIR/\$WP $USERCONFIGDIR/current.png
Was returning the $WP_DIR var and not the $WP var, resulting in the directory of the background image getting linked in, and then an error because it tried to link the image to itself.

The simple fix was almost exactly what you guys had done to the old setter when you added the preview function. Test if the selection was a file, and then test if it was an image, before creating the link.

Anyway it works like a charm now. Thanks again Sigmund.

Karl - under advisement. I've been reading up on gettext a bit and think the picture is starting to become clear now. I'll try and gettext this app when it's closer to a release and add a .pot file.

Incidentally, the feh backend is working for setting backgrounds. Haven't tried the rox backend but it should theoretically also work, as it's substantially the same code as the "set_bg" script in the old program. So it's now officially a working program, just not very user friendly as there's no way to switch between the two backends without editing the config file yet.
Bring on the locusts ...

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#19 Post by zigbert »

Nathan
You can set <width> as well, but I haven't tested to force a resize with a different aspect ratio than the original image.

Be aware that the list and table widgets are not supported by gtk3. If you intend support gtk3 (gtkdialog does) you should use the tree widget instead. The tree widget is also the most powerful out of the 3, since Thunor has met many of my queries of new features. I use pMusic as a testbench for gtkdialog to push the limits. And with pMusic 4, all lists/db's are rewritten to use the tree widget.

And yes, much have happened with gtkdialog since you wandered around here.

Great to hear from you !!!
Things tend to be more innovative with Nathans around :)


Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#20 Post by zigbert »

Nathan F wrote:I'll try and gettext this app when it's closer to a release and add a .pot file.
No need of a .pot file. MoManager creates the .pot file for any script - not for compiled binaries, of course.

On the other side; MoManager is only included in the Puppy distro, so for other translators out there, a .pot file might be required.


Sigmund

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?

Post Reply