Gambas-it

Gambas3 => Programmazione => Topic aperto da: koko - 13 Aprile 2016, 15:45:23

Titolo: Higgins: un lanciatore per gambas
Inserito da: koko - 13 Aprile 2016, 15:45:23
Sto scrivendo un lanciatore di applicazioni, si chiama "higgins", come il maggiordomo di Magnum Pi :)
https://github.com/kokoko3k/higgins/blob/master/README (https://github.com/kokoko3k/higgins/blob/master/README)

Attualmente è in grado di fare calcoli, cercare applicazioni, file (tramite locate), e lanciare comandi eventualmente in un terminale.

Quello che manca, e che vorrei integrare, è la registrazione di hotkey globali, di modo che possa essere richiamato tramite una combinazione di tasti senza l'ausilio di helper esterni (come xbindkeys e quelli integrati in kde).

Non ho trovato nulla nella documentazione ufficiale.
L'unico esempio che ho trovato, questo:
http://gambas.8142.n7.nabble.com/How-to-show-a-form-with-keyboard-shortcut-td25183.html (http://gambas.8142.n7.nabble.com/How-to-show-a-form-with-keyboard-shortcut-td25183.html)
..Ma parla di programmazione delle Xlib a basso livello, troppo basso per me, ed oltretutto non mi funziona nemmeno.
C'è qualcuno in grado di aiutarmi?

A parte questo, estendo l'invito a chiunque volesse contribuire ad allargare le funzionalità di higgins.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: Gianluigi - 13 Aprile 2016, 17:42:58
Ciao Koko,
ben ritrovato. Miseria fai delle robe... :o
Un po mi scappa da ridere perchè proprio ieri parlando con un ns. collega che si lamentava che con l'aggiornamento del kernel aveva vari problemi fra cui il non funzionamento delle trayicon io gli ho risposto che neanche le sapevo usare, ed ecco che tu me le mostri  :D

Comunque non sono sicuro di saperla far funzionare ma ottengo questo in console quando la chiudo.

Codice: [Seleziona]
gbx3: warning: circular references detected:
gbx3:     1 DBusStatusIcon
gbx3:     1 DBusStatusIconMenu
gbx3:     1 TrayIcon
gbx3:     4 DBusObject
gbx3:     2 Picture
gbx3: warning: 74 allocation(s) non freed.

La ricerca mi riesce ma io di menu vedo solo il Quit.
Ho Ubuntu 14.04

Circa il quesito che poni, non so se sono in grado di aiutarti ma cosa vuoi sapere esattamente delle shortcut?
 :ciao:
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 13 Aprile 2016, 18:12:32
Ciao e grazie per le lusinghe :)
Non c'è molto da sapere su higgins, dovrebbe/vorrebbe essere semplice come concetto, e se non lo è, allora non funziona bene  ;D

Comunque la trayicon serve solo a uscire dall'applicazione, ecco perchè ottieni solo "quit" dal suo menu,mentre se ci clicchi, mostri la finestra principale.
Per il resto, basta scrivere un termine nella textbox.
I primi risultati proposti sono i file .desktop (i lanciatori); viene effettuata ricerca per nome, descrizione e commento (purtroppo, per adesso solo i termini inglesi.)
E' quindi presumibile che se scrivi "office" avrai qualsiasi programma che tratti file da ufficio; se scrivi "game", avrai tutti i giochi appartenenti alla categoria "game" e così via.
Se hai installato il programma "locate", che indicizza il tuo disco, higgins lo usa per proporti i risultati della ricerca in modo abbastanza veloce.
Per ultimo, se scrivi =4+4 oppure =sin(4)^2, avrai il risultato dell'operazione.

Essendo un launcher, è comodo che l'utente possa lanciarlo con una combinazione di tasti.
Questa dev'essere registrata in X11 come scorciatoia globale, e a quanto pare gambas non implementa questa cosa; per cui bisogna ricorrere alla programmazione di api a più basso livello come quelle di X11.

