It is currently Wed Jun 19, 2013 4:00 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [solved]Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 8:23 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
I can't find a work around to compile in unicode mode using g_signal_connect
it's a macro and should accept UTF8 encoding but how to do it?

compile in unicode it doesn't work!
Code:
ImportC "-gtk"
EndImport

ProcedureC onSize(*widget.GtkWidget,*event.GtkAllocation)
  Debug *event\x
  Debug *event\y
  ProcedureReturn 1
EndProcedure 

OpenWindow(1,0,0,200,100,"g_signalConnect")
ButtonGadget(0,5,5,60,20,"OK")
g_signal_connect_(GadgetID(0),"size-allocate",@onSize(),0)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Edit this works
Scroll the mouse wheel over the button!

Code:
ImportC "-gtk"
  g_signal_connect(instance,signal.p-ascii,*fn,*vdata,destroy=0,flags=0) As "g_signal_connect_data"
EndImport

ProcedureC onScroll(*widget.GtkWidget,*event.GdkEventScroll,pbID)
  Debug *event\direction
  Debug pbid
  ProcedureReturn 1
EndProcedure

OpenWindow(1,0,0,200,100,"g_signalConnect")
ButtonGadget(2,5,5,60,20,"OK")
ButtonGadget(3,5,30,60,20,"OK TOO")
g_signal_connect(GadgetID(2),"scroll-event",@onScroll(),2)
g_signal_connect(GadgetID(3),"scroll-event",@onScroll(),3)

Repeat
  Ev = WaitWindowEvent()
  evg = EventGadget()
  If Ev
    If  evg = 2
      Debug EventType()
    EndIf
  EndIf
Until Ev = #PB_Event_CloseWindow


Last edited by idle on Wed Jan 11, 2012 11:13 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 8:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
Hello,

I'm just about to suggest this workaround :

Code:
ImportC "-gtk"
EndImport

ProcedureC onSize(*widget.GtkWidget,*event.GtkAllocation)
   Debug *event\x
   Debug *event\y
   ProcedureReturn 1
EndProcedure 

Procedure GLIB_signal_connect(instance, detailed_signal.s, c_handler, Data_)
 
  *Source.Character = @detailed_signal
  g_signal_connect_(instance, PeekS(*Source, Len(detailed_signal), #PB_UTF8), c_handler, Data_)
 
EndProcedure

OpenWindow(1,0,0,200,100,"g_signalConnect")
ButtonGadget(0,5,5,100,30,"OK")

GLIB_signal_connect(GadgetID(0), "size-allocate",@onSize(),0)

; g_signal_connect_(GadgetID(0),"size-allocate",@onSize(),0)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

But the code still generate this warning message :
Quote:
GLib-GObject (Warning): /build/buildd/glib2.0-2.30.0/./gobject/gsignal.c:2295: signal 's' is invalid for instance '0xd8d830'

Best regards.
Guimauve


Top
 Profile  
 
 Post subject: Re: Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 9:29 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
The macro maps to g_signal_connect_data
this appears to work but it's not right!

Code:
ImportC "-gtk"
  g_signal_connect_data(instance,*signal,*fn,*vdata,destroy,flags)
EndImport

Prototype gsignal_connect(*widget,signal.p-utf8,*fn,*vdata,destroy=0)
Global gsignal_connect.gsignal_connect = @g_signal_connect_data()

ProcedureC onScroll(*widget.GtkWidget,*event.GdkEventScroll)
  Debug *event\direction
   ProcedureReturn 1
EndProcedure 

OpenWindow(1,0,0,200,100,"g_signalConnect")
ButtonGadget(2,5,5,60,20,"OK")

gsignal_connect(GadgetID(2),"scroll-event",@onScroll(),0)

Repeat
  Ev = WaitWindowEvent()
  evg = EventGadget()
  If Ev
    If  evg = 2 
      Debug EventType()
    EndIf
  EndIf
Until Ev = #PB_Event_CloseWindow




Top
 Profile  
 
 Post subject: Re: Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 10:23 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
It's probably because some signal should be added to the gadget. Also, special PB EventType are for specific gadget only and this can be an issue.

Best regards.
Guimauve


Top
 Profile  
 
 Post subject: Re: Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 10:43 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
Got it a fix

Code:
ImportC "-gtk"
  g_signal_connect(instance,signal.p-ascii,*fn,*vdata,destroy=0,flags=0) As "g_signal_connect_data"
EndImport

ProcedureC onScroll(*widget.GtkWidget,*event.GdkEventScroll,pbID)
  Debug *event\direction
  Debug pbid
  ProcedureReturn 1
EndProcedure

OpenWindow(1,0,0,200,100,"g_signalConnect")
ButtonGadget(2,5,5,60,20,"OK")
ButtonGadget(3,5,30,60,20,"OK TOO")
g_signal_connect(GadgetID(2),"scroll-event",@onScroll(),2)
g_signal_connect(GadgetID(3),"scroll-event",@onScroll(),3)

Repeat
  Ev = WaitWindowEvent()
  evg = EventGadget()
  If Ev
    If  evg = 2
      Debug EventType()
    EndIf
  EndIf
Until Ev = #PB_Event_CloseWindow 


you can add any signal to a gadget you want since they're inherited from gtkwidget
http://developer.gnome.org/gtk/2.24/Gtk ... et.signals


Top
 Profile  
 
 Post subject: Re: Can't compile Unicode using g_signal_connect_()?
PostPosted: Wed Jan 11, 2012 11:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
idle wrote:
you can add any signal to a gadget you want since they're inherited from gtkwidget
http://developer.gnome.org/gtk/2.24/Gtk ... et.signals


Possible but what happen when we add signals and function to a Gadget when this gadget already have the added signals with different function attached ? They will be all executed or they will interfere each other ?
Thanks for the link.

Best regards.
Guimauve


Top
 Profile  
 
 Post subject: Re: [solved]Can't compile Unicode using g_signal_connect_()?
PostPosted: Thu Jan 12, 2012 5:34 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
I don't know but I expect It'll just add it to the hook chain.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye