Skip to content

Commit

Permalink
gtk: drop unecessary manual code
Browse files Browse the repository at this point in the history
gdk::Event (and fundamental types) code can now be generated correctly
  • Loading branch information
bilelmoussaoui committed Jan 19, 2022
1 parent 4467773 commit 037e8ff
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 269 deletions.
44 changes: 2 additions & 42 deletions gtk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ generate = [
"Gtk.BuilderScope",
"Gtk.ButtonsType",
"Gtk.CellAreaBox",
"Gtk.CellEditable",
"Gtk.CellRendererAccelMode",
"Gtk.CellRendererMode",
"Gtk.CellRendererPixbuf",
Expand Down Expand Up @@ -130,6 +131,7 @@ generate = [
"Gtk.IconThemeError",
"Gtk.IconViewDropPosition",
"Gtk.ImageType",
"Gtk.IMContext",
"Gtk.IMMulticontext",
"Gtk.InputHints",
"Gtk.InputPurpose",
Expand Down Expand Up @@ -671,14 +673,6 @@ manual_traits = ["CellAreaExtManual"]
pattern = "cell_[gs]et_property"
manual = true
[[object.function]]
name = "activate_cell"
manual = true # to handlndle gdk::Event
doc_trait_name = "CellAreaExtManual"
[[object.function]]
name = "event"
manual = true # to handlndle gdk::Event
doc_trait_name = "CellAreaExtManual"
[[object.function]]
name = "apply_attributes"
[[object.function.parameter]]
name = "iter"
Expand All @@ -705,15 +699,6 @@ name = "Gtk.CellAreaContext"
status = "generate"
generate_builder = false

[[object]]
name = "Gtk.CellEditable"
status = "generate"
manual_traits = ["CellEditableExtManual"]
[[object.function]]
name = "start_editing"
manual = true # to handle gdk::Event
doc_trait_name = "CellEditableExtManual"

[[object]]
name = "Gtk.CellLayout"
status = "generate"
Expand All @@ -734,20 +719,12 @@ manual_traits = ["CellRendererExtManual"]
[[object.property]]
pattern = "*-set" # those properties are read only
generate = ["get", "notify"]
[[object.function]]
name = "activate"
manual = true # to handle gdk::Event
doc_trait_name = "CellRendererExtManual"
[[object.signal]]
name = "editing-started"
[[object.signal.parameter]]
name = "path"
transformation = "treepath"
[[object.function]]
name = "start_editing"
manual = true # to handle gdk::Event
doc_trait_name = "CellRendererExtManual"
[[object.function]]
name = "render"
ignore = true # docs only

Expand Down Expand Up @@ -1278,14 +1255,6 @@ status = "generate"
name = "pixbuf"
nullable = false

[[object]]
name = "Gtk.IMContext"
status = "generate"
manual_traits = ["IMContextExtManual"]
[[object.function]]
name = "filter_keypress"
manual = true # to handle gdk::Event
doc_trait_name = "IMContextExtManual"

[[object]]
name = "Gtk.IMContextSimple"
Expand Down Expand Up @@ -1816,10 +1785,6 @@ manual_traits = ["ShortcutTriggerExtManual"]
name = "compare"
manual = true # complains about the trait IsA<T> being so generic
doc_trait_name = "ShortcutTriggerExtManual"
[[object.function]]
name = "trigger"
manual = true # to handle gdk::Event
doc_trait_name = "ShortcutTriggerExtManual"

[[object]]
name = "Gtk.SignalAction"
Expand Down Expand Up @@ -1961,11 +1926,6 @@ status = "generate"
[[object]]
name = "Gtk.TextView"
status = "generate"
manual_traits = ["TextViewExtManual"]
[[object.function]]
name = "im_context_filter_keypress"
manual = true # to handle gdk::Event
doc_trait_name = "TextViewExtManual"
[[object.signal]]
name = "extend-selection"
inhibit = true
Expand Down
60 changes: 60 additions & 0 deletions gtk4/src/auto/cell_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ pub trait CellAreaExt: 'static {
edit_only: bool,
) -> bool;

#[doc(alias = "gtk_cell_area_activate_cell")]
fn activate_cell(
&self,
widget: &impl IsA<Widget>,
renderer: &impl IsA<CellRenderer>,
event: impl AsRef<gdk::Event>,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> bool;

#[doc(alias = "gtk_cell_area_add")]
fn add(&self, renderer: &impl IsA<CellRenderer>);

Expand Down Expand Up @@ -84,6 +94,16 @@ pub trait CellAreaExt: 'static {
#[doc(alias = "gtk_cell_area_create_context")]
fn create_context(&self) -> CellAreaContext;

#[doc(alias = "gtk_cell_area_event")]
fn event(
&self,
context: &impl IsA<CellAreaContext>,
widget: &impl IsA<Widget>,
event: impl AsRef<gdk::Event>,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> i32;

#[doc(alias = "gtk_cell_area_focus")]
fn focus(&self, direction: DirectionType) -> bool;

Expand Down Expand Up @@ -297,6 +317,26 @@ impl<O: IsA<CellArea>> CellAreaExt for O {
}
}

fn activate_cell(
&self,
widget: &impl IsA<Widget>,
renderer: &impl IsA<CellRenderer>,
event: impl AsRef<gdk::Event>,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_activate_cell(
self.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
renderer.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
cell_area.to_glib_none().0,
flags.into_glib(),
))
}
}

