YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#641 Post by Argolance »

Bonjour,
Just for info:
:arrow: A handy script for translations... using yad. :)

Cheers.

Wognath
Posts: 423
Joined: Sun 19 Apr 2009, 17:23

#642 Post by Wognath »

phat7 wrote: May I ask how you want to use it?
I forget to hit enter, or I'm too lazy to click OK :( I have been using Xdialog --timeout --interval, would have been surprised if yad could not do the same--although it required some reading between the lines.

Code: Select all

suspend; z=$(timeout -s SIGUSR1 5 yad --text "enter password" --entry --no-buttons) ; if correct then resume else log out

z=$(timeout -s SIGUSR1 5 yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK) ; case $z in...

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#643 Post by misko_2083 »

Wognath wrote:
phat7 wrote: May I ask how you want to use it?
I forget to hit enter, or I'm too lazy to click OK :( I have been using Xdialog --timeout --interval, would have been surprised if yad could not do the same--although it required some reading between the lines.

Code: Select all

suspend; z=$(timeout -s SIGUSR1 5 yad --text "enter password" --entry --no-buttons) ; if correct then resume else log out

z=$(timeout -s SIGUSR1 5 yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK) ; case $z in...
yad has an option:

Code: Select all

yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK --timeout=5  --timeout-indicator=bottom

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#644 Post by fredx181 »

misko_2083 wrote:yad has an option:
Code:
yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK --timeout=5 --timeout-indicator=bottom
That doesn't give any output for me without clicking OK (which is where this is all about)

@All , note that the "timeout" command can probably be a symlink to busybox on Puppy and there's difference between busybox versions, see radky's and mochimoppels's comments here:
http://murga-linux.com/puppy/viewtopic. ... 80#1031680
http://murga-linux.com/puppy/viewtopic. ... 95#1031795

Fred

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#645 Post by misko_2083 »

fredx181 wrote:
misko_2083 wrote:yad has an option:
Code:
yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK --timeout=5 --timeout-indicator=bottom
That doesn't give any output for me without clicking OK (which is where this is all about)

@All , note that the "timeout" command can probably be a symlink to busybox on Puppy and there's difference between busybox versions, see radky's and mochimoppels's comments here:
http://murga-linux.com/puppy/viewtopic. ... 80#1031680
http://murga-linux.com/puppy/viewtopic. ... 95#1031795

Fred
Well patch it.
in src/main.c find timeout_cb function
and add the call to function yad_print_result () before yad_exit ()

This is an example with 0.41 with added yad_print_result function

Code: Select all

static gboolean
timeout_cb (gpointer data)
{
  static guint count = 1;
  GtkWidget *w = (GtkWidget *) data;

  if (options.data.timeout < count)
    {
      yad_print_result ();
      yad_exit (YAD_RESPONSE_TIMEOUT);
      return FALSE;
    }

  if (w)
    {
      gdouble percent = ((gdouble) options.data.timeout - count) / (gdouble) options.data.timeout;
      gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (w), percent);
      if (g_settings_get_boolean (settings, "show-remain"))
        {
          gchar *lbl = g_strdup_printf (_("%d sec"), options.data.timeout - count);
          gtk_progress_bar_set_text (GTK_PROGRESS_BAR (w), lbl);
          g_free (lbl);
        }
    }

  count++;

  return TRUE;
}
Then compile, and try:

Code: Select all

 yad --text "Shut down and save, or..." --form --field "No save":CHK --field "Reboot":CHK --timeout=5 --timeout-indicator=bottom
:wink:

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

translate-shell

#646 Post by josejp2424 »

Argolance wrote:Bonjour,
Just for info:
:arrow: A handy script for translations... using yad. :)

Cheers.
It would be nice to make an icon in the systray. to have the translator at hand.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#647 Post by Argolance »

It would be nice to make an icon in the systray. to have the translator at hand
Make it, it's a very good idea! :wink:

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

#648 Post by vovchik »

Dear all,

Here is trans-paste and trans-tray. Put them both into some executable dir. Start trans-tray. Left click and you get a trans-paste box that will do the translation if the clipboard has a non-English text. I also supplied an icon and desktop file that you can edit for the icon location.

With kind regards,
vovchik

PS. All of this is very quick and dirty...
Attachments
trans-paste.tar.gz
(1.24 KiB) Downloaded 149 times

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#649 Post by fredx181 »

How nice !! Thanks Argolance and vovchik !!!

Fred

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#650 Post by Argolance »

Bonjour,
PS. All of this is very quick and dirty...
I'm afraid of what some people might think of my own scripts. :oops:

You were very quick indeed!
Icons aside (which are not really adapted) everything is perfect.
Now, a right-click menu would be useful for some settings as well as internationalization by the same token?

I wonder if josejp2424 wouldn't currently be working on scripts of the same kind?

Thank you vovchik for this.