So che da quel messaggio in uscita, ma non capisco dove mettere le mani per impedirlo;  :hard:; non credo comunque sia grave.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: Gianluigi - 13 Aprile 2016, 18:19:51
Si scusami il tuo programma mi funziona bene.
Trova tutto in un attimo è ottimo.
Non ero riuscito a fare le operazioni matematiche perché non ho pensato agli spreadsheet  ;D

Da una vista rapida del codice avevo frainteso che ci fosse un menu (menu1)

Ora ho capito anche cosa chiedevi circa i tasti rapidi, ma come detto di trayicon nulla saccio Comunque se mi dovesse venire qualche idea io non mi vergogno a dirla.

 :ciao:

PS: Purtroppo l'utente che ti potrebbe aiutare è quello a cui il kernel da problemi, gli altri capaci oramai ci hanno abbandonato  :'(

PS2: Se chiudo la finestra di ricerca e poi tento di riaprirla cliccando sulla trayicon non mi riesce, si tratta di un bug?
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: vuott - 14 Aprile 2016, 00:41:57
..Ma parla di programmazione delle Xlib a basso livello
Nell'esempio lì riportato si utilizzano in Gambas mediante la risorsa Extern le funzioni esterne del API del sistema grafico X11.


Nella nostra WIKI ho riportato qualche pagina con esperimenti di utilizzo della libreria X11, come ad esempio questa:
http://www.gambas-it.org/wiki/index.php?title=Creare_una_finestra_mediante_le_funzioni_del_API_di_X11
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 14 Aprile 2016, 18:26:08
Ti ringrazio molto ma non ho fatto molti progressi.
il mio codice:
Codice: [Seleziona]
' Gambas class file

Public Struct XEventStruct
  type As Integer
  serial As Long
  send_event As Boolean
  display As Pointer
  windowL As Long
  root As Long
  subwindow As Long
  timeL As Long
  x As Integer
  y As Integer
  x_root As Integer
  y_root As Integer
  state As Integer
  keycode As Integer
  same_screen As Boolean
End Struct

Private Enum KeyPress = 2, KeyRelease, ButtonPress, ButtonRelease, MotionNotify, EnterNotify, LeaveNotify,
                           FocusIn, FocusOut, KeymapNotify, Expose, GraphicsExpose, NoExpose
Private Const ExposureMask As Integer = 32768
Private Const KeyPressMask As Byte = 1
Private Const ButtonPressMask As Byte = 4



Extern XOpenDisplay(DpyName As String) As Pointer In "libX11"
Extern XDefaultScreen(Display As Pointer) As Integer In "libX11"
Extern XDefaultRootWindow(Display As Pointer) As Integer In "libX11"
Extern XSelectInput(Display As Pointer, Window As Integer, KeyMask As Long) In "libX11"
Private Extern XNextEvent(displayP As Pointer, event_return As XEventStruct) In "libX11"
Extern XGrabKey(Display As Pointer, KeyCode As Integer, Modifiers As Integer, Window As Pointer, OwnEvent As Boolean, PointerMode As Integer, KeyboardMode As Integer) In "libX11"
Extern XGrabKeyboard(Display As Pointer, KeyCode As Integer, Modifiers As Integer, Window As Pointer, OwnEvent As Boolean, PointerMode As Integer, KeyboardMode As Integer) In "libX11"
Extern XKeysymToKeycode(Display As Pointer, keysym As Integer) As Integer In "libX11"


Public Sub form_open()
    Dim pDisplay As Pointer
    Dim pRootWindow As Pointer
    Dim pEvent As New XEventStruct
    Dim keycode As Integer
    pDisplay = XOpenDisplay(":0.0")
    pRootWindow = XDefaultRootWindow(pDisplay)
    keycode = XKeysymToKeycode(pDisplay, Asc("y"))
    XGrabKey(pDisplay, keycode, 1, pRootWindow, False, 1, 1) '95 = F11 key, 1 = GrabModeAsync
    XSelectInput(pDisplay, pRootWindow, KeyPressMask)

    Do
        XNextEvent(pDisplay, pEvent)
        Debug pEvent.type
    Loop
End

Mi stampa qualcosa su un display "nested" vuoto come Xephir (sostituendo pDisplay = XOpenDisplay(":1.0"))
E stampa appena premo *qualsiasi* tasto, non solo quello che in teoria avrei registrato ("y").

D'altro canto questo esempio in c:
https://stackoverflow.com/questions/4037230/global-hotkey-with-x11-xlib
Codice: [Seleziona]
#include <iostream>
#include <X11/Xlib.h>
#include <X11/Xutil.h>


using namespace std;


int main()
{
    Display*    dpy     = XOpenDisplay(0);
    Window      root    = DefaultRootWindow(dpy);
    XEvent      ev;

    unsigned int    modifiers       = ControlMask | ShiftMask;
    int             keycode         = XKeysymToKeycode(dpy,XK_Y);
    Window          grab_window     =  root;
    Bool            owner_events    = False;
    int             pointer_mode    = GrabModeAsync;
    int             keyboard_mode   = GrabModeAsync;

    XGrabKey(dpy, keycode, modifiers, grab_window, owner_events, pointer_mode,
             keyboard_mode);

    XSelectInput(dpy, root, KeyPressMask );
    while(true)
    {
        bool shouldQuit = false;
        XNextEvent(dpy, &ev);
        switch(ev.type)
        {
            case KeyPress:
                cout << "Hot key pressed!" << endl;
                XUngrabKey(dpy,keycode,modifiers,grab_window);
                shouldQuit = true;

            default:
                break;
        }

        if(shouldQuit)
            break;
    }

    XCloseDisplay(dpy);
    return 0;
}

...funziona su qualsiasi display, anche quello su cui c'è kwin e kde (avendo cura di battere ctrl-shift-y con il numlock spento); ed io non riesco a capire quale sia la differenza!
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: vuott - 14 Aprile 2016, 18:41:56
A me pare non funzioni né l'esempio in Gambas né quello in C++.   ... :-\
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: Gianluigi - 14 Aprile 2016, 20:52:58
Riguardo agli warnings ho posto il problema (http://gambas.8142.n7.nabble.com/TrayIcon-question-tp55955.html) sulla ML e Minisini ammette che c'è qualcosa che non va, però con le GTK l'esempio postato pare funzionare.  :-\
 :ciao:
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 18 Aprile 2016, 17:57:08
Grazie, lo terrò presente.
Vuott, è strano, con il codice in c a me funge.
occhio al numlock, dev'essere spento perchè anche quello è un modificatore, poi ctrl-shift-y ed il programma stampa ed esce.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: vuott - 19 Aprile 2016, 01:57:57
occhio al numlock, dev'essere spento perchè anche quello è un modificatore
Sì, giusto. Bravo.
Bene, ora il codice in C++ funziona.


Intanto ho rivisto anche il codice in Gambas: ho semplicemente tradotto quel codice funzionante dal C++ in Gambas; e funziona anche questo:
Codice: [Seleziona]
Library "libX11:6.3.0"

Private Enum KeyPress = 2, KeyRelease, ButtonPress, ButtonRelease, MotionNotify, EnterNotify, LeaveNotify,
                           FocusIn, FocusOut, KeymapNotify, Expose, GraphicsExpose, NoExpose
Private Const GrabModeAsync As Integer = 1
Private KeyPressMask As Integer = 1 * CInt(2 ^ 0) '   1L<<0 '
Private ControlMask As Integer = 1 * CInt(2 ^ 2)  '   1<<2  '
Private ShiftMask As Integer = 1 * CInt(2 ^ 0)    '   1<<0  '

' Display *XOpenDisplay(char *display_name)'
' Opens a connection to the X server that controls a display.'
Private Extern XOpenDisplay(display_name As Pointer) As Pointer

' Window XDefaultRootWindow(Display *display)'
' Returns the root window for the default screen.'
Private Extern XDefaultRootWindow(display As Pointer) As Integer

' KeyCode XKeysymToKeycode(Display *display, KeySym keysym)'
' Obtains a KeyCode for a key having a specific KeySym.'
Private Extern XKeysymToKeycode(display As Pointer, keysym As Integer) As Integer

' XGrabKey(Display *display, int keycode, unsigned int modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode)'
' Passively grabs a single key of the keyboard.'
Private Extern XGrabKey(display As Pointer, keycode As Integer, modifiers As Integer, grab_window As Integer, owner_events As Boolean, pointermode As Integer, keyboard_mode As Integer)

' XSelectInput(Display *display, Window w, long event_mask)'
' Requests that the X server report the events associated with the specified event mask.'
Private Extern XSelectInput(display As Pointer, w As Integer, event_mask As Long)

' XNextEvent(Display *display, XEvent *event_return)'
' Gets the next event and remove it from the queue.'
Private Extern XNextEvent(display As Pointer, event_return As Pointer)

' XUngrabKey(Display *display, int keycode, unsigned int modifiers, Window grab_window)'
' Ungrabs a key.'
Private Extern XUngrabKey(display As Pointer, keycode As Integer, modifiers As Integer, Window As Pointer)

' XCloseDisplay(Display *display)'
' Closes a display or disconnects from the X server.'
Private Extern XCloseDisplay(display As Pointer)


Public Sub Main()

  Dim dpy As Pointer
  Dim root As Integer
  Dim ev As Pointer
  Dim keycode As Integer

    ev = Alloc(192)

    dpy = XOpenDisplay(0)
   
    root = XDefaultRootWindow(dpy)

    keycode = XKeysymToKeycode(dpy, Asc("y"))

    XGrabKey(dpy, keycode, ControlMask Or ShiftMask, root, False, GrabModeAsync, GrabModeAsync)
   
    XSelectInput(dpy, root, KeyPressMask)

    While True
      XNextEvent(dpy, ev)
      Select Case Int@(ev)
        Case KeyPress
          Print "Hot key pressed !"
          XUngrabKey(dpy, keycode, ControlMask Or ShiftMask, root)
          Break
      End Select
    Wend

    Free(ev)
    XCloseDisplay(dpy)

End
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 19 Aprile 2016, 08:27:37
Grazie vuott, il tuo codice sembra funzionare senza problemi.
Ora la missione è capire perchè il mio non andava :)
-EDIT-
Ok, era qualcosa riguardante la maschera in XgrabKey() mettendo la tua maschera, funge senza problemi.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: vuott - 19 Aprile 2016, 08:50:09
Io proprio non riesco a capire  :-\ come quel codice Gambas iniziale potesse funzionare: c'erano - fra l'altro - pure valori discordanti dall'esempio in C++ .
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 19 Aprile 2016, 08:53:41
Se non ci riesci tu, io non ho speranze, quando uso le extern il 99% delle volte ottengo dei crash :)
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 19 Aprile 2016, 11:37:33
Vabeh, fermo restando il fascino della programmazione Xlib, mi sono scontrato con l'ulteriore problema di dover memorizzare una hotkey secondo la preferenza dell'utente, e da qui ho deciso di abbandonare la vecchia strata (grazie comunque Vuott).
Ne è uscita l'integrazione con xbindkeys che posto qui sotto:

