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 Sat 25 Oct 2014, 05:44
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 33 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 31, 32, 33, 34, 35, ..., 62, 63, 64 Next
Author Message
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Thu 09 Jun 2011, 19:06    Post_subject:  

8-bit wrote:
I could not get the checkmark png images for yes and no found and as a result, the one example does not work for me.

I've attached them to my post on the previous page Smile

They are from the Elementary icon set.
Back to top
View user's profile Send_private_message Visit_website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 10 Jun 2011, 12:04    Post_subject:  

thunor wrote:
8-bit wrote:
I could not get the checkmark png images for yes and no found and as a result, the one example does not work for me.

I've attached them to my post on the previous page Smile

They are from the Elementary icon set.


I had used some other png files to get it to work, but I downloaded the ones from your post and they work too.
I do have another question though.
I am running Lupu 520 and in doing a search for "yes", I came up empty handed.
So I assume those png files are not part of a standard puppy.
I had initially used ones from /usr/local/lib/X11/pixmaps.
I picked some that were close, copied them to the directory containing the toggle script, and renamed them to correspond with the names in the script.
One thing I did notice is that a toggle configuration file is written when toggle is run. But even if I have the no.png images displayed when I stop the script, they are not retained for the next time toggle is run.
It always starts with the yes.png images.
So what is that configuration file for?
Back to top
View user's profile Send_private_message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Fri 10 Jun 2011, 17:06    Post_subject:  

8-bit wrote:
One thing I did notice is that a toggle configuration file is written when toggle is run. But even if I have the no.png images displayed when I stop the script, they are not retained for the next time toggle is run.
It always starts with the yes.png images.
So what is that configuration file for?

It's just an example for illustrative purposes which happens to default to yes.

The "configuration" file TOGGLE is necessary because if an exported shell variable were used instead, funcImageToggle would be able to change the exported variable but not the original variable resulting in the image not toggling. That's what you meant right? If so see this.

Replace
Code:
echo 0 > TOGGLE; funcImageToggle

with
Code:
if [ ! -f TOGGLE ]; then echo 0 > TOGGLE; funcImageToggle; fi

and you'll get the functionality you're expecting Smile

Regards,
Thunor
Back to top
View user's profile Send_private_message Visit_website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 10 Jun 2011, 19:29    Post_subject:  

Thank you for making things clear.
I already knew of how to get the script to use the configuration file on startup.
But while I am here, I will ask that the modded gtkdialog file I uploaded be checked out to see if everything works as expected.
I still have the modified source code files, I used gtkdilaog3-0.7.20-pe-1 for my source and added the patches I found in this thread.

So if I missed something or you would like me to upload the modified source in a tar.gz file yell.
Back to top
View user's profile Send_private_message 
01micko


Joined: 11 Oct 2008
Posts: 7836
Location: qld

PostPosted: Fri 10 Jun 2011, 21:23    Post_subject:  

Ah thunor.. this is fun! I will write a revision of the clunky wallpaper setter soon.

8-bit.. your binary works just fine Smile , I notice it's not stripped though, you can get it alot smaller with "strip --strip-unneeded"

Here is a spin on thunor's code that demos the pixmap refreshing capability: (notice how only one of the buttons refreshes the pixmap Wink)
Code:
#!/bin/bash

function funcImageToggle() {
   if [ $(< TOGGLE) = 1 ]; then
      ln -sf no.png toggle.png
      echo 0 > TOGGLE
   else
      ln -sf yes.png toggle.png
      echo 1 > TOGGLE
   fi
}
export -f funcImageToggle

echo 0 > TOGGLE; funcImageToggle

export MAIN_DIALOG='
<window title="btnImageToggle" resizable="false" width-request="300" height-request="100">
   <vbox homogeneous="true">
      <hbox homogeneous="true">
         <pixmap>
         <variable>TOGGLEPIX</variable>
            <input file>toggle.png</input>
         </pixmap>
         <button>
            <variable>TOGGLEME</variable>
            <input file>toggle.png</input>
            <label>"Toggle Me!"</label>
            <action>funcImageToggle</action>
            <action type="refresh">TOGGLEME</action>
            <action type="refresh">TOGGLEMETOO</action>
            <action type="refresh">TOGGLEPIX</action>
         </button>
         <button tooltip-text="Toggle me too!">
            <variable>TOGGLEMETOO</variable>
            <input file>toggle.png</input>
            <action>funcImageToggle</action>
            <action type="refresh">TOGGLEMETOO</action>
            <action type="refresh">TOGGLEME</action>
         </button>
      </hbox>
   </vbox>
   <action signal="hide">exit:Exit</action>
</window>
'

gtkdialog4 --center --program=MAIN_DIALOG


