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 Sun 21 Dec 2014, 10:27
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 57 of 65 Posts_count   Goto page: Previous 1, 2, 3, ..., 55, 56, 57, 58, 59, ..., 63, 64, 65 Next
Author Message
sunburnt


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

PostPosted: Fri 04 Oct 2013, 04:31    Post_subject:  

Another Q guys...

Has GtkDialog been patched so it`s easy to use: /path/icon in place of GTK`s "stock" gtk-ok ?
I know thunor has done work on GtkDialog, I don`t know if it`s still on-going though.

I know you can set a new path for this, but it`s obvious that this should be extremely simple.

Maybe Puppy should default to /usr/share/pixmaps as an alternate GTK icon path.?
.
Back to top
View user's profile Send_private_message 
Geoffrey


Joined: 30 May 2010
Posts: 1513
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sat 05 Oct 2013, 03:50    Post_subject:  

sunburnt wrote:
Another Q guys...

Has GtkDialog been patched so it`s easy to use: /path/icon in place of GTK`s "stock" gtk-ok ?
I know thunor has done work on GtkDialog, I don`t know if it`s still on-going though.

I know you can set a new path for this, but it`s obvious that this should be extremely simple.

Maybe Puppy should default to /usr/share/pixmaps as an alternate GTK icon path.?
.


This works for me.

Code:
<window image-name="/path/to/any/icon">

_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Sat 05 Oct 2013, 14:21    Post_subject:  

Thanks Geoffrey; It looks like the line sets the GTK window`s icon, am I correct.?

I was wanting to substitute user icons for GTK button icons mainly.


Someone gave me a GTK environment command that set a new path for this ( can`t remember it...).
Then you would substitute a user icon for a stock button icon ( gtk-ok ).

Puppy should have this GTK env. command in it`s boot code to set: /usr/share/pixmaps
Then all those icons would be usable substitutes for the GTK stock buttons.
Back to top
View user's profile Send_private_message 
Geoffrey


Joined: 30 May 2010
Posts: 1513
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sat 05 Oct 2013, 17:52    Post_subject:  

sunburnt,

This works for button icons which the size can be varied also

Code:
<button>
<label>"any icon"</label>
<input file>"/path/to/any/icon"</input>
<height>16</height>
</button>


Image positioning works too.

Code:
<button image-position="2">
<label>"any icon"</label>
<input file>"/path/to/any/icon"</input>
<height>48</height>
</button>
Screenshot-2.png
 Description   
 Filesize   6.93 KB
 Viewed   499 Time(s)

Screenshot-2.png

Screenshot-1.png
 Description   
 Filesize   3.56 KB
 Viewed   519 Time(s)

Screenshot-1.png


_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Sun 06 Oct 2013, 14:46    Post_subject:  

Thanks again Geoffrey; It looks like Thunor has indeed fixed much of GtkDialog.

# Are there up-to-date docs. somewhere to download?
Back to top
View user's profile Send_private_message 
Geoffrey


Joined: 30 May 2010
Posts: 1513
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sun 06 Oct 2013, 17:00    Post_subject:  

sunburnt wrote:
Thanks again Geoffrey; It looks like Thunor has indeed fixed much of GtkDialog.

# Are there up-to-date docs. somewhere to download?


I just had a look at don570's Gtkdialog Tutorial Manual, that pretty much has everything covered, http://murga-linux.com/puppy/viewtopic.php?t=89045
Quote:
Button Widget
The general button widget definition

<button yes no ok cancel help tag_attr="value"...>
<label>text</label>
<variable>varname</variable>
<height>value</height>
<width>value</width>
<input file>filename</input>
<input file icon="image"></input>
<input file stock="gtk-image"></input>
<sensitive>state</sensitive>
<action>activity</action>...
<action signal="type">activity</action>...
<action function="type">parameter</action>...
</button>



I've tried a few other icons and found that
Code:
<input file icon="image"></input>

works with icons located in /usr/share/icons, /usr/share/pixmaps and /usr/share/icons/hicolor, or whatever cached icon theme theme is active, you only need to state the icon name no extension.
Code:
<input file icon="pet48x"></input>
Screenshot-3.png
 Description   
 Filesize   4.08 KB
 Viewed   431 Time(s)

Screenshot-3.png


_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Sun 06 Oct 2013, 19:07    Post_subject:  

No extension is very useful, as that`s how icons are listed in the desktop files.
And not having to specify the path is always nice too.

### Damn good programming Thunor !!! Cool

GtkDialog is very much like I always wanted it to be many many years ago.

And I was finally able to download the docs. I tried before but the site was crabby.

Again... Many thanks Geoffrey. Terry B.
.
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Mon 07 Oct 2013, 02:36    Post_subject:  

I made this GtkDialog menu that pads the button text in the middle to the widest line.

It can use icon buttons, and can set the window title.
The window title and icon path are set in the menu file.

It maybe needs an option to use hicolor icons, at present it uses a set path.

Font doesn`t work yet...

# I don`t know how to set the font for GtkDialog. Any suggestions?

