Page 11 of 42

Posted: Sun 21 Aug 2011, 10:53
by 01micko
Hi all,

There is a backward compat issue that has surfaced.

This syntax:

Code: Select all

export DLG="<window>
	<vbox>
	 <hbox>
      <text><label>Password:</label></text>
      <entry invisible_char=\"x\" visibility=\"false\">
        <default>\"1234567890\"</default>
        <variable>VAR</variable>
       </entry>
      </hbox>
      <hbox>
        <button ok></button>
       </hbox>
      </vbox>
     </window>"
gtkdialog -p DLG
was working fine in Pupdial and Pnethood as far as I know. It formerly showed a row of x's (xxxxxxx) to blank the password, now there is no x's and no anything (no visible entry when typing, variable is fine though on exit) I guess though that is the expected result and the old way was a buggy side effect.

There is a syntax I wasn't aware of that shows dots for the password..

Code: Select all

<visible>password</visible>
.. that is backward compat, works in old Pupdial.

Code: Select all

export DLG="<window>
	<vbox>
	 <hbox>
         <text>
	  <label>Password</label>
	 </text>
	 <entry tooltip-text=\"Enter your password here\">
	    <default>\"1234567890\"</default>
	    <visible>password</visible>
	    <variable>ENCKEY</variable>
	  </entry>
      <button ok></button>
     </hbox>
    </vbox>
   </window>"
gtkdialog -p DLG
The example in the docs suggests that the behaviour of my first example is as expected.

cheers
01micko

EDIT: '<entry invisible_char=\"x\" visibility=\"false\">' in first example

Posted: Sun 21 Aug 2011, 11:07
by thunor
zigbert wrote:By replacing <progressbar> by <timer> in Pprocess, the pid handling become much better.
Excellent, and you're welcome.
zigbert wrote:There is a misbehavior in the menu widget. I think (really sure) that this has arrived with 0.7.21.
...
This happens for icon="gtk-save" and gtk-info as well. I have not checked all, but many works as expected.

A sidenote: The menubar example still uses <seperator> instead of <menuitemseperator>
I couldn't see anything wrong with your example. I added entries for gtk-save and gtk-info as well and took and attached a screenshot (I'm using lupu-520 with the GTK+ 2 Crux theme).

[EDIT] I use /usr/sbin/gtkdialog so I still have the /usr/sbin/gtkdialog3 0.7.20 Patriot Edition which I tried and all the icons are present except that originally menuitem theme icons from icon="imagename" were hardcoded to 20px whereas I set them to 16px (the GTK+ function that loads theme icons ultimately chooses the size from the nearest available).

Cheers, I've updated both menubar examples.

Regards,
Thunor

Posted: Sun 21 Aug 2011, 13:12
by thunor
01micko wrote:There is a backward compat issue that has surfaced.
...
It formerly showed a row of x's (xxxxxxx) to blank the password, now there is no x's and no anything...
I've found the issue :)

Firstly I should point out that both "invisible-char" and "visibility" are GTK+ properties and all that Gtkdialog does with them is pass them onto GTK+ to set.

A short while back I fixed some code that was passing variables of type guint (GTK+ unsigned integer) to GTK+ as a gchar, and this was the reason why "border-width" never worked before. Well, "invisible-char" is a guint but because the code was bugged and sending the value to GTK+ as a gchar, the value shown in the examples is "x" when it should've been "120" ;) Therefore the Gtkdialog documented "invisible-char" is wrong.

"invisible-char" isn't even required as GTK+ uses a default asterisk according to the documentation, so the visibility="false" tag attribute or the <sensitive>password</sensitive> directive should suffice.

Yes, the <sensitive>password</sensitive> directive works (I deprecated <visible> but you can still use it).

[EDIT] I've fixed my entry example and updated examples/02.01-entry_attributes.

Regards,
Thunor

Posted: Sun 21 Aug 2011, 13:24
by rcrsn51
thunor wrote:(I deprecated <visible> but you can still use it).
Hopefully, that's all you plan to do with it. The Samba-TNG client tools have always used the <visible> tag to hide passwords.

