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 Fri 19 Dec 2014, 17:08
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Browsers and Internet
Psearch - Puppy web search utility
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [27 Posts]   Goto page: Previous 1, 2
Author Message
seaside

Joined: 11 Apr 2007
Posts: 888

PostPosted: Tue 26 Mar 2013, 18:25    Post subject:  

PaulR wrote:
Thanks for that seaside - what if you run the executable in my last post without recompiling?

Paul


Paul,

That is a pic of your last posted executable Smile
It was run on precise 5.4.3 at Xft.dpi: 96.

Cheers,
s
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Wed 27 Mar 2013, 17:05    Post subject:  

Sorry seaside I misunderstood.

I tried setting my dpi to 96 in xwindows and recompiling with this value in the code
- I ended up with similar overlapping fonts!

Anyway, here's version 1.1 which includes the option for users to define the two sites used in the site-specific search - just edit psearch.sites and change the two lines in the format:

site name,site search url
site name,site search url

As it stands the program has a fallback if this config file doesn't exist, if less than two lines are present, or if there are spurious characters either side of the separator ','.

The archive includes source, *.pot, upx'ed executable and the little config file.

(Compiled at 78 dpi again Smile )

Paul
psearch1-1.png
 Description   
 Filesize   12.88 KB
 Viewed   405 Time(s)

psearch1-1.png

psearch1-1.tar.gz
Description 
gz

 Download 
Filename  psearch1-1.tar.gz 
Filesize  83.71 KB 
Downloaded  166 Time(s) 
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 888

PostPosted: Wed 27 Mar 2013, 18:46    Post subject:  

PaulR.

I just downloaded the new version and ran the executable at 96 and at 78 on Precise 5.4.3 resulting in skewed fonts on both.

I think this might be a Gtk version level issue Idea

Cheers,
s
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Wed 27 Mar 2013, 18:50    Post subject:  

Dear PaulR,

Scaling can be a real PITA in HUG, as you, Barry and others have observed. Recently, I solved the problem of calculating required pixels for width and height using libpango: http://basic-converter.proboards.com/index.cgi?board=doc&action=display&thread=314&page=3. It is towards the bottom of the page. You would have to get the user's current DPI settings (there are routines somewhere), set those in a HUGOPTION and then dynamically set your other w and h dimensions using the results of my function. I have a demo there on the BaCon site. It can be surely done, but it ain't that easy and transparent.

And you can use the following code snippet to get some info about the user's settings:

Code:
REM try to set font size to fit window... ex: xdpy=107 xftdpi=78
xdpi=VAL(EXEC$("xdpyinfo | grep -o 'resolution: .*' | tr -s ' ' | cut -f 2 -d ' ' | cut -f 1 -d 'x'"))
xftdpi=VAL(EXEC$("grep '^Xft.dpi:.*' /root/.Xresources | tr -s ' ' | cut -f 2 -d ' '"))
REM my weird formula...
fontsize=INT(12.0*(78.0/xftdpi)*(107.0/xdpi))
fontsize_mono=fontsize
fontsize$=STR$(fontsize)
fontsize_mono$=STR$(fontsize_mono)
font_sans$=CONCAT$("DejaVu Sans ",fontsize$)
font_mono$=CONCAT$("Monospace ",fontsize_mono$)

PRINT xdpi
PRINT xftdpi
PRINT fontsize
PRINT font_mono$
PRINT font_sans$


I also did a kind of brute force method here:


Code:
' *****************
' DECLARATIONS
' *****************

GLOBAL hres, vres, dsize, dpi, mydpi TYPE FLOATING
GLOBAL version$ TYPE STRING

' *****************
' END DECLARATIONS
' *****************

' *****************
' INIT VARS
' *****************

version$ = "v. 0.1"

' *****************
' END INIT VARS
' *****************


' *****************
' FUNCTIONs
' *****************

FUNCTION CALCDPI(FLOATING hres, FLOATING vres, FLOATING dsize)
        dpi = hres/(hres / SQR(POW(hres,2) + POW(vres,2)) * dsize)
        RETURN dpi
END FUNCTION