Classe xbindkeys:
Codice: [Seleziona]
' Gambas class file

Private xbindkeysp As Process
Private conf_file As String
Private hotkeys As Collection


Public Sub _new(conf As String)
  If Not System.Exist("xbindkeys") Then
    Debug "ERROR: xbindkeys not found in system path"
    Quit
  Endif
  conf_file = conf
  hotkeys = parse_conf()
  If hotkeys = Null Then hotkeys = New Collection
  Reload_xbindkeys()
End

Private Function parse_conf() As Collection
  Dim pHotKeys As New Collection
  Dim aLine As String
  Dim WhatToDo As String 'find_new,find_action,find_hotkey
  Dim action, hotkey As String
  'Syntax:
  '#new
  'Action
  'hotkey
  If Not Exist(conf_file, True) Then Return Null
  WhatToDo = "find_new"
  For Each aLine In Split(File.Load(conf_file), "\n", "", True)
    Select WhatToDo
      Case "find_new"
        If aLine = "#new" Then WhatToDo = "find_action"
      Case "find_action"
        action = aLine
        WhatToDo = "find_hotkey"
      Case "find_hotkey"
        hotkey = aLine
        pHotkeys[hotkey] = action
        WhatToDo = "find_new"
    End Select
  Next
  Return pHotKeys