Posted: Sun 21 Aug 2011, 14:06
by thunor
rcrsn51 wrote:Hopefully, that's all you plan to do with it. The Samba-TNG client tools have always used the <visible> tag to hide passwords.
Hello rcrsn51

The <visible> directive is used to hold "enabled" or "disabled" ("password" in your case which is unique) which describes the widget's sensitive state of "true" or "false". This is equivalent to the tag attribute (GTK+ property) of sensitive="true/false" but it makes no sense whatsoever being called <visible> or holding "enabled" or "disabled" (<enabled>true/false</enabled> would be an improvement). Now, part of what I am doing is making things consistent and sensible, therefore removing <visible>enabled/disabled</visible> from the documentation and replacing it with <sensitive>true/false</sensitive> to me seems like a very sensible thing to do -- even more so when you consider that there exists a visible="false" tag attribute to hide a widget! -- but I'd have to be a complete moron to remove support for <visible> as it would break a very high percentage of every Gtkdialog application ever written.

Anyway, thanks for your positive input as I find it very helpful :)

Kindest regards,
Thunor

Posted: Sun 21 Aug 2011, 16:35
by 8-bit
01micko wrote:Hi all,

There is a backward compat issue that has surfaced.

This syntax:

Code: Select all

export DLG="<window>
	<vbox>
	 <hbox>
      <text><label>Password:</label></text>
      <entry invisible_char="x" visibility="false">
        <default>"1234567890"</default>
        <variable>VAR</variable>
       </entry>
      </hbox>
      <hbox>
        <button ok></button>
       </hbox>
      </vbox>
     </window>"
gtkdialog -p DLG
was working fine in Pupdial and Pnethood as far as I know. It formerly showed a row of x's (xxxxxxx) to blank the password, now there is no x's and no anything (no visible entry when typing, variable is fine though on exit) I guess though that is the expected result and the old way was a buggy side effect.

There is a syntax I wasn't aware of that shows dots for the password..

Code: Select all

<visible>password</visible>
.. that is backward compat, works in old Pupdial.

Code: Select all

export DLG="<window>
	<vbox>
	 <hbox>
         <text>
	  <label>Password</label>
	 </text>
	 <entry tooltip-text="Enter your password here">
	    <default>"1234567890"</default>
	    <visible>password</visible>
	    <variable>ENCKEY</variable>
	  </entry>
      <button ok></button>
     </hbox>
    </vbox>
   </window>"
gtkdialog -p DLG
The example in the docs suggests that the behaviour of my first example is as expected.

cheers
01micko

EDIT: '<entry invisible_char="x" visibility="false">' in first example
In your first example, it looks like it is working just like most linux login password prompts as I do not remember any ever echoing any keyboard input.

I checked both from a terminal with an added "echo $ENCKEY" to see what was passed and that was as expected.

In both examples, if the default is set to an empty string, the entry box looks a lot cleaner.
ie <default>""</default>>

The question is if using the second example for password input is being used in existing puppy applications or changes to gtkdialog break them.

Also, one might want to include the "Enter_ok" code so that if the user presses Enter after entering the password, it acts the same as clicking the OK button.

Posted: Sun 21 Aug 2011, 17:12
by 8-bit
I just tried to add the "Enter_OK" code and evidently it does not work with an entry window.
Too bad, unless someone can show me how it could work.

Maybe the entry widget needs to accept the Enter key as an "end_of_entry_input".
Would this cause any problems?

style addition

Posted: Sun 21 Aug 2011, 20:12
by Moose On The Loose
I often have to do something like:

Code: Select all

echo 'style "specialwarning"
  {  fg[NORMAL] = { 1.0, 0, 0 } }
  widget "*warning" style "specialwarning"
  class "GtkText*" style "specialwarning"
style "specialmono"
  {  font = "mono 12" }
  widget "*mono" style "specialmono"
  class "GtkText*" style "specialmono"' >$GTK_RC_FILE
to make a style for something unusual in the dialog boxes. Doing this could be automated. I can do it by putting a wrapper script around gtkdialog that loos for the "<style>" tag and makes the file needed and then removes it again after the dialog is closed. This could also be built into the gtkdialog.

Posted: Sun 21 Aug 2011, 20:53
by thunor
8-bit: invisible_char="x" is an error in the original Gtkdialog documentation but it worked because the Gtkdialog C code that passed "x" to GTK+ to set was bugged. In fact ALL guint GTK+ properties would've been affected by this bug, but I don't think that there are many of them.

Fixed code and bug: http://code.google.com/p/gtkdialog/sour ... 4&r=194#95

Nothing within the second example is being changed to break anything. <visible>password</visible> has always worked and will always work.

When you say "Enter_OK code", are you describing pressing the Enter key within an entry widget to activate a default OK button? If so the very first entry widget in the entry example does exactly this. I've also connected-up the "activate" signal so that it is emitted when pressing Enter within the widget which can be used to do anything you wish. I recommend that you play with the example.

Regards,
Thunor

Posted: Sun 21 Aug 2011, 22:29
by 8-bit
Thank you thunor,
With your latest example in hand, I figured out the problem.
Sometimes it takes looking at an example from someone that knows how it all works for a blind man to see the light!

Posted: Tue 23 Aug 2011, 16:10
by thunor
Added togglebutton widget

The widget reference is available here.

This widget uses the exact same code (same functions in fact) as the button widget with the following changes:
  • <default>true/false<default> will set the default active state
  • <input>command</input> will set the default active state and again on refresh
  • <action>if true function:parameter</action> conditional action function execution is supported
  • The widget's variable will contain "true" (pressed-in) or "false" (normal)
  • The default signal is "toggled"
  • The save action function will save "true" or "false" to an outputfile
<togglebutton> widget example (attached images required):

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

ln -sf true.svg tgb0.svg; ln -sf false.svg tgb1.svg

export MAIN_DIALOG='
<window title="tgbToggleButton" resizable="false" border-width="0">
	<vbox>
		<menubar>
			<menu use-underline="true">
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
				<label>"_File"</label>
				<variable>mnuFile</variable>
				<sensitive>false</sensitive>
			</menu>
		</menubar>
		<vbox border-width="20" spacing="20">
			<hbox>
				<togglebutton>
					<default>true</default>
					<label>Toggle</label>
					<variable>tgb0</variable>
					<input file>tgb0.svg</input>
					<action>ln -sf $tgb0.svg tgb0.svg</action>
					<action>refresh:tgb0</action>
					<action>save:tgb0</action>
					<action>refresh:ent0</action>
					<output file>outputfile</output>
				</togglebutton>
				<entry>
					<default>true</default>
					<variable>ent0</variable>
					<input>echo $tgb0</input>
				</entry>
			</hbox>
			<hseparator></hseparator>
			<hbox homogeneous="true">
				<togglebutton>
					<variable>tgb1</variable>
					<height>128</height>
					<width>128</width>
					<input file>tgb1.svg</input>
					<action>ln -sf $tgb1.svg tgb1.svg</action>
					<action>refresh:tgb1</action>
					<action>if true enable:mnuFile</action>
					<action>if false disable:mnuFile</action>
				</togglebutton>
			</hbox>
		</vbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor

Posted: Thu 25 Aug 2011, 06:48
by zigbert
More info about the menu-icon issue
I am not sure if this issue should be targeted here, so I will post a link in the Slacko thread as well.

The problem is that icons in the menu shows well in Puppy 5 but not in Slacko. This only happens to some of the builtin icons (like gtk-new, gtk-save, gtk-information). My first thought was that this has to be an gtk issue in Slacko (Puppy 5.xx uses gtk 2.20, Slacko uses gtk 2.24), but programs like Abiword, Gnumeric and Geany does not have this problem with their icons NOT taken from the gtk-stock. It _seems_ to only happen for gtkdialog apps.

