RE: Best way to sort rooms...



Hi,

> I'm making a room scheduler program and what I would
> like to do is be able to dynamically add and delete
> different pages for each building, and then within
> each building tab, there will be another notebook
> with pages for each room in the building. I can do this
> just fine, but I would also like to sort the pages
> alphabetically, so when a new room or building 
> is added, it's put in the right spot.
> 
> To throw another wrench into the plans, for each building
> and room I'm going to need to memorize the status of the widgets
> for each so I can save all of the data
> 
> I was thinking I could use a GList to link together
> a series of structures where each one would correspond
> to a building. Inside a building structure would be
> another GList with a series of structure for each room
> in that respective building with all of the
> widgets and data that I need contained within the
> structure. This make sense? I hope so.

Yep.

> Anyway, I don't know if this is the best way of doing
> this. If anybody has any design suggestions for something
> like this, I would really appreciate hearing them. Thanks!

I think there'splenty of time to:
- Retrieve the building name from the notebook tab
- compare it with the new building name
  - go to the next tab if strcmp() > 0
  - add it if a strcmp() < 0 
  - do the same trich for the rooms if strcmp() == 0
   (of course the parameter order in strcmp matters ;-).

You can speed this up by also storing the information in a separate GList
structure, but that way you have to manage two lists.

For memorizing the data: couldn't the GtkArg system help with that? (I guess
you have to write it to disk too)

Regards,

Arjan




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