diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cb9ab5884e15..97f3690092f5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,7 +10,7 @@ jobs: name: Rust project runs-on: ubuntu-latest container: - image: fedora:latest + image: docker.io/bilelmoussaoui/gtk4 strategy: matrix: rust: @@ -19,7 +19,6 @@ jobs: - nightly - "1.40.0" steps: - - run: sudo dnf install -y gtk4-devel gcc - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: diff --git a/Cargo.toml b/Cargo.toml index e3b54a87525c..b6109e6101d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,13 +52,13 @@ gsk4-sys = { git = "https://github.com/gtk-rs/sys" } gtk4-sys = { git = "https://github.com/gtk-rs/sys" } pango-sys = { git = "https://github.com/gtk-rs/sys" } cairo-rs = { git = "https://github.com/gtk-rs/cairo" } -gio = { git = "https://github.com/gtk-rs/gio", features = ["v2_44"] } +gio = { git = "https://github.com/gtk-rs/gio", features = ["v2_46"] } glib = { git = "https://github.com/gtk-rs/glib" } gdk4 = { git = "https://github.com/gtk-rs/gdk4" } graphene = { package = "graphene-rs", git = "https://github.com/gtk-rs/graphene" } gsk4 = { git = "https://github.com/gtk-rs/gsk4" } gdk-pixbuf = { git = "https://github.com/gtk-rs/gdk-pixbuf" } -pango = { git = "https://github.com/gtk-rs/pango" } +pango = { git = "https://github.com/gtk-rs/pango", features = ["v1_46"] } [dev-dependencies] gir-format-check = "^0.1" diff --git a/Gir.toml b/Gir.toml index 9cba74006227..fe4f1d9eab34 100644 --- a/Gir.toml +++ b/Gir.toml @@ -10,400 +10,224 @@ deprecate_by_min_version = true single_version_file = true generate = [ - "Gtk.AccelFlags", - "Gtk.AccelLabel", + # "Gtk.BuilderCScope", not useful + # "Gtk.CClosureExpression", not useful + # "Gtk.ClosureExpression", + # "Gtk.ConstantExpression", + # "Gtk.Expression", + # "Gtk.ExpressionNotify", + # "Gtk.ExpressionWatch", + # "Gtk.ObjectExpression", + # "Gtk.ParamSpecExpression", + # "Gtk.PropertyExpression", + # "Gtk.RequestedSize", a record "Gtk.Accessible", - "Gtk.ActionBar", - "Gtk.Adjustment", + "Gtk.AccessibleAutocomplete", + "Gtk.AccessibleInvalidState", + "Gtk.AccessibleProperty", + "Gtk.AccessibleRelation", + "Gtk.AccessibleRole", + "Gtk.AccessibleSort", + "Gtk.AccessibleState", + "Gtk.AccessibleTristate", + "Gtk.ActivateAction", "Gtk.Align", "Gtk.Allocation", + "Gtk.AnyFilter", "Gtk.AppChooser", - "Gtk.AppChooserButton", - "Gtk.AppChooserWidget", "Gtk.ApplicationInhibitFlags", - "Gtk.ApplicationWindow", - "Gtk.ArrowPlacement", "Gtk.ArrowType", - "Gtk.AspectFrame", - "Gtk.Assistant", - "Gtk.AssistantPage", "Gtk.AssistantPageType", + "Gtk.ATContext", "Gtk.BaselinePosition", - "Gtk.Bin", "Gtk.BinLayout", + "Gtk.Bitset", + "Gtk.BitsetIter", "Gtk.BorderStyle", - "Gtk.Box", - "Gtk.BoxLayout", "Gtk.Buildable", + "Gtk.BuildableParser", + "Gtk.BuilderClosureFlags", "Gtk.BuilderError", - "Gtk.Button", - "Gtk.ButtonRole", + "Gtk.BuilderScope", "Gtk.ButtonsType", - "Gtk.Calendar", - "Gtk.CalendarDisplayOptions", - "Gtk.CellAreaBox", - "Gtk.CellAreaContext", + "Gtk.CallbackAction", "Gtk.CellEditable", "Gtk.CellLayout", "Gtk.CellRendererAccelMode", "Gtk.CellRendererMode", - "Gtk.CellRendererPixbuf", - "Gtk.CellRendererProgress", - "Gtk.CellRendererSpin", - "Gtk.CellRendererSpinner", "Gtk.CellRendererState", - "Gtk.CenterBox", - "Gtk.CheckButton", - "Gtk.CheckMenuItem", - "Gtk.ColorButton", - "Gtk.ColorChooserDialog", - "Gtk.ColorChooserWidget", - "Gtk.ComboBoxText", - "Gtk.Container", + "Gtk.CenterLayout", + "Gtk.Clipboard", + "Gtk.ConstraintAttribute", + "Gtk.ConstraintLayout", + "Gtk.ConstraintLayoutChild", + "Gtk.ConstraintRelation", + "Gtk.ConstraintStrength", + "Gtk.ConstraintTarget", + "Gtk.ConstraintVflParserError", "Gtk.CornerType", + "Gtk.CssParserError", + "Gtk.CssParserWarning", "Gtk.CssProvider", "Gtk.CssSection", + "Gtk.CustomFilter", "Gtk.CustomLayout", + "Gtk.CustomSorter", "Gtk.DebugFlag", "Gtk.DeleteType", - "Gtk.DestDefaults", "Gtk.DialogFlags", "Gtk.DirectionType", - "Gtk.DragResult", - "Gtk.DrawingArea", + "Gtk.DropControllerMotion", + "Gtk.EditableLabel", "Gtk.EditableProperties", + "Gtk.EmojiChooser", "Gtk.EntryIconPosition", "Gtk.EventController", + "Gtk.EventControllerFocus", "Gtk.EventControllerLegacy", "Gtk.EventControllerMotion", - "Gtk.EventControllerScroll", "Gtk.EventControllerScrollFlags", "Gtk.EventSequenceState", - "Gtk.Expander", + "Gtk.EveryFilter", "Gtk.FileChooserAction", - "Gtk.FileChooserButton", - "Gtk.FileChooserConfirmation", - "Gtk.FileChooserDialog", "Gtk.FileChooserError", - "Gtk.FileChooserNative", - "Gtk.FileChooserWidget", - "Gtk.FileFilter", - "Gtk.FileFilterFlags", - "Gtk.FilterListModel", - "Gtk.Fixed", # TODO: get_child_*() may need fixing: https://github.com/gtk-rs/gtk/issues/565 + "Gtk.Filter", + "Gtk.FilterChange", + "Gtk.FilterMatch", "Gtk.FixedLayout", - "Gtk.FixedLayoutChild", - "Gtk.FlattenListModel", - "Gtk.FlowBox", - "Gtk.FlowBoxChild", - "Gtk.FontButton", "Gtk.FontChooser", - "Gtk.FontChooserDialog", "Gtk.FontChooserLevel", - "Gtk.FontChooserWidget", - "Gtk.Frame", + "Gtk.GestureClick", "Gtk.GestureDrag", - "Gtk.GestureLongPress", - "Gtk.GestureMultiPress", - "Gtk.GesturePan", "Gtk.GestureRotate", - "Gtk.GestureSingle", "Gtk.GestureStylus", "Gtk.GestureSwipe", "Gtk.GestureZoom", - "Gtk.Grid", - "Gtk.GridLayout", - "Gtk.GridLayoutChild", - "Gtk.HeaderBar", - "Gtk.IconInfo", "Gtk.IconLookupFlags", "Gtk.IconSize", "Gtk.IconThemeError", "Gtk.IconViewDropPosition", - "Gtk.Image", "Gtk.ImageType", "Gtk.IMMulticontext", - "Gtk.InfoBar", "Gtk.InputHints", "Gtk.InputPurpose", "Gtk.Justification", "Gtk.LayoutChild", "Gtk.LayoutManager", - "Gtk.LevelBar", "Gtk.LevelBarMode", "Gtk.License", - "Gtk.ListBox", - "Gtk.ListBoxRow", - "Gtk.LockButton", - "Gtk.MapListModel", - "Gtk.MediaControls", + "Gtk.ListBase", + "Gtk.ListItemFactory", "Gtk.MediaFile", - "Gtk.MenuBar", - "Gtk.MenuButton", "Gtk.MenuDirectionType", - "Gtk.MenuToolButton", - "Gtk.MessageDialog", "Gtk.MessageType", - "Gtk.ModelButton", - "Gtk.MountOperation", + "Gtk.MnemonicAction", "Gtk.MovementStep", + "Gtk.MultiFilter", + "Gtk.MultiSorter", + "Gtk.Native", "Gtk.NativeDialog", - "Gtk.NotebookPage", + "Gtk.NeverTrigger", "Gtk.NotebookTab", + "Gtk.NothingAction", "Gtk.NumberUpLayout", + "Gtk.Ordering", "Gtk.Orientable", "Gtk.Orientation", "Gtk.Overflow", + "Gtk.OverlayLayout", "Gtk.PackType", "Gtk.PadActionType", "Gtk.PageOrientation", "Gtk.PageSet", "Gtk.PanDirection", - "Gtk.Paned", - "Gtk.PasswordEntry", "Gtk.PickFlags", - "Gtk.Picture", "Gtk.PlacesOpenFlags", "Gtk.PolicyType", - "Gtk.Popover", "Gtk.PopoverConstraint", - "Gtk.PopoverMenu", + "Gtk.PopoverMenuFlags", "Gtk.PositionType", "Gtk.PrintDuplex", "Gtk.PrintError", - "Gtk.PrintOperation", "Gtk.PrintOperationAction", "Gtk.PrintOperationPreview", "Gtk.PrintOperationResult", "Gtk.PrintPages", "Gtk.PrintQuality", "Gtk.PrintStatus", - "Gtk.ProgressBar", + "Gtk.PropagationLimit", "Gtk.PropagationPhase", "Gtk.RecentInfo", - "Gtk.RecentManager", "Gtk.RecentManagerError", - "Gtk.ReliefStyle", - "Gtk.Revealer", "Gtk.RevealerTransitionType", "Gtk.Root", - "Gtk.Scale", "Gtk.Scrollable", "Gtk.ScrollablePolicy", - "Gtk.Scrollbar", - "Gtk.ScrolledWindow", "Gtk.ScrollStep", "Gtk.ScrollType", - "Gtk.SearchBar", - "Gtk.SearchEntry", "Gtk.SelectionMode", "Gtk.SelectionModel", "Gtk.SensitivityType", - "Gtk.Separator", - "Gtk.SeparatorMenuItem", - "Gtk.SeparatorToolItem", - "Gtk.Settings", - "Gtk.ShadowType", - "Gtk.ShortcutLabel", - "Gtk.ShortcutsGroup", - "Gtk.ShortcutsShortcut", - "Gtk.ShortcutsWindow", + "Gtk.ShortcutAction", + "Gtk.ShortcutActionFlags", + "Gtk.ShortcutManager", + "Gtk.ShortcutScope", "Gtk.ShortcutType", - "Gtk.SingleSelection", - "Gtk.SizeGroup", + "Gtk.SignalListItemFactory", "Gtk.SizeGroupMode", "Gtk.SizeRequestMode", - "Gtk.SliceListModel", - "Gtk.SortListModel", + "Gtk.Sorter", + "Gtk.SorterChange", + "Gtk.SorterOrder", "Gtk.SortType", "Gtk.SpinButtonUpdatePolicy", - "Gtk.Spinner", "Gtk.SpinType", - "Gtk.Stack", - "Gtk.StackPage", - "Gtk.StackSidebar", - "Gtk.StackSwitcher", "Gtk.StackTransitionType", "Gtk.StateFlags", - "Gtk.Statusbar", - "Gtk.StyleContext", + "Gtk.StringFilterMatchMode", + "Gtk.StringList", "Gtk.StyleContextPrintFlags", "Gtk.StyleProvider", + "Gtk.SystemSetting", "Gtk.TextBufferTargetInfo", "Gtk.TextChildAnchor", "Gtk.TextDirection", "Gtk.TextExtendSelection", - "Gtk.TextMark", "Gtk.TextSearchFlags", - "Gtk.TextTagTable", "Gtk.TextViewLayer", "Gtk.TextWindowType", - "Gtk.ToggleButton", - "Gtk.ToggleToolButton", - "Gtk.ToolbarStyle", - "Gtk.ToolButton", - "Gtk.ToolShell", "Gtk.Tooltip", "Gtk.TreeDragDest", "Gtk.TreeDragSource", - "Gtk.TreeListModel", - "Gtk.TreeListRow", "Gtk.TreeModelFlags", "Gtk.TreeViewColumnSizing", "Gtk.TreeViewDropPosition", "Gtk.TreeViewGridLines", "Gtk.Unit", - "Gtk.Video", - "Gtk.Viewport", - "Gtk.VolumeButton", - "Gtk.WidgetPaintable", - "Gtk.WidgetPath", + "Gtk.WindowGeometryInfo", "Gtk.WindowGroup", - "Gtk.WindowPosition", - "Gtk.WindowType", "Gtk.WrapMode", ] -builders = [ - "Gtk.AboutDialogBuilder", - "Gtk.AccelLabelBuilder", - "Gtk.ActionBarBuilder", - "Gtk.AppChooserButtonBuilder", - "Gtk.AppChooserDialogBuilder", - "Gtk.AppChooserWidgetBuilder", - "Gtk.ApplicationWindowBuilder", - "Gtk.AspectFrameBuilder", - "Gtk.AssistantBuilder", - "Gtk.BinBuilder", - "Gtk.BoxBuilder", - "Gtk.ButtonBuilder", - "Gtk.CalendarBuilder", - "Gtk.CellAreaBoxBuilder", - "Gtk.CellAreaBuilder", - "Gtk.CellViewBuilder", - "Gtk.CenterBoxBuilder", - "Gtk.CheckButtonBuilder", - "Gtk.CheckMenuItemBuilder", - "Gtk.ColorButtonBuilder", - "Gtk.ColorChooserDialogBuilder", - "Gtk.ColorChooserWidgetBuilder", - "Gtk.ComboBoxBuilder", - "Gtk.ComboBoxTextBuilder", - "Gtk.ContainerBuilder", - "Gtk.DialogBuilder", - "Gtk.DrawingAreaBuilder", - "Gtk.EntryBuilder", - "Gtk.EntryCompletionBuilder", - "Gtk.ExpanderBuilder", - "Gtk.FileChooserButtonBuilder", - "Gtk.FileChooserDialogBuilder", - "Gtk.FileChooserWidgetBuilder", - "Gtk.FileFilterBuilder", - "Gtk.FixedBuilder", - "Gtk.FlowBoxBuilder", - "Gtk.FlowBoxChildBuilder", - "Gtk.FontButtonBuilder", - "Gtk.FontChooserDialogBuilder", - "Gtk.FontChooserWidgetBuilder", - "Gtk.FrameBuilder", - "Gtk.GLAreaBuilder", - "Gtk.GridBuilder", - "Gtk.HeaderBarBuilder", - "Gtk.ImageBuilder", - "Gtk.InfoBarBuilder", - "Gtk.LabelBuilder", - "Gtk.LevelBarBuilder", - "Gtk.LinkButtonBuilder", - "Gtk.ListBoxBuilder", - "Gtk.ListBoxRowBuilder", - "Gtk.ListStoreBuilder", - "Gtk.LockButtonBuilder", - "Gtk.MediaControlsBuilder", - "Gtk.MenuBarBuilder", - "Gtk.MenuBuilder", - "Gtk.MenuButtonBuilder", - "Gtk.MenuItemBuilder", - "Gtk.MenuShellBuilder", - "Gtk.MenuToolButtonBuilder", - "Gtk.MessageDialogBuilder", - "Gtk.ModelButtonBuilder", - "Gtk.NotebookBuilder", - "Gtk.OverlayBuilder", - "Gtk.PanedBuilder", - "Gtk.PasswordEntryBuilder", - "Gtk.PictureBuilder", - "Gtk.PopoverBuilder", - "Gtk.PopoverMenuBuilder", - "Gtk.ProgressBarBuilder", - "Gtk.RadioButtonBuilder", - "Gtk.RadioMenuItemBuilder", - "Gtk.RadioToolButtonBuilder", - "Gtk.RangeBuilder", - "Gtk.RevealerBuilder", - "Gtk.ScaleBuilder", - "Gtk.ScaleButtonBuilder", - "Gtk.ScrollbarBuilder", - "Gtk.ScrolledWindowBuilder", - "Gtk.SearchBarBuilder", - "Gtk.SearchEntryBuilder", - "Gtk.SeparatorBuilder", - "Gtk.SeparatorMenuItemBuilder", - "Gtk.SeparatorToolItemBuilder", - "Gtk.ShortcutLabelBuilder", - "Gtk.ShortcutsGroupBuilder", - "Gtk.ShortcutsSectionBuilder", - "Gtk.ShortcutsShortcutBuilder", - "Gtk.ShortcutsWindowBuilder", - "Gtk.SizeGroupBuilder", - "Gtk.SpinButtonBuilder", - "Gtk.SpinnerBuilder", - "Gtk.StackBuilder", - "Gtk.StackSidebarBuilder", - "Gtk.StackSwitcherBuilder", - "Gtk.StatusbarBuilder", - "Gtk.SwitchBuilder", - "Gtk.TextBuilder", - "Gtk.TextTagTableBuilder", - "Gtk.TextViewBuilder", - "Gtk.ToggleButtonBuilder", - "Gtk.ToggleToolButtonBuilder", - "Gtk.ToolbarBuilder", - "Gtk.ToolButtonBuilder", - "Gtk.ToolItemBuilder", - "Gtk.TreeStoreBuilder", - "Gtk.TreeViewBuilder", - "Gtk.TreeViewColumnBuilder", - "Gtk.VideoBuilder", - "Gtk.ViewportBuilder", - "Gtk.VolumeButtonBuilder", - "Gtk.WindowBuilder", -] - # TODO ignore = [ - "Gtk.BindingArg", - "Gtk.BindingEntry", - "Gtk.BindingSet", - "Gtk.BindingSignal", ] manual = [ + # "Gdk.TimeCoord", # "GObject.ObjectClass", # "GObject.ParamSpec", # TODO "GLib.Scanner", - "Atk.CoordType", - "Atk.Object", - "Atk.RelationSet", "cairo.Context", "cairo.FontOptions", "cairo.RectangleInt", "cairo.Region", "cairo.Surface", "Gdk.AnchorHints", - "Gdk.Atom", "Gdk.AxisUse", "Gdk.Clipboard", "Gdk.ContentFormats", + "Gdk.ContentProvider", "Gdk.CrossingMode", "Gdk.Cursor", "Gdk.Device", @@ -417,18 +241,17 @@ manual = [ "Gdk.FrameClock", "Gdk.GLContext", "Gdk.Gravity", - "Gdk.ModifierIntent", + "Gdk.KeyMatch", "Gdk.ModifierType", "Gdk.Monitor", "Gdk.NotifyType", "Gdk.Paintable", "Gdk.Rectangle", "Gdk.RGBA", + "Gdk.Snapshot", "Gdk.Surface", "Gdk.SurfaceEdge", - "Gdk.SurfaceTypeHint", "Gdk.Texture", - "Gdk.TimeCoord", "GdkPixbuf.Pixbuf", "Gio.Action", "Gio.ActionGroup", @@ -445,6 +268,8 @@ manual = [ "Gio.MenuModel", "Gio.MountOperation", "Gio.Permission", + "GLib.Bytes", + "GLib.DateTime", "GLib.Error", "GLib.KeyFile", "GLib.MarkupParser", @@ -454,6 +279,7 @@ manual = [ "GLib.VariantType", "GObject.Closure", "GObject.Object", + "GObject.ParamFlags", "GObject.Value", "Graphene.Matrix", "Graphene.Point", @@ -464,14 +290,13 @@ manual = [ "Graphene.Vec4", "Gsk.BlendMode", "Gsk.ColorStop", + "Gsk.Renderer", "Gsk.RenderNode", "Gsk.RoundedRect", "Gsk.Shadow", "Gsk.Transform", - "Gtk.AccelKey", "Gtk.Border", "Gtk.CssLocation", - "Gtk.FileFilterInfo", "Gtk.PadActionEntry", "Gtk.PageRange", "Gtk.RecentData", @@ -488,6 +313,8 @@ manual = [ "Pango.FontMap", "Pango.Language", "Pango.Layout", + "Pango.Overline", + "Pango.ShowFlags", "Pango.Stretch", "Pango.Style", "Pango.TabArray", @@ -568,60 +395,120 @@ status = "generate" pattern = "drag_.+" #manual trait ignore = true + [[object.function]] + name = "show_uri_full" + # TODO: manual + ignore = true [[object]] name = "Gtk.AboutDialog" status = "generate" +generate_builder = true [[object.signal]] name = "activate-link" inhibit = true [[object]] -name = "Gtk.AccelGroup" -status = "generate" - [[object.function]] - name = "query" - # It's not a part of public API - # See https://mail.gnome.org/archives/commits-list/2012-May/msg07052.html - ignore = true - -[[object]] -name = "Gtk.AccelMap" +name = "Gtk.AccelLabel" status = "generate" - [[object.function]] - name = "foreach" - ignore = true #manual - [[object.function]] - name = "foreach_unfiltered" - ignore = true #manual +generate_builder = true [[object]] name = "Gtk.Actionable" status = "generate" +manual_traits = ["ActionableExtManual"] [[object.property]] #value glib.Variant name = "action-target" ignore = true +[[object]] +name = "Gtk.ActionBar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Adjustment" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.AlternativeTrigger" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.AppChooserButton" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.AppChooserDialog" status = "generate" +generate_builder = true [[object.function]] name = "get_widget" [object.function.return] nullable = false +[[object]] +name = "Gtk.AppChooserWidget" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Application" status = "generate" +generate_builder = true trait_name = "GtkApplicationExt" [[object.function]] name = "new" ignore = true +[[object]] +name = "Gtk.ApplicationWindow" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.AspectFrame" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Assistant" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.AssistantPage" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.BookmarkList" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.BoolFilter" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Box" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.BoxLayout" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Builder" status = "generate" +generate_builder = true manual_traits = ["BuilderExtManual"] [[object.function]] pattern = ".+_from_file" @@ -639,9 +526,25 @@ manual_traits = ["BuilderExtManual"] ignore = true doc_trait_name = "BuilderExtManual" +[[object]] +name = "Gtk.BuilderListItemFactory" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Button" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Calendar" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.CellArea" status = "generate" +generate_builder = false [[object.function]] pattern = "cell_[gs]et_property" ignore = true @@ -661,6 +564,16 @@ status = "generate" name = "path" transformation = "treepath" +[[object]] +name = "Gtk.CellAreaBox" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.CellAreaContext" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.CellRenderer" status = "generate" @@ -673,6 +586,7 @@ status = "generate" [[object]] name = "Gtk.CellRendererAccel" status = "generate" +generate_builder = true [[object.signal]] name = "accel-cleared" [[object.signal.parameter]] @@ -689,6 +603,7 @@ status = "generate" [[object]] name = "Gtk.CellRendererCombo" status = "generate" +generate_builder = true [[object.signal]] name = "changed" [[object.signal.parameter]] @@ -696,9 +611,30 @@ status = "generate" transformation = "treepath" new_name = "path" +[[object]] +name = "Gtk.CellRendererPixbuf" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.CellRendererProgress" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.CellRendererSpin" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.CellRendererSpinner" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.CellRendererText" status = "generate" +generate_builder = true [[object.signal]] name = "edited" [[object.signal.parameter]] @@ -720,6 +656,7 @@ status = "generate" [[object]] name = "Gtk.CellRendererToggle" status = "generate" +generate_builder = true [[object.signal]] name = "toggled" [[object.signal.parameter]] @@ -729,12 +666,28 @@ status = "generate" [[object]] name = "Gtk.CellView" status = "generate" +generate_builder = true [[object.function]] name = "set_displayed_row" [[object.function.parameter]] name = "path" nullable = false +[[object]] +name = "Gtk.CenterBox" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.CheckButton" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ColorButton" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.ColorChooser" status = "generate" @@ -745,9 +698,30 @@ manual_traits = ["ColorChooserExtManual"] ignore = true doc_trait_name = "ColorChooserExtManual" +[[object]] +name = "Gtk.ColorChooserDialog" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ColorChooserWidget" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ColumnView" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ColumnViewColumn" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.ComboBox" status = "generate" +generate_builder = true manual_traits = ["ComboBoxExtManual"] [[object.function]] name = "set_active_iter" @@ -767,9 +741,35 @@ manual_traits = ["ComboBoxExtManual"] #manual Option generate = ["notify"] +[[object]] +name = "Gtk.ComboBoxText" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Constraint" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ConstraintGuide" +status = "generate" +generate_builder = true +manual_traits = ["ConstraintGuideExtManual"] + [[object.function]] + name = "get_max_size" + ignore = true + [[object.function]] + name = "get_min_size" + ignore = true + [[object.function]] + name = "get_nat_size" + ignore = true + [[object]] name = "Gtk.Dialog" status = "generate" +generate_builder = true manual_traits = ["DialogExtManual"] [[object.function]] name = "add_button" @@ -788,6 +788,44 @@ manual_traits = ["DialogExtManual"] ignore = true doc_trait_name = "DialogExtManual" +[[object]] +name = "Gtk.DirectoryList" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.DragIcon" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.DragSource" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.DrawingArea" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.DropDown" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.DropTarget" +status = "generate" +generate_builder = true + [[object.signal]] + name = "drop" + ignore = true # manual, to be done + +[[object]] +name = "Gtk.DropTargetAsync" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Editable" status = "generate" @@ -808,6 +846,7 @@ manual_traits = ["EditableExtManual"] [[object]] name = "Gtk.Entry" status = "generate" +generate_builder = true [[object.function]] name = "get_buffer" [object.function.return] @@ -835,6 +874,8 @@ status = "generate" [[object]] name = "Gtk.EntryBuffer" status = "generate" +generate_builder = true +manual_traits = ["EntryBufferExtManual"] #manual [[object.function]] name = "new" @@ -872,8 +913,9 @@ status = "generate" [[object]] name = "Gtk.EntryCompletion" -manual_traits = ["EntryCompletionExtManual"] status = "generate" +generate_builder = true +manual_traits = ["EntryCompletionExtManual"] [[object.signal]] name = "insert-prefix" inhibit = true @@ -898,6 +940,16 @@ status = "generate" name = "modifiers" inhibit = true +[[object]] +name = "Gtk.EventControllerScroll" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Expander" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.FileChooser" status = "generate" @@ -905,6 +957,81 @@ status = "generate" name = "add_choice" ignore = true #strange type of options and option_labels +[[object]] +name = "Gtk.FileChooserButton" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FileChooserDialog" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FileChooserNative" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FileChooserWidget" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FileFilter" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FilterListModel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Fixed" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FixedLayoutChild" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FlattenListModel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FlowBox" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FlowBoxChild" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FontButton" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FontChooserDialog" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.FontChooserWidget" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Frame" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Gesture" status = "generate" @@ -914,9 +1041,25 @@ status = "generate" name = "sequence" const = true +[[object]] +name = "Gtk.GestureLongPress" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.GesturePan" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.GestureSingle" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.GLArea" status = "generate" +generate_builder = true [[object.signal]] pattern = "render" inhibit = true @@ -925,23 +1068,63 @@ status = "generate" [object.signal.return] nullable = true +[[object]] +name = "Gtk.Grid" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.GridLayout" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.GridLayoutChild" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.GridView" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.HeaderBar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.IconPaintable" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.IconTheme" status = "generate" +generate_builder = true [[object.function]] name = "get_icon_sizes" ignore = true # TODO gtk3 ignored some more array functions + [[object.function]] + name = "set_resource_path" + ignore = true # manual [[object]] name = "Gtk.IconView" status = "generate" +generate_builder = true [[object.function]] pattern = ".+" [[object.function.parameter]] name = "path" const = true +[[object]] +name = "Gtk.Image" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.IMContext" status = "generate" @@ -963,23 +1146,56 @@ manual_traits = ["IMContextSimpleExtManual"] name = "add_table" ignore = true # We don't understand API +[[object]] +name = "Gtk.InfoBar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.KeyvalTrigger" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Label" status = "generate" +generate_builder = true [[object.signal]] name = "activate-link" inhibit = true +[[object]] +name = "Gtk.LevelBar" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.LinkButton" status = "generate" +generate_builder = true [[object.signal]] name = "activate-link" inhibit = true +[[object]] +name = "Gtk.ListBox" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ListBoxRow" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ListItem" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.ListStore" status = "generate" +generate_builder = true trait_name = "GtkListStoreExt" manual_traits = ["GtkListStoreExtManual"] [[object.function]] @@ -1006,6 +1222,26 @@ manual_traits = ["GtkListStoreExtManual"] name = "b" const = true +[[object]] +name = "Gtk.ListView" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.LockButton" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.MapListModel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.MediaControls" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.MediaStream" status = "generate" @@ -1015,25 +1251,44 @@ status = "generate" ignore = true [[object]] -name = "Gtk.Menu" +name = "Gtk.MenuButton" status = "generate" -trait_name = "GtkMenuExt" +generate_builder = true [[object]] -name = "Gtk.MenuItem" +name = "Gtk.MessageDialog" status = "generate" -trait_name = "GtkMenuItemExt" +generate_builder = true [[object]] -name = "Gtk.MenuShell" +name = "Gtk.MnemonicTrigger" status = "generate" - [[object.signal]] - name = "move-selected" - inhibit = true +generate_builder = true + +[[object]] +name = "Gtk.MountOperation" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.MultiSelection" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.NamedAction" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.NoSelection" +status = "generate" +generate_builder = true [[object]] name = "Gtk.Notebook" status = "generate" +generate_builder = true manual_traits = ["NotebookExtManual"] # The following functions need integer type adjustments [[object.function]] @@ -1089,14 +1344,31 @@ manual_traits = ["NotebookExtManual"] ignore = true doc_trait_name = "NotebookExtManual" +[[object]] +name = "Gtk.NotebookPage" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.NumericSorter" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Overlay" status = "generate" +generate_builder = true manual_traits = ["OverlayExtManual"] +[[object]] +name = "Gtk.OverlayLayoutChild" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.PadController" status = "generate" +generate_builder = true [[object.function]] name = "set_action_entries" ignore = true @@ -1114,6 +1386,11 @@ status = "generate" name = "size" const = true +[[object]] +name = "Gtk.Paned" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.PaperSize" status = "generate" @@ -1131,6 +1408,31 @@ status = "generate" name = "size2" const = true +[[object]] +name = "Gtk.PasswordEntry" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Picture" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Popover" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.PopoverMenu" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.PopoverMenuBar" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.PrintContext" status = "generate" @@ -1141,6 +1443,11 @@ status = "generate" # cairo::Context is reference-counted const = true +[[object]] +name = "Gtk.PrintOperation" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.PrintSettings" status = "generate" @@ -1158,36 +1465,18 @@ status = "generate" const = true [[object]] -name = "Gtk.RadioButton" +name = "Gtk.ProgressBar" status = "generate" - [[object.function]] - pattern = ".+_from_widget" - [[object.function.parameter]] - name = "radio_group_member" - nullable = false - [[object.function]] - name = "new" - #manual - ignore = true - [[object.function]] - name = "new_with_label" - #manual - ignore = true - [[object.function]] - name = "new_with_mnemonic" - #manual - ignore = true - [[object.function]] - name = "set_group" - ignore = true +generate_builder = true [[object]] -name = "Gtk.RadioMenuItem" +name = "Gtk.RadioButton" status = "generate" +generate_builder = true [[object.function]] pattern = ".+_from_widget" [[object.function.parameter]] - name = "group" + name = "radio_group_member" nullable = false [[object.function]] name = "new" @@ -1205,29 +1494,10 @@ status = "generate" name = "set_group" ignore = true -[[object]] -name = "Gtk.RadioToolButton" -status = "generate" - [[object.function]] - pattern = ".+_from_widget" - [[object.function.parameter]] - name = "group" - nullable = false - [[object.function]] - name = "new" - #manual - ignore = true - [[object.function]] - name = "new_from_stock" - #manual - ignore = true - [[object.function]] - name = "set_group" - ignore = true - [[object]] name = "Gtk.Range" status = "generate" +generate_builder = true [[object.function]] name = "get_adjustment" [object.function.return] @@ -1236,60 +1506,140 @@ status = "generate" name = "change-value" inhibit = true +[[object]] +name = "Gtk.RecentManager" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Revealer" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Scale" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.ScaleButton" status = "generate" +generate_builder = true [[object.function]] name = "get_adjustment" [object.function.return] nullable = false [[object]] -name = "Gtk.SelectionData" +name = "Gtk.Scrollbar" status = "generate" - [[object.function]] - name = "get_data" - ignore = true - [[object.function]] - name = "get_data_type" - [object.function.return] - nullable = false - [[object.function]] - name = "get_data_with_length" - ignore = true - [[object.function]] - name = "get_target" - [object.function.return] - nullable = false - [[object.function]] - name = "set" - [[object.function.parameter]] - name = "selection_data" - const = true - [[object.function]] - name = "set_pixbuf" - [[object.function.parameter]] - name = "selection_data" - const = true - [[object.function]] - name = "set_text" - [[object.function.parameter]] - name = "selection_data" - const = true - [[object.function]] - name = "set_uris" - [[object.function.parameter]] - name = "selection_data" - const = true +generate_builder = true + +[[object]] +name = "Gtk.ScrolledWindow" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.SearchBar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.SearchEntry" +status = "generate" +generate_builder = true + + +[[object]] +name = "Gtk.SelectionFilterModel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Separator" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Settings" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Shortcut" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ShortcutController" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ShortcutLabel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ShortcutsGroup" +status = "generate" +generate_builder = true [[object]] name = "Gtk.ShortcutsSection" status = "generate" +generate_builder = true [[object.signal]] name = "change-current-page" #manual ignore = true +[[object]] +name = "Gtk.ShortcutsShortcut" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ShortcutsWindow" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.ShortcutTrigger" +status = "generate" +manual_traits = ["ShortcutTriggerExtManual"] + [[object.function]] + name = "equal" + # manual, complains about the trait IsA being so generic + ignore = true + [[object.function]] + name = "hash" + ignore = true + [[object.function]] + name = "compare" + ignore = true + +[[object]] +name = "Gtk.SignalAction" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.SingleSelection" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.SizeGroup" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.SliceListModel" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Snapshot" status = "generate" @@ -1302,9 +1652,15 @@ status = "generate" #manual ignore = true +[[object]] +name = "Gtk.SortListModel" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.SpinButton" status = "generate" +generate_builder = true manual_traits = ["SpinButtonExtManual"] [[object.function]] name = "get_adjustment" @@ -1314,9 +1670,63 @@ manual_traits = ["SpinButtonExtManual"] name = "output" inhibit = true +[[object]] +name = "Gtk.Spinner" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Stack" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StackPage" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StackSidebar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StackSwitcher" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Statusbar" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StringFilter" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StringObject" +status = "generate" + [[object.function]] + name = "get_string" + [object.function.return] + nullable = false + +[[object]] +name = "Gtk.StringSorter" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.StyleContext" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Switch" status = "generate" +generate_builder = true [[object.signal]] name = "state-set" inhibit = true @@ -1324,6 +1734,7 @@ status = "generate" [[object]] name = "Gtk.Text" status = "generate" +generate_builder = true [[object.signal]] pattern = ".+" #manual @@ -1337,6 +1748,7 @@ status = "generate" [[object]] name = "Gtk.TextBuffer" status = "generate" +generate_builder = true manual_traits = ["TextBufferExtManual"] [[object.function]] name = "register_deserialize_tagset" @@ -1365,9 +1777,15 @@ status = "generate" init_function_expression = "|_ptr| ()" clear_function_expression = "|_ptr| ()" +[[object]] +name = "Gtk.TextMark" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.TextTag" status = "generate" +generate_builder = true # TODO # [[object.property]] # name = "font-desc" @@ -1380,9 +1798,15 @@ status = "generate" # #value pango::TabArray # ignore = true +[[object]] +name = "Gtk.TextTagTable" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.TextView" status = "generate" +generate_builder = true [[object.function]] name = "im_context_filter_keypress" [[object.function.parameter]] @@ -1398,18 +1822,14 @@ status = "generate" const = true [[object]] -name = "Gtk.Toolbar" +name = "Gtk.ToggleButton" status = "generate" - [[object.signal]] - name = "popup-context-menu" - inhibit = true +generate_builder = true [[object]] -name = "Gtk.ToolItem" +name = "Gtk.TreeExpander" status = "generate" - [[object.signal]] - name = "create-menu-proxy" - inhibit = true +generate_builder = true [[object]] name = "Gtk.TreeIter" @@ -1417,6 +1837,21 @@ status = "generate" init_function_expression = "|_ptr| ()" clear_function_expression = "|_ptr| ()" +[[object]] +name = "Gtk.TreeListModel" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.TreeListRow" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.TreeListRowSorter" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.TreeModel" status = "generate" @@ -1472,6 +1907,7 @@ status = "generate" [[object]] name = "Gtk.TreeModelFilter" status = "generate" +generate_builder = true [[object.function]] name = "convert_child_path_to_path" [[object.function.parameter]] @@ -1500,6 +1936,7 @@ status = "generate" [[object]] name = "Gtk.TreeModelSort" status = "generate" +generate_builder = true [[object.function]] name = "convert_child_path_to_path" [[object.function.parameter]] @@ -1611,6 +2048,7 @@ status = "generate" [[object]] name = "Gtk.TreeSelection" status = "generate" +generate_builder = true [[object.function]] pattern = ".+" [[object.function.parameter]] @@ -1650,6 +2088,7 @@ manual_traits = ["TreeSortableExtManual"] [[object]] name = "Gtk.TreeStore" status = "generate" +generate_builder = true manual_traits = ["TreeStoreExtManual"] [[object.function]] pattern = ".+" @@ -1698,6 +2137,7 @@ manual_traits = ["TreeStoreExtManual"] [[object]] name = "Gtk.TreeView" status = "generate" +generate_builder = true [[object.function]] pattern = ".+" [[object.function.parameter]] @@ -1722,12 +2162,28 @@ status = "generate" [[object]] name = "Gtk.TreeViewColumn" status = "generate" +generate_builder = true [[object.function]] name = "cell_set_cell_data" [[object.function.parameter]] name = "iter" const = true +[[object]] +name = "Gtk.Video" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.Viewport" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.VolumeButton" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Widget" status = "generate" @@ -1778,9 +2234,15 @@ manual_traits = ["WidgetExtManual"] name = "mnemonic-activate" inhibit = true +[[object]] +name = "Gtk.WidgetPaintable" +status = "generate" +generate_builder = true + [[object]] name = "Gtk.Window" status = "generate" +generate_builder = true trait_name = "GtkWindowExt" manual_traits = ["GtkWindowExtManual"] [[object.function]] @@ -1796,3 +2258,14 @@ manual_traits = ["GtkWindowExtManual"] [[object.signal]] name = "close-request" inhibit = true + +[[object]] +name = "Gtk.WindowControls" +status = "generate" +generate_builder = true + +[[object]] +name = "Gtk.WindowHandle" +status = "generate" +generate_builder = true + diff --git a/gir b/gir index 83cc9addf972..ad40c013c474 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit 83cc9addf972e5f413a02b5e5352f6b6d53b0eaa +Subproject commit ad40c013c4745a5a8ed311022d76e6385ff134b8 diff --git a/gir-files b/gir-files index 22748fa889ff..cb01ad7f0c8d 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 22748fa889ff60b97e53966c31693a73a6249f82 +Subproject commit cb01ad7f0c8d319b4fcf5439706a20897d7a0707 diff --git a/src/accel_key.rs b/src/accel_key.rs deleted file mode 100644 index 87e247961670..000000000000 --- a/src/accel_key.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2013-2018, The Gtk-rs Project Developers. -// See the COPYRIGHT file at the top-level directory of this distribution. -// Licensed under the MIT license, see the LICENSE file or - -use gdk::ModifierType; -use glib::translate::*; -use gtk_sys; -use AccelFlags; - -#[repr(C)] -#[derive(Clone)] -pub struct AccelKey(gtk_sys::GtkAccelKey); - -impl AccelKey { - pub fn new(accel_key: u32, accel_mods: ModifierType, accel_flags: AccelFlags) -> AccelKey { - assert_initialized_main_thread!(); - AccelKey(gtk_sys::GtkAccelKey { - accel_key, - accel_mods: accel_mods.to_glib(), - accel_flags: accel_flags.to_glib(), - }) - } - - pub fn get_accel_key(&self) -> u32 { - self.0.accel_key - } - - pub fn get_accel_mods(&self) -> ModifierType { - from_glib(self.0.accel_mods) - } - - pub fn get_accel_flags(&self) -> AccelFlags { - from_glib(self.0.accel_flags) - } -} - -#[doc(hidden)] -impl FromGlibPtrNone<*mut gtk_sys::GtkAccelKey> for AccelKey { - unsafe fn from_glib_none(ptr: *mut gtk_sys::GtkAccelKey) -> Self { - AccelKey((*ptr).clone()) - } -} - -#[doc(hidden)] -impl FromGlibPtrBorrow<*mut gtk_sys::GtkAccelKey> for AccelKey { - unsafe fn from_glib_borrow(ptr: *mut gtk_sys::GtkAccelKey) -> Self { - AccelKey((*ptr).clone()) - } -} - -#[doc(hidden)] -impl<'a> ToGlibPtrMut<'a, *mut gtk_sys::GtkAccelKey> for AccelKey { - type Storage = &'a mut Self; - - fn to_glib_none_mut(&'a mut self) -> StashMut<*mut gtk_sys::GtkAccelKey, Self> { - StashMut(&mut self.0, self) - } -} - -#[doc(hidden)] -impl Uninitialized for AccelKey { - unsafe fn uninitialized() -> Self { - AccelKey::new(0, ModifierType::empty(), AccelFlags::empty()) - } -} diff --git a/src/accel_map.rs b/src/accel_map.rs deleted file mode 100644 index 60334028fc2f..000000000000 --- a/src/accel_map.rs +++ /dev/null @@ -1,62 +0,0 @@ -use gdk; -use gdk_sys; -use glib::translate::*; -use glib::GString; -use glib_sys; -use gtk_sys; -use libc; -use AccelMap; - -impl AccelMap { - pub fn foreach(foreach_func: P) { - assert_initialized_main_thread!(); - let foreach_func_data: P = foreach_func; - unsafe extern "C" fn foreach_func_func( - data: glib_sys::gpointer, - accel_path: *const libc::c_char, - accel_key: libc::c_uint, - accel_mods: gdk_sys::GdkModifierType, - changed: glib_sys::gboolean, - ) { - let accel_path: GString = from_glib_borrow(accel_path); - let accel_mods = from_glib(accel_mods); - let changed = from_glib(changed); - let callback: *mut P = data as *const _ as usize as *mut P; - (*callback)(accel_path.as_str(), accel_key, &accel_mods, changed); - } - let foreach_func = Some(foreach_func_func::

as _); - let super_callback0: &P = &foreach_func_data; - unsafe { - gtk_sys::gtk_accel_map_foreach( - super_callback0 as *const _ as usize as *mut _, - foreach_func, - ); - } - } - - pub fn foreach_unfiltered(foreach_func: P) { - assert_initialized_main_thread!(); - let foreach_func_data: P = foreach_func; - unsafe extern "C" fn foreach_func_func( - data: glib_sys::gpointer, - accel_path: *const libc::c_char, - accel_key: libc::c_uint, - accel_mods: gdk_sys::GdkModifierType, - changed: glib_sys::gboolean, - ) { - let accel_path: GString = from_glib_borrow(accel_path); - let accel_mods = from_glib(accel_mods); - let changed = from_glib(changed); - let callback: *mut P = data as *const _ as usize as *mut P; - (*callback)(accel_path.as_str(), accel_key, &accel_mods, changed); - } - let foreach_func = Some(foreach_func_func::

as _); - let super_callback0: &P = &foreach_func_data; - unsafe { - gtk_sys::gtk_accel_map_foreach_unfiltered( - super_callback0 as *const _ as usize as *mut _, - foreach_func, - ); - } - } -} diff --git a/src/auto/about_dialog.rs b/src/auto/about_dialog.rs index 08cd124cae18..ba69be9683ba 100644 --- a/src/auto/about_dialog.rs +++ b/src/auto/about_dialog.rs @@ -5,6 +5,7 @@ use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -17,23 +18,24 @@ use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use Application; -use Bin; use Buildable; -use Container; +use ConstraintTarget; use Dialog; use LayoutManager; use License; +use Native; use Overflow; use Root; +use ShortcutManager; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct AboutDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, Root; + pub struct AboutDialog(Object) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager; match fn { get_type => || gtk_sys::gtk_about_dialog_get_type(), @@ -45,1503 +47,1302 @@ impl AboutDialog { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_about_dialog_new()).unsafe_cast() } } -} -impl Default for AboutDialog { - fn default() -> Self { - Self::new() + pub fn add_credit_section(&self, section_name: &str, people: &[&str]) { + unsafe { + gtk_sys::gtk_about_dialog_add_credit_section( + self.to_glib_none().0, + section_name.to_glib_none().0, + people.to_glib_none().0, + ); + } } -} -#[derive(Clone, Default)] -pub struct AboutDialogBuilder { - artists: Option>, - authors: Option>, - comments: Option, - copyright: Option, - documenters: Option>, - license: Option, - license_type: Option, - logo: Option, - logo_icon_name: Option, - program_name: Option, - system_information: Option, - translator_credits: Option, - version: Option, - website: Option, - website_label: Option, - wrap_license: Option, - use_header_bar: Option, - accept_focus: Option, - application: Option, - attached_to: Option, - decorated: Option, - default_height: Option, - default_widget: Option, - default_width: Option, - deletable: Option, - destroy_with_parent: Option, - display: Option, - focus_on_map: Option, - focus_visible: Option, - hide_on_close: Option, - icon_name: Option, - mnemonics_visible: Option, - modal: Option, - resizable: Option, - startup_id: Option, - title: Option, - transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, - focus_widget: Option, -} + pub fn get_artists(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_artists( + self.to_glib_none().0, + )) + } + } -impl AboutDialogBuilder { - pub fn new() -> Self { - Self::default() + pub fn get_authors(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_authors( + self.to_glib_none().0, + )) + } } - pub fn build(self) -> AboutDialog { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref artists) = self.artists { - properties.push(("artists", artists)); + pub fn get_comments(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_comments( + self.to_glib_none().0, + )) } - if let Some(ref authors) = self.authors { - properties.push(("authors", authors)); + } + + pub fn get_copyright(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_copyright( + self.to_glib_none().0, + )) } - if let Some(ref comments) = self.comments { - properties.push(("comments", comments)); + } + + pub fn get_documenters(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_documenters( + self.to_glib_none().0, + )) } - if let Some(ref copyright) = self.copyright { - properties.push(("copyright", copyright)); + } + + pub fn get_license(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_license(self.to_glib_none().0)) } + } + + pub fn get_license_type(&self) -> License { + unsafe { + from_glib(gtk_sys::gtk_about_dialog_get_license_type( + self.to_glib_none().0, + )) } - if let Some(ref documenters) = self.documenters { - properties.push(("documenters", documenters)); + } + + pub fn get_logo(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_logo(self.to_glib_none().0)) } + } + + pub fn get_logo_icon_name(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_logo_icon_name( + self.to_glib_none().0, + )) } - if let Some(ref license) = self.license { - properties.push(("license", license)); + } + + pub fn get_program_name(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_program_name( + self.to_glib_none().0, + )) } - if let Some(ref license_type) = self.license_type { - properties.push(("license-type", license_type)); + } + + pub fn get_system_information(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_system_information( + self.to_glib_none().0, + )) } - if let Some(ref logo) = self.logo { - properties.push(("logo", logo)); + } + + pub fn get_translator_credits(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_translator_credits( + self.to_glib_none().0, + )) } - if let Some(ref logo_icon_name) = self.logo_icon_name { - properties.push(("logo-icon-name", logo_icon_name)); + } + + pub fn get_version(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_version(self.to_glib_none().0)) } + } + + pub fn get_website(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_about_dialog_get_website(self.to_glib_none().0)) } + } + + pub fn get_website_label(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_about_dialog_get_website_label( + self.to_glib_none().0, + )) } - if let Some(ref program_name) = self.program_name { - properties.push(("program-name", program_name)); + } + + pub fn get_wrap_license(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_about_dialog_get_wrap_license( + self.to_glib_none().0, + )) } - if let Some(ref system_information) = self.system_information { - properties.push(("system-information", system_information)); + } + + pub fn set_artists(&self, artists: &[&str]) { + unsafe { + gtk_sys::gtk_about_dialog_set_artists(self.to_glib_none().0, artists.to_glib_none().0); } - if let Some(ref translator_credits) = self.translator_credits { - properties.push(("translator-credits", translator_credits)); + } + + pub fn set_authors(&self, authors: &[&str]) { + unsafe { + gtk_sys::gtk_about_dialog_set_authors(self.to_glib_none().0, authors.to_glib_none().0); } - if let Some(ref version) = self.version { - properties.push(("version", version)); + } + + pub fn set_comments(&self, comments: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_comments( + self.to_glib_none().0, + comments.to_glib_none().0, + ); } - if let Some(ref website) = self.website { - properties.push(("website", website)); + } + + pub fn set_copyright(&self, copyright: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_copyright( + self.to_glib_none().0, + copyright.to_glib_none().0, + ); } - if let Some(ref website_label) = self.website_label { - properties.push(("website-label", website_label)); + } + + pub fn set_documenters(&self, documenters: &[&str]) { + unsafe { + gtk_sys::gtk_about_dialog_set_documenters( + self.to_glib_none().0, + documenters.to_glib_none().0, + ); } - if let Some(ref wrap_license) = self.wrap_license { - properties.push(("wrap-license", wrap_license)); + } + + pub fn set_license(&self, license: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_license(self.to_glib_none().0, license.to_glib_none().0); } - if let Some(ref use_header_bar) = self.use_header_bar { - properties.push(("use-header-bar", use_header_bar)); + } + + pub fn set_license_type(&self, license_type: License) { + unsafe { + gtk_sys::gtk_about_dialog_set_license_type( + self.to_glib_none().0, + license_type.to_glib(), + ); } - if let Some(ref accept_focus) = self.accept_focus { - properties.push(("accept-focus", accept_focus)); + } + + pub fn set_logo>(&self, logo: Option<&P>) { + unsafe { + gtk_sys::gtk_about_dialog_set_logo( + self.to_glib_none().0, + logo.map(|p| p.as_ref()).to_glib_none().0, + ); } - if let Some(ref application) = self.application { - properties.push(("application", application)); + } + + pub fn set_logo_icon_name(&self, icon_name: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_logo_icon_name( + self.to_glib_none().0, + icon_name.to_glib_none().0, + ); } - if let Some(ref attached_to) = self.attached_to { - properties.push(("attached-to", attached_to)); + } + + pub fn set_program_name(&self, name: &str) { + unsafe { + gtk_sys::gtk_about_dialog_set_program_name( + self.to_glib_none().0, + name.to_glib_none().0, + ); } - if let Some(ref decorated) = self.decorated { - properties.push(("decorated", decorated)); + } + + pub fn set_system_information(&self, system_information: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_system_information( + self.to_glib_none().0, + system_information.to_glib_none().0, + ); } - if let Some(ref default_height) = self.default_height { - properties.push(("default-height", default_height)); + } + + pub fn set_translator_credits(&self, translator_credits: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_translator_credits( + self.to_glib_none().0, + translator_credits.to_glib_none().0, + ); } - if let Some(ref default_widget) = self.default_widget { - properties.push(("default-widget", default_widget)); + } + + pub fn set_version(&self, version: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_version(self.to_glib_none().0, version.to_glib_none().0); } - 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)); + } + + pub fn set_website(&self, website: Option<&str>) { + unsafe { + gtk_sys::gtk_about_dialog_set_website(self.to_glib_none().0, website.to_glib_none().0); } - if let Some(ref destroy_with_parent) = self.destroy_with_parent { - properties.push(("destroy-with-parent", destroy_with_parent)); + } + + pub fn set_website_label(&self, website_label: &str) { + unsafe { + gtk_sys::gtk_about_dialog_set_website_label( + self.to_glib_none().0, + website_label.to_glib_none().0, + ); } - if let Some(ref display) = self.display { - properties.push(("display", display)); + } + + pub fn set_wrap_license(&self, wrap_license: bool) { + unsafe { + gtk_sys::gtk_about_dialog_set_wrap_license( + self.to_glib_none().0, + wrap_license.to_glib(), + ); } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); + } + + pub fn connect_activate_link glib::signal::Inhibit + 'static>( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn activate_link_trampoline< + F: Fn(&AboutDialog, &str) -> glib::signal::Inhibit + 'static, + >( + this: *mut gtk_sys::GtkAboutDialog, + uri: *mut libc::c_char, + f: glib_sys::gpointer, + ) -> glib_sys::gboolean { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &GString::from_glib_borrow(uri)).to_glib() } - if let Some(ref focus_visible) = self.focus_visible { - properties.push(("focus-visible", focus_visible)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"activate-link\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + activate_link_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref hide_on_close) = self.hide_on_close { - properties.push(("hide-on-close", hide_on_close)); + } + + pub fn connect_property_artists_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_artists_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref icon_name) = self.icon_name { - properties.push(("icon-name", icon_name)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::artists\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_artists_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref mnemonics_visible) = self.mnemonics_visible { - properties.push(("mnemonics-visible", mnemonics_visible)); + } + + pub fn connect_property_authors_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_authors_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref modal) = self.modal { - properties.push(("modal", modal)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::authors\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_authors_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref resizable) = self.resizable { - properties.push(("resizable", resizable)); + } + + pub fn connect_property_comments_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_comments_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref startup_id) = self.startup_id { - properties.push(("startup-id", startup_id)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::comments\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_comments_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref title) = self.title { - properties.push(("title", title)); + } + + pub fn connect_property_copyright_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_copyright_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref transient_for) = self.transient_for { - properties.push(("transient-for", transient_for)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::copyright\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_copyright_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); + } + + pub fn connect_property_documenters_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_documenters_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::documenters\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_documenters_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); + } + + pub fn connect_property_license_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_license_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::license\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_license_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::license-type\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_license_type_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); + } + + pub fn connect_property_logo_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_logo_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::logo\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_logo_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::logo-icon-name\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_logo_icon_name_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::program-name\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_program_name_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); + } + + pub fn connect_property_system_information_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_system_information_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::system-information\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_system_information_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::translator-credits\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_translator_credits_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); + } + + pub fn connect_property_version_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_version_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::version\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_version_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); + } + + pub fn connect_property_website_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_website_trampoline( + this: *mut gtk_sys::GtkAboutDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::website\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_website_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::website-label\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_website_label_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref name) = self.name { - properties.push(("name", name)); + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::wrap-license\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_wrap_license_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); + } +} + +impl Default for AboutDialog { + fn default() -> Self { + Self::new() + } +} + +#[derive(Clone, Default)] +pub struct AboutDialogBuilder { + artists: Option>, + authors: Option>, + comments: Option, + copyright: Option, + documenters: Option>, + license: Option, + license_type: Option, + logo: Option, + logo_icon_name: Option, + program_name: Option, + system_information: Option, + translator_credits: Option, + version: Option, + website: Option, + website_label: Option, + wrap_license: Option, + use_header_bar: Option, + application: Option, + child: Option, + decorated: Option, + default_height: Option, + default_widget: Option, + default_width: Option, + deletable: Option, + destroy_with_parent: Option, + display: Option, + focus_visible: Option, + focus_widget: Option, + hide_on_close: Option, + icon_name: Option, + mnemonics_visible: Option, + modal: Option, + resizable: Option, + startup_id: Option, + title: Option, + transient_for: Option, + can_focus: Option, + can_target: Option, + css_classes: Option>, + css_name: Option, + cursor: Option, + focus_on_click: Option, + focusable: Option, + halign: Option, + has_tooltip: Option, + height_request: Option, + hexpand: Option, + hexpand_set: Option, + layout_manager: Option, + margin_bottom: Option, + margin_end: Option, + margin_start: Option, + margin_top: Option, + name: Option, + opacity: Option, + overflow: Option, + receives_default: Option, + sensitive: Option, + tooltip_markup: Option, + tooltip_text: Option, + valign: Option, + vexpand: Option, + vexpand_set: Option, + visible: Option, + width_request: Option, + accessible_role: Option, +} + +impl AboutDialogBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> AboutDialog { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref artists) = self.artists { + properties.push(("artists", artists)); } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); + if let Some(ref authors) = self.authors { + properties.push(("authors", authors)); } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); + if let Some(ref comments) = self.comments { + properties.push(("comments", comments)); } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); + if let Some(ref copyright) = self.copyright { + properties.push(("copyright", copyright)); } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); + if let Some(ref documenters) = self.documenters { + properties.push(("documenters", documenters)); } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); + if let Some(ref license) = self.license { + properties.push(("license", license)); } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); + if let Some(ref license_type) = self.license_type { + properties.push(("license-type", license_type)); } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); + if let Some(ref logo) = self.logo { + properties.push(("logo", logo)); } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); + if let Some(ref logo_icon_name) = self.logo_icon_name { + properties.push(("logo-icon-name", logo_icon_name)); } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); + if let Some(ref program_name) = self.program_name { + properties.push(("program-name", program_name)); } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); + if let Some(ref system_information) = self.system_information { + properties.push(("system-information", system_information)); } - glib::Object::new(AboutDialog::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn artists(mut self, artists: Vec) -> Self { - self.artists = Some(artists); - self - } - - pub fn authors(mut self, authors: Vec) -> Self { - self.authors = Some(authors); - self - } - - pub fn comments(mut self, comments: &str) -> Self { - self.comments = Some(comments.to_string()); - self - } - - pub fn copyright(mut self, copyright: &str) -> Self { - self.copyright = Some(copyright.to_string()); - self - } - - pub fn documenters(mut self, documenters: Vec) -> Self { - self.documenters = Some(documenters); - self - } - - pub fn license(mut self, license: &str) -> Self { - self.license = Some(license.to_string()); - self - } - - pub fn license_type(mut self, license_type: License) -> Self { - self.license_type = Some(license_type); - self - } - - pub fn logo>(mut self, logo: &P) -> Self { - self.logo = Some(logo.clone().upcast()); - self - } - - pub fn logo_icon_name(mut self, logo_icon_name: &str) -> Self { - self.logo_icon_name = Some(logo_icon_name.to_string()); - self - } - - pub fn program_name(mut self, program_name: &str) -> Self { - self.program_name = Some(program_name.to_string()); - self - } - - pub fn system_information(mut self, system_information: &str) -> Self { - self.system_information = Some(system_information.to_string()); - self - } - - pub fn translator_credits(mut self, translator_credits: &str) -> Self { - self.translator_credits = Some(translator_credits.to_string()); - self - } - - pub fn version(mut self, version: &str) -> Self { - self.version = Some(version.to_string()); - self - } - - pub fn website(mut self, website: &str) -> Self { - self.website = Some(website.to_string()); - self - } - - pub fn website_label(mut self, website_label: &str) -> Self { - self.website_label = Some(website_label.to_string()); - self - } - - pub fn wrap_license(mut self, wrap_license: bool) -> Self { - self.wrap_license = Some(wrap_license); - self - } - - pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { - self.use_header_bar = Some(use_header_bar); - self - } - - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - - pub fn application>(mut self, application: &P) -> Self { - self.application = Some(application.clone().upcast()); - self - } - - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); - self - } - - pub fn decorated(mut self, decorated: bool) -> Self { - self.decorated = Some(decorated); - self - } - - pub fn default_height(mut self, default_height: i32) -> Self { - self.default_height = Some(default_height); - self - } - - pub fn default_widget>(mut self, default_widget: &P) -> Self { - self.default_widget = Some(default_widget.clone().upcast()); - self - } - - pub fn default_width(mut self, default_width: i32) -> Self { - self.default_width = Some(default_width); - self - } - - pub fn deletable(mut self, deletable: bool) -> Self { - self.deletable = Some(deletable); - self - } - - pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { - self.destroy_with_parent = Some(destroy_with_parent); - self - } - - pub fn display(mut self, display: &gdk::Display) -> Self { - self.display = Some(display.clone()); - self - } - - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); - self - } - - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); - self - } - - pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { - self.hide_on_close = Some(hide_on_close); - self - } - - pub fn icon_name(mut self, icon_name: &str) -> Self { - self.icon_name = Some(icon_name.to_string()); - self - } - - pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { - self.mnemonics_visible = Some(mnemonics_visible); - self - } - - pub fn modal(mut self, modal: bool) -> Self { - self.modal = Some(modal); - self - } - - pub fn resizable(mut self, resizable: bool) -> Self { - self.resizable = Some(resizable); - self - } - - pub fn startup_id(mut self, startup_id: &str) -> Self { - self.startup_id = Some(startup_id.to_string()); - self - } - - pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); - self - } - - pub fn transient_for>(mut self, transient_for: &P) -> Self { - self.transient_for = Some(transient_for.clone().upcast()); - self - } - - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self + 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 application) = self.application { + properties.push(("application", application)); + } + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref decorated) = self.decorated { + properties.push(("decorated", decorated)); + } + if let Some(ref default_height) = self.default_height { + properties.push(("default-height", default_height)); + } + if let Some(ref default_widget) = self.default_widget { + properties.push(("default-widget", default_widget)); + } + if let Some(ref default_width) = self.default_width { + properties.push(("default-width", default_width)); + } + if let Some(ref deletable) = self.deletable { + properties.push(("deletable", deletable)); + } + if let Some(ref destroy_with_parent) = self.destroy_with_parent { + properties.push(("destroy-with-parent", destroy_with_parent)); + } + if let Some(ref display) = self.display { + properties.push(("display", display)); + } + if let Some(ref focus_visible) = self.focus_visible { + properties.push(("focus-visible", focus_visible)); + } + if let Some(ref focus_widget) = self.focus_widget { + properties.push(("focus-widget", focus_widget)); + } + if let Some(ref hide_on_close) = self.hide_on_close { + properties.push(("hide-on-close", hide_on_close)); + } + if let Some(ref icon_name) = self.icon_name { + properties.push(("icon-name", icon_name)); + } + if let Some(ref mnemonics_visible) = self.mnemonics_visible { + properties.push(("mnemonics-visible", mnemonics_visible)); + } + if let Some(ref modal) = self.modal { + properties.push(("modal", modal)); + } + if let Some(ref resizable) = self.resizable { + properties.push(("resizable", resizable)); + } + if let Some(ref startup_id) = self.startup_id { + properties.push(("startup-id", startup_id)); + } + if let Some(ref title) = self.title { + properties.push(("title", title)); + } + if let Some(ref transient_for) = self.transient_for { + properties.push(("transient-for", transient_for)); + } + if let Some(ref can_focus) = self.can_focus { + properties.push(("can-focus", can_focus)); + } + if let Some(ref can_target) = self.can_target { + properties.push(("can-target", can_target)); + } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } + if let Some(ref css_name) = self.css_name { + properties.push(("css-name", css_name)); + } + if let Some(ref cursor) = self.cursor { + properties.push(("cursor", cursor)); + } + if let Some(ref focus_on_click) = self.focus_on_click { + properties.push(("focus-on-click", focus_on_click)); + } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } + if let Some(ref halign) = self.halign { + properties.push(("halign", halign)); + } + 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 layout_manager) = self.layout_manager { + properties.push(("layout-manager", layout_manager)); + } + if let Some(ref margin_bottom) = self.margin_bottom { + properties.push(("margin-bottom", margin_bottom)); + } + if let Some(ref margin_end) = self.margin_end { + properties.push(("margin-end", margin_end)); + } + if let Some(ref margin_start) = self.margin_start { + properties.push(("margin-start", margin_start)); + } + if let Some(ref margin_top) = self.margin_top { + properties.push(("margin-top", margin_top)); + } + if let Some(ref name) = self.name { + properties.push(("name", name)); + } + if let Some(ref opacity) = self.opacity { + properties.push(("opacity", opacity)); + } + if let Some(ref overflow) = self.overflow { + properties.push(("overflow", overflow)); + } + if let Some(ref receives_default) = self.receives_default { + properties.push(("receives-default", receives_default)); + } + if let Some(ref sensitive) = self.sensitive { + properties.push(("sensitive", sensitive)); + } + if let Some(ref tooltip_markup) = self.tooltip_markup { + properties.push(("tooltip-markup", tooltip_markup)); + } + if let Some(ref tooltip_text) = self.tooltip_text { + properties.push(("tooltip-text", tooltip_text)); + } + if let Some(ref valign) = self.valign { + properties.push(("valign", valign)); + } + if let Some(ref vexpand) = self.vexpand { + properties.push(("vexpand", vexpand)); + } + if let Some(ref vexpand_set) = self.vexpand_set { + properties.push(("vexpand-set", vexpand_set)); + } + if let Some(ref visible) = self.visible { + properties.push(("visible", visible)); + } + if let Some(ref width_request) = self.width_request { + properties.push(("width-request", width_request)); + } + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } + let ret = glib::Object::new(AboutDialog::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); + pub fn artists(mut self, artists: Vec) -> Self { + self.artists = Some(artists); self } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); + pub fn authors(mut self, authors: Vec) -> Self { + self.authors = Some(authors); self } - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); + pub fn comments(mut self, comments: &str) -> Self { + self.comments = Some(comments.to_string()); self } - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); + pub fn copyright(mut self, copyright: &str) -> Self { + self.copyright = Some(copyright.to_string()); self } - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); + pub fn documenters(mut self, documenters: Vec) -> Self { + self.documenters = Some(documenters); self } - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); + pub fn license(mut self, license: &str) -> Self { + self.license = Some(license.to_string()); self } - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); + pub fn license_type(mut self, license_type: License) -> Self { + self.license_type = Some(license_type); self } - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); + pub fn logo>(mut self, logo: &P) -> Self { + self.logo = Some(logo.clone().upcast()); self } - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); + 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 sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); + pub fn program_name(mut self, program_name: &str) -> Self { + self.program_name = Some(program_name.to_string()); self } - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); + pub fn system_information(mut self, system_information: &str) -> Self { + self.system_information = Some(system_information.to_string()); self } - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); + pub fn translator_credits(mut self, translator_credits: &str) -> Self { + self.translator_credits = Some(translator_credits.to_string()); self } - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); + pub fn version(mut self, version: &str) -> Self { + self.version = Some(version.to_string()); self } - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); + pub fn website(mut self, website: &str) -> Self { + self.website = Some(website.to_string()); self } - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); + pub fn website_label(mut self, website_label: &str) -> Self { + self.website_label = Some(website_label.to_string()); self } - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); + pub fn wrap_license(mut self, wrap_license: bool) -> Self { + self.wrap_license = Some(wrap_license); self } - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); + pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { + self.use_header_bar = Some(use_header_bar); self } - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); + pub fn application>(mut self, application: &P) -> Self { + self.application = Some(application.clone().upcast()); self } -} - -pub const NONE_ABOUT_DIALOG: Option<&AboutDialog> = None; - -pub trait AboutDialogExt: 'static { - fn add_credit_section(&self, section_name: &str, people: &[&str]); - - fn get_artists(&self) -> Vec; - - fn get_authors(&self) -> Vec; - - fn get_comments(&self) -> Option; - - fn get_copyright(&self) -> Option; - - fn get_documenters(&self) -> Vec; - - fn get_license(&self) -> Option; - - fn get_license_type(&self) -> License; - - fn get_logo(&self) -> Option; - - fn get_logo_icon_name(&self) -> Option; - - fn get_program_name(&self) -> Option; - - fn get_system_information(&self) -> Option; - - fn get_translator_credits(&self) -> Option; - - fn get_version(&self) -> Option; - - fn get_website(&self) -> Option; - - fn get_website_label(&self) -> Option; - - fn get_wrap_license(&self) -> bool; - - fn set_artists(&self, artists: &[&str]); - - fn set_authors(&self, authors: &[&str]); - - fn set_comments(&self, comments: Option<&str>); - - fn set_copyright(&self, copyright: Option<&str>); - - fn set_documenters(&self, documenters: &[&str]); - - fn set_license(&self, license: Option<&str>); - - fn set_license_type(&self, license_type: License); - - fn set_logo>(&self, logo: Option<&P>); - - fn set_logo_icon_name(&self, icon_name: Option<&str>); - - fn set_program_name(&self, name: &str); - - fn set_system_information(&self, system_information: Option<&str>); - - fn set_translator_credits(&self, translator_credits: Option<&str>); - - fn set_version(&self, version: Option<&str>); - - fn set_website(&self, website: Option<&str>); - - fn set_website_label(&self, website_label: &str); - - fn set_wrap_license(&self, wrap_license: bool); - - fn connect_activate_link glib::signal::Inhibit + 'static>( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_artists_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_authors_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_comments_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_copyright_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_documenters_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_license_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_license_type_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_logo_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_logo_icon_name_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_program_name_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_system_information_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_translator_credits_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_version_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_website_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_website_label_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_wrap_license_notify(&self, f: F) - -> SignalHandlerId; -} - -impl> AboutDialogExt for O { - fn add_credit_section(&self, section_name: &str, people: &[&str]) { - unsafe { - 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 { - unsafe { - FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_artists( - self.as_ref().to_glib_none().0, - )) - } - } - - fn get_authors(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_authors( - self.as_ref().to_glib_none().0, - )) - } - } - - fn get_comments(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_comments( - self.as_ref().to_glib_none().0, - )) - } + + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); + self } - fn get_copyright(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_copyright( - self.as_ref().to_glib_none().0, - )) - } + pub fn decorated(mut self, decorated: bool) -> Self { + self.decorated = Some(decorated); + self } - fn get_documenters(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_about_dialog_get_documenters( - self.as_ref().to_glib_none().0, - )) - } + pub fn default_height(mut self, default_height: i32) -> Self { + self.default_height = Some(default_height); + self } - fn get_license(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_license( - self.as_ref().to_glib_none().0, - )) - } + pub fn default_widget>(mut self, default_widget: &P) -> Self { + self.default_widget = Some(default_widget.clone().upcast()); + self } - fn get_license_type(&self) -> License { - unsafe { - from_glib(gtk_sys::gtk_about_dialog_get_license_type( - self.as_ref().to_glib_none().0, - )) - } + pub fn default_width(mut self, default_width: i32) -> Self { + self.default_width = Some(default_width); + self } - fn get_logo(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_logo( - self.as_ref().to_glib_none().0, - )) - } + pub fn deletable(mut self, deletable: bool) -> Self { + self.deletable = Some(deletable); + self } - fn get_logo_icon_name(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_logo_icon_name( - self.as_ref().to_glib_none().0, - )) - } + pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self { + self.destroy_with_parent = Some(destroy_with_parent); + self } - fn get_program_name(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_program_name( - self.as_ref().to_glib_none().0, - )) - } + pub fn display(mut self, display: &gdk::Display) -> Self { + self.display = Some(display.clone()); + self } - fn get_system_information(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_system_information( - self.as_ref().to_glib_none().0, - )) - } + pub fn focus_visible(mut self, focus_visible: bool) -> Self { + self.focus_visible = Some(focus_visible); + self } - fn get_translator_credits(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_translator_credits( - self.as_ref().to_glib_none().0, - )) - } + pub fn focus_widget>(mut self, focus_widget: &P) -> Self { + self.focus_widget = Some(focus_widget.clone().upcast()); + self } - fn get_version(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_version( - self.as_ref().to_glib_none().0, - )) - } + pub fn hide_on_close(mut self, hide_on_close: bool) -> Self { + self.hide_on_close = Some(hide_on_close); + self } - fn get_website(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_website( - self.as_ref().to_glib_none().0, - )) - } + pub fn icon_name(mut self, icon_name: &str) -> Self { + self.icon_name = Some(icon_name.to_string()); + self } - fn get_website_label(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_about_dialog_get_website_label( - self.as_ref().to_glib_none().0, - )) - } + pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self { + self.mnemonics_visible = Some(mnemonics_visible); + self } - fn get_wrap_license(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_about_dialog_get_wrap_license( - self.as_ref().to_glib_none().0, - )) - } + pub fn modal(mut self, modal: bool) -> Self { + self.modal = Some(modal); + self } - fn set_artists(&self, artists: &[&str]) { - unsafe { - gtk_sys::gtk_about_dialog_set_artists( - self.as_ref().to_glib_none().0, - artists.to_glib_none().0, - ); - } + pub fn resizable(mut self, resizable: bool) -> Self { + self.resizable = Some(resizable); + self } - fn set_authors(&self, authors: &[&str]) { - unsafe { - gtk_sys::gtk_about_dialog_set_authors( - self.as_ref().to_glib_none().0, - authors.to_glib_none().0, - ); - } + pub fn startup_id(mut self, startup_id: &str) -> Self { + self.startup_id = Some(startup_id.to_string()); + self } - fn set_comments(&self, comments: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_comments( - self.as_ref().to_glib_none().0, - comments.to_glib_none().0, - ); - } + pub fn title(mut self, title: &str) -> Self { + self.title = Some(title.to_string()); + self } - fn set_copyright(&self, copyright: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_copyright( - self.as_ref().to_glib_none().0, - copyright.to_glib_none().0, - ); - } + pub fn transient_for>(mut self, transient_for: &P) -> Self { + self.transient_for = Some(transient_for.clone().upcast()); + self } - fn set_documenters(&self, documenters: &[&str]) { - unsafe { - gtk_sys::gtk_about_dialog_set_documenters( - self.as_ref().to_glib_none().0, - documenters.to_glib_none().0, - ); - } + pub fn can_focus(mut self, can_focus: bool) -> Self { + self.can_focus = Some(can_focus); + self } - fn set_license(&self, license: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_license( - self.as_ref().to_glib_none().0, - license.to_glib_none().0, - ); - } + pub fn can_target(mut self, can_target: bool) -> Self { + self.can_target = Some(can_target); + self } - fn set_license_type(&self, license_type: License) { - unsafe { - gtk_sys::gtk_about_dialog_set_license_type( - self.as_ref().to_glib_none().0, - license_type.to_glib(), - ); - } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self } - fn set_logo>(&self, logo: Option<&P>) { - unsafe { - gtk_sys::gtk_about_dialog_set_logo( - self.as_ref().to_glib_none().0, - logo.map(|p| p.as_ref()).to_glib_none().0, - ); - } + pub fn css_name(mut self, css_name: &str) -> Self { + self.css_name = Some(css_name.to_string()); + self } - fn set_logo_icon_name(&self, icon_name: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_logo_icon_name( - self.as_ref().to_glib_none().0, - icon_name.to_glib_none().0, - ); - } + pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { + self.cursor = Some(cursor.clone()); + self } - fn set_program_name(&self, name: &str) { - unsafe { - gtk_sys::gtk_about_dialog_set_program_name( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - ); - } + pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { + self.focus_on_click = Some(focus_on_click); + self } - fn set_system_information(&self, system_information: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_system_information( - self.as_ref().to_glib_none().0, - system_information.to_glib_none().0, - ); - } + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); + self } - fn set_translator_credits(&self, translator_credits: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_translator_credits( - self.as_ref().to_glib_none().0, - translator_credits.to_glib_none().0, - ); - } + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); + self } - fn set_version(&self, version: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_version( - self.as_ref().to_glib_none().0, - version.to_glib_none().0, - ); - } + pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { + self.has_tooltip = Some(has_tooltip); + self } - fn set_website(&self, website: Option<&str>) { - unsafe { - gtk_sys::gtk_about_dialog_set_website( - self.as_ref().to_glib_none().0, - website.to_glib_none().0, - ); - } + pub fn height_request(mut self, height_request: i32) -> Self { + self.height_request = Some(height_request); + self } - fn set_website_label(&self, website_label: &str) { - unsafe { - gtk_sys::gtk_about_dialog_set_website_label( - self.as_ref().to_glib_none().0, - website_label.to_glib_none().0, - ); - } + pub fn hexpand(mut self, hexpand: bool) -> Self { + self.hexpand = Some(hexpand); + self } - fn set_wrap_license(&self, wrap_license: bool) { - unsafe { - gtk_sys::gtk_about_dialog_set_wrap_license( - self.as_ref().to_glib_none().0, - wrap_license.to_glib(), - ); - } + pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { + self.hexpand_set = Some(hexpand_set); + self } - fn connect_activate_link glib::signal::Inhibit + 'static>( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn activate_link_trampoline< - P, - F: Fn(&P, &str) -> glib::signal::Inhibit + 'static, - >( - 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_ = 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), - ) - } + pub fn layout_manager>(mut self, layout_manager: &P) -> Self { + self.layout_manager = Some(layout_manager.clone().upcast()); + self } - 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(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), - ) - } + pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { + self.margin_bottom = Some(margin_bottom); + self } - 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(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), - ) - } + pub fn margin_end(mut self, margin_end: i32) -> Self { + self.margin_end = Some(margin_end); + self } - 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(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), - ) - } + pub fn margin_start(mut self, margin_start: i32) -> Self { + self.margin_start = Some(margin_start); + self } - 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(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), - ) - } + pub fn margin_top(mut self, margin_top: i32) -> Self { + self.margin_top = Some(margin_top); + self } - 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(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), - ) - } + pub fn name(mut self, name: &str) -> Self { + self.name = Some(name.to_string()); + self } - 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(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), - ) - } + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self } - 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(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), - ) - } + pub fn overflow(mut self, overflow: Overflow) -> Self { + self.overflow = Some(overflow); + self } - 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(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), - ) - } + pub fn receives_default(mut self, receives_default: bool) -> Self { + self.receives_default = Some(receives_default); + self } - 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(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), - ) - } + pub fn sensitive(mut self, sensitive: bool) -> Self { + self.sensitive = Some(sensitive); + self } - 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(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), - ) - } + pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { + self.tooltip_markup = Some(tooltip_markup.to_string()); + self } - fn connect_property_system_information_notify( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn notify_system_information_trampoline( - this: *mut gtk_sys::GtkAboutDialog, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AboutDialog::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::system-information\0".as_ptr() as *const _, - Some(transmute( - notify_system_information_trampoline:: as usize, - )), - Box_::into_raw(f), - ) - } + pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { + self.tooltip_text = Some(tooltip_text.to_string()); + self } - 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(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), - ) - } + pub fn valign(mut self, valign: Align) -> Self { + self.valign = Some(valign); + self } - 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(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), - ) - } + pub fn vexpand(mut self, vexpand: bool) -> Self { + self.vexpand = Some(vexpand); + self } - 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(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), - ) - } + pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { + self.vexpand_set = Some(vexpand_set); + self } - 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(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), - ) - } + pub fn visible(mut self, visible: bool) -> Self { + self.visible = Some(visible); + self } - 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(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), - ) - } + pub fn width_request(mut self, width_request: i32) -> Self { + self.width_request = Some(width_request); + self + } + + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self } } diff --git a/src/auto/accel_group.rs b/src/auto/accel_group.rs deleted file mode 100644 index 857e97fc5a4c..000000000000 --- a/src/auto/accel_group.rs +++ /dev/null @@ -1,354 +0,0 @@ -// 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_sys; -use glib; -use glib::object::Cast; -use glib::object::IsA; -use glib::signal::connect_raw; -use glib::signal::SignalHandlerId; -use glib::translate::*; -use glib_sys; -use gobject_sys; -use gtk_sys; -use libc; -use std::boxed::Box as Box_; -use std::fmt; -use std::mem::transmute; -use AccelFlags; -use AccelKey; - -glib_wrapper! { - pub struct AccelGroup(Object); - - match fn { - 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_none(gtk_sys::gtk_accel_group_from_accel_closure( - closure.to_glib_none().0, - )) - } - } -} - -impl Default for AccelGroup { - fn default() -> Self { - Self::new() - } -} - -pub const NONE_ACCEL_GROUP: Option<&AccelGroup> = None; - -pub trait AccelGroupExt: 'static { - fn activate>( - &self, - accel_quark: glib::Quark, - acceleratable: &P, - accel_key: u32, - accel_mods: gdk::ModifierType, - ) -> bool; - - fn connect( - &self, - accel_key: u32, - accel_mods: gdk::ModifierType, - accel_flags: AccelFlags, - closure: &glib::Closure, - ); - - 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 bool>(&self, find_func: P) -> Option; - - fn get_is_locked(&self) -> bool; - - fn get_modifier_mask(&self) -> gdk::ModifierType; - - fn lock(&self); - - fn unlock(&self); - - 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_property_is_locked_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_modifier_mask_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -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: &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: &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(&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(gtk_sys::gtk_accel_group_disconnect_key( - self.as_ref().to_glib_none().0, - accel_key, - accel_mods.to_glib(), - )) - } - } - - fn find bool>(&self, find_func: P) -> Option { - let find_func_data: P = find_func; - unsafe extern "C" fn find_func_func bool>( - key: *mut gtk_sys::GtkAccelKey, - closure: *mut gobject_sys::GClosure, - data: glib_sys::gpointer, - ) -> glib_sys::gboolean { - let key = from_glib_borrow(key); - let closure = from_glib_borrow(closure); - let callback: *mut P = data as *const _ as usize as *mut P; - let res = (*callback)(&key, &closure); - res.to_glib() - } - let find_func = Some(find_func_func::

as _); - let super_callback0: &P = &find_func_data; - unsafe { - from_glib_none(gtk_sys::gtk_accel_group_find( - self.as_ref().to_glib_none().0, - find_func, - super_callback0 as *const _ as usize as *mut _, - )) - } - } - - fn get_is_locked(&self) -> bool { - unsafe { - 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(gtk_sys::gtk_accel_group_get_modifier_mask( - self.as_ref().to_glib_none().0, - )) - } - } - - fn lock(&self) { - unsafe { - gtk_sys::gtk_accel_group_lock(self.as_ref().to_glib_none().0); - } - } - - fn unlock(&self) { - unsafe { - gtk_sys::gtk_accel_group_unlock(self.as_ref().to_glib_none().0); - } - } - - 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_ = 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 { - 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(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 { - 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(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), - ) - } - } -} - -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 index 720ea0ec2a8e..7e7d723de599 100644 --- a/src/auto/accel_label.rs +++ b/src/auto/accel_label.rs @@ -3,31 +3,32 @@ // DO NOT EDIT use gdk; -use glib; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::ToValue; -use glib::Value; use glib_sys; -use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use Buildable; +use ConstraintTarget; use LayoutManager; use Overflow; use Widget; glib_wrapper! { - pub struct AccelLabel(Object) @extends Widget, @implements Buildable; + pub struct AccelLabel(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget; match fn { get_type => || gtk_sys::gtk_accel_label_get_type(), @@ -42,29 +43,132 @@ impl AccelLabel { .unsafe_cast() } } + + pub fn get_accel(&self) -> (u32, gdk::ModifierType) { + unsafe { + let mut accelerator_key = mem::MaybeUninit::uninit(); + let mut accelerator_mods = mem::MaybeUninit::uninit(); + gtk_sys::gtk_accel_label_get_accel( + self.to_glib_none().0, + accelerator_key.as_mut_ptr(), + accelerator_mods.as_mut_ptr(), + ); + let accelerator_key = accelerator_key.assume_init(); + let accelerator_mods = accelerator_mods.assume_init(); + (accelerator_key, from_glib(accelerator_mods)) + } + } + + pub fn get_accel_width(&self) -> u32 { + unsafe { gtk_sys::gtk_accel_label_get_accel_width(self.to_glib_none().0) } + } + + pub fn get_label(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_accel_label_get_label(self.to_glib_none().0)) } + } + + pub fn get_use_underline(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_accel_label_get_use_underline( + self.to_glib_none().0, + )) + } + } + + pub fn refetch(&self) -> bool { + unsafe { from_glib(gtk_sys::gtk_accel_label_refetch(self.to_glib_none().0)) } + } + + pub fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType) { + unsafe { + gtk_sys::gtk_accel_label_set_accel( + self.to_glib_none().0, + accelerator_key, + accelerator_mods.to_glib(), + ); + } + } + + pub fn set_label(&self, text: &str) { + unsafe { + gtk_sys::gtk_accel_label_set_label(self.to_glib_none().0, text.to_glib_none().0); + } + } + + pub fn set_use_underline(&self, setting: bool) { + unsafe { + gtk_sys::gtk_accel_label_set_use_underline(self.to_glib_none().0, setting.to_glib()); + } + } + + pub fn connect_property_label_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_label_trampoline( + this: *mut gtk_sys::GtkAccelLabel, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::label\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_label_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_use_underline_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_use_underline_trampoline( + this: *mut gtk_sys::GtkAccelLabel, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::use-underline\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_use_underline_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } #[derive(Clone, Default)] pub struct AccelLabelBuilder { - accel_closure: Option, - accel_widget: Option, label: Option, use_underline: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -81,6 +185,7 @@ pub struct AccelLabelBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, } impl AccelLabelBuilder { @@ -90,12 +195,6 @@ impl AccelLabelBuilder { pub fn build(self) -> AccelLabel { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref accel_closure) = self.accel_closure { - properties.push(("accel-closure", accel_closure)); - } - if let Some(ref accel_widget) = self.accel_widget { - properties.push(("accel-widget", accel_widget)); - } if let Some(ref label) = self.label { properties.push(("label", label)); } @@ -108,24 +207,24 @@ impl AccelLabelBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -138,15 +237,9 @@ impl AccelLabelBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -195,20 +288,14 @@ impl AccelLabelBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - glib::Object::new(AccelLabel::static_type(), &properties) + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } + let ret = glib::Object::new(AccelLabel::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn accel_closure(mut self, accel_closure: &glib::Closure) -> Self { - self.accel_closure = Some(accel_closure.clone()); - self - } - - pub fn accel_widget>(mut self, accel_widget: &P) -> Self { - self.accel_widget = Some(accel_widget.clone().upcast()); - self + .downcast::() + .expect("downcast"); + ret } pub fn label(mut self, label: &str) -> Self { @@ -231,6 +318,11 @@ impl AccelLabelBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -241,23 +333,18 @@ impl AccelLabelBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -281,21 +368,11 @@ impl AccelLabelBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -375,264 +452,10 @@ impl AccelLabelBuilder { self.width_request = Some(width_request); self } -} - -pub const NONE_ACCEL_LABEL: Option<&AccelLabel> = None; - -pub trait AccelLabelExt: 'static { - fn get_accel(&self) -> (u32, gdk::ModifierType); - - fn get_accel_widget(&self) -> Option; - - fn get_accel_width(&self) -> u32; - - fn get_label(&self) -> Option; - - fn get_use_underline(&self) -> bool; - - fn refetch(&self) -> bool; - - fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType); - fn set_accel_closure(&self, accel_closure: Option<&glib::Closure>); - - fn set_accel_widget>(&self, accel_widget: Option<&P>); - - fn set_label(&self, text: &str); - - fn set_use_underline(&self, setting: bool); - - fn get_property_accel_closure(&self) -> Option; - - fn connect_property_accel_closure_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_accel_widget_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_label_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_use_underline_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AccelLabelExt for O { - fn get_accel(&self) -> (u32, gdk::ModifierType) { - unsafe { - let mut accelerator_key = mem::MaybeUninit::uninit(); - let mut accelerator_mods = mem::MaybeUninit::uninit(); - gtk_sys::gtk_accel_label_get_accel( - self.as_ref().to_glib_none().0, - accelerator_key.as_mut_ptr(), - accelerator_mods.as_mut_ptr(), - ); - let accelerator_key = accelerator_key.assume_init(); - let accelerator_mods = accelerator_mods.assume_init(); - (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 get_label(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_accel_label_get_label( - self.as_ref().to_glib_none().0, - )) - } - } - - fn get_use_underline(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_accel_label_get_use_underline( - 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 set_label(&self, text: &str) { - unsafe { - gtk_sys::gtk_accel_label_set_label( - self.as_ref().to_glib_none().0, - text.to_glib_none().0, - ); - } - } - - fn set_use_underline(&self, setting: bool) { - unsafe { - gtk_sys::gtk_accel_label_set_use_underline( - self.as_ref().to_glib_none().0, - setting.to_glib(), - ); - } - } - - fn get_property_accel_closure(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"accel-closure\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `accel-closure` getter") - } - } - - fn connect_property_accel_closure_notify( - &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), - ) - } - } - - fn connect_property_label_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_label_trampoline( - this: *mut gtk_sys::GtkAccelLabel, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::label\0".as_ptr() as *const _, - Some(transmute(notify_label_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - - fn connect_property_use_underline_notify( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn notify_use_underline_trampoline( - this: *mut gtk_sys::GtkAccelLabel, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AccelLabel::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::use-underline\0".as_ptr() as *const _, - Some(transmute( - notify_use_underline_trampoline:: as usize, - )), - Box_::into_raw(f), - ) - } + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self } } diff --git a/src/auto/accel_map.rs b/src/auto/accel_map.rs deleted file mode 100644 index 08ddcf86d3a1..000000000000 --- a/src/auto/accel_map.rs +++ /dev/null @@ -1,169 +0,0 @@ -// 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_sys; -use glib::object::ObjectType as ObjectType_; -use glib::signal::connect_raw; -use glib::signal::SignalHandlerId; -use glib::translate::*; -use glib::GString; -use glib_sys; -use gtk_sys; -use libc; -use std; -use std::boxed::Box as Box_; -use std::fmt; -use std::mem::transmute; -use AccelKey; - -glib_wrapper! { - pub struct AccelMap(Object); - - match fn { - get_type => || gtk_sys::gtk_accel_map_get_type(), - } -} - -impl AccelMap { - pub fn add_entry(accel_path: &str, accel_key: u32, accel_mods: gdk::ModifierType) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_add_entry( - accel_path.to_glib_none().0, - accel_key, - accel_mods.to_glib(), - ); - } - } - - pub fn add_filter(filter_pattern: &str) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_add_filter(filter_pattern.to_glib_none().0); - } - } - - pub fn change_entry( - accel_path: &str, - accel_key: u32, - accel_mods: gdk::ModifierType, - replace: bool, - ) -> bool { - assert_initialized_main_thread!(); - unsafe { - from_glib(gtk_sys::gtk_accel_map_change_entry( - accel_path.to_glib_none().0, - accel_key, - accel_mods.to_glib(), - replace.to_glib(), - )) - } - } - - pub fn get() -> Option { - assert_initialized_main_thread!(); - unsafe { from_glib_none(gtk_sys::gtk_accel_map_get()) } - } - - pub fn load>(file_name: P) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_load(file_name.as_ref().to_glib_none().0); - } - } - - pub fn load_fd(fd: i32) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_load_fd(fd); - } - } - - //pub fn load_scanner(scanner: /*Ignored*/&mut glib::Scanner) { - // unsafe { TODO: call gtk_sys:gtk_accel_map_load_scanner() } - //} - - pub fn lock_path(accel_path: &str) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_lock_path(accel_path.to_glib_none().0); - } - } - - pub fn lookup_entry(accel_path: &str) -> Option { - assert_initialized_main_thread!(); - unsafe { - let mut key = AccelKey::uninitialized(); - let ret = from_glib(gtk_sys::gtk_accel_map_lookup_entry( - accel_path.to_glib_none().0, - key.to_glib_none_mut().0, - )); - if ret { - Some(key) - } else { - None - } - } - } - - pub fn save>(file_name: P) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_save(file_name.as_ref().to_glib_none().0); - } - } - - pub fn save_fd(fd: i32) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_save_fd(fd); - } - } - - pub fn unlock_path(accel_path: &str) { - assert_initialized_main_thread!(); - unsafe { - gtk_sys::gtk_accel_map_unlock_path(accel_path.to_glib_none().0); - } - } - - pub fn connect_changed( - &self, - f: F, - ) -> SignalHandlerId { - unsafe extern "C" fn changed_trampoline< - F: Fn(&AccelMap, &str, u32, gdk::ModifierType) + 'static, - >( - this: *mut gtk_sys::GtkAccelMap, - accel_path: *mut libc::c_char, - accel_key: libc::c_uint, - accel_mods: gdk_sys::GdkModifierType, - f: glib_sys::gpointer, - ) { - let f: &F = &*(f as *const F); - f( - &from_glib_borrow(this), - &GString::from_glib_borrow(accel_path), - accel_key, - from_glib(accel_mods), - ) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"changed\0".as_ptr() as *const _, - Some(transmute(changed_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } -} - -impl fmt::Display for AccelMap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "AccelMap") - } -} diff --git a/src/auto/accessible.rs b/src/auto/accessible.rs index a765a4e49a8e..b89966a8615c 100644 --- a/src/auto/accessible.rs +++ b/src/auto/accessible.rs @@ -2,21 +2,26 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use atk; +use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; +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 Widget; +use AccessibleProperty; +use AccessibleRelation; +use AccessibleRole; +use AccessibleState; glib_wrapper! { - pub struct Accessible(Object) @extends atk::Object; + pub struct Accessible(Interface); match fn { get_type => || gtk_sys::gtk_accessible_get_type(), @@ -26,33 +31,124 @@ glib_wrapper! { pub const NONE_ACCESSIBLE: Option<&Accessible> = None; pub trait AccessibleExt: 'static { - fn get_widget(&self) -> Option; + fn get_accessible_role(&self) -> AccessibleRole; - fn set_widget>(&self, widget: Option<&P>); + fn reset_property(&self, property: AccessibleProperty); - fn connect_property_widget_notify(&self, f: F) -> SignalHandlerId; + fn reset_relation(&self, relation: AccessibleRelation); + + fn reset_state(&self, state: AccessibleState); + + //fn update_property(&self, first_property: AccessibleProperty, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + fn update_property_value(&self, property: AccessibleProperty, value: &glib::Value); + + //fn update_relation(&self, first_relation: AccessibleRelation, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + fn update_relation_value(&self, relation: AccessibleRelation, value: &glib::Value); + + //fn update_state(&self, first_state: AccessibleState, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + + fn update_state_value(&self, state: AccessibleState, value: &glib::Value); + + fn set_property_accessible_role(&self, accessible_role: AccessibleRole); + + fn connect_property_accessible_role_notify( + &self, + f: F, + ) -> SignalHandlerId; } impl> AccessibleExt for O { - fn get_widget(&self) -> Option { + fn get_accessible_role(&self) -> AccessibleRole { unsafe { - from_glib_none(gtk_sys::gtk_accessible_get_widget( + from_glib(gtk_sys::gtk_accessible_get_accessible_role( self.as_ref().to_glib_none().0, )) } } - fn set_widget>(&self, widget: Option<&P>) { + fn reset_property(&self, property: AccessibleProperty) { unsafe { - gtk_sys::gtk_accessible_set_widget( + gtk_sys::gtk_accessible_reset_property( self.as_ref().to_glib_none().0, - widget.map(|p| p.as_ref()).to_glib_none().0, + property.to_glib(), + ); + } + } + + fn reset_relation(&self, relation: AccessibleRelation) { + unsafe { + gtk_sys::gtk_accessible_reset_relation( + self.as_ref().to_glib_none().0, + relation.to_glib(), + ); + } + } + + fn reset_state(&self, state: AccessibleState) { + unsafe { + gtk_sys::gtk_accessible_reset_state(self.as_ref().to_glib_none().0, state.to_glib()); + } + } + + //fn update_property(&self, first_property: AccessibleProperty, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_property() } + //} + + fn update_property_value(&self, property: AccessibleProperty, value: &glib::Value) { + unsafe { + gtk_sys::gtk_accessible_update_property_value( + self.as_ref().to_glib_none().0, + property.to_glib(), + value.to_glib_none().0, + ); + } + } + + //fn update_relation(&self, first_relation: AccessibleRelation, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_relation() } + //} + + fn update_relation_value(&self, relation: AccessibleRelation, value: &glib::Value) { + unsafe { + gtk_sys::gtk_accessible_update_relation_value( + self.as_ref().to_glib_none().0, + relation.to_glib(), + value.to_glib_none().0, + ); + } + } + + //fn update_state(&self, first_state: AccessibleState, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + // unsafe { TODO: call gtk_sys:gtk_accessible_update_state() } + //} + + fn update_state_value(&self, state: AccessibleState, value: &glib::Value) { + unsafe { + gtk_sys::gtk_accessible_update_state_value( + self.as_ref().to_glib_none().0, + state.to_glib(), + value.to_glib_none().0, + ); + } + } + + fn set_property_accessible_role(&self, accessible_role: AccessibleRole) { + unsafe { + gobject_sys::g_object_set_property( + self.to_glib_none().0 as *mut gobject_sys::GObject, + b"accessible-role\0".as_ptr() as *const _, + Value::from(&accessible_role).to_glib_none().0, ); } } - fn connect_property_widget_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_widget_trampoline( + fn connect_property_accessible_role_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_accessible_role_trampoline( this: *mut gtk_sys::GtkAccessible, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, @@ -60,14 +156,16 @@ impl> AccessibleExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Accessible::from_glib_borrow(this).unsafe_cast()) + f(&Accessible::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, - b"notify::widget\0".as_ptr() as *const _, - Some(transmute(notify_widget_trampoline:: as usize)), + b"notify::accessible-role\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_accessible_role_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/action_bar.rs b/src/auto/action_bar.rs index 95c6b61cf8d4..979e96caacb4 100644 --- a/src/auto/action_bar.rs +++ b/src/auto/action_bar.rs @@ -5,6 +5,7 @@ use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -15,15 +16,17 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use Buildable; -use Container; +use ConstraintTarget; use LayoutManager; use Overflow; use Widget; glib_wrapper! { - pub struct ActionBar(Object) @extends Container, Widget, @implements Buildable; + pub struct ActionBar(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget; match fn { get_type => || gtk_sys::gtk_action_bar_get_type(), @@ -35,6 +38,82 @@ impl ActionBar { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_action_bar_new()).unsafe_cast() } } + + pub fn get_center_widget(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_action_bar_get_center_widget( + self.to_glib_none().0, + )) + } + } + + pub fn get_revealed(&self) -> bool { + unsafe { from_glib(gtk_sys::gtk_action_bar_get_revealed(self.to_glib_none().0)) } + } + + pub fn pack_end>(&self, child: &P) { + unsafe { + gtk_sys::gtk_action_bar_pack_end( + self.to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + pub fn pack_start>(&self, child: &P) { + unsafe { + gtk_sys::gtk_action_bar_pack_start( + self.to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + pub fn remove>(&self, child: &P) { + unsafe { + gtk_sys::gtk_action_bar_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0); + } + } + + pub fn set_center_widget>(&self, center_widget: Option<&P>) { + unsafe { + gtk_sys::gtk_action_bar_set_center_widget( + self.to_glib_none().0, + center_widget.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + pub fn set_revealed(&self, revealed: bool) { + unsafe { + gtk_sys::gtk_action_bar_set_revealed(self.to_glib_none().0, revealed.to_glib()); + } + } + + pub fn connect_property_revealed_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_revealed_trampoline( + this: *mut gtk_sys::GtkActionBar, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::revealed\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_revealed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } impl Default for ActionBar { @@ -48,19 +127,17 @@ pub struct ActionBarBuilder { revealed: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -77,6 +154,7 @@ pub struct ActionBarBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, } impl ActionBarBuilder { @@ -95,24 +173,24 @@ impl ActionBarBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -125,15 +203,9 @@ impl ActionBarBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -182,10 +254,14 @@ impl ActionBarBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - glib::Object::new(ActionBar::static_type(), &properties) + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } + let ret = glib::Object::new(ActionBar::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn revealed(mut self, revealed: bool) -> Self { @@ -203,6 +279,11 @@ impl ActionBarBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -213,23 +294,18 @@ impl ActionBarBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -253,21 +329,11 @@ impl ActionBarBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -347,99 +413,10 @@ impl ActionBarBuilder { self.width_request = Some(width_request); self } -} - -pub const NONE_ACTION_BAR: Option<&ActionBar> = None; - -pub trait ActionBarExt: 'static { - fn get_center_widget(&self) -> Option; - - fn get_revealed(&self) -> bool; - - fn pack_end>(&self, child: &P); - - fn pack_start>(&self, child: &P); - - fn set_center_widget>(&self, center_widget: Option<&P>); - - fn set_revealed(&self, revealed: bool); - - fn connect_property_revealed_notify(&self, f: F) -> SignalHandlerId; -} - -impl> ActionBarExt for O { - fn get_center_widget(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_action_bar_get_center_widget( - self.as_ref().to_glib_none().0, - )) - } - } - - fn get_revealed(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_action_bar_get_revealed( - self.as_ref().to_glib_none().0, - )) - } - } - - fn pack_end>(&self, child: &P) { - unsafe { - gtk_sys::gtk_action_bar_pack_end( - self.as_ref().to_glib_none().0, - child.as_ref().to_glib_none().0, - ); - } - } - - fn pack_start>(&self, child: &P) { - unsafe { - gtk_sys::gtk_action_bar_pack_start( - self.as_ref().to_glib_none().0, - child.as_ref().to_glib_none().0, - ); - } - } - - fn set_center_widget>(&self, center_widget: Option<&P>) { - unsafe { - gtk_sys::gtk_action_bar_set_center_widget( - self.as_ref().to_glib_none().0, - center_widget.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } - - fn set_revealed(&self, revealed: bool) { - unsafe { - gtk_sys::gtk_action_bar_set_revealed( - self.as_ref().to_glib_none().0, - revealed.to_glib(), - ); - } - } - fn connect_property_revealed_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_revealed_trampoline( - this: *mut gtk_sys::GtkActionBar, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&ActionBar::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::revealed\0".as_ptr() as *const _, - Some(transmute(notify_revealed_trampoline:: as usize)), - Box_::into_raw(f), - ) - } + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self } } diff --git a/src/auto/actionable.rs b/src/auto/actionable.rs index aeea7a82e1da..45257633665b 100644 --- a/src/auto/actionable.rs +++ b/src/auto/actionable.rs @@ -14,11 +14,13 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; use Buildable; +use ConstraintTarget; use Widget; glib_wrapper! { - pub struct Actionable(Interface) @requires Widget, Buildable; + pub struct Actionable(Interface) @requires Widget, Accessible, Buildable, ConstraintTarget; match fn { get_type => || gtk_sys::gtk_actionable_get_type(), @@ -100,14 +102,16 @@ impl> ActionableExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Actionable::from_glib_borrow(this).unsafe_cast()) + f(&Actionable::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::action-name\0".as_ptr() as *const _, - Some(transmute(notify_action_name_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_action_name_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/activate_action.rs b/src/auto/activate_action.rs new file mode 100644 index 000000000000..201654c050ef --- /dev/null +++ b/src/auto/activate_action.rs @@ -0,0 +1,29 @@ +// 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::translate::*; +use gtk_sys; +use std::fmt; +use ShortcutAction; + +glib_wrapper! { + pub struct ActivateAction(Object) @extends ShortcutAction; + + match fn { + get_type => || gtk_sys::gtk_activate_action_get_type(), + } +} + +impl ActivateAction { + pub fn get() -> Option { + assert_initialized_main_thread!(); + unsafe { from_glib_none(gtk_sys::gtk_activate_action_get()) } + } +} + +impl fmt::Display for ActivateAction { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ActivateAction") + } +} diff --git a/src/auto/adjustment.rs b/src/auto/adjustment.rs index 4ad1c6baf549..e8345a925509 100644 --- a/src/auto/adjustment.rs +++ b/src/auto/adjustment.rs @@ -7,6 +7,8 @@ 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_; @@ -44,6 +46,79 @@ impl Adjustment { } } +#[derive(Clone, Default)] +pub struct AdjustmentBuilder { + lower: Option, + page_increment: Option, + page_size: Option, + step_increment: Option, + upper: Option, + value: Option, +} + +impl AdjustmentBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> Adjustment { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref lower) = self.lower { + properties.push(("lower", lower)); + } + if let Some(ref page_increment) = self.page_increment { + properties.push(("page-increment", page_increment)); + } + if let Some(ref page_size) = self.page_size { + properties.push(("page-size", page_size)); + } + if let Some(ref step_increment) = self.step_increment { + properties.push(("step-increment", step_increment)); + } + if let Some(ref upper) = self.upper { + properties.push(("upper", upper)); + } + if let Some(ref value) = self.value { + properties.push(("value", value)); + } + let ret = glib::Object::new(Adjustment::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn lower(mut self, lower: f64) -> Self { + self.lower = Some(lower); + self + } + + pub fn page_increment(mut self, page_increment: f64) -> Self { + self.page_increment = Some(page_increment); + self + } + + pub fn page_size(mut self, page_size: f64) -> Self { + self.page_size = Some(page_size); + self + } + + pub fn step_increment(mut self, step_increment: f64) -> Self { + self.step_increment = Some(step_increment); + self + } + + pub fn upper(mut self, upper: f64) -> Self { + self.upper = Some(upper); + self + } + + pub fn value(mut self, value: f64) -> Self { + self.value = Some(value); + self + } +} + pub const NONE_ADJUSTMENT: Option<&Adjustment> = None; pub trait AdjustmentExt: 'static { @@ -215,14 +290,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, - Some(transmute(changed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + changed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -236,14 +313,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"value-changed\0".as_ptr() as *const _, - Some(transmute(value_changed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + value_changed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -258,14 +337,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::lower\0".as_ptr() as *const _, - Some(transmute(notify_lower_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_lower_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -283,15 +364,15 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::page-increment\0".as_ptr() as *const _, - Some(transmute( - notify_page_increment_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_increment_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -307,14 +388,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::page-size\0".as_ptr() as *const _, - Some(transmute(notify_page_size_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_size_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -332,15 +415,15 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::step-increment\0".as_ptr() as *const _, - Some(transmute( - notify_step_increment_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_step_increment_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -356,14 +439,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::upper\0".as_ptr() as *const _, - Some(transmute(notify_upper_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_upper_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -378,14 +463,16 @@ impl> AdjustmentExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Adjustment::from_glib_borrow(this).unsafe_cast()) + f(&Adjustment::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::value\0".as_ptr() as *const _, - Some(transmute(notify_value_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_value_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/alternative_trigger.rs b/src/auto/alternative_trigger.rs new file mode 100644 index 000000000000..a3f44c51182b --- /dev/null +++ b/src/auto/alternative_trigger.rs @@ -0,0 +1,95 @@ +// 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::Cast; +use glib::object::IsA; +use glib::translate::*; +use glib::StaticType; +use glib::ToValue; +use gtk_sys; +use std::fmt; +use ShortcutTrigger; + +glib_wrapper! { + pub struct AlternativeTrigger(Object) @extends ShortcutTrigger; + + match fn { + get_type => || gtk_sys::gtk_alternative_trigger_get_type(), + } +} + +impl AlternativeTrigger { + pub fn new, Q: IsA>( + first: &P, + second: &Q, + ) -> AlternativeTrigger { + skip_assert_initialized!(); + unsafe { + ShortcutTrigger::from_glib_full(gtk_sys::gtk_alternative_trigger_new( + first.as_ref().to_glib_full(), + second.as_ref().to_glib_full(), + )) + .unsafe_cast() + } + } + + pub fn get_first(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_alternative_trigger_get_first( + self.to_glib_none().0, + )) + } + } + + pub fn get_second(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_alternative_trigger_get_second( + self.to_glib_none().0, + )) + } + } +} + +#[derive(Clone, Default)] +pub struct AlternativeTriggerBuilder { + first: Option, + second: Option, +} + +impl AlternativeTriggerBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> AlternativeTrigger { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref first) = self.first { + properties.push(("first", first)); + } + if let Some(ref second) = self.second { + properties.push(("second", second)); + } + let ret = glib::Object::new(AlternativeTrigger::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn first>(mut self, first: &P) -> Self { + self.first = Some(first.clone().upcast()); + self + } + + pub fn second>(mut self, second: &P) -> Self { + self.second = Some(second.clone().upcast()); + self + } +} + +impl fmt::Display for AlternativeTrigger { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AlternativeTrigger") + } +} diff --git a/src/auto/any_filter.rs b/src/auto/any_filter.rs new file mode 100644 index 000000000000..d8d284b3ceee --- /dev/null +++ b/src/auto/any_filter.rs @@ -0,0 +1,39 @@ +// 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 gio; +use glib::object::Cast; +use glib::translate::*; +use gtk_sys; +use std::fmt; +use Buildable; +use Filter; +use MultiFilter; + +glib_wrapper! { + pub struct AnyFilter(Object) @extends MultiFilter, Filter, @implements gio::ListModel, Buildable; + + match fn { + get_type => || gtk_sys::gtk_any_filter_get_type(), + } +} + +impl AnyFilter { + pub fn new() -> AnyFilter { + assert_initialized_main_thread!(); + unsafe { Filter::from_glib_full(gtk_sys::gtk_any_filter_new()).unsafe_cast() } + } +} + +impl Default for AnyFilter { + fn default() -> Self { + Self::new() + } +} + +impl fmt::Display for AnyFilter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AnyFilter") + } +} diff --git a/src/auto/app_chooser.rs b/src/auto/app_chooser.rs index 400ba4eae08a..b3d394a78ad1 100644 --- a/src/auto/app_chooser.rs +++ b/src/auto/app_chooser.rs @@ -8,11 +8,13 @@ use glib::translate::*; use glib::GString; use gtk_sys; use std::fmt; +use Accessible; use Buildable; +use ConstraintTarget; use Widget; glib_wrapper! { - pub struct AppChooser(Interface) @requires Widget, Buildable; + pub struct AppChooser(Interface) @requires Widget, Accessible, Buildable, ConstraintTarget; match fn { get_type => || gtk_sys::gtk_app_chooser_get_type(), diff --git a/src/auto/app_chooser_button.rs b/src/auto/app_chooser_button.rs index ae458a49ebe4..ff272ff67856 100644 --- a/src/auto/app_chooser_button.rs +++ b/src/auto/app_chooser_button.rs @@ -6,6 +6,7 @@ use gdk; use gio; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -18,15 +19,18 @@ use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use AppChooser; use Buildable; +use ConstraintTarget; use LayoutManager; use Overflow; use Widget; glib_wrapper! { - pub struct AppChooserButton(Object) @extends Widget, @implements Buildable, AppChooser; + pub struct AppChooserButton(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_button_get_type(), @@ -43,28 +47,273 @@ impl AppChooserButton { .unsafe_cast() } } + + pub fn append_custom_item>(&self, name: &str, label: &str, icon: &P) { + unsafe { + gtk_sys::gtk_app_chooser_button_append_custom_item( + self.to_glib_none().0, + name.to_glib_none().0, + label.to_glib_none().0, + icon.as_ref().to_glib_none().0, + ); + } + } + + pub fn append_separator(&self) { + unsafe { + gtk_sys::gtk_app_chooser_button_append_separator(self.to_glib_none().0); + } + } + + pub fn get_heading(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_app_chooser_button_get_heading( + self.to_glib_none().0, + )) + } + } + + pub fn get_modal(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_button_get_modal( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_default_item(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_button_get_show_default_item( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_dialog_item(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_button_get_show_dialog_item( + self.to_glib_none().0, + )) + } + } + + pub fn set_active_custom_item(&self, name: &str) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_active_custom_item( + self.to_glib_none().0, + name.to_glib_none().0, + ); + } + } + + pub fn set_heading(&self, heading: &str) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_heading( + self.to_glib_none().0, + heading.to_glib_none().0, + ); + } + } + + pub fn set_modal(&self, modal: bool) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_modal(self.to_glib_none().0, modal.to_glib()); + } + } + + pub fn set_show_default_item(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_show_default_item( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn set_show_dialog_item(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_button_set_show_dialog_item( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn connect_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn changed_trampoline( + this: *mut gtk_sys::GtkAppChooserButton, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"changed\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_custom_item_activated( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn custom_item_activated_trampoline< + F: Fn(&AppChooserButton, &str) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserButton, + item_name: *mut libc::c_char, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + &from_glib_borrow(this), + &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::<_, unsafe extern "C" fn()>( + custom_item_activated_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_heading_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_heading_trampoline( + this: *mut gtk_sys::GtkAppChooserButton, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::heading\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_heading_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_modal_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_modal_trampoline( + this: *mut gtk_sys::GtkAppChooserButton, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::modal\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_modal_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_show_default_item_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_default_item_trampoline< + F: Fn(&AppChooserButton) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserButton, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-default-item\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_default_item_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_show_dialog_item_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_dialog_item_trampoline< + F: Fn(&AppChooserButton) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserButton, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-dialog-item\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_dialog_item_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } #[derive(Clone, Default)] pub struct AppChooserButtonBuilder { heading: Option, + modal: Option, show_default_item: Option, show_dialog_item: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -81,6 +330,7 @@ pub struct AppChooserButtonBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, content_type: Option, } @@ -94,6 +344,9 @@ impl AppChooserButtonBuilder { if let Some(ref heading) = self.heading { properties.push(("heading", heading)); } + if let Some(ref modal) = self.modal { + properties.push(("modal", modal)); + } if let Some(ref show_default_item) = self.show_default_item { properties.push(("show-default-item", show_default_item)); } @@ -106,24 +359,24 @@ impl AppChooserButtonBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -136,15 +389,9 @@ impl AppChooserButtonBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -193,13 +440,17 @@ impl AppChooserButtonBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } if let Some(ref content_type) = self.content_type { properties.push(("content-type", content_type)); } - glib::Object::new(AppChooserButton::static_type(), &properties) + let ret = glib::Object::new(AppChooserButton::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn heading(mut self, heading: &str) -> Self { @@ -207,6 +458,11 @@ impl AppChooserButtonBuilder { self } + pub fn modal(mut self, modal: bool) -> Self { + self.modal = Some(modal); + self + } + pub fn show_default_item(mut self, show_default_item: bool) -> Self { self.show_default_item = Some(show_default_item); self @@ -227,6 +483,11 @@ impl AppChooserButtonBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -237,23 +498,18 @@ impl AppChooserButtonBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -277,21 +533,11 @@ impl AppChooserButtonBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -372,250 +618,14 @@ impl AppChooserButtonBuilder { self } - pub fn content_type(mut self, content_type: &str) -> Self { - self.content_type = Some(content_type.to_string()); + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); self } -} - -pub const NONE_APP_CHOOSER_BUTTON: Option<&AppChooserButton> = None; - -pub trait AppChooserButtonExt: 'static { - fn append_custom_item>(&self, name: &str, label: &str, icon: &P); - - fn append_separator(&self); - - fn get_heading(&self) -> Option; - - fn get_show_default_item(&self) -> bool; - - fn get_show_dialog_item(&self) -> bool; - - fn set_active_custom_item(&self, name: &str); - - fn set_heading(&self, heading: &str); - - fn set_show_default_item(&self, setting: bool); - - fn set_show_dialog_item(&self, setting: bool); - - fn connect_changed(&self, f: F) -> SignalHandlerId; - - fn connect_custom_item_activated(&self, f: F) -> SignalHandlerId; - - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_default_item_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_show_dialog_item_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AppChooserButtonExt for O { - fn append_custom_item>(&self, name: &str, label: &str, icon: &P) { - 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_changed(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn changed_trampoline( - this: *mut gtk_sys::GtkAppChooserButton, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&AppChooserButton::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"changed\0".as_ptr() as *const _, - Some(transmute(changed_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - - 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), - ) - } + pub fn content_type(mut self, content_type: &str) -> Self { + self.content_type = Some(content_type.to_string()); + self } } diff --git a/src/auto/app_chooser_dialog.rs b/src/auto/app_chooser_dialog.rs index efc2d1e70d85..4e2d25ebc283 100644 --- a/src/auto/app_chooser_dialog.rs +++ b/src/auto/app_chooser_dialog.rs @@ -6,6 +6,7 @@ use gdk; use gio; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -19,24 +20,25 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use AppChooser; use Application; -use Bin; use Buildable; -use Container; +use ConstraintTarget; use Dialog; use DialogFlags; use LayoutManager; +use Native; use Overflow; use Root; +use ShortcutManager; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct AppChooserDialog(Object) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, Root, AppChooser; + pub struct AppChooserDialog(Object) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_dialog_get_type(), @@ -75,6 +77,70 @@ impl AppChooserDialog { .unsafe_cast() } } + + pub fn get_heading(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_heading( + self.to_glib_none().0, + )) + } + } + + pub fn get_widget(&self) -> Widget { + unsafe { + from_glib_none(gtk_sys::gtk_app_chooser_dialog_get_widget( + self.to_glib_none().0, + )) + } + } + + pub fn set_heading(&self, heading: &str) { + unsafe { + gtk_sys::gtk_app_chooser_dialog_set_heading( + self.to_glib_none().0, + heading.to_glib_none().0, + ); + } + } + + pub fn get_property_gfile(&self) -> Option { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property( + self.as_ptr() as *mut gobject_sys::GObject, + b"gfile\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value + .get() + .expect("Return Value for property `gfile` getter") + } + } + + pub fn connect_property_heading_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_heading_trampoline( + this: *mut gtk_sys::GtkAppChooserDialog, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::heading\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_heading_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } #[derive(Clone, Default)] @@ -82,9 +148,8 @@ pub struct AppChooserDialogBuilder { gfile: Option, heading: Option, use_header_bar: Option, - accept_focus: Option, application: Option, - attached_to: Option, + child: Option, decorated: Option, default_height: Option, default_widget: Option, @@ -92,8 +157,8 @@ pub struct AppChooserDialogBuilder { deletable: Option, destroy_with_parent: Option, display: Option, - focus_on_map: Option, focus_visible: Option, + focus_widget: Option, hide_on_close: Option, icon_name: Option, mnemonics_visible: Option, @@ -102,24 +167,19 @@ pub struct AppChooserDialogBuilder { startup_id: Option, title: Option, transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -136,7 +196,7 @@ pub struct AppChooserDialogBuilder { vexpand_set: Option, visible: Option, width_request: Option, - focus_widget: Option, + accessible_role: Option, content_type: Option, } @@ -156,14 +216,11 @@ impl AppChooserDialogBuilder { 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 child) = self.child { + properties.push(("child", child)); } if let Some(ref decorated) = self.decorated { properties.push(("decorated", decorated)); @@ -186,12 +243,12 @@ impl AppChooserDialogBuilder { if let Some(ref display) = self.display { properties.push(("display", display)); } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } if let Some(ref focus_visible) = self.focus_visible { properties.push(("focus-visible", focus_visible)); } + if let Some(ref focus_widget) = self.focus_widget { + properties.push(("focus-widget", focus_widget)); + } if let Some(ref hide_on_close) = self.hide_on_close { properties.push(("hide-on-close", hide_on_close)); } @@ -216,39 +273,30 @@ impl AppChooserDialogBuilder { if let Some(ref transient_for) = self.transient_for { properties.push(("transient-for", transient_for)); } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } if let Some(ref can_focus) = self.can_focus { properties.push(("can-focus", can_focus)); } if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -261,15 +309,9 @@ impl AppChooserDialogBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -318,16 +360,17 @@ impl AppChooserDialogBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); } if let Some(ref content_type) = self.content_type { properties.push(("content-type", content_type)); } - glib::Object::new(AppChooserDialog::static_type(), &properties) + let ret = glib::Object::new(AppChooserDialog::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn gfile>(mut self, gfile: &P) -> Self { @@ -345,18 +388,13 @@ impl AppChooserDialogBuilder { self } - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - pub fn application>(mut self, application: &P) -> Self { self.application = Some(application.clone().upcast()); self } - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); self } @@ -395,13 +433,13 @@ impl AppChooserDialogBuilder { self } - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); + pub fn focus_visible(mut self, focus_visible: bool) -> Self { + self.focus_visible = Some(focus_visible); self } - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); + pub fn focus_widget>(mut self, focus_widget: &P) -> Self { + self.focus_widget = Some(focus_widget.clone().upcast()); self } @@ -445,21 +483,6 @@ impl AppChooserDialogBuilder { self } - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - pub fn can_focus(mut self, can_focus: bool) -> Self { self.can_focus = Some(can_focus); self @@ -470,6 +493,11 @@ impl AppChooserDialogBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -480,23 +508,18 @@ impl AppChooserDialogBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -520,21 +543,11 @@ impl AppChooserDialogBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -615,8 +628,8 @@ impl AppChooserDialogBuilder { self } - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); self } @@ -626,83 +639,6 @@ impl AppChooserDialogBuilder { } } -pub const NONE_APP_CHOOSER_DIALOG: Option<&AppChooserDialog> = None; - -pub trait AppChooserDialogExt: 'static { - fn get_heading(&self) -> Option; - - fn get_widget(&self) -> Widget; - - fn set_heading(&self, heading: &str); - - fn get_property_gfile(&self) -> Option; - - fn connect_property_heading_notify(&self, f: F) -> SignalHandlerId; -} - -impl> AppChooserDialogExt for O { - fn get_heading(&self) -> Option { - unsafe { - 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(gtk_sys::gtk_app_chooser_dialog_get_widget( - self.as_ref().to_glib_none().0, - )) - } - } - - fn set_heading(&self, heading: &str) { - unsafe { - 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) -> 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"gfile\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `gfile` getter") - } - } - - 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(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), - ) - } - } -} - 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 78bc462b7720..e5eb32a61dd6 100644 --- a/src/auto/app_chooser_widget.rs +++ b/src/auto/app_chooser_widget.rs @@ -7,6 +7,7 @@ use gio; use gio_sys; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -18,16 +19,18 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use AppChooser; use Buildable; +use ConstraintTarget; use LayoutManager; -use Menu; use Overflow; use Widget; glib_wrapper! { - pub struct AppChooserWidget(Object) @extends Widget, @implements Buildable, AppChooser; + pub struct AppChooserWidget(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AppChooser; match fn { get_type => || gtk_sys::gtk_app_chooser_widget_get_type(), @@ -44,6 +47,311 @@ impl AppChooserWidget { .unsafe_cast() } } + + pub fn get_default_text(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_app_chooser_widget_get_default_text( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_all(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_all( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_default(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_default( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_fallback(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_fallback( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_other(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_other( + self.to_glib_none().0, + )) + } + } + + pub fn get_show_recommended(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_app_chooser_widget_get_show_recommended( + self.to_glib_none().0, + )) + } + } + + pub fn set_default_text(&self, text: &str) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_default_text( + self.to_glib_none().0, + text.to_glib_none().0, + ); + } + } + + pub fn set_show_all(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_show_all(self.to_glib_none().0, setting.to_glib()); + } + } + + pub fn set_show_default(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_show_default( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn set_show_fallback(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_show_fallback( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn set_show_other(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_show_other( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn set_show_recommended(&self, setting: bool) { + unsafe { + gtk_sys::gtk_app_chooser_widget_set_show_recommended( + self.to_glib_none().0, + setting.to_glib(), + ); + } + } + + pub fn connect_application_activated( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn application_activated_trampoline< + F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserWidget, + application: *mut gio_sys::GAppInfo, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &from_glib_borrow(application)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"application-activated\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + application_activated_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_application_selected( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn application_selected_trampoline< + F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserWidget, + application: *mut gio_sys::GAppInfo, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &from_glib_borrow(application)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"application-selected\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + application_selected_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::default-text\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_default_text_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_show_all_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_all_trampoline( + this: *mut gtk_sys::GtkAppChooserWidget, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-all\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_all_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-default\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_default_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub 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, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-fallback\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_fallback_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_show_other_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_other_trampoline( + this: *mut gtk_sys::GtkAppChooserWidget, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-other\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_other_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_show_recommended_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_show_recommended_trampoline< + F: Fn(&AppChooserWidget) + 'static, + >( + this: *mut gtk_sys::GtkAppChooserWidget, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::show-recommended\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_recommended_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } #[derive(Clone, Default)] @@ -56,19 +364,17 @@ pub struct AppChooserWidgetBuilder { show_recommended: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -85,6 +391,7 @@ pub struct AppChooserWidgetBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, content_type: Option, } @@ -119,24 +426,24 @@ impl AppChooserWidgetBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -149,15 +456,9 @@ impl AppChooserWidgetBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -206,13 +507,17 @@ impl AppChooserWidgetBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } if let Some(ref content_type) = self.content_type { properties.push(("content-type", content_type)); } - glib::Object::new(AppChooserWidget::static_type(), &properties) + let ret = glib::Object::new(AppChooserWidget::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn default_text(mut self, default_text: &str) -> Self { @@ -255,6 +560,11 @@ impl AppChooserWidgetBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -265,23 +575,18 @@ impl AppChooserWidgetBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -305,21 +610,11 @@ impl AppChooserWidgetBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -400,427 +695,14 @@ impl AppChooserWidgetBuilder { self } - pub fn content_type(mut self, content_type: &str) -> Self { - self.content_type = Some(content_type.to_string()); + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); self } -} - -pub const NONE_APP_CHOOSER_WIDGET: Option<&AppChooserWidget> = None; - -pub trait AppChooserWidgetExt: 'static { - fn get_default_text(&self) -> Option; - - fn get_show_all(&self) -> bool; - - fn get_show_default(&self) -> bool; - - fn get_show_fallback(&self) -> bool; - - fn get_show_other(&self) -> bool; - - fn get_show_recommended(&self) -> bool; - - fn set_default_text(&self, text: &str); - - fn set_show_all(&self, setting: bool); - - fn set_show_default(&self, setting: bool); - - fn set_show_fallback(&self, setting: bool); - - fn set_show_other(&self, setting: bool); - - fn set_show_recommended(&self, setting: bool); - - fn connect_application_activated( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_application_selected( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_populate_popup( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_default_text_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_show_all_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_default_notify(&self, f: F) - -> SignalHandlerId; - - fn connect_property_show_fallback_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn connect_property_show_other_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_show_recommended_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> AppChooserWidgetExt for O { - fn get_default_text(&self) -> Option { - unsafe { - 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(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(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(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(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(gtk_sys::gtk_app_chooser_widget_get_show_recommended( - self.as_ref().to_glib_none().0, - )) - } - } - - fn set_default_text(&self, text: &str) { - unsafe { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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(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 { - 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(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 { - unsafe extern "C" fn populate_popup_trampoline< - P, - F: Fn(&P, &Menu, &gio::AppInfo) + 'static, - >( - this: *mut gtk_sys::GtkAppChooserWidget, - menu: *mut gtk_sys::GtkMenu, - application: *mut gio_sys::GAppInfo, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f( - &AppChooserWidget::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(menu), - &from_glib_borrow(application), - ) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"populate-popup\0".as_ptr() as *const _, - Some(transmute(populate_popup_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - fn connect_property_default_text_notify( - &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(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(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 { - 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(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 { - 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(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(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 { - 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(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), - ) - } + pub fn content_type(mut self, content_type: &str) -> Self { + self.content_type = Some(content_type.to_string()); + self } } diff --git a/src/auto/application.rs b/src/auto/application.rs index ad5ec984d4a1..9b966c980425 100644 --- a/src/auto/application.rs +++ b/src/auto/application.rs @@ -10,6 +10,7 @@ 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; @@ -28,6 +29,88 @@ glib_wrapper! { } } +#[derive(Clone, Default)] +pub struct ApplicationBuilder { + 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::default() + } + + pub fn build(self) -> Application { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + 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)); + } + let ret = glib::Object::new(Application::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn menubar>(mut self, menubar: &P) -> Self { + self.menubar = Some(menubar.clone().upcast()); + 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: &P) -> Self { + self.action_group = Some(action_group.clone().upcast()); + 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 const NONE_APPLICATION: Option<&Application> = None; pub trait GtkApplicationExt: 'static { @@ -39,8 +122,6 @@ pub trait GtkApplicationExt: 'static { fn get_active_window(&self) -> Option; - fn get_app_menu(&self) -> Option; - fn get_menu_by_id(&self, id: &str) -> Option; fn get_menubar(&self) -> Option; @@ -58,14 +139,10 @@ pub trait GtkApplicationExt: 'static { fn list_action_descriptions(&self) -> Vec; - fn prefers_app_menu(&self) -> bool; - fn remove_window>(&self, window: &P); fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]); - fn set_app_menu>(&self, app_menu: Option<&P>); - fn set_menubar>(&self, menubar: Option<&P>); fn uninhibit(&self, cookie: u32); @@ -87,8 +164,6 @@ pub trait GtkApplicationExt: 'static { f: F, ) -> SignalHandlerId; - fn connect_property_app_menu_notify(&self, f: F) -> SignalHandlerId; - fn connect_property_menubar_notify(&self, f: F) -> SignalHandlerId; fn connect_property_register_session_notify( @@ -138,14 +213,6 @@ impl> GtkApplicationExt for O { } } - fn get_app_menu(&self) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_application_get_app_menu( - self.as_ref().to_glib_none().0, - )) - } - } - fn get_menu_by_id(&self, id: &str) -> Option { unsafe { from_glib_none(gtk_sys::gtk_application_get_menu_by_id( @@ -204,14 +271,6 @@ impl> GtkApplicationExt for O { } } - fn prefers_app_menu(&self) -> bool { - unsafe { - from_glib(gtk_sys::gtk_application_prefers_app_menu( - self.as_ref().to_glib_none().0, - )) - } - } - fn remove_window>(&self, window: &P) { unsafe { gtk_sys::gtk_application_remove_window( @@ -231,15 +290,6 @@ impl> GtkApplicationExt for O { } } - fn set_app_menu>(&self, app_menu: Option<&P>) { - unsafe { - gtk_sys::gtk_application_set_app_menu( - self.as_ref().to_glib_none().0, - app_menu.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } - fn set_menubar>(&self, menubar: Option<&P>) { unsafe { gtk_sys::gtk_application_set_menubar( @@ -303,14 +353,16 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"query-end\0".as_ptr() as *const _, - Some(transmute(query_end_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + query_end_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -326,7 +378,7 @@ impl> GtkApplicationExt for O { { let f: &F = &*(f as *const F); f( - &Application::from_glib_borrow(this).unsafe_cast(), + &Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(window), ) } @@ -335,7 +387,9 @@ impl> GtkApplicationExt for O { connect_raw( self.as_ptr() as *mut _, b"window-added\0".as_ptr() as *const _, - Some(transmute(window_added_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + window_added_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -351,7 +405,7 @@ impl> GtkApplicationExt for O { { let f: &F = &*(f as *const F); f( - &Application::from_glib_borrow(this).unsafe_cast(), + &Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(window), ) } @@ -360,7 +414,9 @@ impl> GtkApplicationExt for O { connect_raw( self.as_ptr() as *mut _, b"window-removed\0".as_ptr() as *const _, - Some(transmute(window_removed_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + window_removed_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -378,43 +434,21 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::active-window\0".as_ptr() as *const _, - Some(transmute( - notify_active_window_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_active_window_trampoline:: as *const (), )), Box_::into_raw(f), ) } } - fn connect_property_app_menu_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_app_menu_trampoline( - this: *mut gtk_sys::GtkApplication, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::app-menu\0".as_ptr() as *const _, - Some(transmute(notify_app_menu_trampoline:: as usize)), - Box_::into_raw(f), - ) - } - } - fn connect_property_menubar_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_menubar_trampoline( this: *mut gtk_sys::GtkApplication, @@ -424,14 +458,16 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::menubar\0".as_ptr() as *const _, - Some(transmute(notify_menubar_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_menubar_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -449,15 +485,15 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::register-session\0".as_ptr() as *const _, - Some(transmute( - notify_register_session_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_register_session_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -476,15 +512,15 @@ impl> GtkApplicationExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Application::from_glib_borrow(this).unsafe_cast()) + f(&Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::screensaver-active\0".as_ptr() as *const _, - Some(transmute( - notify_screensaver_active_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_screensaver_active_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/application_window.rs b/src/auto/application_window.rs index 129f8be01330..9e24766a738d 100644 --- a/src/auto/application_window.rs +++ b/src/auto/application_window.rs @@ -16,22 +16,23 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use Application; -use Bin; use Buildable; -use Container; +use ConstraintTarget; use LayoutManager; +use Native; use Overflow; use Root; +use ShortcutManager; use ShortcutsWindow; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct ApplicationWindow(Object) @extends Window, Bin, Container, Widget, @implements Buildable, Root, gio::ActionGroup, gio::ActionMap; + pub struct ApplicationWindow(Object) @extends Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, gio::ActionGroup, gio::ActionMap; match fn { get_type => || gtk_sys::gtk_application_window_get_type(), @@ -53,9 +54,8 @@ impl ApplicationWindow { #[derive(Clone, Default)] pub struct ApplicationWindowBuilder { show_menubar: Option, - accept_focus: Option, application: Option, - attached_to: Option, + child: Option, decorated: Option, default_height: Option, default_widget: Option, @@ -63,8 +63,8 @@ pub struct ApplicationWindowBuilder { deletable: Option, destroy_with_parent: Option, display: Option, - focus_on_map: Option, focus_visible: Option, + focus_widget: Option, hide_on_close: Option, icon_name: Option, mnemonics_visible: Option, @@ -73,24 +73,19 @@ pub struct ApplicationWindowBuilder { startup_id: Option, title: Option, transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -107,7 +102,7 @@ pub struct ApplicationWindowBuilder { vexpand_set: Option, visible: Option, width_request: Option, - focus_widget: Option, + accessible_role: Option, } impl ApplicationWindowBuilder { @@ -120,14 +115,11 @@ impl ApplicationWindowBuilder { 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 child) = self.child { + properties.push(("child", child)); } if let Some(ref decorated) = self.decorated { properties.push(("decorated", decorated)); @@ -150,12 +142,12 @@ impl ApplicationWindowBuilder { if let Some(ref display) = self.display { properties.push(("display", display)); } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } if let Some(ref focus_visible) = self.focus_visible { properties.push(("focus-visible", focus_visible)); } + if let Some(ref focus_widget) = self.focus_widget { + properties.push(("focus-widget", focus_widget)); + } if let Some(ref hide_on_close) = self.hide_on_close { properties.push(("hide-on-close", hide_on_close)); } @@ -180,39 +172,30 @@ impl ApplicationWindowBuilder { if let Some(ref transient_for) = self.transient_for { properties.push(("transient-for", transient_for)); } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } if let Some(ref can_focus) = self.can_focus { properties.push(("can-focus", can_focus)); } if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -225,15 +208,9 @@ impl ApplicationWindowBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -282,13 +259,14 @@ impl ApplicationWindowBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); } - glib::Object::new(ApplicationWindow::static_type(), &properties) + let ret = glib::Object::new(ApplicationWindow::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn show_menubar(mut self, show_menubar: bool) -> Self { @@ -296,18 +274,13 @@ impl ApplicationWindowBuilder { self } - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - pub fn application>(mut self, application: &P) -> Self { self.application = Some(application.clone().upcast()); self } - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); self } @@ -346,13 +319,13 @@ impl ApplicationWindowBuilder { self } - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); + pub fn focus_visible(mut self, focus_visible: bool) -> Self { + self.focus_visible = Some(focus_visible); self } - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); + pub fn focus_widget>(mut self, focus_widget: &P) -> Self { + self.focus_widget = Some(focus_widget.clone().upcast()); self } @@ -396,21 +369,6 @@ impl ApplicationWindowBuilder { self } - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - pub fn can_focus(mut self, can_focus: bool) -> Self { self.can_focus = Some(can_focus); self @@ -421,6 +379,11 @@ impl ApplicationWindowBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -431,23 +394,18 @@ impl ApplicationWindowBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -471,21 +429,11 @@ impl ApplicationWindowBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -566,8 +514,8 @@ impl ApplicationWindowBuilder { self } - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); self } } @@ -581,7 +529,7 @@ pub trait ApplicationWindowExt: 'static { fn get_show_menubar(&self) -> bool; - fn set_help_overlay>(&self, help_overlay: Option<&P>); + fn set_help_overlay(&self, help_overlay: Option<&ShortcutsWindow>); fn set_show_menubar(&self, show_menubar: bool); @@ -610,11 +558,11 @@ impl> ApplicationWindowExt for O { } } - fn set_help_overlay>(&self, help_overlay: Option<&P>) { + fn set_help_overlay(&self, help_overlay: Option<&ShortcutsWindow>) { unsafe { gtk_sys::gtk_application_window_set_help_overlay( self.as_ref().to_glib_none().0, - help_overlay.map(|p| p.as_ref()).to_glib_none().0, + help_overlay.to_glib_none().0, ); } } @@ -640,15 +588,15 @@ impl> ApplicationWindowExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast()) + f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-menubar\0".as_ptr() as *const _, - Some(transmute( - notify_show_menubar_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_show_menubar_trampoline:: as *const (), )), Box_::into_raw(f), ) diff --git a/src/auto/aspect_frame.rs b/src/auto/aspect_frame.rs index c3d106d2b66d..df3ef9b68c40 100644 --- a/src/auto/aspect_frame.rs +++ b/src/auto/aspect_frame.rs @@ -5,30 +5,28 @@ use gdk; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; -use glib::Value; use glib_sys; -use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; -use Bin; use Buildable; -use Container; -use Frame; +use ConstraintTarget; use LayoutManager; use Overflow; -use ShadowType; use Widget; glib_wrapper! { - pub struct AspectFrame(Object) @extends Frame, Bin, Container, Widget, @implements Buildable; + pub struct AspectFrame(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget; match fn { get_type => || gtk_sys::gtk_aspect_frame_get_type(), @@ -36,17 +34,10 @@ glib_wrapper! { } impl AspectFrame { - pub fn new( - label: Option<&str>, - xalign: f32, - yalign: f32, - ratio: f32, - obey_child: bool, - ) -> AspectFrame { + pub fn new(xalign: f32, yalign: f32, ratio: f32, obey_child: bool) -> AspectFrame { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_aspect_frame_new( - label.to_glib_none().0, xalign, yalign, ratio, @@ -55,33 +46,210 @@ impl AspectFrame { .unsafe_cast() } } + + pub fn get_child(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_aspect_frame_get_child(self.to_glib_none().0)) } + } + + pub fn get_obey_child(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_aspect_frame_get_obey_child( + self.to_glib_none().0, + )) + } + } + + pub fn get_ratio(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_ratio(self.to_glib_none().0) } + } + + pub fn get_xalign(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_xalign(self.to_glib_none().0) } + } + + pub fn get_yalign(&self) -> f32 { + unsafe { gtk_sys::gtk_aspect_frame_get_yalign(self.to_glib_none().0) } + } + + pub fn set_child>(&self, child: Option<&P>) { + unsafe { + gtk_sys::gtk_aspect_frame_set_child( + self.to_glib_none().0, + child.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + pub fn set_obey_child(&self, obey_child: bool) { + unsafe { + gtk_sys::gtk_aspect_frame_set_obey_child(self.to_glib_none().0, obey_child.to_glib()); + } + } + + pub fn set_ratio(&self, ratio: f32) { + unsafe { + gtk_sys::gtk_aspect_frame_set_ratio(self.to_glib_none().0, ratio); + } + } + + pub fn set_xalign(&self, xalign: f32) { + unsafe { + gtk_sys::gtk_aspect_frame_set_xalign(self.to_glib_none().0, xalign); + } + } + + pub fn set_yalign(&self, yalign: f32) { + unsafe { + gtk_sys::gtk_aspect_frame_set_yalign(self.to_glib_none().0, yalign); + } + } + + pub fn connect_property_child_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_child_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::child\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_child_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_obey_child_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_obey_child_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::obey-child\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_obey_child_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_ratio_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_ratio_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::ratio\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_ratio_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_xalign_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_xalign_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::xalign\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_xalign_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_yalign_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_yalign_trampoline( + this: *mut gtk_sys::GtkAspectFrame, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::yalign\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_yalign_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } #[derive(Clone, Default)] pub struct AspectFrameBuilder { + child: Option, obey_child: Option, ratio: Option, xalign: Option, yalign: Option, - label: Option, - label_widget: Option, - label_xalign: Option, - shadow_type: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -98,6 +266,7 @@ pub struct AspectFrameBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, } impl AspectFrameBuilder { @@ -107,6 +276,9 @@ impl AspectFrameBuilder { pub fn build(self) -> AspectFrame { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref child) = self.child { + properties.push(("child", child)); + } if let Some(ref obey_child) = self.obey_child { properties.push(("obey-child", obey_child)); } @@ -119,42 +291,30 @@ impl AspectFrameBuilder { if let Some(ref yalign) = self.yalign { properties.push(("yalign", yalign)); } - if let Some(ref label) = self.label { - properties.push(("label", label)); - } - if let Some(ref label_widget) = self.label_widget { - properties.push(("label-widget", label_widget)); - } - if let Some(ref label_xalign) = self.label_xalign { - properties.push(("label-xalign", label_xalign)); - } - if let Some(ref shadow_type) = self.shadow_type { - properties.push(("shadow-type", shadow_type)); - } if let Some(ref can_focus) = self.can_focus { properties.push(("can-focus", can_focus)); } if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -167,15 +327,9 @@ impl AspectFrameBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -224,10 +378,19 @@ impl AspectFrameBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - glib::Object::new(AspectFrame::static_type(), &properties) + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } + let ret = glib::Object::new(AspectFrame::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret + } + + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); + self } pub fn obey_child(mut self, obey_child: bool) -> Self { @@ -250,26 +413,6 @@ impl AspectFrameBuilder { self } - pub fn label(mut self, label: &str) -> Self { - self.label = Some(label.to_string()); - self - } - - pub fn label_widget>(mut self, label_widget: &P) -> Self { - self.label_widget = Some(label_widget.clone().upcast()); - self - } - - pub fn label_xalign(mut self, label_xalign: f32) -> Self { - self.label_xalign = Some(label_xalign); - self - } - - pub fn shadow_type(mut self, shadow_type: ShadowType) -> Self { - self.shadow_type = Some(shadow_type); - self - } - pub fn can_focus(mut self, can_focus: bool) -> Self { self.can_focus = Some(can_focus); self @@ -280,6 +423,11 @@ impl AspectFrameBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -290,23 +438,18 @@ impl AspectFrameBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -330,21 +473,11 @@ impl AspectFrameBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -424,237 +557,10 @@ impl AspectFrameBuilder { self.width_request = Some(width_request); self } -} - -pub const NONE_ASPECT_FRAME: Option<&AspectFrame> = None; - -pub trait AspectFrameExt: 'static { - fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool); - - fn get_property_obey_child(&self) -> bool; - - fn set_property_obey_child(&self, obey_child: bool); - fn get_property_ratio(&self) -> f32; - - fn set_property_ratio(&self, ratio: f32); - - fn get_property_xalign(&self) -> f32; - - fn set_property_xalign(&self, xalign: f32); - - fn get_property_yalign(&self) -> f32; - - fn set_property_yalign(&self, yalign: f32); - - fn connect_property_obey_child_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_ratio_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_xalign_notify(&self, f: F) -> SignalHandlerId; - - fn connect_property_yalign_notify(&self, f: F) -> SignalHandlerId; -} - -impl> AspectFrameExt for O { - fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) { - unsafe { - gtk_sys::gtk_aspect_frame_set( - self.as_ref().to_glib_none().0, - xalign, - yalign, - ratio, - obey_child.to_glib(), - ); - } - } - - fn get_property_obey_child(&self) -> bool { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"obey-child\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `obey-child` getter") - .unwrap() - } - } - - fn set_property_obey_child(&self, obey_child: bool) { - unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"obey-child\0".as_ptr() as *const _, - Value::from(&obey_child).to_glib_none().0, - ); - } - } - - fn get_property_ratio(&self) -> f32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"ratio\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `ratio` getter") - .unwrap() - } - } - - fn set_property_ratio(&self, ratio: f32) { - unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"ratio\0".as_ptr() as *const _, - Value::from(&ratio).to_glib_none().0, - ); - } - } - - fn get_property_xalign(&self) -> f32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"xalign\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `xalign` getter") - .unwrap() - } - } - - fn set_property_xalign(&self, xalign: f32) { - unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"xalign\0".as_ptr() as *const _, - Value::from(&xalign).to_glib_none().0, - ); - } - } - - fn get_property_yalign(&self) -> f32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"yalign\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `yalign` getter") - .unwrap() - } - } - - fn set_property_yalign(&self, yalign: f32) { - unsafe { - gobject_sys::g_object_set_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"yalign\0".as_ptr() as *const _, - Value::from(&yalign).to_glib_none().0, - ); - } - } - - 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(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(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(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(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), - ) - } + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self } } diff --git a/src/auto/assistant.rs b/src/auto/assistant.rs index d3109d0713a7..5d7b524b4682 100644 --- a/src/auto/assistant.rs +++ b/src/auto/assistant.rs @@ -8,6 +8,7 @@ use glib; use glib::object::Cast; use glib::object::IsA; use glib::object::ObjectExt; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; @@ -21,23 +22,24 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use Application; use AssistantPage; use AssistantPageType; -use Bin; use Buildable; -use Container; +use ConstraintTarget; use LayoutManager; +use Native; use Overflow; use Root; +use ShortcutManager; use Widget; use Window; -use WindowPosition; -use WindowType; glib_wrapper! { - pub struct Assistant(Object) @extends Window, Bin, Container, Widget, @implements Buildable, Root; + pub struct Assistant(Object) @extends Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager; match fn { get_type => || gtk_sys::gtk_assistant_get_type(), @@ -49,6 +51,364 @@ impl Assistant { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_assistant_new()).unsafe_cast() } } + + pub fn add_action_widget>(&self, child: &P) { + unsafe { + gtk_sys::gtk_assistant_add_action_widget( + self.to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + pub fn append_page>(&self, page: &P) -> i32 { + unsafe { + gtk_sys::gtk_assistant_append_page( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + ) + } + } + + pub fn commit(&self) { + unsafe { + gtk_sys::gtk_assistant_commit(self.to_glib_none().0); + } + } + + pub fn get_current_page(&self) -> i32 { + unsafe { gtk_sys::gtk_assistant_get_current_page(self.to_glib_none().0) } + } + + pub fn get_n_pages(&self) -> i32 { + unsafe { gtk_sys::gtk_assistant_get_n_pages(self.to_glib_none().0) } + } + + pub fn get_nth_page(&self, page_num: i32) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_assistant_get_nth_page( + self.to_glib_none().0, + page_num, + )) + } + } + + pub fn get_page>(&self, child: &P) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_assistant_get_page( + self.to_glib_none().0, + child.as_ref().to_glib_none().0, + )) + } + } + + pub fn get_page_complete>(&self, page: &P) -> bool { + unsafe { + from_glib(gtk_sys::gtk_assistant_get_page_complete( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + )) + } + } + + pub fn get_page_title>(&self, page: &P) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_assistant_get_page_title( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + )) + } + } + + pub fn get_page_type>(&self, page: &P) -> AssistantPageType { + unsafe { + from_glib(gtk_sys::gtk_assistant_get_page_type( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + )) + } + } + + pub fn get_pages(&self) -> Option { + unsafe { from_glib_full(gtk_sys::gtk_assistant_get_pages(self.to_glib_none().0)) } + } + + pub fn insert_page>(&self, page: &P, position: i32) -> i32 { + unsafe { + gtk_sys::gtk_assistant_insert_page( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + position, + ) + } + } + + pub fn next_page(&self) { + unsafe { + gtk_sys::gtk_assistant_next_page(self.to_glib_none().0); + } + } + + pub fn prepend_page>(&self, page: &P) -> i32 { + unsafe { + gtk_sys::gtk_assistant_prepend_page( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + ) + } + } + + pub fn previous_page(&self) { + unsafe { + gtk_sys::gtk_assistant_previous_page(self.to_glib_none().0); + } + } + + pub fn remove_action_widget>(&self, child: &P) { + unsafe { + gtk_sys::gtk_assistant_remove_action_widget( + self.to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + pub fn remove_page(&self, page_num: i32) { + unsafe { + gtk_sys::gtk_assistant_remove_page(self.to_glib_none().0, page_num); + } + } + + pub fn set_current_page(&self, page_num: i32) { + unsafe { + gtk_sys::gtk_assistant_set_current_page(self.to_glib_none().0, page_num); + } + } + + pub fn set_forward_page_func(&self, page_func: Option i32 + 'static>>) { + let page_func_data: Box_ i32 + 'static>>> = Box_::new(page_func); + unsafe extern "C" fn page_func_func( + current_page: libc::c_int, + 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.to_glib_none().0, + page_func, + Box_::into_raw(super_callback0) as *mut _, + destroy_call3, + ); + } + } + + pub fn set_page_complete>(&self, page: &P, complete: bool) { + unsafe { + gtk_sys::gtk_assistant_set_page_complete( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + complete.to_glib(), + ); + } + } + + pub fn set_page_title>(&self, page: &P, title: &str) { + unsafe { + gtk_sys::gtk_assistant_set_page_title( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + title.to_glib_none().0, + ); + } + } + + pub fn set_page_type>(&self, page: &P, type_: AssistantPageType) { + unsafe { + gtk_sys::gtk_assistant_set_page_type( + self.to_glib_none().0, + page.as_ref().to_glib_none().0, + type_.to_glib(), + ); + } + } + + pub fn update_buttons_state(&self) { + unsafe { + gtk_sys::gtk_assistant_update_buttons_state(self.to_glib_none().0); + } + } + + pub fn get_property_use_header_bar(&self) -> i32 { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property( + self.as_ptr() as *mut gobject_sys::GObject, + b"use-header-bar\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value + .get() + .expect("Return Value for property `use-header-bar` getter") + .unwrap() + } + } + + pub fn connect_apply(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn apply_trampoline( + this: *mut gtk_sys::GtkAssistant, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"apply\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + apply_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_cancel(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn cancel_trampoline( + this: *mut gtk_sys::GtkAssistant, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"cancel\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + cancel_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_close(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn close_trampoline( + this: *mut gtk_sys::GtkAssistant, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"close\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + close_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_escape(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn escape_trampoline( + this: *mut gtk_sys::GtkAssistant, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"escape\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + escape_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn emit_escape(&self) { + let _ = unsafe { + glib::Object::from_glib_borrow(self.as_ptr() as *mut gobject_sys::GObject) + .emit("escape", &[]) + .unwrap() + }; + } + + pub fn connect_prepare(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn prepare_trampoline( + this: *mut gtk_sys::GtkAssistant, + page: *mut gtk_sys::GtkWidget, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &from_glib_borrow(page)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"prepare\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + prepare_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_pages_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_pages_trampoline( + this: *mut gtk_sys::GtkAssistant, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::pages\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_pages_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } impl Default for Assistant { @@ -60,9 +420,8 @@ impl Default for Assistant { #[derive(Clone, Default)] pub struct AssistantBuilder { use_header_bar: Option, - accept_focus: Option, application: Option, - attached_to: Option, + child: Option, decorated: Option, default_height: Option, default_widget: Option, @@ -70,8 +429,8 @@ pub struct AssistantBuilder { deletable: Option, destroy_with_parent: Option, display: Option, - focus_on_map: Option, focus_visible: Option, + focus_widget: Option, hide_on_close: Option, icon_name: Option, mnemonics_visible: Option, @@ -80,24 +439,19 @@ pub struct AssistantBuilder { startup_id: Option, title: Option, transient_for: Option, - type_: Option, - type_hint: Option, - window_position: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -114,7 +468,7 @@ pub struct AssistantBuilder { vexpand_set: Option, visible: Option, width_request: Option, - focus_widget: Option, + accessible_role: Option, } impl AssistantBuilder { @@ -127,14 +481,11 @@ impl AssistantBuilder { 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 child) = self.child { + properties.push(("child", child)); } if let Some(ref decorated) = self.decorated { properties.push(("decorated", decorated)); @@ -157,12 +508,12 @@ impl AssistantBuilder { if let Some(ref display) = self.display { properties.push(("display", display)); } - if let Some(ref focus_on_map) = self.focus_on_map { - properties.push(("focus-on-map", focus_on_map)); - } if let Some(ref focus_visible) = self.focus_visible { properties.push(("focus-visible", focus_visible)); } + if let Some(ref focus_widget) = self.focus_widget { + properties.push(("focus-widget", focus_widget)); + } if let Some(ref hide_on_close) = self.hide_on_close { properties.push(("hide-on-close", hide_on_close)); } @@ -187,39 +538,30 @@ impl AssistantBuilder { if let Some(ref transient_for) = self.transient_for { properties.push(("transient-for", transient_for)); } - if let Some(ref type_) = self.type_ { - properties.push(("type", type_)); - } - if let Some(ref type_hint) = self.type_hint { - properties.push(("type-hint", type_hint)); - } - if let Some(ref window_position) = self.window_position { - properties.push(("window-position", window_position)); - } if let Some(ref can_focus) = self.can_focus { properties.push(("can-focus", can_focus)); } if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -232,15 +574,9 @@ impl AssistantBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -289,13 +625,14 @@ impl AssistantBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } - if let Some(ref focus_widget) = self.focus_widget { - properties.push(("focus-widget", focus_widget)); + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); } - glib::Object::new(Assistant::static_type(), &properties) + let ret = glib::Object::new(Assistant::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn use_header_bar(mut self, use_header_bar: i32) -> Self { @@ -303,18 +640,13 @@ impl AssistantBuilder { self } - pub fn accept_focus(mut self, accept_focus: bool) -> Self { - self.accept_focus = Some(accept_focus); - self - } - pub fn application>(mut self, application: &P) -> Self { self.application = Some(application.clone().upcast()); self } - pub fn attached_to>(mut self, attached_to: &P) -> Self { - self.attached_to = Some(attached_to.clone().upcast()); + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); self } @@ -353,13 +685,13 @@ impl AssistantBuilder { self } - pub fn focus_on_map(mut self, focus_on_map: bool) -> Self { - self.focus_on_map = Some(focus_on_map); + pub fn focus_visible(mut self, focus_visible: bool) -> Self { + self.focus_visible = Some(focus_visible); self } - pub fn focus_visible(mut self, focus_visible: bool) -> Self { - self.focus_visible = Some(focus_visible); + pub fn focus_widget>(mut self, focus_widget: &P) -> Self { + self.focus_widget = Some(focus_widget.clone().upcast()); self } @@ -403,21 +735,6 @@ impl AssistantBuilder { self } - pub fn type_(mut self, type_: WindowType) -> Self { - self.type_ = Some(type_); - self - } - - pub fn type_hint(mut self, type_hint: gdk::SurfaceTypeHint) -> Self { - self.type_hint = Some(type_hint); - self - } - - pub fn window_position(mut self, window_position: WindowPosition) -> Self { - self.window_position = Some(window_position); - self - } - pub fn can_focus(mut self, can_focus: bool) -> Self { self.can_focus = Some(can_focus); self @@ -428,6 +745,11 @@ impl AssistantBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -438,574 +760,129 @@ impl AssistantBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } - - pub fn focus_widget>(mut self, focus_widget: &P) -> Self { - self.focus_widget = Some(focus_widget.clone().upcast()); - self - } -} - -pub const NONE_ASSISTANT: Option<&Assistant> = None; - -pub trait AssistantExt: 'static { - fn add_action_widget>(&self, child: &P); - - fn append_page>(&self, page: &P) -> i32; - - fn commit(&self); - - fn get_current_page(&self) -> i32; - - fn get_n_pages(&self) -> i32; - - fn get_nth_page(&self, page_num: i32) -> Option; - - fn get_page>(&self, child: &P) -> Option; - - fn get_page_complete>(&self, page: &P) -> bool; - - fn get_page_title>(&self, page: &P) -> Option; - - fn get_page_type>(&self, page: &P) -> AssistantPageType; - - fn get_pages(&self) -> Option; - - fn insert_page>(&self, page: &P, position: i32) -> i32; - - fn next_page(&self); - - fn prepend_page>(&self, page: &P) -> i32; - - fn previous_page(&self); - - fn remove_action_widget>(&self, child: &P); - - fn remove_page(&self, page_num: i32); - - fn set_current_page(&self, page_num: i32); - - fn set_forward_page_func(&self, page_func: Option i32 + 'static>>); - - fn set_page_complete>(&self, page: &P, complete: bool); - - fn set_page_title>(&self, page: &P, title: &str); - - fn set_page_type>(&self, page: &P, type_: AssistantPageType); - - fn update_buttons_state(&self); - - fn get_property_use_header_bar(&self) -> i32; - - fn connect_apply(&self, f: F) -> SignalHandlerId; - - fn connect_cancel(&self, f: F) -> SignalHandlerId; - - fn connect_close(&self, f: F) -> SignalHandlerId; - - fn connect_escape(&self, f: F) -> SignalHandlerId; - - fn emit_escape(&self); - - fn connect_prepare(&self, f: F) -> SignalHandlerId; - - fn connect_property_pages_notify(&self, f: F) -> SignalHandlerId; -} - -impl> AssistantExt for O { - fn add_action_widget>(&self, child: &P) { - unsafe { - 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 { - gtk_sys::gtk_assistant_append_page( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - ) - } - } - - fn commit(&self) { - unsafe { - gtk_sys::gtk_assistant_commit(self.as_ref().to_glib_none().0); - } - } - - fn get_current_page(&self) -> i32 { - unsafe { gtk_sys::gtk_assistant_get_current_page(self.as_ref().to_glib_none().0) } - } - - fn get_n_pages(&self) -> i32 { - 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(gtk_sys::gtk_assistant_get_nth_page( - self.as_ref().to_glib_none().0, - page_num, - )) - } - } - - fn get_page>(&self, child: &P) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_assistant_get_page( - self.as_ref().to_glib_none().0, - child.as_ref().to_glib_none().0, - )) - } - } - - fn get_page_complete>(&self, page: &P) -> bool { - unsafe { - from_glib(gtk_sys::gtk_assistant_get_page_complete( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - )) - } + pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { + self.focus_on_click = Some(focus_on_click); + self } - fn get_page_title>(&self, page: &P) -> Option { - unsafe { - from_glib_none(gtk_sys::gtk_assistant_get_page_title( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - )) - } + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); + self } - fn get_page_type>(&self, page: &P) -> AssistantPageType { - unsafe { - from_glib(gtk_sys::gtk_assistant_get_page_type( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - )) - } + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); + self } - fn get_pages(&self) -> Option { - unsafe { - from_glib_full(gtk_sys::gtk_assistant_get_pages( - self.as_ref().to_glib_none().0, - )) - } + pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { + self.has_tooltip = Some(has_tooltip); + self } - fn insert_page>(&self, page: &P, position: i32) -> i32 { - unsafe { - gtk_sys::gtk_assistant_insert_page( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - position, - ) - } + pub fn height_request(mut self, height_request: i32) -> Self { + self.height_request = Some(height_request); + self } - fn next_page(&self) { - unsafe { - gtk_sys::gtk_assistant_next_page(self.as_ref().to_glib_none().0); - } + pub fn hexpand(mut self, hexpand: bool) -> Self { + self.hexpand = Some(hexpand); + self } - fn prepend_page>(&self, page: &P) -> i32 { - unsafe { - gtk_sys::gtk_assistant_prepend_page( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - ) - } + pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { + self.hexpand_set = Some(hexpand_set); + self } - fn previous_page(&self) { - unsafe { - gtk_sys::gtk_assistant_previous_page(self.as_ref().to_glib_none().0); - } + pub fn layout_manager>(mut self, layout_manager: &P) -> Self { + self.layout_manager = Some(layout_manager.clone().upcast()); + self } - fn remove_action_widget>(&self, child: &P) { - unsafe { - gtk_sys::gtk_assistant_remove_action_widget( - self.as_ref().to_glib_none().0, - child.as_ref().to_glib_none().0, - ); - } + pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { + self.margin_bottom = Some(margin_bottom); + self } - fn remove_page(&self, page_num: i32) { - unsafe { - gtk_sys::gtk_assistant_remove_page(self.as_ref().to_glib_none().0, page_num); - } + pub fn margin_end(mut self, margin_end: i32) -> Self { + self.margin_end = Some(margin_end); + self } - fn set_current_page(&self, page_num: i32) { - unsafe { - gtk_sys::gtk_assistant_set_current_page(self.as_ref().to_glib_none().0, page_num); - } + pub fn margin_start(mut self, margin_start: i32) -> Self { + self.margin_start = Some(margin_start); + self } - 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, - ); - } + pub fn margin_top(mut self, margin_top: i32) -> Self { + self.margin_top = Some(margin_top); + self } - fn set_page_complete>(&self, page: &P, complete: bool) { - unsafe { - gtk_sys::gtk_assistant_set_page_complete( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - complete.to_glib(), - ); - } + pub fn name(mut self, name: &str) -> Self { + self.name = Some(name.to_string()); + self } - fn set_page_title>(&self, page: &P, title: &str) { - unsafe { - 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, - ); - } + pub fn opacity(mut self, opacity: f64) -> Self { + self.opacity = Some(opacity); + self } - fn set_page_type>(&self, page: &P, type_: AssistantPageType) { - unsafe { - gtk_sys::gtk_assistant_set_page_type( - self.as_ref().to_glib_none().0, - page.as_ref().to_glib_none().0, - type_.to_glib(), - ); - } + pub fn overflow(mut self, overflow: Overflow) -> Self { + self.overflow = Some(overflow); + self } - fn update_buttons_state(&self) { - unsafe { - gtk_sys::gtk_assistant_update_buttons_state(self.as_ref().to_glib_none().0); - } + pub fn receives_default(mut self, receives_default: bool) -> Self { + self.receives_default = Some(receives_default); + self } - fn get_property_use_header_bar(&self) -> i32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_sys::g_object_get_property( - self.to_glib_none().0 as *mut gobject_sys::GObject, - b"use-header-bar\0".as_ptr() as *const _, - value.to_glib_none_mut().0, - ); - value - .get() - .expect("Return Value for property `use-header-bar` getter") - .unwrap() - } + pub fn sensitive(mut self, sensitive: bool) -> Self { + self.sensitive = Some(sensitive); + self } - 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(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), - ) - } + pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { + self.tooltip_markup = Some(tooltip_markup.to_string()); + self } - 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(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), - ) - } + pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { + self.tooltip_text = Some(tooltip_text.to_string()); + self } - 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(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), - ) - } + pub fn valign(mut self, valign: Align) -> Self { + self.valign = Some(valign); + self } - 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(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), - ) - } + pub fn vexpand(mut self, vexpand: bool) -> Self { + self.vexpand = Some(vexpand); + self } - fn emit_escape(&self) { - let _ = unsafe { - glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) - .emit("escape", &[]) - .unwrap() - }; + pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { + self.vexpand_set = Some(vexpand_set); + self } - fn connect_prepare(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn prepare_trampoline( - this: *mut gtk_sys::GtkAssistant, - page: *mut gtk_sys::GtkWidget, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f( - &Assistant::from_glib_borrow(this).unsafe_cast(), - &from_glib_borrow(page), - ) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"prepare\0".as_ptr() as *const _, - Some(transmute(prepare_trampoline:: as usize)), - Box_::into_raw(f), - ) - } + pub fn visible(mut self, visible: bool) -> Self { + self.visible = Some(visible); + self } - fn connect_property_pages_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_pages_trampoline( - this: *mut gtk_sys::GtkAssistant, - _param_spec: glib_sys::gpointer, - f: glib_sys::gpointer, - ) where - P: IsA, - { - let f: &F = &*(f as *const F); - f(&Assistant::from_glib_borrow(this).unsafe_cast()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::pages\0".as_ptr() as *const _, - Some(transmute(notify_pages_trampoline:: as usize)), - Box_::into_raw(f), - ) - } + pub fn width_request(mut self, width_request: i32) -> Self { + self.width_request = Some(width_request); + self + } + + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self } } diff --git a/src/auto/assistant_page.rs b/src/auto/assistant_page.rs index 150b81c328d3..53c848767829 100644 --- a/src/auto/assistant_page.rs +++ b/src/auto/assistant_page.rs @@ -2,12 +2,15 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use glib::object::Cast; +use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; +use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; @@ -19,7 +22,7 @@ use AssistantPageType; use Widget; glib_wrapper! { - pub struct AssistantPage(Object); + pub struct AssistantPage(Object); match fn { get_type => || gtk_sys::gtk_assistant_page_get_type(), @@ -122,7 +125,9 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::complete\0".as_ptr() as *const _, - Some(transmute(notify_complete_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_complete_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -145,7 +150,9 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::page-type\0".as_ptr() as *const _, - Some(transmute(notify_page_type_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_page_type_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -168,13 +175,70 @@ impl AssistantPage { connect_raw( self.as_ptr() as *mut _, b"notify::title\0".as_ptr() as *const _, - Some(transmute(notify_title_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_title_trampoline:: as *const (), + )), Box_::into_raw(f), ) } } } +#[derive(Clone, Default)] +pub struct AssistantPageBuilder { + child: Option, + complete: Option, + page_type: Option, + title: Option, +} + +impl AssistantPageBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> AssistantPage { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref complete) = self.complete { + properties.push(("complete", complete)); + } + if let Some(ref page_type) = self.page_type { + properties.push(("page-type", page_type)); + } + if let Some(ref title) = self.title { + properties.push(("title", title)); + } + let ret = glib::Object::new(AssistantPage::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn child>(mut self, child: &P) -> Self { + self.child = Some(child.clone().upcast()); + self + } + + pub fn complete(mut self, complete: bool) -> Self { + self.complete = Some(complete); + self + } + + pub fn page_type(mut self, page_type: AssistantPageType) -> Self { + self.page_type = Some(page_type); + self + } + + pub fn title(mut self, title: &str) -> Self { + self.title = Some(title.to_string()); + self + } +} + impl fmt::Display for AssistantPage { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AssistantPage") diff --git a/src/auto/at_context.rs b/src/auto/at_context.rs new file mode 100644 index 000000000000..4d89a890341d --- /dev/null +++ b/src/auto/at_context.rs @@ -0,0 +1,61 @@ +// 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 Accessible; +use AccessibleRole; + +glib_wrapper! { + pub struct ATContext(Object); + + match fn { + get_type => || gtk_sys::gtk_at_context_get_type(), + } +} + +impl ATContext { + pub fn create>( + accessible_role: AccessibleRole, + accessible: &P, + ) -> Option { + skip_assert_initialized!(); + unsafe { + from_glib_full(gtk_sys::gtk_at_context_create( + accessible_role.to_glib(), + accessible.as_ref().to_glib_none().0, + )) + } + } + + pub fn get_accessible(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_at_context_get_accessible( + self.to_glib_none().0, + )) + } + } + + pub fn get_accessible_role(&self) -> AccessibleRole { + unsafe { + from_glib(gtk_sys::gtk_at_context_get_accessible_role( + self.to_glib_none().0, + )) + } + } + + //pub fn connect_state_change(&self, f: F) -> SignalHandlerId { + // Unimplemented states: *.Pointer + // Unimplemented properties: *.Pointer + // Unimplemented relations: *.Pointer + //} +} + +impl fmt::Display for ATContext { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ATContext") + } +} diff --git a/src/auto/bin.rs b/src/auto/bin.rs deleted file mode 100644 index b799b06f084c..000000000000 --- a/src/auto/bin.rs +++ /dev/null @@ -1,341 +0,0 @@ -// 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 gtk_sys; -use std::fmt; -use Align; -use Buildable; -use Container; -use LayoutManager; -use Overflow; -use Widget; - -glib_wrapper! { - pub struct Bin(Object) @extends Container, Widget, @implements Buildable; - - match fn { - get_type => || gtk_sys::gtk_bin_get_type(), - } -} - -#[derive(Clone, Default)] -pub struct BinBuilder { - can_focus: Option, - can_target: Option, - css_name: Option, - cursor: Option, - expand: Option, - focus_on_click: Option, - halign: Option, - has_focus: Option, - has_tooltip: Option, - height_request: Option, - hexpand: Option, - hexpand_set: Option, - is_focus: Option, - layout_manager: Option, - margin: Option, - margin_bottom: Option, - margin_end: Option, - margin_start: Option, - margin_top: Option, - name: Option, - opacity: Option, - overflow: Option, - receives_default: Option, - sensitive: Option, - tooltip_markup: Option, - tooltip_text: Option, - valign: Option, - vexpand: Option, - vexpand_set: Option, - visible: Option, - width_request: Option, -} - -impl BinBuilder { - pub fn new() -> Self { - Self::default() - } - - pub fn build(self) -> Bin { - let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; - if let Some(ref can_focus) = self.can_focus { - properties.push(("can-focus", can_focus)); - } - if let Some(ref can_target) = self.can_target { - properties.push(("can-target", can_target)); - } - if let Some(ref css_name) = self.css_name { - properties.push(("css-name", css_name)); - } - if let Some(ref cursor) = self.cursor { - properties.push(("cursor", cursor)); - } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } - if let Some(ref focus_on_click) = self.focus_on_click { - properties.push(("focus-on-click", focus_on_click)); - } - if let Some(ref halign) = self.halign { - properties.push(("halign", halign)); - } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } - if let Some(ref has_tooltip) = self.has_tooltip { - properties.push(("has-tooltip", has_tooltip)); - } - if let Some(ref height_request) = self.height_request { - properties.push(("height-request", height_request)); - } - if let Some(ref hexpand) = self.hexpand { - properties.push(("hexpand", hexpand)); - } - if let Some(ref hexpand_set) = self.hexpand_set { - properties.push(("hexpand-set", hexpand_set)); - } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } - if let Some(ref layout_manager) = self.layout_manager { - properties.push(("layout-manager", layout_manager)); - } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } - if let Some(ref margin_bottom) = self.margin_bottom { - properties.push(("margin-bottom", margin_bottom)); - } - if let Some(ref margin_end) = self.margin_end { - properties.push(("margin-end", margin_end)); - } - if let Some(ref margin_start) = self.margin_start { - properties.push(("margin-start", margin_start)); - } - if let Some(ref margin_top) = self.margin_top { - properties.push(("margin-top", margin_top)); - } - if let Some(ref name) = self.name { - properties.push(("name", name)); - } - if let Some(ref opacity) = self.opacity { - properties.push(("opacity", opacity)); - } - if let Some(ref overflow) = self.overflow { - properties.push(("overflow", overflow)); - } - if let Some(ref receives_default) = self.receives_default { - properties.push(("receives-default", receives_default)); - } - if let Some(ref sensitive) = self.sensitive { - properties.push(("sensitive", sensitive)); - } - if let Some(ref tooltip_markup) = self.tooltip_markup { - properties.push(("tooltip-markup", tooltip_markup)); - } - if let Some(ref tooltip_text) = self.tooltip_text { - properties.push(("tooltip-text", tooltip_text)); - } - if let Some(ref valign) = self.valign { - properties.push(("valign", valign)); - } - if let Some(ref vexpand) = self.vexpand { - properties.push(("vexpand", vexpand)); - } - if let Some(ref vexpand_set) = self.vexpand_set { - properties.push(("vexpand-set", vexpand_set)); - } - if let Some(ref visible) = self.visible { - properties.push(("visible", visible)); - } - if let Some(ref width_request) = self.width_request { - properties.push(("width-request", width_request)); - } - glib::Object::new(Bin::static_type(), &properties) - .expect("object new") - .downcast() - .expect("downcast") - } - - pub fn can_focus(mut self, can_focus: bool) -> Self { - self.can_focus = Some(can_focus); - self - } - - pub fn can_target(mut self, can_target: bool) -> Self { - self.can_target = Some(can_target); - self - } - - pub fn css_name(mut self, css_name: &str) -> Self { - self.css_name = Some(css_name.to_string()); - self - } - - pub fn cursor(mut self, cursor: &gdk::Cursor) -> Self { - self.cursor = Some(cursor.clone()); - self - } - - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { - self.focus_on_click = Some(focus_on_click); - self - } - - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); - self - } - - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); - self - } - - pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { - self.has_tooltip = Some(has_tooltip); - self - } - - pub fn height_request(mut self, height_request: i32) -> Self { - self.height_request = Some(height_request); - self - } - - pub fn hexpand(mut self, hexpand: bool) -> Self { - self.hexpand = Some(hexpand); - self - } - - pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { - self.hexpand_set = Some(hexpand_set); - self - } - - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { - self.layout_manager = Some(layout_manager.clone().upcast()); - self - } - - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { - self.margin_bottom = Some(margin_bottom); - self - } - - pub fn margin_end(mut self, margin_end: i32) -> Self { - self.margin_end = Some(margin_end); - self - } - - pub fn margin_start(mut self, margin_start: i32) -> Self { - self.margin_start = Some(margin_start); - self - } - - pub fn margin_top(mut self, margin_top: i32) -> Self { - self.margin_top = Some(margin_top); - self - } - - pub fn name(mut self, name: &str) -> Self { - self.name = Some(name.to_string()); - self - } - - pub fn opacity(mut self, opacity: f64) -> Self { - self.opacity = Some(opacity); - self - } - - pub fn overflow(mut self, overflow: Overflow) -> Self { - self.overflow = Some(overflow); - self - } - - pub fn receives_default(mut self, receives_default: bool) -> Self { - self.receives_default = Some(receives_default); - self - } - - pub fn sensitive(mut self, sensitive: bool) -> Self { - self.sensitive = Some(sensitive); - self - } - - pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { - self.tooltip_markup = Some(tooltip_markup.to_string()); - self - } - - pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { - self.tooltip_text = Some(tooltip_text.to_string()); - self - } - - pub fn valign(mut self, valign: Align) -> Self { - self.valign = Some(valign); - self - } - - pub fn vexpand(mut self, vexpand: bool) -> Self { - self.vexpand = Some(vexpand); - self - } - - pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { - self.vexpand_set = Some(vexpand_set); - self - } - - pub fn visible(mut self, visible: bool) -> Self { - self.visible = Some(visible); - self - } - - pub fn width_request(mut self, width_request: i32) -> Self { - self.width_request = Some(width_request); - self - } -} - -pub const NONE_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(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/bitset.rs b/src/auto/bitset.rs new file mode 100644 index 000000000000..b6686445abf3 --- /dev/null +++ b/src/auto/bitset.rs @@ -0,0 +1,168 @@ +// 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::translate::*; +use gtk_sys; + +glib_wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct Bitset(Shared); + + match fn { + ref => |ptr| gtk_sys::gtk_bitset_ref(ptr), + unref => |ptr| gtk_sys::gtk_bitset_unref(ptr), + get_type => || gtk_sys::gtk_bitset_get_type(), + } +} + +impl Bitset { + pub fn new_empty() -> Bitset { + assert_initialized_main_thread!(); + unsafe { from_glib_full(gtk_sys::gtk_bitset_new_empty()) } + } + + pub fn new_range(start: u32, n_items: u32) -> Bitset { + assert_initialized_main_thread!(); + unsafe { from_glib_full(gtk_sys::gtk_bitset_new_range(start, n_items)) } + } + + pub fn add(&self, value: u32) -> bool { + unsafe { from_glib(gtk_sys::gtk_bitset_add(self.to_glib_none().0, value)) } + } + + pub fn add_range(&self, start: u32, n_items: u32) { + unsafe { + gtk_sys::gtk_bitset_add_range(self.to_glib_none().0, start, n_items); + } + } + + pub fn add_range_closed(&self, first: u32, last: u32) { + unsafe { + gtk_sys::gtk_bitset_add_range_closed(self.to_glib_none().0, first, last); + } + } + + pub fn add_rectangle(&self, start: u32, width: u32, height: u32, stride: u32) { + unsafe { + gtk_sys::gtk_bitset_add_rectangle(self.to_glib_none().0, start, width, height, stride); + } + } + + pub fn contains(&self, value: u32) -> bool { + unsafe { from_glib(gtk_sys::gtk_bitset_contains(self.to_glib_none().0, value)) } + } + + pub fn copy(&self) -> Option { + unsafe { from_glib_full(gtk_sys::gtk_bitset_copy(self.to_glib_none().0)) } + } + + pub fn difference(&self, other: &Bitset) { + unsafe { + gtk_sys::gtk_bitset_difference(self.to_glib_none().0, other.to_glib_none().0); + } + } + + pub fn equals(&self, other: &Bitset) -> bool { + unsafe { + from_glib(gtk_sys::gtk_bitset_equals( + self.to_glib_none().0, + other.to_glib_none().0, + )) + } + } + + pub fn get_maximum(&self) -> u32 { + unsafe { gtk_sys::gtk_bitset_get_maximum(self.to_glib_none().0) } + } + + pub fn get_minimum(&self) -> u32 { + unsafe { gtk_sys::gtk_bitset_get_minimum(self.to_glib_none().0) } + } + + pub fn get_nth(&self, nth: u32) -> u32 { + unsafe { gtk_sys::gtk_bitset_get_nth(self.to_glib_none().0, nth) } + } + + pub fn get_size(&self) -> u64 { + unsafe { gtk_sys::gtk_bitset_get_size(self.to_glib_none().0) } + } + + pub fn get_size_in_range(&self, first: u32, last: u32) -> u64 { + unsafe { gtk_sys::gtk_bitset_get_size_in_range(self.to_glib_none().0, first, last) } + } + + pub fn intersect(&self, other: &Bitset) { + unsafe { + gtk_sys::gtk_bitset_intersect(self.to_glib_none().0, other.to_glib_none().0); + } + } + + pub fn is_empty(&self) -> bool { + unsafe { from_glib(gtk_sys::gtk_bitset_is_empty(self.to_glib_none().0)) } + } + + pub fn remove(&self, value: u32) -> bool { + unsafe { from_glib(gtk_sys::gtk_bitset_remove(self.to_glib_none().0, value)) } + } + + pub fn remove_all(&self) { + unsafe { + gtk_sys::gtk_bitset_remove_all(self.to_glib_none().0); + } + } + + pub fn remove_range(&self, start: u32, n_items: u32) { + unsafe { + gtk_sys::gtk_bitset_remove_range(self.to_glib_none().0, start, n_items); + } + } + + pub fn remove_range_closed(&self, first: u32, last: u32) { + unsafe { + gtk_sys::gtk_bitset_remove_range_closed(self.to_glib_none().0, first, last); + } + } + + pub fn remove_rectangle(&self, start: u32, width: u32, height: u32, stride: u32) { + unsafe { + gtk_sys::gtk_bitset_remove_rectangle( + self.to_glib_none().0, + start, + width, + height, + stride, + ); + } + } + + pub fn shift_left(&self, amount: u32) { + unsafe { + gtk_sys::gtk_bitset_shift_left(self.to_glib_none().0, amount); + } + } + + pub fn shift_right(&self, amount: u32) { + unsafe { + gtk_sys::gtk_bitset_shift_right(self.to_glib_none().0, amount); + } + } + + pub fn splice(&self, position: u32, removed: u32, added: u32) { + unsafe { + gtk_sys::gtk_bitset_splice(self.to_glib_none().0, position, removed, added); + } + } + + pub fn subtract(&self, other: &Bitset) { + unsafe { + gtk_sys::gtk_bitset_subtract(self.to_glib_none().0, other.to_glib_none().0); + } + } + + pub fn union(&self, other: &Bitset) { + unsafe { + gtk_sys::gtk_bitset_union(self.to_glib_none().0, other.to_glib_none().0); + } + } +} diff --git a/src/auto/bookmark_list.rs b/src/auto/bookmark_list.rs new file mode 100644 index 000000000000..f9f5a941a523 --- /dev/null +++ b/src/auto/bookmark_list.rs @@ -0,0 +1,248 @@ +// 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 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; + +glib_wrapper! { + pub struct BookmarkList(Object) @implements gio::ListModel; + + match fn { + get_type => || gtk_sys::gtk_bookmark_list_get_type(), + } +} + +impl BookmarkList { + pub fn new(filename: Option<&str>, attributes: Option<&str>) -> BookmarkList { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(gtk_sys::gtk_bookmark_list_new( + filename.to_glib_none().0, + attributes.to_glib_none().0, + )) + } + } +} + +#[derive(Clone, Default)] +pub struct BookmarkListBuilder { + attributes: Option, + filename: Option, + io_priority: Option, +} + +impl BookmarkListBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> BookmarkList { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref attributes) = self.attributes { + properties.push(("attributes", attributes)); + } + if let Some(ref filename) = self.filename { + properties.push(("filename", filename)); + } + if let Some(ref io_priority) = self.io_priority { + properties.push(("io-priority", io_priority)); + } + let ret = glib::Object::new(BookmarkList::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn attributes(mut self, attributes: &str) -> Self { + self.attributes = Some(attributes.to_string()); + self + } + + pub fn filename(mut self, filename: &str) -> Self { + self.filename = Some(filename.to_string()); + self + } + + pub fn io_priority(mut self, io_priority: i32) -> Self { + self.io_priority = Some(io_priority); + self + } +} + +pub const NONE_BOOKMARK_LIST: Option<&BookmarkList> = None; + +pub trait BookmarkListExt: 'static { + fn get_attributes(&self) -> Option; + + fn get_filename(&self) -> Option; + + fn get_io_priority(&self) -> i32; + + fn is_loading(&self) -> bool; + + fn set_attributes(&self, attributes: Option<&str>); + + fn set_io_priority(&self, io_priority: i32); + + fn get_property_loading(&self) -> bool; + + fn connect_property_attributes_notify(&self, f: F) -> SignalHandlerId; + + fn connect_property_io_priority_notify(&self, f: F) -> SignalHandlerId; + + fn connect_property_loading_notify(&self, f: F) -> SignalHandlerId; +} + +impl> BookmarkListExt for O { + fn get_attributes(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_bookmark_list_get_attributes( + self.as_ref().to_glib_none().0, + )) + } + } + + fn get_filename(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_bookmark_list_get_filename( + self.as_ref().to_glib_none().0, + )) + } + } + + fn get_io_priority(&self) -> i32 { + unsafe { gtk_sys::gtk_bookmark_list_get_io_priority(self.as_ref().to_glib_none().0) } + } + + fn is_loading(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_bookmark_list_is_loading( + self.as_ref().to_glib_none().0, + )) + } + } + + fn set_attributes(&self, attributes: Option<&str>) { + unsafe { + gtk_sys::gtk_bookmark_list_set_attributes( + self.as_ref().to_glib_none().0, + attributes.to_glib_none().0, + ); + } + } + + fn set_io_priority(&self, io_priority: i32) { + unsafe { + gtk_sys::gtk_bookmark_list_set_io_priority(self.as_ref().to_glib_none().0, io_priority); + } + } + + fn get_property_loading(&self) -> bool { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property( + self.to_glib_none().0 as *mut gobject_sys::GObject, + b"loading\0".as_ptr() as *const _, + value.to_glib_none_mut().0, + ); + value + .get() + .expect("Return Value for property `loading` getter") + .unwrap() + } + } + + fn connect_property_attributes_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_attributes_trampoline( + this: *mut gtk_sys::GtkBookmarkList, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&BookmarkList::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::attributes\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_attributes_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + fn connect_property_io_priority_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_io_priority_trampoline( + this: *mut gtk_sys::GtkBookmarkList, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&BookmarkList::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::io-priority\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_io_priority_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + fn connect_property_loading_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_loading_trampoline( + this: *mut gtk_sys::GtkBookmarkList, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&BookmarkList::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::loading\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_loading_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl fmt::Display for BookmarkList { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BookmarkList") + } +} diff --git a/src/auto/bool_filter.rs b/src/auto/bool_filter.rs new file mode 100644 index 000000000000..d36e52380aa7 --- /dev/null +++ b/src/auto/bool_filter.rs @@ -0,0 +1,154 @@ +// 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::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 Filter; + +glib_wrapper! { + pub struct BoolFilter(Object) @extends Filter; + + match fn { + get_type => || gtk_sys::gtk_bool_filter_get_type(), + } +} + +impl BoolFilter { + //pub fn new(expression: /*Ignored*/Option<&Expression>) -> BoolFilter { + // unsafe { TODO: call gtk_sys:gtk_bool_filter_new() } + //} +} + +#[derive(Clone, Default)] +pub struct BoolFilterBuilder { + //expression: /*Unknown type*/, + invert: Option, +} + +impl BoolFilterBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> BoolFilter { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref invert) = self.invert { + properties.push(("invert", invert)); + } + let ret = glib::Object::new(BoolFilter::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn invert(mut self, invert: bool) -> Self { + self.invert = Some(invert); + self + } +} + +pub const NONE_BOOL_FILTER: Option<&BoolFilter> = None; + +pub trait BoolFilterExt: 'static { + //fn get_expression(&self) -> /*Ignored*/Option; + + fn get_invert(&self) -> bool; + + //fn set_expression(&self, expression: /*Ignored*/&Expression); + + fn set_invert(&self, invert: bool); + + fn connect_property_expression_notify(&self, f: F) -> SignalHandlerId; + + fn connect_property_invert_notify(&self, f: F) -> SignalHandlerId; +} + +impl> BoolFilterExt for O { + //fn get_expression(&self) -> /*Ignored*/Option { + // unsafe { TODO: call gtk_sys:gtk_bool_filter_get_expression() } + //} + + fn get_invert(&self) -> bool { + unsafe { + from_glib(gtk_sys::gtk_bool_filter_get_invert( + self.as_ref().to_glib_none().0, + )) + } + } + + //fn set_expression(&self, expression: /*Ignored*/&Expression) { + // unsafe { TODO: call gtk_sys:gtk_bool_filter_set_expression() } + //} + + fn set_invert(&self, invert: bool) { + unsafe { + gtk_sys::gtk_bool_filter_set_invert(self.as_ref().to_glib_none().0, invert.to_glib()); + } + } + + fn connect_property_expression_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_expression_trampoline( + this: *mut gtk_sys::GtkBoolFilter, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&BoolFilter::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::expression\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_expression_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + fn connect_property_invert_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_invert_trampoline( + this: *mut gtk_sys::GtkBoolFilter, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) where + P: IsA, + { + let f: &F = &*(f as *const F); + f(&BoolFilter::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::invert\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_invert_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl fmt::Display for BoolFilter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BoolFilter") + } +} diff --git a/src/auto/box_.rs b/src/auto/box_.rs index 0e2133da99ef..76701736ab13 100644 --- a/src/auto/box_.rs +++ b/src/auto/box_.rs @@ -15,10 +15,12 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Align; use BaselinePosition; use Buildable; -use Container; +use ConstraintTarget; use LayoutManager; use Orientable; use Orientation; @@ -26,7 +28,7 @@ use Overflow; use Widget; glib_wrapper! { - pub struct Box(Object) @extends Container, Widget, @implements Buildable, Orientable; + pub struct Box(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable; match fn { get_type => || gtk_sys::gtk_box_get_type(), @@ -50,19 +52,17 @@ pub struct BoxBuilder { spacing: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -79,6 +79,7 @@ pub struct BoxBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, orientation: Option, } @@ -104,24 +105,24 @@ impl BoxBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -134,15 +135,9 @@ impl BoxBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -191,13 +186,17 @@ impl BoxBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } if let Some(ref orientation) = self.orientation { properties.push(("orientation", orientation)); } - glib::Object::new(Box::static_type(), &properties) + let ret = glib::Object::new(Box::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::() + .expect("downcast"); + ret } pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { @@ -225,6 +224,11 @@ impl BoxBuilder { self } + pub fn css_classes(mut self, css_classes: Vec) -> Self { + self.css_classes = Some(css_classes); + self + } + pub fn css_name(mut self, css_name: &str) -> Self { self.css_name = Some(css_name.to_string()); self @@ -235,23 +239,18 @@ impl BoxBuilder { self } - pub fn expand(mut self, expand: bool) -> Self { - self.expand = Some(expand); - self - } - pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { self.focus_on_click = Some(focus_on_click); self } - pub fn halign(mut self, halign: Align) -> Self { - self.halign = Some(halign); + pub fn focusable(mut self, focusable: bool) -> Self { + self.focusable = Some(focusable); self } - pub fn has_focus(mut self, has_focus: bool) -> Self { - self.has_focus = Some(has_focus); + pub fn halign(mut self, halign: Align) -> Self { + self.halign = Some(halign); self } @@ -275,21 +274,11 @@ impl BoxBuilder { self } - pub fn is_focus(mut self, is_focus: bool) -> Self { - self.is_focus = Some(is_focus); - self - } - pub fn layout_manager>(mut self, layout_manager: &P) -> Self { self.layout_manager = Some(layout_manager.clone().upcast()); self } - pub fn margin(mut self, margin: i32) -> Self { - self.margin = Some(margin); - self - } - pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { self.margin_bottom = Some(margin_bottom); self @@ -370,6 +359,11 @@ impl BoxBuilder { self } + pub fn accessible_role(mut self, accessible_role: AccessibleRole) -> Self { + self.accessible_role = Some(accessible_role); + self + } + pub fn orientation(mut self, orientation: Orientation) -> Self { self.orientation = Some(orientation); self @@ -379,6 +373,8 @@ impl BoxBuilder { pub const NONE_BOX: Option<&Box> = None; pub trait BoxExt: 'static { + fn append>(&self, child: &P); + fn get_baseline_position(&self) -> BaselinePosition; fn get_homogeneous(&self) -> bool; @@ -387,6 +383,10 @@ pub trait BoxExt: 'static { fn insert_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>); + fn prepend>(&self, child: &P); + + fn remove>(&self, child: &P); + fn reorder_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>); fn set_baseline_position(&self, position: BaselinePosition); @@ -406,6 +406,15 @@ pub trait BoxExt: 'static { } impl> BoxExt for O { + fn append>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_append( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + fn get_baseline_position(&self) -> BaselinePosition { unsafe { from_glib(gtk_sys::gtk_box_get_baseline_position( @@ -436,6 +445,24 @@ impl> BoxExt for O { } } + fn prepend>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_prepend( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + + fn remove>(&self, child: &P) { + unsafe { + gtk_sys::gtk_box_remove( + self.as_ref().to_glib_none().0, + child.as_ref().to_glib_none().0, + ); + } + } + fn reorder_child_after, Q: IsA>(&self, child: &P, sibling: Option<&Q>) { unsafe { gtk_sys::gtk_box_reorder_child_after( @@ -479,15 +506,15 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::baseline-position\0".as_ptr() as *const _, - Some(transmute( - notify_baseline_position_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_baseline_position_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -503,14 +530,16 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::homogeneous\0".as_ptr() as *const _, - Some(transmute(notify_homogeneous_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_homogeneous_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -525,14 +554,16 @@ impl> BoxExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&Box::from_glib_borrow(this).unsafe_cast()) + f(&Box::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::spacing\0".as_ptr() as *const _, - Some(transmute(notify_spacing_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_spacing_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/box_layout.rs b/src/auto/box_layout.rs index 624cadebe2ff..2ca79a54110a 100644 --- a/src/auto/box_layout.rs +++ b/src/auto/box_layout.rs @@ -7,6 +7,8 @@ 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_; @@ -35,6 +37,61 @@ impl BoxLayout { } } +#[derive(Clone, Default)] +pub struct BoxLayoutBuilder { + baseline_position: Option, + homogeneous: Option, + spacing: Option, + orientation: Option, +} + +impl BoxLayoutBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> BoxLayout { + 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 orientation) = self.orientation { + properties.push(("orientation", orientation)); + } + let ret = glib::Object::new(BoxLayout::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + 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 orientation(mut self, orientation: Orientation) -> Self { + self.orientation = Some(orientation); + self + } +} + pub const NONE_BOX_LAYOUT: Option<&BoxLayout> = None; pub trait BoxLayoutExt: 'static { @@ -117,15 +174,15 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::baseline-position\0".as_ptr() as *const _, - Some(transmute( - notify_baseline_position_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_baseline_position_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -141,14 +198,16 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::homogeneous\0".as_ptr() as *const _, - Some(transmute(notify_homogeneous_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_homogeneous_trampoline:: as *const (), + )), Box_::into_raw(f), ) } @@ -163,14 +222,16 @@ impl> BoxLayoutExt for O { P: IsA, { let f: &F = &*(f as *const F); - f(&BoxLayout::from_glib_borrow(this).unsafe_cast()) + f(&BoxLayout::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::spacing\0".as_ptr() as *const _, - Some(transmute(notify_spacing_trampoline:: as usize)), + Some(transmute::<_, unsafe extern "C" fn()>( + notify_spacing_trampoline:: as *const (), + )), Box_::into_raw(f), ) } diff --git a/src/auto/buildable.rs b/src/auto/buildable.rs index a6dce90abd2d..e7f47bde56e1 100644 --- a/src/auto/buildable.rs +++ b/src/auto/buildable.rs @@ -21,84 +21,66 @@ glib_wrapper! { pub const NONE_BUILDABLE: Option<&Buildable> = None; pub trait BuildableExt: 'static { - fn add_child, Q: IsA>( - &self, - builder: &P, - child: &Q, - type_: Option<&str>, - ); + fn add_child>(&self, builder: &Builder, child: &P, type_: Option<&str>); - fn construct_child>(&self, builder: &P, name: &str) -> Option; + fn construct_child(&self, builder: &Builder, name: &str) -> Option; - //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); + //fn custom_finished>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option); + //fn custom_tag_end>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option); - //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option; + //fn custom_tag_start>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option; - fn get_internal_child>( - &self, - builder: &P, - childname: &str, - ) -> Option; + fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option; fn get_name(&self) -> Option; - fn parser_finished>(&self, builder: &P); + fn parser_finished(&self, builder: &Builder); - fn set_buildable_property>(&self, builder: &P, name: &str, value: &glib::Value); + fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value); fn set_name(&self, name: &str); } impl> BuildableExt for O { - fn add_child, Q: IsA>( - &self, - builder: &P, - child: &Q, - type_: Option<&str>, - ) { + fn add_child>(&self, builder: &Builder, child: &P, type_: Option<&str>) { unsafe { gtk_sys::gtk_buildable_add_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, child.as_ref().to_glib_none().0, type_.to_glib_none().0, ); } } - fn construct_child>(&self, builder: &P, name: &str) -> Option { + fn construct_child(&self, builder: &Builder, name: &str) -> Option { unsafe { from_glib_full(gtk_sys::gtk_buildable_construct_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, name.to_glib_none().0, )) } } - //fn custom_finished, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + //fn custom_finished>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option) { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_finished() } //} - //fn custom_tag_end, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/Option) { + //fn custom_tag_end>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/Option) { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_end() } //} - //fn custom_tag_start, Q: IsA>(&self, builder: &P, child: Option<&Q>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option { + //fn custom_tag_start>(&self, builder: &Builder, child: Option<&P>, tagname: &str, data: /*Unimplemented*/&mut Option) -> Option { // unsafe { TODO: call gtk_sys:gtk_buildable_custom_tag_start() } //} - fn get_internal_child>( - &self, - builder: &P, - childname: &str, - ) -> Option { + fn get_internal_child(&self, builder: &Builder, childname: &str) -> Option { unsafe { from_glib_none(gtk_sys::gtk_buildable_get_internal_child( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, childname.to_glib_none().0, )) } @@ -112,25 +94,20 @@ impl> BuildableExt for O { } } - fn parser_finished>(&self, builder: &P) { + fn parser_finished(&self, builder: &Builder) { unsafe { gtk_sys::gtk_buildable_parser_finished( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, ); } } - fn set_buildable_property>( - &self, - builder: &P, - name: &str, - value: &glib::Value, - ) { + fn set_buildable_property(&self, builder: &Builder, name: &str, value: &glib::Value) { unsafe { gtk_sys::gtk_buildable_set_buildable_property( self.as_ref().to_glib_none().0, - builder.as_ref().to_glib_none().0, + builder.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0, ); diff --git a/src/auto/builder.rs b/src/auto/builder.rs index 862c70248543..1bcfd19a943a 100644 --- a/src/auto/builder.rs +++ b/src/auto/builder.rs @@ -5,18 +5,21 @@ use glib; use glib::object::Cast; use glib::object::IsA; +use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; +use glib::StaticType; +use glib::ToValue; use glib_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; -use Application; -use Widget; +use BuilderClosureFlags; +use BuilderScope; glib_wrapper! { pub struct Builder(Object); @@ -32,7 +35,7 @@ impl Builder { unsafe { from_glib_full(gtk_sys::gtk_builder_new()) } } - pub fn new_from_resource(resource_path: &str) -> Builder { + pub fn from_resource(resource_path: &str) -> Builder { assert_initialized_main_thread!(); unsafe { from_glib_full(gtk_sys::gtk_builder_new_from_resource( @@ -41,7 +44,7 @@ impl Builder { } } - pub fn new_from_string(string: &str) -> Builder { + pub fn from_string(string: &str) -> Builder { assert_initialized_main_thread!(); let length = string.len() as isize; unsafe { @@ -51,87 +54,12 @@ impl Builder { )) } } -} - -impl Default for Builder { - fn default() -> Self { - Self::new() - } -} - -pub const NONE_BUILDER: Option<&Builder> = None; - -pub trait BuilderExt: 'static { - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: P); - - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - - fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error>; - - fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error>; - - fn add_objects_from_resource( - &self, - resource_path: &str, - object_ids: &[&str], - ) -> Result<(), glib::Error>; - - fn add_objects_from_string(&self, buffer: &str, object_ids: &[&str]) - -> Result<(), glib::Error>; - - //fn connect_signals(&self, user_data: /*Unimplemented*/Option); - - fn expose_object>(&self, name: &str, object: &P); - - fn extend_with_template>( - &self, - widget: &P, - template_type: glib::types::Type, - buffer: &str, - ) -> Result<(), glib::Error>; - - fn get_application(&self) -> Option; - - fn get_objects(&self) -> Vec; - - fn get_translation_domain(&self) -> Option; - - fn get_type_from_name(&self, type_name: &str) -> glib::types::Type; - - //fn lookup_callback_symbol(&self, callback_name: &str) -> Option>; - - fn set_application>(&self, application: &P); - - fn set_translation_domain(&self, domain: Option<&str>); - - //fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result; - fn value_from_string_type( - &self, - type_: glib::types::Type, - string: &str, - ) -> Result; - - fn connect_property_translation_domain_notify( - &self, - f: F, - ) -> SignalHandlerId; -} - -impl> BuilderExt for O { - //fn add_callback_symbol(&self, callback_name: &str, callback_symbol: P) { - // unsafe { TODO: call gtk_sys:gtk_builder_add_callback_symbol() } - //} - - //fn add_callback_symbols(&self, first_callback_name: &str, first_callback_symbol: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call gtk_sys:gtk_builder_add_callback_symbols() } - //} - - fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error> { + pub fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_from_resource( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, resource_path.to_glib_none().0, &mut error, ); @@ -143,12 +71,12 @@ impl> BuilderExt for O { } } - fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error> { + pub fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error> { let length = buffer.len() as isize; unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_from_string( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, buffer.to_glib_none().0, length, &mut error, @@ -161,7 +89,7 @@ impl> BuilderExt for O { } } - fn add_objects_from_resource( + pub fn add_objects_from_resource( &self, resource_path: &str, object_ids: &[&str], @@ -169,7 +97,7 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_objects_from_resource( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, resource_path.to_glib_none().0, object_ids.to_glib_none().0, &mut error, @@ -182,7 +110,7 @@ impl> BuilderExt for O { } } - fn add_objects_from_string( + pub fn add_objects_from_string( &self, buffer: &str, object_ids: &[&str], @@ -191,7 +119,7 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_add_objects_from_string( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, buffer.to_glib_none().0, length, object_ids.to_glib_none().0, @@ -205,23 +133,42 @@ impl> BuilderExt for O { } } - //fn connect_signals(&self, user_data: /*Unimplemented*/Option) { - // unsafe { TODO: call gtk_sys:gtk_builder_connect_signals() } - //} + pub fn create_closure>( + &self, + function_name: &str, + flags: BuilderClosureFlags, + object: Option<&P>, + ) -> Result, glib::Error> { + unsafe { + let mut error = ptr::null_mut(); + let ret = gtk_sys::gtk_builder_create_closure( + self.to_glib_none().0, + function_name.to_glib_none().0, + flags.to_glib(), + object.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } - fn expose_object>(&self, name: &str, object: &P) { + pub fn expose_object>(&self, name: &str, object: &P) { unsafe { gtk_sys::gtk_builder_expose_object( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, name.to_glib_none().0, object.as_ref().to_glib_none().0, ); } } - fn extend_with_template>( + pub fn extend_with_template>( &self, - widget: &P, + object: &P, template_type: glib::types::Type, buffer: &str, ) -> Result<(), glib::Error> { @@ -229,8 +176,8 @@ impl> BuilderExt for O { unsafe { let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_extend_with_template( - self.as_ref().to_glib_none().0, - widget.as_ref().to_glib_none().0, + self.to_glib_none().0, + object.as_ref().to_glib_none().0, template_type.to_glib(), buffer.to_glib_none().0, length, @@ -244,66 +191,75 @@ impl> BuilderExt for O { } } - fn get_application(&self) -> Option { + pub fn get_current_object(&self) -> Option { unsafe { - from_glib_none(gtk_sys::gtk_builder_get_application( - self.as_ref().to_glib_none().0, + from_glib_none(gtk_sys::gtk_builder_get_current_object( + self.to_glib_none().0, )) } } - fn get_objects(&self) -> Vec { + pub fn get_objects(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_builder_get_objects( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_translation_domain(&self) -> Option { + pub fn get_scope(&self) -> Option { + unsafe { from_glib_none(gtk_sys::gtk_builder_get_scope(self.to_glib_none().0)) } + } + + pub fn get_translation_domain(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_builder_get_translation_domain( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, )) } } - fn get_type_from_name(&self, type_name: &str) -> glib::types::Type { + pub fn get_type_from_name(&self, type_name: &str) -> glib::types::Type { unsafe { from_glib(gtk_sys::gtk_builder_get_type_from_name( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, type_name.to_glib_none().0, )) } } - //fn lookup_callback_symbol(&self, callback_name: &str) -> Option> { - // unsafe { TODO: call gtk_sys:gtk_builder_lookup_callback_symbol() } - //} + pub fn set_current_object>(&self, current_object: Option<&P>) { + unsafe { + gtk_sys::gtk_builder_set_current_object( + self.to_glib_none().0, + current_object.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } - fn set_application>(&self, application: &P) { + pub fn set_scope>(&self, scope: Option<&P>) { unsafe { - gtk_sys::gtk_builder_set_application( - self.as_ref().to_glib_none().0, - application.as_ref().to_glib_none().0, + gtk_sys::gtk_builder_set_scope( + self.to_glib_none().0, + scope.map(|p| p.as_ref()).to_glib_none().0, ); } } - fn set_translation_domain(&self, domain: Option<&str>) { + pub fn set_translation_domain(&self, domain: Option<&str>) { unsafe { gtk_sys::gtk_builder_set_translation_domain( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, domain.to_glib_none().0, ); } } - //fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result { + //pub fn value_from_string(&self, pspec: /*Ignored*/&glib::ParamSpec, string: &str) -> Result { // unsafe { TODO: call gtk_sys:gtk_builder_value_from_string() } //} - fn value_from_string_type( + pub fn value_from_string_type( &self, type_: glib::types::Type, string: &str, @@ -312,7 +268,7 @@ impl> BuilderExt for O { let mut value = glib::Value::uninitialized(); let mut error = ptr::null_mut(); let _ = gtk_sys::gtk_builder_value_from_string_type( - self.as_ref().to_glib_none().0, + self.to_glib_none().0, type_.to_glib(), string.to_glib_none().0, value.to_glib_none_mut().0, @@ -326,27 +282,75 @@ impl> BuilderExt for O { } } - fn connect_property_translation_domain_notify( + pub fn connect_property_current_object_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_current_object_trampoline( + this: *mut gtk_sys::GtkBuilder, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::current-object\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_current_object_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_scope_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_scope_trampoline( + this: *mut gtk_sys::GtkBuilder, + _param_spec: glib_sys::gpointer, + f: glib_sys::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::scope\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_scope_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + pub fn connect_property_translation_domain_notify( &self, f: F, ) -> SignalHandlerId { - unsafe extern "C" fn notify_translation_domain_trampoline( + unsafe extern "C" fn notify_translation_domain_trampoline( this: *mut gtk_sys::GtkBuilder, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, - ) where - P: IsA, - { + ) { let f: &F = &*(f as *const F); - f(&Builder::from_glib_borrow(this).unsafe_cast()) + f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::translation-domain\0".as_ptr() as *const _, - Some(transmute( - notify_translation_domain_trampoline:: as usize, + Some(transmute::<_, unsafe extern "C" fn()>( + notify_translation_domain_trampoline:: as *const (), )), Box_::into_raw(f), ) @@ -354,6 +358,58 @@ impl> BuilderExt for O { } } +impl Default for Builder { + fn default() -> Self { + Self::new() + } +} + +#[derive(Clone, Default)] +pub struct BuilderBuilder { + current_object: Option, + scope: Option, + translation_domain: Option, +} + +impl BuilderBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> Builder { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref current_object) = self.current_object { + properties.push(("current-object", current_object)); + } + if let Some(ref scope) = self.scope { + properties.push(("scope", scope)); + } + if let Some(ref translation_domain) = self.translation_domain { + properties.push(("translation-domain", translation_domain)); + } + let ret = glib::Object::new(Builder::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn current_object>(mut self, current_object: &P) -> Self { + self.current_object = Some(current_object.clone().upcast()); + self + } + + pub fn scope>(mut self, scope: &P) -> Self { + self.scope = Some(scope.clone().upcast()); + self + } + + pub fn translation_domain(mut self, translation_domain: &str) -> Self { + self.translation_domain = Some(translation_domain.to_string()); + self + } +} + impl fmt::Display for Builder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Builder") diff --git a/src/auto/builder_list_item_factory.rs b/src/auto/builder_list_item_factory.rs new file mode 100644 index 000000000000..599369d3ea0c --- /dev/null +++ b/src/auto/builder_list_item_factory.rs @@ -0,0 +1,131 @@ +// 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; +use glib::object::Cast; +use glib::object::IsA; +use glib::translate::*; +use glib::GString; +use glib::StaticType; +use glib::ToValue; +use gtk_sys; +use std::fmt; +use BuilderScope; +use ListItemFactory; + +glib_wrapper! { + pub struct BuilderListItemFactory(Object) @extends ListItemFactory; + + match fn { + get_type => || gtk_sys::gtk_builder_list_item_factory_get_type(), + } +} + +impl BuilderListItemFactory { + pub fn from_bytes>( + scope: Option<&P>, + bytes: &glib::Bytes, + ) -> BuilderListItemFactory { + assert_initialized_main_thread!(); + unsafe { + ListItemFactory::from_glib_full(gtk_sys::gtk_builder_list_item_factory_new_from_bytes( + scope.map(|p| p.as_ref()).to_glib_none().0, + bytes.to_glib_none().0, + )) + .unsafe_cast() + } + } + + pub fn from_resource>( + scope: Option<&P>, + resource_path: &str, + ) -> BuilderListItemFactory { + assert_initialized_main_thread!(); + unsafe { + ListItemFactory::from_glib_full( + gtk_sys::gtk_builder_list_item_factory_new_from_resource( + scope.map(|p| p.as_ref()).to_glib_none().0, + resource_path.to_glib_none().0, + ), + ) + .unsafe_cast() + } + } + + pub fn get_bytes(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_builder_list_item_factory_get_bytes( + self.to_glib_none().0, + )) + } + } + + pub fn get_resource(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_builder_list_item_factory_get_resource( + self.to_glib_none().0, + )) + } + } + + pub fn get_scope(&self) -> Option { + unsafe { + from_glib_none(gtk_sys::gtk_builder_list_item_factory_get_scope( + self.to_glib_none().0, + )) + } + } +} + +#[derive(Clone, Default)] +pub struct BuilderListItemFactoryBuilder { + bytes: Option, + resource: Option, + scope: Option, +} + +impl BuilderListItemFactoryBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn build(self) -> BuilderListItemFactory { + let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref bytes) = self.bytes { + properties.push(("bytes", bytes)); + } + if let Some(ref resource) = self.resource { + properties.push(("resource", resource)); + } + if let Some(ref scope) = self.scope { + properties.push(("scope", scope)); + } + let ret = glib::Object::new(BuilderListItemFactory::static_type(), &properties) + .expect("object new") + .downcast::() + .expect("downcast"); + ret + } + + pub fn bytes(mut self, bytes: &glib::Bytes) -> Self { + self.bytes = Some(bytes.clone()); + self + } + + pub fn resource(mut self, resource: &str) -> Self { + self.resource = Some(resource.to_string()); + self + } + + pub fn scope>(mut self, scope: &P) -> Self { + self.scope = Some(scope.clone().upcast()); + self + } +} + +impl fmt::Display for BuilderListItemFactory { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BuilderListItemFactory") + } +} diff --git a/src/auto/builder_scope.rs b/src/auto/builder_scope.rs new file mode 100644 index 000000000000..91598a6d96a5 --- /dev/null +++ b/src/auto/builder_scope.rs @@ -0,0 +1,28 @@ +// 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; + +glib_wrapper! { + pub struct BuilderScope(Interface); + + match fn { + get_type => || gtk_sys::gtk_builder_scope_get_type(), + } +} + +pub const NONE_BUILDER_SCOPE: Option<&BuilderScope> = None; + +pub trait BuilderScopeExt: 'static {} + +impl> BuilderScopeExt for O {} + +impl fmt::Display for BuilderScope { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BuilderScope") + } +} diff --git a/src/auto/button.rs b/src/auto/button.rs index 9840aaa6423a..9fc02cba3b8f 100644 --- a/src/auto/button.rs +++ b/src/auto/button.rs @@ -19,18 +19,18 @@ use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; +use Accessible; +use AccessibleRole; use Actionable; use Align; -use Bin; use Buildable; -use Container; +use ConstraintTarget; use LayoutManager; use Overflow; -use ReliefStyle; use Widget; glib_wrapper! { - pub struct Button(Object) @extends Bin, Container, Widget, @implements Buildable, Actionable; + pub struct Button(Object) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable; match fn { get_type => || gtk_sys::gtk_button_get_type(), @@ -43,7 +43,7 @@ impl Button { unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new()).unsafe_cast() } } - pub fn new_from_icon_name(icon_name: Option<&str>) -> Button { + pub fn from_icon_name(icon_name: Option<&str>) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_from_icon_name( @@ -53,7 +53,7 @@ impl Button { } } - pub fn new_with_label(label: &str) -> Button { + pub fn with_label(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_with_label(label.to_glib_none().0)) @@ -61,7 +61,7 @@ impl Button { } } - pub fn new_with_mnemonic(label: &str) -> Button { + pub fn with_mnemonic(label: &str) -> Button { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(gtk_sys::gtk_button_new_with_mnemonic( @@ -80,25 +80,24 @@ impl Default for Button { #[derive(Clone, Default)] pub struct ButtonBuilder { + child: Option, + has_frame: Option, icon_name: Option, label: Option, - relief: Option, use_underline: Option, can_focus: Option, can_target: Option, + css_classes: Option>, css_name: Option, cursor: Option, - expand: Option, focus_on_click: Option, + focusable: Option, halign: Option, - has_focus: Option, has_tooltip: Option, height_request: Option, hexpand: Option, hexpand_set: Option, - is_focus: Option, layout_manager: Option, - margin: Option, margin_bottom: Option, margin_end: Option, margin_start: Option, @@ -115,6 +114,7 @@ pub struct ButtonBuilder { vexpand_set: Option, visible: Option, width_request: Option, + accessible_role: Option, action_name: Option, } @@ -125,15 +125,18 @@ impl ButtonBuilder { pub fn build(self) -> Button { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; + if let Some(ref child) = self.child { + properties.push(("child", child)); + } + if let Some(ref has_frame) = self.has_frame { + properties.push(("has-frame", has_frame)); + } if let Some(ref icon_name) = self.icon_name { properties.push(("icon-name", icon_name)); } if let Some(ref label) = self.label { properties.push(("label", label)); } - if let Some(ref relief) = self.relief { - properties.push(("relief", relief)); - } if let Some(ref use_underline) = self.use_underline { properties.push(("use-underline", use_underline)); } @@ -143,24 +146,24 @@ impl ButtonBuilder { if let Some(ref can_target) = self.can_target { properties.push(("can-target", can_target)); } + if let Some(ref css_classes) = self.css_classes { + properties.push(("css-classes", css_classes)); + } if let Some(ref css_name) = self.css_name { properties.push(("css-name", css_name)); } if let Some(ref cursor) = self.cursor { properties.push(("cursor", cursor)); } - if let Some(ref expand) = self.expand { - properties.push(("expand", expand)); - } if let Some(ref focus_on_click) = self.focus_on_click { properties.push(("focus-on-click", focus_on_click)); } + if let Some(ref focusable) = self.focusable { + properties.push(("focusable", focusable)); + } if let Some(ref halign) = self.halign { properties.push(("halign", halign)); } - if let Some(ref has_focus) = self.has_focus { - properties.push(("has-focus", has_focus)); - } if let Some(ref has_tooltip) = self.has_tooltip { properties.push(("has-tooltip", has_tooltip)); } @@ -173,15 +176,9 @@ impl ButtonBuilder { if let Some(ref hexpand_set) = self.hexpand_set { properties.push(("hexpand-set", hexpand_set)); } - if let Some(ref is_focus) = self.is_focus { - properties.push(("is-focus", is_focus)); - } if let Some(ref layout_manager) = self.layout_manager { properties.push(("layout-manager", layout_manager)); } - if let Some(ref margin) = self.margin { - properties.push(("margin", margin)); - } if let Some(ref margin_bottom) = self.margin_bottom { properties.push(("margin-bottom", margin_bottom)); } @@ -230,13 +227,27 @@ impl ButtonBuilder { if let Some(ref width_request) = self.width_request { properties.push(("width-request", width_request)); } + if let Some(ref accessible_role) = self.accessible_role { + properties.push(("accessible-role", accessible_role)); + } if let Some(ref action_name) = self.action_name { properties.push(("action-name", action_name)); } - glib::Object::new(Button::static_type(), &properties) + let ret = glib::Object::new(Button::static_type(), &properties) .expect("object new") - .downcast() - .expect("downcast") + .downcast::