In Slacko the Pmusic menu looks like this (gtkdialog-rev224).
Image

In Puppy 511, it appears like it is meant to be (same gtkdialog).
Image

This might be related to an old gtkdialog behavior I have wondered about. Why menuitems does not support gtk-undo, gtk-redo (together with other icons) else using the gtk-stock. That means <menuitem icon="gtk-undo"> fails but setting <menuitem stock="gtk-undo"> will work - but now you are not allowed to give it another label than the stock-label. Even more strange is it that gtk-media-stop works with both icon and stock setting, while gtk-media-play only works with the stock.


Sigmund

Posted: Thu 25 Aug 2011, 08:02
by 01micko
Hi zigbert, thunor

just some info on Slacko, may or may not be relevant.

*Slacko uses gtk+-2.24.4 version [pkgname: gtk+2-2.24.4-i486-1.txz]

*source and patches

*some icons in gnome-mplayer don't work, so maybe there is a clue there (I suspect other apps too)

*Slackware sources are nearly always patched, they don't care about looks, stability is paramount.

Hope this helps

Posted: Thu 25 Aug 2011, 08:53
by ttuuxxx
hi guys on 2.14X the next version will have gtk+-2.24.5, I just compiled so I installed pmusic and well I only had a total of 4 icons for all three menus combined. But Firefox 6.0 had the regular amount, but pburn had all the menu icons. ?? looks more like a pmusic issue, than gtk2+

Posted: Thu 25 Aug 2011, 16:08
by thunor
Overhauled the fileselect action function
  • The existing accept="filename/savefilename/directory/newdirectory" custom tag attribute has been deprecated in favour of fs-action="file/newfile/folder/newfolder" which better represents the file chooser dialog actions.
  • Added fs-folder="/path/to/current/folder" custom tag attribute.
  • Added fs-filters="pattern|pattern|..." custom tag attribute.
  • Added fs-filters-mime="mime/type|mime/type|..." custom tag attribute.
  • Added fs-title="File Chooser Dialog Title" custom tag attribute.
Note that this is not the <chooser> widget, it is the fileselect action function type as used in <action>fileselect:ENTRY1</action> and within Gtkdialog they are both seperate entities.

Note too that fs-action="newfolder" (accept="newdirectory") is temperamental and the file chooser dialog will hang if you select nothing other than "OK", and for example going back a level and not selecting a folder and then selecting "OK" will return NULL and therefore not update the entry widget. Since this particular file chooser action only wants the user to create a new folder then fs-action="folder" (accept="directory") will suffice as there's a "Create" folder button anyway.

I did notice that the target widget's <label> directive can be used for the file chooser dialog's title which can be seen in the 16.00-fileselect example, but I'm not sure if this is widely known. Anyway, "fs-title" can be used now which will be documented.

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

function funcbtnCreate() {
	echo '<button>
			<input file stock="gtk-'$2'"></input>
			<action>fileselect:ent'$1'</action>
		</button>'
}

export MAIN_DIALOG='
<window title="Fileselect" resizable="false" width-request="500">
	<vbox>
		<vbox border-width="20" spacing="10">
			<hbox>
				<text label="All defaults" width-request="80"></text>
				<entry>
					<variable>ent0</variable>
				</entry>
				'"$(funcbtnCreate 0 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="file" width-request="80"></text>
				<entry fs-action="file" fs-folder="/usr/share/doc"
					fs-filters="*.txt|*.html"
					fs-title="Select an existing file">
					<variable>ent1</variable>
				</entry>
				'"$(funcbtnCreate 1 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="newfile" width-request="80"></text>
				<entry fs-action="newfile" fs-folder="'$HOME'"
					fs-filters-mime="text/plain|text/html"
					fs-title="Select an existing file or type in a new filename">
					<variable>ent2</variable>
				</entry>
				'"$(funcbtnCreate 2 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="folder" width-request="80"></text>
				<entry fs-title="Select an existing folder" fs-action="folder">
					<variable>ent3</variable>
				</entry>
				'"$(funcbtnCreate 3 open)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="newfolder" width-request="80"></text>
				<entry fs-action="newfolder"
					fs-title="Select an existing folder or type in a new folder name">
					<default>This fileselect action type is temperamental</default>
					<variable>ent4</variable>
				</entry>
				'"$(funcbtnCreate 4 open)"'
			</hbox>
		</vbox>
		<hseparator></hseparator>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor

