diff --git a/.travis.yml b/.travis.yml index 0ba6be3e0f..e045d09730 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,69 @@ +dist: xenial language: rust -rust: - - nightly - - beta - - stable -env: - - GTK=3.4 - - GTK=3.18 +matrix: + include: + - os: linux + rust: nightly + env: GTK=3.14 FEATURES=futures + - os: linux + rust: nightly + env: GTK=3.24 FEATURES=v3_16,futures + - os: linux + rust: beta + env: GTK=3.14 FEATURES= + - os: linux + rust: beta + env: GTK=3.24 FEATURES=v3_16 + - os: linux + rust: 1.34.0 + env: GTK=3.14 FEATURES= + - os: linux + rust: 1.34.0 + env: GTK=3.24 FEATURES=v3_16 + - os: osx + rust: nightly + env: GTK=3.14 FEATURES=futures + # - os: osx + # rust: nightly + # env: GTK=3.24 FEATURES=v3_16 + - os: osx + rust: beta + env: GTK=3.14 FEATURES= + # - os: osx + # rust: beta + # env: GTK=3.24 FEATURES=v3_16 + - os: osx + rust: stable + env: GTK=3.14 FEATURES= + # - os: osx + # rust: stable + # env: GTK=3.24 FEATURES=v3_16 addons: apt: packages: - libgtk-3-dev + - libmount-dev +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libffi gtk+3 cairo atk; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig; + fi script: - rustc --version + - if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ "$GTK" == "3.14" ]; then + rustup component add rustfmt; + make regen_check; + fi - ./check_init_asserts - - cargo install clippy || touch clippy_failed - - if [ ! -f clippy_failed ]; then cargo clippy; fi - - cargo test --features embed-lgpl-docs --jobs 1 - - cargo doc --features "dox" + - cargo doc --features "dox,embed-lgpl-docs" + - cargo test --features "$FEATURES,embed-lgpl-docs" # catch any sneaked in lgpl docs - - cargo build --features purge-lgpl-docs --jobs 1 + - cargo build --features "$FEATURES,purge-lgpl-docs" --jobs 1 - git diff -R --exit-code + - rustc --version - mkdir .cargo - echo 'paths = ["."]' > .cargo/config - git clone -q --depth 50 -b master https://github.com/gtk-rs/examples _examples - cd _examples - - ./build.sh + - ./build_travis.sh diff --git a/Cargo.toml b/Cargo.toml index 722c60c568..8db7017d32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,13 @@ name = "gtk" homepage = "http://gtk-rs.org/" authors = ["The Gtk-rs Project Developers"] readme = "README.md" -version = "0.3.0" +version = "0.7.1" keywords = ["gtk", "gtk-rs", "gnome", "GUI"] repository = "https://github.com/gtk-rs/gtk" build = "build.rs" +exclude = [ + "gir-files/*", +] [badges] appveyor = { repository = "GuillaumeGomez/gtk", service = "github" } @@ -20,36 +23,50 @@ travis-ci = { repository = "gtk-rs/gtk" } name = "gtk" [features] -v3_6 = ["gtk-sys/v3_6", "gdk/v3_6"] -v3_20 = ["v3_18", "gtk-sys/v3_20", "gdk/v3_20"] -v3_18 = ["v3_16", "gtk-sys/v3_18", "gdk/v3_18"] -purge-lgpl-docs = ["gtk-rs-lgpl-docs", "gdk/purge-lgpl-docs"] +v3_16 = ["gtk-sys/v3_16", "gio/v2_44", "gdk/v3_16"] +v3_18 = ["v3_16", "gtk-sys/v3_18"] +v3_20 = ["v3_18", "gtk-sys/v3_20"] v3_22 = ["v3_20", "gtk-sys/v3_22", "gdk/v3_22"] -v3_12 = ["v3_10", "gtk-sys/v3_12", "gdk/v3_12"] -v3_8 = ["v3_6", "gtk-sys/v3_8", "gdk/v3_8"] +v3_22_20 = ["v3_22", "gtk-sys/v3_22"] +v3_22_26 = ["v3_22_20", "gtk-sys/v3_22_26"] +v3_22_27 = ["v3_22_26", "gtk-sys/v3_22_27"] +v3_22_29 = ["v3_22_27", "gtk-sys/v3_22_29"] +v3_22_30 = ["v3_22_29", "gtk-sys/v3_22_30"] +v3_24 = ["v3_22_30", "gtk-sys/v3_24"] +purge-lgpl-docs = ["gtk-rs-lgpl-docs", "gdk/purge-lgpl-docs"] embed-lgpl-docs = ["gtk-rs-lgpl-docs", "gdk/embed-lgpl-docs"] -v3_16 = ["v3_14", "gtk-sys/v3_16", "gdk/v3_16"] -v3_10 = ["v3_8", "gtk-sys/v3_10", "gdk/v3_10"] -v3_14 = ["v3_12", "gtk-sys/v3_14", "gdk/v3_14"] dox = ["gdk/dox", "gtk-sys/dox"] +futures = ["futures-preview", "fragile", "gio/futures"] +subclassing = ["glib/subclassing", "gio/subclassing"] + +[target.'cfg(target_os = "macos")'.build-dependencies] +cc = "^1.0" [build-dependencies.gtk-rs-lgpl-docs] version = "0.1.3" optional = true [dependencies] -cairo-rs = "0.3.0" -cairo-sys-rs = "0.5.0" -gobject-sys = "0.5.0" -glib = "0.4.0" -gio-sys = "0.5.0" -gdk = "0.7.0" -gdk-pixbuf-sys = "0.5.0" -gdk-pixbuf = "0.3.0" -pango = "0.3.0" -gio = "0.3.0" -gtk-sys = "0.5.0" -glib-sys = "0.5.0" -gdk-sys = "0.5.0" +atk = "0.7.0" +cairo-rs = "0.7.0" +cairo-sys-rs = "0.9.0" +gobject-sys = "0.9.0" +glib-sys = "0.9.0" +glib = "0.8.0" +gio-sys = "0.9.0" +gio = "0.7.0" +gdk-sys = "0.9.0" +gdk = "0.11.0" +gdk-pixbuf-sys = "0.9.0" +gdk-pixbuf = "0.7.0" +pango = "0.7.0" +pango-sys = "0.9.0" +gtk-sys = "0.9.0" libc = "0.2" bitflags = "1.0" +lazy_static = "1.0" +fragile = { version = "0.3", optional = true } +futures-preview = { version = "0.3.0-alpha", optional = true } + +[dev-dependencies] +gir-format-check = "^0.1" diff --git a/Gir.toml b/Gir.toml index 473ef44d2b..cae1ed0d56 100644 --- a/Gir.toml +++ b/Gir.toml @@ -2,32 +2,31 @@ girs_dir = "gir-files" library = "Gtk" version = "3.0" -min_cfg_version = "3.4" +min_cfg_version = "3.14" target_path = "." work_mode = "normal" generate_safety_asserts = true deprecate_by_min_version = true +single_version_file = true generate = [ - "Gtk.IconSet", "Gtk.AccelFlags", + "Gtk.AccelLabel", "Gtk.Adjustment", "Gtk.Align", - "Gtk.Alignment", + "Gtk.AppChooserButton", "Gtk.AppChooserWidget", "Gtk.ApplicationInhibitFlags", - "Gtk.ApplicationWindow", - "Gtk.Arrow", "Gtk.ArrowType", "Gtk.AspectFrame", "Gtk.AssistantPageType", "Gtk.BaselinePosition", "Gtk.Bin", + "Gtk.BorderStyle", "Gtk.BuilderError", "Gtk.Button", "Gtk.ButtonBox", "Gtk.ButtonBoxStyle", - "Gtk.ButtonRole", "Gtk.ButtonsType", "Gtk.Calendar", "Gtk.CalendarDisplayOptions", @@ -42,7 +41,6 @@ generate = [ "Gtk.CellRendererState", "Gtk.CheckButton", "Gtk.CheckMenuItem", - "Gtk.ColorButton", "Gtk.ColorChooserDialog", "Gtk.ColorChooserWidget", "Gtk.ComboBoxText", @@ -66,14 +64,12 @@ generate = [ "Gtk.FileChooserConfirmation", "Gtk.FileChooserDialog", "Gtk.FileChooserError", + "Gtk.FileChooserNative", "Gtk.FileChooserWidget", "Gtk.FileFilter", "Gtk.FileFilterFlags", - "Gtk.Fixed", - "Gtk.FlowBox", "Gtk.FlowBoxChild", "Gtk.FontButton", - "Gtk.FontChooser", "Gtk.FontChooserDialog", "Gtk.FontChooserWidget", "Gtk.Frame", @@ -86,27 +82,22 @@ generate = [ "Gtk.GestureSwipe", "Gtk.GestureZoom", "Gtk.IconInfo", - "Gtk.IconFactory", "Gtk.IconLookupFlags", "Gtk.IconSize", - "Gtk.IconSource", "Gtk.IconThemeError", "Gtk.IconViewDropPosition", - "Gtk.ImageMenuItem", "Gtk.ImageType", - "Gtk.InfoBar", "Gtk.IMMulticontext", "Gtk.IMPreeditStyle", "Gtk.IMStatusStyle", - "Gtk.InputHints", "Gtk.InputPurpose", "Gtk.JunctionSides", "Gtk.Justification", "Gtk.LevelBar", "Gtk.LevelBarMode", "Gtk.License", - "Gtk.ListBox", "Gtk.ListBoxRow", + "Gtk.LockButton", "Gtk.MenuBar", "Gtk.MenuButton", "Gtk.MenuDirectionType", @@ -115,9 +106,12 @@ generate = [ "Gtk.MessageType", "Gtk.Misc", "Gtk.ModelButton", + "Gtk.MountOperation", "Gtk.MovementStep", + "Gtk.NativeDialog", "Gtk.NotebookTab", "Gtk.NumberUpLayout", + "Gtk.OffscreenWindow", "Gtk.Orientable", "Gtk.Orientation", "Gtk.PackDirection", @@ -126,24 +120,24 @@ generate = [ "Gtk.PageSet", "Gtk.PanDirection", "Gtk.PlacesOpenFlags", - "Gtk.PlacesSidebar", "Gtk.PolicyType", "Gtk.PopoverConstraint", "Gtk.PositionType", "Gtk.PrintDuplex", "Gtk.PrintError", - "Gtk.PrintQuality", "Gtk.PrintOperation", "Gtk.PrintOperationAction", "Gtk.PrintOperationPreview", "Gtk.PrintOperationResult", "Gtk.PrintPages", + "Gtk.PrintQuality", "Gtk.PrintStatus", "Gtk.ProgressBar", "Gtk.PropagationPhase", "Gtk.RecentChooser", "Gtk.RecentChooserDialog", "Gtk.RecentChooserError", + "Gtk.RecentChooserMenu", "Gtk.RecentChooserWidget", "Gtk.RecentFilter", "Gtk.RecentFilterFlags", @@ -154,7 +148,6 @@ generate = [ "Gtk.RegionFlags", "Gtk.ReliefStyle", "Gtk.ResizeMode", - "Gtk.ResponseType", "Gtk.Revealer", "Gtk.RevealerTransitionType", "Gtk.Scale", @@ -184,11 +177,8 @@ generate = [ "Gtk.StateFlags", "Gtk.StateType", "Gtk.Statusbar", - "Gtk.StatusIcon", - "Gtk.StyleContextPrintFlags", "Gtk.StyleProperties", "Gtk.StyleProvider", - "Gtk.SymbolicColor", "Gtk.TargetFlags", "Gtk.TextAttributes", "Gtk.TextChildAnchor", @@ -206,7 +196,8 @@ generate = [ "Gtk.ToolPaletteDragTargets", "Gtk.ToolShell", "Gtk.Tooltip", - "Gtk.TreeIter", + "Gtk.TreeDragDest", + "Gtk.TreeDragSource", "Gtk.TreeModelFlags", "Gtk.TreeViewColumnSizing", "Gtk.TreeViewDropPosition", @@ -215,20 +206,164 @@ generate = [ "Gtk.Viewport", "Gtk.VolumeButton", "Gtk.WidgetHelpType", + "Gtk.WidgetPath", "Gtk.WindowGroup", "Gtk.WindowPosition", "Gtk.WindowType", "Gtk.WrapMode", ] +builders = [ + "Gtk.AboutDialogBuilder", + "Gtk.AccelLabelBuilder", + "Gtk.ActionBarBuilder", + "Gtk.AlignmentBuilder", + "Gtk.AppChooserButtonBuilder", + "Gtk.AppChooserDialogBuilder", + "Gtk.AppChooserWidgetBuilder", + "Gtk.ApplicationBuilder", + "Gtk.ApplicationWindowBuilder", + "Gtk.AspectFrameBuilder", + "Gtk.AssistantBuilder", + "Gtk.BoxBuilder", + "Gtk.ButtonBoxBuilder", + "Gtk.ButtonBuilder", + "Gtk.CalendarBuilder", + "Gtk.CellAreaBoxBuilder", + "Gtk.CellRendererAccelBuilder", + "Gtk.CellRendererComboBuilder", + "Gtk.CellRendererPixbufBuilder", + "Gtk.CellRendererProgressBuilder", + "Gtk.CellRendererSpinBuilder", + "Gtk.CellRendererSpinnerBuilder", + "Gtk.CellRendererTextBuilder", + "Gtk.CellRendererToggleBuilder", + "Gtk.CellViewBuilder", + "Gtk.CheckButtonBuilder", + "Gtk.CheckMenuItemBuilder", + "Gtk.ColorButtonBuilder", + "Gtk.ColorChooserDialogBuilder", + "Gtk.ColorChooserWidgetBuilder", + "Gtk.ComboBoxBuilder", + "Gtk.ComboBoxTextBuilder", + "Gtk.DialogBuilder", + "Gtk.DrawingAreaBuilder", + "Gtk.EntryBufferBuilder", + "Gtk.EntryBuilder", + "Gtk.EntryCompletionBuilder", + "Gtk.EventBoxBuilder", + "Gtk.ExpanderBuilder", + "Gtk.FileChooserButtonBuilder", + "Gtk.FileChooserDialogBuilder", + "Gtk.FileChooserNativeBuilder", + "Gtk.FileChooserWidgetBuilder", + "Gtk.FixedBuilder", + "Gtk.FlowBoxBuilder", + "Gtk.FlowBoxChildBuilder", + "Gtk.FontButtonBuilder", + "Gtk.FontChooserDialogBuilder", + "Gtk.FontChooserWidgetBuilder", + "Gtk.FrameBuilder", + "Gtk.GestureDragBuilder", + "Gtk.GestureLongPressBuilder", + "Gtk.GestureMultiPressBuilder", + "Gtk.GesturePanBuilder", + "Gtk.GestureRotateBuilder", + "Gtk.GestureSwipeBuilder", + "Gtk.GestureZoomBuilder", + "Gtk.GLAreaBuilder", + "Gtk.GridBuilder", + "Gtk.HeaderBarBuilder", + "Gtk.ImageBuilder", + "Gtk.ImageMenuItemBuilder", + "Gtk.IMContextSimpleBuilder", + "Gtk.IMMulticontextBuilder", + "Gtk.InfoBarBuilder", + "Gtk.InvisibleBuilder", + "Gtk.LabelBuilder", + "Gtk.LayoutBuilder", + "Gtk.LevelBarBuilder", + "Gtk.LinkButtonBuilder", + "Gtk.ListBoxBuilder", + "Gtk.ListBoxRowBuilder", + "Gtk.LockButtonBuilder", + "Gtk.MenuBarBuilder", + "Gtk.MenuBuilder", + "Gtk.MenuButtonBuilder", + "Gtk.MenuItemBuilder", + "Gtk.MenuToolButtonBuilder", + "Gtk.MessageDialogBuilder", + "Gtk.ModelButtonBuilder", + "Gtk.MountOperationBuilder", + "Gtk.NotebookBuilder", + "Gtk.OffscreenWindowBuilder", + "Gtk.OverlayBuilder", + "Gtk.PadControllerBuilder", + "Gtk.PanedBuilder", + "Gtk.PlacesSidebarBuilder", + "Gtk.PlugBuilder", + "Gtk.PopoverBuilder", + "Gtk.PopoverMenuBuilder", + "Gtk.PrintOperationBuilder", + "Gtk.ProgressBarBuilder", + "Gtk.RadioButtonBuilder", + "Gtk.RadioMenuItemBuilder", + "Gtk.RadioToolButtonBuilder", + "Gtk.RecentChooserDialogBuilder", + "Gtk.RecentChooserMenuBuilder", + "Gtk.RecentChooserWidgetBuilder", + "Gtk.RecentManagerBuilder", + "Gtk.RevealerBuilder", + "Gtk.ScaleBuilder", + "Gtk.ScaleButtonBuilder", + "Gtk.ScrollbarBuilder", + "Gtk.ScrolledWindowBuilder", + "Gtk.SearchBarBuilder", + "Gtk.SearchEntryBuilder", + "Gtk.SeparatorBuilder", + "Gtk.SeparatorMenuItemBuilder", + "Gtk.SeparatorToolItemBuilder", + "Gtk.SizeGroupBuilder", + "Gtk.SocketBuilder", + "Gtk.SpinButtonBuilder", + "Gtk.SpinnerBuilder", + "Gtk.StackBuilder", + "Gtk.StackSidebarBuilder", + "Gtk.StackSwitcherBuilder", + "Gtk.StatusbarBuilder", + "Gtk.StatusIconBuilder", + "Gtk.StyleContextBuilder", + "Gtk.SwitchBuilder", + "Gtk.TextBufferBuilder", + "Gtk.TextMarkBuilder", + "Gtk.TextTagBuilder", + "Gtk.TextViewBuilder", + "Gtk.ToggleButtonBuilder", + "Gtk.ToggleToolButtonBuilder", + "Gtk.ToolbarBuilder", + "Gtk.ToolButtonBuilder", + "Gtk.ToolItemBuilder", + "Gtk.ToolItemGroupBuilder", + "Gtk.ToolPaletteBuilder", + "Gtk.TreeViewColumnBuilder", + "Gtk.ViewportBuilder", + "Gtk.VolumeButtonBuilder", + "Gtk.WindowBuilder", +] + ignore = [ "Gtk.Activatable", ] manual = [ + "Atk.Object", + "cairo.Context", + "cairo.FontOptions", + "cairo.RectangleInt", + "cairo.Region", + "cairo.Surface", "Gdk.AnchorHints", "Gdk.Atom", - "Gdk.Atom_", "Gdk.Device", "Gdk.Display", "Gdk.DragAction", @@ -246,8 +381,9 @@ manual = [ "Gdk.EventMotion", "Gdk.EventProperty", "Gdk.EventProximity", - "Gdk.EventSelection", "Gdk.EventScroll", + "Gdk.EventSelection", + "Gdk.EventSequence", "Gdk.EventVisibility", "Gdk.EventWindowState", "Gdk.FrameClock", @@ -272,33 +408,39 @@ manual = [ "Gio.Application", "Gio.ApplicationFlags", "Gio.Cancellable", + "Gio.File", "Gio.Icon", + "Gio.ListModel", "Gio.Menu", "Gio.MenuModel", + "Gio.MountOperation", "Gio.Permission", "GLib.Error", "GLib.KeyFile", + "GLib.Quark", "GLib.Variant", "GLib.VariantType", + "GObject.Closure", "GObject.Object", "GObject.Value", "Gtk.Allocation", "Gtk.AppChooser", + "Gtk.Border", "Gtk.EntryBuffer", + "Gtk.PadActionEntry", + "Gtk.PageRange", "Gtk.RecentData", "Gtk.Requisition", + "Gtk.ResponseType", "Gtk.TargetEntry", - "cairo.Context", - "cairo.RectangleInt", - "cairo.Region", - "cairo.Surface", + "Pango.Alignment", "Pango.AttrList", "Pango.Context", "Pango.Direction", "Pango.EllipsizeMode", + "Pango.FontDescription", "Pango.FontFace", "Pango.FontFamily", - "Pango.FontDescription", "Pango.FontMap", "Pango.Language", "Pango.Layout", @@ -308,6 +450,7 @@ manual = [ "Pango.Underline", "Pango.Variant", "Pango.WrapMode", + "xlib.Window", ] [[object]] @@ -363,27 +506,6 @@ status = "generate" #manual trait ignore = true -[[object]] -name = "Gtk.IconTheme" -status = "generate" - [[object.function]] - name = "set_search_path" - ignore = true - [[object.function]] - name = "choose_icon" - ignore = true - [[object.function]] - name = "choose_icon_for_scale" - ignore = true - [[object.function]] - name = "get_icon_sizes" - #array - ignore = true - [[object.function]] - name = "get_search_path" - #array - ignore = true - [[object]] name = "Gtk.AboutDialog" status = "generate" @@ -406,6 +528,14 @@ status = "generate" # See https://mail.gnome.org/archives/commits-list/2012-May/msg07052.html ignore = true +[[object]] +name = "Gtk.Actionable" +status = "generate" + [[object.property]] + #value glib.Variant + name = "action-target" + ignore = true + [[object]] name = "Gtk.ActionBar" status = "generate" @@ -416,6 +546,11 @@ status = "generate" name = "position" type = "gint" +[[object]] +name = "Gtk.Alignment" +#deprecated since 3.14 +status = "ignore" + [[object]] name = "Gtk.AppChooserDialog" status = "generate" @@ -428,22 +563,23 @@ status = "generate" name = "Gtk.Application" status = "generate" trait_name = "GtkApplicationExt" +manual_traits = ["gio::ApplicationExtManual"] [[object.function]] name = "new" ignore = true [[object]] -name = "Gtk.Builder" +name = "Gtk.ApplicationWindow" status = "generate" [[object.function]] - pattern = ".+_from_file" - #path - ignore = true - [[object.function]] - name = "get_object" - #downcast + name = "new" ignore = true +[[object]] +name = "Gtk.Arrow" +#deprecated since 3.14 +status = "ignore" + [[object]] name = "Gtk.Assistant" status = "generate" @@ -489,10 +625,29 @@ status = "generate" [[object]] name = "Gtk.Buildable" status = "generate" +manual_traits = ["BuildableExtManual"] [[object.function]] pattern = "[gs]et_name" ignore = true +[[object]] +name = "Gtk.Builder" +status = "generate" +manual_traits = ["BuilderExtManual"] + [[object.function]] + pattern = ".+_from_file" + #path + ignore = true + [[object.function]] + name = "get_object" + #downcast + ignore = true + +[[object]] +name = "Gtk.ButtonRole" +status = "generate" +version = "3.16" + [[object]] name = "Gtk.CellArea" status = "generate" @@ -602,10 +757,15 @@ status = "generate" [[object]] name = "Gtk.CellRendererPixbuf" status = "generate" +manual_traits = ["CellRendererPixbufExtManual"] [[object.property]] name = "surface" #value cairo::Surface ignore = true + [[object.property]] + name = "stock-size" + #value ImageSize + generate = ["notify"] [[object]] name = "Gtk.CellRendererText" @@ -633,6 +793,15 @@ status = "generate" name = "path" transformation = "treepath" +[[object]] +name = "Gtk.CellView" +status = "generate" + [[object.function]] + name = "set_displayed_row" + [[object.function.parameter]] + name = "path" + nullable = false + [[object]] name = "Gtk.Clipboard" status = "generate" @@ -648,10 +817,32 @@ status = "generate" name = "set_can_store" #array with size ignore = true + [[object.function]] + name = "request_targets" + #array with size + ignore = true + [[object.function]] + name = "request_uris" + #array with size + ignore = true + [[object.function]] + name = "set_with_data" + #array with size + ignore = true + [[object.function]] + name = "set_with_owner" + #array with size + ignore = true + +[[object]] +name = "Gtk.ColorButton" +status = "generate" +manual_traits = ["ColorButtonExtManual"] [[object]] name = "Gtk.ColorChooser" status = "generate" +manual_traits = ["ColorChooserExtManual"] [[object.function]] name = "add_palette" #array with size @@ -660,11 +851,22 @@ status = "generate" [[object]] name = "Gtk.ComboBox" status = "generate" +manual_traits = ["ColorBoxExtManual"] [[object.function]] name = "set_active_iter" [[object.function.parameter]] name = "iter" const = true + [[object.function]] + name = "set_active" + ignore = true + [[object.function]] + name = "get_active" + ignore = true + [[object.property]] + name = "active" + #manual Option + generate = ["notify"] [[object]] name = "Gtk.Container" @@ -682,6 +884,7 @@ status = "generate" [[object]] name = "Gtk.Dialog" status = "generate" +manual_traits = ["DialogExtManual"] [[object.function]] name = "add_button" [object.function.return] @@ -694,10 +897,19 @@ status = "generate" name = "get_content_area" [object.function.return] nullable = false + [[object.function]] + name = "run" + [object.function.return] + type = "Gtk.ResponseType" + [[object.function]] + name = "get_response_for_widget" + [object.function.return] + type = "Gtk.ResponseType" [[object]] name = "Gtk.Editable" status = "generate" +manual_traits = ["EditableSignals"] [[object.signal]] pattern = ".+" ignore = true #out #manual @@ -728,6 +940,11 @@ status = "generate" [[object.function.parameter]] name = "event" const = true + [[object.function]] + name = "set_tabs" + [[object.function.parameter]] + name = "tabs" + const = true [[object.property]] name = "tabs" #value pango::TabArray @@ -735,6 +952,7 @@ status = "generate" [[object]] name = "Gtk.EntryCompletion" +manual_traits = ["EntryCompletionExtManual"] status = "generate" [[object.signal]] name = "insert-prefix" @@ -745,6 +963,9 @@ status = "generate" [[object.signal]] name = "cursor-on-match" inhibit = true + [[object.function]] + name = "get_entry" + ignore = true [[object]] name = "Gtk.Expander" @@ -767,6 +988,40 @@ status = "generate" name = "add_choice" ignore = true #strange type of options and option_labels +[[object]] +name = "Gtk.Fixed" +status = "generate" +manual_traits = ["FixedExtManual"] + +[[object]] +name = "Gtk.FlowBox" +status = "generate" +manual_traits = ["FlowBoxExtManual"] + [[object.function]] + name = "bind_model" + [[object.function.parameter]] + name = "create_widget_func" + # we add a manual unbind() function instead + nullable = false + +[[object]] +name = "Gtk.FontChooser" +status = "generate" + [[object.property]] + name = "level" + version = "3.24" + [[object.property]] + name = "font-features" + version = "3.24" + [[object.property]] + name = "language" + version = "3.24" + +[[object]] +name = "Gtk.FontChooserLevel" +status = "generate" +version = "3.24" + [[object]] name = "Gtk.Gesture" status = "generate" @@ -784,6 +1039,10 @@ module_name = "gl_area" [[object.signal]] pattern = "render" inhibit = true + [[object.signal]] + name = "create-context" + [object.signal.return] + nullable = true [[object]] name = "Gtk.Grid" @@ -812,6 +1071,42 @@ status = "generate" name = "position" type = "gint" +[[object]] +name = "Gtk.IconFactory" +#deprecated since 3.10 +status = "ignore" + +[[object]] +name = "Gtk.IconSet" +#deprecated since 3.10 +status = "ignore" + +[[object]] +name = "Gtk.IconSource" +#deprecated since 3.10 +status = "ignore" + +[[object]] +name = "Gtk.IconTheme" +status = "generate" + [[object.function]] + name = "set_search_path" + ignore = true + [[object.function]] + name = "choose_icon" + ignore = true + [[object.function]] + name = "choose_icon_for_scale" + ignore = true + [[object.function]] + name = "get_icon_sizes" + #array + ignore = true + [[object.function]] + name = "get_search_path" + #array + ignore = true + [[object]] name = "Gtk.IconView" status = "generate" @@ -861,6 +1156,11 @@ status = "generate" # wrong out parameter mutability and deprecated anyway ignore = true +[[object]] +name = "Gtk.ImageMenuItem" +#deprecated since 3.10 +status = "ignore" + [[object]] name = "Gtk.IMContext" status = "generate" @@ -876,6 +1176,39 @@ status = "generate" name = "input-purpose" version = "3.6" +[[object]] +name = "Gtk.IMContextSimple" +status = "generate" +manual_traits = ["IMContextSimpleExtManual"] + [[object.function]] + name = "add_compose_file" + ignore = true + [[object.function]] + name = "add_table" + ignore = true # We don't understand API + +[[object]] +name = "Gtk.InfoBar" +status = "generate" + [[object.property]] + name = "revealed" + version = "3.22.29" + +[[object]] +name = "Gtk.InputHints" +status = "generate" + [[object.member]] + name = "emoji" + version = "3.22.20" + [[object.member]] + name = "no_emoji" + version = "3.22.20" + +[[object]] +name = "Gtk.Invisible" +status = "generate" +manual_traits = ["InvisibleExtManual"] + [[object]] name = "Gtk.Label" status = "generate" @@ -900,9 +1233,22 @@ status = "generate" name = "activate-link" inhibit = true +[[object]] +name = "Gtk.ListBox" +status = "generate" +manual_traits = ["ListBoxExtManual"] + [[object.function]] + name = "bind_model" + [[object.function.parameter]] + name = "create_widget_func" + # we add a manual unbind() function instead + nullable = false + [[object]] name = "Gtk.ListStore" status = "generate" +trait_name = "GtkListStoreExt" +manual_traits = ["GtkListStoreExtManual"] [[object.function]] pattern = ".+" [[object.function.parameter]] @@ -931,6 +1277,8 @@ name = "Gtk.Menu" status = "generate" child_type = "Gtk.MenuItem" child_name = "item" +trait_name = "GtkMenuExt" +manual_traits = ["GtkMenuExtManual"] [[object.child_prop]] name = "bottom-attach" type = "gint" @@ -950,6 +1298,7 @@ child_name = "item" [[object]] name = "Gtk.MenuItem" status = "generate" +trait_name = "GtkMenuItemExt" [[object.function]] name = "activate" ignore = true @@ -964,6 +1313,7 @@ status = "generate" [[object]] name = "Gtk.Notebook" status = "generate" +manual_traits = ["NotebookExtManual"] # The following functions need integer type adjustments [[object.function]] name = "append_page" @@ -1036,10 +1386,30 @@ status = "generate" [[object]] name = "Gtk.Overlay" status = "generate" +manual_traits = ["OverlaySignals"] [[object.child_prop]] name = "index" type = "gint" +#[[object]] +#name = "Gtk.PadActionEntry" <- Missing memory management functions +#status = "generate" +#version = "3.22" + +[[object]] +name = "Gtk.PadActionType" +status = "generate" +version = "3.22" + +[[object]] +name = "Gtk.PadController" +status = "generate" +manual_traits = ["PadControllerExtManual"] +version = "3.22" + [[object.function]] + name = "set_action_entries" + ignore = true + [[object]] name = "Gtk.PageSetup" status = "generate" @@ -1063,21 +1433,6 @@ status = "generate" name = "shrink" type = "gboolean" -[[object]] -name = "Gtk.Popover" -status = "generate" -version = "3.12" - -[[object]] -name = "Gtk.PopoverMenu" -status = "generate" - [[object.child_prop]] - name = "position" - type = "gint" - [[object.child_prop]] - name = "submenu" - type = "utf8" - [[object]] name = "Gtk.PaperSize" status = "generate" @@ -1098,6 +1453,41 @@ status = "generate" name = "is_ipp" version = "3.16" +[[object]] +name = "Gtk.PlacesSidebar" +status = "generate" + [[object.signal]] + name = "drag-action-requested" + #[gio::File] + ignore = true + [[object.signal]] + name = "drag-perform-drop" + #[gio::File] + ignore = true + [[object.property]] + name = "show-starred-location" + version = "3.22.26" + +[[object]] +name = "Gtk.Plug" +status = "generate" +cfg_condition = "not(windows)" + +[[object]] +name = "Gtk.Popover" +status = "generate" +version = "3.12" + +[[object]] +name = "Gtk.PopoverMenu" +status = "generate" + [[object.child_prop]] + name = "position" + type = "gint" + [[object.child_prop]] + name = "submenu" + type = "utf8" + [[object]] name = "Gtk.PrintContext" status = "generate" @@ -1111,9 +1501,6 @@ status = "generate" [[object]] name = "Gtk.PrintSettings" status = "generate" - [[object.function]] - name = "get_page_ranges" - ignore = true [[object.function]] name = "get_paper_size" [object.function.return] @@ -1233,11 +1620,6 @@ status = "generate" name = "event" const = true -[[object]] -name = "Gtk.ShortcutsWindow" -status = "generate" -version = "3.20" - [[object]] name = "Gtk.SelectionData" status = "generate" @@ -1264,6 +1646,11 @@ status = "generate" name = "selection_data" const = true [[object.function]] + name = "set" + [[object.function.parameter]] + name = "selection_data" + const = true + [[object.function]] name = "set_uris" [[object.function.parameter]] name = "selection_data" @@ -1272,10 +1659,25 @@ status = "generate" name = "get_data" #array without length ignore = true + [[object.function]] + name = "get_data_with_length" + ignore = true + +[[object]] +name = "Gtk.ShortcutsWindow" +status = "generate" +version = "3.20" + +[[object]] +name = "Gtk.Socket" +status = "generate" +cfg_condition = "not(windows)" +trait_name = "GtkSocketExt" [[object]] name = "Gtk.SpinButton" status = "generate" +manual_traits = ["SpinButtonSignals"] [[object.function]] name = "get_adjustment" [object.function.return] @@ -1303,6 +1705,11 @@ status = "generate" name = "title" type = "utf8" +[[object]] +name = "Gtk.StatusIcon" +#deprecated since 3.14 +status = "ignore" + [[object]] name = "Gtk.StyleContext" status = "generate" @@ -1316,13 +1723,24 @@ status = "generate" name = "paint-clock" version = "3.8" +[[object]] +name = "Gtk.StyleContextPrintFlags" +status = "generate" +version = "3.20" + [[object]] name = "Gtk.Switch" status = "generate" +manual_traits = ["SwitchExtManual"] [[object.signal]] name = "state-set" inhibit = true +[[object]] +name = "Gtk.SymbolicColor" +#deprecated since 3.8 +status = "ignore" + [[object]] name = "Gtk.TargetList" status = "generate" @@ -1338,6 +1756,7 @@ status = "generate" [[object]] name = "Gtk.TextBuffer" status = "generate" +manual_traits = ["TextBufferExtManual"] [[object.function]] name = "register_deserialize_tagset" [object.function.return] @@ -1354,10 +1773,16 @@ status = "generate" [[object.signal]] name = "insert-text" ignore = true + [[object.function]] + name = "register_serialize_format" + ignore = true [[object]] name = "Gtk.TextIter" status = "generate" +init_function_expression = "|_ptr| ()" +clear_function_expression = "|_ptr| ()" + [[object.function]] name = "get_attributes" ignore = true @@ -1398,9 +1823,23 @@ status = "generate" [[object.function.parameter]] name = "event" const = true + [[object.function]] + name = "set_tabs" + [[object.function.parameter]] + name = "tabs" + const = true [[object.signal]] name = "extend-selection" inhibit = true + [[object.signal]] + name = "insert-emoji" + #actually Since 3.22.27 + version = "3.22.26" + +[[object]] +name = "Gtk.TextViewLayer" +status = "generate" +version = "3.14" [[object]] name = "Gtk.Toolbar" @@ -1441,6 +1880,12 @@ child_name = "item" name = "new-row" type = "gboolean" +[[object]] +name = "Gtk.TreeIter" +status = "generate" +init_function_expression = "|_ptr| ()" +clear_function_expression = "|_ptr| ()" + [[object]] name = "Gtk.TreeModel" status = "generate" @@ -1457,6 +1902,10 @@ status = "generate" # Replaced by TreeModelFilter::new ignore = true [[object.function]] + name = " sort_new_with_model" + # Replaced by TreeModelSort::new + ignore = true + [[object.function]] name = "iter_children" [[object.function.parameter]] name = "parent" @@ -1509,6 +1958,39 @@ status = "generate" #value recordboxed ignore = true +[[object]] +name = "Gtk.TreeModelSort" +status = "generate" + [[object.function]] + name = "convert_child_path_to_path" + [[object.function.parameter]] + name = "child_path" + const = true + [[object.function]] + name = "convert_path_to_child_path" + [[object.function.parameter]] + name = "sorted_path" + const = true + [[object.function]] + name = "convert_iter_to_child_iter" + [[object.function.parameter]] + name = "sorted_iter" + const = true + [[object.function]] + name = "convert_child_iter_to_iter" + [[object.function.parameter]] + name = "child_iter" + const = true + [[object.function]] + name = "iter_is_valid" + [[object.function.parameter]] + name = "iter" + const = true + [[object.function]] + name = "get_model" + [object.function.return] + nullable = false + [[object]] name = "Gtk.TreePath" status = "generate" @@ -1610,13 +2092,23 @@ status = "generate" [[object]] name = "Gtk.TreeSortable" status = "generate" +manual_traits = ["TreeSortableExtManual"] [[object.function]] pattern = "[gs]et_sort_column_id" ignore = true + [[object.function]] + pattern = "set_sort_func" + # return type u32 -> Ordering + ignore = true + [[object.function]] + pattern = "set_default_sort_func" + # return type u32 -> Ordering + ignore = true [[object]] name = "Gtk.TreeStore" status = "generate" +manual_traits = ["TreeStoreExtManual"] [[object.function]] pattern = ".+" [[object.function.parameter]] @@ -1658,6 +2150,7 @@ status = "generate" [[object]] name = "Gtk.TreeView" status = "generate" +generate_builder = true [[object.function]] name = "enable_model_drag_dest" #array with size @@ -1699,6 +2192,7 @@ status = "generate" [[object]] name = "Gtk.Widget" status = "generate" +manual_traits = ["WidgetExtManual"] [[object.function]] name = "drag_dest_set" #array with size @@ -1732,6 +2226,29 @@ status = "generate" [[object.function]] name = "style_get_property" ignore = true + [[object.function]] + name = "get_path" + [object.function.return] + nullable = false + [[object.function]] + name = "add_tick_callback" + ignore = true + [[object.function]] + name = "remove_tick_callback" + ignore = true + [[object.function]] + name = "add_events" + ignore = true + [[object.function]] + name = "get_events" + ignore = true + [[object.function]] + name = "set_events" + ignore = true + [[object.function]] + name = "get_style_context" + [object.function.return] + nullable = false [[object.signal]] name = "button-press-event" inhibit = true @@ -1839,6 +2356,9 @@ status = "generate" name = "style" #deprecated ignore = true + [[object.property]] + name = "events" + generate = ["notify"] [[object.function]] name = "input_shape_combine_region" [[object.function.parameter]] @@ -1854,6 +2374,7 @@ status = "generate" name = "Gtk.Window" status = "generate" trait_name = "GtkWindowExt" +manual_traits = ["GtkWindowExtManual"] [[object.function]] name = "activate_key" [[object.function.parameter]] @@ -1864,11 +2385,6 @@ trait_name = "GtkWindowExt" [[object.function.parameter]] name = "event" const = true - -[[object]] -name = "Gtk.Actionable" -status = "generate" - [[object.property]] - #value glib.Variant - name = "action-target" + [[object.function]] + name = "present" ignore = true diff --git a/Makefile b/Makefile index 6b1f1b1503..a514baaba0 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,23 @@ GIR = gir/target/bin/gir -GIR_SRC = gir/Cargo.toml gir/Cargo.lock gir/build.rs $(shell find gir/src -name '*.rs') +GIR_SRC != find gir/src -name '*.rs' +GIR_SRC += gir/Cargo.toml gir/Cargo.lock gir/build.rs GIR_FILES = gir-files/Gtk-3.0.gir # Run `gir` generating the bindings gir : src/auto/mod.rs + cargo fmt + +doc: $(GIR) $(GIR_FILES) + $(GIR) -m doc -c Gir.toml + +not_bound: $(GIR) $(GIR_FILES) + $(GIR) -m not_bound -c Gir.toml + +regen_check: $(GIR) $(GIR_FILES) + rm src/auto/* + $(GIR) -c Gir.toml + cargo fmt + git diff -R --exit-code src/auto/mod.rs : Gir.toml $(GIR) $(GIR_FILES) $(GIR) -c Gir.toml diff --git a/appveyor.yml b/appveyor.yml index 12faceedf4..a0024c6cf9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,11 +16,15 @@ install: - pacman --noconfirm -S mingw-w64-%ARCH%-gtk3 build_script: + - cargo doc --features "dox" + - cargo test + - cargo test --features v3_24 + - cargo doc --features "dox" - mkdir .cargo - echo paths = ["."] > .cargo\config - git clone -q --depth 50 -b master https://github.com/gtk-rs/examples _examples - cd _examples - cargo build - - cargo build --features gtk_3_18 + - cargo build --features gtk_3_24 test: false diff --git a/build.rs b/build.rs index 95724b5f62..7665322ae9 100644 --- a/build.rs +++ b/build.rs @@ -1,17 +1,17 @@ +#[cfg(target_os = "macos")] +extern crate cc; + fn main() { manage_docs(); + #[cfg(target_os = "macos")] + build_foreground(); } #[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))] -fn manage_docs () { +fn manage_docs() { extern crate lgpl_docs; const PATH: &'static str = "src"; - const IGNORES: &'static [&'static str] = &[ - "lib.rs", - "prelude.rs", - "rt.rs", - "signal.rs", - ]; + const IGNORES: &'static [&'static str] = &["lib.rs", "prelude.rs", "rt.rs", "signal.rs"]; lgpl_docs::purge(PATH, IGNORES); if cfg!(feature = "embed-lgpl-docs") { lgpl_docs::embed(lgpl_docs::Library::Gtk, PATH, IGNORES); @@ -19,4 +19,13 @@ fn manage_docs () { } #[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))] -fn manage_docs() { } +fn manage_docs() {} + +#[cfg(target_os = "macos")] +fn build_foreground() { + cc::Build::new() + .file("src/foreground.m") + .compile("foreground"); + println!("cargo:rustc-link-lib=framework=AppKit"); + println!("cargo:rustc-link-lib=framework=CoreFoundation"); +} diff --git a/check_init_asserts b/check_init_asserts index 005c1ce2c4..52919e5164 100755 --- a/check_init_asserts +++ b/check_init_asserts @@ -5,13 +5,12 @@ BEGIN { $e = 0 } while (/^(\N*)\V*fn\s+(\w+)\s*(<[^(]+>)?\s*(\([^{;]+)\{\N*\n^(\N*)$/gms) { ($modifiers, $name, $signature, $first_line) = ($1, $2, $4, $5); unless ($modifiers =~ /^\s*(\/\/|(pub )?unsafe)/ || - $signature =~ /^\((&(\x27\w+ )?)?(mut )?self\b/ || + $signature =~ /^\(\s*(&(\x27\w+ )?)?(mut )?self\b/ || $signature =~ /^\(\)/ || $first_line =~ /^\s*( assert_initialized_main_thread | assert_not_initialized | - skip_assert_initialized | - callback_guard + skip_assert_initialized )!\(\)/x) { print "$ARGV: $name$signature\n"; $e = 1 diff --git a/gir b/gir index d933f9a143..e586ff8cc0 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit d933f9a143bb23ecb79550ba1692c4de640fa05f +Subproject commit e586ff8cc061a716f28ad3e37f5db8a0cf06fbf5 diff --git a/gir-files b/gir-files index 469db10183..617a344b41 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 469db1018320ebda8f82b144e411fba8b2373549 +Subproject commit 617a344b41061d8fbf6a7b04358357cc5c0886f0 diff --git a/src/app_chooser.rs b/src/app_chooser.rs index a39a9317a1..65a1fcf929 100644 --- a/src/app_chooser.rs +++ b/src/app_chooser.rs @@ -2,26 +2,21 @@ // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or -use glib::translate::*; use gio::AppInfo; -use ffi; -use glib_ffi; -use gobject_ffi; -use std::ptr; -use std::mem; - use glib::object::IsA; +use glib::translate::*; +use gtk_sys; use Widget; glib_wrapper! { - pub struct AppChooser(Object): Widget; + pub struct AppChooser(Interface) @requires Widget; match fn { - get_type => || ffi::gtk_app_chooser_get_type(), + get_type => || gtk_sys::gtk_app_chooser_get_type(), } } -pub trait AppChooserExt { +pub trait AppChooserExt: 'static { fn get_app_info(&self) -> Option; fn get_content_type(&self) -> Option; fn refresh(&self); @@ -29,17 +24,22 @@ pub trait AppChooserExt { impl> AppChooserExt for O { fn get_app_info(&self) -> Option { - unsafe { from_glib_full(ffi::gtk_app_chooser_get_app_info(self.to_glib_none().0)) } + unsafe { + from_glib_full(gtk_sys::gtk_app_chooser_get_app_info( + self.as_ref().to_glib_none().0, + )) + } } fn get_content_type(&self) -> Option { unsafe { - from_glib_full( - ffi::gtk_app_chooser_get_content_type(self.to_glib_none().0)) + from_glib_full(gtk_sys::gtk_app_chooser_get_content_type( + self.as_ref().to_glib_none().0, + )) } } fn refresh(&self) { - unsafe { ffi::gtk_app_chooser_refresh(self.to_glib_none().0) } + unsafe { gtk_sys::gtk_app_chooser_refresh(self.as_ref().to_glib_none().0) } } } diff --git a/src/application.rs b/src/application.rs index ac65531e53..a5c01b004b 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,30 +1,23 @@ -use Application; -use ffi; use gio::ApplicationFlags; +use glib; use glib::translate::*; +use gtk_sys; use rt; -use glib; +use Application; impl Application { - #[cfg(feature = "v3_6")] - pub fn new<'a, I: Into>>(application_id: I, flags: ApplicationFlags) -> Result { - skip_assert_initialized!(); - try!(rt::init()); - unsafe { - Option::from_glib_full( - ffi::gtk_application_new(application_id.into().to_glib_none().0, flags.to_glib())) - .ok_or(glib::BoolError("Failed to create application")) - } - } - - #[cfg(not(feature = "v3_6"))] - pub fn new(application_id: &str, flags: ApplicationFlags) -> Result { + pub fn new( + application_id: Option<&str>, + flags: ApplicationFlags, + ) -> Result { skip_assert_initialized!(); try!(rt::init()); unsafe { - Option::from_glib_full( - ffi::gtk_application_new(application_id.to_glib_none().0, flags.to_glib())) - .ok_or(glib::BoolError("Failed to create application")) + Option::from_glib_full(gtk_sys::gtk_application_new( + application_id.to_glib_none().0, + flags.to_glib(), + )) + .ok_or_else(|| glib_bool_error!("Failed to create application")) } } } diff --git a/src/application_window.rs b/src/application_window.rs new file mode 100644 index 0000000000..c891febde3 --- /dev/null +++ b/src/application_window.rs @@ -0,0 +1,19 @@ +use glib::object::Cast; +use glib::object::IsA; +use glib::translate::*; +use gtk_sys; +use Application; +use ApplicationWindow; +use Widget; + +impl ApplicationWindow { + pub fn new>(application: &P) -> ApplicationWindow { + skip_assert_initialized!(); + unsafe { + Widget::from_glib_none(gtk_sys::gtk_application_window_new( + application.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } +} diff --git a/src/assistant.rs b/src/assistant.rs deleted file mode 100644 index 0485113665..0000000000 --- a/src/assistant.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::mem::transmute; -use std::boxed::Box as Box_; - -use Assistant; -use ffi; -use glib::object::IsA; -use glib_ffi; - -pub trait AssistantExtManual { - fn set_forward_page_func i32 + 'static>(&self, f: F); -} - -impl> AssistantExtManual for O { - fn set_forward_page_func i32 + 'static>(&self, f: F) { - unsafe { - let f: Box_ i32 + 'static>> = Box_::new(Box_::new(f)); - ffi::gtk_assistant_set_forward_page_func(self.to_glib_none().0, - Some(forward_page_trampoline), Box_::into_raw(f) as *mut _, Some(destroy_closure)) - } - } -} - -unsafe extern "C" fn forward_page_trampoline(current_page: i32, f: glib_ffi::gpointer) -> i32 { - callback_guard!(); - let f: &&(Fn(i32) -> i32 + 'static) = transmute(f); - f(current_page) -} - -unsafe extern "C" fn destroy_closure(ptr: glib_ffi::gpointer) { - callback_guard!(); - Box_:: i32 + 'static>>::from_raw(ptr as *mut _); -} diff --git a/src/auto/about_dialog.rs b/src/auto/about_dialog.rs index 734e9e2bb7..1bb9f888d8 100644 --- a/src/auto/about_dialog.rs +++ b/src/auto/about_dialog.rs @@ -1,44 +1,49 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use Bin; -use Buildable; -use Container; -use Dialog; -use License; -use Widget; -use Window; -use ffi; +use gdk; use gdk_pixbuf; -use glib; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib::GString; +use glib::StaticType; +use glib::ToValue; +use glib_sys; +use gtk_sys; use libc; use signal::Inhibit; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use Align; +use Application; +use Bin; +use Buildable; +use Container; +use Dialog; +use License; +use ResizeMode; +use Widget; +use Window; +use WindowPosition; +use WindowType; glib_wrapper! { - pub struct AboutDialog(Object): Dialog, Window, Bin, Container, Widget, Buildable; + pub struct AboutDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable; match fn { - get_type => || ffi::gtk_about_dialog_get_type(), + get_type => || gtk_sys::gtk_about_dialog_get_type(), } } impl AboutDialog { pub fn new() -> AboutDialog { assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_about_dialog_new()).downcast_unchecked() - } + unsafe { Widget::from_glib_none(gtk_sys::gtk_about_dialog_new()).unsafe_cast() } } } @@ -48,36 +53,853 @@ impl Default for AboutDialog { } } -pub trait AboutDialogExt { +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, + 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_width: Option, + deletable: Option, + destroy_with_parent: Option, + focus_on_map: Option, + focus_visible: Option, + gravity: Option, + hide_titlebar_when_maximized: Option, + icon: Option, + icon_name: Option, + mnemonics_visible: Option, + modal: Option, + resizable: Option, + role: Option, + screen: Option, + skip_pager_hint: Option, + skip_taskbar_hint: Option, + startup_id: Option, + title: Option, + transient_for: Option, + type_: Option, + type_hint: Option, + urgency_hint: Option, + window_position: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl AboutDialogBuilder { + pub fn new() -> Self { + Self { + artists: None, + authors: None, + comments: None, + copyright: None, + documenters: None, + license: None, + license_type: None, + logo: None, + logo_icon_name: None, + program_name: None, + translator_credits: None, + version: None, + website: None, + website_label: None, + wrap_license: None, + use_header_bar: None, + accept_focus: None, + application: None, + attached_to: None, + decorated: None, + default_height: None, + default_width: None, + deletable: None, + destroy_with_parent: None, + focus_on_map: None, + focus_visible: None, + gravity: None, + hide_titlebar_when_maximized: None, + icon: None, + icon_name: None, + mnemonics_visible: None, + modal: None, + resizable: None, + role: None, + screen: None, + skip_pager_hint: None, + skip_taskbar_hint: None, + startup_id: None, + title: None, + transient_for: None, + type_: None, + type_hint: None, + urgency_hint: None, + window_position: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 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_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 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 gravity) = self.gravity { + properties.push(("gravity", gravity)); + } + if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized { + properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized)); + } + if let Some(ref icon) = self.icon { + properties.push(("icon", icon)); + } + 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 role) = self.role { + properties.push(("role", role)); + } + if let Some(ref screen) = self.screen { + properties.push(("screen", screen)); + } + if let Some(ref skip_pager_hint) = self.skip_pager_hint { + properties.push(("skip-pager-hint", skip_pager_hint)); + } + if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint { + properties.push(("skip-taskbar-hint", skip_taskbar_hint)); + } + 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 urgency_hint) = self.urgency_hint { + properties.push(("urgency-hint", urgency_hint)); + } + if let Some(ref window_position) = self.window_position { + properties.push(("window-position", window_position)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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: &gdk_pixbuf::Pixbuf) -> Self { + self.logo = Some(logo.clone()); + 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 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: &Application) -> Self { + self.application = Some(application.clone()); + self + } + + pub fn attached_to(mut self, attached_to: &Widget) -> Self { + self.attached_to = Some(attached_to.clone()); + 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_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 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 gravity(mut self, gravity: gdk::Gravity) -> Self { + self.gravity = Some(gravity); + self + } + + pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self { + self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized); + self + } + + pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self { + self.icon = Some(icon.clone()); + 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 role(mut self, role: &str) -> Self { + self.role = Some(role.to_string()); + self + } + + pub fn screen(mut self, screen: &gdk::Screen) -> Self { + self.screen = Some(screen.clone()); + self + } + + pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self { + self.skip_pager_hint = Some(skip_pager_hint); + self + } + + pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self { + self.skip_taskbar_hint = Some(skip_taskbar_hint); + 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: &Window) -> Self { + self.transient_for = Some(transient_for.clone()); + self + } + + pub fn type_(mut self, type_: WindowType) -> Self { + self.type_ = Some(type_); + self + } + + pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self { + self.type_hint = Some(type_hint); + self + } + + pub fn urgency_hint(mut self, urgency_hint: bool) -> Self { + self.urgency_hint = Some(urgency_hint); + self + } + + pub fn window_position(mut self, window_position: WindowPosition) -> Self { + self.window_position = Some(window_position); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_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_artists(&self) -> Vec; - fn get_authors(&self) -> Vec; + fn get_authors(&self) -> Vec; - fn get_comments(&self) -> Option; + fn get_comments(&self) -> Option; - fn get_copyright(&self) -> Option; + fn get_copyright(&self) -> Option; - fn get_documenters(&self) -> Vec; + fn get_documenters(&self) -> Vec; - fn get_license(&self) -> Option; + 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_logo_icon_name(&self) -> Option; - fn get_program_name(&self) -> Option; + fn get_program_name(&self) -> Option; - fn get_translator_credits(&self) -> Option; + fn get_translator_credits(&self) -> Option; - fn get_version(&self) -> Option; + fn get_version(&self) -> Option; - fn get_website(&self) -> Option; + fn get_website(&self) -> Option; - fn get_website_label(&self) -> Option; + fn get_website_label(&self) -> Option; fn get_wrap_license(&self) -> bool; @@ -85,33 +907,36 @@ pub trait AboutDialogExt { fn set_authors(&self, authors: &[&str]); - fn set_comments<'a, P: Into>>(&self, comments: P); + fn set_comments(&self, comments: Option<&str>); - fn set_copyright<'a, P: Into>>(&self, copyright: P); + fn set_copyright(&self, copyright: Option<&str>); fn set_documenters(&self, documenters: &[&str]); - fn set_license<'a, P: Into>>(&self, license: P); + fn set_license(&self, license: Option<&str>); fn set_license_type(&self, license_type: License); - fn set_logo<'a, P: Into>>(&self, logo: P); + fn set_logo(&self, logo: Option<&gdk_pixbuf::Pixbuf>); - fn set_logo_icon_name<'a, P: Into>>(&self, icon_name: P); + fn set_logo_icon_name(&self, icon_name: Option<&str>); fn set_program_name(&self, name: &str); - fn set_translator_credits<'a, P: Into>>(&self, translator_credits: P); + fn set_translator_credits(&self, translator_credits: Option<&str>); - fn set_version<'a, P: Into>>(&self, version: P); + fn set_version(&self, version: Option<&str>); - fn set_website<'a, P: Into>>(&self, website: P); + fn set_website(&self, website: Option<&str>); - fn set_website_label<'a, P: Into>>(&self, website_label: P); + fn set_website_label(&self, website_label: Option<&str>); fn set_wrap_license(&self, wrap_license: bool); - fn connect_activate_link Inhibit + 'static>(&self, f: F) -> SignalHandlerId; + fn connect_activate_link Inhibit + 'static>( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_artists_notify(&self, f: F) -> SignalHandlerId; @@ -125,467 +950,696 @@ pub trait AboutDialogExt { fn connect_property_license_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_license_type_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_logo_icon_name_notify( + &self, + f: F, + ) -> SignalHandlerId; - fn connect_property_program_name_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_program_name_notify(&self, f: F) + -> SignalHandlerId; - fn connect_property_translator_credits_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_website_label_notify( + &self, + f: F, + ) -> SignalHandlerId; - fn connect_property_wrap_license_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_wrap_license_notify(&self, f: F) + -> SignalHandlerId; } -impl + IsA> AboutDialogExt for O { +impl> AboutDialogExt for O { fn add_credit_section(&self, section_name: &str, people: &[&str]) { unsafe { - ffi::gtk_about_dialog_add_credit_section(self.to_glib_none().0, section_name.to_glib_none().0, people.to_glib_none().0); + gtk_sys::gtk_about_dialog_add_credit_section( + self.as_ref().to_glib_none().0, + section_name.to_glib_none().0, + people.to_glib_none().0, + ); } } - fn get_artists(&self) -> Vec { + fn get_artists(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_none(ffi::gtk_about_dialog_get_artists(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_artists( + self.as_ref().to_glib_none().0, + )) } } - fn get_authors(&self) -> Vec { + fn get_authors(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_none(ffi::gtk_about_dialog_get_authors(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_authors( + self.as_ref().to_glib_none().0, + )) } } - fn get_comments(&self) -> Option { + fn get_comments(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_comments(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_comments( + self.as_ref().to_glib_none().0, + )) } } - fn get_copyright(&self) -> Option { + fn get_copyright(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_copyright(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_copyright( + self.as_ref().to_glib_none().0, + )) } } - fn get_documenters(&self) -> Vec { + fn get_documenters(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_none(ffi::gtk_about_dialog_get_documenters(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_documenters( + self.as_ref().to_glib_none().0, + )) } } - fn get_license(&self) -> Option { + fn get_license(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_license(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_license( + self.as_ref().to_glib_none().0, + )) } } fn get_license_type(&self) -> License { unsafe { - from_glib(ffi::gtk_about_dialog_get_license_type(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_about_dialog_get_license_type( + self.as_ref().to_glib_none().0, + )) } } fn get_logo(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_logo(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_logo( + self.as_ref().to_glib_none().0, + )) } } - fn get_logo_icon_name(&self) -> Option { + fn get_logo_icon_name(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_logo_icon_name(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_logo_icon_name( + self.as_ref().to_glib_none().0, + )) } } - fn get_program_name(&self) -> Option { + fn get_program_name(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_program_name(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_program_name( + self.as_ref().to_glib_none().0, + )) } } - fn get_translator_credits(&self) -> Option { + fn get_translator_credits(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_translator_credits(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_translator_credits( + self.as_ref().to_glib_none().0, + )) } } - fn get_version(&self) -> Option { + fn get_version(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_version(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_version( + self.as_ref().to_glib_none().0, + )) } } - fn get_website(&self) -> Option { + fn get_website(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_website(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_website( + self.as_ref().to_glib_none().0, + )) } } - fn get_website_label(&self) -> Option { + fn get_website_label(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_about_dialog_get_website_label(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_about_dialog_get_website_label( + self.as_ref().to_glib_none().0, + )) } } fn get_wrap_license(&self) -> bool { unsafe { - from_glib(ffi::gtk_about_dialog_get_wrap_license(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_about_dialog_get_wrap_license( + self.as_ref().to_glib_none().0, + )) } } fn set_artists(&self, artists: &[&str]) { unsafe { - ffi::gtk_about_dialog_set_artists(self.to_glib_none().0, artists.to_glib_none().0); + gtk_sys::gtk_about_dialog_set_artists( + self.as_ref().to_glib_none().0, + artists.to_glib_none().0, + ); } } fn set_authors(&self, authors: &[&str]) { unsafe { - ffi::gtk_about_dialog_set_authors(self.to_glib_none().0, authors.to_glib_none().0); + gtk_sys::gtk_about_dialog_set_authors( + self.as_ref().to_glib_none().0, + authors.to_glib_none().0, + ); } } - fn set_comments<'a, P: Into>>(&self, comments: P) { - let comments = comments.into(); - let comments = comments.to_glib_none(); + fn set_comments(&self, comments: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_comments(self.to_glib_none().0, comments.0); + gtk_sys::gtk_about_dialog_set_comments( + self.as_ref().to_glib_none().0, + comments.to_glib_none().0, + ); } } - fn set_copyright<'a, P: Into>>(&self, copyright: P) { - let copyright = copyright.into(); - let copyright = copyright.to_glib_none(); + fn set_copyright(&self, copyright: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_copyright(self.to_glib_none().0, copyright.0); + gtk_sys::gtk_about_dialog_set_copyright( + self.as_ref().to_glib_none().0, + copyright.to_glib_none().0, + ); } } fn set_documenters(&self, documenters: &[&str]) { unsafe { - ffi::gtk_about_dialog_set_documenters(self.to_glib_none().0, documenters.to_glib_none().0); + gtk_sys::gtk_about_dialog_set_documenters( + self.as_ref().to_glib_none().0, + documenters.to_glib_none().0, + ); } } - fn set_license<'a, P: Into>>(&self, license: P) { - let license = license.into(); - let license = license.to_glib_none(); + fn set_license(&self, license: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_license(self.to_glib_none().0, license.0); + gtk_sys::gtk_about_dialog_set_license( + self.as_ref().to_glib_none().0, + license.to_glib_none().0, + ); } } fn set_license_type(&self, license_type: License) { unsafe { - ffi::gtk_about_dialog_set_license_type(self.to_glib_none().0, license_type.to_glib()); + gtk_sys::gtk_about_dialog_set_license_type( + self.as_ref().to_glib_none().0, + license_type.to_glib(), + ); } } - fn set_logo<'a, P: Into>>(&self, logo: P) { - let logo = logo.into(); - let logo = logo.to_glib_none(); + fn set_logo(&self, logo: Option<&gdk_pixbuf::Pixbuf>) { unsafe { - ffi::gtk_about_dialog_set_logo(self.to_glib_none().0, logo.0); + gtk_sys::gtk_about_dialog_set_logo( + self.as_ref().to_glib_none().0, + logo.to_glib_none().0, + ); } } - fn set_logo_icon_name<'a, P: Into>>(&self, icon_name: P) { - let icon_name = icon_name.into(); - let icon_name = icon_name.to_glib_none(); + fn set_logo_icon_name(&self, icon_name: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_logo_icon_name(self.to_glib_none().0, icon_name.0); + gtk_sys::gtk_about_dialog_set_logo_icon_name( + self.as_ref().to_glib_none().0, + icon_name.to_glib_none().0, + ); } } fn set_program_name(&self, name: &str) { unsafe { - ffi::gtk_about_dialog_set_program_name(self.to_glib_none().0, name.to_glib_none().0); + gtk_sys::gtk_about_dialog_set_program_name( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + ); } } - fn set_translator_credits<'a, P: Into>>(&self, translator_credits: P) { - let translator_credits = translator_credits.into(); - let translator_credits = translator_credits.to_glib_none(); + fn set_translator_credits(&self, translator_credits: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_translator_credits(self.to_glib_none().0, translator_credits.0); + gtk_sys::gtk_about_dialog_set_translator_credits( + self.as_ref().to_glib_none().0, + translator_credits.to_glib_none().0, + ); } } - fn set_version<'a, P: Into>>(&self, version: P) { - let version = version.into(); - let version = version.to_glib_none(); + fn set_version(&self, version: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_version(self.to_glib_none().0, version.0); + gtk_sys::gtk_about_dialog_set_version( + self.as_ref().to_glib_none().0, + version.to_glib_none().0, + ); } } - fn set_website<'a, P: Into>>(&self, website: P) { - let website = website.into(); - let website = website.to_glib_none(); + fn set_website(&self, website: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_website(self.to_glib_none().0, website.0); + gtk_sys::gtk_about_dialog_set_website( + self.as_ref().to_glib_none().0, + website.to_glib_none().0, + ); } } - fn set_website_label<'a, P: Into>>(&self, website_label: P) { - let website_label = website_label.into(); - let website_label = website_label.to_glib_none(); + fn set_website_label(&self, website_label: Option<&str>) { unsafe { - ffi::gtk_about_dialog_set_website_label(self.to_glib_none().0, website_label.0); + gtk_sys::gtk_about_dialog_set_website_label( + self.as_ref().to_glib_none().0, + website_label.to_glib_none().0, + ); } } fn set_wrap_license(&self, wrap_license: bool) { unsafe { - ffi::gtk_about_dialog_set_wrap_license(self.to_glib_none().0, wrap_license.to_glib()); + gtk_sys::gtk_about_dialog_set_wrap_license( + self.as_ref().to_glib_none().0, + wrap_license.to_glib(), + ); } } - fn connect_activate_link Inhibit + 'static>(&self, f: F) -> SignalHandlerId { + fn connect_activate_link Inhibit + 'static>( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn activate_link_trampoline Inhibit + 'static>( + this: *mut gtk_sys::GtkAboutDialog, + uri: *mut libc::c_char, + f: glib_sys::gpointer, + ) -> glib_sys::gboolean + where + P: IsA, + { + let f: &F = &*(f as *const F); + f( + &AboutDialog::from_glib_borrow(this).unsafe_cast(), + &GString::from_glib_borrow(uri), + ) + .to_glib() + } unsafe { - let f: Box_ Inhibit + 'static>> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "activate-link", - transmute(activate_link_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::artists", - transmute(notify_artists_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::authors", - transmute(notify_authors_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::comments", - transmute(notify_comments_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::copyright", - transmute(notify_copyright_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::documenters", - transmute(notify_documenters_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::license", - transmute(notify_license_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_license_type_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_license_type_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::license-type", - transmute(notify_license_type_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::logo", - transmute(notify_logo_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_logo_icon_name_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_logo_icon_name_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::logo-icon-name", - transmute(notify_logo_icon_name_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_property_program_name_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_program_name_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::program-name", - transmute(notify_program_name_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_property_translator_credits_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_translator_credits_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::translator-credits", - transmute(notify_translator_credits_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::version", - transmute(notify_version_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::website", - transmute(notify_website_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_website_label_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_website_label_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::website-label", - transmute(notify_website_label_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_property_wrap_license_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_wrap_license_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::wrap-license", - transmute(notify_wrap_license_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn activate_link_trampoline