End

Private Sub write_conf()
  Dim outfile As String
  Dim action As String
  Dim HotKey As String
  For Each Action In hotkeys
    hotkey = hotkeys.key
    outfile &= "#new" & "\n"
    outfile &= Action & "\n"
    outfile &= Hotkey & "\n"
  Next
  File.Save(conf_file, outfile)
End

Public Sub register(action As String) As String
  Dim tmp As String = Temp()
  Dim out As String
  Dim splitted As String[]
  Dim hotkey As String
  Shell "touch " & tmp Wait
  xbindkeysp.kill
  Shell System.Find("xbindkeys") & " -k -f " & tmp To out
  splitted = Split(out, "\n", "", True)
  hotkey = Trim(splitted[splitted.count - 1])
  hotkeys[hotkey] = "\"" & "echo " & action & "\""
  write_conf()
  Reload_xbindkeys()
  Return hotkey
End

Public Sub close()
  Try xbindkeysp.kill
End

Public Sub Reload_xbindkeys()
  Try xbindkeysp.kill
  xbindkeysp = Shell "xbindkeys -n -f " & conf_file For Read As "xbindkeysp"
End

Event HotkeyPressed(action As String)

Public Sub xbindkeysp_read()
  Dim out As String
  Line Input #xbindkeysp, out
  Raise Hotkeypressed(out)
End

Utilizzatore della classe (esempio)
Codice: [Seleziona]
Public xb As XbindKeys

Public Sub Form_Open()
  xb = New XbindKeys("/tmp/y") As "xb"
End

Public Sub Button1_Click()
  xb.register("Prova_action")
End

Public Sub Form_Close()
  xb.close
End

Public Sub xb_HotkeyPressed(action As String)
  Debug action
End

In sostanza si instanzia un processo xbindkeys, si possono definire nuove hotkey associate a semplici stringhe che ritorneranno al programma principale tramite l'evento _HotkeyPressed.
Manca il codice per rimuovere una hotkey o una azione.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: vuott - 21 Aprile 2016, 02:43:15
Ora la missione è capire perchè il mio non andava
-EDIT-
Ok, era qualcosa riguardante la maschera in XgrabKey() mettendo la tua maschera, funge senza problemi.

...relativamente a quella funzione esterna:
* il 3° argomento è = 5 e non 1;
* il 4° argomento è un Intero e non un Puntatore.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 29 Aprile 2016, 13:56:31
Dopo un lungo ed estenuante lavoro...
No, in realtà è stato divertente, credo di aver concluso, a meno di bug dell'ultim'ora.

Comunque, ho fatto molta attenzione a rendere il programma modulare; in altre parole dovrebbe essere semplice aggiungere plugin per estendere i risultati di higgins.
Nel caso qualcuno fosse interessato a scrivenre di nuovi, ecco come fare:

Prima di tutto bisogna scrivere una classe che si chiami:
plugins/plugin_NomeAPiacere.gambas
inoltre il "NomeAPiacere" non deve finire con "_gui" perchè plugins/plugin_NomeAPiacere_gui.gambas è una stringa riservata a eventuali form di configurazione dello stesso plugin.
I plugin sono lanciati in ordine alfabetico, per questo quelli esistenti li ho chiamati (es:) plugin_090_indexer
Eventuali configurazioni interne al plugin potranno essere salvate tramite la classe Settings.
Ma ogni plugin può fare un pò come vuole riguardo il salvataggio delle sue impostazioni.

Questa classe deve rispecchiare bene o male la classe "plugin_template" che ho scritto come una linea guida, eccola:
Codice: [Seleziona]
' Gambas class file