Posted: Thu 25 Aug 2011, 16:32
by vovchik
Dear thunor,

What can I say? FAB...

With thanks and kind regards,
vovchik

Posted: Thu 25 Aug 2011, 18:33
by jpeps
thunor wrote:Overhauled the fileselect action function
Great!!! Will give it a try...Thanks

edit: This works nicely...major addition.

Posted: Thu 25 Aug 2011, 22:46
by thunor
vovchik and jpeps: cheers for the feedback.

[EDIT] Screenshot below looks cool :)

Regards,
Thunor

New Fileselect Filters

Posted: Fri 26 Aug 2011, 07:05
by jpeps
Ah....This is way better!

Posted: Fri 26 Aug 2011, 16:50
by thunor
zigbert, 01micko and ttuuxxx: Ok, where to start with this. I'll list the C code for the widgets that support theme icons:

button widget
pixmap widget
menuitem widget
tree widget (the task is handled by a GTK+ function)

I didn't write the icon theme loading code and I haven't particularly researched it either; it was already there and working and all I've done is make it more robust, but the results within the tree widget are identical to the other widgets so I personally wouldn't focus my attention on the code at this point.

I did very recently modify the menuitem theme icon code to show the missing icon image if it wasn't found and I'm now thinking that it'd be better not to show the image within the menu so I intend to change that.

I should point out too that there's more to theme icons than the gtk-stock-id images we are dealing with here. I recently fixed a few examples within the examples folder that were referencing invalid theme icons and I replaced them with a selection that I know are located within /usr/share/icons and /usr/share/mini-icons, so can everybody see icons from those folders?

Updated 2011-08-27 23:41: You should see all of the icons except for gtk-discard which is a known GTK+ "issue".

Here's an example that attempts to show all the stock images by loading them as theme icons:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

window_width=800
icon_names=(echo $(<icon-names.txt))
type=icon

mnuCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<menu label="Menu'$x'" width-request="'$(($window_width/7+1))'">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<menuitem '$type'="'${icon_names[$i]}'">
					<label>""</label>
				</menuitem>'
		done
		echo '</menu>'
	done
}

pixCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<vbox spacing="0" scrollable="true">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<pixmap>
					<input file '$type'="'${icon_names[$i]}'"></input>
				</pixmap>'
		done
		echo '</vbox>'
	done
}

btnCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<vbox spacing="0" scrollable="true">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<button>
					<input file '$type'="'${icon_names[$i]}'"></input>
				</button>'
		done
		echo '</vbox>'
	done
}

treCreate() {
	for ((x = 0; x < 3; x++)); do
		echo '<tree>
				<label>Name|GTK+</label>'
		for ((y = 0; y < 35; y++)); do
			i=$((x*35*2+y*2+1))
			echo '<item '$type'="'${icon_names[$i]}'">"'${icon_names[$i]}'|'
			if [ ${icon_names[$(($i+1))]} != 0 ]; then
				echo ${icon_names[$(($i+1))]}
			fi
			echo '"</item>'
		done
		echo '</tree>'
	done
}

export MAIN_DIALOG='
<window title="Theme Icon Test" width-request="'$window_width'"
	border-width="0" resizable="false">
	<vbox spacing="0">
		<menubar>
			'"$(mnuCreate)"'
		</menubar>
		<hbox spacing="0" height-request="200">
			'"$(pixCreate)"'
		</hbox>
		<hbox spacing="0" height-request="200">
			'"$(btnCreate)"'
		</hbox>
		<hbox spacing="0" height-request="200">
			'"$(treCreate)"'
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor