Problem with Editorgadget and GTK+

Linux specific forum
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Problem with Editorgadget and GTK+

Post by gerd »

Hello everybody,

A few words about me: I am new to PureBasic and GTK and even to programming. So you may call me a newbie.

After searching documentation of PureBasic and GTK, through the forums without being able to solve my little problem, I decided to post it here. I hope this is the right spot and somebody will be nice enough to help me out. Said this, here it is:

Code: Select all

GtkTextBuffer *buffer
color.GdkColor
start.GtkTextIter 
ende.GtkTextIter

If OpenWindow(0, 100, 200, 600, 200, "Test", #PB_Window_ScreenCentered)  
     CreateStatusBar(0, WindowID(0))
     AddStatusBarField(#PB_Ignore)
     StatusBarText(0, 0, "Test", 0)
     EditorGadget(14, 10, 10, 580, 100)
     SetGadgetColor(14, #PB_Gadget_BackColor, RGB(255, 255, 210))
     AddGadgetItem(14, -1, "This is just an example and it works, as in my code it does as well.")
     AddGadgetItem(14, -1, "But when compiling, I get an annoying warning!")
     AddGadgetItem(14, -1, "Line 20, Glib-GObject: A_g_object_set_valist: object class 'GtkTextTag' has no property named ...")
EndIf

buffer = gtk_text_view_get_buffer_(GadgetID(14))
tag = gtk_text_buffer_create_tag_(buffer, "mytag", "background", "darkred")
gtk_text_buffer_get_iter_at_offset_(buffer, @start, 8)
gtk_text_buffer_get_iter_at_offset_(buffer, @ende, 12)
gtk_text_buffer_apply_tag_by_name_(buffer, "mytag", @start, @ende)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
The problem is the warning I get from GTK

The code runs fine

Thanks a lot :oops:
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Problem with Editorgadget and GTK+

Post by Shardik »

Welcome in the PureBasic Forum, gerd.

Did you already program in other programming languages? I ask because your code
example already contains quite hefty API stuff for a first posting. :wink:

Unfortunately until now I wasn't able to solve your problem using the assignment of
the GtkTextLabel "mytag" but I somehow circumvented the problem by not using a
clear-text label at all. Perhaps freak (the PB co-developer) has a better solution or
it even could be an internal PB implementation problem...

Code: Select all

*buffer.GtkTextBuffer
*tag.GtkTextTag
start.GtkTextIter
ende.GtkTextIter

If OpenWindow(0, 100, 200, 600, 200, "Test", #PB_Window_ScreenCentered) 
     CreateStatusBar(0, WindowID(0))
     AddStatusBarField(#PB_Ignore)
     StatusBarText(0, 0, "Test", 0)
     EditorGadget(14, 10, 10, 580, 100)
     SetGadgetColor(14, #PB_Gadget_BackColor, RGB(255, 255, 210))
     AddGadgetItem(14, -1, "This is just an example and it works, as in my code it does as well.")
     AddGadgetItem(14, -1, "But when compiling, I get an annoying warning!")
     AddGadgetItem(14, -1, "Line 20, Glib-GObject: A_g_object_set_valist: object class 'GtkTextTag' has no property named ...")
EndIf

*buffer = gtk_text_view_get_buffer_(GadgetID(14))
*tag = gtk_text_tag_new_(0)
*tag\table = *buffer\tag_table

PropertyText.S = "orange"
Property.GValue
Property\g_type = 16 << 2
Property\data\v_pointer = @PropertyText

g_object_set_property_(*tag, "background", @Property)

gtk_text_buffer_get_iter_at_offset_(*buffer, @start, 8)
gtk_text_buffer_get_iter_at_offset_(*buffer, @ende, 12)
gtk_text_buffer_apply_tag_(*buffer, *tag, @start, @ende)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Last edited by Shardik on Fri Apr 30, 2010 10:05 pm, edited 2 times in total.
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Problem with Editorgadget and GTK+

Post by gerd »

Hi Shardik,

Thanks for helping me, right after I finish this post I will try your code.

To answer your question about other programming languages: I tried a little bit of Basic, C and may be some other, but I never really programmed anything. And I don't know any of the other languages well enough to use them.

Now I try with PureBasic and may be I get a working, useful program out of it. Would be the first time.

What you see from the code I posted, I got from the documentation and trial and error.

Better I stop now, before you get bored by reading this.

Thanks again, I let you know, if it works for me.
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Problem with Editorgadget and GTK+

Post by gerd »

Sorry, doesn't do the job, may be I should explain better. What I want is, the word "just" with a red background and only this word. Your code doesn' set any background and does not give the error.

Any other idea???

Thank's
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Problem with Editorgadget and GTK+

Post by Shardik »

Sorry gerd, I had forgotten to include the property setting instructions... :oops:
I have corrected my above code example. Please try again... :wink:
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Problem with Editorgadget and GTK+

Post by gerd »

hi Shardik,

thanx again. This time it works nicely. I have to find out now why your code does not produce the warning and mine does.

Thanx again
gerd
Post Reply