[Glade-users] Where is the input callback method in glade?



On Thu, Oct 6, 2011 at 3:28 AM, Rottengatter, Peter <
Peter.Rottengatter at bakerhughes.com> wrote:


The infinite loop is easily avoided by setting a flag while modifying the
text withing the handler, and testing the flag at the beginning of the
handler (not exactly a beautiful solution, but I'm sure it works). This way
your intented functionality can be implemented with GtkEntry.


FWIW, for this recursion check you can use
g_signal_handlers_block/unblock_by_func().

Cheers


I have no experience with GtkTextView though. It's not a GtkEditable, hence
the details of how to implement this will be different.

Regards

Peter Rottengatter

-----Original Message-----
From: Ferdinand Ramirez [mailto:ramirez.ferdinand at yahoo.com]
Sent: 06 October 2011 08:18
To: Rottengatter, Peter; glade-users at lists.ximian.com
Subject: RE: [Glade-users] Where is the input callback method in glade?

Thanks. I tried something similar with GtkTextBuffer and it worked, but I
cannot modify the text, only block it or let it through. If I modify it, and
insert the modified text into the buffer from within the callback, I end up
in an infinite loop.

Is there another way you know, using GtkTextView perhaps?

Thanks,
-Ferdinand

--- On Wed, 10/5/11, Rottengatter, Peter <
Peter.Rottengatter at bakerhughes.com> wrote:

From: Rottengatter, Peter <Peter.Rottengatter at bakerhughes.com>
Subject: RE: [Glade-users] Where is the input callback method in glade?
To: "Ferdinand Ramirez" <ramirez.ferdinand at yahoo.com>, "
glade-users at lists.ximian.com" <glade-users at lists.ximian.com>
Date: Wednesday, October 5, 2011, 12:46 AM

Read

http://developer.gnome.org/gtk/stable/GtkEditable.html#GtkEditable-insert-text


I use the following code to restrict input to numerical
characters (so that the user can only enter positive integer
numbers):

...
GtkEntry  *entry = gtk_entry_new();
gtk_signal_connect (G_OBJECT (entry), "insert-text",
G_CALLBACK (entry_insert), NULL);
...

void entry_insert (GtkEditable *entry, char *new, gint len,
gpointer position, gpointer data)
{
  gboolean  faulty = FALSE;
  for (int i = 0; i < len; i++)
  {
    if (! isdigit (new[i]))
      faulty = TRUE;
  }
  if (faulty)
  {
    g_signal_stop_emission_by_name ((gpointer)
entry, "insert-text");
  }
}


Regards

Peter Rottengatter

-----Original Message-----
From: glade-users-bounces at lists.ximian.com
[mailto:glade-users-bounces at lists.ximian.com]
On Behalf Of Ferdinand Ramirez
Sent: 04 October 2011 13:55
To: glade-users at lists.ximian.com
Subject: [Glade-users] Where is the input callback method
in glade?

Where is the callback to keyboard input in glade. I want
this so that I can respond to each letter that is input.

As as example, I was looking at the tutorial at
http://www.micahcarrick.com/files/gtk-glade-tutorial/C/main.c
and was wondering how the callback method for keyboard
inputs can be enabled and how I could modify it.

For simplicity, let us say that I want to be able to print
out the characters on the terminal as I input them in the
above program. I then want to update the buffer instead of
letting some hidden function in glade do it for me. How do I
achieve this?

I'm just using the above example since it is simple and
neatly written.

Thanks,
-Ferdinand
_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users
Baker Hughes INTEQ GmbH
Baker-Hughes-Strasse 1, D - 29221 Celle
Tel.: +49 5141 203 0, Fax: +49 5141 203 296
Sitz der Gesellschaft: Celle, Amtsgericht L?neburg HRB
100845
Gesch?ftsf?hrer: Johannes Witte, Tommie Lee Pate, Dr.
Hans-Werner Hesse

Diese Nachricht ist ausschlie?lich f?r die Person oder
Organisation bestimmt, an die sie adressiert ist. Sie kann
herstellerspezifische, nur f?r bestimmte Personen
bestimmte,  vertrauliche oder andere Informationen
enthalten, die kraft Gesetzes nicht offen gelegt werden
m?ssen.  Wenn Sie nicht der in der Adresse genannte
Empf?nger sind oder versehentlich in der Adresszeile
angesprochen werden, sind Sie nicht berechtigt, diese
Nachricht oder Teile davon zu lesen, zu drucken,
aufzubewahren, zu kopieren oder zu verbreiten.  Sollten
Sie diese Nachricht irrt?mlich erhalten haben,
benachrichtigen Sie bitte den Absender umgehend per Email
und vernichten Sie s?mtliche Kopien der Nachricht.

DISC-GER-A

_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20111008/11baccda/attachment.html 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]