Create Static
Static Public Description As String = "Example plugin"    'A description for this plugin
Static Public Friendly_name As String = "Example plugin"  'A friendly name for this plugin
Static Public configurable As Boolean = False             'Does this plugin provides a configure() method?

Public Sub _free()

End


Public Struct rItemT
  plugin As String            'The plugin name
  Text As String              'Text displayed in the clipboard
  SubText As String           'Text displayed under the main text
  Image_file As String        'Optional image displayed: possible values:
                              '  "mimetype://fullpath/to/filename/to/identify"
                              '     get picture from mime icon
                              '   "desktopfile://fullpath/to/.desktop/file"
                              '     Get the picture from .desktop file
                              '   "resize://fullpath/to/image/file"
                              '     Load the image from disk and resize it automatically
                              '   "/fullpath/to/image/file"
                              '     Load the image from disk
 
  Clipboard_data As String    'The data copied to the clipboard
  Action As String            'String that indicates what to do when activating a result:
                              '"DESKTOPOPEN"
                              '       Open folders and starts .desktop files
                              '"EXEC"
                              '       Executes executables files
                              '"GUESS"
                              '       Choose an action based on filetype
                              '"NULL"
                              '       Does nothing

  Action_p As Variant         'the parameter for Action
 
End Struct


Private textcontrol As Object
Private plugin As String
Private iconsize As Integer
Private minchar As Integer = 3 'The plugin will not operate on searches smaller than that


Public Sub _new(p_plugin As String, p_iconsize As Integer)

  plugin = p_plugin
  iconsize = p_iconsize

End


Public Sub Stop()
 
  'not sure if this is the right way, but this should be called when the plugin has to be unloaded
 
End


Private Sub trigged(query As String) As Boolean
  'this function will decide if the plugin will be search for "query" or not.
  If Len(query) < minchar Then Return False
  'some more controls here (?)
  Return True
End


Public Sub find(textcontrol As Object) As RItemT[]
  'this is the main function, textcontrol is an object that exposes a "text" property.
  'We need to pass an entire object reference instead of a simple string so that
  'we can stop a (slow) plugin as soon as textcontrol.text changes (ie: the user is still typing...)

  Dim anItem As String
  Dim rResults As New RItemT[]
  Dim rResult As RItemT
  Dim current_search As String = textcontrol.text
 
  If Not trigged(textcontrol.text) Then Return
 
  For Each anItem In Dir(User.home).sort()
   
    rResult = create_item(anItem)
    If rResult <> Null Then rResults.Add(rResult)
    'Wait 'if calculations are heavy a wait may be handy.
    If textcontrol.text <> current_search Then Return


  Next 'anItem
  Return rResults

End


Private Function create_item(result As String) As RItemT
  'this function creates an item that will be pushed into the result list.
  Dim return_item As RItemT
  return_item = New RItemT
  return_item.plugin = plugin
  return_item.Action = "EXEC" ' DESKTOPOPEN,EXEC,GUESS,NULL... MORE?
  return_item.Action_p = "/usr/bin/gambas3"
  return_item.Clipboard_data = "Some data copied to the clipboard"
  return_item.image_file = "icon:/" & iconsize & "/bookmark"
  return_item.Text = result
  return_item.SubText = "In: " & User.home
  Return return_item
End

Public Sub configure()
 
  'this starts the configuration window.
  'eg: plugin_template_gui.show()
End

