Re: Key-value file parser, howto get all groups and create loop from them



grrr, simple as most of the time:

void crypto_mount_set_pixbuf(struct treedata *treedata){

   gchar *mountpoint;
   GtkTreeIter iter;
   gtk_tree_model_get_iter_first(treedata->store,&iter);


   do
   {
       gtk_tree_model_get(treedata->store, &iter, MOUNTPOINT_COLUMN,
&mountpoint, -1);
       g_print("MOUNTPOINT_COLUMN: %s\n", mountpoint);

       if(crypto_mount_check(mountpoint))
       {
           g_print("%s FOUND\n", mountpoint);
           treedata->pixbuf_mount =
gdk_pixbuf_new_from_file("pics/mount.png", NULL);
           gtk_list_store_set(treedata->store, &iter, MOUNT_COLUMN,
treedata->pixbuf_mount, -1);
           g_object_unref(treedata->pixbuf_mount);

       }
       else
       {
           g_print("%s NOT FOUND\n", mountpoint);
           treedata->pixbuf_mount =
gdk_pixbuf_new_from_file("pics/unmount.png", NULL);
           gtk_list_store_set(treedata->store, &iter, MOUNT_COLUMN,
treedata->pixbuf_mount, -1);
           g_object_unref(treedata->pixbuf_mount);

       }

   }while(gtk_tree_model_iter_next(treedata->store, &iter));
   gtk_tree_model_get_iter_first(treedata->store,&iter);
}


I have to give me a timeframe of a day or two before asking question,(this
gets a note on the monitor.)...

so long
On 8/14/06, rupert <rupertt gmail com> wrote:

its getting good,  somehow i packed the gtk_tree_model_iter_next in a do
while loop,
when i have no return in the loop it show all the lines once(it should
show it every 100ms) , when i add a return it always loops(but loops) at the
first line.


void crypto_mount_set_pixbuf(struct treedata *treedata){

    gchar *mountpoint;
    GtkTreeIter iter;
    gtk_tree_model_get_iter_first(treedata->store,&iter);

    do
    {
        gtk_tree_model_get(treedata->store, &iter, MOUNTPOINT_COLUMN,
&mountpoint, -1);
        g_print("MOUNTPOINT_COLUMN: %s\n", mountpoint);
/*

        if(crypto_mount_check(mountpoint))
        {
            g_print("%s FOUND\n", mountpoint);

            treedata->pixbuf_mount =
gdk_pixbuf_new_from_file("pics/mount.png", NULL);
            gtk_list_store_set(treedata->store, &treedata->iter,
MOUNT_COLUMN, treedata->pixbuf_mount, -1);

            g_object_unref(treedata->pixbuf_mount);
            return;
        }
        else
        {
            g_print("%s NOT FOUND\n", mountpoint);

            treedata->pixbuf_mount =
gdk_pixbuf_new_from_file("pics/unmount.png", NULL);
            gtk_list_store_set(treedata->store, &treedata->iter,
MOUNT_COLUMN, treedata->pixbuf_mount, -1);

            g_object_unref(treedata->pixbuf_mount);
            return;
        }
*/
    }while(gtk_tree_model_iter_next(treedata->store, &iter));

}

On 8/14/06, Peter Firefly Lund <firefly diku dk> wrote:

> On Mon, 14 Aug 2006, rupert wrote:
>
> > thx for the hel, with adding the tip lanve gave its working somehow
> now,
> > but i had to do some changes:
> >
> > gtk_tree_model_get_iter_first(treedata->store,&treedata->iter);
> > i have this line now before make_list and also in the function that
> updates
> > the
> > pixbuf.
>
> The next improvement you should try is to remove the iter field from the
> struct, remove the gtk_tree_model_get_iter_first() call before the call
> to
> make_list() and put a gtk_tree_model_get_iter_first() call into your
> callback function (probably as the first line of code after the
> declarations of the local variables).
>
> Iterators are usually just used as a special kind of loop variables --
> you
> don't make loop variables global just so you can use the same loop
> variable in another loop inside a completely unrelated function.  Or so
> that you can initialize a local loop variable to whatever value was left
> in the global loop variable from the last executed loop somewhere else.
>
> Just get rid of it.
>
> > Now i have to extract one field from every single line, so that i
> update the
> > pixbuf in
> > each line.
>
> use gtk_tree_model_iter_next() inside your loop.  You can use it instead
>
> of normal loop variable: just call it until it returns FALSE.
>
> -Peter
>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]