GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 2:27 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GTk3 Combobox
PostPosted: Tue Feb 11, 2014 10:31 am 
Offline
Familiar Face

Joined: Fri Sep 23, 2011 12:04 pm
Posts: 31
I am trying to create a combobox in which I use a list of characters which is every time different so I cannot use Glade to fill the liststore.
The language I program in is Ada but The Functions I use can certainly be recognized.
Therefore I create in glade a liststore with one empty column of the type gchar. Inside my program I did create a refill routine:

Code:
   procedure Refill(Set : integer; max : integer) is
      ch       : character;
      n1       : integer;
      G_char   : Gvalue;
      Types    : GType := (GType_Char);
   begin
      Clear(CH_List);
      n1 := 0;
      for nn in 1 .. max loop
         if not Grid(x_vak, y_vak).impossible(n1) then
            ch := CHARACTER'Val(Symbols(n1 ,Set)); -- create a character from an ascii value of that character
            Init(G_Char, GType_Char);
            Set_Char (G_Char, gchar(ch));
            append(CH_List, CH_Iter);
            Set_Value (CH_List, CH_Iter, 0, G_Char);
            Unset (G_Char);
         end if;
         n1 := n1 + 1;
      end loop;
   end Refill;


The problem is that as I expected the combobox to show characters it showed me ASCII values of the characters.
What did I do wrong.

I have tried the same with null terminated strings but then I get a list of zero's.
The same with strings of one character

L. Dries


Top
 Profile  
 
 Post subject: Re: GTk3 Combobox
PostPosted: Wed Feb 12, 2014 7:14 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hello,

I do not know much Ada. What I can see from your code is that you are using a type "GType_Char" to store data into the tree modal. This is an 8 bit unsigned integer in most cases and would be displayed as such. What you need is to use a string type. If Ada is using the same naming conventions the that type would be called "GType_String". You will need to create a string and add the character to the string before passing it onto GTK.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTk3 Combobox
PostPosted: Fri Feb 14, 2014 12:01 pm 
Offline
Familiar Face

Joined: Fri Sep 23, 2011 12:04 pm
Posts: 31
Thanks you got me on the right track with a combination of a string of one character and the the liststore defined with gchararray.

L. Dries


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

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot], Yahoo [Bot] and 4 guests


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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group