Re: Getting text out of a GtkTextView

2003-06-22 Thread Carl B. Constantine
* Carl B. Constantine ([EMAIL PROTECTED]) wrote:
> > The following link tells you how to get the contents of the
> > entire text widget as a string:
> > http://developer.gnome.org/doc/API/2.0/gtk/gtk-question-index.html#id2850623
> 
> No it's not. that url doesn't resolve (at least as far as the #id tag
> goes).  Additionally, your suggestion doesn't work either...

Actually, I *did* find it on that page, way down but clicking the link
didn't put me in the correct spot.

> > buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
> > gtk_text_buffer_get_bounds (buffer, &start, &end);
> > text = gtk_text_iter_get_text (&start, &end);
> > ...use text...
> > g_free (text);
> 
> In both of these instances I get the following error:

Never mind, I found my problem. I had declared start and end as
*GtkTextIter instead of just GtkTextIter. That pointer makes all the
difference in the world ;-)

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom


pgp0.pgp
Description: PGP signature


Re: Getting text out of a GtkTextView

2003-06-22 Thread Carl B. Constantine
* Seth Remington ([EMAIL PROTECTED]) wrote:
> You've created two pointers to a GtkTextIter, but they don't point to a 
> valid GtkTextIter structure in memory. Here's what you probably meant to 
> do...
> 
> void insertCustomer( GtkWidget*customers )
> {
>   GtkTextBuffer   *specialBuffer;
>   GtkTextView *specialView;
>   GtkTextIter start;
>   GtkTextIter end;
>   gchar*  *specialText;
> 
>specialView = lookup_widget(customers, "cust_instructions");
>   specialBuffer = gtk_text_view_get_buffer(specialView);
>   gtk_text_buffer_get_bounds(specialBuffer, &start, &end);
>   specialText = gtk_text_buffer_get_text(specialBuffer, &start, &end, 
>   FALSE);
>   g_print("Special Text: %s \n",specialText);
> }

The gtk_text_buffer_get_text() routine does *not* work.

* Alejandro Garc?a Rodr?guez ([EMAIL PROTECTED]) wrote:
>   Hello, list!
> 
>   The following link tells you how to get the contents of the
> entire text widget as a string:
> http://developer.gnome.org/doc/API/2.0/gtk/gtk-question-index.html#id2850623

No it's not. that url doesn't resolve (at least as far as the #id tag
goes).  Additionally, your suggestion doesn't work either...

> buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
> gtk_text_buffer_get_bounds (buffer, &start, &end);
> text = gtk_text_iter_get_text (&start, &end);
> ...use text...
> g_free (text);

In both of these instances I get the following error:

 Gtk-WARNING **: Invalid text buffer iterator: either the iter
ator is uninitialized, or the characters/pixbufs/widgets in the buffer have been
 modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position ac
ross buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be
referred to by character offset)
will invalidate all outstanding iterators

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom


pgp0.pgp
Description: PGP signature


Re: Getting text out of a GtkTextView

2003-06-18 Thread Alejandro García Rodríguez
Hello, list!

The following link tells you how to get the contents of the
entire text widget as a string:
http://developer.gnome.org/doc/API/2.0/gtk/gtk-question-index.html#id2850623

GtkTextIter start, end;
GtkTextBuffer *buffer;
char *text;

buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_iter_get_text (&start, &end);
...use text...
g_free (text);

;) Just copy. It has to work, doesn't it?
 Today
   
   -- Alejandro García Rodríguez --
   --  Ingeniero... a falta de proyecto  --
   ----
   -- Laboratorio de Sistemas Integrados --
   --  e.mail.   [EMAIL PROTECTED]  --
   --  Tel. (+34) 91 549 57 00 ext. 402  --
   ----
   -- E.T.S. Ingenieros Telecomunicación --
   -- Dpto. Ingeniería Electrónica   --
   --   Ciudad Universitaria s/n --
   -- 28040 Madrid - Spain   --
   

On Wed, 18 Jun 2003, Carl B. Constantine wrote:

> I have a GtkTextView in one of my application windows; mainly because a
> GtkEntry is only single width and I want text wrapping and so forth.
>
> Anyway, I'm trying to get the text from the GtkTextView but only end up
> with 'null' when I try to print it. Here is a code snipped:
>
> void insertCustomer( GtkWidget*customers )
> {
>   GtkTextBuffer   *specialBuffer;
>   GtkTextView *specialView;
>   GtkTextIter *start;
>   GtkTextIter *end;
>   gchar*  *specialText;
>
> specialView = lookup_widget(customers, "cust_instructions");
>   specialBuffer = gtk_text_view_get_buffer(specialView);
>   gtk_text_buffer_get_bounds(specialBuffer, start, end);
>   specialText = gtk_text_buffer_get_text(specialBuffer, start, end, FALSE);
>   g_print("Special Text: %s \n",specialText);
> }
>
> I actually want to be able to insert that text into a database field but
> it's not working.
>
> Any help is appreciated.
>
> --
>  .''`.  Carl B. Constantine
> : :' : [EMAIL PROTECTED]
> `. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
>   `-  Debian GNU/Linux -- The power of freedom
>
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Getting text out of a GtkTextView

2003-06-18 Thread Seth Remington
You've created two pointers to a GtkTextIter, but they don't point to a 
valid GtkTextIter structure in memory. Here's what you probably meant to 
do...

void insertCustomer( GtkWidget  *customers )
{
GtkTextBuffer   *specialBuffer;
GtkTextView *specialView;
GtkTextIter start;
GtkTextIter end;
gchar*  *specialText;
   specialView = lookup_widget(customers, "cust_instructions");
specialBuffer = gtk_text_view_get_buffer(specialView);
gtk_text_buffer_get_bounds(specialBuffer, &start, &end);
specialText = gtk_text_buffer_get_text(specialBuffer, &start, &end, FALSE);
g_print("Special Text: %s \n",specialText);
}
- Seth

Carl B. Constantine wrote:

I have a GtkTextView in one of my application windows; mainly because a
GtkEntry is only single width and I want text wrapping and so forth.
Anyway, I'm trying to get the text from the GtkTextView but only end up
with 'null' when I try to print it. Here is a code snipped:
void insertCustomer( GtkWidget  *customers )
{
GtkTextBuffer   *specialBuffer;
GtkTextView *specialView;
GtkTextIter *start;
GtkTextIter *end;
gchar*  *specialText;
   specialView = lookup_widget(customers, "cust_instructions");
specialBuffer = gtk_text_view_get_buffer(specialView);
gtk_text_buffer_get_bounds(specialBuffer, start, end);
specialText = gtk_text_buffer_get_text(specialBuffer, start, end, FALSE);
g_print("Special Text: %s \n",specialText);
}
I actually want to be able to insert that text into a database field but
it's not working.
Any help is appreciated.

 

--
Seth Remington
SaberLogic, LLC
661-B Weber Drive
Wadsworth, Ohio 44281
Phone: (330)335-6442
Fax: (330)336-8559
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Getting text out of a GtkTextView

2003-06-18 Thread Carl B. Constantine
I have a GtkTextView in one of my application windows; mainly because a
GtkEntry is only single width and I want text wrapping and so forth.

Anyway, I'm trying to get the text from the GtkTextView but only end up
with 'null' when I try to print it. Here is a code snipped:

void insertCustomer( GtkWidget  *customers )
{
GtkTextBuffer   *specialBuffer;
GtkTextView *specialView;
GtkTextIter *start;
GtkTextIter *end;
gchar*  *specialText;

specialView = lookup_widget(customers, "cust_instructions");
specialBuffer = gtk_text_view_get_buffer(specialView);
gtk_text_buffer_get_bounds(specialBuffer, start, end);
specialText = gtk_text_buffer_get_text(specialBuffer, start, end, FALSE);
g_print("Special Text: %s \n",specialText);
}

I actually want to be able to insert that text into a database field but
it's not working.

Any help is appreciated.

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom


pgp0.pgp
Description: PGP signature