Page 1 of 1

Bash & GtkDialog

Posted: Tue 10 Apr 2012, 10:59
by RSH
Hi.

I want to open a program (Bash/GtkDialog) at specific screen position. This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.

How can i get current screen size/resolution and how do i convert this into a gtkdialog position?

Thanks

RSH

Posted: Tue 10 Apr 2012, 12:34
by 01micko
An example here

Posted: Tue 10 Apr 2012, 20:07
by don570
Make sure you use <window resizable="false">
to avoid empty space

_______________________________________________


Zigbert wrote in his tutorial

Code: Select all

N.B. some properties are enumerated and can be replaced by integer values e.g in a window widget window-position=\"1\" means centre the window and window-position=\"2\" means follow cursor. A tip is when reading the documentation a tooltip indicates the property type 
Also note that widgets have hierarchy and inherit from them 
If you can read French here's some useful advice on windows

window_position="1" and window_position="2"
can be useful

Code: Select all

GtkWindow
Icône de la fenêtre :
<window icon-name="gtk-info">
Titre de la fenêtre :
<window title="Titre">
Fenêtre impossible à redimensionner :
<window resizable="false">
Retirer le contour de la fenêtre :
<window decorated="false">
Cacher la fenêtre de la barre des taches :
<window skip_taskbar_hint="true">
Position de la fenêtre :
<window window_position="XXX">
1 : placer la fenêtre au centre de l'écran;
2 : la fenêtre se placera automatiquement à la position actuelle de la souris;
3 : garder la fenêtre centrée même après redimensionnement.
Exemple final :
<window window_position="1" resizable="false" title="Joli titre" skip_taskbar_hint="true">
<text>
<label>
"Voici une fenêtre non modifiable,
avec un joli titre
qui apparaît au centre de l`écran
et qui n`apparait pas dans la barre des taches."
</label>
</text>
</window>
Retour au Sommaire
Fenêtre pop-up au survol de texte :
#! /bin/bash
#window_position="2"
export POPUP='<window window_position="2" decorated="false">
<vbox>
<text>
<input>cat /tmp/msgaafficher</input>
</text>
</vbox>
</window>'
export MAITRE='<window title="Test survol" icon-name="gtk-info">
<vbox>
<text>
<input>echo "Vouep bon c'\''est pas encore top\nmais bon...\navec 2 dans
window_position est mieux,\nmais a mon avis ogligé de passer par include file pour fonction qui masque
message...\n\na faire évoluer."</input>
</text>
<button>
<label>Essai de survol</label>
<action signal="enter-notify-event">echo "Texte à\nafficher" | tee
/tmp/msgaafficher && sleep 1 && gtkdialog --program=POPUP&</action>
<action signal="leave-notify-event">sleep 2 && kill $(ps ax | grep "gtkdialog
--program=POPUP" | awk '\''{print $1}'\'' | grep -v grep | xargs)&</action>
<action>kill $(ps ax | grep "gtkdialog --program=POPUP" | awk '\''{print $1}'\'' |
grep -v grep | xargs)</action>
<action type="exit">exit</action>
</button>
</vbox>
<action signal="show">echo "" | tee /tmp/msgaafficher</action>
<action signal="hide">echo "" | tee /tmp/msgaafficher</action>
</window>'
gtkdialog --program=MAITRE
exit 0

Posted: Tue 10 Apr 2012, 20:54
by SFR
Here's another example of determining current screen resolution (using xrandr) and adjusting position of the GtkDialog window.
http://www.murga-linux.com/puppy/viewto ... 172#602172

BTW, you said:
This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.
In this case you might consider the use of xdotool:

Code: Select all

xdotool getmouselocation
will return the current X/Y position, and thanks to this you'll be able to open a new window in exact cursor position, or (in other words) above the mentioned icon, when clicked.

Greetings!

Posted: Tue 10 Apr 2012, 21:29
by RSH
don570 wrote:Zigbert wrote in his tutorial

Code: Select all

N.B. some properties are enumerated and can be replaced by integer values e.g in a window widget window-position="1" means centre the window and window-position="2" means follow cursor. A tip is when reading the documentation a tooltip indicates the property type 
Also note that widgets have hierarchy and inherit from them 
Currently this one seems to be the easiest way for me to do.
SFR wrote:BTW, you said:
This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.
In this case you might consider the use of xdotool:

Code: Select all

xdotool getmouselocation
will return the current X/Y position, and thanks to this you'll be able to open a new window in exact cursor position, or (in other words) above the mentioned icon, when clicked.
This might be useful also, because LazY Puppy has already built in the xdotool.

But: how do i get the results of xdotool in a $xpos and $ypos variable?

To set the result of xdotool as positions of a gtkdialog application i can not use the automatically generated console output of xdotool.

Posted: Tue 10 Apr 2012, 21:41
by SFR
RSH wrote:This might be useful also, because LazY Puppy has already built in the xdotool.

But: how do i get the results of xdotool in a $xpos and $ypos variable?

To set the result of xdotool as positions of a gtkdialog application i can not use the automatically generated console output of xdotool.
Like that, I suppose:

Code: Select all

#!/bin/bash

LOCATION=`xdotool getmouselocation`
Xpos=`echo $LOCATION | cut -f2 -d ':' | cut -f1 -d ' '`
Ypos=`echo $LOCATION | cut -f3 -d ':' | cut -f1 -d ' '`
echo $Xpos   # just for testing
echo $Ypos   # just for testing
BTW, It's cool that you have put xdotool in LazY; it should be out-of-the-box in every Puppy IMHO :D

Greetings!

Posted: Wed 11 Apr 2012, 03:23
by technosaurus
gtkdialog can set geometry

Code: Select all

gtkdialog
-G, --geometry=[XxY][+W+H]      The placement and the size of the window.
to get a quick cursor position

Code: Select all

read X Y <<< $(getcurpos)
then do whatever magic calculations you want for $X and $Y (awk works well)