BaCon - Bash-based Basic-to-C converter/compiler

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#141 Post by jpeps »

big_bass wrote:Hey vovchik

fast and small
what more can you want and
compiled it in bacon 8)


I can see many good apps to follow from you

thanks for posting the app and the source

Joe
Great example, although similar cli scaling can be done with about 3 lines using something like exactimage:

example: 'scale old.png new.png 16'

note: econvert also has --quality, which could be the fourth argument

Code: Select all

#!/bin/sh

OldSize=`edentify $1 | cut -d"x" -f1 | cut -d" " -f3`
size=`dc $3 $OldSize / p`  
econvert -i $1 --scale $size -o $2
Last edited by jpeps on Sun 21 Nov 2010, 23:14, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Thanks

#142 Post by vovchik »

Dear Joe,

Thanks. I am trying to understand gdk_pixbuf_composite, and once I do satisfactorily, I will change pikona to use only gtk/gdk calls. That means a binary of about 70k without any ImageMagick dependencies that will run on any standard Puppy. Of course, the various background, object and overlay files will still be needed, but the main bulk for the user is now IM and that will be gone. And the transformations will be faster, since they will be made in RAM. And input pics will be able to be in any of the formats that can be read by gtk_pixbuf. Have to get onto this....

With kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

image conversion

#143 Post by vovchik »

Dear jpeps,

No it can't do that in three lines, unless you install either IM (a good 6 MB binary with libs) or ExactImage (a good 3+ MB binary with libs). Of course econvert and IM's convert can do the job, but I think you may have missed my point above about ugly and huge dependencies. Puppy is supposed to be small and capable, and exploiting gdk_pixbuf (included in the GFK libs in every Puppy by default) is, I think, a good idea.

With kind regards,
vovchik

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#144 Post by big_bass »

I will change pikona to use only gtk/gdk calls. That means a binary of about 70k without any ImageMagick dependencies

there are a few small apps that do image resize

but there is a little history here that just took place over a long period of time
its hard to follow all the threads so here is a short recap

pikona a great icon making app (compiled in bacon)
uses image magic to do the resize

there is a great small cli c code app MU wrote and compiled

but for some reason the alpha channel had a small error
during the conversion with png that was fixed

then converted from c code to bacon basic
and expanded on adding the IMPORTS

a lot of work went to getting all that to work
so vovchik savor the moment friend

what I like about bacon the most is having
apps that work on all linux distros not
special apps that only work for one special version (like the gtkdialog3 if you plan to share work with the linux
community

Joe

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#145 Post by vovchik »

Dear Puppians,

I think I have finally understood gdk_pixbuf_composite. Here is a little demo (archive includes src, binary and images). Now I can change Pikona :)

With kind regards,
vovchik
Attachments
new_img.png
(28.91 KiB) Downloaded 1621 times
image2.png
(26.22 KiB) Downloaded 1634 times
image1.png
(18.48 KiB) Downloaded 1609 times
composite-test.tar.gz
(57.78 KiB) Downloaded 600 times

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#146 Post by PjotAwake »

Gents,

Updated the Source Code Editor a bit more.

Tabbing: done.
What do you think about a FIND/HIGHLIGHT option?
Done.

Furthermore did some preparations to integrate with the complete BaCon source. So I am working on it, also looking at contributions from 2lss and mechanic.

For now, code of version 1.4 is here. More to come...

Regards,
Peter

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#147 Post by vovchik »

Dear PjotAwake,

We are grateful to you for your brains, effort and conscientiousness. I think the IDE will be a VERY useful addition. If we have this, Doyle's glade2bac plus a few utilities that can scan BaCon code and find the (i) undefined function calls to external shared libs (that is, ultimately, compiler errors) and (ii) then do something like an nm -D on the probable libs to automatically produce the imports with proper type defs, life will be a breeze. In a way, one could, for instance, load the entire GTK/GDK stuff, then do a diff on the code to grab only those functions as IMPORTs that are really called, and produce the import list on the basis of matches. I am giving that some thought...

With thanks and kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

pnotify revisited

#148 Post by vovchik »

Dear puppians,

I revised my notification prog and have attached it here. I eliminated the global HUG dependencies, doing the IMPORTs by hand, and, in so doing, reduced the size of the binary by 50% - now 42k. It is similar to the gnome notify prog, but no icons yet and no command-line argument for duration of the popup, but with complete use of markup. Shall I do the icon and duration bits (we could make it into a 1:1 clone of notify, but without the gnome deps)? It's not a bad way of giving users information about an event that has transpired - i.e. successful inet connection or the completion of some long process such as indexing or backup. Please have a look. The archive contains the source, binary and a bash demo launcher (which shows how to do the markup).

With kind regards,
vovchik
Attachments
pnotify-0.1a.tar.gz
(18.19 KiB) Downloaded 603 times

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#149 Post by seaside »

