From 5e280a6c279650e934e834c79ebc3e352bad3d64 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 9 Oct 2020 19:22:29 +0200 Subject: [PATCH 01/45] groovy update: regenerate --- gir | 2 +- gir-files | 2 +- src/auto/about_dialog.rs | 1250 +++-------------- src/auto/accel_label.rs | 556 +------- src/auto/accessible.rs | 105 +- src/auto/action_bar.rs | 403 +----- src/auto/actionable.rs | 9 +- src/auto/adjustment.rs | 48 +- src/auto/app_chooser.rs | 3 +- src/auto/app_chooser_button.rs | 540 ++------ src/auto/app_chooser_dialog.rs | 612 +-------- src/auto/app_chooser_widget.rs | 649 ++------- src/auto/application.rs | 97 +- src/auto/application_window.rs | 547 +------- src/auto/aspect_frame.rs | 614 ++------- src/auto/assistant.rs | 810 ++--------- src/auto/assistant_page.rs | 14 +- src/auto/box_.rs | 394 +----- src/auto/box_layout.rs | 18 +- src/auto/buildable.rs | 65 +- src/auto/builder.rs | 233 ++-- src/auto/button.rs | 497 ++----- src/auto/calendar.rs | 1089 ++------------- src/auto/cell_area.rs | 91 +- src/auto/cell_area_box.rs | 114 +- src/auto/cell_area_context.rs | 24 +- src/auto/cell_editable.rs | 27 +- src/auto/cell_renderer.rs | 230 ++-- src/auto/cell_renderer_accel.rs | 192 ++- src/auto/cell_renderer_combo.rs | 137 +- src/auto/cell_renderer_pixbuf.rs | 245 ++-- src/auto/cell_renderer_progress.rs | 212 ++- src/auto/cell_renderer_spin.rs | 117 +- src/auto/cell_renderer_spinner.rs | 115 +- src/auto/cell_renderer_text.rs | 282 ++-- src/auto/cell_renderer_toggle.rs | 174 +-- src/auto/cell_view.rs | 514 +------ src/auto/center_box.rs | 329 +---- src/auto/check_button.rs | 397 +----- src/auto/color_button.rs | 508 ++----- src/auto/color_chooser.rs | 18 +- src/auto/color_chooser_dialog.rs | 600 +-------- src/auto/color_chooser_widget.rs | 424 +----- src/auto/combo_box.rs | 550 ++------ src/auto/combo_box_text.rs | 481 +------ src/auto/constants.rs | 72 - src/auto/css_provider.rs | 83 +- src/auto/custom_layout.rs | 2 +- src/auto/dialog.rs | 556 +------- src/auto/drawing_area.rs | 368 +---- src/auto/editable.rs | 104 +- src/auto/entry.rs | 1077 +++------------ src/auto/entry_buffer.rs | 18 +- src/auto/entry_completion.rs | 582 +++----- src/auto/enums.rs | 824 ++---------- src/auto/event_controller.rs | 149 ++- src/auto/event_controller_key.rs | 169 +-- src/auto/event_controller_legacy.rs | 4 +- src/auto/event_controller_motion.rs | 94 +- src/auto/event_controller_scroll.rs | 20 +- src/auto/expander.rs | 626 ++------- src/auto/file_chooser.rs | 787 +---------- src/auto/file_chooser_button.rs | 556 ++------ src/auto/file_chooser_dialog.rs | 641 +-------- src/auto/file_chooser_native.rs | 12 +- src/auto/file_chooser_widget.rs | 787 +++-------- src/auto/file_filter.rs | 80 +- src/auto/filter_list_model.rs | 232 ++-- src/auto/fixed.rs | 330 +---- src/auto/fixed_layout_child.rs | 28 +- src/auto/flags.rs | 229 +--- src/auto/flatten_list_model.rs | 44 +- src/auto/flow_box.rs | 960 +++---------- src/auto/flow_box_child.rs | 363 +---- src/auto/font_button.rs | 556 ++------ src/auto/font_chooser.rs | 48 +- src/auto/font_chooser_dialog.rs | 594 +------- src/auto/font_chooser_widget.rs | 404 +----- src/auto/frame.rs | 425 +----- src/auto/functions.rs | 410 ++---- src/auto/gesture.rs | 30 +- src/auto/gesture_drag.rs | 18 +- src/auto/gesture_long_press.rs | 38 +- src/auto/gesture_pan.rs | 8 +- src/auto/gesture_rotate.rs | 4 +- src/auto/gesture_single.rs | 18 +- src/auto/gesture_stylus.rs | 18 +- src/auto/gesture_swipe.rs | 4 +- src/auto/gesture_zoom.rs | 4 +- src/auto/gl_area.rs | 393 +----- src/auto/grid.rs | 403 +----- src/auto/grid_layout.rs | 30 +- src/auto/grid_layout_child.rs | 24 +- src/auto/header_bar.rs | 762 +---------- src/auto/icon_theme.rs | 471 +++---- src/auto/icon_view.rs | 929 +++++-------- src/auto/im_context.rs | 96 +- src/auto/image.rs | 734 ++-------- src/auto/info_bar.rs | 605 ++------- src/auto/label.rs | 1445 ++++---------------- src/auto/level_bar.rs | 584 ++------ src/auto/link_button.rs | 473 +------ src/auto/list_box.rs | 852 +++--------- src/auto/list_box_row.rs | 402 +----- src/auto/lock_button.rs | 600 ++------- src/auto/map_list_model.rs | 31 +- src/auto/media_controls.rs | 321 +---- src/auto/media_file.rs | 34 +- src/auto/media_stream.rs | 126 +- src/auto/menu_button.rs | 731 +++------- src/auto/message_dialog.rs | 796 ++--------- src/auto/mod.rs | 565 +------- src/auto/mount_operation.rs | 18 +- src/auto/native_dialog.rs | 36 +- src/auto/notebook.rs | 1053 ++++----------- src/auto/notebook_page.rs | 30 +- src/auto/orientable.rs | 6 +- src/auto/overlay.rs | 413 +----- src/auto/page_setup.rs | 8 +- src/auto/paned.rs | 1016 ++++---------- src/auto/paper_size.rs | 13 +- src/auto/password_entry.rs | 528 ++------ src/auto/picture.rs | 380 +----- src/auto/popover.rs | 630 +++------ src/auto/popover_menu.rs | 473 +------ src/auto/print_operation.rs | 176 +-- src/auto/print_operation_preview.rs | 12 +- src/auto/print_settings.rs | 10 +- src/auto/progress_bar.rs | 595 ++------- src/auto/radio_button.rs | 472 +------ src/auto/range.rs | 431 +----- src/auto/recent_manager.rs | 12 +- src/auto/revealer.rs | 508 ++----- src/auto/root.rs | 89 +- src/auto/scale.rs | 499 +------ src/auto/scale_button.rs | 434 +----- src/auto/scrollable.rs | 24 +- src/auto/scrollbar.rs | 366 +---- src/auto/scrolled_window.rs | 1176 +++++----------- src/auto/search_bar.rs | 505 ++----- src/auto/search_entry.rs | 581 ++------ src/auto/selection_model.rs | 58 +- src/auto/separator.rs | 318 +---- src/auto/settings.rs | 1657 +++++++++-------------- src/auto/shortcut_label.rs | 374 +----- src/auto/shortcuts_group.rs | 413 +----- src/auto/shortcuts_section.rs | 398 +----- src/auto/shortcuts_shortcut.rs | 460 +------ src/auto/shortcuts_window.rs | 657 +-------- src/auto/single_selection.rs | 81 +- src/auto/size_group.rs | 92 +- src/auto/slice_list_model.rs | 56 +- src/auto/snapshot.rs | 11 +- src/auto/sort_list_model.rs | 158 ++- src/auto/spin_button.rs | 842 +++--------- src/auto/spinner.rs | 397 +----- src/auto/stack.rs | 768 ++--------- src/auto/stack_page.rs | 158 +-- src/auto/stack_sidebar.rs | 375 +----- src/auto/stack_switcher.rs | 414 +----- src/auto/statusbar.rs | 409 +----- src/auto/style_context.rs | 163 +-- src/auto/style_provider.rs | 14 +- src/auto/switch.rs | 467 +------ src/auto/text.rs | 668 ++------- src/auto/text_buffer.rs | 372 +++++- src/auto/text_child_anchor.rs | 13 +- src/auto/text_iter.rs | 8 +- src/auto/text_tag.rs | 991 +++++++++++--- src/auto/text_tag_table.rs | 117 +- src/auto/text_view.rs | 1019 ++++---------- src/auto/toggle_button.rs | 379 +----- src/auto/tree_drag_dest.rs | 22 +- src/auto/tree_drag_source.rs | 15 +- src/auto/tree_list_model.rs | 20 +- src/auto/tree_list_row.rs | 30 +- src/auto/tree_model.rs | 24 +- src/auto/tree_model_sort.rs | 11 + src/auto/tree_path.rs | 6 +- src/auto/tree_selection.rs | 172 +-- src/auto/tree_sortable.rs | 6 +- src/auto/tree_view.rs | 898 +++---------- src/auto/tree_view_column.rs | 865 ++++-------- src/auto/versions.txt | 4 +- src/auto/video.rs | 366 +---- src/auto/viewport.rs | 426 +----- src/auto/volume_button.rs | 451 +------ src/auto/widget.rs | 1933 ++++++--------------------- src/auto/widget_paintable.rs | 6 +- src/auto/window.rs | 1139 +++------------- src/auto/window_group.rs | 23 - 191 files changed, 13052 insertions(+), 54287 deletions(-) diff --git a/gir b/gir index 83cc9addf972..ad40c013c474 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit 83cc9addf972e5f413a02b5e5352f6b6d53b0eaa +Subproject commit ad40c013c4745a5a8ed311022d76e6385ff134b8 diff --git a/gir-files b/gir-files index 22748fa889ff..8a626fde7528 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 22748fa889ff60b97e53966c31693a73a6249f82 +Subproject commit 8a626fde7528ebb62a4d7902f201e483ca2ae05b diff --git a/src/auto/about_dialog.rs b/src/auto/about_dialog.rs index 08cd124cae18..851bff5b95f9 100644 --- a/src/auto/about_dialog.rs +++ b/src/auto/about_dialog.rs @@ -5,35 +5,27 @@ use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; -use Application; -use Bin; +use Accessible; use Buildable; -use Container; use Dialog; -use LayoutManager; use License; -use Overflow; use Root; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct AboutDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, Root; + pub struct AboutDialog(Object) @extends Dialog, Window, Widget, @implements Accessible, Buildable, Root; match fn { get_type => || gtk_sys::gtk_about_dialog_get_type(), @@ -45,1499 +37,679 @@ impl AboutDialog { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_about_dialog_new()).unsafe_cast() } } -} - -impl Default for AboutDialog { - fn default() -> Self { - Self::new() - } -} - -#[derive(Clone, Default)] -pub struct AboutDialogBuilder { - artists: Option>, - authors: Option>, - comments: Option, - copyright: Option, - documenters: Option>, - license: Option, - license_type: Option, - logo: Option, - logo_icon_name: Option, - program_name: Option, - system_information: Option, - translator_credits: Option, - version: Option, - website: Option, - website_label: Option, - wrap_license: Option, - use_header_bar: Option, - accept_focus: Option, - application: Option, - attached_to: Option, - decorated: Option, - default_height: Option, - default_widget: Option, - default_width: Option, - deletable: Option, - destroy_with_parent: Option, - display: Option, - focus_on_map: Option, - focus_visible: Option, - hide_on_close: Option, - icon_name: Option, - mnemonics_visible: Option, - modal: Option, - resizable: Option, - startup_id: Option, - title: Option, - transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - focus_widget: Option, -} - -impl AboutDialogBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> AboutDialog { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref artists) = self.artists { - properties.push(("artists", artists)); - } - if let Some(ref authors) = self.authors { - properties.push(("authors", authors)); - } - if let Some(ref comments) = self.comments { - properties.push(("comments", comments)); - } - if let Some(ref copyright) = self.copyright { - properties.push(("copyright", copyright)); - } - if let Some(ref documenters) = self.documenters { - properties.push(("documenters", documenters)); - } - if let Some(ref license) = self.license { - properties.push(("license", license)); - } - if let Some(ref license_type) = self.license_type { - properties.push(("license-type", license_type)); - } - if let Some(ref logo) = self.logo { - properties.push(("logo", logo)); - } - if let Some(ref logo_icon_name) = self.logo_icon_name { - properties.push(("logo-icon-name", logo_icon_name)); - } - if let Some(ref program_name) = self.program_name { - properties.push(("program-name", program_name)); - } - if let Some(ref system_information) = self.system_information { - properties.push(("system-information", system_information)); - } - if let Some(ref translator_credits) = self.translator_credits { - properties.push(("translator-credits", translator_credits)); - } - if let Some(ref version) = self.version { - properties.push(("version", version)); - } - if let Some(ref website) = self.website { - properties.push(("website", website)); - } - if let Some(ref website_label) = self.website_label { - properties.push(("website-label", website_label)); - } - if let Some(ref wrap_license) = self.wrap_license { - properties.push(("wrap-license", wrap_license)); - } - if let Some(ref use_header_bar) = self.use_header_bar { - properties.push(("use-header-bar", use_header_bar)); - } - if let Some(ref accept_focus) = self.accept_focus { - properties.push(("accept-focus", accept_focus)); - } - if let Some(ref application) = self.application { - properties.push(("application", application)); - } - if let Some(ref attached_to) = self.attached_to { - properties.push(("attached-to", attached_to)); - } - if let Some(ref decorated) = self.decorated { - properties.push(("decorated", decorated)); - } - if let Some(ref default_height) = self.default_height { - properties.push(("default-height", default_height)); - } - if let Some(ref default_widget) = self.default_widget { - properties.push(("default-widget", default_widget)); - } - if let Some(ref default_width) = self.default_width { - properties.push(("default-width", default_width)); - } - if let Some(ref deletable) = self.deletable { - properties.push(("deletable", deletable)); - } - if let Some(ref destroy_with_parent) = self.destroy_with_parent { - properties.push(("destroy-with-parent", destroy_with_parent)); - } - if let Some(ref display) = self.display { - properties.push(("display", display)); - } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } - if let Some(ref focus_visible) = self.focus_visible { - properties.push(("focus-visible", focus_visible)); - } - if let Some(ref hide_on_close) = self.hide_on_close { - properties.push(("hide-on-close", hide_on_close)); - } - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); - } - if let Some(ref mnemonics_visible) = self.mnemonics_visible { - properties.push(("mnemonics-visible", mnemonics_visible)); - } - if let Some(ref modal) = self.modal { - properties.push(("modal", modal)); - } - if let Some(ref resizable) = self.resizable { - properties.push(("resizable", resizable)); - } - if let Some(ref startup_id) = self.startup_id { - properties.push(("startup-id", startup_id)); - } - if let Some(ref title) = self.title { - properties.push(("title", title)); - } - if let Some(ref transient_for) = self.transient_for { - properties.push(("transient-for", transient_for)); - } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); - } - glib::Object::new(AboutDialog::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn artists(mut self, artists: Vec) -> Self { - self.artists = Some(artists); - self - } - - pub fn authors(mut self, authors: Vec) -> Self { - self.authors = Some(authors); - self - } - - pub fn comments(mut self, comments: &str) -> Self { - self.comments = Some(comments.to_string()); - self - } - - pub fn copyright(mut self, copyright: &str) -> Self { - self.copyright = Some(copyright.to_string()); - self - } - - pub fn documenters(mut self, documenters: Vec) -> Self { - self.documenters = Some(documenters); - self - } - - pub fn license(mut self, license: &str) -> Self { - self.license = Some(license.to_string()); - self - } - - pub fn license_type(mut self, license_type: License) -> Self { - self.license_type = Some(license_type); - self - } - - pub fn logo>(mut self, logo: &P) -> Self { - self.logo = Some(logo.clone().upcast()); - self - } - - pub fn logo_icon_name(mut self, logo_icon_name: &str) -> Self { - self.logo_icon_name = Some(logo_icon_name.to_string()); - self - } - - pub fn program_name(mut self, program_name: &str) -> Self { - self.program_name = Some(program_name.to_string()); - self - } - - pub fn system_information(mut self, system_information: &str) -> Self { - self.system_information = Some(system_information.to_string()); - self - } - - pub fn translator_credits(mut self, translator_credits: &str) -> Self { - self.translator_credits = Some(translator_credits.to_string()); - self - } - - pub fn version(mut self, version: &str) -> Self { - self.version = Some(version.to_string()); - self - } - - pub fn website(mut self, website: &str) -> Self { - self.website = Some(website.to_string()); - self - } - - pub fn website_label(mut self, website_label: &str) -> Self { - self.website_label = Some(website_label.to_string()); - self - } - - pub fn wrap_license(mut self, wrap_license: bool) -> Self { - self.wrap_license = Some(wrap_license); - self - } - - pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { - self.use_header_bar = Some(use_header_bar); - self - } - - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - - pub fn application>(mut self, application: &P) -> Self { - self.application = Some(application.clone().upcast()); - self - } - - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); - self - } - - pub fn decorated(mut self, decorated: bool) -> Self { - self.decorated = Some(decorated); - self - } - - pub fn default_height(mut self, default_height: i32) -> Self { - self.default_height = Some(default_height); - self - } - - pub fn default_widget>(mut self, default_widget: &P) -> Self { - self.default_widget = Some(default_widget.clone().upcast()); - self - } - - pub fn default_width(mut self, default_width: i32) -> Self { - self.default_width = Some(default_width); - self - } - - pub fn deletable(mut self, deletable: bool) -> Self { - self.deletable = Some(deletable); - self - } - - pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { - self.destroy_with_parent = Some(destroy_with_parent); - self - } - - pub fn display(mut self, display: &gdk::Display) -> Self { - self.display = Some(display.clone()); - self - } - - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); - self - } - - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); - self - } - - pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { - self.hide_on_close = Some(hide_on_close); - self - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { - self.mnemonics_visible = Some(mnemonics_visible); - self - } - - pub fn modal(mut self, modal: bool) -> Self { - self.modal = Some(modal); - self - } - - pub fn resizable(mut self, resizable: bool) -> Self { - self.resizable = Some(resizable); - self - } - - pub fn startup_id(mut self, startup_id: &str) -> Self { - self.startup_id = Some(startup_id.to_string()); - self - } - - pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); - self - } - - pub fn transient_for>(mut self, transient_for: &P) -> Self { - self.transient_for = Some(transient_for.clone().upcast()); - self - } - - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); - self - } -} - -pub const NONE_ABOUT_DIALOG: Option<&AboutDialog> = None; - -pub trait AboutDialogExt: 'static { - fn add_credit_section(&self, section_name: &str, people: &[&str]); - - fn get_artists(&self) -> Vec; - - fn get_authors(&self) -> Vec; - - fn get_comments(&self) -> Option; - - fn get_copyright(&self) -> Option; - - fn get_documenters(&self) -> Vec; - - fn get_license(&self) -> Option; - - fn get_license_type(&self) -> License; - - fn get_logo(&self) -> Option; - - fn get_logo_icon_name(&self) -> Option; - - fn get_program_name(&self) -> Option; - - fn get_system_information(&self) -> Option; - - fn get_translator_credits(&self) -> Option; - - fn get_version(&self) -> Option; - - fn get_website(&self) -> Option; - - fn get_website_label(&self) -> Option; - - fn get_wrap_license(&self) -> bool; - - fn set_artists(&self, artists: &[&str]); - - fn set_authors(&self, authors: &[&str]); - - fn set_comments(&self, comments: Option<&str>); - - fn set_copyright(&self, copyright: Option<&str>); - - fn set_documenters(&self, documenters: &[&str]); - - fn set_license(&self, license: Option<&str>); - - fn set_license_type(&self, license_type: License); - - fn set_logo>(&self, logo: Option<&P>); - - fn set_logo_icon_name(&self, icon_name: Option<&str>); - - fn set_program_name(&self, name: &str); - - fn set_system_information(&self, system_information: Option<&str>); - - fn set_translator_credits(&self, translator_credits: Option<&str>); - - fn set_version(&self, version: Option<&str>); - - fn set_website(&self, website: Option<&str>); - - fn set_website_label(&self, website_label: &str); - - fn set_wrap_license(&self, wrap_license: bool); - - fn connect_activate_link glib::signal::Inhibit + 'static>( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_artists_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_authors_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_comments_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_copyright_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_documenters_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_license_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_license_type_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_logo_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_logo_icon_name_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_program_name_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_system_information_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_translator_credits_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_version_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_website_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_website_label_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_wrap_license_notify(&self, f: F) - -> SignalHandlerId; -} - -impl> AboutDialogExt for O { - fn add_credit_section(&self, section_name: &str, people: &[&str]) { + pub fn add_credit_section(&self, section_name: &str, people: &[&str]) { unsafe { gtk_sys::gtk_about_dialog_add_credit_section( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, section_name.to_glib_none().0, people.to_glib_none().0, ); } } - fn get_artists(&self) -> Vec { + pub fn get_artists(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_artists( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_authors(&self) -> Vec { + pub fn get_authors(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_authors( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_comments(&self) -> Option { + pub fn get_comments(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_comments( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_copyright(&self) -> Option { + pub fn get_copyright(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_copyright( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_documenters(&self) -> Vec { + pub fn get_documenters(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_documenters( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_license(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_license( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_license(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_license(self.to_glib_none().0)) } } - fn get_license_type(&self) -> License { + pub fn get_license_type(&self) -> License { unsafe { from_glib(gtk_sys::gtk_about_dialog_get_license_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_logo(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_logo( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_logo(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_logo(self.to_glib_none().0)) } } - fn get_logo_icon_name(&self) -> Option { + pub fn get_logo_icon_name(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_logo_icon_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_program_name(&self) -> Option { + pub fn get_program_name(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_program_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_system_information(&self) -> Option { + pub fn get_system_information(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_system_information( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_translator_credits(&self) -> Option { + pub fn get_translator_credits(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_translator_credits( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_version(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_version( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_version(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_version(self.to_glib_none().0)) } } - fn get_website(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_website( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_website(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_website(self.to_glib_none().0)) } } - fn get_website_label(&self) -> Option { + pub fn get_website_label(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_website_label( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_wrap_license(&self) -> bool { + pub fn get_wrap_license(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_about_dialog_get_wrap_license( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn set_artists(&self, artists: &[&str]) { + pub fn set_artists(&self, artists: &[&str]) { unsafe { - gtk_sys::gtk_about_dialog_set_artists( - self.as_ref().to_glib_none().0, - artists.to_glib_none().0, - ); + gtk_sys::gtk_about_dialog_set_artists(self.to_glib_none().0, artists.to_glib_none().0); } } - fn set_authors(&self, authors: &[&str]) { + pub fn set_authors(&self, authors: &[&str]) { unsafe { - gtk_sys::gtk_about_dialog_set_authors( - self.as_ref().to_glib_none().0, - authors.to_glib_none().0, - ); + gtk_sys::gtk_about_dialog_set_authors(self.to_glib_none().0, authors.to_glib_none().0); } } - fn set_comments(&self, comments: Option<&str>) { + pub fn set_comments(&self, comments: Option<&str>) { unsafe { gtk_sys::gtk_about_dialog_set_comments( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, comments.to_glib_none().0, ); } } - fn set_copyright(&self, copyright: Option<&str>) { + pub fn set_copyright(&self, copyright: Option<&str>) { unsafe { gtk_sys::gtk_about_dialog_set_copyright( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, copyright.to_glib_none().0, ); } } - fn set_documenters(&self, documenters: &[&str]) { + pub fn set_documenters(&self, documenters: &[&str]) { unsafe { gtk_sys::gtk_about_dialog_set_documenters( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, documenters.to_glib_none().0, ); } } - fn set_license(&self, license: Option<&str>) { + pub fn set_license(&self, license: Option<&str>) { unsafe { - gtk_sys::gtk_about_dialog_set_license( - self.as_ref().to_glib_none().0, - license.to_glib_none().0, - ); + gtk_sys::gtk_about_dialog_set_license(self.to_glib_none().0, license.to_glib_none().0); } } - fn set_license_type(&self, license_type: License) { + pub fn set_license_type(&self, license_type: License) { unsafe { gtk_sys::gtk_about_dialog_set_license_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, license_type.to_glib(), ); } } - fn set_logo>(&self, logo: Option<&P>) { + pub fn set_logo>(&self, logo: Option<&P>) { unsafe { gtk_sys::gtk_about_dialog_set_logo( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, logo.map(|p| p.as_ref()).to_glib_none().0, ); } } - fn set_logo_icon_name(&self, icon_name: Option<&str>) { + pub fn set_logo_icon_name(&self, icon_name: Option<&str>) { unsafe { gtk_sys::gtk_about_dialog_set_logo_icon_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, icon_name.to_glib_none().0, ); } } - fn set_program_name(&self, name: &str) { + pub fn set_program_name(&self, name: &str) { unsafe { gtk_sys::gtk_about_dialog_set_program_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, name.to_glib_none().0, ); } } - fn set_system_information(&self, system_information: Option<&str>) { + pub fn set_system_information(&self, system_information: Option<&str>) { unsafe { gtk_sys::gtk_about_dialog_set_system_information( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, system_information.to_glib_none().0, ); } } - fn set_translator_credits(&self, translator_credits: Option<&str>) { + pub fn set_translator_credits(&self, translator_credits: Option<&str>) { unsafe { gtk_sys::gtk_about_dialog_set_translator_credits( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, translator_credits.to_glib_none().0, ); } } - fn set_version(&self, version: Option<&str>) { + pub fn set_version(&self, version: Option<&str>) { unsafe { - gtk_sys::gtk_about_dialog_set_version( - self.as_ref().to_glib_none().0, - version.to_glib_none().0, - ); + gtk_sys::gtk_about_dialog_set_version(self.to_glib_none().0, version.to_glib_none().0); } } - fn set_website(&self, website: Option<&str>) { + pub fn set_website(&self, website: Option<&str>) { unsafe { - gtk_sys::gtk_about_dialog_set_website( - self.as_ref().to_glib_none().0, - website.to_glib_none().0, - ); + gtk_sys::gtk_about_dialog_set_website(self.to_glib_none().0, website.to_glib_none().0); } } - fn set_website_label(&self, website_label: &str) { + pub fn set_website_label(&self, website_label: &str) { unsafe { gtk_sys::gtk_about_dialog_set_website_label( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, website_label.to_glib_none().0, ); } } - fn set_wrap_license(&self, wrap_license: bool) { + pub fn set_wrap_license(&self, wrap_license: bool) { unsafe { gtk_sys::gtk_about_dialog_set_wrap_license( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, wrap_license.to_glib(), ); } } - fn connect_activate_link glib::signal::Inhibit + 'static>( + pub fn connect_activate_link glib::signal::Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn activate_link_trampoline< - P, - F: Fn(&P, &str) -> glib::signal::Inhibit + 'static, + F: Fn(&AboutDialog, &str) -> glib::signal::Inhibit + 'static, >( this: *mut gtk_sys::GtkAboutDialog, uri: *mut libc::c_char, f: glib_sys::gpointer, - ) -> glib_sys::gboolean - where - P: IsA, - { + ) -> glib_sys::gboolean { let f: &F = &*(f as *const F); - f( - &AboutDialog::from_glib_borrow(this).unsafe_cast(), - &GString::from_glib_borrow(uri), - ) - .to_glib() + f(&from_glib_borrow(this), &GString::from_glib_borrow(uri)).to_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"activate-link\0".as_ptr() as *const _, - Some(transmute(activate_link_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + activate_link_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_artists_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_artists_trampoline( + pub fn connect_property_artists_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_artists_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::artists\0".as_ptr() as *const _, - Some(transmute(notify_artists_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_artists_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_authors_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_authors_trampoline( + pub fn connect_property_authors_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_authors_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::authors\0".as_ptr() as *const _, - Some(transmute(notify_authors_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_authors_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_comments_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_comments_trampoline( + pub fn connect_property_comments_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_comments_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::comments\0".as_ptr() as *const _, - Some(transmute(notify_comments_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_comments_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_copyright_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_copyright_trampoline( + pub fn connect_property_copyright_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_copyright_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::copyright\0".as_ptr() as *const _, - Some(transmute(notify_copyright_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_copyright_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_documenters_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_documenters_trampoline( + pub fn connect_property_documenters_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_documenters_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::documenters\0".as_ptr() as *const _, - Some(transmute(notify_documenters_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_documenters_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_license_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_license_trampoline( + pub fn connect_property_license_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_license_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::license\0".as_ptr() as *const _, - Some(transmute(notify_license_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_license_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_license_type_notify( + pub fn connect_property_license_type_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_license_type_trampoline( + unsafe extern "C" fn notify_license_type_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::license-type\0".as_ptr() as *const _, - Some(transmute( - notify_license_type_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_license_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_logo_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_logo_trampoline( + pub fn connect_property_logo_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_logo_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::logo\0".as_ptr() as *const _, - Some(transmute(notify_logo_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_logo_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_logo_icon_name_notify( + pub fn connect_property_logo_icon_name_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_logo_icon_name_trampoline( + unsafe extern "C" fn notify_logo_icon_name_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::logo-icon-name\0".as_ptr() as *const _, - Some(transmute( - notify_logo_icon_name_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_logo_icon_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_program_name_notify( + pub fn connect_property_program_name_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_program_name_trampoline( + unsafe extern "C" fn notify_program_name_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::program-name\0".as_ptr() as *const _, - Some(transmute( - notify_program_name_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_program_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_system_information_notify( + pub fn connect_property_system_information_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_system_information_trampoline( + unsafe extern "C" fn notify_system_information_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::system-information\0".as_ptr() as *const _, - Some(transmute( - notify_system_information_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_system_information_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_translator_credits_notify( + pub fn connect_property_translator_credits_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_translator_credits_trampoline( + unsafe extern "C" fn notify_translator_credits_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::translator-credits\0".as_ptr() as *const _, - Some(transmute( - notify_translator_credits_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_translator_credits_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_version_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_version_trampoline( + pub fn connect_property_version_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_version_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::version\0".as_ptr() as *const _, - Some(transmute(notify_version_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_version_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_website_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_website_trampoline( + pub fn connect_property_website_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_website_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::website\0".as_ptr() as *const _, - Some(transmute(notify_website_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_website_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_website_label_notify( + pub fn connect_property_website_label_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_website_label_trampoline( + unsafe extern "C" fn notify_website_label_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::website-label\0".as_ptr() as *const _, - Some(transmute( - notify_website_label_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_website_label_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_wrap_license_notify( + pub fn connect_property_wrap_license_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_wrap_license_trampoline( + unsafe extern "C" fn notify_wrap_license_trampoline( this: *mut gtk_sys::GtkAboutDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::wrap-license\0".as_ptr() as *const _, - Some(transmute( - notify_wrap_license_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_wrap_license_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -1545,6 +717,12 @@ impl> AboutDialogExt for O { } } +impl Default for AboutDialog { + fn default() -> Self { + Self::new() + } +} + impl fmt::Display for AboutDialog { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AboutDialog") diff --git a/src/auto/accel_label.rs b/src/auto/accel_label.rs index 720ea0ec2a8e..909c84190763 100644 --- a/src/auto/accel_label.rs +++ b/src/auto/accel_label.rs @@ -3,31 +3,24 @@ // DO NOT EDIT use gdk; -use glib; use glib::object::Cast; -use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use glib::StaticType; -use glib::ToValue; -use glib::Value; use glib_sys; -use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; -use Align; +use Accessible; use Buildable; -use LayoutManager; -use Overflow; use Widget; glib_wrapper! { - pub struct AccelLabel(Object) @extends Widget, @implements Buildable; + pub struct AccelLabel(Object) @extends Widget, @implements Accessible, Buildable; match fn { get_type => || gtk_sys::gtk_accel_label_get_type(), @@ -42,391 +35,13 @@ impl AccelLabel { .unsafe_cast() } } -} - -#[derive(Clone, Default)] -pub struct AccelLabelBuilder { - accel_closure: Option, - accel_widget: Option, - label: Option, - use_underline: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, -} - -impl AccelLabelBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> AccelLabel { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref accel_closure) = self.accel_closure { - properties.push(("accel-closure", accel_closure)); - } - if let Some(ref accel_widget) = self.accel_widget { - properties.push(("accel-widget", accel_widget)); - } - if let Some(ref label) = self.label { - properties.push(("label", label)); - } - if let Some(ref use_underline) = self.use_underline { - properties.push(("use-underline", use_underline)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - glib::Object::new(AccelLabel::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn accel_closure(mut self, accel_closure: &glib::Closure) -> Self { - self.accel_closure = Some(accel_closure.clone()); - self - } - - pub fn accel_widget>(mut self, accel_widget: &P) -> Self { - self.accel_widget = Some(accel_widget.clone().upcast()); - self - } - - pub fn label(mut self, label: &str) -> Self { - self.label = Some(label.to_string()); - self - } - - pub fn use_underline(mut self, use_underline: bool) -> Self { - self.use_underline = Some(use_underline); - self - } - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } -} - -pub const NONE_ACCEL_LABEL: Option<&AccelLabel> = None; - -pub trait AccelLabelExt: 'static { - fn get_accel(&self) -> (u32, gdk::ModifierType); - - fn get_accel_widget(&self) -> Option; - - fn get_accel_width(&self) -> u32; - - fn get_label(&self) -> Option; - - fn get_use_underline(&self) -> bool; - - fn refetch(&self) -> bool; - - fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType); - - fn set_accel_closure(&self, accel_closure: Option<&glib::Closure>); - - fn set_accel_widget>(&self, accel_widget: Option<&P>); - - fn set_label(&self, text: &str); - - fn set_use_underline(&self, setting: bool); - - fn get_property_accel_closure(&self) -> Option; - - fn connect_property_accel_closure_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_accel_widget_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_label_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_use_underline_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AccelLabelExt for O { - fn get_accel(&self) -> (u32, gdk::ModifierType) { + pub fn get_accel(&self) -> (u32, gdk::ModifierType) { unsafe { let mut accelerator_key = mem::MaybeUninit::uninit(); let mut accelerator_mods = mem::MaybeUninit::uninit(); gtk_sys::gtk_accel_label_get_accel( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, accelerator_key.as_mut_ptr(), accelerator_mods.as_mut_ptr(), ); @@ -436,199 +51,92 @@ impl> AccelLabelExt for O { } } - fn get_accel_widget(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_accel_label_get_accel_widget( - self.as_ref().to_glib_none().0, - )) - } - } - - fn get_accel_width(&self) -> u32 { - unsafe { gtk_sys::gtk_accel_label_get_accel_width(self.as_ref().to_glib_none().0) } + pub fn get_accel_width(&self) -> u32 { + unsafe { gtk_sys::gtk_accel_label_get_accel_width(self.to_glib_none().0) } } - fn get_label(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_accel_label_get_label( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_label(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_accel_label_get_label(self.to_glib_none().0)) } } - fn get_use_underline(&self) -> bool { + pub fn get_use_underline(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_accel_label_get_use_underline( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn refetch(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_accel_label_refetch( - self.as_ref().to_glib_none().0, - )) - } + pub fn refetch(&self) -> bool { + unsafe { from_glib(gtk_sys::gtk_accel_label_refetch(self.to_glib_none().0)) } } - fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType) { + pub fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType) { unsafe { gtk_sys::gtk_accel_label_set_accel( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, accelerator_key, accelerator_mods.to_glib(), ); } } - fn set_accel_closure(&self, accel_closure: Option<&glib::Closure>) { - unsafe { - gtk_sys::gtk_accel_label_set_accel_closure( - self.as_ref().to_glib_none().0, - accel_closure.to_glib_none().0, - ); - } - } - - fn set_accel_widget>(&self, accel_widget: Option<&P>) { + pub fn set_label(&self, text: &str) { unsafe { - gtk_sys::gtk_accel_label_set_accel_widget( - self.as_ref().to_glib_none().0, - accel_widget.map(|p| p.as_ref()).to_glib_none().0, - ); + gtk_sys::gtk_accel_label_set_label(self.to_glib_none().0, text.to_glib_none().0); } } - fn set_label(&self, text: &str) { + pub fn set_use_underline(&self, setting: bool) { unsafe { - gtk_sys::gtk_accel_label_set_label( - self.as_ref().to_glib_none().0, - text.to_glib_none().0, - ); + gtk_sys::gtk_accel_label_set_use_underline(self.to_glib_none().0, setting.to_glib()); } } - fn set_use_underline(&self, setting: bool) { - unsafe { - gtk_sys::gtk_accel_label_set_use_underline( - self.as_ref().to_glib_none().0, - setting.to_glib(), - ); - } - } - - fn get_property_accel_closure(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"accel-closure\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `accel-closure` getter") - } - } - - fn connect_property_accel_closure_notify( + pub fn connect_property_label_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_accel_closure_trampoline( + unsafe extern "C" fn notify_label_trampoline( this: *mut gtk_sys::GtkAccelLabel, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::accel-closure\0".as_ptr() as *const _, - Some(transmute( - notify_accel_closure_trampoline:: as usize, - )), - Box_::into_raw(f), - ) - } - } - - fn connect_property_accel_widget_notify( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn notify_accel_widget_trampoline( - this: *mut gtk_sys::GtkAccelLabel, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::accel-widget\0".as_ptr() as *const _, - Some(transmute( - notify_accel_widget_trampoline:: as usize, - )), - Box_::into_raw(f), - ) - } - } - - fn connect_property_label_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_label_trampoline( - this: *mut gtk_sys::GtkAccelLabel, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::label\0".as_ptr() as *const _, - Some(transmute(notify_label_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_label_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_use_underline_notify( + pub fn connect_property_use_underline_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_use_underline_trampoline( + unsafe extern "C" fn notify_use_underline_trampoline( this: *mut gtk_sys::GtkAccelLabel, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::use-underline\0".as_ptr() as *const _, - Some(transmute( - notify_use_underline_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_use_underline_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/accessible.rs b/src/auto/accessible.rs index a765a4e49a8e..fb7b261461ed 100644 --- a/src/auto/accessible.rs +++ b/src/auto/accessible.rs @@ -2,7 +2,6 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use atk; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; @@ -13,10 +12,9 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Widget; glib_wrapper! { - pub struct Accessible(Object) @extends atk::Object; + pub struct Accessible(Interface); match fn { get_type => || gtk_sys::gtk_accessible_get_type(), @@ -26,33 +24,86 @@ glib_wrapper! { pub const NONE_ACCESSIBLE: Option<&Accessible> = None; pub trait AccessibleExt: 'static { - fn get_widget(&self) -> Option; + //fn get_accessible_role(&self) -> /*Ignored*/AccessibleRole; - fn set_widget>(&self, widget: Option<&P>); + //fn reset_property(&self, property: /*Ignored*/AccessibleProperty); - fn connect_property_widget_notify(&self, f: F) -> SignalHandlerId; + //fn reset_relation(&self, relation: /*Ignored*/AccessibleRelation); + + //fn reset_state(&self, state: /*Ignored*/AccessibleState); + + //fn update_property(&self, first_property: /*Ignored*/AccessibleProperty, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + //fn update_property_value(&self, property: /*Ignored*/AccessibleProperty, value: &glib::Value); + + //fn update_relation(&self, first_relation: /*Ignored*/AccessibleRelation, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + //fn update_relation_value(&self, relation: /*Ignored*/AccessibleRelation, value: &glib::Value); + + //fn update_state(&self, first_state: /*Ignored*/AccessibleState, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + //fn update_state_value(&self, state: /*Ignored*/AccessibleState, value: &glib::Value); + + //fn set_property_accessible_role(&self, accessible_role: /*Ignored*/AccessibleRole); + + fn connect_property_accessible_role_notify( + &self, + f: F, + ) -> SignalHandlerId; } impl> AccessibleExt for O { - fn get_widget(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_accessible_get_widget( - self.as_ref().to_glib_none().0, - )) - } - } + //fn get_accessible_role(&self) -> /*Ignored*/AccessibleRole { + // unsafe { TODO: call gtk_sys:gtk_accessible_get_accessible_role() } + //} - fn set_widget>(&self, widget: Option<&P>) { - unsafe { - gtk_sys::gtk_accessible_set_widget( - self.as_ref().to_glib_none().0, - widget.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } + //fn reset_property(&self, property: /*Ignored*/AccessibleProperty) { + // unsafe { TODO: call gtk_sys:gtk_accessible_reset_property() } + //} + + //fn reset_relation(&self, relation: /*Ignored*/AccessibleRelation) { + // unsafe { TODO: call gtk_sys:gtk_accessible_reset_relation() } + //} + + //fn reset_state(&self, state: /*Ignored*/AccessibleState) { + // unsafe { TODO: call gtk_sys:gtk_accessible_reset_state() } + //} + + //fn update_property(&self, first_property: /*Ignored*/AccessibleProperty, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_property() } + //} + + //fn update_property_value(&self, property: /*Ignored*/AccessibleProperty, value: &glib::Value) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_property_value() } + //} + + //fn update_relation(&self, first_relation: /*Ignored*/AccessibleRelation, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_relation() } + //} + + //fn update_relation_value(&self, relation: /*Ignored*/AccessibleRelation, value: &glib::Value) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_relation_value() } + //} + + //fn update_state(&self, first_state: /*Ignored*/AccessibleState, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_state() } + //} + + //fn update_state_value(&self, state: /*Ignored*/AccessibleState, value: &glib::Value) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_state_value() } + //} + + //fn set_property_accessible_role(&self, accessible_role: /*Ignored*/AccessibleRole) { + // unsafe { + // gobject_sys::g_object_set_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"accessible-role\0".as_ptr() as *const _, Value::from(&accessible_role).to_glib_none().0); + // } + //} - fn connect_property_widget_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_widget_trampoline( + fn connect_property_accessible_role_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_accessible_role_trampoline( this: *mut gtk_sys::GtkAccessible, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, @@ -60,14 +111,16 @@ impl> AccessibleExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Accessible::from_glib_borrow(this).unsafe_cast()) + f(&Accessible::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, - b"notify::widget\0".as_ptr() as *const _, - Some(transmute(notify_widget_trampoline:: as usize)), + b"notify::accessible-role\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_accessible_role_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/action_bar.rs b/src/auto/action_bar.rs index 95c6b61cf8d4..eb188bef8090 100644 --- a/src/auto/action_bar.rs +++ b/src/auto/action_bar.rs @@ -2,28 +2,23 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use Buildable; -use Container; -use LayoutManager; -use Overflow; use Widget; glib_wrapper! { - pub struct ActionBar(Object) @extends Container, Widget, @implements Buildable; + pub struct ActionBar(Object) @extends Widget, @implements Accessible, Buildable; match fn { get_type => || gtk_sys::gtk_action_bar_get_type(), @@ -35,414 +30,90 @@ impl ActionBar { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_action_bar_new()).unsafe_cast() } } -} - -impl Default for ActionBar { - fn default() -> Self { - Self::new() - } -} - -#[derive(Clone, Default)] -pub struct ActionBarBuilder { - revealed: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, -} - -impl ActionBarBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> ActionBar { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref revealed) = self.revealed { - properties.push(("revealed", revealed)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - glib::Object::new(ActionBar::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn revealed(mut self, revealed: bool) -> Self { - self.revealed = Some(revealed); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } -} - -pub const NONE_ACTION_BAR: Option<&ActionBar> = None; - -pub trait ActionBarExt: 'static { - fn get_center_widget(&self) -> Option; - - fn get_revealed(&self) -> bool; - - fn pack_end>(&self, child: &P); - - fn pack_start>(&self, child: &P); - - fn set_center_widget>(&self, center_widget: Option<&P>); - - fn set_revealed(&self, revealed: bool); - - fn connect_property_revealed_notify(&self, f: F) -> SignalHandlerId; -} - -impl> ActionBarExt for O { - fn get_center_widget(&self) -> Option { + pub fn get_center_widget(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_action_bar_get_center_widget( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_revealed(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_action_bar_get_revealed( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_revealed(&self) -> bool { + unsafe { from_glib(gtk_sys::gtk_action_bar_get_revealed(self.to_glib_none().0)) } } - fn pack_end>(&self, child: &P) { + pub fn pack_end>(&self, child: &P) { unsafe { gtk_sys::gtk_action_bar_pack_end( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, child.as_ref().to_glib_none().0, ); } } - fn pack_start>(&self, child: &P) { + pub fn pack_start>(&self, child: &P) { unsafe { gtk_sys::gtk_action_bar_pack_start( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, child.as_ref().to_glib_none().0, ); } } - fn set_center_widget>(&self, center_widget: Option<&P>) { + pub fn remove>(&self, child: &P) { + unsafe { + gtk_sys::gtk_action_bar_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0); + } + } + + pub fn set_center_widget>(&self, center_widget: Option<&P>) { unsafe { gtk_sys::gtk_action_bar_set_center_widget( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, center_widget.map(|p| p.as_ref()).to_glib_none().0, ); } } - fn set_revealed(&self, revealed: bool) { + pub fn set_revealed(&self, revealed: bool) { unsafe { - gtk_sys::gtk_action_bar_set_revealed( - self.as_ref().to_glib_none().0, - revealed.to_glib(), - ); + gtk_sys::gtk_action_bar_set_revealed(self.to_glib_none().0, revealed.to_glib()); } } - fn connect_property_revealed_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_revealed_trampoline( + pub fn connect_property_revealed_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_revealed_trampoline( this: *mut gtk_sys::GtkActionBar, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&ActionBar::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::revealed\0".as_ptr() as *const _, - Some(transmute(notify_revealed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_revealed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } } +impl Default for ActionBar { + fn default() -> Self { + Self::new() + } +} + impl fmt::Display for ActionBar { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ActionBar") diff --git a/src/auto/actionable.rs b/src/auto/actionable.rs index aeea7a82e1da..75e81604d873 100644 --- a/src/auto/actionable.rs +++ b/src/auto/actionable.rs @@ -14,11 +14,12 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; use Buildable; use Widget; glib_wrapper! { - pub struct Actionable(Interface) @requires Widget, Buildable; + pub struct Actionable(Interface) @requires Widget, Accessible, Buildable; match fn { get_type => || gtk_sys::gtk_actionable_get_type(), @@ -100,14 +101,16 @@ impl> ActionableExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Actionable::from_glib_borrow(this).unsafe_cast()) + f(&Actionable::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::action-name\0".as_ptr() as *const _, - Some(transmute(notify_action_name_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_action_name_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/adjustment.rs b/src/auto/adjustment.rs index 4ad1c6baf549..a21e7806d134 100644 --- a/src/auto/adjustment.rs +++ b/src/auto/adjustment.rs @@ -215,14 +215,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, - Some(transmute(changed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + changed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -236,14 +238,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"value-changed\0".as_ptr() as *const _, - Some(transmute(value_changed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + value_changed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -258,14 +262,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::lower\0".as_ptr() as *const _, - Some(transmute(notify_lower_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_lower_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -283,15 +289,15 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::page-increment\0".as_ptr() as *const _, - Some(transmute( - notify_page_increment_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_increment_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -307,14 +313,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::page-size\0".as_ptr() as *const _, - Some(transmute(notify_page_size_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_size_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -332,15 +340,15 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::step-increment\0".as_ptr() as *const _, - Some(transmute( - notify_step_increment_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_step_increment_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -356,14 +364,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::upper\0".as_ptr() as *const _, - Some(transmute(notify_upper_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_upper_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -378,14 +388,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::value\0".as_ptr() as *const _, - Some(transmute(notify_value_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_value_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/app_chooser.rs b/src/auto/app_chooser.rs index 400ba4eae08a..dad543bf8d92 100644 --- a/src/auto/app_chooser.rs +++ b/src/auto/app_chooser.rs @@ -8,11 +8,12 @@ use glib::translate::*; use glib::GString; use gtk_sys; use std::fmt; +use Accessible; use Buildable; use Widget; glib_wrapper! { - pub struct AppChooser(Interface) @requires Widget, Buildable; + pub struct AppChooser(Interface) @requires Widget, Accessible, Buildable; match fn { get_type => || gtk_sys::gtk_app_chooser_get_type(), diff --git a/src/auto/app_chooser_button.rs b/src/auto/app_chooser_button.rs index ae458a49ebe4..ead2cf7aef49 100644 --- a/src/auto/app_chooser_button.rs +++ b/src/auto/app_chooser_button.rs @@ -2,31 +2,27 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use gio; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use AppChooser; use Buildable; -use LayoutManager; -use Overflow; use Widget; glib_wrapper! { - pub struct AppChooserButton(Object) @extends Widget, @implements Buildable, AppChooser; + pub struct AppChooserButton(Object) @extends Widget, @implements Accessible, Buildable, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_button_get_type(), @@ -43,384 +39,11 @@ impl AppChooserButton { .unsafe_cast() } } -} - -#[derive(Clone, Default)] -pub struct AppChooserButtonBuilder { - heading: Option, - show_default_item: Option, - show_dialog_item: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - content_type: Option, -} - -impl AppChooserButtonBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> AppChooserButton { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref heading) = self.heading { - properties.push(("heading", heading)); - } - if let Some(ref show_default_item) = self.show_default_item { - properties.push(("show-default-item", show_default_item)); - } - if let Some(ref show_dialog_item) = self.show_dialog_item { - properties.push(("show-dialog-item", show_dialog_item)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref content_type) = self.content_type { - properties.push(("content-type", content_type)); - } - glib::Object::new(AppChooserButton::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn heading(mut self, heading: &str) -> Self { - self.heading = Some(heading.to_string()); - self - } - - pub fn show_default_item(mut self, show_default_item: bool) -> Self { - self.show_default_item = Some(show_default_item); - self - } - - pub fn show_dialog_item(mut self, show_dialog_item: bool) -> Self { - self.show_dialog_item = Some(show_dialog_item); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn content_type(mut self, content_type: &str) -> Self { - self.content_type = Some(content_type.to_string()); - self - } -} - -pub const NONE_APP_CHOOSER_BUTTON: Option<&AppChooserButton> = None; - -pub trait AppChooserButtonExt: 'static { - fn append_custom_item>(&self, name: &str, label: &str, icon: &P); - - fn append_separator(&self); - - fn get_heading(&self) -> Option; - - fn get_show_default_item(&self) -> bool; - - fn get_show_dialog_item(&self) -> bool; - - fn set_active_custom_item(&self, name: &str); - - fn set_heading(&self, heading: &str); - - fn set_show_default_item(&self, setting: bool); - - fn set_show_dialog_item(&self, setting: bool); - - fn connect_changed(&self, f: F) -> SignalHandlerId; - - fn connect_custom_item_activated(&self, f: F) -> SignalHandlerId; - - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_default_item_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_show_dialog_item_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AppChooserButtonExt for O { - fn append_custom_item>(&self, name: &str, label: &str, icon: &P) { + pub fn append_custom_item>(&self, name: &str, label: &str, icon: &P) { unsafe { gtk_sys::gtk_app_chooser_button_append_custom_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, name.to_glib_none().0, label.to_glib_none().0, icon.as_ref().to_glib_none().0, @@ -428,104 +51,121 @@ impl> AppChooserButtonExt for O { } } - fn append_separator(&self) { + pub fn append_separator(&self) { unsafe { - gtk_sys::gtk_app_chooser_button_append_separator(self.as_ref().to_glib_none().0); + gtk_sys::gtk_app_chooser_button_append_separator(self.to_glib_none().0); } } - fn get_heading(&self) -> Option { + pub fn get_heading(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_app_chooser_button_get_heading( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_default_item(&self) -> bool { + pub fn get_modal(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_button_get_modal( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_default_item(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_button_get_show_default_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_dialog_item(&self) -> bool { + pub fn get_show_dialog_item(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_button_get_show_dialog_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn set_active_custom_item(&self, name: &str) { + pub fn set_active_custom_item(&self, name: &str) { unsafe { gtk_sys::gtk_app_chooser_button_set_active_custom_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, name.to_glib_none().0, ); } } - fn set_heading(&self, heading: &str) { + pub fn set_heading(&self, heading: &str) { unsafe { gtk_sys::gtk_app_chooser_button_set_heading( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, heading.to_glib_none().0, ); } } - fn set_show_default_item(&self, setting: bool) { + pub fn set_modal(&self, modal: bool) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_modal(self.to_glib_none().0, modal.to_glib()); + } + } + + pub fn set_show_default_item(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_button_set_show_default_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn set_show_dialog_item(&self, setting: bool) { + pub fn set_show_dialog_item(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_button_set_show_dialog_item( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn connect_changed(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn changed_trampoline( + pub fn connect_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn changed_trampoline( this: *mut gtk_sys::GtkAppChooserButton, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserButton::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, - Some(transmute(changed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + changed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_custom_item_activated(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn custom_item_activated_trampoline( + pub fn connect_custom_item_activated( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn custom_item_activated_trampoline< + F: Fn(&AppChooserButton, &str) + 'static, + >( this: *mut gtk_sys::GtkAppChooserButton, item_name: *mut libc::c_char, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); f( - &AppChooserButton::from_glib_borrow(this).unsafe_cast(), + &from_glib_borrow(this), &GString::from_glib_borrow(item_name), ) } @@ -534,84 +174,112 @@ impl> AppChooserButtonExt for O { connect_raw( self.as_ptr() as *mut _, b"custom-item-activated\0".as_ptr() as *const _, - Some(transmute( - custom_item_activated_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + custom_item_activated_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_heading_trampoline( + pub fn connect_property_heading_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_heading_trampoline( this: *mut gtk_sys::GtkAppChooserButton, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserButton::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::heading\0".as_ptr() as *const _, - Some(transmute(notify_heading_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_heading_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_modal_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_modal_trampoline( + this: *mut gtk_sys::GtkAppChooserButton, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::modal\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_modal_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_show_default_item_notify( + pub fn connect_property_show_default_item_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_show_default_item_trampoline( + unsafe extern "C" fn notify_show_default_item_trampoline< + F: Fn(&AppChooserButton) + 'static, + >( this: *mut gtk_sys::GtkAppChooserButton, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserButton::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-default-item\0".as_ptr() as *const _, - Some(transmute( - notify_show_default_item_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_default_item_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_show_dialog_item_notify( + pub fn connect_property_show_dialog_item_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_show_dialog_item_trampoline( + unsafe extern "C" fn notify_show_dialog_item_trampoline< + F: Fn(&AppChooserButton) + 'static, + >( this: *mut gtk_sys::GtkAppChooserButton, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserButton::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-dialog-item\0".as_ptr() as *const _, - Some(transmute( - notify_show_dialog_item_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_dialog_item_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/app_chooser_dialog.rs b/src/auto/app_chooser_dialog.rs index efc2d1e70d85..393dede48433 100644 --- a/src/auto/app_chooser_dialog.rs +++ b/src/auto/app_chooser_dialog.rs @@ -2,16 +2,15 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use gio; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; -use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; @@ -19,24 +18,17 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use AppChooser; -use Application; -use Bin; use Buildable; -use Container; use Dialog; use DialogFlags; -use LayoutManager; -use Overflow; use Root; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct AppChooserDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, Root, AppChooser; + pub struct AppChooserDialog(Object) @extends Dialog, Window, Widget, @implements Accessible, Buildable, Root, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_dialog_get_type(), @@ -75,602 +67,37 @@ impl AppChooserDialog { .unsafe_cast() } } -} - -#[derive(Clone, Default)] -pub struct AppChooserDialogBuilder { - gfile: Option, - heading: Option, - use_header_bar: Option, - accept_focus: Option, - application: Option, - attached_to: Option, - decorated: Option, - default_height: Option, - default_widget: Option, - default_width: Option, - deletable: Option, - destroy_with_parent: Option, - display: Option, - focus_on_map: Option, - focus_visible: Option, - hide_on_close: Option, - icon_name: Option, - mnemonics_visible: Option, - modal: Option, - resizable: Option, - startup_id: Option, - title: Option, - transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - focus_widget: Option, - content_type: Option, -} - -impl AppChooserDialogBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> AppChooserDialog { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref gfile) = self.gfile { - properties.push(("gfile", gfile)); - } - if let Some(ref heading) = self.heading { - properties.push(("heading", heading)); - } - if let Some(ref use_header_bar) = self.use_header_bar { - properties.push(("use-header-bar", use_header_bar)); - } - if let Some(ref accept_focus) = self.accept_focus { - properties.push(("accept-focus", accept_focus)); - } - if let Some(ref application) = self.application { - properties.push(("application", application)); - } - if let Some(ref attached_to) = self.attached_to { - properties.push(("attached-to", attached_to)); - } - if let Some(ref decorated) = self.decorated { - properties.push(("decorated", decorated)); - } - if let Some(ref default_height) = self.default_height { - properties.push(("default-height", default_height)); - } - if let Some(ref default_widget) = self.default_widget { - properties.push(("default-widget", default_widget)); - } - if let Some(ref default_width) = self.default_width { - properties.push(("default-width", default_width)); - } - if let Some(ref deletable) = self.deletable { - properties.push(("deletable", deletable)); - } - if let Some(ref destroy_with_parent) = self.destroy_with_parent { - properties.push(("destroy-with-parent", destroy_with_parent)); - } - if let Some(ref display) = self.display { - properties.push(("display", display)); - } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } - if let Some(ref focus_visible) = self.focus_visible { - properties.push(("focus-visible", focus_visible)); - } - if let Some(ref hide_on_close) = self.hide_on_close { - properties.push(("hide-on-close", hide_on_close)); - } - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); - } - if let Some(ref mnemonics_visible) = self.mnemonics_visible { - properties.push(("mnemonics-visible", mnemonics_visible)); - } - if let Some(ref modal) = self.modal { - properties.push(("modal", modal)); - } - if let Some(ref resizable) = self.resizable { - properties.push(("resizable", resizable)); - } - if let Some(ref startup_id) = self.startup_id { - properties.push(("startup-id", startup_id)); - } - if let Some(ref title) = self.title { - properties.push(("title", title)); - } - if let Some(ref transient_for) = self.transient_for { - properties.push(("transient-for", transient_for)); - } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); - } - if let Some(ref content_type) = self.content_type { - properties.push(("content-type", content_type)); - } - glib::Object::new(AppChooserDialog::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn gfile>(mut self, gfile: &P) -> Self { - self.gfile = Some(gfile.clone().upcast()); - self - } - - pub fn heading(mut self, heading: &str) -> Self { - self.heading = Some(heading.to_string()); - self - } - - pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { - self.use_header_bar = Some(use_header_bar); - self - } - - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - - pub fn application>(mut self, application: &P) -> Self { - self.application = Some(application.clone().upcast()); - self - } - - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); - self - } - - pub fn decorated(mut self, decorated: bool) -> Self { - self.decorated = Some(decorated); - self - } - - pub fn default_height(mut self, default_height: i32) -> Self { - self.default_height = Some(default_height); - self - } - - pub fn default_widget>(mut self, default_widget: &P) -> Self { - self.default_widget = Some(default_widget.clone().upcast()); - self - } - - pub fn default_width(mut self, default_width: i32) -> Self { - self.default_width = Some(default_width); - self - } - - pub fn deletable(mut self, deletable: bool) -> Self { - self.deletable = Some(deletable); - self - } - - pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { - self.destroy_with_parent = Some(destroy_with_parent); - self - } - - pub fn display(mut self, display: &gdk::Display) -> Self { - self.display = Some(display.clone()); - self - } - - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); - self - } - - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); - self - } - - pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { - self.hide_on_close = Some(hide_on_close); - self - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { - self.mnemonics_visible = Some(mnemonics_visible); - self - } - - pub fn modal(mut self, modal: bool) -> Self { - self.modal = Some(modal); - self - } - - pub fn resizable(mut self, resizable: bool) -> Self { - self.resizable = Some(resizable); - self - } - - pub fn startup_id(mut self, startup_id: &str) -> Self { - self.startup_id = Some(startup_id.to_string()); - self - } - - pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); - self - } - - pub fn transient_for>(mut self, transient_for: &P) -> Self { - self.transient_for = Some(transient_for.clone().upcast()); - self - } - - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); - self - } - - pub fn content_type(mut self, content_type: &str) -> Self { - self.content_type = Some(content_type.to_string()); - self - } -} - -pub const NONE_APP_CHOOSER_DIALOG: Option<&AppChooserDialog> = None; - -pub trait AppChooserDialogExt: 'static { - fn get_heading(&self) -> Option; - - fn get_widget(&self) -> Widget; - - fn set_heading(&self, heading: &str); - - fn get_property_gfile(&self) -> Option; - - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId; -} -impl> AppChooserDialogExt for O { - fn get_heading(&self) -> Option { + pub fn get_heading(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_heading( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_widget(&self) -> Widget { + pub fn get_widget(&self) -> Widget { unsafe { from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_widget( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn set_heading(&self, heading: &str) { + pub fn set_heading(&self, heading: &str) { unsafe { gtk_sys::gtk_app_chooser_dialog_set_heading( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, heading.to_glib_none().0, ); } } - fn get_property_gfile(&self) -> Option { + pub fn get_property_gfile(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, + self.as_ptr() as *mut gobject_sys::GObject, b"gfile\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); @@ -680,23 +107,26 @@ impl> AppChooserDialogExt for O { } } - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_heading_trampoline( + pub fn connect_property_heading_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_heading_trampoline( this: *mut gtk_sys::GtkAppChooserDialog, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserDialog::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::heading\0".as_ptr() as *const _, - Some(transmute(notify_heading_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_heading_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/app_chooser_widget.rs b/src/auto/app_chooser_widget.rs index 78bc462b7720..c718e24b246a 100644 --- a/src/auto/app_chooser_widget.rs +++ b/src/auto/app_chooser_widget.rs @@ -2,32 +2,26 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use gio; use gio_sys; use glib::object::Cast; -use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use AppChooser; use Buildable; -use LayoutManager; -use Menu; -use Overflow; use Widget; glib_wrapper! { - pub struct AppChooserWidget(Object) @extends Widget, @implements Buildable, AppChooser; + pub struct AppChooserWidget(Object) @extends Widget, @implements Accessible, Buildable, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_widget_get_type(), @@ -44,779 +38,306 @@ impl AppChooserWidget { .unsafe_cast() } } -} - -#[derive(Clone, Default)] -pub struct AppChooserWidgetBuilder { - default_text: Option, - show_all: Option, - show_default: Option, - show_fallback: Option, - show_other: Option, - show_recommended: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - content_type: Option, -} - -impl AppChooserWidgetBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> AppChooserWidget { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref default_text) = self.default_text { - properties.push(("default-text", default_text)); - } - if let Some(ref show_all) = self.show_all { - properties.push(("show-all", show_all)); - } - if let Some(ref show_default) = self.show_default { - properties.push(("show-default", show_default)); - } - if let Some(ref show_fallback) = self.show_fallback { - properties.push(("show-fallback", show_fallback)); - } - if let Some(ref show_other) = self.show_other { - properties.push(("show-other", show_other)); - } - if let Some(ref show_recommended) = self.show_recommended { - properties.push(("show-recommended", show_recommended)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref content_type) = self.content_type { - properties.push(("content-type", content_type)); - } - glib::Object::new(AppChooserWidget::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn default_text(mut self, default_text: &str) -> Self { - self.default_text = Some(default_text.to_string()); - self - } - pub fn show_all(mut self, show_all: bool) -> Self { - self.show_all = Some(show_all); - self - } - - pub fn show_default(mut self, show_default: bool) -> Self { - self.show_default = Some(show_default); - self - } - - pub fn show_fallback(mut self, show_fallback: bool) -> Self { - self.show_fallback = Some(show_fallback); - self - } - - pub fn show_other(mut self, show_other: bool) -> Self { - self.show_other = Some(show_other); - self - } - - pub fn show_recommended(mut self, show_recommended: bool) -> Self { - self.show_recommended = Some(show_recommended); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn content_type(mut self, content_type: &str) -> Self { - self.content_type = Some(content_type.to_string()); - self - } -} - -pub const NONE_APP_CHOOSER_WIDGET: Option<&AppChooserWidget> = None; - -pub trait AppChooserWidgetExt: 'static { - fn get_default_text(&self) -> Option; - - fn get_show_all(&self) -> bool; - - fn get_show_default(&self) -> bool; - - fn get_show_fallback(&self) -> bool; - - fn get_show_other(&self) -> bool; - - fn get_show_recommended(&self) -> bool; - - fn set_default_text(&self, text: &str); - - fn set_show_all(&self, setting: bool); - - fn set_show_default(&self, setting: bool); - - fn set_show_fallback(&self, setting: bool); - - fn set_show_other(&self, setting: bool); - - fn set_show_recommended(&self, setting: bool); - - fn connect_application_activated( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_application_selected( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_populate_popup( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_default_text_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_show_all_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_default_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_show_fallback_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_show_other_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_recommended_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AppChooserWidgetExt for O { - fn get_default_text(&self) -> Option { + pub fn get_default_text(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_app_chooser_widget_get_default_text( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_all(&self) -> bool { + pub fn get_show_all(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_widget_get_show_all( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_default(&self) -> bool { + pub fn get_show_default(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_widget_get_show_default( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_fallback(&self) -> bool { + pub fn get_show_fallback(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_widget_get_show_fallback( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_other(&self) -> bool { + pub fn get_show_other(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_widget_get_show_other( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_show_recommended(&self) -> bool { + pub fn get_show_recommended(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_app_chooser_widget_get_show_recommended( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn set_default_text(&self, text: &str) { + pub fn set_default_text(&self, text: &str) { unsafe { gtk_sys::gtk_app_chooser_widget_set_default_text( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, text.to_glib_none().0, ); } } - fn set_show_all(&self, setting: bool) { + pub fn set_show_all(&self, setting: bool) { unsafe { - gtk_sys::gtk_app_chooser_widget_set_show_all( - self.as_ref().to_glib_none().0, - setting.to_glib(), - ); + gtk_sys::gtk_app_chooser_widget_set_show_all(self.to_glib_none().0, setting.to_glib()); } } - fn set_show_default(&self, setting: bool) { + pub fn set_show_default(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_widget_set_show_default( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn set_show_fallback(&self, setting: bool) { + pub fn set_show_fallback(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_widget_set_show_fallback( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn set_show_other(&self, setting: bool) { + pub fn set_show_other(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_widget_set_show_other( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn set_show_recommended(&self, setting: bool) { + pub fn set_show_recommended(&self, setting: bool) { unsafe { gtk_sys::gtk_app_chooser_widget_set_show_recommended( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, setting.to_glib(), ); } } - fn connect_application_activated( + pub fn connect_application_activated( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn application_activated_trampoline< - P, - F: Fn(&P, &gio::AppInfo) + 'static, + F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static, >( this: *mut gtk_sys::GtkAppChooserWidget, application: *mut gio_sys::GAppInfo, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f( - &AppChooserWidget::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(application), - ) + f(&from_glib_borrow(this), &from_glib_borrow(application)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"application-activated\0".as_ptr() as *const _, - Some(transmute( - application_activated_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + application_activated_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_application_selected( + pub fn connect_application_selected( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn application_selected_trampoline< - P, - F: Fn(&P, &gio::AppInfo) + 'static, + F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static, >( this: *mut gtk_sys::GtkAppChooserWidget, application: *mut gio_sys::GAppInfo, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f( - &AppChooserWidget::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(application), - ) + f(&from_glib_borrow(this), &from_glib_borrow(application)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"application-selected\0".as_ptr() as *const _, - Some(transmute( - application_selected_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + application_selected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_populate_popup( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn populate_popup_trampoline< - P, - F: Fn(&P, &Menu, &gio::AppInfo) + 'static, - >( - this: *mut gtk_sys::GtkAppChooserWidget, - menu: *mut gtk_sys::GtkMenu, - application: *mut gio_sys::GAppInfo, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f( - &AppChooserWidget::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(menu), - &from_glib_borrow(application), - ) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"populate-popup\0".as_ptr() as *const _, - Some(transmute(populate_popup_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - - fn connect_property_default_text_notify( + pub fn connect_property_default_text_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_default_text_trampoline( + unsafe extern "C" fn notify_default_text_trampoline( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::default-text\0".as_ptr() as *const _, - Some(transmute( - notify_default_text_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_default_text_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_show_all_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_show_all_trampoline( + pub fn connect_property_show_all_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_all_trampoline( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-all\0".as_ptr() as *const _, - Some(transmute(notify_show_all_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_all_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_show_default_notify( + pub fn connect_property_show_default_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_show_default_trampoline( + unsafe extern "C" fn notify_show_default_trampoline( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-default\0".as_ptr() as *const _, - Some(transmute( - notify_show_default_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_default_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_show_fallback_notify( + pub fn connect_property_show_fallback_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_show_fallback_trampoline( + unsafe extern "C" fn notify_show_fallback_trampoline( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-fallback\0".as_ptr() as *const _, - Some(transmute( - notify_show_fallback_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_fallback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_show_other_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_show_other_trampoline( + pub fn connect_property_show_other_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_other_trampoline( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-other\0".as_ptr() as *const _, - Some(transmute(notify_show_other_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_other_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_show_recommended_notify( + pub fn connect_property_show_recommended_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_show_recommended_trampoline( + unsafe extern "C" fn notify_show_recommended_trampoline< + F: Fn(&AppChooserWidget) + 'static, + >( this: *mut gtk_sys::GtkAppChooserWidget, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AppChooserWidget::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-recommended\0".as_ptr() as *const _, - Some(transmute( - notify_show_recommended_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_recommended_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/application.rs b/src/auto/application.rs index ad5ec984d4a1..8fde8803fb9b 100644 --- a/src/auto/application.rs +++ b/src/auto/application.rs @@ -39,8 +39,6 @@ pub trait GtkApplicationExt: 'static { fn get_active_window(&self) -> Option; - fn get_app_menu(&self) -> Option; - fn get_menu_by_id(&self, id: &str) -> Option; fn get_menubar(&self) -> Option; @@ -58,14 +56,10 @@ pub trait GtkApplicationExt: 'static { fn list_action_descriptions(&self) -> Vec; - fn prefers_app_menu(&self) -> bool; - fn remove_window>(&self, window: &P); fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]); - fn set_app_menu>(&self, app_menu: Option<&P>); - fn set_menubar>(&self, menubar: Option<&P>); fn uninhibit(&self, cookie: u32); @@ -87,8 +81,6 @@ pub trait GtkApplicationExt: 'static { f: F, ) -> SignalHandlerId; - fn connect_property_app_menu_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_menubar_notify(&self, f: F) -> SignalHandlerId; fn connect_property_register_session_notify( @@ -138,14 +130,6 @@ impl> GtkApplicationExt for O { } } - fn get_app_menu(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_application_get_app_menu( - self.as_ref().to_glib_none().0, - )) - } - } - fn get_menu_by_id(&self, id: &str) -> Option { unsafe { from_glib_none(gtk_sys::gtk_application_get_menu_by_id( @@ -204,14 +188,6 @@ impl> GtkApplicationExt for O { } } - fn prefers_app_menu(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_application_prefers_app_menu( - self.as_ref().to_glib_none().0, - )) - } - } - fn remove_window>(&self, window: &P) { unsafe { gtk_sys::gtk_application_remove_window( @@ -231,15 +207,6 @@ impl> GtkApplicationExt for O { } } - fn set_app_menu>(&self, app_menu: Option<&P>) { - unsafe { - gtk_sys::gtk_application_set_app_menu( - self.as_ref().to_glib_none().0, - app_menu.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } - fn set_menubar>(&self, menubar: Option<&P>) { unsafe { gtk_sys::gtk_application_set_menubar( @@ -303,14 +270,16 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"query-end\0".as_ptr() as *const _, - Some(transmute(query_end_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + query_end_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -326,7 +295,7 @@ impl> GtkApplicationExt for O { { let f: &F = &*(f as *const F); f( - &Application::from_glib_borrow(this).unsafe_cast(), + &Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(window), ) } @@ -335,7 +304,9 @@ impl> GtkApplicationExt for O { connect_raw( self.as_ptr() as *mut _, b"window-added\0".as_ptr() as *const _, - Some(transmute(window_added_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + window_added_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -351,7 +322,7 @@ impl> GtkApplicationExt for O { { let f: &F = &*(f as *const F); f( - &Application::from_glib_borrow(this).unsafe_cast(), + &Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(window), ) } @@ -360,7 +331,9 @@ impl> GtkApplicationExt for O { connect_raw( self.as_ptr() as *mut _, b"window-removed\0".as_ptr() as *const _, - Some(transmute(window_removed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + window_removed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -378,43 +351,21 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::active-window\0".as_ptr() as *const _, - Some(transmute( - notify_active_window_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_active_window_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_app_menu_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_app_menu_trampoline( - this: *mut gtk_sys::GtkApplication, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::app-menu\0".as_ptr() as *const _, - Some(transmute(notify_app_menu_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - fn connect_property_menubar_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_menubar_trampoline( this: *mut gtk_sys::GtkApplication, @@ -424,14 +375,16 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::menubar\0".as_ptr() as *const _, - Some(transmute(notify_menubar_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_menubar_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -449,15 +402,15 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::register-session\0".as_ptr() as *const _, - Some(transmute( - notify_register_session_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_register_session_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -476,15 +429,15 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::screensaver-active\0".as_ptr() as *const _, - Some(transmute( - notify_screensaver_active_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_screensaver_active_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/application_window.rs b/src/auto/application_window.rs index 129f8be01330..b1dee983ffb9 100644 --- a/src/auto/application_window.rs +++ b/src/auto/application_window.rs @@ -2,36 +2,27 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use gio; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use Application; -use Bin; use Buildable; -use Container; -use LayoutManager; -use Overflow; use Root; use ShortcutsWindow; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct ApplicationWindow(Object) @extends Window, Bin, Container, Widget, @implements Buildable, Root, gio::ActionGroup, gio::ActionMap; + pub struct ApplicationWindow(Object) @extends Window, Widget, @implements Accessible, Buildable, Root, gio::ActionGroup, gio::ActionMap; match fn { get_type => || gtk_sys::gtk_application_window_get_type(), @@ -50,528 +41,6 @@ impl ApplicationWindow { } } -#[derive(Clone, Default)] -pub struct ApplicationWindowBuilder { - show_menubar: Option, - accept_focus: Option, - application: Option, - attached_to: Option, - decorated: Option, - default_height: Option, - default_widget: Option, - default_width: Option, - deletable: Option, - destroy_with_parent: Option, - display: Option, - focus_on_map: Option, - focus_visible: Option, - hide_on_close: Option, - icon_name: Option, - mnemonics_visible: Option, - modal: Option, - resizable: Option, - startup_id: Option, - title: Option, - transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - focus_widget: Option, -} - -impl ApplicationWindowBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> ApplicationWindow { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref show_menubar) = self.show_menubar { - properties.push(("show-menubar", show_menubar)); - } - if let Some(ref accept_focus) = self.accept_focus { - properties.push(("accept-focus", accept_focus)); - } - if let Some(ref application) = self.application { - properties.push(("application", application)); - } - if let Some(ref attached_to) = self.attached_to { - properties.push(("attached-to", attached_to)); - } - if let Some(ref decorated) = self.decorated { - properties.push(("decorated", decorated)); - } - if let Some(ref default_height) = self.default_height { - properties.push(("default-height", default_height)); - } - if let Some(ref default_widget) = self.default_widget { - properties.push(("default-widget", default_widget)); - } - if let Some(ref default_width) = self.default_width { - properties.push(("default-width", default_width)); - } - if let Some(ref deletable) = self.deletable { - properties.push(("deletable", deletable)); - } - if let Some(ref destroy_with_parent) = self.destroy_with_parent { - properties.push(("destroy-with-parent", destroy_with_parent)); - } - if let Some(ref display) = self.display { - properties.push(("display", display)); - } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } - if let Some(ref focus_visible) = self.focus_visible { - properties.push(("focus-visible", focus_visible)); - } - if let Some(ref hide_on_close) = self.hide_on_close { - properties.push(("hide-on-close", hide_on_close)); - } - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); - } - if let Some(ref mnemonics_visible) = self.mnemonics_visible { - properties.push(("mnemonics-visible", mnemonics_visible)); - } - if let Some(ref modal) = self.modal { - properties.push(("modal", modal)); - } - if let Some(ref resizable) = self.resizable { - properties.push(("resizable", resizable)); - } - if let Some(ref startup_id) = self.startup_id { - properties.push(("startup-id", startup_id)); - } - if let Some(ref title) = self.title { - properties.push(("title", title)); - } - if let Some(ref transient_for) = self.transient_for { - properties.push(("transient-for", transient_for)); - } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); - } - glib::Object::new(ApplicationWindow::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn show_menubar(mut self, show_menubar: bool) -> Self { - self.show_menubar = Some(show_menubar); - self - } - - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - - pub fn application>(mut self, application: &P) -> Self { - self.application = Some(application.clone().upcast()); - self - } - - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); - self - } - - pub fn decorated(mut self, decorated: bool) -> Self { - self.decorated = Some(decorated); - self - } - - pub fn default_height(mut self, default_height: i32) -> Self { - self.default_height = Some(default_height); - self - } - - pub fn default_widget>(mut self, default_widget: &P) -> Self { - self.default_widget = Some(default_widget.clone().upcast()); - self - } - - pub fn default_width(mut self, default_width: i32) -> Self { - self.default_width = Some(default_width); - self - } - - pub fn deletable(mut self, deletable: bool) -> Self { - self.deletable = Some(deletable); - self - } - - pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { - self.destroy_with_parent = Some(destroy_with_parent); - self - } - - pub fn display(mut self, display: &gdk::Display) -> Self { - self.display = Some(display.clone()); - self - } - - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); - self - } - - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); - self - } - - pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { - self.hide_on_close = Some(hide_on_close); - self - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { - self.mnemonics_visible = Some(mnemonics_visible); - self - } - - pub fn modal(mut self, modal: bool) -> Self { - self.modal = Some(modal); - self - } - - pub fn resizable(mut self, resizable: bool) -> Self { - self.resizable = Some(resizable); - self - } - - pub fn startup_id(mut self, startup_id: &str) -> Self { - self.startup_id = Some(startup_id.to_string()); - self - } - - pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); - self - } - - pub fn transient_for>(mut self, transient_for: &P) -> Self { - self.transient_for = Some(transient_for.clone().upcast()); - self - } - - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); - self - } -} - pub const NONE_APPLICATION_WINDOW: Option<&ApplicationWindow> = None; pub trait ApplicationWindowExt: 'static { @@ -581,7 +50,7 @@ pub trait ApplicationWindowExt: 'static { fn get_show_menubar(&self) -> bool; - fn set_help_overlay>(&self, help_overlay: Option<&P>); + fn set_help_overlay(&self, help_overlay: Option<&ShortcutsWindow>); fn set_show_menubar(&self, show_menubar: bool); @@ -610,11 +79,11 @@ impl> ApplicationWindowExt for O { } } - fn set_help_overlay>(&self, help_overlay: Option<&P>) { + fn set_help_overlay(&self, help_overlay: Option<&ShortcutsWindow>) { unsafe { gtk_sys::gtk_application_window_set_help_overlay( self.as_ref().to_glib_none().0, - help_overlay.map(|p| p.as_ref()).to_glib_none().0, + help_overlay.to_glib_none().0, ); } } @@ -640,15 +109,15 @@ impl> ApplicationWindowExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast()) + f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-menubar\0".as_ptr() as *const _, - Some(transmute( - notify_show_menubar_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_menubar_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/aspect_frame.rs b/src/auto/aspect_frame.rs index c3d106d2b66d..3d716cf08ed4 100644 --- a/src/auto/aspect_frame.rs +++ b/src/auto/aspect_frame.rs @@ -2,33 +2,23 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib::StaticType; -use glib::ToValue; -use glib::Value; use glib_sys; -use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; -use Bin; +use Accessible; use Buildable; -use Container; -use Frame; -use LayoutManager; -use Overflow; -use ShadowType; use Widget; glib_wrapper! { - pub struct AspectFrame(Object) @extends Frame, Bin, Container, Widget, @implements Buildable; + pub struct AspectFrame(Object) @extends Widget, @implements Accessible, Buildable; match fn { get_type => || gtk_sys::gtk_aspect_frame_get_type(), @@ -36,17 +26,10 @@ glib_wrapper! { } impl AspectFrame { - pub fn new( - label: Option<&str>, - xalign: f32, - yalign: f32, - ratio: f32, - obey_child: bool, - ) -> AspectFrame { + pub fn new(xalign: f32, yalign: f32, ratio: f32, obey_child: bool) -> AspectFrame { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_aspect_frame_new( - label.to_glib_none().0, xalign, yalign, ratio, @@ -55,603 +38,184 @@ impl AspectFrame { .unsafe_cast() } } -} - -#[derive(Clone, Default)] -pub struct AspectFrameBuilder { - obey_child: Option, - ratio: Option, - xalign: Option, - yalign: Option, - label: Option, - label_widget: Option, - label_xalign: Option, - shadow_type: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, -} -impl AspectFrameBuilder { - pub fn new() -> Self { - Self::default() + pub fn get_child(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_aspect_frame_get_child(self.to_glib_none().0)) } } - pub fn build(self) -> AspectFrame { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref obey_child) = self.obey_child { - properties.push(("obey-child", obey_child)); - } - if let Some(ref ratio) = self.ratio { - properties.push(("ratio", ratio)); - } - if let Some(ref xalign) = self.xalign { - properties.push(("xalign", xalign)); - } - if let Some(ref yalign) = self.yalign { - properties.push(("yalign", yalign)); - } - if let Some(ref label) = self.label { - properties.push(("label", label)); - } - if let Some(ref label_widget) = self.label_widget { - properties.push(("label-widget", label_widget)); - } - if let Some(ref label_xalign) = self.label_xalign { - properties.push(("label-xalign", label_xalign)); - } - if let Some(ref shadow_type) = self.shadow_type { - properties.push(("shadow-type", shadow_type)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); + pub fn get_obey_child(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_aspect_frame_get_obey_child( + self.to_glib_none().0, + )) } - glib::Object::new(AspectFrame::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn obey_child(mut self, obey_child: bool) -> Self { - self.obey_child = Some(obey_child); - self - } - - pub fn ratio(mut self, ratio: f32) -> Self { - self.ratio = Some(ratio); - self } - pub fn xalign(mut self, xalign: f32) -> Self { - self.xalign = Some(xalign); - self + pub fn get_ratio(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_ratio(self.to_glib_none().0) } } - pub fn yalign(mut self, yalign: f32) -> Self { - self.yalign = Some(yalign); - self + pub fn get_xalign(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_xalign(self.to_glib_none().0) } } - pub fn label(mut self, label: &str) -> Self { - self.label = Some(label.to_string()); - self + pub fn get_yalign(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_yalign(self.to_glib_none().0) } } - pub fn label_widget>(mut self, label_widget: &P) -> Self { - self.label_widget = Some(label_widget.clone().upcast()); - self - } - - pub fn label_xalign(mut self, label_xalign: f32) -> Self { - self.label_xalign = Some(label_xalign); - self - } - - pub fn shadow_type(mut self, shadow_type: ShadowType) -> Self { - self.shadow_type = Some(shadow_type); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } -} - -pub const NONE_ASPECT_FRAME: Option<&AspectFrame> = None; - -pub trait AspectFrameExt: 'static { - fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool); - - fn get_property_obey_child(&self) -> bool; - - fn set_property_obey_child(&self, obey_child: bool); - - fn get_property_ratio(&self) -> f32; - - fn set_property_ratio(&self, ratio: f32); - - fn get_property_xalign(&self) -> f32; - - fn set_property_xalign(&self, xalign: f32); - - fn get_property_yalign(&self) -> f32; - - fn set_property_yalign(&self, yalign: f32); - - fn connect_property_obey_child_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_ratio_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId; -} - -impl> AspectFrameExt for O { - fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) { - unsafe { - gtk_sys::gtk_aspect_frame_set( - self.as_ref().to_glib_none().0, - xalign, - yalign, - ratio, - obey_child.to_glib(), - ); - } - } - - fn get_property_obey_child(&self) -> bool { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"obey-child\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `obey-child` getter") - .unwrap() - } - } - - fn set_property_obey_child(&self, obey_child: bool) { + pub fn set_child>(&self, child: Option<&P>) { unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"obey-child\0".as_ptr() as *const _, - Value::from(&obey_child).to_glib_none().0, + gtk_sys::gtk_aspect_frame_set_child( + self.to_glib_none().0, + child.map(|p| p.as_ref()).to_glib_none().0, ); } } - fn get_property_ratio(&self) -> f32 { + pub fn set_obey_child(&self, obey_child: bool) { unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"ratio\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `ratio` getter") - .unwrap() + gtk_sys::gtk_aspect_frame_set_obey_child(self.to_glib_none().0, obey_child.to_glib()); } } - fn set_property_ratio(&self, ratio: f32) { + pub fn set_ratio(&self, ratio: f32) { unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"ratio\0".as_ptr() as *const _, - Value::from(&ratio).to_glib_none().0, - ); + gtk_sys::gtk_aspect_frame_set_ratio(self.to_glib_none().0, ratio); } } - fn get_property_xalign(&self) -> f32 { + pub fn set_xalign(&self, xalign: f32) { unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"xalign\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `xalign` getter") - .unwrap() + gtk_sys::gtk_aspect_frame_set_xalign(self.to_glib_none().0, xalign); } } - fn set_property_xalign(&self, xalign: f32) { + pub fn set_yalign(&self, yalign: f32) { unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"xalign\0".as_ptr() as *const _, - Value::from(&xalign).to_glib_none().0, - ); + gtk_sys::gtk_aspect_frame_set_yalign(self.to_glib_none().0, yalign); } } - fn get_property_yalign(&self) -> f32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"yalign\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `yalign` getter") - .unwrap() + pub fn connect_property_child_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_child_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - } - - fn set_property_yalign(&self, yalign: f32) { unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"yalign\0".as_ptr() as *const _, - Value::from(&yalign).to_glib_none().0, - ); + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::child\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_child_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } } - fn connect_property_obey_child_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_obey_child_trampoline( + pub fn connect_property_obey_child_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_obey_child_trampoline( this: *mut gtk_sys::GtkAspectFrame, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AspectFrame::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::obey-child\0".as_ptr() as *const _, - Some(transmute(notify_obey_child_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_obey_child_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_ratio_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_ratio_trampoline( + pub fn connect_property_ratio_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_ratio_trampoline( this: *mut gtk_sys::GtkAspectFrame, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AspectFrame::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ratio\0".as_ptr() as *const _, - Some(transmute(notify_ratio_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_ratio_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_xalign_trampoline( + pub fn connect_property_xalign_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_xalign_trampoline( this: *mut gtk_sys::GtkAspectFrame, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AspectFrame::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::xalign\0".as_ptr() as *const _, - Some(transmute(notify_xalign_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_xalign_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_yalign_trampoline( + pub fn connect_property_yalign_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_yalign_trampoline( this: *mut gtk_sys::GtkAspectFrame, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&AspectFrame::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::yalign\0".as_ptr() as *const _, - Some(transmute(notify_yalign_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_yalign_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/assistant.rs b/src/auto/assistant.rs index d3109d0713a7..8a34a2bef903 100644 --- a/src/auto/assistant.rs +++ b/src/auto/assistant.rs @@ -2,18 +2,17 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use gio; use glib; use glib::object::Cast; use glib::object::IsA; use glib::object::ObjectExt; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; -use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; @@ -21,23 +20,16 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; -use Application; +use Accessible; use AssistantPage; use AssistantPageType; -use Bin; use Buildable; -use Container; -use LayoutManager; -use Overflow; use Root; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct Assistant(Object) @extends Window, Bin, Container, Widget, @implements Buildable, Root; + pub struct Assistant(Object) @extends Window, Widget, @implements Accessible, Buildable, Root; match fn { get_type => || gtk_sys::gtk_assistant_get_type(), @@ -49,741 +41,141 @@ impl Assistant { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_assistant_new()).unsafe_cast() } } -} - -impl Default for Assistant { - fn default() -> Self { - Self::new() - } -} - -#[derive(Clone, Default)] -pub struct AssistantBuilder { - use_header_bar: Option, - accept_focus: Option, - application: Option, - attached_to: Option, - decorated: Option, - default_height: Option, - default_widget: Option, - default_width: Option, - deletable: Option, - destroy_with_parent: Option, - display: Option, - focus_on_map: Option, - focus_visible: Option, - hide_on_close: Option, - icon_name: Option, - mnemonics_visible: Option, - modal: Option, - resizable: Option, - startup_id: Option, - title: Option, - transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - focus_widget: Option, -} - -impl AssistantBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> Assistant { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref use_header_bar) = self.use_header_bar { - properties.push(("use-header-bar", use_header_bar)); - } - if let Some(ref accept_focus) = self.accept_focus { - properties.push(("accept-focus", accept_focus)); - } - if let Some(ref application) = self.application { - properties.push(("application", application)); - } - if let Some(ref attached_to) = self.attached_to { - properties.push(("attached-to", attached_to)); - } - if let Some(ref decorated) = self.decorated { - properties.push(("decorated", decorated)); - } - if let Some(ref default_height) = self.default_height { - properties.push(("default-height", default_height)); - } - if let Some(ref default_widget) = self.default_widget { - properties.push(("default-widget", default_widget)); - } - if let Some(ref default_width) = self.default_width { - properties.push(("default-width", default_width)); - } - if let Some(ref deletable) = self.deletable { - properties.push(("deletable", deletable)); - } - if let Some(ref destroy_with_parent) = self.destroy_with_parent { - properties.push(("destroy-with-parent", destroy_with_parent)); - } - if let Some(ref display) = self.display { - properties.push(("display", display)); - } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } - if let Some(ref focus_visible) = self.focus_visible { - properties.push(("focus-visible", focus_visible)); - } - if let Some(ref hide_on_close) = self.hide_on_close { - properties.push(("hide-on-close", hide_on_close)); - } - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); - } - if let Some(ref mnemonics_visible) = self.mnemonics_visible { - properties.push(("mnemonics-visible", mnemonics_visible)); - } - if let Some(ref modal) = self.modal { - properties.push(("modal", modal)); - } - if let Some(ref resizable) = self.resizable { - properties.push(("resizable", resizable)); - } - if let Some(ref startup_id) = self.startup_id { - properties.push(("startup-id", startup_id)); - } - if let Some(ref title) = self.title { - properties.push(("title", title)); - } - if let Some(ref transient_for) = self.transient_for { - properties.push(("transient-for", transient_for)); - } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); - } - glib::Object::new(Assistant::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { - self.use_header_bar = Some(use_header_bar); - self - } - - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - - pub fn application>(mut self, application: &P) -> Self { - self.application = Some(application.clone().upcast()); - self - } - - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); - self - } - - pub fn decorated(mut self, decorated: bool) -> Self { - self.decorated = Some(decorated); - self - } - - pub fn default_height(mut self, default_height: i32) -> Self { - self.default_height = Some(default_height); - self - } - - pub fn default_widget>(mut self, default_widget: &P) -> Self { - self.default_widget = Some(default_widget.clone().upcast()); - self - } - - pub fn default_width(mut self, default_width: i32) -> Self { - self.default_width = Some(default_width); - self - } - - pub fn deletable(mut self, deletable: bool) -> Self { - self.deletable = Some(deletable); - self - } - - pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { - self.destroy_with_parent = Some(destroy_with_parent); - self - } - - pub fn display(mut self, display: &gdk::Display) -> Self { - self.display = Some(display.clone()); - self - } - - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); - self - } - - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); - self - } - - pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { - self.hide_on_close = Some(hide_on_close); - self - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { - self.mnemonics_visible = Some(mnemonics_visible); - self - } - - pub fn modal(mut self, modal: bool) -> Self { - self.modal = Some(modal); - self - } - - pub fn resizable(mut self, resizable: bool) -> Self { - self.resizable = Some(resizable); - self - } - - pub fn startup_id(mut self, startup_id: &str) -> Self { - self.startup_id = Some(startup_id.to_string()); - self - } - - pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); - self - } - - pub fn transient_for>(mut self, transient_for: &P) -> Self { - self.transient_for = Some(transient_for.clone().upcast()); - self - } - - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); - self - } -} - -pub const NONE_ASSISTANT: Option<&Assistant> = None; - -pub trait AssistantExt: 'static { - fn add_action_widget>(&self, child: &P); - - fn append_page>(&self, page: &P) -> i32; - - fn commit(&self); - - fn get_current_page(&self) -> i32; - - fn get_n_pages(&self) -> i32; - - fn get_nth_page(&self, page_num: i32) -> Option; - - fn get_page>(&self, child: &P) -> Option; - - fn get_page_complete>(&self, page: &P) -> bool; - - fn get_page_title>(&self, page: &P) -> Option; - - fn get_page_type>(&self, page: &P) -> AssistantPageType; - - fn get_pages(&self) -> Option; - - fn insert_page>(&self, page: &P, position: i32) -> i32; - - fn next_page(&self); - - fn prepend_page>(&self, page: &P) -> i32; - - fn previous_page(&self); - - fn remove_action_widget>(&self, child: &P); - - fn remove_page(&self, page_num: i32); - - fn set_current_page(&self, page_num: i32); - - fn set_forward_page_func(&self, page_func: Option i32 + 'static>>); - - fn set_page_complete>(&self, page: &P, complete: bool); - - fn set_page_title>(&self, page: &P, title: &str); - - fn set_page_type>(&self, page: &P, type_: AssistantPageType); - - fn update_buttons_state(&self); - - fn get_property_use_header_bar(&self) -> i32; - - fn connect_apply(&self, f: F) -> SignalHandlerId; - - fn connect_cancel(&self, f: F) -> SignalHandlerId; - - fn connect_close(&self, f: F) -> SignalHandlerId; - - fn connect_escape(&self, f: F) -> SignalHandlerId; - - fn emit_escape(&self); - - fn connect_prepare(&self, f: F) -> SignalHandlerId; - - fn connect_property_pages_notify(&self, f: F) -> SignalHandlerId; -} - -impl> AssistantExt for O { - fn add_action_widget>(&self, child: &P) { + pub fn add_action_widget>(&self, child: &P) { unsafe { gtk_sys::gtk_assistant_add_action_widget( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, child.as_ref().to_glib_none().0, ); } } - fn append_page>(&self, page: &P) -> i32 { + pub fn append_page>(&self, page: &P) -> i32 { unsafe { gtk_sys::gtk_assistant_append_page( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, ) } } - fn commit(&self) { + pub fn commit(&self) { unsafe { - gtk_sys::gtk_assistant_commit(self.as_ref().to_glib_none().0); + gtk_sys::gtk_assistant_commit(self.to_glib_none().0); } } - fn get_current_page(&self) -> i32 { - unsafe { gtk_sys::gtk_assistant_get_current_page(self.as_ref().to_glib_none().0) } + pub fn get_current_page(&self) -> i32 { + unsafe { gtk_sys::gtk_assistant_get_current_page(self.to_glib_none().0) } } - fn get_n_pages(&self) -> i32 { - unsafe { gtk_sys::gtk_assistant_get_n_pages(self.as_ref().to_glib_none().0) } + pub fn get_n_pages(&self) -> i32 { + unsafe { gtk_sys::gtk_assistant_get_n_pages(self.to_glib_none().0) } } - fn get_nth_page(&self, page_num: i32) -> Option { + pub fn get_nth_page(&self, page_num: i32) -> Option { unsafe { from_glib_none(gtk_sys::gtk_assistant_get_nth_page( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page_num, )) } } - fn get_page>(&self, child: &P) -> Option { + pub fn get_page>(&self, child: &P) -> Option { unsafe { from_glib_none(gtk_sys::gtk_assistant_get_page( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, child.as_ref().to_glib_none().0, )) } } - fn get_page_complete>(&self, page: &P) -> bool { + pub fn get_page_complete>(&self, page: &P) -> bool { unsafe { from_glib(gtk_sys::gtk_assistant_get_page_complete( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, )) } } - fn get_page_title>(&self, page: &P) -> Option { + pub fn get_page_title>(&self, page: &P) -> Option { unsafe { from_glib_none(gtk_sys::gtk_assistant_get_page_title( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, )) } } - fn get_page_type>(&self, page: &P) -> AssistantPageType { + pub fn get_page_type>(&self, page: &P) -> AssistantPageType { unsafe { from_glib(gtk_sys::gtk_assistant_get_page_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, )) } } - fn get_pages(&self) -> Option { - unsafe { - from_glib_full(gtk_sys::gtk_assistant_get_pages( - self.as_ref().to_glib_none().0, - )) - } + pub fn get_pages(&self) -> Option { + unsafe { from_glib_full(gtk_sys::gtk_assistant_get_pages(self.to_glib_none().0)) } } - fn insert_page>(&self, page: &P, position: i32) -> i32 { + pub fn insert_page>(&self, page: &P, position: i32) -> i32 { unsafe { gtk_sys::gtk_assistant_insert_page( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, position, ) } } - fn next_page(&self) { + pub fn next_page(&self) { unsafe { - gtk_sys::gtk_assistant_next_page(self.as_ref().to_glib_none().0); + gtk_sys::gtk_assistant_next_page(self.to_glib_none().0); } } - fn prepend_page>(&self, page: &P) -> i32 { + pub fn prepend_page>(&self, page: &P) -> i32 { unsafe { gtk_sys::gtk_assistant_prepend_page( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, ) } } - fn previous_page(&self) { + pub fn previous_page(&self) { unsafe { - gtk_sys::gtk_assistant_previous_page(self.as_ref().to_glib_none().0); + gtk_sys::gtk_assistant_previous_page(self.to_glib_none().0); } } - fn remove_action_widget>(&self, child: &P) { + pub fn remove_action_widget>(&self, child: &P) { unsafe { gtk_sys::gtk_assistant_remove_action_widget( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, child.as_ref().to_glib_none().0, ); } } - fn remove_page(&self, page_num: i32) { + pub fn remove_page(&self, page_num: i32) { unsafe { - gtk_sys::gtk_assistant_remove_page(self.as_ref().to_glib_none().0, page_num); + gtk_sys::gtk_assistant_remove_page(self.to_glib_none().0, page_num); } } - fn set_current_page(&self, page_num: i32) { + pub fn set_current_page(&self, page_num: i32) { unsafe { - gtk_sys::gtk_assistant_set_current_page(self.as_ref().to_glib_none().0, page_num); + gtk_sys::gtk_assistant_set_current_page(self.to_glib_none().0, page_num); } } - fn set_forward_page_func(&self, page_func: Option i32 + 'static>>) { + pub fn set_forward_page_func(&self, page_func: Option i32 + 'static>>) { let page_func_data: Box_ i32 + 'static>>> = Box_::new(page_func); unsafe extern "C" fn page_func_func( current_page: libc::c_int, @@ -810,7 +202,7 @@ impl> AssistantExt for O { let super_callback0: Box_ i32 + 'static>>> = page_func_data; unsafe { gtk_sys::gtk_assistant_set_forward_page_func( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page_func, Box_::into_raw(super_callback0) as *mut _, destroy_call3, @@ -818,47 +210,47 @@ impl> AssistantExt for O { } } - fn set_page_complete>(&self, page: &P, complete: bool) { + pub fn set_page_complete>(&self, page: &P, complete: bool) { unsafe { gtk_sys::gtk_assistant_set_page_complete( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, complete.to_glib(), ); } } - fn set_page_title>(&self, page: &P, title: &str) { + pub fn set_page_title>(&self, page: &P, title: &str) { unsafe { gtk_sys::gtk_assistant_set_page_title( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, title.to_glib_none().0, ); } } - fn set_page_type>(&self, page: &P, type_: AssistantPageType) { + pub fn set_page_type>(&self, page: &P, type_: AssistantPageType) { unsafe { gtk_sys::gtk_assistant_set_page_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, page.as_ref().to_glib_none().0, type_.to_glib(), ); } } - fn update_buttons_state(&self) { + pub fn update_buttons_state(&self) { unsafe { - gtk_sys::gtk_assistant_update_buttons_state(self.as_ref().to_glib_none().0); + gtk_sys::gtk_assistant_update_buttons_state(self.to_glib_none().0); } } - fn get_property_use_header_bar(&self) -> i32 { + pub fn get_property_use_header_bar(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, + self.as_ptr() as *mut gobject_sys::GObject, b"use-header-bar\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); @@ -869,146 +261,152 @@ impl> AssistantExt for O { } } - fn connect_apply(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn apply_trampoline( + pub fn connect_apply(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn apply_trampoline( this: *mut gtk_sys::GtkAssistant, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"apply\0".as_ptr() as *const _, - Some(transmute(apply_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + apply_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_cancel(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn cancel_trampoline( + pub fn connect_cancel(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn cancel_trampoline( this: *mut gtk_sys::GtkAssistant, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"cancel\0".as_ptr() as *const _, - Some(transmute(cancel_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + cancel_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_close(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn close_trampoline( + pub fn connect_close(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn close_trampoline( this: *mut gtk_sys::GtkAssistant, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"close\0".as_ptr() as *const _, - Some(transmute(close_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + close_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_escape(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn escape_trampoline( + pub fn connect_escape(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn escape_trampoline( this: *mut gtk_sys::GtkAssistant, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"escape\0".as_ptr() as *const _, - Some(transmute(escape_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + escape_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn emit_escape(&self) { + pub fn emit_escape(&self) { let _ = unsafe { - glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) + glib::Object::from_glib_borrow(self.as_ptr() as *mut gobject_sys::GObject) .emit("escape", &[]) .unwrap() }; } - fn connect_prepare(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn prepare_trampoline( + pub fn connect_prepare(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn prepare_trampoline( this: *mut gtk_sys::GtkAssistant, page: *mut gtk_sys::GtkWidget, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f( - &Assistant::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(page), - ) + f(&from_glib_borrow(this), &from_glib_borrow(page)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"prepare\0".as_ptr() as *const _, - Some(transmute(prepare_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + prepare_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } - fn connect_property_pages_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_pages_trampoline( + pub fn connect_property_pages_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_pages_trampoline( this: *mut gtk_sys::GtkAssistant, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::pages\0".as_ptr() as *const _, - Some(transmute(notify_pages_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_pages_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } } +impl Default for Assistant { + fn default() -> Self { + Self::new() + } +} + impl fmt::Display for Assistant { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Assistant") diff --git a/src/auto/assistant_page.rs b/src/auto/assistant_page.rs index 150b81c328d3..3833b2a5b38a 100644 --- a/src/auto/assistant_page.rs +++ b/src/auto/assistant_page.rs @@ -19,7 +19,7 @@ use AssistantPageType; use Widget; glib_wrapper! { - pub struct AssistantPage(Object); + pub struct AssistantPage(Object); match fn { get_type => || gtk_sys::gtk_assistant_page_get_type(), @@ -122,7 +122,9 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::complete\0".as_ptr() as *const _, - Some(transmute(notify_complete_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_complete_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -145,7 +147,9 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::page-type\0".as_ptr() as *const _, - Some(transmute(notify_page_type_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_type_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -168,7 +172,9 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::title\0".as_ptr() as *const _, - Some(transmute(notify_title_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_title_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/box_.rs b/src/auto/box_.rs index 0e2133da99ef..ce41eee14cf1 100644 --- a/src/auto/box_.rs +++ b/src/auto/box_.rs @@ -2,31 +2,25 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; -use Align; +use Accessible; use BaselinePosition; use Buildable; -use Container; -use LayoutManager; use Orientable; use Orientation; -use Overflow; use Widget; glib_wrapper! { - pub struct Box(Object) @extends Container, Widget, @implements Buildable, Orientable; + pub struct Box(Object) @extends Widget, @implements Accessible, Buildable, Orientable; match fn { get_type => || gtk_sys::gtk_box_get_type(), @@ -43,342 +37,11 @@ impl Box { } } -#[derive(Clone, Default)] -pub struct BoxBuilder { - baseline_position: Option, - homogeneous: Option, - spacing: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - orientation: Option, -} - -impl BoxBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> Box { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref baseline_position) = self.baseline_position { - properties.push(("baseline-position", baseline_position)); - } - if let Some(ref homogeneous) = self.homogeneous { - properties.push(("homogeneous", homogeneous)); - } - if let Some(ref spacing) = self.spacing { - properties.push(("spacing", spacing)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref orientation) = self.orientation { - properties.push(("orientation", orientation)); - } - glib::Object::new(Box::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { - self.baseline_position = Some(baseline_position); - self - } - - pub fn homogeneous(mut self, homogeneous: bool) -> Self { - self.homogeneous = Some(homogeneous); - self - } - - pub fn spacing(mut self, spacing: i32) -> Self { - self.spacing = Some(spacing); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn orientation(mut self, orientation: Orientation) -> Self { - self.orientation = Some(orientation); - self - } -} - pub const NONE_BOX: Option<&Box> = None; pub trait BoxExt: 'static { + fn append>(&self, child: &P); + fn get_baseline_position(&self) -> BaselinePosition; fn get_homogeneous(&self) -> bool; @@ -387,6 +50,10 @@ pub trait BoxExt: 'static { fn insert_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>); + fn prepend>(&self, child: &P); + + fn remove>(&self, child: &P); + fn reorder_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>); fn set_baseline_position(&self, position: BaselinePosition); @@ -406,6 +73,15 @@ pub trait BoxExt: 'static { } impl> BoxExt for O { + fn append>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_append( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + fn get_baseline_position(&self) -> BaselinePosition { unsafe { from_glib(gtk_sys::gtk_box_get_baseline_position( @@ -436,6 +112,24 @@ impl> BoxExt for O { } } + fn prepend>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_prepend( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + fn remove>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_remove( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + fn reorder_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>) { unsafe { gtk_sys::gtk_box_reorder_child_after( @@ -479,15 +173,15 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::baseline-position\0".as_ptr() as *const _, - Some(transmute( - notify_baseline_position_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_baseline_position_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -503,14 +197,16 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::homogeneous\0".as_ptr() as *const _, - Some(transmute(notify_homogeneous_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_homogeneous_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -525,14 +221,16 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::spacing\0".as_ptr() as *const _, - Some(transmute(notify_spacing_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_spacing_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/box_layout.rs b/src/auto/box_layout.rs index 624cadebe2ff..b60500e14d7e 100644 --- a/src/auto/box_layout.rs +++ b/src/auto/box_layout.rs @@ -117,15 +117,15 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::baseline-position\0".as_ptr() as *const _, - Some(transmute( - notify_baseline_position_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_baseline_position_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -141,14 +141,16 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::homogeneous\0".as_ptr() as *const _, - Some(transmute(notify_homogeneous_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_homogeneous_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -163,14 +165,16 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::spacing\0".as_ptr() as *const _, - Some(transmute(notify_spacing_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_spacing_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/buildable.rs b/src/auto/buildable.rs index a6dce90abd2d..802ff95aa0ad 100644 --- a/src/auto/buildable.rs +++ b/src/auto/buildable.rs @@ -21,84 +21,66 @@ glib_wrapper! { pub const NONE_BUILDABLE: Option<&Buildable> = None; pub trait BuildableExt: 'static { - fn add_child, Q: IsA>( - &self, - builder: &P, - child: &Q, - type_: Option<&str>, - ); + fn add_child>(&self, builder: &Builder, child: &P, type_: Option<&str>); - fn construct_child>(&self, builder: &P, name: &str) -> Option; + fn construct_child(&self, builder: &Builder, name: &str) -> Option; - //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); + //fn custom_finished>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); + //fn custom_tag_end>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option; + //fn custom_tag_start>(&self, builder: &Builder, child: Option<&P>, tagname: &str, parser: /*Ignored*/BuildableParser, data: /*Unimplemented*/&mut Option) -> bool; - fn get_internal_child>( - &self, - builder: &P, - childname: &str, - ) -> Option; + fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option; fn get_name(&self) -> Option; - fn parser_finished>(&self, builder: &P); + fn parser_finished(&self, builder: &Builder); - fn set_buildable_property>(&self, builder: &P, name: &str, value: &glib::Value); + fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value); fn set_name(&self, name: &str); } impl> BuildableExt for O { - fn add_child, Q: IsA>( - &self, - builder: &P, - child: &Q, - type_: Option<&str>, - ) { + fn add_child>(&self, builder: &Builder, child: &P, type_: Option<&str>) { unsafe { gtk_sys::gtk_buildable_add_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, child.as_ref().to_glib_none().0, type_.to_glib_none().0, ); } } - fn construct_child>(&self, builder: &P, name: &str) -> Option { + fn construct_child(&self, builder: &Builder, name: &str) -> Option { unsafe { from_glib_full(gtk_sys::gtk_buildable_construct_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, name.to_glib_none().0, )) } } - //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + //fn custom_finished>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option) { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_finished() } //} - //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + //fn custom_tag_end>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option) { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_end() } //} - //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option { + //fn custom_tag_start>(&self, builder: &Builder, child: Option<&P>, tagname: &str, parser: /*Ignored*/BuildableParser, data: /*Unimplemented*/&mut Option) -> bool { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_start() } //} - fn get_internal_child>( - &self, - builder: &P, - childname: &str, - ) -> Option { + fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option { unsafe { from_glib_none(gtk_sys::gtk_buildable_get_internal_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, childname.to_glib_none().0, )) } @@ -112,25 +94,20 @@ impl> BuildableExt for O { } } - fn parser_finished>(&self, builder: &P) { + fn parser_finished(&self, builder: &Builder) { unsafe { gtk_sys::gtk_buildable_parser_finished( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, ); } } - fn set_buildable_property>( - &self, - builder: &P, - name: &str, - value: &glib::Value, - ) { + fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value) { unsafe { gtk_sys::gtk_buildable_set_buildable_property( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0, ); diff --git a/src/auto/builder.rs b/src/auto/builder.rs index 862c70248543..e3a0b23ff21f 100644 --- a/src/auto/builder.rs +++ b/src/auto/builder.rs @@ -3,8 +3,8 @@ // DO NOT EDIT use glib; -use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -15,8 +15,6 @@ use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; -use Application; -use Widget; glib_wrapper! { pub struct Builder(Object); @@ -32,7 +30,7 @@ impl Builder { unsafe { from_glib_full(gtk_sys::gtk_builder_new()) } } - pub fn new_from_resource(resource_path: &str) -> Builder { + pub fn from_resource(resource_path: &str) -> Builder { assert_initialized_main_thread!(); unsafe { from_glib_full(gtk_sys::gtk_builder_new_from_resource( @@ -41,7 +39,7 @@ impl Builder { } } - pub fn new_from_string(string: &str) -> Builder { + pub fn from_string(string: &str) -> Builder { assert_initialized_main_thread!(); let length = string.len() as isize; unsafe { @@ -51,87 +49,12 @@ impl Builder { )) } } -} - -impl Default for Builder { - fn default() -> Self { - Self::new() - } -} - -pub const NONE_BUILDER: Option<&Builder> = None; - -pub trait BuilderExt: 'static { - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: P); - - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - - fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error>; - - fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error>; - - fn add_objects_from_resource( - &self, - resource_path: &str, - object_ids: &[&str], - ) -> Result<(), glib::Error>; - - fn add_objects_from_string(&self, buffer: &str, object_ids: &[&str]) - -> Result<(), glib::Error>; - - //fn connect_signals(&self, user_data: /*Unimplemented*/Option); - - fn expose_object>(&self, name: &str, object: &P); - - fn extend_with_template>( - &self, - widget: &P, - template_type: glib::types::Type, - buffer: &str, - ) -> Result<(), glib::Error>; - fn get_application(&self) -> Option; - - fn get_objects(&self) -> Vec; - - fn get_translation_domain(&self) -> Option; - - fn get_type_from_name(&self, type_name: &str) -> glib::types::Type; - - //fn lookup_callback_symbol(&self, callback_name: &str) -> Option>; - - fn set_application>(&self, application: &P); - - fn set_translation_domain(&self, domain: Option<&str>); - - //fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result; - - fn value_from_string_type( - &self, - type_: glib::types::Type, - string: &str, - ) -> Result; - - fn connect_property_translation_domain_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> BuilderExt for O { - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: P) { - // unsafe { TODO: call gtk_sys:gtk_builder_add_callback_symbol() } - //} - - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call gtk_sys:gtk_builder_add_callback_symbols() } - //} - - fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error> { + pub fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_from_resource( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, resource_path.to_glib_none().0, &mut error, ); @@ -143,12 +66,12 @@ impl> BuilderExt for O { } } - fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error> { + pub fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error> { let length = buffer.len() as isize; unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_from_string( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, buffer.to_glib_none().0, length, &mut error, @@ -161,7 +84,7 @@ impl> BuilderExt for O { } } - fn add_objects_from_resource( + pub fn add_objects_from_resource( &self, resource_path: &str, object_ids: &[&str], @@ -169,7 +92,7 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_objects_from_resource( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, resource_path.to_glib_none().0, object_ids.to_glib_none().0, &mut error, @@ -182,7 +105,7 @@ impl> BuilderExt for O { } } - fn add_objects_from_string( + pub fn add_objects_from_string( &self, buffer: &str, object_ids: &[&str], @@ -191,7 +114,7 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_objects_from_string( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, buffer.to_glib_none().0, length, object_ids.to_glib_none().0, @@ -205,23 +128,23 @@ impl> BuilderExt for O { } } - //fn connect_signals(&self, user_data: /*Unimplemented*/Option) { - // unsafe { TODO: call gtk_sys:gtk_builder_connect_signals() } + //pub fn create_closure>(&self, function_name: &str, flags: /*Ignored*/BuilderClosureFlags, object: Option<&P>) -> Result, glib::Error> { + // unsafe { TODO: call gtk_sys:gtk_builder_create_closure() } //} - fn expose_object>(&self, name: &str, object: &P) { + pub fn expose_object>(&self, name: &str, object: &P) { unsafe { gtk_sys::gtk_builder_expose_object( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, name.to_glib_none().0, object.as_ref().to_glib_none().0, ); } } - fn extend_with_template>( + pub fn extend_with_template>( &self, - widget: &P, + object: &P, template_type: glib::types::Type, buffer: &str, ) -> Result<(), glib::Error> { @@ -229,8 +152,8 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_extend_with_template( - self.as_ref().to_glib_none().0, - widget.as_ref().to_glib_none().0, + self.to_glib_none().0, + object.as_ref().to_glib_none().0, template_type.to_glib(), buffer.to_glib_none().0, length, @@ -244,66 +167,70 @@ impl> BuilderExt for O { } } - fn get_application(&self) -> Option { + pub fn get_current_object(&self) -> Option { unsafe { - from_glib_none(gtk_sys::gtk_builder_get_application( - self.as_ref().to_glib_none().0, + from_glib_none(gtk_sys::gtk_builder_get_current_object( + self.to_glib_none().0, )) } } - fn get_objects(&self) -> Vec { + pub fn get_objects(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_builder_get_objects( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_translation_domain(&self) -> Option { + //pub fn get_scope(&self) -> /*Ignored*/Option { + // unsafe { TODO: call gtk_sys:gtk_builder_get_scope() } + //} + + pub fn get_translation_domain(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_builder_get_translation_domain( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_type_from_name(&self, type_name: &str) -> glib::types::Type { + pub fn get_type_from_name(&self, type_name: &str) -> glib::types::Type { unsafe { from_glib(gtk_sys::gtk_builder_get_type_from_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, type_name.to_glib_none().0, )) } } - //fn lookup_callback_symbol(&self, callback_name: &str) -> Option> { - // unsafe { TODO: call gtk_sys:gtk_builder_lookup_callback_symbol() } - //} - - fn set_application>(&self, application: &P) { + pub fn set_current_object>(&self, current_object: Option<&P>) { unsafe { - gtk_sys::gtk_builder_set_application( - self.as_ref().to_glib_none().0, - application.as_ref().to_glib_none().0, + gtk_sys::gtk_builder_set_current_object( + self.to_glib_none().0, + current_object.map(|p| p.as_ref()).to_glib_none().0, ); } } - fn set_translation_domain(&self, domain: Option<&str>) { + //pub fn set_scope(&self, scope: /*Ignored*/Option<&BuilderScope>) { + // unsafe { TODO: call gtk_sys:gtk_builder_set_scope() } + //} + + pub fn set_translation_domain(&self, domain: Option<&str>) { unsafe { gtk_sys::gtk_builder_set_translation_domain( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, domain.to_glib_none().0, ); } } - //fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result { + //pub fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result { // unsafe { TODO: call gtk_sys:gtk_builder_value_from_string() } //} - fn value_from_string_type( + pub fn value_from_string_type( &self, type_: glib::types::Type, string: &str, @@ -312,7 +239,7 @@ impl> BuilderExt for O { let mut value = glib::Value::uninitialized(); let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_value_from_string_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, type_.to_glib(), string.to_glib_none().0, value.to_glib_none_mut().0, @@ -326,27 +253,75 @@ impl> BuilderExt for O { } } - fn connect_property_translation_domain_notify( + pub fn connect_property_current_object_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_current_object_trampoline( + this: *mut gtk_sys::GtkBuilder, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::current-object\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_current_object_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_scope_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_scope_trampoline( + this: *mut gtk_sys::GtkBuilder, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::scope\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_scope_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_translation_domain_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_translation_domain_trampoline( + unsafe extern "C" fn notify_translation_domain_trampoline( this: *mut gtk_sys::GtkBuilder, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Builder::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::translation-domain\0".as_ptr() as *const _, - Some(transmute( - notify_translation_domain_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_translation_domain_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -354,6 +329,12 @@ impl> BuilderExt for O { } } +impl Default for Builder { + fn default() -> Self { + Self::new() + } +} + impl fmt::Display for Builder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Builder") diff --git a/src/auto/button.rs b/src/auto/button.rs index 9840aaa6423a..ed1f846ea672 100644 --- a/src/auto/button.rs +++ b/src/auto/button.rs @@ -2,7 +2,6 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gdk; use glib; use glib::object::Cast; use glib::object::IsA; @@ -11,26 +10,19 @@ use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use glib::StaticType; -use glib::ToValue; use glib_sys; use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; use Actionable; -use Align; -use Bin; use Buildable; -use Container; -use LayoutManager; -use Overflow; -use ReliefStyle; use Widget; glib_wrapper! { - pub struct Button(Object) @extends Bin, Container, Widget, @implements Buildable, Actionable; + pub struct Button(Object) @extends Widget, @implements Accessible, Buildable, Actionable; match fn { get_type => || gtk_sys::gtk_button_get_type(), @@ -43,7 +35,7 @@ impl Button { unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new()).unsafe_cast() } } - pub fn new_from_icon_name(icon_name: Option<&str>) -> Button { + pub fn from_icon_name(icon_name: Option<&str>) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_from_icon_name( @@ -53,7 +45,7 @@ impl Button { } } - pub fn new_with_label(label: &str) -> Button { + pub fn with_label(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_with_label(label.to_glib_none().0)) @@ -61,7 +53,7 @@ impl Button { } } - pub fn new_with_mnemonic(label: &str) -> Button { + pub fn with_mnemonic(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_with_mnemonic( @@ -78,367 +70,27 @@ impl Default for Button { } } -#[derive(Clone, Default)] -pub struct ButtonBuilder { - icon_name: Option, - label: Option, - relief: Option, - use_underline: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - action_name: Option, -} - -impl ButtonBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> Button { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); - } - if let Some(ref label) = self.label { - properties.push(("label", label)); - } - if let Some(ref relief) = self.relief { - properties.push(("relief", relief)); - } - if let Some(ref use_underline) = self.use_underline { - properties.push(("use-underline", use_underline)); - } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - if let Some(ref action_name) = self.action_name { - properties.push(("action-name", action_name)); - } - glib::Object::new(Button::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn label(mut self, label: &str) -> Self { - self.label = Some(label.to_string()); - self - } - - pub fn relief(mut self, relief: ReliefStyle) -> Self { - self.relief = Some(relief); - self - } - - pub fn use_underline(mut self, use_underline: bool) -> Self { - self.use_underline = Some(use_underline); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn action_name(mut self, action_name: &str) -> Self { - self.action_name = Some(action_name.to_string()); - self - } -} - pub const NONE_BUTTON: Option<&Button> = None; pub trait ButtonExt: 'static { - fn clicked(&self); + fn get_child(&self) -> Option; + + fn get_has_frame(&self) -> bool; fn get_icon_name(&self) -> Option; fn get_label(&self) -> Option; - fn get_relief(&self) -> ReliefStyle; - fn get_use_underline(&self) -> bool; + fn set_child>(&self, child: Option<&P>); + + fn set_has_frame(&self, has_frame: bool); + fn set_icon_name(&self, icon_name: &str); fn set_label(&self, label: &str); - fn set_relief(&self, relief: ReliefStyle); - fn set_use_underline(&self, use_underline: bool); fn connect_activate(&self, f: F) -> SignalHandlerId; @@ -449,12 +101,14 @@ pub trait ButtonExt: 'static { fn emit_clicked(&self); + fn connect_property_child_notify(&self, f: F) -> SignalHandlerId; + + fn connect_property_has_frame_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_icon_name_notify(&self, f: F) -> SignalHandlerId; fn connect_property_label_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_relief_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_use_underline_notify( &self, f: F, @@ -462,9 +116,19 @@ pub trait ButtonExt: 'static { } impl> ButtonExt for O { - fn clicked(&self) { + fn get_child(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_button_get_child( + self.as_ref().to_glib_none().0, + )) + } + } + + fn get_has_frame(&self) -> bool { unsafe { - gtk_sys::gtk_button_clicked(self.as_ref().to_glib_none().0); + from_glib(gtk_sys::gtk_button_get_has_frame( + self.as_ref().to_glib_none().0, + )) } } @@ -484,19 +148,26 @@ impl> ButtonExt for O { } } - fn get_relief(&self) -> ReliefStyle { + fn get_use_underline(&self) -> bool { unsafe { - from_glib(gtk_sys::gtk_button_get_relief( + from_glib(gtk_sys::gtk_button_get_use_underline( self.as_ref().to_glib_none().0, )) } } - fn get_use_underline(&self) -> bool { + fn set_child>(&self, child: Option<&P>) { unsafe { - from_glib(gtk_sys::gtk_button_get_use_underline( + gtk_sys::gtk_button_set_child( self.as_ref().to_glib_none().0, - )) + child.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + fn set_has_frame(&self, has_frame: bool) { + unsafe { + gtk_sys::gtk_button_set_has_frame(self.as_ref().to_glib_none().0, has_frame.to_glib()); } } @@ -515,12 +186,6 @@ impl> ButtonExt for O { } } - fn set_relief(&self, relief: ReliefStyle) { - unsafe { - gtk_sys::gtk_button_set_relief(self.as_ref().to_glib_none().0, relief.to_glib()); - } - } - fn set_use_underline(&self, use_underline: bool) { unsafe { gtk_sys::gtk_button_set_use_underline( @@ -538,14 +203,16 @@ impl> ButtonExt for O { P: IsA