EDIT:
Prossimo passo, permettere di usare plugin scritti in qualsiasi "linguaggio"; l'idea è di lanciarli come come "process" tramite "SHELL" e di comunicare con loro tramite semplici stream.
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: Gianluigi - 01 Maggio 2016, 13:31:41
Forse lo hai fatto e io non l'ho visto o capito altrimenti andrebbe spiegato che per far funzionare, almeno in parte, higgins-master occorre che nel sistema sia presente la libreria xbindkeys altrimenti ottieni errore e non funziona.
In realtà anche dopo aver installato così xbindkeys:
Codice: [Seleziona]
~$ xbindkeys
Il programma "xbindkeys" non è attualmente installato. È possibile installarlo digitando:
sudo apt-get install xbindkeys
$ sudo apt-get install xbindkeys
ottengo questo avviso in console:
Codice: [Seleziona]
/home/gian/.config/gambas3/higgins/xbindkeys_higgins: File o directory non esistente
FMain.load_plugin.109: PLUGIN_010_CALCULATOR
FMain.load_plugin.109: PLUGIN_020_APPS
FMain.load_plugin.109: PLUGIN_030_EXECUTABLE
FMain.load_plugin.109: PLUGIN_040_FBOOKMARKS
FMain.load_plugin.109: PLUGIN_050_LS
FMain.load_plugin.109: PLUGIN_090_INDEXER
FMain.load_plugin.109: PLUGIN_TEMPLATE
PLUGIN_090_INDEXER.reindex_timer_Timer.171: -61184844 minutes to go
PLUGIN_090_INDEXER.ReIndex.200: Indexing...
PLUGIN_090_INDEXER.ReIndex.201: sh -c ""
PLUGIN_090_INDEXER.reindex_timer_Timer.171: -61184844 minutes to go
PLUGIN_090_INDEXER.ReIndex.200: Indexing...
PLUGIN_090_INDEXER.ReIndex.201: sh -c ""
PLUGIN_090_INDEXER.indexprocess_kill.213: Finished indexing
PLUGIN_090_INDEXER.indexprocess_kill.213: Finished indexing
PLUGIN_090_INDEXER.reindex_timer_Timer.171: 30 minutes to go

Il lanciatore funziona ma non le shortcut (credo) e l'applicazione non si chiude realmente e se de-commenti il quit da i soliti warning.
Da notare che in realtà higgins/xbindkeys_higgins esiste come puoi vedere dall'immagine allegata.
 :ciao:
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 02 Maggio 2016, 09:48:27
xbindkeys non è, purtroppo, una libreria, ma proprio un programma, ed hai ragione che dovrei segnalarne l'eventuale assenza tramite un messaggio a video.
L'errore che dà in console lo scrive higgins "da design":
Codice: [Seleziona]
Public Sub _new(conf As String, Optional alias As String = "")
  If Not System.Exist("xbindkeys") Then
    Debug "ERROR: xbindkeys not found in system path"
    Quit
  Endif

Ad ogni modo, higgins usa xbindkeys solo per registrare una hotkey (shortcut) che visualizzi/nasconda la sua interfaccia.

Credo di aver capito cosa è successo nel tuo caso.
Al primo avvio, higgins cerca la sua directory di configurazione; se non la trova, assume che quella sia la prima volta che l'utente lo lancia; crea la cartella, e quindi avverte l'utente che va configurata almeno l'hotkey.
Poi vuole far partire xbindkeys per regitrare la hotkey, ma non lo trova ed esce.
L'utente installa xbindkeys e rilancia higgins, che però a quel punto trova la sua cartella (l'aveva creata prima di uscire) e quindi non chiede più di registrare la hotkey.
Quetso lo metto a posto in giornata, ma intanto, avendo installato xbindkeys, puoi impostate la hotkey cliccando col tasto dx sulla tray icon e scegliendo "Options" dal menu, oppure clicchi col tasto sx sulla tray icon e poi clicchi sul pulsante alla destra della barra di ricerca.
nella finestra che si apre, clicca "change default hotkey"; a quel punto i apre xbindkeys che ti chiede di battere una combinazione di tasti; io uso alt-space.
Fatto ciò, alt-space mostrerà e nasconderà il form di higgins.


Riguardo la chiusura, higgins è pensato per rimanere sempre attivo; per chiuderlo si usa la tray icon (tasto dx->quit) oppure tasto dx sul bottone di configurazione -> quit.

Dà un warning di riferimento circolare all'uscita (è solo un warning, non necessariamente un male), ma le risorse vengono liberate tutte correttamente, per cui non c'è bisogno di "Quit".