Cordialement.

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#651 Post by fredx181 »

Here's a (not so quick, but very dirty :D ) script, modified vovchik's script with addition of simple right-click menu with option to set the target language to translate to (provides list with languages to choose from)
A lot more can be done of course with all the options from "translate-shell", this is just a simple setup for testing, but maybe can be a start for a much more advanced program, who knows !

Attached trans_tray (merged together trans-tray and trans-paste from vovchik's concept) remove fake .gz and make executable.

Fred
Attachments
2019-08-18-234825_635x710_scrot_635x710.jpg
In italian
(97.27 KiB) Downloaded 363 times
trans_tray.gz
Remove fake .gz and make executable, depends on translate-shell and yad
(5.55 KiB) Downloaded 141 times
Last edited by fredx181 on Sun 18 Aug 2019, 21:50, edited 1 time in total.

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

trans_tray

#652 Post by josejp2424 »

fredx181 wrote:Here's a (not so quick, but very dirty :D ) script, modified vovchik's script with addition of simple right-click menu with option to set the target language to translate to (provides list with languages to choose from)
A lot more can be done of course with all the options from "translate-shell", this is just a simple setup for testing, but maybe can be a start for a much more advanced program, who knows !

Attached trans_tray (merged together trans-tray and trans-paste from vovchik's concept) remove fake .gz and make executable.

Fred
it is excellent fredx181 and vovchik

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

#653 Post by vovchik »

Dear josejp2424,

Well done. Thanks. I think one thing we might want eventually to include in the right-click menu is the selection of translation engine (google, bing, yandex and deepl). Some engines are better at certain languages and worse at others, and deepl, for example, cannot handle very many. It's just a thought... In any case,trans_tray works nicely as it is. :)

With kind regards,
vovchik

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

tran_tray

#654 Post by josejp2424 »

fredx181 and vovchik

I included gettext to trans_tray.
Change the icon and color. Do not modify the lines of the icon.

icon to differentiate who is a translator

Image

gettext in GUI

Image
Attachments
translate_shell+GUI-0.9.6.11-dpupbuster64.pet
for which you use dpupbuster64.
complete package for testing.
translate-shell + trans-tray
(46.75 KiB) Downloaded 102 times
trans_tray.tar.bz2
trans_tray+gettext+icono+locale-es
(5.99 KiB) Downloaded 119 times

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#655 Post by fredx181 »

josejp2424 wrote:fredx181 and vovchik

I included gettext to trans_tray.
Change the icon and color. Do not modify the lines of the icon.

icon to differentiate who is a translator
Nice josejp !
In the meantime I worked on a version with choice of different engines in the menu, see attached. (but not gettext added, sorry)
The engine choices are Google, Bing and Yandex, but Yandex doesn't always work well, half of the time I get message:

Code: Select all

[ERROR] Oops! Something went wrong and I can't translate it for you :(
I use the newest trans, see here:
https://github.com/soimort/translate-shell#installation
I think with older version the Bing translator doesn't work.

Fred

Fred
Attachments
trans_tray.gz
Remove fake .gz and make executable
(6.28 KiB) Downloaded 100 times
2019-08-19-165754_633x713_scrot_533x600.jpg
Added choice of translate engines
(55.37 KiB) Downloaded 283 times

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

#656 Post by vovchik »

Dear Fredx181 and josejp2424,

This little thing is getting better by the day. :) Thanks. I have been using the latest trans in my testing (v. 0.9.6.11-release) and suggest that everybody use a recent version.

With kind regards,
vovchik

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#657 Post by fredx181 »

And thanks again to you, vovchik ! for your great start concept.
For me it's ok for the most as it is, except maybe some help text could be added, do you perhaps have any more ideas for changes or improvement ?

Fred

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

button exit

#658 Post by josejp2424 »

fredx181 wrote:And thanks again to you, vovchik ! for your great start concept.
For me it's ok for the most as it is, except maybe some help text could be added, do you perhaps have any more ideas for changes or improvement ?

Fred
the EXIT button should be removed .
because it eliminates the sistray program

Image

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#659 Post by fredx181 »

josejp2424 wrote:the EXIT button should be removed .
because it eliminates the sistray program
Not sure if I understand, if you don't want to eliminate the sistray program, then just don't click on EXIT, or are you perhaps saying that for you it eliminates without clicking on EXIT, (accidentally ?)

Fred

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

button exit

#660 Post by josejp2424 »

fredx181 wrote:
josejp2424 wrote:the EXIT button should be removed .
because it eliminates the sistray program
Not sure if I understand, if you don't want to eliminate the sistray program, then just don't click on EXIT, or are you perhaps saying that for you it eliminates without clicking on EXIT, (accidentally ?)

Fred
If the exit button is pressed by mistake, the program closes.
and is no longer available in the systray bar.
That is why it should be removed.

Post Reply