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 30 Oct 2014, 08:22
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
gtk2desklet 3.1
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 5 [71 Posts]   Goto page: 1, 2, 3, 4, 5 Next
Author Message
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sun 11 Dec 2011, 14:47    Post subject:  gtk2desklet 3.1
Subject description: (Was: gtkdialog-desklet) Convert many GTK2 programs into desktop apps
 

This is a GTK module, which can turn many GTK based programs into a desktop app.

It is likely that the module may not succeed. Till now, I confirm gtkdialog, sylpheed, Xdialog, leafpad and thunar to be working.

You make the target program load the module by just passing an extra argument to the program:
Code:

--gtk-module=gtk2desklet

e.g.
Code:

gtkdialog3 --program=WIDGET --gtk-module=gtk2desklet

Hopefully, if the program is structured properly, the program's window will appear on the desktop, transparent, and without borders.

Download gtk2desklet-3.1.pet (15.9 KB)

Older versions here

Screenshots:
gtkdialog:


gcolor2:

Last edited by akash_rawal on Sun 15 Jul 2012, 00:06; edited 19 times in total
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Mon 12 Dec 2011, 13:01    Post subject:  

akash_rawal,

Nice program. In testing I got this result.
Quote:

# gtkdialog-desklet --help
mktemp: invalid option -- -
Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]


Also, I wasn't sure exactly how to run this program- could you post some examples... perhaps the one for the "desklet_example.png" that you listed.

Thanks,
s
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Mon 12 Dec 2011, 13:04    Post subject:  

Wonderful Very Happy Very Happy Very Happy

Thanks a lot.
Would you become upset if I used this in Pwidgets ?


Sigmund

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


Joined: 11 Oct 2008
Posts: 7840
Location: qld

PostPosted: Mon 12 Dec 2011, 15:36    Post subject:  

Just a tip Wink

A useful option to the <button> tags with this mthod is reliief="2" has-focus="false"

More shortly...

..later

