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 Thu 17 Apr 2014, 17:24
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 2 of 3 [37 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Mon 05 Aug 2013, 07:46    Post subject:  

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:
alias gettext='_g'
to reduce the code a little bit .

See alias for gettext :http://en.wikipedia.org/wiki/Gettext

Quote:
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 Razz
Back to top
View user's profile Send private message Visit poster's website 
Nathan F


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

PostPosted: Mon 05 Aug 2013, 09:18    Post subject:  

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:
<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 Smile 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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
Nathan F


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

PostPosted: Mon 05 Aug 2013, 10:01    Post subject:  

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:
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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: Mon 05 Aug 2013, 10:14    Post subject:  

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 Smile


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: Mon 05 Aug 2013, 10:17    Post subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Nathan F


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

PostPosted: Mon 05 Aug 2013, 10:32    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
sunburnt


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

PostPosted: Mon 05 Aug 2013, 12:36    Post subject:  

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.
.
Back to top
View user's profile Send private message 
Nathan F


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

PostPosted: Mon 05 Aug 2013, 13:31    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
Nathan F


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

PostPosted: Mon 05 Aug 2013, 15:07    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
sunburnt


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

PostPosted: Mon 05 Aug 2013, 20:05    Post subject:  

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.
.
Back to top
View user's profile Send private message 
Nathan F


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

PostPosted: Tue 06 Aug 2013, 00:13    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
sunburnt


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

PostPosted: Tue 06 Aug 2013, 03:09    Post subject:  

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.
.
Back to top
View user's profile Send private message 
Nathan F


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

PostPosted: Tue 06 Aug 2013, 03:45    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
Nathan F


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

PostPosted: Tue 06 Aug 2013, 14:44    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
sunburnt


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

PostPosted: Tue 06 Aug 2013, 22:44    Post subject:  

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:
#!/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
.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [37 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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