I took the liberty to make a combined patch of moose's and thunor's patches, (see attached), gunzip it and place it in the dir with the source dir and (patriot's source) and run:
Code:
patch -p0 <  gtkdialog_moose_thunor_pixmap.patch


Have fun!
gtkdialog_moose_thunor_pixmap.patch.gz
Description 
gz

 Download 
Filename  gtkdialog_moose_thunor_pixmap.patch.gz 
Filesize  1.19 KB 
Downloaded  175 Time(s) 

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
01micko


Joined: 11 Oct 2008
Posts: 7836
Location: qld

PostPosted: Fri 10 Jun 2011, 21:59    Post_subject:  

Ok, this is the not so clunky SWS (simple-wallpaper-setter) Very Happy

Thanks to thunor's patches to gtkdialog.

note, this depends on the gtkdialog4 executable posted by 8-bit, or roll your own with the patch above, name it "gtkdialog4" and pop it in /usr/sbin or /usr/bin
sws-exp.jpg
 Description   
 Filesize   37.27 KB
 Viewed   953 Time(s)

sws-exp.jpg

sws-0.3exp.pet
Description 
pet

 Download 
Filename  sws-0.3exp.pet 
Filesize  4.14 KB 
Downloaded  190 Time(s) 

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Fri 10 Jun 2011, 23:28    Post_subject:  

As long as it doesn't _remove_ or change existing functionality when compared to gtkdialog3, there is no need to bump the version number. ... perhaps a symlink or version file etc... (btw there is an operational difference between 2 & 3 that required a version bump)
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 10 Jun 2011, 23:42    Post_subject:  

For all concerned about my calling the patched gtkdialog 4, I was not actually bumping the version number.
Or at least I did not mean to.
It was a case of calling it what I did for testing purposes so as not to interfere with the gtkdialog3 file that was already on my PC.
As a matter of fact, I compiled it as gtkdialog3 and just renamed the executable for co-existence while testing it.
If you do not like it being called gtkdialog4, just rename it to gtkdialog3.

I hope I made myself clear as mud on that.

Also, since I have never used the strip option in compiling, and have no idea where or how to implement it, my compile was not stripped.
Back to top
View user's profile Send_private_message 
01micko


Joined: 11 Oct 2008
Posts: 7836
Location: qld

PostPosted: Fri 10 Jun 2011, 23:57    Post_subject:  

Understood 8-bit and I was thinking along those lines too.

I'm going to put the exec in the next spup (as gtkdialog3) just to see if anything breaks, I don't think it will but you never know.

As a note, my patch does not include this from thunor (return ""; [in src/stringman.c]) .. as I understood his edit on the previous page took care of that. Please correct me if I'm wrong and I'll do another patch. Gtkdialog is not segfaulting for me if it doesn't find the image without that line.

BTW strip --strip-unneeded <name-of-exec> is all that's needed to strip in most cases. (learnt that from disciple a few years ago now Smile )

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sat 11 Jun 2011, 00:33    Post_subject:  

01micko,
Thank you for the strip command usage.
I tried it and it brought the gtkdialog4 executable from 371K to 123K.

And also, I did modify the source for the "return;" in my compile.

Also, nice work on the Simple Wallpaper Switcher!

And lastly, I lied! The name originally compiled to was just "gtkdialog".
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Sat 11 Jun 2011, 01:31    Post_subject:  

Note that .so and .a files would normally be stripped before packaging too. If you strip these without the --strip-unneeded flag then it breaks them, but you can strip executables without --strip-unneeded... and they might even end up smaller.
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send_private_message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sat 11 Jun 2011, 11:13    Post_subject:  

thunor opens the door!

With the changes made to gtkdialog3, and after seeing 01micko's Simple Wallpaper Switcher, one could design a package/application and call it something like "Picture This".
Feed it the name of a picture directory and display each picture in that directory.
For trying to find a specific picture that had some name given by a camera
it would come in handy.
Back to top
View user's profile Send_private_message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sun 12 Jun 2011, 17:49    Post_subject:  

Here's some code to enable <pixmap> to be scaled (no need to use external command-line scalers anymore):

[EDIT] 20110618-22:01 Gtkdialog is now in a repository (see this post).

This is how it works:

By default the image will be loaded without constraint as per the norm (width will default to -1 and height -1).
If either <width> or <height> (or both) is set then "the image will be scaled to fit in the requested size, preserving the image's aspect ratio."

e.g.
<width>100</width><height>100</height>
<width>100</width> (equivalent to <width>100</width><height>-1</height>)
<height>100</height> (equivalent to <width>-1</width><height>100</height>)

I achieved this by replacing gtk_image_new/set_from_file() with gdk_pixbuf_new_from_file_at_size() and I recommend reading the link.

Edited_times_total
Back to top
View user's profile Send_private_message Visit_website 
01micko


Joined: 11 Oct 2008
Posts: 7836
Location: qld

PostPosted: Sun 12 Jun 2011, 18:28    Post_subject:  

thunor,

re my earlier post..

is the return ""; still needed in stringman.c?

TIA

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sun 12 Jun 2011, 19:09    Post_subject:  

01micko wrote:
thunor,

re my earlier post..

is the return ""; still needed in stringman.c?

TIA

Yes. It is missing and a bug.
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 33 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 31, 32, 33, 34, 35, ..., 62, 63, 64 Next
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.1091s ][ Queries: 13 (0.0162s) ][ GZIP on ]