Re: GtkOptionMenu



  I guess this is more of a question/advice-request to Havoc.

  I agree that your application should rely as little as possible on the GUI
toolkit you use. In my case; however, wrote an pp that has a linked list of
struct and MOST of the fields of this struct needs to be shown on a
GtkListStore/TreeView.

  Now are find myself writting spaggetti code just to keep the to lists (My own
GList and the GtkListStore synchronized.)

  As if I do have enought time on my hands, I am trying to modify the program
to use only one list (GtkListStore). and modify my stuct to something like.

  struct gui_fields{
   .
   ..
   ..
   strcut no_gui_fields* extra_info;
  }

  The struct names are not really these, but you get the idea...

  And now use the no_gui_fields as a G_TYPE_POINTER on my GtkListStore.

  Do you think it is worth to make these changes ?

  Thanks.
 
--- Havoc Pennington <hp redhat com> wrote:
On Thu, Mar 06, 2003 at 11:21:07AM -0000, martyn 2 russell bt com wrote:
Again, this is an FAQ similar to the question about how to get and set the
label for a menu.  Perhaps there should be an API call for this...?


There's no API call because it's normally a really bad way to write
the program - it's a FAQ because it's the first way people think of,
not because you should actually do it.

One reason it's bad is that almost all real-life programs other than
in-house apps end up internationalized, and this code breaks as soon
as you internationalize the program. (Except in the case where the
option menu contains non-predetermined strings, such as database query
results. Even then though, the option menu text must be in UTF-8, and
your actual data may not be.)

It's better to use object data
(g_object_set_data()/g_object_get_data()) or simply the option menu
index (gtk_option_menu_get_history()) instead of the label.

As a general guideline for GUI programming, you should never use your
widgets as your data structure. Anytime you do that it's hard to
change around the UI and hard to port to other toolkits and you
usually end up with spaghetti code.

The program should be structured around the data structures and
algorithms that make sense for the application, then layer the GUI on
top of that non-invasively. This is another way of stating that you
should have a "model" separate from your "view"

Havoc

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


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



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