Try this crazy script! (it's a bit of fun Smile , oh, and Pwidgets must be running)
Code:
#!/bin/sh

WIDGETNAME=`basename $0`

#gif image to use (full path may be needed)
#this is the gif we use, I don't know if I can distribute
#so if it's not there then we download it
#http://caccioppoli.com/Animations/Navidad/54.gif
#you can use any image but you need to change X and Y
[ ! -f file.gif ] && \
wget http://caccioppoli.com/Animations/Navidad/54.gif
[ "$?" -ne "0" ] && echo "failed" && exit
mv *.gif file.gif
if [ -s file.gif ];then echo "ok"
  else echo "woops, empty load, try again after ctrl/C"
  rm -f file.gif
  exit
fi

GIF=file.gif

#secreensize
SCREEN=`xwininfo -root | grep ' \-geometry ' | tr -s ' ' | cut -f 3 -d ' ' | cut -f 1 -d '+' | tr 'x' ' '`
HEIGHT=`echo -n "$SCREEN" | cut -f 2 -d ' '`
WIDTH=`echo -n "$SCREEN" | cut -f 1 -d ' '`

[ ! -d /tmp/santawidget ] && mkdir /tmp/santawidget #workdir
DESKBG=`cat /root/.config/wallpaper/bg_img`
resizepng "$DESKBG" /tmp/santawidget/background.png $WIDTH $HEIGHT 50 #resize and move bg
IMAGE=/tmp/santawidget/background.png #this is .png, makes life easier! It's the one we cut
NEWIMAGE=/tmp/santawidget/${WIDGETNAME}_background #this is the result
BGHEIGHT=`file $IMAGE| cut -d ' ' -f6|tr -d ','`
BGWIDTH=`file $IMAGE| cut -d ' ' -f4`
YDIMENSION=$(($BGHEIGHT - 400))    #  150 #`echo $(($HEIGHT - 300))` #hard code for demo
XDIMPRE1=$((${BGWIDTH} / 2))
XDIMPRE2=205
XDIMPRE3=$((${XDIMPRE1} + ${XDIMPRE2}))
XDIMENSION=$((${BGWIDTH} - ${XDIMPRE3}))
NEWIMAGEPATH=/tmp/santawidget #pixmap_path
IMAGEFILE=${WIDGETNAME}_background #_${WIDGETNAME} #our widget background

#REPLACE THESE dimensions if you use a different image file
#hard coded for demo
#we can do a quick dummy run and get the info from xwininfo if geometry \
#is variable
X=410
Y=289

#code based on /usr/sbin/background_reshape BK
CROPLEFT=${XDIMENSION}
CROPTOP=${YDIMENSION}
#the magic #crop image using pamcut
pngtopnm $IMAGE | pamcut -left=${CROPLEFT} -top=${CROPTOP}  -height=$Y -width=$X | pnmtopng > $NEWIMAGE

#gtkrc ..our widget background, pseudo transparency
echo 'pixmap_path "'"$NEWIMAGEPATH"'"
style "'"${WIDGETNAME}-background"'"
{
   engine "pixmap"
   {
        image
        {
                function = FLAT_BOX
                file = "'"${IMAGEFILE}"'"
                border = {0, 0, 0, 0}
                detail = "base"
                stretch = FALSE
        }
   }
}
class "GtkWindow" style "'"${WIDGETNAME}-background"'"' >/tmp/gtkwidgetrc
export GTK2_RC_FILES=/tmp/gtkwidgetrc

export gui='<window title="'"${WIDGETNAME}"'" type-hint="7">
 <vbox>
  <pixmap>
   <input file>'"$GIF"'</input>
  </pixmap>
  <button has-focus="false" relief="2" tooltip-text="click to stop">
  </button>
 </vbox>
</window>'

gtkdialog -p gui -G  +${XDIMENSION}+${YDIMENSION} #${X}x${Y}

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Mon 12 Dec 2011, 20:54    Post subject:  

01micko,

Nice tip and polished stars for the widget Idea

Just a couple of corrections -

01micko wrote:

wget http://caccioppoli.com/Animations/Navidad/54.gif && \
[ "$?" -ne "0" ] && echo "failed" && exit

BGWIDTH=`file $IMAGE| cut -d ' ' -f5`


Regards,
s
Back to top
View user's profile Send private message 
puppyluvr


Joined: 06 Jan 2008
Posts: 3213
Location: Chickasha Oklahoma

PostPosted: Mon 12 Dec 2011, 23:30    Post subject:  

Very Happy Hello,
I get as far as "OK"..
Then I get:
Quote:
ok
./gtkdialog-desklets: line 53: pamcut: command not found
pnmtopng: Error reading magic number from Netpbm image stream. Most often, this means your input file is empty.

** (gtkdialog:3246): WARNING **: Pixbuf theme: Cannot load pixmap file /tmp/santawidget/gtkdialog-desklets_background: Image file '/tmp/santawidget/gtkdialog-desklets_background' contains no data


(gtkdialog:3246): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `GDK_IS_PIXBUF (pixbuf)' failed


The part I colored red repeats till I hit ctrl-c to stop it...
Where do I get "pamcut"???

_________________
Close the Windows, and open your eyes, to a whole new world
http://puppylinuxstuff.meownplanet.net/puppyluvr/
Puppy Linux Users Group on Facebook

Puppy since 2.15CE...
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7840
Location: qld

PostPosted: Tue 13 Dec 2011, 00:10    Post subject:  

Thanks seaside, I was a bit sloppy Embarassed

-

puppyluvr try pnmcut, I should have a test..

if [ `which pamcut` ];then CUT=pamcut
elif [ `which pnmcut` ];then CUT=pnmcut
else echo "sorry not cropping tool found" && exit
fi

obviously then you substitute pamcut with $CUT

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Tue 13 Dec 2011, 00:24    Post subject:  

01micko wrote:
Thanks seaside, I was a bit sloppy Embarassed

-

puppyluvr try pnmcut, I should have a test..

if [ `which pamcut` ];then CUT=pamcut
elif [ `which pnmcut` ];then CUT=pnmcut
else echo "sorry not cropping tool found" && exit
fi

obviously then you substitute pamcut with $CUT


Yes, I forgot to mention that I put-
ln -s /usr/bin/pnmcut /usr/bin/pamcut
at the top of the script.

Also one other correction-
BGHEIGHT=`file $IMAGE| cut -d ' ' -f7|tr -d ','`

I get the same pix errors, but it runs anyway....

Regards,
s
Back to top
View user's profile Send private message 
puppyluvr


Joined: 06 Jan 2008
Posts: 3213
Location: Chickasha Oklahoma

PostPosted: Tue 13 Dec 2011, 01:51    Post subject:  

Very Happy Hello,
Works now...
Tried a few different images..

2 questions:
1. Why does pwidgets have to be running...?
2. Which part controls screen location..? I cant seem to find it.. Embarassed

_________________
Close the Windows, and open your eyes, to a whole new world
http://puppylinuxstuff.meownplanet.net/puppyluvr/
Puppy Linux Users Group on Facebook

Puppy since 2.15CE...
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7840
Location: qld

PostPosted: Tue 13 Dec 2011, 07:59    Post subject:  

puppyluvr wrote:
Very Happy Hello,
Works now...
Tried a few different images..

2 questions:
1. Why does pwidgets have to be running...?
2. Which part controls screen location..? I cant seem to find it.. Embarassed
Answers
1) It doesn't, but you do need resizepng from pwidgets, actually it's a MU proggy, or you could change it to vovchik's bacon version.. I forget the name. I was a bit hasty in posting this morning!
2) XDIMENSION and YDIMENSION

Actually, I just had a moment to look at the code, I changed the file.gif test to an if statement, easier for me to fit in more!

Thanks to akash_rawal's work for the inspiration Smile

Code:
#!/bin/sh

WIDGETNAME=`basename $0`

#gif image to use (full path may be needed)
#this is the gif we use, I don't know if I can distribute
#so if it's not there then we download it
#http://caccioppoli.com/Animations/Navidad/54.gif
#you can use any image but you need to change X and Y
if [ ! -f file.gif ];then
  wget http://caccioppoli.com/Animations/Navidad/54.gif
    if [ "$?" -ne "0" ];then
     echo "failed" && exit
      else mv *.gif file.gif
    fi
fi
if [ -s file.gif ];then echo "ok"
  else echo "woops, empty load, try again after ctrl/C"
  rm -f file.gif
  exit
fi

GIF=file.gif

#secreensize
SCREEN=`xwininfo -root | grep ' \-geometry ' | tr -s ' ' | cut -f 3 -d ' ' | cut -f 1 -d '+' | tr 'x' ' '`
HEIGHT=`echo -n "$SCREEN" | cut -f 2 -d ' '`
WIDTH=`echo -n "$SCREEN" | cut -f 1 -d ' '`

[ ! -d /tmp/santawidget ] && mkdir /tmp/santawidget #workdir
if [ -f /root/.config/wallpaper/bg_img ];then DESKBG=`cat /root/.config/wallpaper/bg_img`
  else DESKBG=/usr/share/backgrounds/default.jpg
fi
resizepng "$DESKBG" /tmp/santawidget/background.png $WIDTH $HEIGHT 50 #resize and move bg
IMAGE=/tmp/santawidget/background.png #this is .png, makes life easier! It's the one we cut
NEWIMAGE=/tmp/santawidget/${WIDGETNAME}_background #this is the result
BGHEIGHT=`file $IMAGE| cut -d ' ' -f6|tr -d ','`
BGWIDTH=`file $IMAGE| cut -d ' ' -f4`
YDIMENSION=$(($BGHEIGHT - 400))    #  150 #`echo $(($HEIGHT - 300))` #hard code for demo
XDIMPRE1=$((${BGWIDTH} / 2))
XDIMPRE2=205
XDIMPRE3=$((${XDIMPRE1} + ${XDIMPRE2}))
XDIMENSION=$((${BGWIDTH} - ${XDIMPRE3}))
NEWIMAGEPATH=/tmp/santawidget #pixmap_path
IMAGEFILE=${WIDGETNAME}_background #_${WIDGETNAME} #our widget background

#REPLACE THESE dimensions if you use a different image file
#hard coded for demo
#we can do a quick dummy run and get the info from xwininfo if geometry \
#is variable
X=410
Y=289

#code based on /usr/sbin/background_reshape BK
CROPLEFT=${XDIMENSION}
CROPTOP=${YDIMENSION}
#the magic #crop image using pamcut
if [ `which pamcut` ];then CUT=pamcut
  elif [ `which pnmcut` ];then CUT=pnmcut
  else echo "sorry no cropping tool found" && exit
fi
pngtopnm $IMAGE | $CUT -left=${CROPLEFT} -top=${CROPTOP}  -height=$Y -width=$X | pnmtopng > $NEWIMAGE

#gtkrc ..our widget background, pseudo transparency
echo 'pixmap_path "'"$NEWIMAGEPATH"'"
style "'"${WIDGETNAME}-background"'"
{
   engine "pixmap"
   {
        image
        {
                function = FLAT_BOX
                file = "'"${IMAGEFILE}"'"
                border = {0, 0, 0, 0}
                detail = "base"
                stretch = FALSE
        }
   }
}
class "GtkWindow" style "'"${WIDGETNAME}-background"'"' >/tmp/gtkwidgetrc
export GTK2_RC_FILES=/tmp/gtkwidgetrc

export gui='<window title="'"${WIDGETNAME}"'" type-hint="7">
 <vbox>
  <pixmap>
   <input file>'"$GIF"'</input>
  </pixmap>
  <button has-focus="false" relief="2" tooltip-text="click to stop">
  </button>
 </vbox>
</window>'

gtkdialog -p gui -G  +${XDIMENSION}+${YDIMENSION} #${X}x${Y}
resizepng.gz
Description 
gz

 Download 
Filename  resizepng.gz 
Filesize  2 KB 
Downloaded  603 Time(s) 

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Fri 23 Dec 2011, 15:02    Post subject:
Subject description: Upgraded to version 1.0
 

Sorry for responding late.

Upgraded to version 1.0
Changelog:

  • Now using gdk-pixbuf library instead of pnmcut, transparency is now displayed much faster.
  • Now using JPEG format instead of PNG, much faster.
  • Several compatibility issues fixed.
  • Help and examples added at /usr/share/doc/gtkdialog-desklet
  • Response to wallpaper change has been improved significantly.

_________________________________________________________

zigbert wrote:

Thanks a lot.
Would you become upset if I used this in Pwidgets ?

Not at all Exclamation
You may use it the way you want.
________________________________________________________

seaside wrote:

Nice program. In testing I got this result.
Code:

# gtkdialog-desklet --help
mktemp: invalid option -- -
Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]



I observed this issue in Puppy 430. This issue has been fixed in version 1.0 .
In addition, I observe another issue.
type-hint="7" tag isn't working in 430.
Seems to be a problem in GTK.
desklet_malfunction.jpg
 Description   WM is treating gtkdialog-desklet as a normal window.
 Filesize   67.48 KB
 Viewed   2441 Time(s)

desklet_malfunction.jpg

Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7840
Location: qld

PostPosted: Fri 23 Dec 2011, 22:13    Post subject:  

akash_rawal

Nice!

I made a useful widget... I have more too, will post later when I fine tune them.
Code:
#!/bin/sh
#named "ramGTK"
WIDGETNAME=`basename $0`

export TOTRAM=`free -m|grep ^Mem|awk '{print $2}'`
freeramfunc(){
while [ 1 ]; do
USEDRAM=`free -m|grep ^Mem|awk '{print $3}'`
FREERAM=`free -m|grep ^Mem|awk '{print $4}'`
echo $(($USEDRAM * 100 / $TOTRAM))
echo "RAM $FREERAM MB"
sleep 1
continue
done
}

export -f freeramfunc

export ramwidget="<hbox>
  <progressbar width-request=\"140\" height-request=\"14\" tooltip-text=\"showing free RAM of total $TOTRAM\">
   <input>freeramfunc</input>
  </progressbar>
 </hbox>"
gtkdialog-desklet -p ramwidget -c


ramwidget.png
 Description   
 Filesize   19.64 KB
 Viewed   2411 Time(s)

ramwidget.png


_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11125
Location: Arizona USA

PostPosted: Fri 23 Dec 2011, 23:51    Post subject:  

Doesn't this belong in the Desktop section of Additional Software? Confused
Back to top
View user's profile Send private message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 24 Dec 2011, 00:56    Post subject:  

01micko wrote:

I made a useful widget...

Great widget, but I had to make some modifications to make it work on lucid puppy 511.

Portability issues are always a headache. If only there was a thread dealing with writing portable shell scripts.

Code:

#!/bin/sh
#named "ramGTK"
WIDGETNAME=`basename $0`

export TOTRAM=`free|grep Mem|awk '{print $2}'` #Removed '-m' option
freeramfunc(){
while [ 1 ]; do
USEDRAM=`free|grep Mem|awk '{print $3}'` #Removed '-m' option
FREERAM=`free|grep Mem|awk '{print $4}'`#Removed '-m' option
echo $(($USEDRAM * 100 / $TOTRAM))
echo "RAM $FREERAM MB"
sleep 1
continue
done
}

export -f freeramfunc

export ramwidget="<hbox>
  <progressbar width-request=\"140\" height-request=\"14\" tooltip-text=\"showing free RAM of total $TOTRAM\">
   <input>freeramfunc</input>
  </progressbar>
 </hbox>"
gtkdialog-desklet -p ramwidget -c


________________________________________________

Flash wrote:

Doesn't this belong in the Desktop section of Additional Software?

It may, but this is not a full widget platform. It's a way to write programs, just like gtkdialog.
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Sat 24 Dec 2011, 04:36    Post subject:  

Quote:
Thanks to akash_rawal's work for the inspiration


It's like Christmas . . . wait a minute it is Christmas . . .

Thanks guys - Mick I had to move resizepng to the bin directory (remembering to right click on it and change permissions to make runnable)

What fun. Will we be seeing its use in Slacko 5.3.2, or in Saluki 004 I wonder . . .

Smile

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 5 [71 Posts]   Goto page: 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
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.1228s ][ Queries: 13 (0.0054s) ][ GZIP on ]