FUNCTION USAGE()
        PRINT NL$,"BaCon DPI Calculator - ", version$,NL$
        PRINT "Usage: dpicalc hres vres size", NL$
        PRINT "Where:"
        PRINT "  hres = horizontal resolution in pixels"
        PRINT "  vres = vertical resolution in pixels"
        PRINT "  size = diag. size of screen in inches",NL$
        PRINT "Example: dpicalc 1280 1024 19", NL$
        END
        RETURN TRUE
END FUNCTION

FUNCTION GETARGS()
        SPLIT ARGUMENT$ BY " " TO array$ SIZE dimension
        IF dimension < 4 THEN
                USAGE
        ELSE
                IF VAL(array$[1]) > 0 AND VAL(array$[2]) > 0 AND VAL(array$[3]) > 0 THEN
                        hres   = VAL(array$[1])
                        vres   = VAL(array$[2])
                        dsize  = VAL(array$[3])
                ELSE
                        PRINT NL$, "DPI Calculator: Input arguments contain bad values."
                        USAGE
                END IF
        END IF
        RETURN TRUE
END FUNCTION

FUNCTION SHOWRESULTS()
        STR1$ = "Calculated DPI for screen resolution of "
        PRINT NL$, STR1$, hres,"x",vres,"pixels and ",dsize, " in."," diagonal = ", mydpi, NL$
        RETURN TRUE
END FUNCTION

' *****************
' END FUNCTIONS
' *****************


' *****************
' MAIN
' *****************

GETARGS
mydpi = CALCDPI(hres, vres, dsize)
SHOWRESULTS
END

' *****************
' END MAIN
' *****************


Lastly, you can use some combination of gdk and pango calls, which I have in the past, but can't right now find to give you an example. Sad

With kind regards,
vovchik
Back to top
View user's profile Send private message 
linuxcbon

Joined: 09 Aug 2007
Posts: 797

PostPosted: Thu 28 Mar 2013, 16:05    Post subject:
Subject description: font
 

L18L wrote:
I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled. See the result, your original and mine Rolling Eyes

Why 66 ?
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Thu 28 Mar 2013, 16:54    Post subject:  

