Re: number of entries in GtkCombobox

2006-09-19 Thread Lance Dillon
I'm not sure I like this answer, it seems to be way to much for this question, 
but it looks like the best way to do it is to get a GtkTreeIter with 
gtk_tree_model_get_iter_first(), then walk the list with 
gtk_tree_model_iter_next(), counting up the number of rows:

GtkTreeIter iter;
int num,v;
GtkTreeModel *m;
m=gtk_combo_box_get_model(combo_box);
v=gtk_tree_model_get_iter_first(m,iter);
if (v) {
  num=1;
  while (v=gtk_tree_model_iter_next(m,iter))
num++;
} else
  num=0;



- Original Message 
From: [EMAIL PROTECTED]
To: gtk-app-devel-list@gnome.org
Sent: Monday, September 18, 2006 11:54:21 AM
Subject: number of entries in GtkCombobox

Hi.
How do I get the number of entries in GtkComboBox (created with
gtk_combo_box_new_text() )?

Tomek
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: number of entries in GtkCombobox

2006-09-19 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, Sep 19, 2006 at 08:34:56AM -0700, Lance Dillon wrote:
 I'm not sure I like this answer, it seems to be way to much for this question,
 but it looks like the best way to do it is to get a GtkTreeIter with
 gtk_tree_model_get_iter_first(), then walk the list with 
 gtk_tree_model_iter_next(),
 counting up the number of rows:

There is gtk_tree_model_iter_n_children ():

 | gint gtk_tree_model_iter_n_children(GtkTreeModel *tree_model,
 | GtkTreeIter *iter);
 | 
 | Returns the number of children that iter has. As a special case, if iter
 | is NULL, then the number of toplevel nodes is returned.

HTH
- -- tomás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFEBCCBcgs9XrR2kYRAnKoAJ9udyMXFULPZfDhdVt50d5H62MrFACeKB4s
pHwsM5/sWoBj4AkdwhbS5A0=
=ME1l
-END PGP SIGNATURE-

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: number of entries in GtkCombobox

2006-09-19 Thread Lance Dillon
Okay, that's better.  I didn't see the special case.


- Original Message 
From: [EMAIL PROTECTED]
To: Lance Dillon [EMAIL PROTECTED]
Cc: gtk-app-devel-list@gnome.org
Sent: Tuesday, September 19, 2006 11:45:06 AM
Subject: Re: number of entries in GtkCombobox

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, Sep 19, 2006 at 08:34:56AM -0700, Lance Dillon wrote:
 I'm not sure I like this answer, it seems to be way to much for this question,
 but it looks like the best way to do it is to get a GtkTreeIter with
 gtk_tree_model_get_iter_first(), then walk the list with 
 gtk_tree_model_iter_next(),
 counting up the number of rows:

There is gtk_tree_model_iter_n_children ():

 | gint gtk_tree_model_iter_n_children(GtkTreeModel *tree_model,
 | GtkTreeIter *iter);
 | 
 | Returns the number of children that iter has. As a special case, if iter
 | is NULL, then the number of toplevel nodes is returned.

HTH
- -- tomás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFEBCCBcgs9XrR2kYRAnKoAJ9udyMXFULPZfDhdVt50d5H62MrFACeKB4s
pHwsM5/sWoBj4AkdwhbS5A0=
=ME1l
-END PGP SIGNATURE-





___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list