gtk+pb+unicode problem
Posted: Tue Feb 26, 2013 7:10 pm
Hello everybody,
I am not sure if the following code is right, but it works well as long as it is compiled without unicode enabled. Even then I get this warning:
[18:48:58] [WARNING] GLib-GObject (WARNING): g_object_set_valist: object class `GtkTextTag' has no property named `0í'
Now same code still no unicode, but with internal purifier enabled, I get
[18:59:40] [ERROR] myTest.pb (Line: 56)
[18:59:40] [ERROR] Invalid memory access.
Finally with unicode enabled all colours are gone. The buttons turn black on activation.
I hope somebody can show me how this code has to be modified to work with unicode enabled and how to get rid of the annoying warning from the debugger.
openSuse 12.2, PureBasic 5.10 x64
Thanks in advance
gerd
I am not sure if the following code is right, but it works well as long as it is compiled without unicode enabled. Even then I get this warning:
[18:48:58] [WARNING] GLib-GObject (WARNING): g_object_set_valist: object class `GtkTextTag' has no property named `0í'
Now same code still no unicode, but with internal purifier enabled, I get
[18:59:40] [ERROR] myTest.pb (Line: 56)
[18:59:40] [ERROR] Invalid memory access.
Finally with unicode enabled all colours are gone. The buttons turn black on activation.
Code: Select all
; GUI DESIGNER V 0.9 Beta
Enumeration ; Windows
#Form_100
EndEnumeration ; Windows
Enumeration ; Gadget
#Button_0
#Button_1
#Editor_0
EndEnumeration ; Gadget
; Your code here
Procedure Open_Form_100()
OpenWindow(#Form_100, 380, 100, 600, 440, "Form_100", $2)
; Gadgetliste
EditorGadget(#Editor_0, 10, 10, 360, 390)
ButtonGadget(#Button_0, 385, 10, 200, 40, "Button blue")
ButtonGadget(#Button_1, 385, 65, 200, 40, "Button black")
SetGadgetAttribute(#Editor_0, #PB_Editor_WordWrap, 1)
EndProcedure
; Your code here
Procedure.l GetCursorPos(Id.l)
Protected mypointertoiteration.GtkTextIter, *buffer, cursor.l
*buffer = gtk_text_view_get_buffer_(GadgetID(#Editor_0))
cursor = gtk_text_buffer_get_insert_(*buffer)
gtk_text_buffer_get_iter_at_mark_(*buffer, @mypointertoiteration, cursor)
ProcedureReturn gtk_text_iter_get_offset_(@mypointertoiteration)
EndProcedure
Open_Form_100()
gtk_init_(0,0)
gdk_init_(0,0)
GtkTextBuffer *buffer
color.GdkColor
start.GtkTextIter
ende.GtkTextIter
gdk_color_parse_("lightblue", @color)
gtk_widget_modify_bg_(GadgetID(#Button_0), #GTK_STATE_PRELIGHT, @color)
gtk_widget_modify_bg_(GadgetID(#Button_0), #GTK_STATE_ACTIVE, @color)
gdk_color_parse_("lightgreen", @color)
gtk_widget_modify_bg_(GadgetID(#Button_1), #GTK_STATE_PRELIGHT, @color)
gtk_widget_modify_bg_(GadgetID(#Button_1), #GTK_STATE_ACTIVE, @color)
buffer = gtk_text_view_get_buffer_(GadgetID(#Editor_0))
tag = gtk_text_buffer_create_tag_(buffer, "mytag", "foreground", "blue")
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
; Event Schleife
Repeat
Event = WaitWindowEvent()
Select Event
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Case #PB_Event_Gadget
EventGadget = EventGadget()
; Gadget
If EventGadget = #Editor_0
ElseIf EventGadget = #Button_0
SetActiveGadget(#Editor_0)
einfuegepos = GetCursorPos(GadgetID(#Editor_0))
text$ = GetGadgetText(#Editor_0)
SetGadgetText(#Editor_0, InsertString(text$, "<This should be blue>", einfuegepos + 1))
gtk_text_buffer_get_iter_at_offset_(buffer, @start, einfuegepos)
einfuegepos = GetCursorPos(GadgetID(#Editor_0))
gtk_text_buffer_get_iter_at_offset_(buffer, @ende, einfuegepos)
gtk_text_buffer_apply_tag_by_name_(buffer, "mytag", @start, @ende)
If CountGadgetItems(#Editor_0) > 0
GetGadgetText(#Editor_0)
b = 1
While b
b = FindString(GetGadgetText(#Editor_0),"<",b)
If b
b + 1
c = FindString(GetGadgetText(#Editor_0),">",b)
If c
gtk_text_buffer_get_iter_at_offset_(buffer, @start, b - 2)
gtk_text_buffer_get_iter_at_offset_(buffer, @ende, c)
gtk_text_buffer_apply_tag_by_name_(buffer, "mytag", @start, @ende)
EndIf
EndIf
Wend
EndIf
ElseIf EventGadget = #Button_1
SetActiveGadget(#Editor_0)
einfuegepos = GetCursorPos(GadgetID(#Editor_0))
text$ = GetGadgetText(#Editor_0)
SetGadgetText(#Editor_0, InsertString(text$, "This should be black", einfuegepos + 1))
If CountGadgetItems(#Editor_0) > 0
GetGadgetText(#Editor_0)
b = 1
While b
b = FindString(GetGadgetText(#Editor_0),"<",b)
If b
b + 1
c = FindString(GetGadgetText(#Editor_0),">",b)
If c
gtk_text_buffer_get_iter_at_offset_(buffer, @start, b - 2)
gtk_text_buffer_get_iter_at_offset_(buffer, @ende, c)
gtk_text_buffer_apply_tag_by_name_(buffer, "mytag", @start, @ende)
EndIf
EndIf
Wend
EndIf
EndIf
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
; Window
If EventWindow = #Form_100
CloseWindow(#Form_100)
Break
EndIf
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EndSelect
ForEver
EndopenSuse 12.2, PureBasic 5.10 x64
Thanks in advance
gerd