Re: enum/flag package registration? (was Re: Missing pango constants)



On Tue, 29 Jul 2003 11:51:28 -0400 (EDT), muppet wrote:

[Type issues that trick the enum magician.]

Now, *that*'s a mess. :)

are there any pure-perl workarounds that would avoid the problem?

At the moment, I'm simply defining three constants, setup an Glib::Int
column and point the style attribute to it:

  use constant PANGO_STYLE_NORMAL => 0;
  use constant PANGO_STYLE_OBLIQUE => 1;
  use constant PANGO_STYLE_ITALIC => 2;

  # ...


  my $model = Gtk2::TreeStore -> new(qw(Glib::String
                                        Glib::String
                                        Glib::Int
                                        Glib::Int));

  # ...

  my $view_column =
    Gtk2::TreeViewColumn -> new_with_attributes($title,
                                                $cell_renderer,
                                                text => $column,
                                                weight => COLUMN_WEIGHT,
                                                style => COLUMN_STYLE);

When populating the tree, I set $style according to certain criteria
and use:

  $model -> set($iterator,
                COLUMN_TASK, $task,
                COLUMN_DUE_DATE, $due_date,
                COLUMN_WEIGHT, $weight,
                COLUMN_STYLE, $style);

to get the appearance I want.

what's some more context on what you're doing --- is it the first way
you'd think of doing something, or is it sneaky wizzardry[1]?  (i ask
because the obvious way needs support, but wizardry might be able to
suffer at the expense of performance.)

All this is for a simple task list manager that organizes the tasks
hierarchically and prints them bold and italic if their due date is
within a certain range.

I do it this way because I was told that this is the way to do it by a
irc://irc.gnome.org/gtk+ regular. He (Tim Müller, author of the
ed2k_gui) told me how to do the weight thingy. I then simply took the
same path for the style attribute - until I stumbled accross the
"missing" constants which I assumed have to exist since
PANGO_WEIGHT_BOLD, etc. are there, too. Hence the patch.

In comparison to what Ross proposed this approach seems more
straightforward and less Rincewindly to me.

HTH,
-Torsten



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