Scusa la prolissità :D[/code]
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: Gianluigi - 02 Maggio 2016, 11:40:37
Purtroppo in questo momento a causa di aggiornamento OS non ho tempo per farti da cavia.
Due cose però te le posso dire:
Ora all'apertura si comporta come dici tu ma la finestra che si apre e che ti dovrebbe dire cosa fare (digitare la combinazione di tasti) è piccola vicino alla trayicon e completamente bianca.
In save_geometry c'è ancora uno stop.
 :ciao:
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 02 Maggio 2016, 11:45:17
purtroppo quella è la finestra di xbindkeys, non ho controllo su di essa.
Al massimo posso ridimensionarla o posizionarla dove voglio...
Titolo: Re:Higgins: un lanciatore per gambas
Inserito da: koko - 13 Maggio 2016, 13:45:08
Sono riuscito finalmente ad implementare i plugin esterni.
Adesso higgins riconoscerà eventuali eseguibili presenti in: ~/.config/gambas3/higgins/extbin
Il bello è che l' "API" con cui il plugin esterno dialoga con higgins si basa su semplici messaggi di testo.
Questo vuol dire che i plugin esterni possono essere scritti in qualsiasi linguaggio.
Un plugin di esempio che ho scritto è il seguente, in bash:
Codice: [Seleziona]
#!/bin/bash
#Simple locate plugin example.
#Put me in ~/.config/gambas3/higgins/extbin to use me

#This plugin will search for files using locate command, which has to be installed.
#This plugin will run only when the trigger is used, so:
#   to search for "myfile.txt"
#   write: l:myfile.txt
#   (trigger is "l:")

#This plugin will not search anything lower than 3 characters (minchar=3)


export IFS=$'\n'
trigger="l:" #Search using the trigger? es: l:myfile
minchar=3    #Don't search on queries smaller than that, trigger does not count.

query="$@"

#Do we use a trigger?
if [ -n "$trigger" ] ; then
    #...Yes, we do, so exit if not triggered
    if [[ $query != $trigger* ]] ; then
        exit
    fi
    #Strip the trigger prefix from the query
    query=$(echo $query| sed "s/^$trigger//")
fi

len=${#query}

#Exit if the query is too small
if [ $len -lt $minchar ] ; then
    exit ;
fi


#Finally, start the search:
for file in $(locate -i "$query") ; do
    echo BEGIN
    # For fields description and possible values, please refer to plugins/plugin_999_template
      echo Text=$(basename $file)
      echo SubText="in " $(dirname $file)"/"
      echo Image_file="mimetype://$file"
      echo Clipboard_data="$file"
      echo Action="GUESS"
      echo Action_p="$file"
    echo END
done

Questo script si può lanciare anche da linea di comando (che poi è quello che higgins fa), così:
Codice: [Seleziona]
# ~/.config/gambas3/higgins/extbin/locate.sh l:ciao 
e l'uscita dello script sarà qualcosa del genere:
Codice: [Seleziona]
BEGIN
Text=ciao.srt
SubText=in  /home/
Image_file=mimetype:///home/ciao.srt
Clipboard_data=/home/ciao.srt
Action=GUESS
Action_p=/home/ciao.srt
END
BEGIN
Text=ciao.ORIGINAL.srt
SubText=in  /home/p2p/.aegisub/autoback/
Image_file=mimetype:///home/p2p/.aegisub/autoback/ciao.ORIGINAL.srt
Clipboard_data=/home/p2p/.aegisub/autoback/ciao.ORIGINAL.srt
Action=GUESS
Action_p=/home/p2p/.aegisub/autoback/ciao.ORIGINAL.srt
END
Higgins parserà l'output del programma e prenderà tutte le informazioni che gli servono per compilare la lista dei risultati.

Più semplice di così!

Altra cosa che ho aggiunto è che ogni plugin può essere abilitato/disabilitato e gli stessi possono essere ordinati in modo da avere prima i risultati che ci interessano maggiormente.
Nella lista dei plugin vengono ovviamente visualizzati anche i plugin esterni.