# Also GtkDialog buttons don`t allow spaces on the left of text to pad from the icon.
.
gtkdialog.menu.zip
Description  UnZip anywhere, has all files needed.
zip

 Download 
Filename  gtkdialog.menu.zip 
Filesize  36.71 KB 
Downloaded  136 Time(s) 
000_GtkDialog-Menu.png
 Description   
 Filesize   7.88 KB
 Viewed   392 Time(s)

000_GtkDialog-Menu.png

Back to top
View user's profile Send_private_message 
SFR


Joined: 26 Oct 2011
Posts: 1117

PostPosted: Mon 07 Oct 2013, 05:16    Post_subject:  

sunburnt wrote:
# I don`t know how to set the font for GtkDialog. Any suggestions?

Hey Terry

AFAIK it's necessary to use custom gtkrc, here's an example:
Code:
#!/bin/bash

FONT_NAME="Astloch"
FONT_SIZE="25"
FONT_STYLE="bold"
 
echo 'style "custom"
{
font_name="'$FONT_NAME' '$FONT_STYLE' '$FONT_SIZE'"
fg[NORMAL]="blue"
fg[PRELIGHT]="red"
}
widget "*GtkButton*" style "custom" ' > /tmp/gtkrc_custom
# widget "*" <- global

export GTK2_RC_FILES="${HOME}/.gtkrc-2.0:/tmp/gtkrc_custom"


export MAIN='
<window>
  <vbox>
    <edit></edit>
    <button><label>Custom font</label></button>
  </vbox>
</window>'

gtkdialog -p MAIN

Anyway, I used this method only once or twice, so I'm not an expert if it comes for details...

Greetings!
Screenshot.png
 Description   
 Filesize   14.35 KB
 Viewed   376 Time(s)

Screenshot.png


_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send_private_message 
Geoffrey


Joined: 30 May 2010
Posts: 1513
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Mon 07 Oct 2013, 07:33    Post_subject:  

sunburnt wrote:

# Also GtkDialog buttons don`t allow spaces on the left of text to pad from the icon.
.


Code:
<label>"          10 spaces"</label>


Spaces works for me.
Screenshot-4.png
 Description   
 Filesize   5.25 KB
 Viewed   385 Time(s)

Screenshot-4.png


_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send_private_message 
01micko


Joined: 11 Oct 2008
Posts: 7841
Location: qld

PostPosted: Mon 07 Oct 2013, 08:09    Post_subject:  

SFR wrote:
AFAIK it's necessary to use custom gtkrc


or (depends partly on what you want to do)

Code:
#!/bin/sh

export gui='<window title="fonts">
  <vbox>
    <text use-markup="true">
      <label>"<span color='"'red'"' font-family='"'mono'"' weight='"'bold'"' size='"'x-large'"'><big>What Great Text ! </big></span>"
      </label>
    </text>
    <hbox>
      <button ok></button>
      <button cancel></button>
    </hbox>
  </vbox>
</window>'
gtkdialog -p gui


http://www.murga-linux.com/puppy/viewtopic.php?t=40418

Wink
Quote:

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


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

PostPosted: Mon 07 Oct 2013, 12:28    Post_subject:  

Hi again SFR; I want the font to be easily changeable, like the icons.
So I don`t know if the config. file is best for this, it may change everything else too.

Hey Geoffrey; Duh.!!! I`m so damn slow some times... Thanks again.

01micko; As per my usual fits with GtkDialog and XML style code.
I can`t get the quoting correct. I`m building the button code in a loop.
I have best luck using variables in GtkDialog code if the whole thing is in "...".
Here`s a short version of the final code with only 1 button, all interior " are \".
# Does the use-markup work inside of the button tag?
OR, should it be: <button><text use-markup=\"true\"><label>\"<span ........
Both error.
Code:
export MENU_DLG="
<window title=\" $TITLE\">
 <vbox>

    <button use-markup=\"true\"><label>
      \"<span font-family=\"DejaVu Sans\">\"    Xfe            File Manager    \"</span>\"
      </label><input file>icon/xfe.xpm</input><height>20</height>
      <action>export=xfe_1.32.4-3_i386</action><action>/xfe &</action>
      <action>EXIT:exit</action></button>

 </vbox>
</window>"
gtkdialog --program=MENU_DLG

I can`t see why your code has '"'red'"', it makes no sense to me.
But mainly I need to use variables in place of all your literals.
Bash quoting ambiguities plus XML vagaries combined is insanity.!
Back to top
View user's profile Send_private_message 
SFR


Joined: 26 Oct 2011
Posts: 1117

PostPosted: Mon 07 Oct 2013, 14:41    Post_subject:  

Ahh, me too can't find a way to use markup within buttons' labels. Is it possible? I hope so...

Another way would be to use (dynamically generated) SVG images as button's body, instead of a plain text.
More info here: http://www.murga-linux.com/puppy/viewtopic.php?t=88715
___________

Speaking of which, yet another scroller to collection. Wink
Code:
#!/bin/bash

TEXT=" I hope that someone gets my Message in the button..."

# -----------------------------------------------------------------------------

