Re: PATCH for tab-scrolling



Owen Taylor <otaylor redhat com> writes:

> * It would be best to get the patch into bugzilla; patches on the
>   mailing list can easily get forgotten about.

Gabriel, will you take care of this?

> * The one thing I'd do as well is change the return type to be
>   gboolean rather than gint. Consistency with the prototype is more
>   important than consistency with the rest of the file, IMO.

Yeah, I thought about this too, but was confused by the fact that all
the other event handlers are declared as returning gint.  Further
confusion came from the fact that some of the functions are actually
*definined* as returning gboolean.

So I got curious, and so I did some research.  First, I took everything
in `cat gtk*.c`.  Then I grabbed all identifiers that appear in a line
that looks like this,

  widget_class->GDKEVENT = IDENTIFIER;

where GDKEVENT is any of the following:

  event
  button_press_event
  button_release_event
  scroll_event
  motion_notify_event
  delete_event
  destroy_event
  expose_event
  key_press_event
  key_release_event
  enter_notify_event
  leave_notify_event
  configure_event
  focus_in_event
  focus_out_event
  map_event
  unmap_event
  property_notify_event
  selection_clear_event
  selection_request_event
  selection_notify_event
  proximity_in_event
  proximity_out_event
  visibility_notify_event
  client_event
  no_expose_event
  window_state_event

I found a total of 178 identifiers, beginning with

  gtk_accel_label_expose_event
  gtk_arrow_expose
  gtk_button_expose
  gtk_button_button_press
  gtk_button_button_release
  ...

Then I verified that each of these identifiers appear as a function name
in both a declaration and a definition, and that its return type in
those is ether gint or gboolean (though the declaration and definition
might conflict).  However, I did this using some crude regular
expressions, and I'm not completely sure that everything was matched
correctly.

Anyway, I collected the data, and here's what I found:

                      GDK Event Handler Functions
                        in GtkWidget Subclasses

               Declaration  |  Definition  |  Occurences
             ---------------+--------------+--------------
               gint         |  gint        |         115
               gboolean     |  gboolean    |          46
               gint         |  gboolean    |          17
               gboolean     |  gint        |           0

This means that gint is almost three times as common as gboolean.
Further, noone declares their function as returning gboolean and then
goes and defines it with a gint return type.  On the other hand, a
significant number of people define their function with a gboolean
return type despite the fact that it's declared as returning gint.

Now that kind of mixing is obviously incorrect, and as Owen pointed out,
the gint-gint case is undesireable too, since the declarations in
gtkwidget.h use gboolean.

Should I file this as a bug?


Cheers,

--
Daniel Brockman
drlion deepwood net




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