Thanks vovchik, it seems hideously complicated to do this accurately (I've just read a four page post here http://basic-converter.proboards.com/index.cgi?board=doc&action=display&thread=314&page=2 that several PL forum members have posted in).

In a language that offered a simple getpixel() function (or the address of the window's buffer!) I'd take the ultra-crude/pragmatic route and blit a white 'W' or 'M' on a black background, get the white pixel with the maximum x value and use that as the character width. Unfortunately that's not an appropriate technique in this case. It might be better to build a few different versions of the program for use on systems with differing dpi settings instead! Laughing

Paul
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2612
Location: www.eussenheim.de/

PostPosted: Fri 29 Mar 2013, 09:36    Post subject: HUG
Subject description: font
 

linuxcbon wrote:
L18L wrote:
I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled. See the result, your original and mine Rolling Eyes

Why 66 ?

Do not know why. I only know that it has given the good result.

Posted on 29 Mar 2013, 8:06 by BarryK wrote:

re hug dpi
L18L,
I don't see any problem.
I solved that problem a long time ago:

http://bkhome.org/bacon/hug/layout.htm

Both /usr/share/doc/welcome1stboot.bac and /usr/local/simple_network_setup/proxy-setup.bac in Woof use that method.

So did I by using 66.
And don't know why because PaulR has used 78.
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 888

PostPosted: Fri 29 Mar 2013, 16:05    Post subject:  

L18L,

Quote:
I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled.....


Quite a puzzle.....
I used your solution and find it works for all my dpi settings from 58 through 108 using the following:

1366x768
precise 5.4.3
bacon and hug build 29

Regards,
s
psearch1-1.tar
Description  Binary compile at 66dpi
(Not a tar file - remove .tar)
tar

 Download 
Filename  psearch1-1.tar 
Filesize  201.42 KB 
Downloaded  166 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2612
Location: www.eussenheim.de/

PostPosted: Sun 31 Mar 2013, 06:18    Post subject: Re: HUG
Subject description: [solved]
 

seaside
thanks for your assistance Smile

The problem
why 66 if PaulR has 78
solved
L18L wrote:
linuxcbon wrote:
L18L wrote:
I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled. See the result, your original and mine Rolling Eyes

Why 66 ?

Do not know why. I only know that it has given the good result.

Posted on 29 Mar 2013, 8:06 by BarryK wrote:

re hug dpi
L18L,
I don't see any problem.
I solved that problem a long time ago:

http://bkhome.org/bacon/hug/layout.htm

Both /usr/share/doc/welcome1stboot.bac and /usr/local/simple_network_setup/proxy-setup.bac in Woof use that method.

So did I by using 66.
And don't know why because PaulR has used 78.


Shame on all of us Embarassed except BarryK Cool
who wrote:
The same thing as shown above could also happen if a different GTK theme with larger font is chosen (see menu Desktop -> GTK theme chooser). Different users are going to have their own theme preference, but it isn't so good if a theme has bigger font sizes which cause our example window to be messed up.

There is also a simple solution to this. Peter introduced a feature that allows a font to be specified in the program, that overrides the GTK default. This will apply to all widgets. Put this near the beginning of the program:

HUGOPTIONS("FONT DejaVu Sans 12")

...with whatever font you want. DejaVu Sans is available in all puppies.
quoted from
http://bkhome.org/bacon/hug/layout.htm

Applying that hint:
Code:
HUGOPTIONS("BASEXFTDPI 78")
'set font size so
'windows/fonts will scale properly on other systems
HUGOPTIONS("FONT DejaVu Sans 9")


Everything is fine now.
Our thanks go to ...
PuppyMaster BarryK Exclamation
psearch_solved.png
 Description   
 Filesize   15.96 KB
 Viewed   657 Time(s)

psearch_solved.png

Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Sun 31 Mar 2013, 12:37    Post subject:  

Thank you L18L, I haven't had much chance to think about this over the last few days as I've been working on some other projects. I missed that on Barry's page too - doh!

I've recompiled and attached the program, source and pot file.

Cheers

Paul
psearch1-1.tar.gz
Description 
gz

 Download 
Filename  psearch1-1.tar.gz 
Filesize  114.17 KB 
Downloaded  172 Time(s) 
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Sun 31 Mar 2013, 12:45    Post subject:  

ooops forgot to include the .sites file Embarassed
psearch.tar.gz
Description 
gz

 Download 
Filename  psearch.tar.gz 
Filesize  58.47 KB 
Downloaded  190 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2612
Location: www.eussenheim.de/

PostPosted: Sun 31 Mar 2013, 14:57    Post subject: Psearch - Puppy web search utility
Subject description: packaging
 

PaulR
packaged just to help you on the Puppy way:

for next version (how I would do it):
cp .pet to .tgz
expand .tgz to /mnt/home/bacon
copy xxx-1.2 xxx-1.3

cd xxx-1.3
edit version, ...
maybe: define location of file psearch.sites? -> $HOME

compile .......

dir2pet xxx-1.3

Who needs which package?
dev: psearch_DEV
english user: psearch
other user: psearch and psearch_NLS
translator: psearch and psearch_DEV

please move the 3 packages to 1st post of this thread
where everybody will expect them to be.

Have fun.

-------
edited later
I have copied only your file to version 1.2
but did not change version number in the source. Crying or Very sad
psearch-1.2.pet
Description 
pet

 Download 
Filename  psearch-1.2.pet 
Filesize  40.47 KB 
Downloaded  187 Time(s) 
psearch-1.2_NLS.pet
Description  for non-english users
at the moment german only
pet

 Download 
Filename  psearch-1.2_NLS.pet 
Filesize  1.02 KB 
Downloaded  169 Time(s) 
psearch-1.2_DEV.pet
Description  for toranslators
pet

 Download 
Filename  psearch-1.2_DEV.pet 
Filesize  4.03 KB 
Downloaded  156 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [27 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Browsers and Internet
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.1018s ][ Queries: 13 (0.0091s) ][ GZIP on ]