gtk3-rs icon indicating copy to clipboard operation
gtk3-rs copied to clipboard

GtkWidget Subclassing: virtual methods

Open BrainBlasted opened this issue 6 years ago • 7 comments

This issue is to provide a list of vfuncs of GtkWidget, to be crossed of as they are implemented. The first batch is covered in gtk-rs/gtk#861.

  • [x] adjust_baseline_allocation
  • [x] adjust_baseline_request
  • [x] adjust_size_allocation
  • [x] adjust_size_request
  • [x] button_press_event
  • [x] button_release_event
  • [ ] ~~can_activate_accel~~ (Needs work on signals API)
  • [ ] child_notify
  • [x] composited_changed
  • [x] compute_expand
  • [x] configure_event
  • [x] damage_event
  • [ ] ~~delete_event~~ (Needs bindings for GdkEventAny)
  • [x] destroy
  • [ ] destroy_event
  • [x] direction_changed
  • [ ] dispatch_child_properties_changed
  • [x] drag_begin
  • [x] drag_data_delete
  • [x] drag_data_get
  • [x] drag_data_received
  • [x] drag_drop
  • [x] drag_end
  • [x] drag_failed
  • [x] drag_leave
  • [x] drag_motion
  • [x] draw
  • [ ] enter_notify_event
  • [ ] event
  • [ ] focus
  • [ ] focus_in_event
  • [ ] focus_out_event
  • [ ] get_accessible
  • [ ] get_preferred_height
  • [ ] get_preferred_height_and_baseline_for_width
  • [ ] get_preferred_height_for_width
  • [ ] get_preferred_width
  • [ ] get_preferred_width_for_height
  • [ ] get_request_mode
  • [ ] grab_broken_event
  • [ ] grab_focus
  • [ ] grab_notify
  • [ ] hide
  • [ ] hierarchy_changed
  • [ ] key_press_event
  • [ ] key_release_event
  • [ ] keynav_failed
  • [ ] leave_notify_event
  • [ ] map
  • [ ] map_event
  • [ ] mnemonic_activate
  • [ ] motion_notify_event
  • [ ] move_focus
  • [ ] parent_set
  • [ ] popup_menu
  • [ ] property_notify_event
  • [ ] proximity_in_event
  • [ ] proximity_out_event
  • [ ] query_tooltip
  • [ ] queue_draw_region
  • [ ] realize
  • [ ] screen_changed
  • [ ] scroll_event
  • [ ] selection_clear_event
  • [ ] selection_get
  • [ ] selection_notify_event
  • [ ] selection_received
  • [ ] selection_request_event
  • [ ] show
  • [ ] show_all
  • [ ] show_help
  • [ ] size_allocate
  • [ ] state_changed
  • [ ] state_flags_changed
  • [ ] style_set
  • [ ] style_updated
  • [ ] touch_event
  • [ ] unmap
  • [ ] unmap_event
  • [ ] unrealize
  • [ ] visibility_notify_event
  • [ ] window_state_event

BrainBlasted avatar Aug 06 '19 15:08 BrainBlasted

Note that we don't need all of them (or not even most of them) for writing meaningful widgets. Check existing widget implementations, only a very small subset of the virtual methods is usually needed.

I think the main important missing one is draw at this point, that should really be added rather sooner than later :)

sdroege avatar Aug 06 '19 15:08 sdroege

Currently we use expect if no parent implementation for a vfunc exists. There are a few vfuncs in GtkWidget that default to NULL - what's the right way to handle this? Is it okay to leave these as panics if the user makes a call to a non-existent parent implementation?

BrainBlasted avatar Aug 10 '19 06:08 BrainBlasted

On 10 August 2019 09:35:12 EEST, Chris [email protected] wrote:

Currently we use expect if no parent implementation for a vfunc exists. There are a few vfuncs in GtkWidget that default to NULL - what's the right way to handle this? Is it okay to leave these as panics if the user makes a call to a non-existent parent implementation?

It depends. If it's mandatory to implement the virtual method then yes, and you would put no default impl into the Impl trait.

If it's optional then you would instead return a default value here. Whatever the base class would do anyway if it was left at NULL.

See the various cases in gstreamer-rs, they all appear there.

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

sdroege avatar Aug 10 '19 07:08 sdroege

A few of the vfunc have been added, I don't have the permissions to check them in the list.

hfiguiere avatar Feb 21 '20 02:02 hfiguiere

Which ones?

BrainBlasted avatar Feb 21 '20 02:02 BrainBlasted

The ones in commit ccc855a for example. No?

hfiguiere avatar Feb 21 '20 04:02 hfiguiere

@GuillaumeGomez your job :)

sdroege avatar Feb 21 '20 08:02 sdroege