vovchik,

Thanks for working on this.

I get this -

Code: Select all

./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
Could it be a bash 3 problem?

I also wondered if the BaCon larger font size rendering problem has seen any resolution.

Best Regards,
s

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#150 Post by vovchik »

Dear Seaside,

Yep, I spoke to Peter about this and our suspicion is that it is bash3 -related. Although Peter recommends bash4 for BaCon (for good reason), I have used GNU bash, version 3.2.48(1)-release (i686-pc-linux-gnu) successfully. Shall I post that binary here? I think Joe has posted a useful bash4 somewhere, and Barry has one posted too. The binary should work in any case -- I hope :)

With kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#151 Post by jpeps »

vovchik wrote:Dear Seaside,

Yep, I spoke to Peter about this and our suspicion is that it is bash3 -related. Although Peter recommends bash4 for BaCon (for good reason), I have used GNU bash, version 3.2.48(1)-release (i686-pc-linux-gnu) successfully. Shall I post that binary here? I think Joe has posted a useful bash4 somewhere, and Barry has one posted too. The binary should work in any case -- I hope :)

With kind regards,
vovchik
Here's one I compiled in Lucid

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

pnotify

#152 Post by seaside »

vovchik,

Thanks for your feedback - I did a temp install of bash 4 and got the same....

Code: Select all

 ./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
# bash -version
GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.

Am I the only one getting this error ....... :D :D

Best Regards,
s

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

Re: pnotify

#153 Post by jpeps »

seaside wrote:vovchik,

Thanks for your feedback - I did a temp install of bash 4 and got the same....

Code: Select all

 ./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
# bash -version
GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.

Am I the only one getting this error ....... :D :D

Best Regards,
s
Both the enclosed app and freshly compiled app work on this end.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#154 Post by seaside »

jpeps,

I just recompiled the pnotify.bac using bash 4 and it now works!!.

The pnotify exec included in Vovchik's package did not run in bash 3 or 4. That is still a bit of a puzzle??

Oh, well.... :D

Cheers,
s

EDIT: I reverted back to bash 3 and it runs there also
Last edited by seaside on Mon 29 Nov 2010, 23:54, edited 1 time in total.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#155 Post by BarryK »

seaside wrote:I also wondered if the BaCon larger font size rendering problem has seen any resolution.
In my Proxy Server Setup application now used in Woof, see /usr/local/simple_network_setup/proxy-setup.bac in recent Wary/Quirky/Luci builds, I attempted to adjust font size so that the text will always fit the window.

I have this at the beginning of my program (using HUG):

Code: Select all

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=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$)
Then in the program I use FONT function on all text, for example:

Code: Select all

ATTACH(mainwin, label_http, 10, 100)
FONT(label_http,font_sans$)
I can't guarantee the accuracy of my formula, but it seemed ok in limited testing.

I don't know if this idea of keeping the text always the same size regardless, would appeal to everybody.
[url]https://bkhome.org/news/[/url]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#156 Post by seaside »

BarryK wrote:
seaside wrote:I also wondered if the BaCon larger font size rendering problem has seen any resolution.
I have this at the beginning of my program (using HUG):
.......
Wow! I have no idea how this works and it astounds me how you can come up with these ideas. Bravo.

Thanks,
s

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#157 Post by jpeps »

seaside wrote:
EDIT: I reverted back to bash 3 and it runs there also
...think you only need 4 to compile.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#158 Post by seaside »

FOUND the problem.

There is something needed from the pup431 devx files!!!

When I ran the working execs without the devx files, I got the same segmentation error.


Cheers,
s
(Not sure what file (files) might be missing)

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#159 Post by BarryK »

I have created a PET of the latest beta BaCon, with instructions to those who build puppies using Woof how to incorporate it into the devx:

http://bkhome.org/blog/?viewDetailed=02007

It would be good for consistency if all puppies have it in their devx.

For anyone running a Puppy, any Puppy, you can download the PET and use it. You do of course need the devx loaded for C compiling.

The PET has all the .bac include files plus docs in /usr/share/BaCon.
[url]https://bkhome.org/news/[/url]

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#160 Post by 2lss »

PjotAwake wrote:Gents,
Updated the Source Code Editor a bit more.
Wow, this thing is slowly becoming my favorite text editor! I am very curious to see how you will implement the bacon source. Should be interesting. :D

Although I am running in to one problem.

The editor works fine using ubuntu however, using puppy, it fails to find the gtksourceview libs even though they exist.

Code: Select all

GtkSourceView library not found!

Code: Select all

# pkg-config --variable=prefix gtksourceview-2.0
/usr
Can anyone else reproduce this? I'm using 4.3 so maybe its outdated. I also had problems with Nicoedit (the newest version), so maybe the gtksourceview file is just borked.

Post Reply