[gtk-server] Re: Accelerator keys - Warning, newbie questions

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Sat, 02 Sep 2006 22:08:26 +0200

Hi Derek,

> Why was cut defined as ctrl+u and paste defined as ctrl+p?

For no reason, I just took some random shortcuts. You can use anything you like.

Your issues seem to come down to a misconception of the possibilities of Glade.
When I run your Glade file in my BASIC program, I receive the following errors:

(<unknown>:7124): Gtk-WARNING **: gtkwidget.c:3260: widget `GtkTextView' has no
activatable signal "select_all" without arguments

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_save1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_delete1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_quit1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_cut1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_about1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_open1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_paste1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_new1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_save_as1_activate'.

(<unknown>:7124): libglade-WARNING **: could not find signal handler
'on_copy1_activate'.


As you can see, your activate signals did not define a handler, e.g. a
subroutine, handling the signal. If I look into your GLADE file, you indeed have
 broken definitions:

 <signal name="activate" handler="on_cut1_activate" last_modification_time="Sat,
02 Sep 2006 14:11:33 GMT"/>

Now Glade cannot do anything with this, for Glade expects a memory address, to
which it can jump to execute some code when the 'activate' signal occurs. But a
memory address only is available when you have a compiled program, *or* when you
use one of the predefined GTK-functions in the libraries.

With interpreted programs, like Yabasic programs, you never can point to your
own subroutines, as they are... well, interpreted. The BASIC subroutines do not
have a memory address, as the interpreter just jumps there when it encounters
the name of a subroutine.

In short, the thing you can do is pointing to some of the predefined GTK
functions, like 'gtk_widget_show', 'gtk_widget_hide', 'gtk_exit' and so on, for
these have actual memory addresses.

So what else can you do?

You must implement the cut, copy and paste actions yourself, in your client
program. This may sound a lot of work, but I did it myself once in the IDE for
the programming language newLisp. You can find it here:

http://www.turtle.dds.nl/newlisp/ide.lsp

For example, the cut:

# Cut
(define (cut, board)
        (GTK "gtk_text_buffer_get_selection_bounds" TextBuffer mystartiter 
myenditer)
        (set 'board (GTK "gtk_clipboard_get 0"))
        (GTK "gtk_text_buffer_cut_clipboard" TextBuffer board 1)
        (GTK "gtk_text_buffer_get_end_iter" TextBuffer myenditer)
        (GTK "gtk_text_buffer_place_cursor" TextBuffer myenditer)
        (GTK "gtk_text_view_scroll_to_mark " TextConsole TextMark 0 1 0.0 1.0)
)

I hope the code is readable. The functions are called (define (cut, board)), and
(define (copy, board)) etc. As you see they are very small. The idea is, that
when a click signal occurs on one of your buttons, you only have to run your own
subroutine containing these GTK-commands. Remember, in the beginning of your
program you have to connect the 'clicked' signal to the buttons first. Please
look into the same program on how I did it.

Best regards
Peter


Citeren Derek Griffin <d_griffin@xxxxxxxxxxxxxxxx>:

> Hi Peter,
>
> thank you for your reply.
>
> The example you sent works perfectly :) Ctrl+x and Ctrl+u cuts the text,
> Ctrl+p and Ctrl+v pastes the text and ctrl+c and ctrl+a work just as they
> should.
>
> Why was cut defined as ctrl+u and paste defined as ctrl+p?
>
> When I re-create your example from within Glade I can get similar results but
> when I add a few more features things start to go awry. Cutting and pasting
> only works on with ctrl+u and ctrl+p and copy fails completely. Select all
> works fine.
>
> I have included my Glade file for you to take a look at.
>
> I'm sorry for all these questions and thank you for taking the time to answer
> me,
>
> regards,
>
> Derek.

-- 
http://www.gtk-server.org

Other related posts: