GtkLabel Question
- From: Brian Cameron <Brian Cameron Sun COM>
- To: gtk-devel-list gnome org
- Subject: GtkLabel Question
- Date: Fri, 1 Jun 2001 17:08:45 +0100 (BST)
Gtk Experts:
I need to be able to access a substring of the text within a GtkLabel.
For example. Lets say the GtkLabel contains a string that is
20 characters long and I want to access the substring from offset
5-10.
What is the best way to do this? I notice that the GtkEntry logic in
gtk_entry_get_chars looks like this:
if (end_pos < 0)
end_pos = entry->text_length;
start_pos = MIN (entry->text_length, start_pos);
end_pos = MIN (entry->text_length, end_pos);
start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text;
end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text;
return g_strndup (entry->text + start_index, end_index - start_index);
However, GtkLabel also doesn't seem to keep track of its text length.
Should I just usse g_utf8_strlen() to get this?
Thanks!
Brian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]