fn add(&self, renderer: &impl IsA<CellRenderer>) {
unsafe {
ffi::gtk_cell_area_add(
Expand Down Expand Up @@ -386,6 +426,26 @@ impl<O: IsA<CellArea>> CellAreaExt for O {
}
}

fn event(
&self,
context: &impl IsA<CellAreaContext>,
widget: &impl IsA<Widget>,
event: impl AsRef<gdk::Event>,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> i32 {
unsafe {
ffi::gtk_cell_area_event(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
cell_area.to_glib_none().0,
flags.into_glib(),
)
}
}

fn focus(&self, direction: DirectionType) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_focus(
Expand Down
12 changes: 12 additions & 0 deletions gtk4/src/auto/cell_editable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub trait CellEditableExt: 'static {
#[doc(alias = "gtk_cell_editable_remove_widget")]
fn remove_widget(&self);

#[doc(alias = "gtk_cell_editable_start_editing")]
fn start_editing(&self, event: Option<impl AsRef<gdk::Event>>);

#[doc(alias = "editing-canceled")]
fn is_editing_canceled(&self) -> bool;

Expand Down Expand Up @@ -66,6 +69,15 @@ impl<O: IsA<CellEditable>> CellEditableExt for O {
}
}

fn start_editing(&self, event: Option<impl AsRef<gdk::Event>>) {
unsafe {
ffi::gtk_cell_editable_start_editing(
self.as_ref().to_glib_none().0,
event.as_ref().map(|p| p.as_ref()).to_glib_none().0,
);
}
}

fn is_editing_canceled(&self) -> bool {
glib::ObjectExt::property(self.as_ref(), "editing-canceled")
}
Expand Down
66 changes: 66 additions & 0 deletions gtk4/src/auto/cell_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ impl CellRenderer {
}

pub trait CellRendererExt: 'static {
#[doc(alias = "gtk_cell_renderer_activate")]
fn activate(
&self,
event: impl AsRef<gdk::Event>,
widget: &impl IsA<Widget>,
path: &str,
background_area: &gdk::Rectangle,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> bool;

#[doc(alias = "gtk_cell_renderer_get_aligned_area")]
#[doc(alias = "get_aligned_area")]
fn aligned_area(
Expand Down Expand Up @@ -137,6 +148,17 @@ pub trait CellRendererExt: 'static {
flags: CellRendererState,
);

#[doc(alias = "gtk_cell_renderer_start_editing")]
fn start_editing(
&self,
event: Option<impl AsRef<gdk::Event>>,
widget: &impl IsA<Widget>,
path: &str,
background_area: &gdk::Rectangle,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> Option<CellEditable>;

#[doc(alias = "gtk_cell_renderer_stop_editing")]
fn stop_editing(&self, canceled: bool);

Expand Down Expand Up @@ -238,6 +260,28 @@ pub trait CellRendererExt: 'static {
}

impl<O: IsA<CellRenderer>> CellRendererExt for O {
fn activate(
&self,
event: impl AsRef<gdk::Event>,
widget: &impl IsA<Widget>,
path: &str,
background_area: &gdk::Rectangle,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> bool {
unsafe {
from_glib(ffi::gtk_cell_renderer_activate(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
path.to_glib_none().0,
background_area.to_glib_none().0,
cell_area.to_glib_none().0,
flags.into_glib(),
))
}
}

fn aligned_area(
&self,
widget: &impl IsA<Widget>,
Expand Down Expand Up @@ -515,6 +559,28 @@ impl<O: IsA<CellRenderer>> CellRendererExt for O {
}
}

fn start_editing(
&self,
event: Option<impl AsRef<gdk::Event>>,
widget: &impl IsA<Widget>,
path: &str,
background_area: &gdk::Rectangle,
cell_area: &gdk::Rectangle,
flags: CellRendererState,
) -> Option<CellEditable> {
unsafe {
from_glib_none(ffi::gtk_cell_renderer_start_editing(
self.as_ref().to_glib_none().0,
event.as_ref().map(|p| p.as_ref()).to_glib_none().0,
widget.as_ref().to_glib_none().0,
path.to_glib_none().0,
background_area.to_glib_none().0,
cell_area.to_glib_none().0,
flags.into_glib(),
))
}
}

fn stop_editing(&self, canceled: bool) {
unsafe {
ffi::gtk_cell_renderer_stop_editing(
Expand Down
12 changes: 12 additions & 0 deletions gtk4/src/auto/im_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub trait IMContextExt: 'static {
group: i32,
) -> bool;

#[doc(alias = "gtk_im_context_filter_keypress")]
fn filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool;

#[doc(alias = "gtk_im_context_focus_in")]
fn focus_in(&self);

Expand Down Expand Up @@ -165,6 +168,15 @@ impl<O: IsA<IMContext>> IMContextExt for O {
}
}

fn filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool {
unsafe {
from_glib(ffi::gtk_im_context_filter_keypress(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
))
}
}

fn focus_in(&self) {
unsafe {
ffi::gtk_im_context_focus_in(self.as_ref().to_glib_none().0);
Expand Down
13 changes: 13 additions & 0 deletions gtk4/src/auto/shortcut_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub trait ShortcutTriggerExt: 'static {
#[doc(alias = "gtk_shortcut_trigger_to_string")]
#[doc(alias = "to_string")]
fn to_str(&self) -> glib::GString;

#[doc(alias = "gtk_shortcut_trigger_trigger")]
fn trigger(&self, event: impl AsRef<gdk::Event>, enable_mnemonics: bool) -> gdk::KeyMatch;
}

impl<O: IsA<ShortcutTrigger>> ShortcutTriggerExt for O {
Expand All @@ -62,4 +65,14 @@ impl<O: IsA<ShortcutTrigger>> ShortcutTriggerExt for O {
))
}
}

fn trigger(&self, event: impl AsRef<gdk::Event>, enable_mnemonics: bool) -> gdk::KeyMatch {
unsafe {
from_glib(ffi::gtk_shortcut_trigger_trigger(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
enable_mnemonics.into_glib(),
))
}
}
}
12 changes: 12 additions & 0 deletions gtk4/src/auto/text_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ pub trait TextViewExt: 'static {
#[doc(alias = "get_wrap_mode")]
fn wrap_mode(&self) -> WrapMode;

#[doc(alias = "gtk_text_view_im_context_filter_keypress")]
fn im_context_filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool;

#[doc(alias = "gtk_text_view_move_mark_onscreen")]
fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool;

Expand Down Expand Up @@ -1371,6 +1374,15 @@ impl<O: IsA<TextView>> TextViewExt for O {
}
}

fn im_context_filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool {
unsafe {
from_glib(ffi::gtk_text_view_im_context_filter_keypress(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
))
}
}

fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool {
unsafe {
from_glib(ffi::gtk_text_view_move_mark_onscreen(
Expand Down
Loading

0 comments on commit 037e8ff

Please sign in to comment.