TEMPDIR=/dev/shm/scrollbutton_${$}
mkdir -p $TEMPDIR
trap 'rm -rf $TEMPDIR' EXIT

export PIC=$TEMPDIR/pic.svg
export X_POS=$TEMPDIR/xpos
export TMPTEXT="$TEMPDIR/text"
export WIDTH=256
echo $WIDTH > $X_POS
echo -n "$TEXT" | sed -e 's~&~\&amp;~g' -e 's~<~\&lt;~g'  -e  's~>~\&gt;~g' > $TMPTEXT

# -----------------------------------------------------------------------------

scroll () {
X=$(<$X_POS)
TEXT=$(<$TMPTEXT)

echo '<svg width="'$WIDTH'" height="32">
<path id="note" transform="scale(0.6) translate('$((200+$X-$X/4))')" stroke="none" fill-rule="nonzero" fill="darkgreen" opacity="0.8" d="M 79 11 C 80 14 82 18 85 20 C 87 23 87 28 85 31 C 85 29 86 26 85 23 C 84 21 82 20 80 18 C 79 24 79 31 80 37 C 78 39 75 41 73 41 C 71 41 69 40 69 38 C 70 34 75 32 79 33 C 78 26 78 19 79 11 Z M 79 11 "/>
<use xlink:href="#note" transform="translate(75,4)" />
<use xlink:href="#note" transform="translate(150,-7)" />
<use xlink:href="#note" transform="translate(225,7)" />
<use xlink:href="#note" transform="translate(300,-2)" />
<text x="'$X'" y="22" xml:space="preserve" style="font-family:monospace;font-size:32px;" font-weight="bold" fill="#7B2EAD" opacity="0.8">'"$TEXT"'</text>
</svg>' > $PIC

X=$(($X-3))
[ $X -lt -$(( ${#TEXT}*20 )) ] && X=$WIDTH
echo $X > $X_POS
}
export -f scroll && scroll

# -----------------------------------------------------------------------------

export MAIN='
<window title="Scrollbutton" resizable="false">
  <vbox>
    <button>
      <variable>BUTTON</variable>
      <input file>'$PIC'</input>
    </button>
    <timer visible="false" milliseconds="true" interval="50">
      <action>scroll</action>
      <action>refresh:BUTTON</action>
    </timer>
  </vbox>
</window>'

[ `which gtkdialog4 2>/dev/null` ] && GTKDIALOG=gtkdialog4 || GTKDIALOG=gtkdialog
$GTKDIALOG -cp MAIN

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Tue 08 Oct 2013, 01:55    Post_subject:  

SFR; Very interesting and intricate. Lots of code I`ve never seen before.


# Doing mark-up is only a nicety.

# Mainly I would like: font, font-style, font-size, and font-color.

Even color isn`t that important, but it would be nice.
I think windows and widgets should be easily to tell from one another and color really helps.
All windows look almost exactly alike ( within a given theme ), and each widget type also.
.
Back to top
View user's profile Send_private_message 
01micko


Joined: 11 Oct 2008
Posts: 7841
Location: qld

PostPosted: Tue 08 Oct 2013, 19:01    Post_subject:  

just knocked up a very simple svg generator (I'm not all that knowledgeable in svg) but it does seem to work ok and can probably generate button text that you might want.

Just comment everything after the gtkdialog bit to keep the images (saved in /tmp)

Code:
#!/bin/sh

#params: $1 = font ; $2 = size ; $3 = string (use quotes) ; $4 (optional) = color (quoted hex or otherwise)

Y=$((${2}/2))
H=$((${Y}+${2}))
X1=$(echo "$3"|wc -c)
X2=$((${Y}/2))
W=$((${X1}*${X2}))
Z=$((${2}+4))
[ ! "$4" ] && C='#000000' || C=$4

echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect width='\"$W\"'
     height='\"$H\"'
     x="0"
     y="0"
     rx="3"
     ry="3"
     style="font-size:'$2';fill-opacity:'"0"';fill-rule:evenodd;stroke-width:3pt;"
     id="rect1" />
  <text
     x="0"
     y='\"$Z\"'
     style="font-size:'$2';font-weight:normal;fill:'$C';fill-opacity:0.75;stroke-width:3pt;font-family:'$1';"
     id="text1">
    <tspan
       id="tspan1">'"$3"'</tspan>
  </text>
</svg>' > /tmp/img${$}.svg
echo "img${$}.svg is in /tmp"

echo '<window title="test">
  <vbox>
    <button><input file>"'"/tmp/img${$}.svg"'"</input></button>
  </vbox>
</window>'|gtkdialog -s
rm /tmp/img${$}.svg


Whatever you name it, add .sh extension or else ROX thinks it's an svg image. this could probably be tweaked into something useful. (It's based on technosaurus' stuffs).

PS, no way I found to alter button text either with pango markup. There are ways in gtk programming but go way beyond the scope of gtkdialog.

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 57 of 65 Posts_count   Goto page: Previous 1, 2, 3, ..., 55, 56, 57, 58, 59, ..., 63, 64, 65 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.1323s ][ Queries: 12 (0.0230s) ][ GZIP on ]