(this: *mut ffi::GtkAboutDialog, uri: *mut libc::c_char, f: glib_ffi::gpointer) -> glib_ffi::gboolean -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &str) -> Inhibit + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(uri)).to_glib() -} - -unsafe extern "C" fn notify_artists_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_authors_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_comments_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_copyright_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_documenters_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_license_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_license_type_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_logo_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_logo_icon_name_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_program_name_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_translator_credits_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_version_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_website_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_website_label_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_wrap_license_trampoline

(this: *mut ffi::GtkAboutDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AboutDialog::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for AboutDialog { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AboutDialog") + } } diff --git a/src/auto/accel_group.rs b/src/auto/accel_group.rs index 5a3f96e90b..31723d126d 100644 --- a/src/auto/accel_group.rs +++ b/src/auto/accel_group.rs @@ -1,42 +1,46 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; use gdk; -use gdk_ffi; +use gdk_sys; use glib; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use gobject_sys; +use gtk_sys; use libc; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use AccelFlags; glib_wrapper! { - pub struct AccelGroup(Object); + pub struct AccelGroup(Object); match fn { - get_type => || ffi::gtk_accel_group_get_type(), + get_type => || gtk_sys::gtk_accel_group_get_type(), } } impl AccelGroup { pub fn new() -> AccelGroup { + assert_initialized_main_thread!(); + unsafe { from_glib_full(gtk_sys::gtk_accel_group_new()) } + } + + pub fn from_accel_closure(closure: &glib::Closure) -> Option { assert_initialized_main_thread!(); unsafe { - from_glib_full(ffi::gtk_accel_group_new()) + from_glib_none(gtk_sys::gtk_accel_group_from_accel_closure( + closure.to_glib_none().0, + )) } } - - //pub fn from_accel_closure(closure: /*Ignored*/&glib::Closure) -> Option { - // unsafe { TODO: call ffi::gtk_accel_group_from_accel_closure() } - //} } impl Default for AccelGroup { @@ -45,18 +49,32 @@ impl Default for AccelGroup { } } -pub trait AccelGroupExt { - //fn activate>(&self, accel_quark: /*Ignored*/glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType) -> bool; +pub const NONE_ACCEL_GROUP: Option<&AccelGroup> = None; - //fn connect(&self, accel_key: u32, accel_mods: gdk::ModifierType, accel_flags: AccelFlags, closure: /*Ignored*/&glib::Closure); +pub trait AccelGroupExt: 'static { + fn activate>( + &self, + accel_quark: glib::Quark, + acceleratable: &P, + accel_key: u32, + accel_mods: gdk::ModifierType, + ) -> bool; - //fn connect_by_path(&self, accel_path: &str, closure: /*Ignored*/&glib::Closure); + fn connect( + &self, + accel_key: u32, + accel_mods: gdk::ModifierType, + accel_flags: AccelFlags, + closure: &glib::Closure, + ); - //fn disconnect<'a, P: Into>>(&self, closure: P) -> bool; + fn connect_by_path(&self, accel_path: &str, closure: &glib::Closure); + + fn disconnect(&self, closure: Option<&glib::Closure>) -> bool; fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool; - //fn find>>(&self, find_func: /*Unknown conversion*//*Unimplemented*/AccelGroupFindFunc, data: P) -> /*Ignored*/Option; + //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option) -> /*Ignored*/Option; fn get_is_locked(&self) -> bool; @@ -66,112 +84,250 @@ pub trait AccelGroupExt { fn unlock(&self); - fn connect_accel_activate bool + 'static>(&self, f: F) -> SignalHandlerId; + fn connect_accel_activate< + F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId; - //fn connect_accel_changed(&self, f: F) -> SignalHandlerId; + fn connect_accel_changed( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_is_locked_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_modifier_mask_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_modifier_mask_notify( + &self, + f: F, + ) -> SignalHandlerId; } -impl + IsA> AccelGroupExt for O { - //fn activate>(&self, accel_quark: /*Ignored*/glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType) -> bool { - // unsafe { TODO: call ffi::gtk_accel_group_activate() } - //} +impl> AccelGroupExt for O { + fn activate>( + &self, + accel_quark: glib::Quark, + acceleratable: &P, + accel_key: u32, + accel_mods: gdk::ModifierType, + ) -> bool { + unsafe { + from_glib(gtk_sys::gtk_accel_group_activate( + self.as_ref().to_glib_none().0, + accel_quark.to_glib(), + acceleratable.as_ref().to_glib_none().0, + accel_key, + accel_mods.to_glib(), + )) + } + } - //fn connect(&self, accel_key: u32, accel_mods: gdk::ModifierType, accel_flags: AccelFlags, closure: /*Ignored*/&glib::Closure) { - // unsafe { TODO: call ffi::gtk_accel_group_connect() } - //} + fn connect( + &self, + accel_key: u32, + accel_mods: gdk::ModifierType, + accel_flags: AccelFlags, + closure: &glib::Closure, + ) { + unsafe { + gtk_sys::gtk_accel_group_connect( + self.as_ref().to_glib_none().0, + accel_key, + accel_mods.to_glib(), + accel_flags.to_glib(), + closure.to_glib_none().0, + ); + } + } - //fn connect_by_path(&self, accel_path: &str, closure: /*Ignored*/&glib::Closure) { - // unsafe { TODO: call ffi::gtk_accel_group_connect_by_path() } - //} + fn connect_by_path(&self, accel_path: &str, closure: &glib::Closure) { + unsafe { + gtk_sys::gtk_accel_group_connect_by_path( + self.as_ref().to_glib_none().0, + accel_path.to_glib_none().0, + closure.to_glib_none().0, + ); + } + } - //fn disconnect<'a, P: Into>>(&self, closure: P) -> bool { - // unsafe { TODO: call ffi::gtk_accel_group_disconnect() } - //} + fn disconnect(&self, closure: Option<&glib::Closure>) -> bool { + unsafe { + from_glib(gtk_sys::gtk_accel_group_disconnect( + self.as_ref().to_glib_none().0, + closure.to_glib_none().0, + )) + } + } fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool { unsafe { - from_glib(ffi::gtk_accel_group_disconnect_key(self.to_glib_none().0, accel_key, accel_mods.to_glib())) + from_glib(gtk_sys::gtk_accel_group_disconnect_key( + self.as_ref().to_glib_none().0, + accel_key, + accel_mods.to_glib(), + )) } } - //fn find>>(&self, find_func: /*Unknown conversion*//*Unimplemented*/AccelGroupFindFunc, data: P) -> /*Ignored*/Option { - // unsafe { TODO: call ffi::gtk_accel_group_find() } + //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option) -> /*Ignored*/Option { + // unsafe { TODO: call gtk_sys:gtk_accel_group_find() } //} fn get_is_locked(&self) -> bool { unsafe { - from_glib(ffi::gtk_accel_group_get_is_locked(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_accel_group_get_is_locked( + self.as_ref().to_glib_none().0, + )) } } fn get_modifier_mask(&self) -> gdk::ModifierType { unsafe { - from_glib(ffi::gtk_accel_group_get_modifier_mask(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_accel_group_get_modifier_mask( + self.as_ref().to_glib_none().0, + )) } } fn lock(&self) { unsafe { - ffi::gtk_accel_group_lock(self.to_glib_none().0); + gtk_sys::gtk_accel_group_lock(self.as_ref().to_glib_none().0); } } fn unlock(&self) { unsafe { - ffi::gtk_accel_group_unlock(self.to_glib_none().0); + gtk_sys::gtk_accel_group_unlock(self.as_ref().to_glib_none().0); } } - fn connect_accel_activate bool + 'static>(&self, f: F) -> SignalHandlerId { + fn connect_accel_activate< + F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn accel_activate_trampoline< + P, + F: Fn(&P, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, + >( + this: *mut gtk_sys::GtkAccelGroup, + acceleratable: *mut gobject_sys::GObject, + keyval: libc::c_uint, + modifier: gdk_sys::GdkModifierType, + f: glib_sys::gpointer, + ) -> glib_sys::gboolean + where + P: IsA, + { + let f: &F = &*(f as *const F); + f( + &AccelGroup::from_glib_borrow(this).unsafe_cast(), + &from_glib_borrow(acceleratable), + keyval, + from_glib(modifier), + ) + .to_glib() + } unsafe { - let f: Box_ bool + 'static>> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "accel-activate", - transmute(accel_activate_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"accel-activate\0".as_ptr() as *const _, + Some(transmute(accel_activate_trampoline:: as usize)), + Box_::into_raw(f), + ) } } - //fn connect_accel_changed(&self, f: F) -> SignalHandlerId { - // Ignored accel_closure: GObject.Closure - //} + fn connect_accel_changed( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn accel_changed_trampoline< + P, + F: Fn(&P, u32, gdk::ModifierType, &glib::Closure) + 'static, + >( + this: *mut gtk_sys::GtkAccelGroup, + keyval: libc::c_uint, + modifier: gdk_sys::GdkModifierType, + accel_closure: *mut gobject_sys::GClosure, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f( + &AccelGroup::from_glib_borrow(this).unsafe_cast(), + keyval, + from_glib(modifier), + &from_glib_borrow(accel_closure), + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"accel-changed\0".as_ptr() as *const _, + Some(transmute(accel_changed_trampoline:: as usize)), + Box_::into_raw(f), + ) + } + } fn connect_property_is_locked_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_is_locked_trampoline( + this: *mut gtk_sys::GtkAccelGroup, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&AccelGroup::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::is-locked", - transmute(notify_is_locked_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::is-locked\0".as_ptr() as *const _, + Some(transmute(notify_is_locked_trampoline:: as usize)), + Box_::into_raw(f), + ) } } - fn connect_property_modifier_mask_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_modifier_mask_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_modifier_mask_trampoline( + this: *mut gtk_sys::GtkAccelGroup, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&AccelGroup::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::modifier-mask", - transmute(notify_modifier_mask_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::modifier-mask\0".as_ptr() as *const _, + Some(transmute( + notify_modifier_mask_trampoline:: as usize, + )), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn accel_activate_trampoline

(this: *mut ffi::GtkAccelGroup, acceleratable: *mut gobject_ffi::GObject, keyval: libc::c_uint, modifier: gdk_ffi::GdkModifierType, f: glib_ffi::gpointer) -> glib_ffi::gboolean -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &glib::Object, u32, gdk::ModifierType) -> bool + 'static) = transmute(f); - f(&AccelGroup::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(acceleratable), keyval, from_glib(modifier)).to_glib() -} - -unsafe extern "C" fn notify_is_locked_trampoline

(this: *mut ffi::GtkAccelGroup, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AccelGroup::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_modifier_mask_trampoline

(this: *mut ffi::GtkAccelGroup, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AccelGroup::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for AccelGroup { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AccelGroup") + } } diff --git a/src/auto/accel_label.rs b/src/auto/accel_label.rs new file mode 100644 index 0000000000..17fb3e0fe6 --- /dev/null +++ b/src/auto/accel_label.rs @@ -0,0 +1,777 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// 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; +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 pango; +use std::boxed::Box as Box_; +use std::fmt; +use std::mem; +use std::mem::transmute; +use Align; +use Buildable; +use Container; +use Justification; +use Label; +use Misc; +use Widget; + +glib_wrapper! { + pub struct AccelLabel(Object) @extends Label, Misc, Widget, @implements Buildable; + + match fn { + get_type => || gtk_sys::gtk_accel_label_get_type(), + } +} + +impl AccelLabel { + pub fn new(string: &str) -> AccelLabel { + assert_initialized_main_thread!(); + unsafe { + Widget::from_glib_none(gtk_sys::gtk_accel_label_new(string.to_glib_none().0)) + .unsafe_cast() + } + } +} + +pub struct AccelLabelBuilder { + accel_closure: Option, + accel_widget: Option, + angle: Option, + attributes: Option, + ellipsize: Option, + justify: Option, + label: Option, + lines: Option, + max_width_chars: Option, + mnemonic_widget: Option, + pattern: Option, + selectable: Option, + single_line_mode: Option, + track_visited_links: Option, + use_markup: Option, + use_underline: Option, + width_chars: Option, + wrap: Option, + wrap_mode: Option, + #[cfg(any(feature = "v3_16", feature = "dox"))] + xalign: Option, + #[cfg(any(feature = "v3_16", feature = "dox"))] + yalign: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + 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 { + accel_closure: None, + accel_widget: None, + angle: None, + attributes: None, + ellipsize: None, + justify: None, + label: None, + lines: None, + max_width_chars: None, + mnemonic_widget: None, + pattern: None, + selectable: None, + single_line_mode: None, + track_visited_links: None, + use_markup: None, + use_underline: None, + width_chars: None, + wrap: None, + wrap_mode: None, + #[cfg(any(feature = "v3_16", feature = "dox"))] + xalign: None, + #[cfg(any(feature = "v3_16", feature = "dox"))] + yalign: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 angle) = self.angle { + properties.push(("angle", angle)); + } + if let Some(ref attributes) = self.attributes { + properties.push(("attributes", attributes)); + } + if let Some(ref ellipsize) = self.ellipsize { + properties.push(("ellipsize", ellipsize)); + } + if let Some(ref justify) = self.justify { + properties.push(("justify", justify)); + } + if let Some(ref label) = self.label { + properties.push(("label", label)); + } + if let Some(ref lines) = self.lines { + properties.push(("lines", lines)); + } + if let Some(ref max_width_chars) = self.max_width_chars { + properties.push(("max-width-chars", max_width_chars)); + } + if let Some(ref mnemonic_widget) = self.mnemonic_widget { + properties.push(("mnemonic-widget", mnemonic_widget)); + } + if let Some(ref pattern) = self.pattern { + properties.push(("pattern", pattern)); + } + if let Some(ref selectable) = self.selectable { + properties.push(("selectable", selectable)); + } + if let Some(ref single_line_mode) = self.single_line_mode { + properties.push(("single-line-mode", single_line_mode)); + } + if let Some(ref track_visited_links) = self.track_visited_links { + properties.push(("track-visited-links", track_visited_links)); + } + if let Some(ref use_markup) = self.use_markup { + properties.push(("use-markup", use_markup)); + } + if let Some(ref use_underline) = self.use_underline { + properties.push(("use-underline", use_underline)); + } + if let Some(ref width_chars) = self.width_chars { + properties.push(("width-chars", width_chars)); + } + if let Some(ref wrap) = self.wrap { + properties.push(("wrap", wrap)); + } + if let Some(ref wrap_mode) = self.wrap_mode { + properties.push(("wrap-mode", wrap_mode)); + } + #[cfg(any(feature = "v3_16", feature = "dox"))] + { + if let Some(ref xalign) = self.xalign { + properties.push(("xalign", xalign)); + } + } + #[cfg(any(feature = "v3_16", feature = "dox"))] + { + if let Some(ref yalign) = self.yalign { + properties.push(("yalign", yalign)); + } + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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: &Widget) -> Self { + self.accel_widget = Some(accel_widget.clone()); + self + } + + pub fn angle(mut self, angle: f64) -> Self { + self.angle = Some(angle); + self + } + + pub fn attributes(mut self, attributes: &pango::AttrList) -> Self { + self.attributes = Some(attributes.clone()); + self + } + + pub fn ellipsize(mut self, ellipsize: pango::EllipsizeMode) -> Self { + self.ellipsize = Some(ellipsize); + self + } + + pub fn justify(mut self, justify: Justification) -> Self { + self.justify = Some(justify); + self + } + + pub fn label(mut self, label: &str) -> Self { + self.label = Some(label.to_string()); + self + } + + pub fn lines(mut self, lines: i32) -> Self { + self.lines = Some(lines); + self + } + + pub fn max_width_chars(mut self, max_width_chars: i32) -> Self { + self.max_width_chars = Some(max_width_chars); + self + } + + pub fn mnemonic_widget(mut self, mnemonic_widget: &Widget) -> Self { + self.mnemonic_widget = Some(mnemonic_widget.clone()); + self + } + + pub fn pattern(mut self, pattern: &str) -> Self { + self.pattern = Some(pattern.to_string()); + self + } + + pub fn selectable(mut self, selectable: bool) -> Self { + self.selectable = Some(selectable); + self + } + + pub fn single_line_mode(mut self, single_line_mode: bool) -> Self { + self.single_line_mode = Some(single_line_mode); + self + } + + pub fn track_visited_links(mut self, track_visited_links: bool) -> Self { + self.track_visited_links = Some(track_visited_links); + self + } + + pub fn use_markup(mut self, use_markup: bool) -> Self { + self.use_markup = Some(use_markup); + self + } + + pub fn use_underline(mut self, use_underline: bool) -> Self { + self.use_underline = Some(use_underline); + self + } + + pub fn width_chars(mut self, width_chars: i32) -> Self { + self.width_chars = Some(width_chars); + self + } + + pub fn wrap(mut self, wrap: bool) -> Self { + self.wrap = Some(wrap); + self + } + + pub fn wrap_mode(mut self, wrap_mode: pango::WrapMode) -> Self { + self.wrap_mode = Some(wrap_mode); + self + } + + #[cfg(any(feature = "v3_16", feature = "dox"))] + pub fn xalign(mut self, xalign: f32) -> Self { + self.xalign = Some(xalign); + self + } + + #[cfg(any(feature = "v3_16", feature = "dox"))] + pub fn yalign(mut self, yalign: f32) -> Self { + self.yalign = Some(yalign); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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 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 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; +} + +impl> AccelLabelExt for O { + fn get_accel(&self) -> (u32, gdk::ModifierType) { + unsafe { + let mut accelerator_key = mem::uninitialized(); + let mut accelerator_mods = mem::uninitialized(); + gtk_sys::gtk_accel_label_get_accel( + self.as_ref().to_glib_none().0, + &mut accelerator_key, + &mut accelerator_mods, + ); + (accelerator_key, from_glib(accelerator_mods)) + } + } + + 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) } + } + + fn refetch(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_accel_label_refetch( + self.as_ref().to_glib_none().0, + )) + } + } + + 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, + 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>) { + 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, + ); + } + } + + 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() + } + } + + fn connect_property_accel_closure_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_accel_closure_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), + ) + } + } +} + +impl fmt::Display for AccelLabel { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AccelLabel") + } +} diff --git a/src/auto/action_bar.rs b/src/auto/action_bar.rs index 7b4be2f66e..73a004fbda 100644 --- a/src/auto/action_bar.rs +++ b/src/auto/action_bar.rs @@ -1,59 +1,430 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// 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::translate::*; +use glib::StaticType; +use glib::ToValue; +use glib::Value; +use gtk_sys; +use std::fmt; +use Align; use Bin; use Buildable; use Container; use PackType; +use ResizeMode; use Widget; -use ffi; -use glib::Value; -use glib::object::Downcast; -use glib::object::IsA; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::mem::transmute; -use std::ptr; glib_wrapper! { - pub struct ActionBar(Object): Bin, Container, Widget, Buildable; + pub struct ActionBar(Object) @extends Bin, Container, Widget, @implements Buildable; match fn { - get_type => || ffi::gtk_action_bar_get_type(), + get_type => || gtk_sys::gtk_action_bar_get_type(), } } impl ActionBar { - #[cfg(any(feature = "v3_12", feature = "dox"))] pub fn new() -> ActionBar { assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_action_bar_new()).downcast_unchecked() - } + unsafe { Widget::from_glib_none(gtk_sys::gtk_action_bar_new()).unsafe_cast() } } } -#[cfg(any(feature = "v3_12", feature = "dox"))] impl Default for ActionBar { fn default() -> Self { Self::new() } } -pub trait ActionBarExt { - #[cfg(any(feature = "v3_12", feature = "dox"))] +pub struct ActionBarBuilder { + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + 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 { + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + pub fn build(self) -> ActionBar { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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 border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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; - #[cfg(any(feature = "v3_12", feature = "dox"))] fn pack_end>(&self, child: &P); - #[cfg(any(feature = "v3_12", feature = "dox"))] fn pack_start>(&self, child: &P); - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn set_center_widget<'a, P: IsA + 'a, Q: Into>>(&self, center_widget: Q); + fn set_center_widget>(&self, center_widget: Option<&P>); fn get_child_pack_type>(&self, item: &T) -> PackType; @@ -64,63 +435,93 @@ pub trait ActionBarExt { fn set_child_position>(&self, item: &T, position: i32); } -impl + IsA> ActionBarExt for O { - #[cfg(any(feature = "v3_12", feature = "dox"))] +impl> ActionBarExt for O { fn get_center_widget(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_action_bar_get_center_widget(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_action_bar_get_center_widget( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_12", feature = "dox"))] fn pack_end>(&self, child: &P) { unsafe { - ffi::gtk_action_bar_pack_end(self.to_glib_none().0, child.to_glib_none().0); + gtk_sys::gtk_action_bar_pack_end( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] fn pack_start>(&self, child: &P) { unsafe { - ffi::gtk_action_bar_pack_start(self.to_glib_none().0, child.to_glib_none().0); + gtk_sys::gtk_action_bar_pack_start( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn set_center_widget<'a, P: IsA + 'a, Q: Into>>(&self, center_widget: Q) { - let center_widget = center_widget.into(); - let center_widget = center_widget.to_glib_none(); + fn set_center_widget>(&self, center_widget: Option<&P>) { unsafe { - ffi::gtk_action_bar_set_center_widget(self.to_glib_none().0, center_widget.0); + gtk_sys::gtk_action_bar_set_center_widget( + self.as_ref().to_glib_none().0, + center_widget.map(|p| p.as_ref()).to_glib_none().0, + ); } } fn get_child_pack_type>(&self, item: &T) -> PackType { - let mut value = Value::from(&0); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "pack-type".to_glib_none().0, value.to_glib_none_mut().0); - from_glib(transmute(value.get::().unwrap())) + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"pack-type\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } } fn set_child_pack_type>(&self, item: &T, pack_type: PackType) { - let pack_type = pack_type.to_glib() as i32; unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "pack-type".to_glib_none().0, Value::from(&pack_type).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"pack-type\0".as_ptr() as *const _, + Value::from(&pack_type).to_glib_none().0, + ); } } fn get_child_position>(&self, item: &T) -> i32 { - let mut value = Value::from(&0); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "position".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"position\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } fn set_child_position>(&self, item: &T, position: i32) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "position".to_glib_none().0, Value::from(&position).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"position\0".as_ptr() as *const _, + Value::from(&position).to_glib_none().0, + ); } } } + +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 2efef32095..aeea7a82e1 100644 --- a/src/auto/actionable.rs +++ b/src/auto/actionable.rs @@ -1,95 +1,121 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use Buildable; -use Widget; -use ffi; use glib; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib::GString; +use glib_sys; +use gtk_sys; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use Buildable; +use Widget; glib_wrapper! { - pub struct Actionable(Object): Widget, Buildable; + pub struct Actionable(Interface) @requires Widget, Buildable; match fn { - get_type => || ffi::gtk_actionable_get_type(), + get_type => || gtk_sys::gtk_actionable_get_type(), } } -pub trait ActionableExt { - fn get_action_name(&self) -> Option; +pub const NONE_ACTIONABLE: Option<&Actionable> = None; + +pub trait ActionableExt: 'static { + fn get_action_name(&self) -> Option; fn get_action_target_value(&self) -> Option; - fn set_action_name<'a, P: Into>>(&self, action_name: P); + fn set_action_name(&self, action_name: Option<&str>); //fn set_action_target(&self, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - fn set_action_target_value(&self, target_value: &glib::Variant); + fn set_action_target_value(&self, target_value: Option<&glib::Variant>); fn set_detailed_action_name(&self, detailed_action_name: &str); fn connect_property_action_name_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA> ActionableExt for O { - fn get_action_name(&self) -> Option { +impl> ActionableExt for O { + fn get_action_name(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_actionable_get_action_name(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_actionable_get_action_name( + self.as_ref().to_glib_none().0, + )) } } fn get_action_target_value(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_actionable_get_action_target_value(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_actionable_get_action_target_value( + self.as_ref().to_glib_none().0, + )) } } - fn set_action_name<'a, P: Into>>(&self, action_name: P) { - let action_name = action_name.into(); - let action_name = action_name.to_glib_none(); + fn set_action_name(&self, action_name: Option<&str>) { unsafe { - ffi::gtk_actionable_set_action_name(self.to_glib_none().0, action_name.0); + gtk_sys::gtk_actionable_set_action_name( + self.as_ref().to_glib_none().0, + action_name.to_glib_none().0, + ); } } //fn set_action_target(&self, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call ffi::gtk_actionable_set_action_target() } + // unsafe { TODO: call gtk_sys:gtk_actionable_set_action_target() } //} - fn set_action_target_value(&self, target_value: &glib::Variant) { + fn set_action_target_value(&self, target_value: Option<&glib::Variant>) { unsafe { - ffi::gtk_actionable_set_action_target_value(self.to_glib_none().0, target_value.to_glib_none().0); + gtk_sys::gtk_actionable_set_action_target_value( + self.as_ref().to_glib_none().0, + target_value.to_glib_none().0, + ); } } fn set_detailed_action_name(&self, detailed_action_name: &str) { unsafe { - ffi::gtk_actionable_set_detailed_action_name(self.to_glib_none().0, detailed_action_name.to_glib_none().0); + gtk_sys::gtk_actionable_set_detailed_action_name( + self.as_ref().to_glib_none().0, + detailed_action_name.to_glib_none().0, + ); } } fn connect_property_action_name_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_action_name_trampoline( + this: *mut gtk_sys::GtkActionable, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Actionable::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::action-name", - transmute(notify_action_name_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn notify_action_name_trampoline

(this: *mut ffi::GtkActionable, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Actionable::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for Actionable { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Actionable") + } } diff --git a/src/auto/adjustment.rs b/src/auto/adjustment.rs index 5a99f07121..13606b2edb 100644 --- a/src/auto/adjustment.rs +++ b/src/auto/adjustment.rs @@ -1,43 +1,66 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; -use glib; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use gtk_sys; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; glib_wrapper! { - pub struct Adjustment(Object); + pub struct Adjustment(Object); match fn { - get_type => || ffi::gtk_adjustment_get_type(), + get_type => || gtk_sys::gtk_adjustment_get_type(), } } impl Adjustment { - pub fn new(value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64) -> Adjustment { + pub fn new( + value: f64, + lower: f64, + upper: f64, + step_increment: f64, + page_increment: f64, + page_size: f64, + ) -> Adjustment { assert_initialized_main_thread!(); unsafe { - from_glib_none(ffi::gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size)) + from_glib_none(gtk_sys::gtk_adjustment_new( + value, + lower, + upper, + step_increment, + page_increment, + page_size, + )) } } } -pub trait AdjustmentExt { +pub const NONE_ADJUSTMENT: Option<&Adjustment> = None; + +pub trait AdjustmentExt: 'static { + #[cfg_attr(feature = "v3_18", deprecated)] fn changed(&self); fn clamp_page(&self, lower: f64, upper: f64); - fn configure(&self, value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64); + fn configure( + &self, + value: f64, + lower: f64, + upper: f64, + step_increment: f64, + page_increment: f64, + page_size: f64, + ); fn get_lower(&self) -> f64; @@ -65,6 +88,7 @@ pub trait AdjustmentExt { fn set_value(&self, value: f64); + #[cfg_attr(feature = "v3_18", deprecated)] fn value_changed(&self); fn connect_changed(&self, f: F) -> SignalHandlerId; @@ -73,237 +97,321 @@ pub trait AdjustmentExt { fn connect_property_lower_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_page_increment_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_page_increment_notify( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_page_size_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_step_increment_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_step_increment_notify( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_upper_notify(&self, f: F) -> SignalHandlerId; fn connect_property_value_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA> AdjustmentExt for O { +impl> AdjustmentExt for O { fn changed(&self) { unsafe { - ffi::gtk_adjustment_changed(self.to_glib_none().0); + gtk_sys::gtk_adjustment_changed(self.as_ref().to_glib_none().0); } } fn clamp_page(&self, lower: f64, upper: f64) { unsafe { - ffi::gtk_adjustment_clamp_page(self.to_glib_none().0, lower, upper); + gtk_sys::gtk_adjustment_clamp_page(self.as_ref().to_glib_none().0, lower, upper); } } - fn configure(&self, value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64) { + fn configure( + &self, + value: f64, + lower: f64, + upper: f64, + step_increment: f64, + page_increment: f64, + page_size: f64, + ) { unsafe { - ffi::gtk_adjustment_configure(self.to_glib_none().0, value, lower, upper, step_increment, page_increment, page_size); + gtk_sys::gtk_adjustment_configure( + self.as_ref().to_glib_none().0, + value, + lower, + upper, + step_increment, + page_increment, + page_size, + ); } } fn get_lower(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_lower(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_lower(self.as_ref().to_glib_none().0) } } fn get_minimum_increment(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_minimum_increment(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_minimum_increment(self.as_ref().to_glib_none().0) } } fn get_page_increment(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_page_increment(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_page_increment(self.as_ref().to_glib_none().0) } } fn get_page_size(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_page_size(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_page_size(self.as_ref().to_glib_none().0) } } fn get_step_increment(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_step_increment(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_step_increment(self.as_ref().to_glib_none().0) } } fn get_upper(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_upper(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_upper(self.as_ref().to_glib_none().0) } } fn get_value(&self) -> f64 { - unsafe { - ffi::gtk_adjustment_get_value(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_adjustment_get_value(self.as_ref().to_glib_none().0) } } fn set_lower(&self, lower: f64) { unsafe { - ffi::gtk_adjustment_set_lower(self.to_glib_none().0, lower); + gtk_sys::gtk_adjustment_set_lower(self.as_ref().to_glib_none().0, lower); } } fn set_page_increment(&self, page_increment: f64) { unsafe { - ffi::gtk_adjustment_set_page_increment(self.to_glib_none().0, page_increment); + gtk_sys::gtk_adjustment_set_page_increment( + self.as_ref().to_glib_none().0, + page_increment, + ); } } fn set_page_size(&self, page_size: f64) { unsafe { - ffi::gtk_adjustment_set_page_size(self.to_glib_none().0, page_size); + gtk_sys::gtk_adjustment_set_page_size(self.as_ref().to_glib_none().0, page_size); } } fn set_step_increment(&self, step_increment: f64) { unsafe { - ffi::gtk_adjustment_set_step_increment(self.to_glib_none().0, step_increment); + gtk_sys::gtk_adjustment_set_step_increment( + self.as_ref().to_glib_none().0, + step_increment, + ); } } fn set_upper(&self, upper: f64) { unsafe { - ffi::gtk_adjustment_set_upper(self.to_glib_none().0, upper); + gtk_sys::gtk_adjustment_set_upper(self.as_ref().to_glib_none().0, upper); } } fn set_value(&self, value: f64) { unsafe { - ffi::gtk_adjustment_set_value(self.to_glib_none().0, value); + gtk_sys::gtk_adjustment_set_value(self.as_ref().to_glib_none().0, value); } } fn value_changed(&self) { unsafe { - ffi::gtk_adjustment_value_changed(self.to_glib_none().0); + gtk_sys::gtk_adjustment_value_changed(self.as_ref().to_glib_none().0); } } fn connect_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn changed_trampoline( + this: *mut gtk_sys::GtkAdjustment, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "changed", - transmute(changed_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } fn connect_value_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn value_changed_trampoline( + this: *mut gtk_sys::GtkAdjustment, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "value-changed", - transmute(value_changed_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } fn connect_property_lower_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_lower_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::lower", - transmute(notify_lower_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_page_increment_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_page_increment_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_page_increment_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::page-increment", - transmute(notify_page_increment_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } fn connect_property_page_size_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_page_size_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::page-size", - transmute(notify_page_size_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_step_increment_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_step_increment_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_step_increment_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::step-increment", - transmute(notify_step_increment_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } fn connect_property_upper_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_upper_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::upper", - transmute(notify_upper_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } fn connect_property_value_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_value_trampoline( + this: *mut gtk_sys::GtkAdjustment, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::value", - transmute(notify_value_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn changed_trampoline

(this: *mut ffi::GtkAdjustment, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn value_changed_trampoline

(this: *mut ffi::GtkAdjustment, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_lower_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_page_increment_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_page_size_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_step_increment_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_upper_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_value_trampoline

(this: *mut ffi::GtkAdjustment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Adjustment::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for Adjustment { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Adjustment") + } } diff --git a/src/auto/alignment.rs b/src/auto/alignment.rs deleted file mode 100644 index 9ea2736926..0000000000 --- a/src/auto/alignment.rs +++ /dev/null @@ -1,351 +0,0 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) -// DO NOT EDIT - -use Bin; -use Buildable; -use Container; -use Widget; -use ffi; -use glib; -use glib::Value; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; - -glib_wrapper! { - pub struct Alignment(Object): Bin, Container, Widget, Buildable; - - match fn { - get_type => || ffi::gtk_alignment_get_type(), - } -} - -impl Alignment { - pub fn new(xalign: f32, yalign: f32, xscale: f32, yscale: f32) -> Alignment { - assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_alignment_new(xalign, yalign, xscale, yscale)).downcast_unchecked() - } - } -} - -pub trait AlignmentExt { - fn get_padding(&self) -> (u32, u32, u32, u32); - - fn set(&self, xalign: f32, yalign: f32, xscale: f32, yscale: f32); - - fn set_padding(&self, padding_top: u32, padding_bottom: u32, padding_left: u32, padding_right: u32); - - fn get_property_bottom_padding(&self) -> u32; - - fn set_property_bottom_padding(&self, bottom_padding: u32); - - fn get_property_left_padding(&self) -> u32; - - fn set_property_left_padding(&self, left_padding: u32); - - fn get_property_right_padding(&self) -> u32; - - fn set_property_right_padding(&self, right_padding: u32); - - fn get_property_top_padding(&self) -> u32; - - fn set_property_top_padding(&self, top_padding: u32); - - fn get_property_xalign(&self) -> f32; - - fn set_property_xalign(&self, xalign: f32); - - fn get_property_xscale(&self) -> f32; - - fn set_property_xscale(&self, xscale: f32); - - fn get_property_yalign(&self) -> f32; - - fn set_property_yalign(&self, yalign: f32); - - fn get_property_yscale(&self) -> f32; - - fn set_property_yscale(&self, yscale: f32); - - fn connect_property_bottom_padding_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_left_padding_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_right_padding_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_top_padding_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_xscale_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_yscale_notify(&self, f: F) -> SignalHandlerId; -} - -impl + IsA> AlignmentExt for O { - fn get_padding(&self) -> (u32, u32, u32, u32) { - unsafe { - let mut padding_top = mem::uninitialized(); - let mut padding_bottom = mem::uninitialized(); - let mut padding_left = mem::uninitialized(); - let mut padding_right = mem::uninitialized(); - ffi::gtk_alignment_get_padding(self.to_glib_none().0, &mut padding_top, &mut padding_bottom, &mut padding_left, &mut padding_right); - (padding_top, padding_bottom, padding_left, padding_right) - } - } - - fn set(&self, xalign: f32, yalign: f32, xscale: f32, yscale: f32) { - unsafe { - ffi::gtk_alignment_set(self.to_glib_none().0, xalign, yalign, xscale, yscale); - } - } - - fn set_padding(&self, padding_top: u32, padding_bottom: u32, padding_left: u32, padding_right: u32) { - unsafe { - ffi::gtk_alignment_set_padding(self.to_glib_none().0, padding_top, padding_bottom, padding_left, padding_right); - } - } - - fn get_property_bottom_padding(&self) -> u32 { - let mut value = Value::from(&0u32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "bottom-padding".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_bottom_padding(&self, bottom_padding: u32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "bottom-padding".to_glib_none().0, Value::from(&bottom_padding).to_glib_none().0); - } - } - - fn get_property_left_padding(&self) -> u32 { - let mut value = Value::from(&0u32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "left-padding".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_left_padding(&self, left_padding: u32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "left-padding".to_glib_none().0, Value::from(&left_padding).to_glib_none().0); - } - } - - fn get_property_right_padding(&self) -> u32 { - let mut value = Value::from(&0u32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "right-padding".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_right_padding(&self, right_padding: u32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "right-padding".to_glib_none().0, Value::from(&right_padding).to_glib_none().0); - } - } - - fn get_property_top_padding(&self) -> u32 { - let mut value = Value::from(&0u32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "top-padding".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_top_padding(&self, top_padding: u32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "top-padding".to_glib_none().0, Value::from(&top_padding).to_glib_none().0); - } - } - - fn get_property_xalign(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "xalign".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_xalign(&self, xalign: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "xalign".to_glib_none().0, Value::from(&xalign).to_glib_none().0); - } - } - - fn get_property_xscale(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "xscale".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_xscale(&self, xscale: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "xscale".to_glib_none().0, Value::from(&xscale).to_glib_none().0); - } - } - - fn get_property_yalign(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "yalign".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_yalign(&self, yalign: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "yalign".to_glib_none().0, Value::from(&yalign).to_glib_none().0); - } - } - - fn get_property_yscale(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "yscale".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_yscale(&self, yscale: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "yscale".to_glib_none().0, Value::from(&yscale).to_glib_none().0); - } - } - - fn connect_property_bottom_padding_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::bottom-padding", - transmute(notify_bottom_padding_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_left_padding_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::left-padding", - transmute(notify_left_padding_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_right_padding_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::right-padding", - transmute(notify_right_padding_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_top_padding_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::top-padding", - transmute(notify_top_padding_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::xalign", - transmute(notify_xalign_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_xscale_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::xscale", - transmute(notify_xscale_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::yalign", - transmute(notify_yalign_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_yscale_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::yscale", - transmute(notify_yscale_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } -} - -unsafe extern "C" fn notify_bottom_padding_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_left_padding_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_right_padding_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_top_padding_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_xalign_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_xscale_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_yalign_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_yscale_trampoline

(this: *mut ffi::GtkAlignment, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Alignment::from_glib_borrow(this).downcast_unchecked()) -} diff --git a/src/auto/app_chooser_button.rs b/src/auto/app_chooser_button.rs new file mode 100644 index 0000000000..42b28d5f7f --- /dev/null +++ b/src/auto/app_chooser_button.rs @@ -0,0 +1,812 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// 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::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 AppChooser; +use Bin; +use Buildable; +use CellArea; +use CellEditable; +use CellLayout; +use ComboBox; +use Container; +use ResizeMode; +use SensitivityType; +use TreeModel; +use Widget; + +glib_wrapper! { + pub struct AppChooserButton(Object) @extends ComboBox, Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout, AppChooser; + + match fn { + get_type => || gtk_sys::gtk_app_chooser_button_get_type(), + } +} + +impl AppChooserButton { + pub fn new(content_type: &str) -> AppChooserButton { + assert_initialized_main_thread!(); + unsafe { + Widget::from_glib_none(gtk_sys::gtk_app_chooser_button_new( + content_type.to_glib_none().0, + )) + .unsafe_cast() + } + } +} + +pub struct AppChooserButtonBuilder { + heading: Option, + show_default_item: Option, + show_dialog_item: Option, + active: Option, + active_id: Option, + button_sensitivity: Option, + cell_area: Option, + column_span_column: Option, + entry_text_column: Option, + has_entry: Option, + has_frame: Option, + id_column: Option, + model: Option, + popup_fixed_width: Option, + row_span_column: Option, + wrap_width: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl AppChooserButtonBuilder { + pub fn new() -> Self { + Self { + heading: None, + show_default_item: None, + show_dialog_item: None, + active: None, + active_id: None, + button_sensitivity: None, + cell_area: None, + column_span_column: None, + entry_text_column: None, + has_entry: None, + has_frame: None, + id_column: None, + model: None, + popup_fixed_width: None, + row_span_column: None, + wrap_width: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 active) = self.active { + properties.push(("active", active)); + } + if let Some(ref active_id) = self.active_id { + properties.push(("active-id", active_id)); + } + if let Some(ref button_sensitivity) = self.button_sensitivity { + properties.push(("button-sensitivity", button_sensitivity)); + } + if let Some(ref cell_area) = self.cell_area { + properties.push(("cell-area", cell_area)); + } + if let Some(ref column_span_column) = self.column_span_column { + properties.push(("column-span-column", column_span_column)); + } + if let Some(ref entry_text_column) = self.entry_text_column { + properties.push(("entry-text-column", entry_text_column)); + } + if let Some(ref has_entry) = self.has_entry { + properties.push(("has-entry", has_entry)); + } + if let Some(ref has_frame) = self.has_frame { + properties.push(("has-frame", has_frame)); + } + if let Some(ref id_column) = self.id_column { + properties.push(("id-column", id_column)); + } + if let Some(ref model) = self.model { + properties.push(("model", model)); + } + if let Some(ref popup_fixed_width) = self.popup_fixed_width { + properties.push(("popup-fixed-width", popup_fixed_width)); + } + if let Some(ref row_span_column) = self.row_span_column { + properties.push(("row-span-column", row_span_column)); + } + if let Some(ref wrap_width) = self.wrap_width { + properties.push(("wrap-width", wrap_width)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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 active(mut self, active: i32) -> Self { + self.active = Some(active); + self + } + + pub fn active_id(mut self, active_id: &str) -> Self { + self.active_id = Some(active_id.to_string()); + self + } + + pub fn button_sensitivity(mut self, button_sensitivity: SensitivityType) -> Self { + self.button_sensitivity = Some(button_sensitivity); + self + } + + pub fn cell_area(mut self, cell_area: &CellArea) -> Self { + self.cell_area = Some(cell_area.clone()); + self + } + + pub fn column_span_column(mut self, column_span_column: i32) -> Self { + self.column_span_column = Some(column_span_column); + self + } + + pub fn entry_text_column(mut self, entry_text_column: i32) -> Self { + self.entry_text_column = Some(entry_text_column); + self + } + + pub fn has_entry(mut self, has_entry: bool) -> Self { + self.has_entry = Some(has_entry); + self + } + + pub fn has_frame(mut self, has_frame: bool) -> Self { + self.has_frame = Some(has_frame); + self + } + + pub fn id_column(mut self, id_column: i32) -> Self { + self.id_column = Some(id_column); + self + } + + pub fn model(mut self, model: &TreeModel) -> Self { + self.model = Some(model.clone()); + self + } + + pub fn popup_fixed_width(mut self, popup_fixed_width: bool) -> Self { + self.popup_fixed_width = Some(popup_fixed_width); + self + } + + pub fn row_span_column(mut self, row_span_column: i32) -> Self { + self.row_span_column = Some(row_span_column); + self + } + + pub fn wrap_width(mut self, wrap_width: i32) -> Self { + self.wrap_width = Some(wrap_width); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_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_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) { + unsafe { + gtk_sys::gtk_app_chooser_button_append_custom_item( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + label.to_glib_none().0, + icon.as_ref().to_glib_none().0, + ); + } + } + + fn append_separator(&self) { + unsafe { + gtk_sys::gtk_app_chooser_button_append_separator(self.as_ref().to_glib_none().0); + } + } + + fn get_heading(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_app_chooser_button_get_heading( + self.as_ref().to_glib_none().0, + )) + } + } + + 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, + )) + } + } + + 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, + )) + } + } + + 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, + name.to_glib_none().0, + ); + } + } + + fn set_heading(&self, heading: &str) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_heading( + self.as_ref().to_glib_none().0, + heading.to_glib_none().0, + ); + } + } + + 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, + setting.to_glib(), + ); + } + } + + 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, + setting.to_glib(), + ); + } + } + + fn connect_custom_item_activated(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn custom_item_activated_trampoline( + 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(), + &GString::from_glib_borrow(item_name), + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"custom-item-activated\0".as_ptr() as *const _, + Some(transmute( + custom_item_activated_trampoline:: as usize, + )), + Box_::into_raw(f), + ) + } + } + + 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()) + } + 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)), + Box_::into_raw(f), + ) + } + } + + fn connect_property_show_default_item_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_default_item_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()) + } + 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, + )), + Box_::into_raw(f), + ) + } + } + + fn connect_property_show_dialog_item_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_dialog_item_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()) + } + 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, + )), + Box_::into_raw(f), + ) + } + } +} + +impl fmt::Display for AppChooserButton { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AppChooserButton") + } +} diff --git a/src/auto/app_chooser_dialog.rs b/src/auto/app_chooser_dialog.rs index 22cc78af8c..0f77ef1d1f 100644 --- a/src/auto/app_chooser_dialog.rs +++ b/src/auto/app_chooser_dialog.rs @@ -1,119 +1,843 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use gdk; +use gdk_pixbuf; +use gio; +use glib::object::Cast; +use glib::object::IsA; +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::transmute; +use Align; use AppChooser; +use Application; use Bin; use Buildable; use Container; use Dialog; use DialogFlags; +use ResizeMode; use Widget; use Window; -use ffi; -use glib; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; +use WindowPosition; +use WindowType; glib_wrapper! { - pub struct AppChooserDialog(Object): Dialog, Window, Bin, Container, Widget, Buildable, AppChooser; + pub struct AppChooserDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, AppChooser; match fn { - get_type => || ffi::gtk_app_chooser_dialog_get_type(), + get_type => || gtk_sys::gtk_app_chooser_dialog_get_type(), } } impl AppChooserDialog { - //pub fn new<'a, P: IsA + 'a, Q: Into>, R: IsA>(parent: Q, flags: DialogFlags, file: &R) -> AppChooserDialog { - // unsafe { TODO: call ffi::gtk_app_chooser_dialog_new() } - //} + pub fn new, Q: IsA>( + parent: Option<&P>, + flags: DialogFlags, + file: &Q, + ) -> AppChooserDialog { + assert_initialized_main_thread!(); + unsafe { + Widget::from_glib_none(gtk_sys::gtk_app_chooser_dialog_new( + parent.map(|p| p.as_ref()).to_glib_none().0, + flags.to_glib(), + file.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } - pub fn new_for_content_type<'a, P: IsA + 'a, Q: Into>>(parent: Q, flags: DialogFlags, content_type: &str) -> AppChooserDialog { + pub fn new_for_content_type>( + parent: Option<&P>, + flags: DialogFlags, + content_type: &str, + ) -> AppChooserDialog { assert_initialized_main_thread!(); - let parent = parent.into(); - let parent = parent.to_glib_none(); unsafe { - Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new_for_content_type(parent.0, flags.to_glib(), content_type.to_glib_none().0)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_app_chooser_dialog_new_for_content_type( + parent.map(|p| p.as_ref()).to_glib_none().0, + flags.to_glib(), + content_type.to_glib_none().0, + )) + .unsafe_cast() } } } -pub trait AppChooserDialogExt { - fn get_heading(&self) -> Option; +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_width: Option, + deletable: Option, + destroy_with_parent: Option, + focus_on_map: Option, + focus_visible: Option, + gravity: Option, + hide_titlebar_when_maximized: Option, + icon: Option, + icon_name: Option, + mnemonics_visible: Option, + modal: Option, + resizable: Option, + role: Option, + screen: Option, + skip_pager_hint: Option, + skip_taskbar_hint: Option, + startup_id: Option, + title: Option, + transient_for: Option, + type_: Option, + type_hint: Option, + urgency_hint: Option, + window_position: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl AppChooserDialogBuilder { + pub fn new() -> Self { + Self { + gfile: None, + heading: None, + use_header_bar: None, + accept_focus: None, + application: None, + attached_to: None, + decorated: None, + default_height: None, + default_width: None, + deletable: None, + destroy_with_parent: None, + focus_on_map: None, + focus_visible: None, + gravity: None, + hide_titlebar_when_maximized: None, + icon: None, + icon_name: None, + mnemonics_visible: None, + modal: None, + resizable: None, + role: None, + screen: None, + skip_pager_hint: None, + skip_taskbar_hint: None, + startup_id: None, + title: None, + transient_for: None, + type_: None, + type_hint: None, + urgency_hint: None, + window_position: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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_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 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 gravity) = self.gravity { + properties.push(("gravity", gravity)); + } + if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized { + properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized)); + } + if let Some(ref icon) = self.icon { + properties.push(("icon", icon)); + } + 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 role) = self.role { + properties.push(("role", role)); + } + if let Some(ref screen) = self.screen { + properties.push(("screen", screen)); + } + if let Some(ref skip_pager_hint) = self.skip_pager_hint { + properties.push(("skip-pager-hint", skip_pager_hint)); + } + if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint { + properties.push(("skip-taskbar-hint", skip_taskbar_hint)); + } + 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 urgency_hint) = self.urgency_hint { + properties.push(("urgency-hint", urgency_hint)); + } + if let Some(ref window_position) = self.window_position { + properties.push(("window-position", window_position)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(AppChooserDialog::static_type(), &properties) + .expect("object new") + .downcast() + .expect("downcast") + } + + pub fn gfile(mut self, gfile: &gio::File) -> Self { + self.gfile = Some(gfile.clone()); + 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: &Application) -> Self { + self.application = Some(application.clone()); + self + } + + pub fn attached_to(mut self, attached_to: &Widget) -> Self { + self.attached_to = Some(attached_to.clone()); + 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_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 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 gravity(mut self, gravity: gdk::Gravity) -> Self { + self.gravity = Some(gravity); + self + } + + pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self { + self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized); + self + } + + pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self { + self.icon = Some(icon.clone()); + 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 role(mut self, role: &str) -> Self { + self.role = Some(role.to_string()); + self + } + + pub fn screen(mut self, screen: &gdk::Screen) -> Self { + self.screen = Some(screen.clone()); + self + } + + pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self { + self.skip_pager_hint = Some(skip_pager_hint); + self + } + + pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self { + self.skip_taskbar_hint = Some(skip_taskbar_hint); + 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: &Window) -> Self { + self.transient_for = Some(transient_for.clone()); + self + } + + pub fn type_(mut self, type_: WindowType) -> Self { + self.type_ = Some(type_); + self + } + + pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self { + self.type_hint = Some(type_hint); + self + } + + pub fn urgency_hint(mut self, urgency_hint: bool) -> Self { + self.urgency_hint = Some(urgency_hint); + self + } + + pub fn window_position(mut self, window_position: WindowPosition) -> Self { + self.window_position = Some(window_position); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_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) -> /*Ignored*/Option; - - fn connect_property_gfile_notify(&self, f: F) -> SignalHandlerId; + fn get_property_gfile(&self) -> Option; fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA> AppChooserDialogExt for O { - fn get_heading(&self) -> Option { +impl> AppChooserDialogExt for O { + fn get_heading(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_app_chooser_dialog_get_heading(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_heading( + self.as_ref().to_glib_none().0, + )) } } fn get_widget(&self) -> Widget { unsafe { - from_glib_none(ffi::gtk_app_chooser_dialog_get_widget(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_widget( + self.as_ref().to_glib_none().0, + )) } } fn set_heading(&self, heading: &str) { unsafe { - ffi::gtk_app_chooser_dialog_set_heading(self.to_glib_none().0, heading.to_glib_none().0); + gtk_sys::gtk_app_chooser_dialog_set_heading( + self.as_ref().to_glib_none().0, + heading.to_glib_none().0, + ); } } - //fn get_property_gfile(&self) -> /*Ignored*/Option { - // let mut value = Value::from(None::<&/*Ignored*/gio::File>); - // unsafe { - // gobject_ffi::g_object_get_property(self.to_glib_none().0, "gfile".to_glib_none().0, value.to_glib_none_mut().0); - // } - // value.get() - //} - - fn connect_property_gfile_notify(&self, f: F) -> SignalHandlerId { + fn get_property_gfile(&self) -> Option { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::gfile", - transmute(notify_gfile_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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"gfile\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get() } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::heading", - transmute(notify_heading_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn notify_gfile_trampoline

(this: *mut ffi::GtkAppChooserDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserDialog::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_heading_trampoline

(this: *mut ffi::GtkAppChooserDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserDialog::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for AppChooserDialog { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AppChooserDialog") + } } diff --git a/src/auto/app_chooser_widget.rs b/src/auto/app_chooser_widget.rs index 39004c0f07..35b0deb060 100644 --- a/src/auto/app_chooser_widget.rs +++ b/src/auto/app_chooser_widget.rs @@ -1,34 +1,39 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// 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::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 AppChooser; +use BaselinePosition; use Box; use Buildable; use Container; use Menu; use Orientable; +use ResizeMode; use Widget; -use ffi; -use gio; -use gio_ffi; -use glib; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; glib_wrapper! { - pub struct AppChooserWidget(Object): Box, Container, Widget, Buildable, Orientable, AppChooser; + pub struct AppChooserWidget(Object) @extends Box, Container, Widget, @implements Buildable, Orientable, AppChooser; match fn { - get_type => || ffi::gtk_app_chooser_widget_get_type(), + get_type => || gtk_sys::gtk_app_chooser_widget_get_type(), } } @@ -36,13 +41,483 @@ impl AppChooserWidget { pub fn new(content_type: &str) -> AppChooserWidget { assert_initialized_main_thread!(); unsafe { - Widget::from_glib_none(ffi::gtk_app_chooser_widget_new(content_type.to_glib_none().0)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_app_chooser_widget_new( + content_type.to_glib_none().0, + )) + .unsafe_cast() } } } -pub trait AppChooserWidgetExt { - fn get_default_text(&self) -> Option; +pub struct AppChooserWidgetBuilder { + default_text: Option, + show_all: Option, + show_default: Option, + show_fallback: Option, + show_other: Option, + show_recommended: Option, + baseline_position: Option, + homogeneous: Option, + spacing: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl AppChooserWidgetBuilder { + pub fn new() -> Self { + Self { + default_text: None, + show_all: None, + show_default: None, + show_fallback: None, + show_other: None, + show_recommended: None, + baseline_position: None, + homogeneous: None, + spacing: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 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 border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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 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 border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_APP_CHOOSER_WIDGET: Option<&AppChooserWidget> = None; + +pub trait AppChooserWidgetExt: 'static { + fn get_default_text(&self) -> Option; fn get_show_all(&self) -> bool; @@ -66,230 +541,399 @@ pub trait AppChooserWidgetExt { fn set_show_recommended(&self, setting: bool); - fn connect_application_activated(&self, f: F) -> SignalHandlerId; + fn connect_application_activated( + &self, + f: F, + ) -> SignalHandlerId; - fn connect_application_selected(&self, f: F) -> SignalHandlerId; + fn connect_application_selected( + &self, + f: F, + ) -> SignalHandlerId; - fn connect_populate_popup(&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_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_default_notify(&self, f: F) + -> SignalHandlerId; - fn connect_property_show_fallback_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; + fn connect_property_show_recommended_notify( + &self, + f: F, + ) -> SignalHandlerId; } -impl + IsA> AppChooserWidgetExt for O { - fn get_default_text(&self) -> Option { +impl> AppChooserWidgetExt for O { + fn get_default_text(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_app_chooser_widget_get_default_text(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_app_chooser_widget_get_default_text( + self.as_ref().to_glib_none().0, + )) } } fn get_show_all(&self) -> bool { unsafe { - from_glib(ffi::gtk_app_chooser_widget_get_show_all(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_all( + self.as_ref().to_glib_none().0, + )) } } fn get_show_default(&self) -> bool { unsafe { - from_glib(ffi::gtk_app_chooser_widget_get_show_default(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_default( + self.as_ref().to_glib_none().0, + )) } } fn get_show_fallback(&self) -> bool { unsafe { - from_glib(ffi::gtk_app_chooser_widget_get_show_fallback(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_fallback( + self.as_ref().to_glib_none().0, + )) } } fn get_show_other(&self) -> bool { unsafe { - from_glib(ffi::gtk_app_chooser_widget_get_show_other(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_other( + self.as_ref().to_glib_none().0, + )) } } fn get_show_recommended(&self) -> bool { unsafe { - from_glib(ffi::gtk_app_chooser_widget_get_show_recommended(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_recommended( + self.as_ref().to_glib_none().0, + )) } } fn set_default_text(&self, text: &str) { unsafe { - ffi::gtk_app_chooser_widget_set_default_text(self.to_glib_none().0, text.to_glib_none().0); + gtk_sys::gtk_app_chooser_widget_set_default_text( + self.as_ref().to_glib_none().0, + text.to_glib_none().0, + ); } } fn set_show_all(&self, setting: bool) { unsafe { - ffi::gtk_app_chooser_widget_set_show_all(self.to_glib_none().0, setting.to_glib()); + gtk_sys::gtk_app_chooser_widget_set_show_all( + self.as_ref().to_glib_none().0, + setting.to_glib(), + ); } } fn set_show_default(&self, setting: bool) { unsafe { - ffi::gtk_app_chooser_widget_set_show_default(self.to_glib_none().0, setting.to_glib()); + gtk_sys::gtk_app_chooser_widget_set_show_default( + self.as_ref().to_glib_none().0, + setting.to_glib(), + ); } } fn set_show_fallback(&self, setting: bool) { unsafe { - ffi::gtk_app_chooser_widget_set_show_fallback(self.to_glib_none().0, setting.to_glib()); + gtk_sys::gtk_app_chooser_widget_set_show_fallback( + self.as_ref().to_glib_none().0, + setting.to_glib(), + ); } } fn set_show_other(&self, setting: bool) { unsafe { - ffi::gtk_app_chooser_widget_set_show_other(self.to_glib_none().0, setting.to_glib()); + gtk_sys::gtk_app_chooser_widget_set_show_other( + self.as_ref().to_glib_none().0, + setting.to_glib(), + ); } } fn set_show_recommended(&self, setting: bool) { unsafe { - ffi::gtk_app_chooser_widget_set_show_recommended(self.to_glib_none().0, setting.to_glib()); + gtk_sys::gtk_app_chooser_widget_set_show_recommended( + self.as_ref().to_glib_none().0, + setting.to_glib(), + ); } } - fn connect_application_activated(&self, f: F) -> SignalHandlerId { + fn connect_application_activated( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn application_activated_trampoline< + P, + F: Fn(&P, &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), + ) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "application-activated", - transmute(application_activated_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_application_selected(&self, f: F) -> SignalHandlerId { + fn connect_application_selected( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn application_selected_trampoline< + P, + F: Fn(&P, &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), + ) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "application-selected", - transmute(application_selected_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_populate_popup(&self, f: F) -> SignalHandlerId { + 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(Box_::new(f)); - connect(self.to_glib_none().0, "populate-popup", - transmute(populate_popup_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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(&self, f: F) -> SignalHandlerId { + fn connect_property_default_text_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::default-text", - transmute(notify_default_text_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-all", - transmute(notify_show_all_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_show_default_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_show_default_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-default", - transmute(notify_show_default_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } - fn connect_property_show_fallback_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_show_fallback_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-fallback", - transmute(notify_show_fallback_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-other", - transmute(notify_show_other_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_show_recommended_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_show_recommended_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_recommended_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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-recommended", - transmute(notify_show_recommended_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn application_activated_trampoline

(this: *mut ffi::GtkAppChooserWidget, application: *mut gio_ffi::GAppInfo, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &gio::AppInfo) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(application)) -} - -unsafe extern "C" fn application_selected_trampoline

(this: *mut ffi::GtkAppChooserWidget, application: *mut gio_ffi::GAppInfo, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &gio::AppInfo) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(application)) -} - -unsafe extern "C" fn populate_popup_trampoline

(this: *mut ffi::GtkAppChooserWidget, menu: *mut ffi::GtkMenu, application: *mut gio_ffi::GAppInfo, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &Menu, &gio::AppInfo) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(menu), &from_glib_borrow(application)) -} - -unsafe extern "C" fn notify_default_text_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_show_all_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_show_default_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_show_fallback_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_show_other_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_show_recommended_trampoline

(this: *mut ffi::GtkAppChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AppChooserWidget::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for AppChooserWidget { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AppChooserWidget") + } } diff --git a/src/auto/application.rs b/src/auto/application.rs index 58635cd2ed..de1b590c9b 100644 --- a/src/auto/application.rs +++ b/src/auto/application.rs @@ -1,355 +1,584 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ApplicationInhibitFlags; -use Window; -use ffi; use gio; -use gio_ffi; -use glib; -use glib::Value; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +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::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use ApplicationInhibitFlags; +use Window; glib_wrapper! { - pub struct Application(Object): [ - gio::Application => gio_ffi::GApplication, - gio::ActionGroup => gio_ffi::GActionGroup, - gio::ActionMap => gio_ffi::GActionMap, - ]; + pub struct Application(Object) @extends gio::Application, @implements gio::ActionGroup, gio::ActionMap; match fn { - get_type => || ffi::gtk_application_get_type(), + get_type => || gtk_sys::gtk_application_get_type(), + } +} + +pub struct ApplicationBuilder { + app_menu: Option, + menubar: Option, + register_session: Option, + action_group: Option, + application_id: Option, + flags: Option, + inactivity_timeout: Option, + resource_base_path: Option, +} + +impl ApplicationBuilder { + pub fn new() -> Self { + Self { + app_menu: None, + menubar: None, + register_session: None, + action_group: None, + application_id: None, + flags: None, + inactivity_timeout: None, + resource_base_path: None, + } + } + + pub fn build(self) -> Application { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref app_menu) = self.app_menu { + properties.push(("app-menu", app_menu)); + } + if let Some(ref menubar) = self.menubar { + properties.push(("menubar", menubar)); + } + if let Some(ref register_session) = self.register_session { + properties.push(("register-session", register_session)); + } + if let Some(ref action_group) = self.action_group { + properties.push(("action-group", action_group)); + } + if let Some(ref application_id) = self.application_id { + properties.push(("application-id", application_id)); + } + if let Some(ref flags) = self.flags { + properties.push(("flags", flags)); + } + if let Some(ref inactivity_timeout) = self.inactivity_timeout { + properties.push(("inactivity-timeout", inactivity_timeout)); + } + if let Some(ref resource_base_path) = self.resource_base_path { + properties.push(("resource-base-path", resource_base_path)); + } + glib::Object::new(Application::static_type(), &properties) + .expect("object new") + .downcast() + .expect("downcast") + } + + pub fn app_menu(mut self, app_menu: &gio::MenuModel) -> Self { + self.app_menu = Some(app_menu.clone()); + self + } + + pub fn menubar(mut self, menubar: &gio::MenuModel) -> Self { + self.menubar = Some(menubar.clone()); + self + } + + pub fn register_session(mut self, register_session: bool) -> Self { + self.register_session = Some(register_session); + self + } + + pub fn action_group(mut self, action_group: &gio::ActionGroup) -> Self { + self.action_group = Some(action_group.clone()); + self + } + + pub fn application_id(mut self, application_id: &str) -> Self { + self.application_id = Some(application_id.to_string()); + self + } + + pub fn flags(mut self, flags: gio::ApplicationFlags) -> Self { + self.flags = Some(flags); + self + } + + pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self { + self.inactivity_timeout = Some(inactivity_timeout); + self + } + + pub fn resource_base_path(mut self, resource_base_path: &str) -> Self { + self.resource_base_path = Some(resource_base_path.to_string()); + self } } -pub trait GtkApplicationExt { - fn add_accelerator<'a, P: Into>>(&self, accelerator: &str, action_name: &str, parameter: P); +pub const NONE_APPLICATION: Option<&Application> = None; +pub trait GtkApplicationExt: 'static { fn add_window>(&self, window: &P); - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec; + fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec; - #[cfg(any(feature = "v3_14", feature = "dox"))] - fn get_actions_for_accel(&self, accel: &str) -> Vec; + fn get_actions_for_accel(&self, accel: &str) -> Vec; - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_active_window(&self) -> Option; fn get_app_menu(&self) -> Option; - #[cfg(any(feature = "v3_14", feature = "dox"))] fn get_menu_by_id(&self, id: &str) -> Option; fn get_menubar(&self) -> Option; - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_window_by_id(&self, id: u32) -> Option; fn get_windows(&self) -> Vec; - fn inhibit<'a, 'b, P: IsA + 'a, Q: Into>, R: Into>>(&self, window: Q, flags: ApplicationInhibitFlags, reason: R) -> u32; + fn inhibit>( + &self, + window: Option<&P>, + flags: ApplicationInhibitFlags, + reason: Option<&str>, + ) -> u32; fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool; - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn list_action_descriptions(&self) -> Vec; + fn list_action_descriptions(&self) -> Vec; - #[cfg(any(feature = "v3_14", feature = "dox"))] fn prefers_app_menu(&self) -> bool; - fn remove_accelerator<'a, P: Into>>(&self, action_name: &str, parameter: P); - fn remove_window>(&self, window: &P); - #[cfg(any(feature = "v3_12", feature = "dox"))] fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]); - fn set_app_menu<'a, P: IsA + 'a, Q: Into>>(&self, app_menu: Q); + fn set_app_menu>(&self, app_menu: Option<&P>); - fn set_menubar<'a, P: IsA + 'a, Q: Into>>(&self, menubar: Q); + fn set_menubar>(&self, menubar: Option<&P>); fn uninhibit(&self, cookie: u32); - fn get_property_active_window(&self) -> Option; - fn get_property_register_session(&self) -> bool; fn set_property_register_session(&self, register_session: bool); + #[cfg(any(feature = "v3_24", feature = "dox"))] + fn get_property_screensaver_active(&self) -> bool; + fn connect_window_added(&self, f: F) -> SignalHandlerId; fn connect_window_removed(&self, f: F) -> SignalHandlerId; - fn connect_property_active_window_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_active_window_notify( + &self, + 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(&self, f: F) -> SignalHandlerId; -} + fn connect_property_register_session_notify( + &self, + f: F, + ) -> SignalHandlerId; -impl + IsA> GtkApplicationExt for O { - fn add_accelerator<'a, P: Into>>(&self, accelerator: &str, action_name: &str, parameter: P) { - let parameter = parameter.into(); - let parameter = parameter.to_glib_none(); - unsafe { - ffi::gtk_application_add_accelerator(self.to_glib_none().0, accelerator.to_glib_none().0, action_name.to_glib_none().0, parameter.0); - } - } + #[cfg(any(feature = "v3_24", feature = "dox"))] + fn connect_property_screensaver_active_notify( + &self, + f: F, + ) -> SignalHandlerId; +} +impl> GtkApplicationExt for O { fn add_window>(&self, window: &P) { unsafe { - ffi::gtk_application_add_window(self.to_glib_none().0, window.to_glib_none().0); + gtk_sys::gtk_application_add_window( + self.as_ref().to_glib_none().0, + window.as_ref().to_glib_none().0, + ); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec { + fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gtk_application_get_accels_for_action(self.to_glib_none().0, detailed_action_name.to_glib_none().0)) + FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_get_accels_for_action( + self.as_ref().to_glib_none().0, + detailed_action_name.to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_14", feature = "dox"))] - fn get_actions_for_accel(&self, accel: &str) -> Vec { + fn get_actions_for_accel(&self, accel: &str) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gtk_application_get_actions_for_accel(self.to_glib_none().0, accel.to_glib_none().0)) + FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_get_actions_for_accel( + self.as_ref().to_glib_none().0, + accel.to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_active_window(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_application_get_active_window(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_application_get_active_window( + self.as_ref().to_glib_none().0, + )) } } fn get_app_menu(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_application_get_app_menu(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_application_get_app_menu( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_14", feature = "dox"))] fn get_menu_by_id(&self, id: &str) -> Option { unsafe { - from_glib_none(ffi::gtk_application_get_menu_by_id(self.to_glib_none().0, id.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_application_get_menu_by_id( + self.as_ref().to_glib_none().0, + id.to_glib_none().0, + )) } } fn get_menubar(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_application_get_menubar(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_application_get_menubar( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_window_by_id(&self, id: u32) -> Option { unsafe { - from_glib_none(ffi::gtk_application_get_window_by_id(self.to_glib_none().0, id)) + from_glib_none(gtk_sys::gtk_application_get_window_by_id( + self.as_ref().to_glib_none().0, + id, + )) } } fn get_windows(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_none(ffi::gtk_application_get_windows(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_application_get_windows( + self.as_ref().to_glib_none().0, + )) } } - fn inhibit<'a, 'b, P: IsA + 'a, Q: Into>, R: Into>>(&self, window: Q, flags: ApplicationInhibitFlags, reason: R) -> u32 { - let window = window.into(); - let window = window.to_glib_none(); - let reason = reason.into(); - let reason = reason.to_glib_none(); + fn inhibit>( + &self, + window: Option<&P>, + flags: ApplicationInhibitFlags, + reason: Option<&str>, + ) -> u32 { unsafe { - ffi::gtk_application_inhibit(self.to_glib_none().0, window.0, flags.to_glib(), reason.0) + gtk_sys::gtk_application_inhibit( + self.as_ref().to_glib_none().0, + window.map(|p| p.as_ref()).to_glib_none().0, + flags.to_glib(), + reason.to_glib_none().0, + ) } } fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool { unsafe { - from_glib(ffi::gtk_application_is_inhibited(self.to_glib_none().0, flags.to_glib())) + from_glib(gtk_sys::gtk_application_is_inhibited( + self.as_ref().to_glib_none().0, + flags.to_glib(), + )) } } - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn list_action_descriptions(&self) -> Vec { + fn list_action_descriptions(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gtk_application_list_action_descriptions(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_list_action_descriptions( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_14", feature = "dox"))] fn prefers_app_menu(&self) -> bool { unsafe { - from_glib(ffi::gtk_application_prefers_app_menu(self.to_glib_none().0)) - } - } - - fn remove_accelerator<'a, P: Into>>(&self, action_name: &str, parameter: P) { - let parameter = parameter.into(); - let parameter = parameter.to_glib_none(); - unsafe { - ffi::gtk_application_remove_accelerator(self.to_glib_none().0, action_name.to_glib_none().0, parameter.0); + from_glib(gtk_sys::gtk_application_prefers_app_menu( + self.as_ref().to_glib_none().0, + )) } } fn remove_window>(&self, window: &P) { unsafe { - ffi::gtk_application_remove_window(self.to_glib_none().0, window.to_glib_none().0); + gtk_sys::gtk_application_remove_window( + self.as_ref().to_glib_none().0, + window.as_ref().to_glib_none().0, + ); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]) { unsafe { - ffi::gtk_application_set_accels_for_action(self.to_glib_none().0, detailed_action_name.to_glib_none().0, accels.to_glib_none().0); + gtk_sys::gtk_application_set_accels_for_action( + self.as_ref().to_glib_none().0, + detailed_action_name.to_glib_none().0, + accels.to_glib_none().0, + ); } } - fn set_app_menu<'a, P: IsA + 'a, Q: Into>>(&self, app_menu: Q) { - let app_menu = app_menu.into(); - let app_menu = app_menu.to_glib_none(); + fn set_app_menu>(&self, app_menu: Option<&P>) { unsafe { - ffi::gtk_application_set_app_menu(self.to_glib_none().0, app_menu.0); + 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<'a, P: IsA + 'a, Q: Into>>(&self, menubar: Q) { - let menubar = menubar.into(); - let menubar = menubar.to_glib_none(); + fn set_menubar>(&self, menubar: Option<&P>) { unsafe { - ffi::gtk_application_set_menubar(self.to_glib_none().0, menubar.0); + gtk_sys::gtk_application_set_menubar( + self.as_ref().to_glib_none().0, + menubar.map(|p| p.as_ref()).to_glib_none().0, + ); } } fn uninhibit(&self, cookie: u32) { unsafe { - ffi::gtk_application_uninhibit(self.to_glib_none().0, cookie); + gtk_sys::gtk_application_uninhibit(self.as_ref().to_glib_none().0, cookie); } } - fn get_property_active_window(&self) -> Option { - let mut value = Value::from(None::<&Window>); + fn get_property_register_session(&self) -> bool { unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "active-window".to_glib_none().0, value.to_glib_none_mut().0); + 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"register-session\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get() } - fn get_property_register_session(&self) -> bool { - let mut value = Value::from(&false); + fn set_property_register_session(&self, register_session: bool) { unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "register-session".to_glib_none().0, value.to_glib_none_mut().0); + gobject_sys::g_object_set_property( + self.to_glib_none().0 as *mut gobject_sys::GObject, + b"register-session\0".as_ptr() as *const _, + Value::from(®ister_session).to_glib_none().0, + ); } - value.get().unwrap() } - fn set_property_register_session(&self, register_session: bool) { + #[cfg(any(feature = "v3_24", feature = "dox"))] + fn get_property_screensaver_active(&self) -> bool { unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "register-session".to_glib_none().0, Value::from(®ister_session).to_glib_none().0); + 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"screensaver-active\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } } fn connect_window_added(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn window_added_trampoline( + this: *mut gtk_sys::GtkApplication, + window: *mut gtk_sys::GtkWindow, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f( + &Application::from_glib_borrow(this).unsafe_cast(), + &from_glib_borrow(window), + ) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "window-added", - transmute(window_added_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"window-added\0".as_ptr() as *const _, + Some(transmute(window_added_trampoline:: as usize)), + Box_::into_raw(f), + ) } } fn connect_window_removed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn window_removed_trampoline( + this: *mut gtk_sys::GtkApplication, + window: *mut gtk_sys::GtkWindow, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f( + &Application::from_glib_borrow(this).unsafe_cast(), + &from_glib_borrow(window), + ) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "window-removed", - transmute(window_removed_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"window-removed\0".as_ptr() as *const _, + Some(transmute(window_removed_trampoline:: as usize)), + Box_::into_raw(f), + ) } } - fn connect_property_active_window_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_active_window_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_active_window_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(Box_::new(f)); - connect(self.to_glib_none().0, "notify::active-window", - transmute(notify_active_window_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + 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(Box_::new(f)); - connect(self.to_glib_none().0, "notify::app-menu", - transmute(notify_app_menu_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + _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(Box_::new(f)); - connect(self.to_glib_none().0, "notify::menubar", - transmute(notify_menubar_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } - fn connect_property_register_session_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_register_session_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_register_session_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(Box_::new(f)); - connect(self.to_glib_none().0, "notify::register-session", - transmute(notify_register_session_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } -} - -unsafe extern "C" fn window_added_trampoline

(this: *mut ffi::GtkApplication, window: *mut ffi::GtkWindow, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &Window) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(window)) -} - -unsafe extern "C" fn window_removed_trampoline

(this: *mut ffi::GtkApplication, window: *mut ffi::GtkWindow, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &Window) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(window)) -} -unsafe extern "C" fn notify_active_window_trampoline

(this: *mut ffi::GtkApplication, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_app_menu_trampoline

(this: *mut ffi::GtkApplication, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_menubar_trampoline

(this: *mut ffi::GtkApplication, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked()) + #[cfg(any(feature = "v3_24", feature = "dox"))] + fn connect_property_screensaver_active_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_screensaver_active_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::screensaver-active\0".as_ptr() as *const _, + Some(transmute( + notify_screensaver_active_trampoline:: as usize, + )), + Box_::into_raw(f), + ) + } + } } -unsafe extern "C" fn notify_register_session_trampoline

(this: *mut ffi::GtkApplication, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Application::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for Application { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Application") + } } diff --git a/src/auto/application_window.rs b/src/auto/application_window.rs index 808c043005..6b34f391d7 100644 --- a/src/auto/application_window.rs +++ b/src/auto/application_window.rs @@ -1,120 +1,798 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use gdk; +use gdk_pixbuf; +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 Application; use Bin; use Buildable; use Container; +use ResizeMode; #[cfg(any(feature = "v3_20", feature = "dox"))] use ShortcutsWindow; use Widget; use Window; -use ffi; -use gio; -use gio_ffi; -use glib; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; +use WindowPosition; +use WindowType; glib_wrapper! { - pub struct ApplicationWindow(Object): [ - Window, - Bin, - Container, - Widget, - Buildable, - gio::ActionGroup => gio_ffi::GActionGroup, - gio::ActionMap => gio_ffi::GActionMap, - ]; + pub struct ApplicationWindow(Object) @extends Window, Bin, Container, Widget, @implements Buildable, gio::ActionGroup, gio::ActionMap; match fn { - get_type => || ffi::gtk_application_window_get_type(), + get_type => || gtk_sys::gtk_application_window_get_type(), } } -impl ApplicationWindow { - pub fn new(application: &Application) -> ApplicationWindow { - skip_assert_initialized!(); - unsafe { - Widget::from_glib_none(ffi::gtk_application_window_new(application.to_glib_none().0)).downcast_unchecked() +pub struct ApplicationWindowBuilder { + show_menubar: Option, + accept_focus: Option, + application: Option, + attached_to: Option, + decorated: Option, + default_height: Option, + default_width: Option, + deletable: Option, + destroy_with_parent: Option, + focus_on_map: Option, + focus_visible: Option, + gravity: Option, + hide_titlebar_when_maximized: Option, + icon: Option, + icon_name: Option, + mnemonics_visible: Option, + modal: Option, + resizable: Option, + role: Option, + screen: Option, + skip_pager_hint: Option, + skip_taskbar_hint: Option, + startup_id: Option, + title: Option, + transient_for: Option, + type_: Option, + type_hint: Option, + urgency_hint: Option, + window_position: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl ApplicationWindowBuilder { + pub fn new() -> Self { + Self { + show_menubar: None, + accept_focus: None, + application: None, + attached_to: None, + decorated: None, + default_height: None, + default_width: None, + deletable: None, + destroy_with_parent: None, + focus_on_map: None, + focus_visible: None, + gravity: None, + hide_titlebar_when_maximized: None, + icon: None, + icon_name: None, + mnemonics_visible: None, + modal: None, + resizable: None, + role: None, + screen: None, + skip_pager_hint: None, + skip_taskbar_hint: None, + startup_id: None, + title: None, + transient_for: None, + type_: None, + type_hint: None, + urgency_hint: None, + window_position: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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_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 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 gravity) = self.gravity { + properties.push(("gravity", gravity)); + } + if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized { + properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized)); + } + if let Some(ref icon) = self.icon { + properties.push(("icon", icon)); + } + 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 role) = self.role { + properties.push(("role", role)); + } + if let Some(ref screen) = self.screen { + properties.push(("screen", screen)); + } + if let Some(ref skip_pager_hint) = self.skip_pager_hint { + properties.push(("skip-pager-hint", skip_pager_hint)); + } + if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint { + properties.push(("skip-taskbar-hint", skip_taskbar_hint)); + } + 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 urgency_hint) = self.urgency_hint { + properties.push(("urgency-hint", urgency_hint)); + } + if let Some(ref window_position) = self.window_position { + properties.push(("window-position", window_position)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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: &Application) -> Self { + self.application = Some(application.clone()); + self + } + + pub fn attached_to(mut self, attached_to: &Widget) -> Self { + self.attached_to = Some(attached_to.clone()); + 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_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 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 gravity(mut self, gravity: gdk::Gravity) -> Self { + self.gravity = Some(gravity); + self + } + + pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self { + self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized); + self + } + + pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self { + self.icon = Some(icon.clone()); + 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 role(mut self, role: &str) -> Self { + self.role = Some(role.to_string()); + self + } + + pub fn screen(mut self, screen: &gdk::Screen) -> Self { + self.screen = Some(screen.clone()); + self + } + + pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self { + self.skip_pager_hint = Some(skip_pager_hint); + self + } + + pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self { + self.skip_taskbar_hint = Some(skip_taskbar_hint); + 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: &Window) -> Self { + self.transient_for = Some(transient_for.clone()); + self + } + + pub fn type_(mut self, type_: WindowType) -> Self { + self.type_ = Some(type_); + self + } + + pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self { + self.type_hint = Some(type_hint); + self + } + + pub fn urgency_hint(mut self, urgency_hint: bool) -> Self { + self.urgency_hint = Some(urgency_hint); + self + } + + pub fn window_position(mut self, window_position: WindowPosition) -> Self { + self.window_position = Some(window_position); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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 trait ApplicationWindowExt { +pub const NONE_APPLICATION_WINDOW: Option<&ApplicationWindow> = None; + +pub trait ApplicationWindowExt: 'static { #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_help_overlay(&self) -> Option; - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_id(&self) -> u32; fn get_show_menubar(&self) -> bool; #[cfg(any(feature = "v3_20", feature = "dox"))] - fn set_help_overlay<'a, P: Into>>(&self, help_overlay: P); + fn set_help_overlay>(&self, help_overlay: Option<&P>); fn set_show_menubar(&self, show_menubar: bool); - fn connect_property_show_menubar_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_show_menubar_notify(&self, f: F) + -> SignalHandlerId; } -impl + IsA> ApplicationWindowExt for O { +impl> ApplicationWindowExt for O { #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_help_overlay(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_application_window_get_help_overlay(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_application_window_get_help_overlay( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_id(&self) -> u32 { - unsafe { - ffi::gtk_application_window_get_id(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_application_window_get_id(self.as_ref().to_glib_none().0) } } fn get_show_menubar(&self) -> bool { unsafe { - from_glib(ffi::gtk_application_window_get_show_menubar(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_application_window_get_show_menubar( + self.as_ref().to_glib_none().0, + )) } } #[cfg(any(feature = "v3_20", feature = "dox"))] - fn set_help_overlay<'a, P: Into>>(&self, help_overlay: P) { - let help_overlay = help_overlay.into(); - let help_overlay = help_overlay.to_glib_none(); + fn set_help_overlay>(&self, help_overlay: Option<&P>) { unsafe { - ffi::gtk_application_window_set_help_overlay(self.to_glib_none().0, help_overlay.0); + 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, + ); } } fn set_show_menubar(&self, show_menubar: bool) { unsafe { - ffi::gtk_application_window_set_show_menubar(self.to_glib_none().0, show_menubar.to_glib()); + gtk_sys::gtk_application_window_set_show_menubar( + self.as_ref().to_glib_none().0, + show_menubar.to_glib(), + ); } } - fn connect_property_show_menubar_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_show_menubar_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_menubar_trampoline( + this: *mut gtk_sys::GtkApplicationWindow, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::show-menubar", - transmute(notify_show_menubar_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn notify_show_menubar_trampoline

(this: *mut ffi::GtkApplicationWindow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&ApplicationWindow::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for ApplicationWindow { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ApplicationWindow") + } } diff --git a/src/auto/arrow.rs b/src/auto/arrow.rs deleted file mode 100644 index 01c066f7ad..0000000000 --- a/src/auto/arrow.rs +++ /dev/null @@ -1,123 +0,0 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) -// DO NOT EDIT - -use ArrowType; -use Buildable; -use Misc; -use ShadowType; -use Widget; -use ffi; -use glib; -use glib::Value; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; - -glib_wrapper! { - pub struct Arrow(Object): Misc, Widget, Buildable; - - match fn { - get_type => || ffi::gtk_arrow_get_type(), - } -} - -impl Arrow { - pub fn new(arrow_type: ArrowType, shadow_type: ShadowType) -> Arrow { - assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_arrow_new(arrow_type.to_glib(), shadow_type.to_glib())).downcast_unchecked() - } - } -} - -pub trait ArrowExt { - fn set(&self, arrow_type: ArrowType, shadow_type: ShadowType); - - fn get_property_arrow_type(&self) -> ArrowType; - - fn set_property_arrow_type(&self, arrow_type: ArrowType); - - fn get_property_shadow_type(&self) -> ShadowType; - - fn set_property_shadow_type(&self, shadow_type: ShadowType); - - fn connect_property_arrow_type_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_shadow_type_notify(&self, f: F) -> SignalHandlerId; -} - -impl + IsA> ArrowExt for O { - fn set(&self, arrow_type: ArrowType, shadow_type: ShadowType) { - unsafe { - ffi::gtk_arrow_set(self.to_glib_none().0, arrow_type.to_glib(), shadow_type.to_glib()); - } - } - - fn get_property_arrow_type(&self) -> ArrowType { - let mut value = Value::from(&0); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "arrow-type".to_glib_none().0, value.to_glib_none_mut().0); - from_glib(transmute(value.get::().unwrap())) - } - } - - fn set_property_arrow_type(&self, arrow_type: ArrowType) { - let arrow_type = arrow_type.to_glib() as i32; - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "arrow-type".to_glib_none().0, Value::from(&arrow_type).to_glib_none().0); - } - } - - fn get_property_shadow_type(&self) -> ShadowType { - let mut value = Value::from(&0); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "shadow-type".to_glib_none().0, value.to_glib_none_mut().0); - from_glib(transmute(value.get::().unwrap())) - } - } - - fn set_property_shadow_type(&self, shadow_type: ShadowType) { - let shadow_type = shadow_type.to_glib() as i32; - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "shadow-type".to_glib_none().0, Value::from(&shadow_type).to_glib_none().0); - } - } - - fn connect_property_arrow_type_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::arrow-type", - transmute(notify_arrow_type_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } - - fn connect_property_shadow_type_notify(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::shadow-type", - transmute(notify_shadow_type_trampoline:: as usize), Box_::into_raw(f) as *mut _) - } - } -} - -unsafe extern "C" fn notify_arrow_type_trampoline

(this: *mut ffi::GtkArrow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Arrow::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_shadow_type_trampoline

(this: *mut ffi::GtkArrow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Arrow::from_glib_borrow(this).downcast_unchecked()) -} diff --git a/src/auto/aspect_frame.rs b/src/auto/aspect_frame.rs index 2be96dd3ed..533f13e2b3 100644 --- a/src/auto/aspect_frame.rs +++ b/src/auto/aspect_frame.rs @@ -1,46 +1,529 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use Bin; -use Buildable; -use Container; -use Frame; -use Widget; -use ffi; -use glib; -use glib::Value; -use glib::object::Downcast; +use gdk; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +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::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use Align; +use Bin; +use Buildable; +use Container; +use Frame; +use ResizeMode; +use ShadowType; +use Widget; glib_wrapper! { - pub struct AspectFrame(Object): Frame, Bin, Container, Widget, Buildable; + pub struct AspectFrame(Object) @extends Frame, Bin, Container, Widget, @implements Buildable; match fn { - get_type => || ffi::gtk_aspect_frame_get_type(), + get_type => || gtk_sys::gtk_aspect_frame_get_type(), } } impl AspectFrame { - pub fn new<'a, P: Into>>(label: P, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) -> AspectFrame { + pub fn new( + label: Option<&str>, + xalign: f32, + yalign: f32, + ratio: f32, + obey_child: bool, + ) -> AspectFrame { assert_initialized_main_thread!(); - let label = label.into(); - let label = label.to_glib_none(); unsafe { - Widget::from_glib_none(ffi::gtk_aspect_frame_new(label.0, xalign, yalign, ratio, obey_child.to_glib())).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_aspect_frame_new( + label.to_glib_none().0, + xalign, + yalign, + ratio, + obey_child.to_glib(), + )) + .unsafe_cast() + } + } +} + +pub struct AspectFrameBuilder { + obey_child: Option, + ratio: Option, + xalign: Option, + yalign: Option, + label: Option, + label_widget: Option, + label_xalign: Option, + label_yalign: Option, + shadow_type: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + 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 { + obey_child: None, + ratio: None, + xalign: None, + yalign: None, + label: None, + label_widget: None, + label_xalign: None, + label_yalign: None, + shadow_type: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 label_yalign) = self.label_yalign { + properties.push(("label-yalign", label_yalign)); + } + if let Some(ref shadow_type) = self.shadow_type { + properties.push(("shadow-type", shadow_type)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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 yalign(mut self, yalign: f32) -> Self { + self.yalign = Some(yalign); + self + } + + pub fn label(mut self, label: &str) -> Self { + self.label = Some(label.to_string()); + self + } + + pub fn label_widget(mut self, label_widget: &Widget) -> Self { + self.label_widget = Some(label_widget.clone()); + self + } + + pub fn label_xalign(mut self, label_xalign: f32) -> Self { + self.label_xalign = Some(label_xalign); + self + } + + pub fn label_yalign(mut self, label_yalign: f32) -> Self { + self.label_yalign = Some(label_yalign); + self + } + + pub fn shadow_type(mut self, shadow_type: ShadowType) -> Self { + self.shadow_type = Some(shadow_type); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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 trait AspectFrameExt { +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; @@ -68,126 +551,198 @@ pub trait AspectFrameExt { fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA> AspectFrameExt for O { +impl> AspectFrameExt for O { fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) { unsafe { - ffi::gtk_aspect_frame_set(self.to_glib_none().0, xalign, yalign, ratio, obey_child.to_glib()); + 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 { - let mut value = Value::from(&false); unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "obey-child".to_glib_none().0, value.to_glib_none_mut().0); + 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().unwrap() } - value.get().unwrap() } fn set_property_obey_child(&self, obey_child: bool) { unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "obey-child".to_glib_none().0, Value::from(&obey_child).to_glib_none().0); + 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, + ); } } fn get_property_ratio(&self) -> f32 { - let mut value = Value::from(&0f32); unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "ratio".to_glib_none().0, value.to_glib_none_mut().0); + 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().unwrap() } - value.get().unwrap() } fn set_property_ratio(&self, ratio: f32) { unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "ratio".to_glib_none().0, Value::from(&ratio).to_glib_none().0); + 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, + ); } } fn get_property_xalign(&self) -> f32 { - let mut value = Value::from(&0f32); unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "xalign".to_glib_none().0, value.to_glib_none_mut().0); + 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().unwrap() } - value.get().unwrap() } fn set_property_xalign(&self, xalign: f32) { unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "xalign".to_glib_none().0, Value::from(&xalign).to_glib_none().0); + 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, + ); } } fn get_property_yalign(&self) -> f32 { - let mut value = Value::from(&0f32); unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "yalign".to_glib_none().0, value.to_glib_none_mut().0); + 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().unwrap() } - value.get().unwrap() } fn set_property_yalign(&self, yalign: f32) { unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "yalign".to_glib_none().0, Value::from(&yalign).to_glib_none().0); + 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, + ); } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::obey-child", - transmute(notify_obey_child_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::ratio", - transmute(notify_ratio_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::xalign", - transmute(notify_xalign_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::yalign", - transmute(notify_yalign_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn notify_obey_child_trampoline

(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AspectFrame::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_ratio_trampoline

(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AspectFrame::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_xalign_trampoline

(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AspectFrame::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_yalign_trampoline

(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AspectFrame::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for AspectFrame { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AspectFrame") + } } diff --git a/src/auto/assistant.rs b/src/auto/assistant.rs index 7c1653a004..e4952b4b6c 100644 --- a/src/auto/assistant.rs +++ b/src/auto/assistant.rs @@ -1,41 +1,50 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use AssistantPageType; -use Bin; -use Buildable; -use Container; -use Widget; -use Window; -use ffi; +use gdk; +use gdk_pixbuf; use glib; -use glib::Value; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectExt; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +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::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use Align; +use Application; +use AssistantPageType; +use Bin; +use Buildable; +use Container; +use ResizeMode; +use Widget; +use Window; +use WindowPosition; +use WindowType; glib_wrapper! { - pub struct Assistant(Object): Window, Bin, Container, Widget, Buildable; + pub struct Assistant(Object) @extends Window, Bin, Container, Widget, @implements Buildable; match fn { - get_type => || ffi::gtk_assistant_get_type(), + get_type => || gtk_sys::gtk_assistant_get_type(), } } impl Assistant { pub fn new() -> Assistant { assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_assistant_new()).downcast_unchecked() - } + unsafe { Widget::from_glib_none(gtk_sys::gtk_assistant_new()).unsafe_cast() } } } @@ -45,7 +54,674 @@ impl Default for Assistant { } } -pub trait AssistantExt { +pub struct AssistantBuilder { + use_header_bar: Option, + accept_focus: Option, + application: Option, + attached_to: Option, + decorated: Option, + default_height: Option, + default_width: Option, + deletable: Option, + destroy_with_parent: Option, + focus_on_map: Option, + focus_visible: Option, + gravity: Option, + hide_titlebar_when_maximized: Option, + icon: Option, + icon_name: Option, + mnemonics_visible: Option, + modal: Option, + resizable: Option, + role: Option, + screen: Option, + skip_pager_hint: Option, + skip_taskbar_hint: Option, + startup_id: Option, + title: Option, + transient_for: Option, + type_: Option, + type_hint: Option, + urgency_hint: Option, + window_position: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl AssistantBuilder { + pub fn new() -> Self { + Self { + use_header_bar: None, + accept_focus: None, + application: None, + attached_to: None, + decorated: None, + default_height: None, + default_width: None, + deletable: None, + destroy_with_parent: None, + focus_on_map: None, + focus_visible: None, + gravity: None, + hide_titlebar_when_maximized: None, + icon: None, + icon_name: None, + mnemonics_visible: None, + modal: None, + resizable: None, + role: None, + screen: None, + skip_pager_hint: None, + skip_taskbar_hint: None, + startup_id: None, + title: None, + transient_for: None, + type_: None, + type_hint: None, + urgency_hint: None, + window_position: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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_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 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 gravity) = self.gravity { + properties.push(("gravity", gravity)); + } + if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized { + properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized)); + } + if let Some(ref icon) = self.icon { + properties.push(("icon", icon)); + } + 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 role) = self.role { + properties.push(("role", role)); + } + if let Some(ref screen) = self.screen { + properties.push(("screen", screen)); + } + if let Some(ref skip_pager_hint) = self.skip_pager_hint { + properties.push(("skip-pager-hint", skip_pager_hint)); + } + if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint { + properties.push(("skip-taskbar-hint", skip_taskbar_hint)); + } + 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 urgency_hint) = self.urgency_hint { + properties.push(("urgency-hint", urgency_hint)); + } + if let Some(ref window_position) = self.window_position { + properties.push(("window-position", window_position)); + } + if let Some(ref border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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: &Application) -> Self { + self.application = Some(application.clone()); + self + } + + pub fn attached_to(mut self, attached_to: &Widget) -> Self { + self.attached_to = Some(attached_to.clone()); + 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_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 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 gravity(mut self, gravity: gdk::Gravity) -> Self { + self.gravity = Some(gravity); + self + } + + pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self { + self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized); + self + } + + pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self { + self.icon = Some(icon.clone()); + 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 role(mut self, role: &str) -> Self { + self.role = Some(role.to_string()); + self + } + + pub fn screen(mut self, screen: &gdk::Screen) -> Self { + self.screen = Some(screen.clone()); + self + } + + pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self { + self.skip_pager_hint = Some(skip_pager_hint); + self + } + + pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self { + self.skip_taskbar_hint = Some(skip_taskbar_hint); + 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: &Window) -> Self { + self.transient_for = Some(transient_for.clone()); + self + } + + pub fn type_(mut self, type_: WindowType) -> Self { + self.type_ = Some(type_); + self + } + + pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self { + self.type_hint = Some(type_hint); + self + } + + pub fn urgency_hint(mut self, urgency_hint: bool) -> Self { + self.urgency_hint = Some(urgency_hint); + self + } + + pub fn window_position(mut self, window_position: WindowPosition) -> Self { + self.window_position = Some(window_position); + self + } + + pub fn border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_ASSISTANT: Option<&Assistant> = None; + +pub trait AssistantExt: 'static { fn add_action_widget>(&self, child: &P); fn append_page>(&self, page: &P) -> i32; @@ -63,7 +739,7 @@ pub trait AssistantExt { #[cfg(any(feature = "v3_18", feature = "dox"))] fn get_page_has_padding>(&self, page: &P) -> bool; - fn get_page_title>(&self, page: &P) -> Option; + fn get_page_title>(&self, page: &P) -> Option; fn get_page_type>(&self, page: &P) -> AssistantPageType; @@ -81,7 +757,7 @@ pub trait AssistantExt { fn set_current_page(&self, page_num: i32); - //fn set_forward_page_func<'a, P: Into>, Q: Into>>(&self, page_func: P, data: Q, destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify); + fn set_forward_page_func(&self, page_func: Option i32 + 'static>>); fn set_page_complete>(&self, page: &P, complete: bool); @@ -94,7 +770,6 @@ pub trait AssistantExt { fn update_buttons_state(&self); - #[cfg(any(feature = "v3_12", feature = "dox"))] fn get_property_use_header_bar(&self) -> i32; fn get_child_complete>(&self, item: &T) -> bool; @@ -109,9 +784,9 @@ pub trait AssistantExt { fn set_child_page_type>(&self, item: &T, page_type: AssistantPageType); - fn get_child_title>(&self, item: &T) -> Option; + fn get_child_title>(&self, item: &T) -> Option; - fn set_child_title<'a, P: Into>, T: IsA>(&self, item: &T, title: P); + fn set_child_title>(&self, item: &T, title: Option<&str>); fn connect_apply(&self, f: F) -> SignalHandlerId; @@ -124,310 +799,449 @@ pub trait AssistantExt { fn emit_escape(&self); fn connect_prepare(&self, f: F) -> SignalHandlerId; - - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn connect_property_use_header_bar_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA + IsA + glib::object::ObjectExt> AssistantExt for O { +impl> AssistantExt for O { fn add_action_widget>(&self, child: &P) { unsafe { - ffi::gtk_assistant_add_action_widget(self.to_glib_none().0, child.to_glib_none().0); + gtk_sys::gtk_assistant_add_action_widget( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); } } fn append_page>(&self, page: &P) -> i32 { unsafe { - ffi::gtk_assistant_append_page(self.to_glib_none().0, page.to_glib_none().0) + gtk_sys::gtk_assistant_append_page( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + ) } } fn commit(&self) { unsafe { - ffi::gtk_assistant_commit(self.to_glib_none().0); + gtk_sys::gtk_assistant_commit(self.as_ref().to_glib_none().0); } } fn get_current_page(&self) -> i32 { - unsafe { - ffi::gtk_assistant_get_current_page(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_assistant_get_current_page(self.as_ref().to_glib_none().0) } } fn get_n_pages(&self) -> i32 { - unsafe { - ffi::gtk_assistant_get_n_pages(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_assistant_get_n_pages(self.as_ref().to_glib_none().0) } } fn get_nth_page(&self, page_num: i32) -> Option { unsafe { - from_glib_none(ffi::gtk_assistant_get_nth_page(self.to_glib_none().0, page_num)) + from_glib_none(gtk_sys::gtk_assistant_get_nth_page( + self.as_ref().to_glib_none().0, + page_num, + )) } } fn get_page_complete>(&self, page: &P) -> bool { unsafe { - from_glib(ffi::gtk_assistant_get_page_complete(self.to_glib_none().0, page.to_glib_none().0)) + from_glib(gtk_sys::gtk_assistant_get_page_complete( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + )) } } #[cfg(any(feature = "v3_18", feature = "dox"))] fn get_page_has_padding>(&self, page: &P) -> bool { unsafe { - from_glib(ffi::gtk_assistant_get_page_has_padding(self.to_glib_none().0, page.to_glib_none().0)) + from_glib(gtk_sys::gtk_assistant_get_page_has_padding( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + )) } } - fn get_page_title>(&self, page: &P) -> Option { + fn get_page_title>(&self, page: &P) -> Option { unsafe { - from_glib_none(ffi::gtk_assistant_get_page_title(self.to_glib_none().0, page.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_assistant_get_page_title( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + )) } } fn get_page_type>(&self, page: &P) -> AssistantPageType { unsafe { - from_glib(ffi::gtk_assistant_get_page_type(self.to_glib_none().0, page.to_glib_none().0)) + from_glib(gtk_sys::gtk_assistant_get_page_type( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + )) } } fn insert_page>(&self, page: &P, position: i32) -> i32 { unsafe { - ffi::gtk_assistant_insert_page(self.to_glib_none().0, page.to_glib_none().0, position) + gtk_sys::gtk_assistant_insert_page( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + position, + ) } } fn next_page(&self) { unsafe { - ffi::gtk_assistant_next_page(self.to_glib_none().0); + gtk_sys::gtk_assistant_next_page(self.as_ref().to_glib_none().0); } } fn prepend_page>(&self, page: &P) -> i32 { unsafe { - ffi::gtk_assistant_prepend_page(self.to_glib_none().0, page.to_glib_none().0) + gtk_sys::gtk_assistant_prepend_page( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + ) } } fn previous_page(&self) { unsafe { - ffi::gtk_assistant_previous_page(self.to_glib_none().0); + gtk_sys::gtk_assistant_previous_page(self.as_ref().to_glib_none().0); } } fn remove_action_widget>(&self, child: &P) { unsafe { - ffi::gtk_assistant_remove_action_widget(self.to_glib_none().0, child.to_glib_none().0); + gtk_sys::gtk_assistant_remove_action_widget( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); } } fn remove_page(&self, page_num: i32) { unsafe { - ffi::gtk_assistant_remove_page(self.to_glib_none().0, page_num); + gtk_sys::gtk_assistant_remove_page(self.as_ref().to_glib_none().0, page_num); } } fn set_current_page(&self, page_num: i32) { unsafe { - ffi::gtk_assistant_set_current_page(self.to_glib_none().0, page_num); + gtk_sys::gtk_assistant_set_current_page(self.as_ref().to_glib_none().0, page_num); } } - //fn set_forward_page_func<'a, P: Into>, Q: Into>>(&self, page_func: P, data: Q, destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { - // unsafe { TODO: call ffi::gtk_assistant_set_forward_page_func() } - //} + 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, + data: glib_sys::gpointer, + ) -> libc::c_int { + let callback: &Option i32 + 'static>> = &*(data as *mut _); + let res = if let Some(ref callback) = *callback { + callback(current_page) + } else { + panic!("cannot get closure...") + }; + res + } + let page_func = if page_func_data.is_some() { + Some(page_func_func as _) + } else { + None + }; + unsafe extern "C" fn destroy_func(data: glib_sys::gpointer) { + let _callback: Box_ i32 + 'static>>> = + Box_::from_raw(data as *mut _); + } + let destroy_call3 = Some(destroy_func as _); + 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, + page_func, + Box::into_raw(super_callback0) as *mut _, + destroy_call3, + ); + } + } fn set_page_complete>(&self, page: &P, complete: bool) { unsafe { - ffi::gtk_assistant_set_page_complete(self.to_glib_none().0, page.to_glib_none().0, complete.to_glib()); + gtk_sys::gtk_assistant_set_page_complete( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + complete.to_glib(), + ); } } #[cfg(any(feature = "v3_18", feature = "dox"))] fn set_page_has_padding>(&self, page: &P, has_padding: bool) { unsafe { - ffi::gtk_assistant_set_page_has_padding(self.to_glib_none().0, page.to_glib_none().0, has_padding.to_glib()); + gtk_sys::gtk_assistant_set_page_has_padding( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + has_padding.to_glib(), + ); } } fn set_page_title>(&self, page: &P, title: &str) { unsafe { - ffi::gtk_assistant_set_page_title(self.to_glib_none().0, page.to_glib_none().0, title.to_glib_none().0); + gtk_sys::gtk_assistant_set_page_title( + self.as_ref().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) { unsafe { - ffi::gtk_assistant_set_page_type(self.to_glib_none().0, page.to_glib_none().0, type_.to_glib()); + gtk_sys::gtk_assistant_set_page_type( + self.as_ref().to_glib_none().0, + page.as_ref().to_glib_none().0, + type_.to_glib(), + ); } } fn update_buttons_state(&self) { unsafe { - ffi::gtk_assistant_update_buttons_state(self.to_glib_none().0); + gtk_sys::gtk_assistant_update_buttons_state(self.as_ref().to_glib_none().0); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] fn get_property_use_header_bar(&self) -> i32 { - let mut value = Value::from(&0); unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "use-header-bar".to_glib_none().0, value.to_glib_none_mut().0); + 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"use-header-bar\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } fn get_child_complete>(&self, item: &T) -> bool { - let mut value = Value::from(&false); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "complete".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"complete\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } fn set_child_complete>(&self, item: &T, complete: bool) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "complete".to_glib_none().0, Value::from(&complete).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"complete\0".as_ptr() as *const _, + Value::from(&complete).to_glib_none().0, + ); } } fn get_child_has_padding>(&self, item: &T) -> bool { - let mut value = Value::from(&false); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "has-padding".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"has-padding\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } fn set_child_has_padding>(&self, item: &T, has_padding: bool) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "has-padding".to_glib_none().0, Value::from(&has_padding).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"has-padding\0".as_ptr() as *const _, + Value::from(&has_padding).to_glib_none().0, + ); } } fn get_child_page_type>(&self, item: &T) -> AssistantPageType { - let mut value = Value::from(&0); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "page-type".to_glib_none().0, value.to_glib_none_mut().0); - from_glib(transmute(value.get::().unwrap())) + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"page-type\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } } fn set_child_page_type>(&self, item: &T, page_type: AssistantPageType) { - let page_type = page_type.to_glib() as i32; unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "page-type".to_glib_none().0, Value::from(&page_type).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"page-type\0".as_ptr() as *const _, + Value::from(&page_type).to_glib_none().0, + ); } } - fn get_child_title>(&self, item: &T) -> Option { - let mut value = Value::from(None::<&str>); + fn get_child_title>(&self, item: &T) -> Option { unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "title".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"title\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get() } - value.get() } - fn set_child_title<'a, P: Into>, T: IsA>(&self, item: &T, title: P) { - let title = title.into(); + fn set_child_title>(&self, item: &T, title: Option<&str>) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "title".to_glib_none().0, Value::from(title).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"title\0".as_ptr() as *const _, + Value::from(title).to_glib_none().0, + ); } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "apply", - transmute(apply_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "cancel", - transmute(cancel_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "close", - transmute(close_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "escape", - transmute(escape_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } fn emit_escape(&self) { - let _ = self.emit("escape", &[]).unwrap(); + let _ = unsafe { + glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) + .emit("escape", &[]) + .unwrap() + }; } fn connect_prepare(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "prepare", - transmute(prepare_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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), + ) } - } - - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn connect_property_use_header_bar_notify(&self, f: F) -> SignalHandlerId { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::use-header-bar", - transmute(notify_use_header_bar_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn apply_trampoline

(this: *mut ffi::GtkAssistant, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn cancel_trampoline

(this: *mut ffi::GtkAssistant, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn close_trampoline

(this: *mut ffi::GtkAssistant, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn escape_trampoline

(this: *mut ffi::GtkAssistant, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn prepare_trampoline

(this: *mut ffi::GtkAssistant, page: *mut ffi::GtkWidget, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P, &Widget) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(page)) -} - -#[cfg(any(feature = "v3_12", feature = "dox"))] -unsafe extern "C" fn notify_use_header_bar_trampoline

(this: *mut ffi::GtkAssistant, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Assistant::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for Assistant { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Assistant") + } } diff --git a/src/auto/bin.rs b/src/auto/bin.rs index c836a968be..45c1e38eec 100644 --- a/src/auto/bin.rs +++ b/src/auto/bin.rs @@ -1,33 +1,37 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use glib::object::IsA; +use glib::translate::*; +use gtk_sys; +use std::fmt; use Buildable; use Container; use Widget; -use ffi; -use glib::object::IsA; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; glib_wrapper! { - pub struct Bin(Object): Container, Widget, Buildable; + pub struct Bin(Object) @extends Container, Widget, @implements Buildable; match fn { - get_type => || ffi::gtk_bin_get_type(), + get_type => || gtk_sys::gtk_bin_get_type(), } } -pub trait BinExt { +pub const NONE_BIN: Option<&Bin> = None; + +pub trait BinExt: 'static { fn get_child(&self) -> Option; } impl> BinExt for O { fn get_child(&self) -> Option { - unsafe { - from_glib_none(ffi::gtk_bin_get_child(self.to_glib_none().0)) - } + unsafe { from_glib_none(gtk_sys::gtk_bin_get_child(self.as_ref().to_glib_none().0)) } + } +} + +impl fmt::Display for Bin { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Bin") } } diff --git a/src/auto/box_.rs b/src/auto/box_.rs index 7db1ddccfc..b1cceb324f 100644 --- a/src/auto/box_.rs +++ b/src/auto/box_.rs @@ -1,34 +1,37 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -#[cfg(any(feature = "v3_10", feature = "dox"))] +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::Value; +use glib_sys; +use gtk_sys; +use std::boxed::Box as Box_; +use std::fmt; +use std::mem; +use std::mem::transmute; +use Align; use BaselinePosition; use Buildable; use Container; use Orientable; use Orientation; use PackType; +use ResizeMode; use Widget; -use ffi; -use glib; -use glib::Value; -use glib::object::Downcast; -use glib::object::IsA; -use glib::signal::SignalHandlerId; -use glib::signal::connect; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::boxed::Box as Box_; -use std::mem; -use std::mem::transmute; -use std::ptr; glib_wrapper! { - pub struct Box(Object): Container, Widget, Buildable, Orientable; + pub struct Box(Object) @extends Container, Widget, @implements Buildable, Orientable; match fn { - get_type => || ffi::gtk_box_get_type(), + get_type => || gtk_sys::gtk_box_get_type(), } } @@ -36,16 +39,422 @@ impl Box { pub fn new(orientation: Orientation, spacing: i32) -> Box { assert_initialized_main_thread!(); unsafe { - Widget::from_glib_none(ffi::gtk_box_new(orientation.to_glib(), spacing)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_box_new(orientation.to_glib(), spacing)) + .unsafe_cast() } } } -pub trait BoxExt { - #[cfg(any(feature = "v3_10", feature = "dox"))] +pub struct BoxBuilder { + baseline_position: Option, + homogeneous: Option, + spacing: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl BoxBuilder { + pub fn new() -> Self { + Self { + baseline_position: None, + homogeneous: None, + spacing: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + 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 border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(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 border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_BOX: Option<&Box> = None; + +pub trait BoxExt: 'static { fn get_baseline_position(&self) -> BaselinePosition; - #[cfg(any(feature = "v3_12", feature = "dox"))] fn get_center_widget(&self) -> Option; fn get_homogeneous(&self) -> bool; @@ -60,13 +469,18 @@ pub trait BoxExt { fn reorder_child>(&self, child: &P, position: i32); - #[cfg(any(feature = "v3_10", feature = "dox"))] fn set_baseline_position(&self, position: BaselinePosition); - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn set_center_widget<'a, P: IsA + 'a, Q: Into>>(&self, widget: Q); + fn set_center_widget>(&self, widget: Option<&P>); - fn set_child_packing>(&self, child: &P, expand: bool, fill: bool, padding: u32, pack_type: PackType); + fn set_child_packing>( + &self, + child: &P, + expand: bool, + fill: bool, + padding: u32, + pack_type: PackType, + ); fn set_homogeneous(&self, homogeneous: bool); @@ -100,50 +514,66 @@ pub trait BoxExt { fn set_child_position>(&self, item: &T, position: i32); - #[cfg(any(feature = "v3_10", feature = "dox"))] - fn connect_property_baseline_position_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_baseline_position_notify( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_homogeneous_notify(&self, f: F) -> SignalHandlerId; fn connect_property_spacing_notify(&self, f: F) -> SignalHandlerId; } -impl + IsA + IsA> BoxExt for O { - #[cfg(any(feature = "v3_10", feature = "dox"))] +impl> BoxExt for O { fn get_baseline_position(&self) -> BaselinePosition { unsafe { - from_glib(ffi::gtk_box_get_baseline_position(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_box_get_baseline_position( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_12", feature = "dox"))] fn get_center_widget(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_box_get_center_widget(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_box_get_center_widget( + self.as_ref().to_glib_none().0, + )) } } fn get_homogeneous(&self) -> bool { unsafe { - from_glib(ffi::gtk_box_get_homogeneous(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_box_get_homogeneous( + self.as_ref().to_glib_none().0, + )) } } fn get_spacing(&self) -> i32 { - unsafe { - ffi::gtk_box_get_spacing(self.to_glib_none().0) - } + unsafe { gtk_sys::gtk_box_get_spacing(self.as_ref().to_glib_none().0) } } fn pack_end>(&self, child: &P, expand: bool, fill: bool, padding: u32) { unsafe { - ffi::gtk_box_pack_end(self.to_glib_none().0, child.to_glib_none().0, expand.to_glib(), fill.to_glib(), padding); + gtk_sys::gtk_box_pack_end( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + expand.to_glib(), + fill.to_glib(), + padding, + ); } } fn pack_start>(&self, child: &P, expand: bool, fill: bool, padding: u32) { unsafe { - ffi::gtk_box_pack_start(self.to_glib_none().0, child.to_glib_none().0, expand.to_glib(), fill.to_glib(), padding); + gtk_sys::gtk_box_pack_start( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + expand.to_glib(), + fill.to_glib(), + padding, + ); } } @@ -153,174 +583,285 @@ impl + IsA + IsA> BoxExt for O { let mut fill = mem::uninitialized(); let mut padding = mem::uninitialized(); let mut pack_type = mem::uninitialized(); - ffi::gtk_box_query_child_packing(self.to_glib_none().0, child.to_glib_none().0, &mut expand, &mut fill, &mut padding, &mut pack_type); - (from_glib(expand), from_glib(fill), padding, from_glib(pack_type)) + gtk_sys::gtk_box_query_child_packing( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + &mut expand, + &mut fill, + &mut padding, + &mut pack_type, + ); + ( + from_glib(expand), + from_glib(fill), + padding, + from_glib(pack_type), + ) } } fn reorder_child>(&self, child: &P, position: i32) { unsafe { - ffi::gtk_box_reorder_child(self.to_glib_none().0, child.to_glib_none().0, position); + gtk_sys::gtk_box_reorder_child( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + position, + ); } } - #[cfg(any(feature = "v3_10", feature = "dox"))] fn set_baseline_position(&self, position: BaselinePosition) { unsafe { - ffi::gtk_box_set_baseline_position(self.to_glib_none().0, position.to_glib()); + gtk_sys::gtk_box_set_baseline_position( + self.as_ref().to_glib_none().0, + position.to_glib(), + ); } } - #[cfg(any(feature = "v3_12", feature = "dox"))] - fn set_center_widget<'a, P: IsA + 'a, Q: Into>>(&self, widget: Q) { - let widget = widget.into(); - let widget = widget.to_glib_none(); + fn set_center_widget>(&self, widget: Option<&P>) { unsafe { - ffi::gtk_box_set_center_widget(self.to_glib_none().0, widget.0); + gtk_sys::gtk_box_set_center_widget( + self.as_ref().to_glib_none().0, + widget.map(|p| p.as_ref()).to_glib_none().0, + ); } } - fn set_child_packing>(&self, child: &P, expand: bool, fill: bool, padding: u32, pack_type: PackType) { + fn set_child_packing>( + &self, + child: &P, + expand: bool, + fill: bool, + padding: u32, + pack_type: PackType, + ) { unsafe { - ffi::gtk_box_set_child_packing(self.to_glib_none().0, child.to_glib_none().0, expand.to_glib(), fill.to_glib(), padding, pack_type.to_glib()); + gtk_sys::gtk_box_set_child_packing( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + expand.to_glib(), + fill.to_glib(), + padding, + pack_type.to_glib(), + ); } } fn set_homogeneous(&self, homogeneous: bool) { unsafe { - ffi::gtk_box_set_homogeneous(self.to_glib_none().0, homogeneous.to_glib()); + gtk_sys::gtk_box_set_homogeneous(self.as_ref().to_glib_none().0, homogeneous.to_glib()); } } fn set_spacing(&self, spacing: i32) { unsafe { - ffi::gtk_box_set_spacing(self.to_glib_none().0, spacing); + gtk_sys::gtk_box_set_spacing(self.as_ref().to_glib_none().0, spacing); } } #[doc(hidden)] fn get_child_expand>(&self, item: &T) -> bool { - let mut value = Value::from(&false); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "expand".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"expand\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } #[doc(hidden)] fn set_child_expand>(&self, item: &T, expand: bool) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "expand".to_glib_none().0, Value::from(&expand).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"expand\0".as_ptr() as *const _, + Value::from(&expand).to_glib_none().0, + ); } } #[doc(hidden)] fn get_child_fill>(&self, item: &T) -> bool { - let mut value = Value::from(&false); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "fill".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"fill\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } #[doc(hidden)] fn set_child_fill>(&self, item: &T, fill: bool) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "fill".to_glib_none().0, Value::from(&fill).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"fill\0".as_ptr() as *const _, + Value::from(&fill).to_glib_none().0, + ); } } #[doc(hidden)] fn get_child_pack_type>(&self, item: &T) -> PackType { - let mut value = Value::from(&0); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "pack-type".to_glib_none().0, value.to_glib_none_mut().0); - from_glib(transmute(value.get::().unwrap())) + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"pack-type\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } } #[doc(hidden)] fn set_child_pack_type>(&self, item: &T, pack_type: PackType) { - let pack_type = pack_type.to_glib() as i32; unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "pack-type".to_glib_none().0, Value::from(&pack_type).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"pack-type\0".as_ptr() as *const _, + Value::from(&pack_type).to_glib_none().0, + ); } } #[doc(hidden)] fn get_child_padding>(&self, item: &T) -> u32 { - let mut value = Value::from(&0u32); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "padding".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"padding\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } #[doc(hidden)] fn set_child_padding>(&self, item: &T, padding: u32) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "padding".to_glib_none().0, Value::from(&padding).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"padding\0".as_ptr() as *const _, + Value::from(&padding).to_glib_none().0, + ); } } fn get_child_position>(&self, item: &T) -> i32 { - let mut value = Value::from(&0); unsafe { - ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "position".to_glib_none().0, value.to_glib_none_mut().0); + let mut value = Value::from_type(::static_type()); + gtk_sys::gtk_container_child_get_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"position\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value.get().unwrap() } - value.get().unwrap() } fn set_child_position>(&self, item: &T, position: i32) { unsafe { - ffi::gtk_container_child_set_property(self.to_glib_none().0, item.to_glib_none().0, "position".to_glib_none().0, Value::from(&position).to_glib_none().0); + gtk_sys::gtk_container_child_set_property( + self.to_glib_none().0 as *mut gtk_sys::GtkContainer, + item.to_glib_none().0 as *mut _, + b"position\0".as_ptr() as *const _, + Value::from(&position).to_glib_none().0, + ); } } - #[cfg(any(feature = "v3_10", feature = "dox"))] - fn connect_property_baseline_position_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_baseline_position_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_baseline_position_trampoline( + this: *mut gtk_sys::GtkBox, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Box::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::baseline-position", - transmute(notify_baseline_position_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } fn connect_property_homogeneous_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_homogeneous_trampoline( + this: *mut gtk_sys::GtkBox, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Box::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::homogeneous", - transmute(notify_homogeneous_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } fn connect_property_spacing_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_spacing_trampoline( + this: *mut gtk_sys::GtkBox, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&Box::from_glib_borrow(this).unsafe_cast()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::spacing", - transmute(notify_spacing_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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)), + Box_::into_raw(f), + ) } } } -#[cfg(any(feature = "v3_10", feature = "dox"))] -unsafe extern "C" fn notify_baseline_position_trampoline

(this: *mut ffi::GtkBox, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Box::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_homogeneous_trampoline

(this: *mut ffi::GtkBox, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Box::from_glib_borrow(this).downcast_unchecked()) -} - -unsafe extern "C" fn notify_spacing_trampoline

(this: *mut ffi::GtkBox, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Box::from_glib_borrow(this).downcast_unchecked()) +impl fmt::Display for Box { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Box") + } } diff --git a/src/auto/buildable.rs b/src/auto/buildable.rs index 9e02ccdaa0..b0133f2cfe 100644 --- a/src/auto/buildable.rs +++ b/src/auto/buildable.rs @@ -1,84 +1,132 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use Builder; -use ffi; use glib; use glib::object::IsA; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use gtk_sys; +use std::fmt; +use Builder; glib_wrapper! { - pub struct Buildable(Object); + pub struct Buildable(Interface); match fn { - get_type => || ffi::gtk_buildable_get_type(), + get_type => || gtk_sys::gtk_buildable_get_type(), } } -pub trait BuildableExt { - fn add_child<'a, P: IsA, Q: Into>>(&self, builder: &Builder, child: &P, type_: Q); +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 construct_child(&self, builder: &Builder, name: &str) -> Option; + fn construct_child>(&self, builder: &P, name: &str) -> Option; - //fn custom_finished<'a, P: IsA + 'a, Q: Into>, R: Into>>(&self, builder: &Builder, child: Q, tagname: &str, data: R); + //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_end<'a, P: IsA + 'a, Q: Into>, R: Into>>(&self, builder: &Builder, child: Q, tagname: &str, data: R); + //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_start<'a, P: IsA + 'a, Q: Into>>(&self, builder: &Builder, child: Q, tagname: &str, parser: /*Ignored*/glib::MarkupParser, data: /*Unimplemented*/&mut Option) -> bool; + //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, parser: /*Ignored*/glib::MarkupParser, data: /*Unimplemented*/&mut Option) -> bool; - fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option; + fn get_internal_child>( + &self, + builder: &P, + childname: &str, + ) -> Option; - fn parser_finished(&self, builder: &Builder); + fn parser_finished>(&self, builder: &P); - fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value); + fn set_buildable_property>(&self, builder: &P, name: &str, value: &glib::Value); } impl> BuildableExt for O { - fn add_child<'a, P: IsA, Q: Into>>(&self, builder: &Builder, child: &P, type_: Q) { - let type_ = type_.into(); - let type_ = type_.to_glib_none(); + fn add_child, Q: IsA>( + &self, + builder: &P, + child: &Q, + type_: Option<&str>, + ) { unsafe { - ffi::gtk_buildable_add_child(self.to_glib_none().0, builder.to_glib_none().0, child.to_glib_none().0, type_.0); + gtk_sys::gtk_buildable_add_child( + self.as_ref().to_glib_none().0, + builder.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + type_.to_glib_none().0, + ); } } - fn construct_child(&self, builder: &Builder, name: &str) -> Option { + fn construct_child>(&self, builder: &P, name: &str) -> Option { unsafe { - from_glib_full(ffi::gtk_buildable_construct_child(self.to_glib_none().0, builder.to_glib_none().0, name.to_glib_none().0)) + from_glib_full(gtk_sys::gtk_buildable_construct_child( + self.as_ref().to_glib_none().0, + builder.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) } } - //fn custom_finished<'a, P: IsA + 'a, Q: Into>, R: Into>>(&self, builder: &Builder, child: Q, tagname: &str, data: R) { - // unsafe { TODO: call ffi::gtk_buildable_custom_finished() } + //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + // unsafe { TODO: call gtk_sys:gtk_buildable_custom_finished() } //} - //fn custom_tag_end<'a, P: IsA + 'a, Q: Into>, R: Into>>(&self, builder: &Builder, child: Q, tagname: &str, data: R) { - // unsafe { TODO: call ffi::gtk_buildable_custom_tag_end() } + //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_end() } //} - //fn custom_tag_start<'a, P: IsA + 'a, Q: Into>>(&self, builder: &Builder, child: Q, tagname: &str, parser: /*Ignored*/glib::MarkupParser, data: /*Unimplemented*/&mut Option) -> bool { - // unsafe { TODO: call ffi::gtk_buildable_custom_tag_start() } + //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, parser: /*Ignored*/glib::MarkupParser, data: /*Unimplemented*/&mut Option) -> bool { + // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_start() } //} - fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option { + fn get_internal_child>( + &self, + builder: &P, + childname: &str, + ) -> Option { unsafe { - from_glib_none(ffi::gtk_buildable_get_internal_child(self.to_glib_none().0, builder.to_glib_none().0, childname.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_buildable_get_internal_child( + self.as_ref().to_glib_none().0, + builder.as_ref().to_glib_none().0, + childname.to_glib_none().0, + )) } } - fn parser_finished(&self, builder: &Builder) { + fn parser_finished>(&self, builder: &P) { unsafe { - ffi::gtk_buildable_parser_finished(self.to_glib_none().0, builder.to_glib_none().0); + gtk_sys::gtk_buildable_parser_finished( + self.as_ref().to_glib_none().0, + builder.as_ref().to_glib_none().0, + ); } } - fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value) { + fn set_buildable_property>( + &self, + builder: &P, + name: &str, + value: &glib::Value, + ) { unsafe { - ffi::gtk_buildable_set_buildable_property(self.to_glib_none().0, builder.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0); + gtk_sys::gtk_buildable_set_buildable_property( + self.as_ref().to_glib_none().0, + builder.as_ref().to_glib_none().0, + name.to_glib_none().0, + value.to_glib_none().0, + ); } } } + +impl fmt::Display for Buildable { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Buildable") + } +} diff --git a/src/auto/builder.rs b/src/auto/builder.rs index ab850b465e..7b210aded1 100644 --- a/src/auto/builder.rs +++ b/src/auto/builder.rs @@ -1,54 +1,55 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -#[cfg(any(feature = "v3_10", feature = "dox"))] -use Application; -use Error; -use Widget; -use ffi; use glib; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib::GString; +use glib_sys; +use gtk_sys; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; use std::ptr; +use Application; +use Error; +use Widget; glib_wrapper! { - pub struct Builder(Object); + pub struct Builder(Object); match fn { - get_type => || ffi::gtk_builder_get_type(), + get_type => || gtk_sys::gtk_builder_get_type(), } } impl Builder { pub fn new() -> Builder { assert_initialized_main_thread!(); - unsafe { - from_glib_full(ffi::gtk_builder_new()) - } + unsafe { from_glib_full(gtk_sys::gtk_builder_new()) } } - #[cfg(any(feature = "v3_10", feature = "dox"))] pub fn new_from_resource(resource_path: &str) -> Builder { assert_initialized_main_thread!(); unsafe { - from_glib_full(ffi::gtk_builder_new_from_resource(resource_path.to_glib_none().0)) + from_glib_full(gtk_sys::gtk_builder_new_from_resource( + resource_path.to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_10", feature = "dox"))] pub fn new_from_string(string: &str) -> Builder { assert_initialized_main_thread!(); let length = string.len() as isize; unsafe { - from_glib_full(ffi::gtk_builder_new_from_string(string.to_glib_none().0, length)) + from_glib_full(gtk_sys::gtk_builder_new_from_string( + string.to_glib_none().0, + length, + )) } } } @@ -59,70 +60,88 @@ impl Default for Builder { } } -pub trait BuilderExt { - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: /*Unknown conversion*//*Unimplemented*/Callback); +pub const NONE_BUILDER: Option<&Builder> = None; + +pub trait BuilderExt: 'static { + //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: P); - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: /*Unknown conversion*//*Unimplemented*/Callback, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + //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<(), Error>; fn add_from_string(&self, buffer: &str) -> Result<(), Error>; - fn add_objects_from_resource(&self, resource_path: &str, object_ids: &[&str]) -> Result<(), Error>; + fn add_objects_from_resource( + &self, + resource_path: &str, + object_ids: &[&str], + ) -> Result<(), Error>; fn add_objects_from_string(&self, buffer: &str, object_ids: &[&str]) -> Result<(), Error>; - //fn connect_signals>>(&self, user_data: P); + //fn connect_signals(&self, user_data: /*Unimplemented*/Option); - //fn connect_signals_full>>(&self, func: /*Unknown conversion*//*Unimplemented*/BuilderConnectFunc, user_data: P); + //fn connect_signals_full(&self, func: /*Unimplemented*/FnMut(&Builder, &glib::Object, &str, &str, Option<&glib::Object>, /*Ignored*/glib::ConnectFlags), user_data: /*Unimplemented*/Option); - #[cfg(any(feature = "v3_8", feature = "dox"))] fn expose_object>(&self, name: &str, object: &P); - fn extend_with_template>(&self, widget: &P, template_type: glib::types::Type, buffer: &str) -> Result<(), Error>; + fn extend_with_template>( + &self, + widget: &P, + template_type: glib::types::Type, + buffer: &str, + ) -> Result<(), Error>; - #[cfg(any(feature = "v3_10", feature = "dox"))] fn get_application(&self) -> Option; fn get_objects(&self) -> Vec; - fn get_translation_domain(&self) -> Option; + fn get_translation_domain(&self) -> Option; fn get_type_from_name(&self, type_name: &str) -> glib::types::Type; - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn lookup_callback_symbol(&self, callback_name: &str) -> /*Unknown conversion*//*Unimplemented*/Callback; + //fn lookup_callback_symbol(&self, callback_name: &str) -> Option>; - #[cfg(any(feature = "v3_10", feature = "dox"))] - fn set_application(&self, application: &Application); + fn set_application>(&self, application: &P); - fn set_translation_domain<'a, P: Into>>(&self, domain: P); + fn set_translation_domain(&self, domain: Option<&str>); - //fn value_from_string>(&self, pspec: &P, string: &str) -> Result; + //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 value_from_string_type( + &self, + type_: glib::types::Type, + string: &str, + ) -> Result; - fn connect_property_translation_domain_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_translation_domain_notify( + &self, + f: F, + ) -> SignalHandlerId; } -impl + IsA> BuilderExt for O { - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: /*Unknown conversion*//*Unimplemented*/Callback) { - // unsafe { TODO: call ffi::gtk_builder_add_callback_symbol() } +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() } //} - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: /*Unknown conversion*//*Unimplemented*/Callback, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call ffi::gtk_builder_add_callback_symbols() } + //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<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_add_from_resource(self.to_glib_none().0, resource_path.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_add_from_resource( + self.as_ref().to_glib_none().0, + resource_path.to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } } } @@ -130,16 +149,38 @@ impl + IsA> BuilderExt for O { let length = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_add_from_string(self.to_glib_none().0, buffer.to_glib_none().0, length, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_add_from_string( + self.as_ref().to_glib_none().0, + buffer.to_glib_none().0, + length, + &mut error, + ); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } } } - fn add_objects_from_resource(&self, resource_path: &str, object_ids: &[&str]) -> Result<(), Error> { + fn add_objects_from_resource( + &self, + resource_path: &str, + object_ids: &[&str], + ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_add_objects_from_resource(self.to_glib_none().0, resource_path.to_glib_none().0, object_ids.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_add_objects_from_resource( + self.as_ref().to_glib_none().0, + resource_path.to_glib_none().0, + object_ids.to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } } } @@ -147,105 +188,176 @@ impl + IsA> BuilderExt for O { let length = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_add_objects_from_string(self.to_glib_none().0, buffer.to_glib_none().0, length, object_ids.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_add_objects_from_string( + self.as_ref().to_glib_none().0, + buffer.to_glib_none().0, + length, + object_ids.to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } } } - //fn connect_signals>>(&self, user_data: P) { - // unsafe { TODO: call ffi::gtk_builder_connect_signals() } + //fn connect_signals(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call gtk_sys:gtk_builder_connect_signals() } //} - //fn connect_signals_full>>(&self, func: /*Unknown conversion*//*Unimplemented*/BuilderConnectFunc, user_data: P) { - // unsafe { TODO: call ffi::gtk_builder_connect_signals_full() } + //fn connect_signals_full(&self, func: /*Unimplemented*/FnMut(&Builder, &glib::Object, &str, &str, Option<&glib::Object>, /*Ignored*/glib::ConnectFlags), user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call gtk_sys:gtk_builder_connect_signals_full() } //} - #[cfg(any(feature = "v3_8", feature = "dox"))] fn expose_object>(&self, name: &str, object: &P) { unsafe { - ffi::gtk_builder_expose_object(self.to_glib_none().0, name.to_glib_none().0, object.to_glib_none().0); + gtk_sys::gtk_builder_expose_object( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + object.as_ref().to_glib_none().0, + ); } } - fn extend_with_template>(&self, widget: &P, template_type: glib::types::Type, buffer: &str) -> Result<(), Error> { + fn extend_with_template>( + &self, + widget: &P, + template_type: glib::types::Type, + buffer: &str, + ) -> Result<(), Error> { let length = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_extend_with_template(self.to_glib_none().0, widget.to_glib_none().0, template_type.to_glib(), buffer.to_glib_none().0, length, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_extend_with_template( + self.as_ref().to_glib_none().0, + widget.as_ref().to_glib_none().0, + template_type.to_glib(), + buffer.to_glib_none().0, + length, + &mut error, + ); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } } } - #[cfg(any(feature = "v3_10", feature = "dox"))] fn get_application(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_builder_get_application(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_builder_get_application( + self.as_ref().to_glib_none().0, + )) } } fn get_objects(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_container(ffi::gtk_builder_get_objects(self.to_glib_none().0)) + FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_builder_get_objects( + self.as_ref().to_glib_none().0, + )) } } - fn get_translation_domain(&self) -> Option { + fn get_translation_domain(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_builder_get_translation_domain(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_builder_get_translation_domain( + self.as_ref().to_glib_none().0, + )) } } fn get_type_from_name(&self, type_name: &str) -> glib::types::Type { unsafe { - from_glib(ffi::gtk_builder_get_type_from_name(self.to_glib_none().0, type_name.to_glib_none().0)) + from_glib(gtk_sys::gtk_builder_get_type_from_name( + self.as_ref().to_glib_none().0, + type_name.to_glib_none().0, + )) } } - //#[cfg(any(feature = "v3_10", feature = "dox"))] - //fn lookup_callback_symbol(&self, callback_name: &str) -> /*Unknown conversion*//*Unimplemented*/Callback { - // unsafe { TODO: call ffi::gtk_builder_lookup_callback_symbol() } + //fn lookup_callback_symbol(&self, callback_name: &str) -> Option> { + // unsafe { TODO: call gtk_sys:gtk_builder_lookup_callback_symbol() } //} - #[cfg(any(feature = "v3_10", feature = "dox"))] - fn set_application(&self, application: &Application) { + fn set_application>(&self, application: &P) { unsafe { - ffi::gtk_builder_set_application(self.to_glib_none().0, application.to_glib_none().0); + gtk_sys::gtk_builder_set_application( + self.as_ref().to_glib_none().0, + application.as_ref().to_glib_none().0, + ); } } - fn set_translation_domain<'a, P: Into>>(&self, domain: P) { - let domain = domain.into(); - let domain = domain.to_glib_none(); + fn set_translation_domain(&self, domain: Option<&str>) { unsafe { - ffi::gtk_builder_set_translation_domain(self.to_glib_none().0, domain.0); + gtk_sys::gtk_builder_set_translation_domain( + self.as_ref().to_glib_none().0, + domain.to_glib_none().0, + ); } } - //fn value_from_string>(&self, pspec: &P, string: &str) -> Result { - // unsafe { TODO: call ffi::gtk_builder_value_from_string() } + //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(&self, type_: glib::types::Type, string: &str) -> Result { + fn value_from_string_type( + &self, + type_: glib::types::Type, + string: &str, + ) -> Result { unsafe { let mut value = glib::Value::uninitialized(); let mut error = ptr::null_mut(); - let _ = ffi::gtk_builder_value_from_string_type(self.to_glib_none().0, type_.to_glib(), string.to_glib_none().0, value.to_glib_none_mut().0, &mut error); - if error.is_null() { Ok(value) } else { Err(from_glib_full(error)) } + let _ = gtk_sys::gtk_builder_value_from_string_type( + self.as_ref().to_glib_none().0, + type_.to_glib(), + string.to_glib_none().0, + value.to_glib_none_mut().0, + &mut error, + ); + if error.is_null() { + Ok(value) + } else { + Err(from_glib_full(error)) + } } } - fn connect_property_translation_domain_notify(&self, f: F) -> SignalHandlerId { + fn connect_property_translation_domain_notify( + &self, + f: F, + ) -> SignalHandlerId { + 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()) + } unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::translation-domain", - transmute(notify_translation_domain_trampoline:: as usize), Box_::into_raw(f) as *mut _) + 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, + )), + Box_::into_raw(f), + ) } } } -unsafe extern "C" fn notify_translation_domain_trampoline

(this: *mut ffi::GtkBuilder, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { - callback_guard!(); - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&Builder::from_glib_borrow(this).downcast_unchecked()) +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 9da60802de..401cf6e8f9 100644 --- a/src/auto/button.rs +++ b/src/auto/button.rs @@ -1,73 +1,75 @@ -// This file was generated by gir (d933f9a) from gir-files (469db10) +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use Actionable; -use Bin; -use Buildable; -use Container; -use PositionType; -use ReliefStyle; -use Widget; -use ffi; use gdk; use glib; -use glib::Value; -use glib::object::Downcast; +use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectExt; +use glib::signal::connect_raw; use glib::signal::SignalHandlerId; -use glib::signal::connect; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +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::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; +use Actionable; +use Align; +use Bin; +use Buildable; +use Container; +use IconSize; +use PositionType; +use ReliefStyle; +use ResizeMode; +use Widget; glib_wrapper! { - pub struct Button(Object): Bin, Container, Widget, Buildable, Actionable; + pub struct Button(Object) @extends Bin, Container, Widget, @implements Buildable, Actionable; match fn { - get_type => || ffi::gtk_button_get_type(), + get_type => || gtk_sys::gtk_button_get_type(), } } impl Button { pub fn new() -> Button { assert_initialized_main_thread!(); - unsafe { - Widget::from_glib_none(ffi::gtk_button_new()).downcast_unchecked() - } - } - - #[cfg(any(feature = "v3_10", feature = "dox"))] - pub fn new_from_icon_name<'a, P: Into>>(icon_name: P, size: i32) -> Button { - assert_initialized_main_thread!(); - let icon_name = icon_name.into(); - let icon_name = icon_name.to_glib_none(); - unsafe { - Widget::from_glib_none(ffi::gtk_button_new_from_icon_name(icon_name.0, size)).downcast_unchecked() - } + unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new()).unsafe_cast() } } - pub fn new_from_stock(stock_id: &str) -> Button { + pub fn new_from_icon_name(icon_name: Option<&str>, size: IconSize) -> Button { assert_initialized_main_thread!(); unsafe { - Widget::from_glib_none(ffi::gtk_button_new_from_stock(stock_id.to_glib_none().0)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_button_new_from_icon_name( + icon_name.to_glib_none().0, + size.to_glib(), + )) + .unsafe_cast() } } pub fn new_with_label(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { - Widget::from_glib_none(ffi::gtk_button_new_with_label(label.to_glib_none().0)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_button_new_with_label(label.to_glib_none().0)) + .unsafe_cast() } } pub fn new_with_mnemonic(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { - Widget::from_glib_none(ffi::gtk_button_new_with_mnemonic(label.to_glib_none().0)).downcast_unchecked() + Widget::from_glib_none(gtk_sys::gtk_button_new_with_mnemonic( + label.to_glib_none().0, + )) + .unsafe_cast() } } } @@ -78,16 +80,451 @@ impl Default for Button { } } -pub trait ButtonExt { - fn clicked(&self); +pub struct ButtonBuilder { + always_show_image: Option, + image: Option, + image_position: Option, + label: Option, + relief: Option, + use_underline: Option, + border_width: Option, + child: Option, + resize_mode: Option, + app_paintable: Option, + can_default: Option, + can_focus: Option, + events: Option, + expand: Option, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: Option, + halign: Option, + has_default: Option, + has_focus: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + is_focus: Option, + margin: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + no_show_all: Option, + opacity: Option, + parent: Option, + receives_default: Option, + sensitive: Option, + //style: /*Unknown type*/, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, +} + +impl ButtonBuilder { + pub fn new() -> Self { + Self { + always_show_image: None, + image: None, + image_position: None, + label: None, + relief: None, + use_underline: None, + border_width: None, + child: None, + resize_mode: None, + app_paintable: None, + can_default: None, + can_focus: None, + events: None, + expand: None, + #[cfg(any(feature = "v3_20", feature = "dox"))] + focus_on_click: None, + halign: None, + has_default: None, + has_focus: None, + has_tooltip: None, + height_request: None, + hexpand: None, + hexpand_set: None, + is_focus: None, + margin: None, + margin_bottom: None, + margin_end: None, + margin_start: None, + margin_top: None, + name: None, + no_show_all: None, + opacity: None, + parent: None, + receives_default: None, + sensitive: None, + tooltip_markup: None, + tooltip_text: None, + valign: None, + vexpand: None, + vexpand_set: None, + visible: None, + width_request: None, + } + } + + pub fn build(self) -> Button { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref always_show_image) = self.always_show_image { + properties.push(("always-show-image", always_show_image)); + } + if let Some(ref image) = self.image { + properties.push(("image", image)); + } + if let Some(ref image_position) = self.image_position { + properties.push(("image-position", image_position)); + } + 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 border_width) = self.border_width { + properties.push(("border-width", border_width)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref resize_mode) = self.resize_mode { + properties.push(("resize-mode", resize_mode)); + } + if let Some(ref app_paintable) = self.app_paintable { + properties.push(("app-paintable", app_paintable)); + } + if let Some(ref can_default) = self.can_default { + properties.push(("can-default", can_default)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref events) = self.events { + properties.push(("events", events)); + } + if let Some(ref expand) = self.expand { + properties.push(("expand", expand)); + } + #[cfg(any(feature = "v3_20", feature = "dox"))] + { + 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_default) = self.has_default { + properties.push(("has-default", has_default)); + } + 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 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 no_show_all) = self.no_show_all { + properties.push(("no-show-all", no_show_all)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref parent) = self.parent { + properties.push(("parent", parent)); + } + 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(Button::static_type(), &properties) + .expect("object new") + .downcast() + .expect("downcast") + } + + pub fn always_show_image(mut self, always_show_image: bool) -> Self { + self.always_show_image = Some(always_show_image); + self + } + + pub fn image(mut self, image: &Widget) -> Self { + self.image = Some(image.clone()); + self + } + + pub fn image_position(mut self, image_position: PositionType) -> Self { + self.image_position = Some(image_position); + 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 border_width(mut self, border_width: u32) -> Self { + self.border_width = Some(border_width); + self + } + + pub fn child(mut self, child: &Widget) -> Self { + self.child = Some(child.clone()); + self + } + + pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { + self.resize_mode = Some(resize_mode); + self + } + + pub fn app_paintable(mut self, app_paintable: bool) -> Self { + self.app_paintable = Some(app_paintable); + self + } + + pub fn can_default(mut self, can_default: bool) -> Self { + self.can_default = Some(can_default); + self + } + + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self + } + + pub fn events(mut self, events: gdk::EventMask) -> Self { + self.events = Some(events); + self + } + + pub fn expand(mut self, expand: bool) -> Self { + self.expand = Some(expand); + self + } + + #[cfg(any(feature = "v3_20", feature = "dox"))] + 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_default(mut self, has_default: bool) -> Self { + self.has_default = Some(has_default); + 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 + } - fn get_alignment(&self) -> (f32, f32); + 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 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 no_show_all(mut self, no_show_all: bool) -> Self { + self.no_show_all = Some(no_show_all); + self + } + + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self + } + + pub fn parent(mut self, parent: &Container) -> Self { + self.parent = Some(parent.clone()); + 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_BUTTON: Option<&Button> = None; + +pub trait ButtonExt: 'static { + fn clicked(&self); - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_always_show_image(&self) -> bool; fn get_event_window(&self) -> Option; + #[cfg_attr(feature = "v3_20", deprecated)] #[cfg(any(not(feature = "v3_20"), feature = "dox"))] fn get_focus_on_click(&self) -> bool; @@ -95,23 +532,19 @@ pub trait ButtonExt { fn get_image_position(&self) -> PositionType; - fn get_label(&self) -> Option; + fn get_label(&self) -> Option; fn get_relief(&self) -> ReliefStyle; - fn get_use_stock(&self) -> bool; - fn get_use_underline(&self) -> bool; - fn set_alignment(&self, xalign: f32, yalign: f32); - - #[cfg(any(feature = "v3_6", feature = "dox"))] fn set_always_show_image(&self, always_show: bool); + #[cfg_attr(feature = "v3_20", deprecated)] #[cfg(any(not(feature = "v3_20"), feature = "dox"))] fn set_focus_on_click(&self, focus_on_click: bool); - fn set_image>(&self, image: &P); + fn set_image>(&self, image: Option<&P>); fn set_image_position(&self, position: PositionType); @@ -119,18 +552,8 @@ pub trait ButtonExt { fn set_relief(&self, relief: ReliefStyle); - fn set_use_stock(&self, use_stock: bool); - fn set_use_underline(&self, use_underline: bool); - 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_activate(&self, f: F) -> SignalHandlerId; fn emit_activate(&self); @@ -139,354 +562,366 @@ pub trait ButtonExt { fn emit_clicked(&self); - #[cfg(any(feature = "v3_6", feature = "dox"))] - fn connect_property_always_show_image_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_always_show_image_notify( + &self, + f: F, + ) -> SignalHandlerId; fn connect_property_image_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_image_position_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_image_position_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_stock_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_use_underline_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId; + fn connect_property_use_underline_notify( + &self, + f: F, + ) -> SignalHandlerId; } -impl + IsA + glib::object::ObjectExt> ButtonExt for O { +impl> ButtonExt for O { fn clicked(&self) { unsafe { - ffi::gtk_button_clicked(self.to_glib_none().0); + gtk_sys::gtk_button_clicked(self.as_ref().to_glib_none().0); } } - fn get_alignment(&self) -> (f32, f32) { - unsafe { - let mut xalign = mem::uninitialized(); - let mut yalign = mem::uninitialized(); - ffi::gtk_button_get_alignment(self.to_glib_none().0, &mut xalign, &mut yalign); - (xalign, yalign) - } - } - - #[cfg(any(feature = "v3_6", feature = "dox"))] fn get_always_show_image(&self) -> bool { unsafe { - from_glib(ffi::gtk_button_get_always_show_image(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_button_get_always_show_image( + self.as_ref().to_glib_none().0, + )) } } fn get_event_window(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_button_get_event_window(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_button_get_event_window( + self.as_ref().to_glib_none().0, + )) } } #[cfg(any(not(feature = "v3_20"), feature = "dox"))] fn get_focus_on_click(&self) -> bool { unsafe { - from_glib(ffi::gtk_button_get_focus_on_click(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_button_get_focus_on_click( + self.as_ref().to_glib_none().0, + )) } } fn get_image(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_button_get_image(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_button_get_image( + self.as_ref().to_glib_none().0, + )) } } fn get_image_position(&self) -> PositionType { unsafe { - from_glib(ffi::gtk_button_get_image_position(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_button_get_image_position( + self.as_ref().to_glib_none().0, + )) } } - fn get_label(&self) -> Option { + fn get_label(&self) -> Option { unsafe { - from_glib_none(ffi::gtk_button_get_label(self.to_glib_none().0)) + from_glib_none(gtk_sys::gtk_button_get_label( + self.as_ref().to_glib_none().0, + )) } } fn get_relief(&self) -> ReliefStyle { unsafe { - from_glib(ffi::gtk_button_get_relief(self.to_glib_none().0)) - } - } - - fn get_use_stock(&self) -> bool { - unsafe { - from_glib(ffi::gtk_button_get_use_stock(self.to_glib_none().0)) + from_glib(gtk_sys::gtk_button_get_relief( + self.as_ref().to_glib_none().0, + )) } } fn get_use_underline(&self) -> bool { unsafe { - from_glib(ffi::gtk_button_get_use_underline(self.to_glib_none().0)) - } - } - - fn set_alignment(&self, xalign: f32, yalign: f32) { - unsafe { - ffi::gtk_button_set_alignment(self.to_glib_none().0, xalign, yalign); + from_glib(gtk_sys::gtk_button_get_use_underline( + self.as_ref().to_glib_none().0, + )) } } - #[cfg(any(feature = "v3_6", feature = "dox"))] fn set_always_show_image(&self, always_show: bool) { unsafe { - ffi::gtk_button_set_always_show_image(self.to_glib_none().0, always_show.to_glib()); + gtk_sys::gtk_button_set_always_show_image( + self.as_ref().to_glib_none().0, + always_show.to_glib(), + ); } } #[cfg(any(not(feature = "v3_20"), feature = "dox"))] fn set_focus_on_click(&self, focus_on_click: bool) { unsafe { - ffi::gtk_button_set_focus_on_click(self.to_glib_none().0, focus_on_click.to_glib()); + gtk_sys::gtk_button_set_focus_on_click( + self.as_ref().to_glib_none().0, + focus_on_click.to_glib(), + ); } } - fn set_image>(&self, image: &P) { + fn set_image>(&self, image: Option<&P>) { unsafe { - ffi::gtk_button_set_image(self.to_glib_none().0, image.to_glib_none().0); + gtk_sys::gtk_button_set_image( + self.as_ref().to_glib_none().0, + image.map(|p| p.as_ref()).to_glib_none().0, + ); } } fn set_image_position(&self, position: PositionType) { unsafe { - ffi::gtk_button_set_image_position(self.to_glib_none().0, position.to_glib()); + gtk_sys::gtk_button_set_image_position( + self.as_ref().to_glib_none().0, + position.to_glib(), + ); } } fn set_label(&self, label: &str) { unsafe { - ffi::gtk_button_set_label(self.to_glib_none().0, label.to_glib_none().0); + gtk_sys::gtk_button_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0); } } fn set_relief(&self, relief: ReliefStyle) { unsafe { - ffi::gtk_button_set_relief(self.to_glib_none().0, relief.to_glib()); - } - } - - fn set_use_stock(&self, use_stock: bool) { - unsafe { - ffi::gtk_button_set_use_stock(self.to_glib_none().0, use_stock.to_glib()); + 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 { - ffi::gtk_button_set_use_underline(self.to_glib_none().0, use_underline.to_glib()); - } - } - - fn get_property_xalign(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "xalign".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_xalign(&self, xalign: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "xalign".to_glib_none().0, Value::from(&xalign).to_glib_none().0); - } - } - - fn get_property_yalign(&self) -> f32 { - let mut value = Value::from(&0f32); - unsafe { - gobject_ffi::g_object_get_property(self.to_glib_none().0, "yalign".to_glib_none().0, value.to_glib_none_mut().0); - } - value.get().unwrap() - } - - fn set_property_yalign(&self, yalign: f32) { - unsafe { - gobject_ffi::g_object_set_property(self.to_glib_none().0, "yalign".to_glib_none().0, Value::from(&yalign).to_glib_none().0); + gtk_sys::gtk_button_set_use_underline( + self.as_ref().to_glib_none().0, + use_underline.to_glib(), + ); } } fn connect_activate(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn activate_trampoline( + this: *mut gtk_sys::GtkButton, + f: glib_sys::gpointer, + ) where + P: IsA