├── atk ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── tests │ │ └── manual.h │ ├── versions.txt │ ├── build.rs │ ├── Gir.toml │ └── Cargo.toml ├── src │ ├── attribute_set.rs │ ├── auto │ │ ├── versions.txt │ │ ├── alias.rs │ │ ├── util.rs │ │ ├── rectangle.rs │ │ ├── text_range.rs │ │ ├── no_op_object_factory.rs │ │ ├── no_op_object.rs │ │ ├── hyperlink_impl.rs │ │ ├── plug.rs │ │ ├── misc.rs │ │ └── socket.rs │ ├── rt.rs │ ├── prelude.rs │ ├── lib.rs │ ├── editable_text.rs │ ├── attribute.rs │ └── table.rs ├── Cargo.toml └── README.md ├── gdk ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── tests │ │ └── manual.h │ ├── versions.txt │ ├── build_version.rs │ ├── Gir.toml │ ├── build.rs │ └── Cargo.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── event_sequence.rs │ │ ├── device_tool.rs │ │ ├── frame_timings.rs │ │ └── drawing_context.rs │ ├── device_manager.rs │ ├── time_coord.rs │ ├── event_focus.rs │ ├── event_visibility.rs │ ├── prelude.rs │ ├── visual.rs │ ├── event_setting.rs │ ├── event_proximity.rs │ ├── event_pad_group_mode.rs │ ├── event_window_state.rs │ ├── frame_clock.rs │ ├── event_grab_broken.rs │ ├── event_property.rs │ ├── event_configure.rs │ ├── keymap_key.rs │ ├── event_expose.rs │ ├── event_pad_button.rs │ ├── event_pad_axis.rs │ ├── event_dnd.rs │ ├── screen.rs │ ├── event_owner_change.rs │ ├── change_data.rs │ ├── event_selection.rs │ ├── event_key.rs │ └── event_touchpad_swipe.rs ├── tests │ ├── check_gir.rs │ └── check_event.rs └── Cargo.toml ├── gtk ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── tests │ │ └── manual.h │ ├── versions.txt │ ├── build.rs │ ├── src │ │ └── manual.rs │ └── Gir.toml ├── src │ ├── xlib.rs │ ├── auto │ │ ├── versions.txt │ │ ├── tree_iter.rs │ │ ├── misc.rs │ │ ├── style_properties.rs │ │ ├── file_chooser_widget_accessible.rs │ │ ├── bin.rs │ │ └── text_attributes.rs │ ├── builders.rs │ ├── subclass │ │ ├── bin.rs │ │ ├── box_.rs │ │ ├── event_box.rs │ │ ├── fixed.rs │ │ ├── stack.rs │ │ ├── drawing_area.rs │ │ ├── tree_view.rs │ │ ├── header_bar.rs │ │ ├── application_window.rs │ │ ├── cell_renderer_pixbuf.rs │ │ ├── cell_renderer_spin.rs │ │ ├── cell_renderer_combo.rs │ │ ├── cell_renderer_spinner.rs │ │ ├── cell_renderer_progress.rs │ │ ├── menu_button.rs │ │ └── plug.rs │ ├── print_settings.rs │ ├── print_operation.rs │ ├── application_window.rs │ ├── tree_model_filter.rs │ ├── style_context.rs │ ├── selection_data.rs │ ├── flow_box.rs │ ├── list_box.rs │ ├── tree_path.rs │ ├── cell_renderer_pixbuf.rs │ ├── target_list.rs │ ├── invisible.rs │ ├── entry.rs │ ├── buildable.rs │ ├── page_range.rs │ ├── color_chooser.rs │ ├── text_iter.rs │ ├── im_context_simple.rs │ ├── entry_completion.rs │ ├── enums.rs │ ├── combo_box.rs │ ├── requisition.rs │ ├── tree_row_reference.rs │ ├── tree_view_column.rs │ ├── radio_tool_button.rs │ ├── pad_controller.rs │ ├── gesture_stylus.rs │ ├── color_button.rs │ ├── pad_action_entry.rs │ ├── radio_button.rs │ ├── radio_menu_item.rs │ ├── switch.rs │ ├── app_chooser.rs │ ├── functions.rs │ ├── application.rs │ └── recent_chooser_dialog.rs ├── tests │ └── check_gir.rs ├── build.rs └── release_process.md ├── gdkwayland ├── LICENSE ├── sys │ ├── LICENSE │ └── Cargo.toml ├── src │ ├── wayland_gl_context.rs │ ├── lib.rs │ ├── wayland_seat.rs │ └── wayland_monitor.rs └── Cargo.toml ├── gdkx11 ├── COPYRIGHT ├── LICENSE ├── sys │ ├── LICENSE │ ├── src │ │ └── manual.rs │ ├── versions.txt │ ├── Gir.toml │ ├── build.rs │ └── Cargo.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── x11_visual.rs │ │ ├── x11gl_context.rs │ │ ├── x11_device_core.rs │ │ ├── x11_drag_context.rs │ │ ├── x11_display_manager.rs │ │ ├── x11_app_launch_context.rs │ │ ├── x11_device_manager_core.rs │ │ ├── x11_cursor.rs │ │ ├── x11_monitor.rs │ │ ├── x11_keymap.rs │ │ └── mod.rs │ ├── builders.rs │ ├── lib.rs │ └── rt.rs ├── Cargo.toml └── README.md ├── generator.py ├── gtk3-macros ├── COPYRIGHT ├── LICENSE ├── src │ ├── composite_template.ui │ └── util.rs └── Cargo.toml ├── rustfmt.toml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── blank-issue.md │ ├── feature-request-or-missing-binding.md │ ├── bug_report.md │ └── asking-for-help.md └── workflows │ └── image.yml ├── .gitattributes ├── examples ├── resources │ ├── eye.png │ ├── file.png │ ├── menu.png │ └── resources.gresource.xml ├── clock │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── css │ ├── screenshot.png │ ├── README.md │ └── style.css ├── grid │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── basics │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── overlay │ ├── screenshot.png │ ├── style.css │ └── README.md ├── drag_drop │ ├── screenshot.png │ └── README.md ├── gtk_test │ ├── screenshot.png │ └── README.md ├── header_bar │ ├── screenshot.png │ ├── README.md │ ├── title_bar.rs │ └── main.rs ├── icon_view │ ├── screenshot.png │ └── README.md ├── list_store │ ├── screenshot.png │ └── README.md ├── menu_bar │ ├── screenshot.png │ └── README.md ├── notebook │ ├── screenshot.png │ ├── README.md │ ├── main.rs │ └── notebook.rs ├── tree_view │ ├── screenshot.png │ └── README.md ├── cairo_test │ ├── screenshot_1.png │ ├── screenshot_2.png │ └── README.md ├── clone_macro │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── dialog_async │ ├── screenshot.png │ └── README.md ├── multi_window │ ├── screenshot.png │ └── README.md ├── sync_widget │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── text_viewer │ ├── screenshot.png │ └── README.md ├── accessibility │ ├── screenshot.png │ └── README.md ├── basic_subclass │ ├── screenshot.png │ ├── main.rs │ ├── README.md │ ├── simple_window │ │ └── mod.rs │ └── simple_application │ │ └── mod.rs ├── builder_pattern │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── cairo_threads │ ├── screenshot.png │ ├── README.md │ └── image │ │ └── image_holder.rs ├── list_box_model │ ├── screenshot.png │ ├── README.md │ ├── row_data │ │ └── mod.rs │ └── model │ │ ├── imp.rs │ │ └── mod.rs ├── menu_bar_system │ ├── screenshot.png │ └── README.md ├── child_properties │ ├── screenshot.png │ └── README.md ├── clipboard_simple │ ├── screenshot.png │ └── README.md ├── entry_completion │ ├── screenshot.png │ └── README.md ├── pango_attributes │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── progress_tracker │ ├── screenshot.png │ └── README.md ├── tree_view_simple │ ├── screenshot.png │ └── README.md ├── combobox_liststore │ ├── screenshot.png │ └── README.md ├── communication_thread │ ├── screenshot.png │ └── README.md ├── composite_template │ ├── screenshot.png │ ├── README.md │ ├── main.rs │ └── example_application_window │ │ └── mod.rs ├── drag_drop_text_view │ ├── screenshot.png │ └── README.md ├── gtk_builder_basics │ ├── screenshot.png │ ├── README.md │ └── main.rs ├── gtk_builder_signal │ ├── screenshot.png │ └── README.md ├── tree_view_model_sort │ ├── screenshot.png │ └── README.md ├── multi_threading_context │ ├── screenshot.png │ └── README.md ├── transparent_main_window │ ├── screenshot.png │ └── README.md ├── build.rs ├── printing │ └── README.md └── cairo_png │ ├── README.md │ └── main.rs ├── .gitignore ├── .gitmodules ├── Cargo.toml ├── COPYRIGHT ├── Dockerfile └── LICENSE /atk/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /gdk/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /gtk/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /atk/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /atk/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /gdk/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gdk/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /gdkwayland/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /gdkx11/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gdkx11/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /generator.py: -------------------------------------------------------------------------------- 1 | gir/generator.py -------------------------------------------------------------------------------- /gtk/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gtk/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /gdkx11/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /gtk3-macros/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gtk3-macros/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | -------------------------------------------------------------------------------- /gdkwayland/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: gtk-rs 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | Cargo.* eol=lf 2 | *.sh eol=lf 3 | -------------------------------------------------------------------------------- /examples/resources/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/resources/eye.png -------------------------------------------------------------------------------- /examples/clock/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/clock/screenshot.png -------------------------------------------------------------------------------- /examples/css/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/css/screenshot.png -------------------------------------------------------------------------------- /examples/grid/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/grid/screenshot.png -------------------------------------------------------------------------------- /examples/resources/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/resources/file.png -------------------------------------------------------------------------------- /examples/resources/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/resources/menu.png -------------------------------------------------------------------------------- /examples/basics/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/basics/screenshot.png -------------------------------------------------------------------------------- /examples/overlay/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/overlay/screenshot.png -------------------------------------------------------------------------------- /examples/drag_drop/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/drag_drop/screenshot.png -------------------------------------------------------------------------------- /examples/gtk_test/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/gtk_test/screenshot.png -------------------------------------------------------------------------------- /examples/header_bar/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/header_bar/screenshot.png -------------------------------------------------------------------------------- /examples/icon_view/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/icon_view/screenshot.png -------------------------------------------------------------------------------- /examples/list_store/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/list_store/screenshot.png -------------------------------------------------------------------------------- /examples/menu_bar/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/menu_bar/screenshot.png -------------------------------------------------------------------------------- /examples/notebook/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/notebook/screenshot.png -------------------------------------------------------------------------------- /examples/tree_view/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/tree_view/screenshot.png -------------------------------------------------------------------------------- /examples/cairo_test/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/cairo_test/screenshot_1.png -------------------------------------------------------------------------------- /examples/cairo_test/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/cairo_test/screenshot_2.png -------------------------------------------------------------------------------- /examples/clone_macro/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/clone_macro/screenshot.png -------------------------------------------------------------------------------- /examples/dialog_async/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/dialog_async/screenshot.png -------------------------------------------------------------------------------- /examples/multi_window/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/multi_window/screenshot.png -------------------------------------------------------------------------------- /examples/sync_widget/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/sync_widget/screenshot.png -------------------------------------------------------------------------------- /examples/text_viewer/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/text_viewer/screenshot.png -------------------------------------------------------------------------------- /examples/accessibility/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/accessibility/screenshot.png -------------------------------------------------------------------------------- /examples/basic_subclass/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/basic_subclass/screenshot.png -------------------------------------------------------------------------------- /examples/builder_pattern/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/builder_pattern/screenshot.png -------------------------------------------------------------------------------- /examples/cairo_threads/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/cairo_threads/screenshot.png -------------------------------------------------------------------------------- /examples/list_box_model/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/list_box_model/screenshot.png -------------------------------------------------------------------------------- /examples/menu_bar_system/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/menu_bar_system/screenshot.png -------------------------------------------------------------------------------- /examples/child_properties/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/child_properties/screenshot.png -------------------------------------------------------------------------------- /examples/clipboard_simple/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/clipboard_simple/screenshot.png -------------------------------------------------------------------------------- /examples/entry_completion/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/entry_completion/screenshot.png -------------------------------------------------------------------------------- /examples/pango_attributes/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/pango_attributes/screenshot.png -------------------------------------------------------------------------------- /examples/progress_tracker/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/progress_tracker/screenshot.png -------------------------------------------------------------------------------- /examples/tree_view_simple/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/tree_view_simple/screenshot.png -------------------------------------------------------------------------------- /examples/combobox_liststore/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/combobox_liststore/screenshot.png -------------------------------------------------------------------------------- /examples/communication_thread/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/communication_thread/screenshot.png -------------------------------------------------------------------------------- /examples/composite_template/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/composite_template/screenshot.png -------------------------------------------------------------------------------- /examples/drag_drop_text_view/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/drag_drop_text_view/screenshot.png -------------------------------------------------------------------------------- /examples/gtk_builder_basics/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/gtk_builder_basics/screenshot.png -------------------------------------------------------------------------------- /examples/gtk_builder_signal/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/gtk_builder_signal/screenshot.png -------------------------------------------------------------------------------- /examples/tree_view_model_sort/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/tree_view_model_sort/screenshot.png -------------------------------------------------------------------------------- /gdkx11/sys/src/manual.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | pub use x11::xlib; 4 | -------------------------------------------------------------------------------- /atk/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /examples/multi_threading_context/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/multi_threading_context/screenshot.png -------------------------------------------------------------------------------- /examples/transparent_main_window/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtk-rs/gtk3-rs/HEAD/examples/transparent_main_window/screenshot.png -------------------------------------------------------------------------------- /gdk/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /gtk/src/xlib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | pub type Window = ffi::xlib::Window; 4 | -------------------------------------------------------------------------------- /gtk/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /examples/overlay/style.css: -------------------------------------------------------------------------------- 1 | #overlay-label { 2 | background-color: rgba(192, 192, 192, 0.8); 3 | color: black; 4 | font-weight: bold; 5 | } 6 | -------------------------------------------------------------------------------- /atk/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gdk/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gdkx11/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gtk/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /atk/src/attribute_set.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | pub type AttributeSet = glib::translate::SList; 4 | -------------------------------------------------------------------------------- /atk/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gdk/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gdkx11/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /gtk/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40) 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/blank-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Blank issue 3 | about: None of the above templates match your issue 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **test/bin/ 2 | **target/ 3 | **doc/ 4 | configure.in 5 | config.log 6 | config.status 7 | *.dylib 8 | .rust 9 | *.so 10 | *.o 11 | *.swp 12 | **Cargo.lock 13 | gtk/tests/* 14 | **~ 15 | -------------------------------------------------------------------------------- /examples/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | glib_build_tools::compile_resources( 3 | &["resources"], 4 | "resources/resources.gresource.xml", 5 | "compiled.gresource", 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /examples/drag_drop/README.md: -------------------------------------------------------------------------------- 1 | # Drag and Drop 2 | 3 | Simple drag and drop example. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin drag_drop 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/grid/README.md: -------------------------------------------------------------------------------- 1 | # Grid 2 | 3 | Demonstrates how to arrange widgets in a grid. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin grid 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/overlay/README.md: -------------------------------------------------------------------------------- 1 | # Overlay 2 | 3 | This example shows how to overlay a widget. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin overlay 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdkx11/src/builders.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Builder pattern types. 5 | 6 | pub use crate::auto::builders::*; 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gir"] 2 | path = gir 3 | url = https://github.com/gtk-rs/gir 4 | update = none 5 | [submodule "gir-files"] 6 | path = gir-files 7 | url = https://github.com/gtk-rs/gir-files 8 | update = none 9 | -------------------------------------------------------------------------------- /examples/notebook/README.md: -------------------------------------------------------------------------------- 1 | # Notebook 2 | 3 | This example shows how to use `gtk::Notebook`. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin notebook 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/clipboard_simple/README.md: -------------------------------------------------------------------------------- 1 | # Clipboard Simple 2 | 3 | A simple clipboard example. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin clipboard_simple 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/css/README.md: -------------------------------------------------------------------------------- 1 | # CSS example 2 | 3 | This example demonstrates how to use CSS with gtk-rs. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin css 9 | ``` 10 | 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/dialog_async/README.md: -------------------------------------------------------------------------------- 1 | # Dialog Async 2 | 3 | Example of how to obtain the response to a dialog as a future 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin dialog 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/multi_window/README.md: -------------------------------------------------------------------------------- 1 | # Multi Windows 2 | 3 | This example shows how to create multiple windows. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin multi_window 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/clone_macro/README.md: -------------------------------------------------------------------------------- 1 | # Clone Macro 2 | 3 | This example demonstrates how to use the `glib::clone` macro. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin clone_macro 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/gtk_test/README.md: -------------------------------------------------------------------------------- 1 | # GTK Test 2 | 3 | This example shows the usage of various widgets within a single window. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gtk_test 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/header_bar/README.md: -------------------------------------------------------------------------------- 1 | # HeaderBar example 2 | 3 | This example demonstrates how to use HeaderBar in windows. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin header_bar 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/text_viewer/README.md: -------------------------------------------------------------------------------- 1 | # Toolbar, Scrollable Text View and File Chooser 2 | 3 | A simple text file viewer 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin text_viewer 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/combobox_liststore/README.md: -------------------------------------------------------------------------------- 1 | # Combobox liststore 2 | 3 | Example on how to use combobox and liststore. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin combobox_liststore 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/child_properties/README.md: -------------------------------------------------------------------------------- 1 | # Child Properties 2 | 3 | This example demonstrates how to set child properties. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin child_properties 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/list_store/README.md: -------------------------------------------------------------------------------- 1 | # List Store 2 | 3 | This example demonstrates how to use list store by showing (fake) bug data. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin list_store 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/accessibility/README.md: -------------------------------------------------------------------------------- 1 | # Accessibility 2 | 3 | This example demonstrates how to make an application more accessible. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin accessibility 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/tree_view_simple/README.md: -------------------------------------------------------------------------------- 1 | # TreeView example 2 | 3 | This example demonstrates how to create a TreeView with a ListStore. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin tree_view_simple 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/gtk_builder_signal/README.md: -------------------------------------------------------------------------------- 1 | # Builder Signal example 2 | 3 | This example demonstrates how to handle signals in builder. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gtk_builder_signal 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request-or-missing-binding.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request or missing binding 3 | about: A missing binding or something that could be improved 4 | title: "[FEATURE REQUEST]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/pango_attributes/README.md: -------------------------------------------------------------------------------- 1 | # Pango text attributes 2 | 3 | This example demonstrates how to use various attributes the text of a `label`. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin pango_attributes 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/progress_tracker/README.md: -------------------------------------------------------------------------------- 1 | # Progress tracker 2 | 3 | This example shows how to track progress with a background thread and a channel. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin progress_tracker 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/tree_view_model_sort/README.md: -------------------------------------------------------------------------------- 1 | # Tree Model Sort example 2 | 3 | This example demonstrates how to use the `TreeModelSort` widget. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin tree_view_model_sort 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdk/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /gtk/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /atk/src/rt.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | /// No-op. 4 | macro_rules! assert_initialized_main_thread { 5 | () => {}; 6 | } 7 | 8 | /// No-op. 9 | macro_rules! skip_assert_initialized { 10 | () => {}; 11 | } 12 | -------------------------------------------------------------------------------- /examples/composite_template/README.md: -------------------------------------------------------------------------------- 1 | # Composite Template 2 | 3 | This example demonstrates how to create a widget using GTK's composite templates. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin composite_template 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/gtk_builder_basics/README.md: -------------------------------------------------------------------------------- 1 | # Builder Basics example 2 | 3 | This example demonstrates how to use the builder with an imported ui file. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gtk_builder_basics 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/resources/resources.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eye.png 5 | file.png 6 | menu.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/tree_view/README.md: -------------------------------------------------------------------------------- 1 | # TreeView example 2 | 3 | This example demonstrates how to create a `TreeView` with either a `ListStore` or `TreeStore`. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin tree_view 9 | ``` 10 | 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /atk/src/auto/alias.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[allow(unused_imports)] 6 | use crate::auto::*; 7 | 8 | #[doc(alias = "AtkState")] 9 | pub type State = u64; 10 | -------------------------------------------------------------------------------- /examples/cairo_test/README.md: -------------------------------------------------------------------------------- 1 | # Cairo Test 2 | 3 | This example demonstrates how to draw images only with cairo and code. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin cairo_test 9 | ``` 10 | 11 | ![screenshot_1](screenshot_1.png) 12 | ![screenshot_2](screenshot_2.png) -------------------------------------------------------------------------------- /examples/drag_drop_text_view/README.md: -------------------------------------------------------------------------------- 1 | # More Complex Drag and Drop Example 2 | 3 | Displays a list of filenames when they're dropped on the textview widget. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin drag_drop_text_view 9 | ``` 10 | 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/basic_subclass/main.rs: -------------------------------------------------------------------------------- 1 | pub mod simple_application; 2 | pub mod simple_window; 3 | 4 | use gtk::prelude::*; 5 | 6 | fn main() { 7 | gtk::init().expect("Failed to initialize gtk"); 8 | 9 | let app = simple_application::SimpleApplication::new(); 10 | 11 | app.run(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/clock/README.md: -------------------------------------------------------------------------------- 1 | # Clock 2 | 3 | This example demonstrates how to use `glib::timeout_add_seconds_local` to run 4 | a periodic task, implementing a clock in this example. 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin clock 10 | ``` 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/transparent_main_window/README.md: -------------------------------------------------------------------------------- 1 | # Transparent main window example 2 | 3 | This example demonstrates how to create a main window with a transparent background. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin transparent_main_window 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gtk/src/builders.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Builder pattern types. 5 | 6 | pub use crate::auto::builders::*; 7 | pub use crate::image::ImageBuilder; 8 | pub use crate::stack_switcher::StackSwitcherBuilder; 9 | -------------------------------------------------------------------------------- /examples/printing/README.md: -------------------------------------------------------------------------------- 1 | # Printing 2 | 3 | This example reads text from two Entry fields, 4 | shows a print dialog and prints both texts one below 5 | the other. 6 | 7 | Run it by executing: 8 | 9 | ```bash 10 | cargo run --bin printing --features="pangocairo" 11 | ``` 12 | 13 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/multi_threading_context/README.md: -------------------------------------------------------------------------------- 1 | # Multi-threading Context 2 | 3 | This example shows how to deal with multi-threaded situations by sending messages through the main context. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin multi_threading_context 9 | ``` 10 | 11 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdk/sys/build_version.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | pub fn version() -> &'static str { 6 | if cfg!(feature = "v3_24") { 7 | "3.24" 8 | } else { 9 | "3.22" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/cairo_png/README.md: -------------------------------------------------------------------------------- 1 | # Cairo PNG 2 | 3 | This example demonstrates how to create `ImageSurface`, draw on it 4 | and then save result to PNG file. 5 | Analog of C# example http://www.mgsloan.com/cairo_tut/stroke.cs 6 | 7 | Run it by executing: 8 | 9 | ```bash 10 | cargo run --bin cairo_png --features="cairo" 11 | ``` 12 | -------------------------------------------------------------------------------- /examples/entry_completion/README.md: -------------------------------------------------------------------------------- 1 | # Entry completion example 2 | 3 | This example demonstrates how to build a list of items and use them 4 | to autocomplete a field as the user types in something. 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin entry_completions 10 | ``` 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /atk/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | //! Traits intended for blanket imports. 4 | 5 | pub use crate::auto::traits::*; 6 | pub use crate::editable_text::EditableTextExtManual; 7 | pub use crate::table::TableExtManual; 8 | #[doc(hidden)] 9 | pub use glib::prelude::*; 10 | -------------------------------------------------------------------------------- /examples/sync_widget/README.md: -------------------------------------------------------------------------------- 1 | # Synchronizing Widgets 2 | 3 | You can use property bindings in order to synchronize the values of widgets. In this example a 4 | spin button and a horizontal scale will get interlocked. 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin sync_widget 10 | ``` 11 | 12 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/basics/README.md: -------------------------------------------------------------------------------- 1 | # Basics 2 | 3 | This example demonstrates how to create a top-level `Window`, set its title, size and 4 | position, how to add a `Button` to this `Window` and how to connect signals with 5 | actions. 6 | 7 | Run it by executing: 8 | 9 | ```bash 10 | cargo run --bin basics 11 | ``` 12 | 13 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/menu_bar/README.md: -------------------------------------------------------------------------------- 1 | # MenuBar example 2 | 3 | This example demonstrates how to use Menus/MenuBars and MenuItems in Windows. 4 | This is different from the system menu bar (which are preferred) available in `gio::Menu`! 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin menu_bar 10 | ``` 11 | 12 | 13 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/menu_bar_system/README.md: -------------------------------------------------------------------------------- 1 | # System MenuBar example 2 | 3 | This example demonstrates how to create a "system" menu bar. It should always be preferred 4 | over the `gtk::MenuBar` since it adapts to the targeted system. 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin menu_bar_system 10 | ``` 11 | 12 | 13 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/builder_pattern/README.md: -------------------------------------------------------------------------------- 1 | # Builder Pattern 2 | 3 | This example demonstrates how to create a widget using the builders. 4 | These allow to set construct-only properties and other construct 5 | properties when creating the widget. 6 | 7 | Run it by executing: 8 | 9 | ```bash 10 | cargo run --bin builder_pattern 11 | ``` 12 | 13 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdk/src/device_manager.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::DeviceManager; 4 | 5 | impl DeviceManager { 6 | #[doc(alias = "gdk_disable_multidevice")] 7 | pub fn disable_multidevice() { 8 | assert_not_initialized!(); 9 | unsafe { ffi::gdk_disable_multidevice() } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /gdkwayland/src/wayland_gl_context.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | glib::wrapper! { 4 | #[doc(alias = "GdkWaylandGLContext")] 5 | pub struct WaylandGLContext(Object) @extends gdk::GLContext; 6 | 7 | match fn { 8 | type_ => || ffi::gdk_wayland_gl_context_get_type(), 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gdkx11/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "GdkX11" 4 | version = "3.0" 5 | min_cfg_version = "3.22" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "Cairo", 11 | "Gdk", 12 | "GLib", 13 | ] 14 | 15 | ignore = [ 16 | ] 17 | 18 | [[feature_dependencies]] 19 | version = "3.24.2" 20 | dependencies = [ 21 | "cairo" 22 | ] 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Bug description** 11 | 12 | Please provide a code sample as small as possible which reproduces the bug. 13 | 14 | **Backtrace** 15 | 16 | You can get the backtrace running your program with the environment variable `RUST_BACKTRACE=full`. 17 | -------------------------------------------------------------------------------- /examples/basic_subclass/README.md: -------------------------------------------------------------------------------- 1 | # Basic Subclass 2 | 3 | This example creates a `GtkApplication` and a `GtkApplicationWindow` subclass 4 | and showcases how you can override virtual funcitons such as `startup` 5 | and `activate` and how to interact with the GObjects and their private 6 | structs. 7 | 8 | Run it by executing: 9 | 10 | ```bash 11 | cargo run --bin basic_subclass 12 | ``` 13 | 14 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /atk/src/auto/util.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "AtkUtil")] 7 | pub struct Util(Object); 8 | 9 | match fn { 10 | type_ => || ffi::atk_util_get_type(), 11 | } 12 | } 13 | 14 | impl Util { 15 | pub const NONE: Option<&'static Util> = None; 16 | } 17 | -------------------------------------------------------------------------------- /gdk/src/time_coord.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | glib::wrapper! { 4 | #[doc(alias = "GdkTimeCoord")] 5 | pub struct TimeCoord(BoxedInline); 6 | } 7 | 8 | impl TimeCoord { 9 | pub fn time(&self) -> u32 { 10 | self.inner.time 11 | } 12 | 13 | pub fn axes(&self) -> &[f64; ffi::GDK_MAX_TIMECOORD_AXES as usize] { 14 | &self.inner.axes 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_visual.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11Visual")] 7 | pub struct X11Visual(Object) @extends gdk::Visual; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_visual_get_type(), 11 | } 12 | } 13 | 14 | impl X11Visual {} 15 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | default-members = [ 3 | "atk", 4 | "atk/sys", 5 | "gdk", 6 | "gdk/sys", 7 | "gtk", 8 | "gtk/sys", 9 | "gtk3-macros", 10 | "examples", 11 | ] 12 | 13 | members = [ 14 | "atk", 15 | "atk/sys", 16 | "gdk", 17 | "gdk/sys", 18 | "gdkwayland", 19 | "gdkwayland/sys", 20 | "gdkx11", 21 | "gdkx11/sys", 22 | "gtk", 23 | "gtk/sys", 24 | "gtk3-macros", 25 | "examples", 26 | ] 27 | 28 | exclude = ["gir", "checker"] 29 | -------------------------------------------------------------------------------- /examples/communication_thread/README.md: -------------------------------------------------------------------------------- 1 | # Communication Thread 2 | 3 | Example on how to use a communication thread alongside with the GUI thread. 4 | 5 | Tricks used here: 6 | - Use a channel to show data on the GUI. 7 | - Run an `async` function on the GUI event loop. 8 | - Use a separate thread to handle incoming data and put it into a channel. 9 | 10 | Run it by executing: 11 | 12 | ```bash 13 | cargo run --bin communication_thread 14 | ``` 15 | 16 | 17 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdk/tests/check_event.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn check_event() { 3 | gdk::init(); 4 | let base_ev = gdk::Event::new(gdk::EventType::KeyPress); 5 | let mut ev: gdk::EventKey = base_ev.downcast().unwrap(); 6 | ev.as_mut().keyval = *gdk::keys::constants::A; 7 | 8 | let keyval_unicode = ev.keyval().to_unicode(); 9 | 10 | assert_eq!(keyval_unicode, Some('A')); 11 | 12 | let keyval_name = ev.keyval().name(); 13 | 14 | assert_eq!(keyval_name, Some("A".into())); 15 | } 16 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11gl_context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11GLContext")] 7 | pub struct X11GLContext(Object) @extends gdk::GLContext; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_gl_context_get_type(), 11 | } 12 | } 13 | 14 | impl X11GLContext {} 15 | -------------------------------------------------------------------------------- /gtk3-macros/src/composite_template.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_device_core.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11DeviceCore")] 7 | pub struct X11DeviceCore(Object) @extends gdk::Device; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_device_core_get_type(), 11 | } 12 | } 13 | 14 | impl X11DeviceCore {} 15 | -------------------------------------------------------------------------------- /examples/basic_subclass/simple_window/mod.rs: -------------------------------------------------------------------------------- 1 | mod imp; 2 | 3 | use gtk::glib; 4 | 5 | use crate::simple_application::SimpleApplication; 6 | 7 | glib::wrapper! { 8 | pub struct SimpleWindow(ObjectSubclass) 9 | @extends gtk::Widget, gtk::Container, gtk::Bin, gtk::Window, gtk::ApplicationWindow; 10 | } 11 | 12 | impl SimpleWindow { 13 | pub fn new(app: &SimpleApplication) -> Self { 14 | glib::Object::builder().property("application", app).build() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_drag_context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11DragContext")] 7 | pub struct X11DragContext(Object) @extends gdk::DragContext; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_drag_context_get_type(), 11 | } 12 | } 13 | 14 | impl X11DragContext {} 15 | -------------------------------------------------------------------------------- /gdkx11/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg))] 4 | #![allow(clippy::upper_case_acronyms)] 5 | #![doc = include_str!("../README.md")] 6 | 7 | pub use ffi; 8 | pub use gdk; 9 | pub use gio; 10 | pub use glib; 11 | pub use x11; 12 | 13 | #[macro_use] 14 | mod rt; 15 | #[allow(unused_imports)] 16 | mod auto; 17 | 18 | pub mod builders; 19 | 20 | pub use crate::auto::functions::*; 21 | pub use crate::auto::*; 22 | -------------------------------------------------------------------------------- /atk/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gdkx11/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gtk/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/asking-for-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Asking for help 3 | about: You have a question on how to use gtk3-rs 4 | title: "[HELP]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | If you need help to use the libraries and not the Rust API specifically, better go to instead. 11 | 12 | In case you need help with the Rust API, please provide as much information as possible and a sample of code as small as possible which reproduces your issue so we can help you better. 13 | -------------------------------------------------------------------------------- /examples/basic_subclass/simple_application/mod.rs: -------------------------------------------------------------------------------- 1 | mod imp; 2 | 3 | use gtk::{gio, glib}; 4 | 5 | glib::wrapper! { 6 | pub struct SimpleApplication(ObjectSubclass) 7 | @extends gio::Application, gtk::Application; 8 | } 9 | 10 | impl SimpleApplication { 11 | #[allow(clippy::new_without_default)] 12 | pub fn new() -> Self { 13 | glib::Object::builder() 14 | .property("application-id", "org.gtk-rs.SimpleApplication") 15 | .build() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gdk/src/event_focus.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventFocus(crate::Event); 7 | 8 | event_wrapper!(EventFocus, GdkEventFocus); 9 | event_subtype!(EventFocus, ffi::GDK_FOCUS_CHANGE); 10 | 11 | impl EventFocus { 12 | #[doc(alias = "get_in")] 13 | pub fn is_in(&self) -> bool { 14 | unsafe { from_glib(self.as_ref().in_ as _) } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/composite_template/main.rs: -------------------------------------------------------------------------------- 1 | mod example_application_window; 2 | 3 | use gtk::prelude::*; 4 | 5 | use example_application_window::ExampleApplicationWindow; 6 | 7 | fn main() { 8 | let application = gtk::Application::new( 9 | Some("com.github.gtk-rs.examples.composite_template"), 10 | Default::default(), 11 | ); 12 | 13 | application.connect_activate(|app| { 14 | let win = ExampleApplicationWindow::new(app); 15 | win.show(); 16 | }); 17 | 18 | application.run(); 19 | } 20 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_display_manager.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11DisplayManager")] 7 | pub struct X11DisplayManager(Object) @extends gdk::DisplayManager; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_display_manager_get_type(), 11 | } 12 | } 13 | 14 | impl X11DisplayManager {} 15 | -------------------------------------------------------------------------------- /gtk/src/auto/tree_iter.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug)] 9 | pub struct TreeIter(BoxedInline); 10 | 11 | match fn { 12 | copy => |ptr| ffi::gtk_tree_iter_copy(mut_override(ptr)), 13 | free => |ptr| ffi::gtk_tree_iter_free(ptr), 14 | type_ => || ffi::gtk_tree_iter_get_type(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gtk3-macros/src/util.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use proc_macro2::{Ident, Span}; 4 | use proc_macro_crate::crate_name; 5 | 6 | pub fn crate_ident_new() -> Ident { 7 | use proc_macro_crate::FoundCrate; 8 | 9 | let crate_name = match crate_name("gtk").expect("missing gtk dependency in `Cargo.toml`") { 10 | FoundCrate::Name(name) => name, 11 | FoundCrate::Itself => "gtk".to_owned(), 12 | }; 13 | 14 | Ident::new(&crate_name, Span::call_site()) 15 | } 16 | -------------------------------------------------------------------------------- /gtk/src/auto/misc.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{Buildable, Widget}; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "GtkMisc")] 9 | pub struct Misc(Object) @extends Widget, @implements Buildable; 10 | 11 | match fn { 12 | type_ => || ffi::gtk_misc_get_type(), 13 | } 14 | } 15 | 16 | impl Misc { 17 | pub const NONE: Option<&'static Misc> = None; 18 | } 19 | -------------------------------------------------------------------------------- /gtk/src/subclass/bin.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | use crate::Bin; 7 | 8 | pub trait BinImpl: ContainerImpl {} 9 | 10 | unsafe impl IsSubclassable for Bin { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gtk/src/subclass/box_.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | use crate::Box; 7 | 8 | pub trait BoxImpl: ContainerImpl {} 9 | 10 | unsafe impl IsSubclassable for Box { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_app_launch_context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11AppLaunchContext")] 7 | pub struct X11AppLaunchContext(Object) @extends gdk::AppLaunchContext, gio::AppLaunchContext; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_app_launch_context_get_type(), 11 | } 12 | } 13 | 14 | impl X11AppLaunchContext {} 15 | -------------------------------------------------------------------------------- /gtk/sys/src/manual.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | pub mod xlib { 4 | pub type Window = i32; 5 | } 6 | 7 | //========================================================================= 8 | // GtkContainerClass 9 | //========================================================================= 10 | 11 | extern "C" { 12 | pub fn gtk_container_class_find_child_property( 13 | cclass: *const gobject::GObjectClass, 14 | property_name: *const libc::c_char, 15 | ) -> *mut gobject::GParamSpec; 16 | } 17 | -------------------------------------------------------------------------------- /gdk/src/event_visibility.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventVisibility(crate::Event); 7 | 8 | event_wrapper!(EventVisibility, GdkEventVisibility); 9 | event_subtype!(EventVisibility, ffi::GDK_VISIBILITY_NOTIFY); 10 | 11 | impl EventVisibility { 12 | #[doc(alias = "get_state")] 13 | pub fn state(&self) -> crate::VisibilityState { 14 | unsafe { from_glib(self.as_ref().state) } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gtk/src/subclass/event_box.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::bin::BinImpl; 6 | 7 | use crate::EventBox; 8 | 9 | pub trait EventBoxImpl: BinImpl {} 10 | 11 | unsafe impl IsSubclassable for EventBox { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/fixed.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | 7 | use crate::Fixed; 8 | 9 | pub trait FixedImpl: ContainerImpl {} 10 | 11 | unsafe impl IsSubclassable for Fixed { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/stack.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | 7 | use crate::Stack; 8 | 9 | pub trait StackImpl: ContainerImpl {} 10 | 11 | unsafe impl IsSubclassable for Stack { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/drawing_area.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::widget::WidgetImpl; 6 | use crate::DrawingArea; 7 | 8 | pub trait DrawingAreaImpl: WidgetImpl {} 9 | 10 | unsafe impl IsSubclassable for DrawingArea { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gtk/src/subclass/tree_view.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | 7 | use crate::TreeView; 8 | 9 | pub trait TreeViewImpl: ContainerImpl {} 10 | 11 | unsafe impl IsSubclassable for TreeView { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/header_bar.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::container::ContainerImpl; 6 | 7 | use crate::HeaderBar; 8 | 9 | pub trait HeaderBarImpl: ContainerImpl {} 10 | 11 | unsafe impl IsSubclassable for HeaderBar { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gdk/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | //! Traits intended for blanket imports. 4 | 5 | pub use crate::auto::traits::*; 6 | pub use crate::cairo_interaction::{GdkContextExt, GdkPixbufExt, GdkSurfaceExt}; 7 | pub use crate::device::DeviceExtManual; 8 | pub use crate::display::DisplayExtManual; 9 | pub use crate::window::WindowExtManual; 10 | 11 | #[doc(hidden)] 12 | pub use gdk_pixbuf::prelude::*; 13 | #[doc(hidden)] 14 | pub use gio::prelude::*; 15 | #[doc(hidden)] 16 | pub use glib::prelude::*; 17 | #[doc(hidden)] 18 | pub use pango::prelude::*; 19 | -------------------------------------------------------------------------------- /gtk/src/auto/style_properties.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::StyleProvider; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "GtkStyleProperties")] 9 | pub struct StyleProperties(Object) @implements StyleProvider; 10 | 11 | match fn { 12 | type_ => || ffi::gtk_style_properties_get_type(), 13 | } 14 | } 15 | 16 | impl StyleProperties { 17 | pub const NONE: Option<&'static StyleProperties> = None; 18 | } 19 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_device_manager_core.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkX11DeviceManagerCore")] 7 | pub struct X11DeviceManagerCore(Object) @extends gdk::DeviceManager; 8 | 9 | match fn { 10 | type_ => || ffi::gdk_x11_device_manager_core_get_type(), 11 | } 12 | } 13 | 14 | impl X11DeviceManagerCore { 15 | pub const NONE: Option<&'static X11DeviceManagerCore> = None; 16 | } 17 | -------------------------------------------------------------------------------- /gtk/src/subclass/application_window.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::window::WindowImpl; 6 | use crate::ApplicationWindow; 7 | 8 | pub trait ApplicationWindowImpl: WindowImpl {} 9 | 10 | unsafe impl IsSubclassable for ApplicationWindow { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /atk/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![doc = include_str!("../README.md")] 4 | #![cfg_attr(docsrs, feature(doc_cfg))] 5 | 6 | pub use ffi; 7 | pub use glib; 8 | 9 | #[macro_use] 10 | mod rt; 11 | 12 | #[allow(unused_imports)] 13 | mod auto; 14 | 15 | pub use crate::auto::*; 16 | 17 | pub mod prelude; 18 | 19 | pub use crate::attribute::Attribute; 20 | pub use crate::attribute_set::AttributeSet; 21 | pub use crate::text_rectangle::TextRectangle; 22 | 23 | mod attribute; 24 | mod attribute_set; 25 | mod editable_text; 26 | mod table; 27 | mod text_rectangle; 28 | -------------------------------------------------------------------------------- /atk/src/auto/rectangle.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 7 | pub struct Rectangle(Boxed); 8 | 9 | match fn { 10 | copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::atk_rectangle_get_type(), ptr as *mut _) as *mut ffi::AtkRectangle, 11 | free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::atk_rectangle_get_type(), ptr as *mut _), 12 | type_ => || ffi::atk_rectangle_get_type(), 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /atk/src/auto/text_range.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 7 | pub struct TextRange(Boxed); 8 | 9 | match fn { 10 | copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::atk_text_range_get_type(), ptr as *mut _) as *mut ffi::AtkTextRange, 11 | free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::atk_text_range_get_type(), ptr as *mut _), 12 | type_ => || ffi::atk_text_range_get_type(), 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gtk/src/subclass/cell_renderer_pixbuf.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::cell_renderer::CellRendererImpl; 6 | 7 | use crate::CellRendererPixbuf; 8 | 9 | pub trait CellRendererPixbufImpl: CellRendererImpl {} 10 | 11 | unsafe impl IsSubclassable for CellRendererPixbuf { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/cell_renderer_spin.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::cell_renderer_text::CellRendererTextImpl; 6 | use crate::CellRendererSpin; 7 | 8 | pub trait CellRendererSpinImpl: CellRendererTextImpl {} 9 | 10 | unsafe impl IsSubclassable for CellRendererSpin { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gtk/src/subclass/cell_renderer_combo.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::cell_renderer_text::CellRendererTextImpl; 6 | use crate::CellRendererCombo; 7 | 8 | pub trait CellRendererComboImpl: CellRendererTextImpl {} 9 | 10 | unsafe impl IsSubclassable for CellRendererCombo { 11 | fn class_init(class: &mut ::glib::Class) { 12 | Self::parent_class_init::(class); 13 | 14 | if !crate::rt::is_initialized() { 15 | panic!("GTK has to be initialized first"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gtk/src/subclass/cell_renderer_spinner.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::cell_renderer::CellRendererImpl; 6 | 7 | use crate::CellRendererSpinner; 8 | 9 | pub trait CellRendererSpinnerImpl: CellRendererImpl {} 10 | 11 | unsafe impl IsSubclassable for CellRendererSpinner { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gtk/src/subclass/cell_renderer_progress.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::cell_renderer::CellRendererImpl; 6 | 7 | use crate::CellRendererProgress; 8 | 9 | pub trait CellRendererProgressImpl: CellRendererImpl {} 10 | 11 | unsafe impl IsSubclassable for CellRendererProgress { 12 | fn class_init(class: &mut ::glib::Class) { 13 | Self::parent_class_init::(class); 14 | 15 | if !crate::rt::is_initialized() { 16 | panic!("GTK has to be initialized first"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gdk/src/auto/event_sequence.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 7 | pub struct EventSequence(Boxed); 8 | 9 | match fn { 10 | copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gdk_event_sequence_get_type(), ptr as *mut _) as *mut ffi::GdkEventSequence, 11 | free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gdk_event_sequence_get_type(), ptr as *mut _), 12 | type_ => || ffi::gdk_event_sequence_get_type(), 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gtk/src/auto/file_chooser_widget_accessible.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GtkFileChooserWidgetAccessible")] 7 | pub struct FileChooserWidgetAccessible(Object) @extends atk::Object; 8 | 9 | match fn { 10 | type_ => || ffi::gtk_file_chooser_widget_accessible_get_type(), 11 | } 12 | } 13 | 14 | impl FileChooserWidgetAccessible { 15 | pub const NONE: Option<&'static FileChooserWidgetAccessible> = None; 16 | } 17 | -------------------------------------------------------------------------------- /gdkwayland/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg))] 4 | #![doc = include_str!("../README.md")] 5 | 6 | pub use ffi; 7 | pub use gdk; 8 | 9 | mod wayland_device; 10 | pub use wayland_device::WaylandDevice; 11 | 12 | mod wayland_display; 13 | pub use wayland_display::WaylandDisplay; 14 | 15 | mod wayland_gl_context; 16 | pub use wayland_gl_context::WaylandGLContext; 17 | 18 | mod wayland_monitor; 19 | pub use wayland_monitor::WaylandMonitor; 20 | 21 | mod wayland_seat; 22 | pub use wayland_seat::WaylandSeat; 23 | 24 | mod wayland_window; 25 | pub use wayland_window::WaylandWindow; 26 | -------------------------------------------------------------------------------- /gtk/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | check_features(); 3 | } 4 | 5 | fn check_features() { 6 | // The pkg-config file defines a `targets` variable listing the 7 | // various backends that gdk (yes, gdk) was compiled for. 8 | // We extract that and create gdk_backend="x11" and the like 9 | // as configuration variables. 10 | // For reference, the backend set at time of writing consists of: 11 | // x11 win32 quartz broadway wayland 12 | if let Ok(targets) = pkg_config::get_variable("gtk+-3.0", "targets") { 13 | for target in targets.split_whitespace() { 14 | println!("cargo:rustc-cfg=gdk_backend=\"{target}\""); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gtk/src/print_settings.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::PageRange; 6 | use crate::PrintSettings; 7 | 8 | impl PrintSettings { 9 | #[doc(alias = "gtk_print_settings_set_page_ranges")] 10 | pub fn set_page_ranges(&self, page_ranges: &[PageRange]) { 11 | let num_ranges = page_ranges.len() as i32; 12 | unsafe { 13 | ffi::gtk_print_settings_set_page_ranges( 14 | self.to_glib_none().0, 15 | mut_override(page_ranges.as_ptr() as *const _), 16 | num_ranges, 17 | ); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | The gtk-rs Project is licensed under the MIT license, see the LICENSE file or 2 | . 3 | 4 | Copyrights in the gtk-rs Project project are retained by their contributors. 5 | No copyright assignment is required to contribute to the gtk-rs Project 6 | project. 7 | 8 | For full authorship information, see the version control history. 9 | 10 | This project provides interoperability with various GNOME libraries but 11 | doesn't distribute any parts of them. Distributing compiled libraries and 12 | executables that link to those libraries may be subject to terms of the GNU 13 | LGPL or other licenses. For more information check the license of each GNOME 14 | library. 15 | -------------------------------------------------------------------------------- /gtk/src/print_operation.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::PrintOperation; 4 | use glib::translate::*; 5 | use std::ptr; 6 | 7 | impl PrintOperation { 8 | #[doc(alias = "gtk_print_operation_get_error")] 9 | #[doc(alias = "get_error")] 10 | pub fn error(&self) -> Option { 11 | unsafe { 12 | let mut error = ptr::null_mut(); 13 | ffi::gtk_print_operation_get_error(self.to_glib_none().0, &mut error); 14 | if error.is_null() { 15 | None 16 | } else { 17 | Some(from_glib_full(error)) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gdk/src/visual.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Visual; 4 | use std::ptr; 5 | use std::slice; 6 | 7 | impl Visual { 8 | #[doc(alias = "gdk_query_depths")] 9 | pub fn query_depths() -> Vec { 10 | assert_initialized_main_thread!(); 11 | let mut ptr = ptr::null_mut(); 12 | let mut count = 0; 13 | 14 | unsafe { 15 | ffi::gdk_query_depths(&mut ptr, &mut count); 16 | if ptr.is_null() || count == 0 { 17 | vec![] 18 | } else { 19 | Vec::from(slice::from_raw_parts(ptr as *const i32, count as usize)) 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gtk/src/application_window.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Application; 4 | use crate::ApplicationWindow; 5 | use crate::Widget; 6 | use glib::object::Cast; 7 | use glib::object::IsA; 8 | use glib::translate::*; 9 | 10 | impl ApplicationWindow { 11 | #[doc(alias = "gtk_application_window_new")] 12 | pub fn new>(application: &P) -> ApplicationWindow { 13 | skip_assert_initialized!(); 14 | unsafe { 15 | Widget::from_glib_none(ffi::gtk_application_window_new( 16 | application.as_ref().to_glib_none().0, 17 | )) 18 | .unsafe_cast() 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/basics/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::prelude::*; 2 | 3 | fn build_ui(application: >k::Application) { 4 | let window = gtk::ApplicationWindow::new(application); 5 | 6 | window.set_title("First GTK+ Program"); 7 | window.set_border_width(10); 8 | window.set_position(gtk::WindowPosition::Center); 9 | window.set_default_size(350, 70); 10 | 11 | let button = gtk::Button::with_label("Click me!"); 12 | 13 | window.add(&button); 14 | 15 | window.show_all(); 16 | } 17 | 18 | fn main() { 19 | let application = 20 | gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default()); 21 | 22 | application.connect_activate(build_ui); 23 | 24 | application.run(); 25 | } 26 | -------------------------------------------------------------------------------- /gdk/src/event_setting.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | use glib::GString; 5 | 6 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 7 | pub struct EventSetting(crate::Event); 8 | 9 | event_wrapper!(EventSetting, GdkEventSetting); 10 | event_subtype!(EventSetting, ffi::GDK_SETTING); 11 | 12 | impl EventSetting { 13 | #[doc(alias = "get_name")] 14 | pub fn name(&self) -> Option { 15 | unsafe { from_glib_none(self.as_ref().name) } 16 | } 17 | 18 | #[doc(alias = "get_action")] 19 | pub fn action(&self) -> crate::SettingAction { 20 | unsafe { from_glib(self.as_ref().action) } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/image.yml: -------------------------------------------------------------------------------- 1 | name: github packages 2 | 3 | on: 4 | push: 5 | branches: 6 | - "master" 7 | paths: 8 | - "Dockerfile" 9 | pull_request: 10 | paths: 11 | - "Dockerfile" 12 | workflow_dispatch: 13 | 14 | jobs: 15 | docker: 16 | runs-on: ubuntu-20.04 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Push to GitHub Packages 20 | uses: docker/build-push-action@v1 21 | with: 22 | push: ${{ github.event_name != 'pull_request' }} 23 | username: ${{ github.actor }} 24 | password: ${{ secrets.GITHUB_TOKEN }} 25 | registry: ghcr.io 26 | repository: ${{ github.repository }}/gtk3 27 | tags: latest 28 | -------------------------------------------------------------------------------- /gdk/src/event_proximity.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventProximity(crate::Event); 7 | 8 | event_wrapper!(EventProximity, GdkEventProximity); 9 | event_subtype!( 10 | EventProximity, 11 | ffi::GDK_PROXIMITY_IN | ffi::GDK_PROXIMITY_OUT 12 | ); 13 | 14 | impl EventProximity { 15 | #[doc(alias = "get_time")] 16 | pub fn time(&self) -> u32 { 17 | self.as_ref().time 18 | } 19 | 20 | #[doc(alias = "get_device")] 21 | pub fn device(&self) -> Option { 22 | unsafe { from_glib_none(self.as_ref().device) } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/list_box_model/README.md: -------------------------------------------------------------------------------- 1 | # ListBox and ListModel example 2 | 3 | This example demonstrates how to use `gtk::ListBox` in combination with 4 | a custom model and a custom row type. 5 | The custom model resides in `model.rs` and the custom row type in `row_data.rs`. 6 | 7 | It sets up a `gtk::ListBox` containing, per row, a label, spinbutton and 8 | an edit button. The edit button allows to edit the underlying data structure 9 | and changes are taking place immediately in the listbox by making use of GObject 10 | property bindings. 11 | 12 | In addition, it is possible to add new rows and delete old ones. 13 | 14 | Run it by executing: 15 | 16 | ```bash 17 | cargo run --bin list_box_model 18 | ``` 19 | 20 | ![screenshot](screenshot.png) 21 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_cursor.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use x11::xlib; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GdkX11Cursor")] 10 | pub struct X11Cursor(Object) @extends gdk::Cursor; 11 | 12 | match fn { 13 | type_ => || ffi::gdk_x11_cursor_get_type(), 14 | } 15 | } 16 | 17 | impl X11Cursor { 18 | #[doc(alias = "gdk_x11_cursor_get_xcursor")] 19 | #[doc(alias = "get_xcursor")] 20 | pub fn xcursor(&self) -> xlib::Cursor { 21 | unsafe { ffi::gdk_x11_cursor_get_xcursor(self.to_glib_none().0) } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gtk/src/subclass/menu_button.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use super::toggle_button::ToggleButtonImpl; 6 | use crate::MenuButton; 7 | 8 | pub trait MenuButtonImpl: MenuButtonImplExt + ToggleButtonImpl {} 9 | 10 | mod sealed { 11 | pub trait Sealed {} 12 | impl Sealed for T {} 13 | } 14 | 15 | pub trait MenuButtonImplExt: ObjectSubclass + sealed::Sealed {} 16 | 17 | impl MenuButtonImplExt for T {} 18 | 19 | unsafe impl IsSubclassable for MenuButton { 20 | fn class_init(class: &mut glib::Class) { 21 | Self::parent_class_init::(class); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gtk/src/tree_model_filter.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::object::{Cast, IsA}; 4 | use glib::translate::*; 5 | 6 | use crate::{TreeModel, TreeModelFilter, TreePath}; 7 | 8 | impl TreeModelFilter { 9 | #[doc(alias = "gtk_tree_model_filter_new")] 10 | pub fn new>(child_model: &T, root: Option<&TreePath>) -> TreeModelFilter { 11 | skip_assert_initialized!(); 12 | unsafe { 13 | TreeModel::from_glib_none(ffi::gtk_tree_model_filter_new( 14 | child_model.as_ref().to_glib_none().0, 15 | mut_override(root.to_glib_none().0), 16 | )) 17 | .unsafe_cast() 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/header_bar/title_bar.rs: -------------------------------------------------------------------------------- 1 | use gtk::prelude::*; 2 | use gtk::{HeaderBar, Label, Stack, StackSwitcher}; 3 | 4 | pub struct TitleBar { 5 | header: HeaderBar, 6 | menu: StackSwitcher, 7 | } 8 | 9 | impl TitleBar { 10 | pub fn new() -> Self { 11 | let menu = StackSwitcher::new(); 12 | let header = HeaderBar::builder() 13 | .custom_title(&menu) 14 | .show_close_button(true) 15 | .build(); 16 | header.add(&Label::new(Some("Custom title"))); 17 | Self { header, menu } 18 | } 19 | 20 | pub fn set_stack(&self, stack: &Stack) { 21 | self.menu.set_stack(Some(stack)); 22 | } 23 | 24 | pub fn header(&self) -> &HeaderBar { 25 | &self.header 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gtk/src/style_context.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::prelude::*; 4 | use crate::StateFlags; 5 | use crate::StyleContext; 6 | use pango::FontDescription; 7 | 8 | mod sealed { 9 | pub trait Sealed {} 10 | impl> Sealed for T {} 11 | } 12 | 13 | pub trait StyleContextExtManual: IsA + sealed::Sealed + 'static { 14 | #[doc(alias = "get_font")] 15 | fn font(&self, state: StateFlags) -> FontDescription { 16 | self.style_property_for_state("font", state) 17 | .get() 18 | .expect("font property is not pango::FontDescription") 19 | } 20 | } 21 | 22 | impl> StyleContextExtManual for O {} 23 | -------------------------------------------------------------------------------- /gtk/src/selection_data.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::SelectionData; 4 | use glib::translate::*; 5 | use std::mem; 6 | 7 | impl SelectionData { 8 | #[doc(alias = "gtk_selection_data_get_data_with_length")] 9 | #[doc(alias = "get_data")] 10 | pub fn data(&self) -> Vec { 11 | unsafe { 12 | let mut length = mem::MaybeUninit::uninit(); 13 | FromGlibContainer::from_glib_none_num( 14 | ffi::gtk_selection_data_get_data_with_length( 15 | self.to_glib_none().0, 16 | length.as_mut_ptr(), 17 | ), 18 | length.assume_init() as usize, 19 | ) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gdk/src/event_pad_group_mode.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventPadGroupMode(crate::Event); 7 | 8 | event_wrapper!(EventPadGroupMode, GdkEventPadGroupMode); 9 | event_subtype!(EventPadGroupMode, ffi::GDK_PAD_GROUP_MODE); 10 | 11 | impl EventPadGroupMode { 12 | #[doc(alias = "get_time")] 13 | pub fn time(&self) -> u32 { 14 | self.as_ref().time 15 | } 16 | 17 | #[doc(alias = "get_group")] 18 | pub fn group(&self) -> u32 { 19 | self.as_ref().group 20 | } 21 | 22 | #[doc(alias = "get_mode")] 23 | pub fn mode(&self) -> u32 { 24 | self.as_ref().mode 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gdk/src/event_window_state.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventWindowState(crate::Event); 7 | 8 | event_wrapper!(EventWindowState, GdkEventWindowState); 9 | event_subtype!(EventWindowState, ffi::GDK_WINDOW_STATE); 10 | 11 | impl EventWindowState { 12 | #[doc(alias = "get_changed_mask")] 13 | pub fn changed_mask(&self) -> crate::WindowState { 14 | unsafe { from_glib(self.as_ref().changed_mask) } 15 | } 16 | 17 | #[doc(alias = "get_new_window_state")] 18 | pub fn new_window_state(&self) -> crate::WindowState { 19 | unsafe { from_glib(self.as_ref().new_window_state) } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gtk/src/flow_box.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::FlowBox; 4 | use glib::object::IsA; 5 | use glib::translate::*; 6 | use std::ptr; 7 | 8 | mod sealed { 9 | pub trait Sealed {} 10 | impl> Sealed for T {} 11 | } 12 | 13 | pub trait FlowBoxExtManual: IsA + sealed::Sealed + 'static { 14 | fn unbind_model(&self) { 15 | unsafe { 16 | ffi::gtk_flow_box_bind_model( 17 | self.as_ref().to_glib_none().0, 18 | ptr::null_mut(), 19 | None, 20 | ptr::null_mut(), 21 | None, 22 | ) 23 | } 24 | } 25 | } 26 | 27 | impl> FlowBoxExtManual for O {} 28 | -------------------------------------------------------------------------------- /gtk/src/list_box.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ListBox; 4 | use glib::object::IsA; 5 | use glib::translate::*; 6 | use std::ptr; 7 | 8 | mod sealed { 9 | pub trait Sealed {} 10 | impl> Sealed for T {} 11 | } 12 | 13 | pub trait ListBoxExtManual: IsA + sealed::Sealed + 'static { 14 | fn unbind_model(&self) { 15 | unsafe { 16 | ffi::gtk_list_box_bind_model( 17 | self.as_ref().to_glib_none().0, 18 | ptr::null_mut(), 19 | None, 20 | ptr::null_mut(), 21 | None, 22 | ) 23 | } 24 | } 25 | } 26 | 27 | impl> ListBoxExtManual for O {} 28 | -------------------------------------------------------------------------------- /gdk/src/frame_clock.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::FrameClock; 4 | use glib::translate::*; 5 | 6 | impl FrameClock { 7 | #[doc(alias = "gdk_frame_clock_get_refresh_info")] 8 | #[doc(alias = "get_refresh_info")] 9 | pub fn refresh_info(&self, base_time: i64) -> (i64, i64) { 10 | unsafe { 11 | let mut refresh_interval = 0; 12 | let mut presentation_time = 0; 13 | ffi::gdk_frame_clock_get_refresh_info( 14 | self.to_glib_none().0, 15 | base_time, 16 | &mut refresh_interval, 17 | &mut presentation_time, 18 | ); 19 | (refresh_interval, presentation_time) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gdk/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "Gdk" 4 | version = "3.0" 5 | min_cfg_version = "3.22" 6 | single_version_file = "." 7 | split_build_rs = true 8 | girs_directories = ["../../gir-files"] 9 | 10 | external_libraries = [ 11 | "GLib", 12 | "GObject", 13 | "Gio", 14 | "GdkPixbuf", 15 | "Pango", 16 | "Cairo", 17 | ] 18 | 19 | ignore = [ 20 | "Gdk.MAJOR_VERSION", 21 | "Gdk.MICRO_VERSION", 22 | "Gdk.MINOR_VERSION", 23 | ] 24 | 25 | [[object]] 26 | name = "Gdk.EventType" 27 | status = "generate" 28 | [[object.member]] 29 | name = "2button_press" 30 | alias = true 31 | [[object.member]] 32 | name = "3button_press" 33 | alias = true 34 | [[object.member]] 35 | name = "event_last" 36 | alias = true 37 | -------------------------------------------------------------------------------- /gtk/src/tree_path.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::TreePath; 4 | use glib::translate::*; 5 | use std::slice; 6 | 7 | impl TreePath { 8 | #[doc(alias = "gtk_tree_path_get_indices_with_depth")] 9 | #[doc(alias = "get_indices")] 10 | pub fn indices(&self) -> Vec { 11 | unsafe { 12 | let mut count = 0; 13 | let ptr = ffi::gtk_tree_path_get_indices_with_depth( 14 | mut_override(self.to_glib_none().0), 15 | &mut count, 16 | ); 17 | if ptr.is_null() || count == 0 { 18 | vec![] 19 | } else { 20 | slice::from_raw_parts(ptr, count as usize).to_owned() 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/css/style.css: -------------------------------------------------------------------------------- 1 | #entry1 { 2 | background-image: -gtk-gradient (linear, 3 | 0 0, 1 0, 4 | color-stop(0, #f00), 5 | color-stop(1, #0f0)); 6 | color: blue; 7 | font-weight: bold; 8 | } 9 | 10 | button { 11 | /* If we don't put it, the yellow background won't be visible */ 12 | background-image: none; 13 | } 14 | #label1:hover { 15 | transition: 500ms; 16 | color: red; 17 | background-color: yellow; 18 | } 19 | 20 | combobox button.combo box { 21 | padding: 5px; 22 | } 23 | combobox box arrow { 24 | -gtk-icon-source: none; 25 | border-left: 5px solid transparent; 26 | border-right: 5px solid transparent; 27 | border-top: 5px solid black; 28 | } 29 | -------------------------------------------------------------------------------- /gtk/src/cell_renderer_pixbuf.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::CellRendererPixbuf; 4 | use crate::IconSize; 5 | use glib::object::{IsA, ObjectExt}; 6 | use glib::translate::*; 7 | 8 | pub trait CellRendererPixbufExtManual: 9 | IsA + IsA + 'static 10 | { 11 | #[doc(alias = "get_property_stock_size")] 12 | fn stock_size(&self) -> IconSize { 13 | unsafe { from_glib(self.property::("stock-size") as i32) } 14 | } 15 | 16 | fn set_stock_size(&self, stock_size: IconSize) { 17 | self.set_property("stock-size", stock_size.into_glib() as u32); 18 | } 19 | } 20 | 21 | impl + IsA> CellRendererPixbufExtManual for O {} 22 | -------------------------------------------------------------------------------- /gtk/src/target_list.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::TargetEntry; 4 | use crate::TargetList; 5 | use glib::translate::*; 6 | use std::ptr; 7 | 8 | impl TargetList { 9 | #[doc(alias = "gtk_target_list_new")] 10 | pub fn new(targets: &[TargetEntry]) -> Self { 11 | skip_assert_initialized!(); 12 | let stashes: Vec<_> = targets.iter().map(|e| e.to_glib_none()).collect(); 13 | let t: Vec<_> = stashes.iter().map(|stash| unsafe { *stash.0 }).collect(); 14 | let t_ptr: *mut ffi::GtkTargetEntry = if !t.is_empty() { 15 | t.as_ptr() as *mut _ 16 | } else { 17 | ptr::null_mut() 18 | }; 19 | unsafe { from_glib_full(ffi::gtk_target_list_new(t_ptr, t.len() as u32)) } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gdk/src/event_grab_broken.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventGrabBroken(crate::Event); 7 | 8 | event_wrapper!(EventGrabBroken, GdkEventGrabBroken); 9 | event_subtype!(EventGrabBroken, ffi::GDK_GRAB_BROKEN); 10 | 11 | impl EventGrabBroken { 12 | pub fn is_keyboard(&self) -> bool { 13 | unsafe { from_glib(self.as_ref().keyboard) } 14 | } 15 | 16 | pub fn is_implicit(&self) -> bool { 17 | unsafe { from_glib(self.as_ref().implicit) } 18 | } 19 | 20 | #[doc(alias = "get_grab_window")] 21 | pub fn grab_window(&self) -> Option { 22 | unsafe { from_glib_none(self.as_ref().grab_window) } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gdk/src/event_property.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventProperty(crate::Event); 7 | 8 | event_wrapper!(EventProperty, GdkEventProperty); 9 | event_subtype!(EventProperty, ffi::GDK_PROPERTY_NOTIFY); 10 | 11 | impl EventProperty { 12 | #[doc(alias = "get_atom")] 13 | pub fn atom(&self) -> crate::Atom { 14 | unsafe { from_glib_none(self.as_ref().atom) } 15 | } 16 | 17 | #[doc(alias = "get_time")] 18 | pub fn time(&self) -> u32 { 19 | self.as_ref().time 20 | } 21 | 22 | #[doc(alias = "get_state")] 23 | pub fn state(&self) -> crate::PropertyState { 24 | unsafe { from_glib(self.as_ref().state) } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gtk/src/invisible.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Invisible; 4 | use glib::translate::{from_glib_none, ToGlibPtr}; 5 | use glib::IsA; 6 | 7 | // For some reasons, it's not generated... 8 | mod sealed { 9 | pub trait Sealed {} 10 | impl> Sealed for T {} 11 | } 12 | 13 | pub trait InvisibleExtManual: IsA + sealed::Sealed + 'static { 14 | #[doc(alias = "gtk_invisible_get_screen")] 15 | #[doc(alias = "get_screen")] 16 | fn screen(&self) -> Option { 17 | unsafe { 18 | from_glib_none(ffi::gtk_invisible_get_screen( 19 | self.as_ref().to_glib_none().0, 20 | )) 21 | } 22 | } 23 | } 24 | 25 | impl> InvisibleExtManual for T {} 26 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_monitor.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::{prelude::*, translate::*}; 6 | use x11::xlib; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GdkX11Monitor")] 10 | pub struct X11Monitor(Object) @extends gdk::Monitor; 11 | 12 | match fn { 13 | type_ => || ffi::gdk_x11_monitor_get_type(), 14 | } 15 | } 16 | 17 | impl X11Monitor { 18 | #[doc(alias = "gdk_x11_monitor_get_output")] 19 | #[doc(alias = "get_output")] 20 | pub fn output(monitor: &impl IsA) -> xlib::XID { 21 | assert_initialized_main_thread!(); 22 | unsafe { ffi::gdk_x11_monitor_get_output(monitor.as_ref().to_glib_none().0) } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/cairo_png/main.rs: -------------------------------------------------------------------------------- 1 | use cairo::{Context, Format, ImageSurface}; 2 | use std::fs::File; 3 | 4 | fn main() { 5 | let surface = ImageSurface::create(Format::ARgb32, 120, 120).expect("Can't create surface"); 6 | let cr = Context::new(&surface).expect("Can't create a Cairo context"); 7 | // Examples are in 1.0 x 1.0 coordinate space 8 | cr.scale(120.0, 120.0); 9 | 10 | // Drawing code goes here 11 | cr.set_line_width(0.1); 12 | cr.set_source_rgb(0.0, 0.0, 0.0); 13 | cr.rectangle(0.25, 0.25, 0.5, 0.5); 14 | cr.stroke().expect("Invalid cairo surface state"); 15 | 16 | let mut file = File::create("file.png").expect("Couldn't create 'file.png'"); 17 | match surface.write_to_png(&mut file) { 18 | Ok(_) => println!("file.png created"), 19 | Err(_) => println!("Error create file.png"), 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gdk/src/event_configure.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventConfigure(crate::Event); 7 | 8 | event_wrapper!(EventConfigure, GdkEventConfigure); 9 | event_subtype!(EventConfigure, ffi::GDK_CONFIGURE); 10 | 11 | impl EventConfigure { 12 | #[doc(alias = "get_position")] 13 | pub fn position(&self) -> (i32, i32) { 14 | (self.as_ref().x, self.as_ref().y) 15 | } 16 | 17 | #[doc(alias = "get_size")] 18 | pub fn size(&self) -> (u32, u32) { 19 | let width = self.as_ref().width; 20 | let height = self.as_ref().height; 21 | assert!(width >= 0 && height >= 0, "Unexpected negative value"); 22 | (width as u32, height as u32) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gdk/src/keymap_key.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::fmt; 4 | 5 | glib::wrapper! { 6 | #[doc(alias = "GdkKeymapKey")] 7 | pub struct KeymapKey(BoxedInline); 8 | } 9 | 10 | impl KeymapKey { 11 | pub fn keycode(&self) -> u32 { 12 | self.inner.keycode 13 | } 14 | pub fn group(&self) -> i32 { 15 | self.inner.group 16 | } 17 | pub fn level(&self) -> i32 { 18 | self.inner.level 19 | } 20 | } 21 | 22 | impl fmt::Debug for KeymapKey { 23 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 24 | f.debug_struct("Geometry") 25 | .field("keycode", &self.keycode()) 26 | .field("group", &self.group()) 27 | .field("level", &self.level()) 28 | .finish() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/builder_pattern/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::prelude::*; 2 | 3 | fn build_ui(application: >k::Application) { 4 | let window = gtk::ApplicationWindow::builder() 5 | .application(application) 6 | .title("First GTK+ Program") 7 | .border_width(10) 8 | .window_position(gtk::WindowPosition::Center) 9 | .default_width(350) 10 | .default_height(70) 11 | .build(); 12 | 13 | let button = gtk::LockButton::builder() 14 | .text_lock("Lock") 15 | .text_unlock("Unlock") 16 | .build(); 17 | 18 | window.add(&button); 19 | 20 | window.show_all(); 21 | } 22 | 23 | fn main() { 24 | let application = 25 | gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default()); 26 | 27 | application.connect_activate(build_ui); 28 | 29 | application.run(); 30 | } 31 | -------------------------------------------------------------------------------- /gtk3-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gtk3_macros/" 3 | categories = ["api-bindings", "gui"] 4 | license = "MIT" 5 | description = "Rust bindings for the GTK 3 library" 6 | homepage = "https://gtk-rs.org/" 7 | name = "gtk3-macros" 8 | version = "0.19.0" 9 | authors = ["The gtk-rs Project Developers"] 10 | edition = "2021" 11 | keywords = ["gtk", "gtk3", "gtk-rs", "gnome", "GUI"] 12 | repository = "https://github.com/gtk-rs/gtk3-rs" 13 | exclude = [ 14 | "gir-files/*", 15 | "src/composite_template.ui" 16 | ] 17 | rust-version = "1.70" 18 | 19 | [lib] 20 | proc-macro = true 21 | 22 | [dependencies] 23 | proc-macro-error = "1.0" 24 | proc-macro2 = "1.0" 25 | quote = "1.0" 26 | syn = { version = "2.0", features = ["full"] } 27 | proc-macro-crate = "1.0" 28 | 29 | [dev-dependencies] 30 | gtk = { path = "../gtk" } 31 | -------------------------------------------------------------------------------- /atk/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "Atk" 4 | version = "1.0" 5 | min_cfg_version = "2.28" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "GObject", 12 | ] 13 | 14 | ignore = [ 15 | "Atk.BINARY_AGE", 16 | "Atk.INTERFACE_AGE", 17 | "Atk.MAJOR_VERSION", 18 | "Atk.MICRO_VERSION", 19 | "Atk.MINOR_VERSION", 20 | "Atk.VERSION_MIN_REQUIRED", 21 | ] 22 | 23 | extra_versions = [ 24 | "2.38" 25 | ] 26 | 27 | [[object]] 28 | name = "Atk.Live" 29 | status = "generate" 30 | version = "2.50" 31 | 32 | [[object]] 33 | name = "Atk.StateType" 34 | status = "generate" 35 | [[object.member]] 36 | name = "collapsed" 37 | version = "2.38" 38 | [[object.member]] 39 | name = "last_defined" 40 | alias = true # not useful and should fix -sys tests 41 | -------------------------------------------------------------------------------- /gdk/src/event_expose.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Rectangle; 4 | use glib::translate::*; 5 | 6 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 7 | pub struct EventExpose(crate::Event); 8 | 9 | event_wrapper!(EventExpose, GdkEventExpose); 10 | event_subtype!(EventExpose, ffi::GDK_EXPOSE | ffi::GDK_DAMAGE); 11 | 12 | impl EventExpose { 13 | #[doc(alias = "get_region")] 14 | pub fn region(&self) -> Option { 15 | unsafe { from_glib_none(self.as_ref().region) } 16 | } 17 | 18 | #[doc(alias = "get_count")] 19 | pub fn count(&self) -> u32 { 20 | self.as_ref().count as u32 21 | } 22 | 23 | #[doc(alias = "get_area")] 24 | pub fn area(&self) -> Rectangle { 25 | unsafe { from_glib_none(&self.as_ref().area as *const _) } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/composite_template/example_application_window/mod.rs: -------------------------------------------------------------------------------- 1 | mod imp; 2 | 3 | use glib::subclass::prelude::*; 4 | use gtk::prelude::*; 5 | use gtk::{gio, glib}; 6 | 7 | glib::wrapper! { 8 | pub struct ExampleApplicationWindow(ObjectSubclass) 9 | @extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, @implements gio::ActionMap, gio::ActionGroup; 10 | } 11 | 12 | impl ExampleApplicationWindow { 13 | pub fn new>(app: &P) -> Self { 14 | glib::Object::builder().property("application", app).build() 15 | } 16 | 17 | fn init_label(&self) { 18 | // To access fields such as template children, you must get 19 | // the private struct. 20 | let imp = self.imp(); 21 | imp.subtitle 22 | .set_text("This is an example window made using composite templates"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gtk/src/entry.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::object::IsA; 4 | use glib::translate::ToGlibPtr; 5 | use std::convert::TryFrom; 6 | 7 | use crate::Entry; 8 | 9 | mod sealed { 10 | pub trait Sealed {} 11 | impl> Sealed for T {} 12 | } 13 | 14 | pub trait EntryExtManual: IsA + sealed::Sealed + 'static { 15 | #[doc(alias = "gtk_entry_get_invisible_char")] 16 | #[doc(alias = "get_invisible_char")] 17 | fn invisible_char(&self) -> Option { 18 | let ret = unsafe { ffi::gtk_entry_get_invisible_char(self.as_ref().to_glib_none().0) }; 19 | 20 | if ret == 0 { 21 | return None; 22 | } 23 | 24 | Some(TryFrom::try_from(ret).expect("conversion from an invalid Unicode value attempted")) 25 | } 26 | } 27 | 28 | impl> EntryExtManual for O {} 29 | -------------------------------------------------------------------------------- /atk/src/editable_text.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::EditableText; 4 | use glib::object::IsA; 5 | use glib::translate::*; 6 | 7 | mod sealed { 8 | pub trait Sealed {} 9 | impl> Sealed for T {} 10 | } 11 | 12 | pub trait EditableTextExtManual: IsA + sealed::Sealed + 'static { 13 | #[doc(alias = "atk_editable_text_insert_text")] 14 | fn insert_text(&self, string: &str, mut position: i32) -> i32 { 15 | let length = string.len() as i32; 16 | unsafe { 17 | ffi::atk_editable_text_insert_text( 18 | self.as_ref().to_glib_none().0, 19 | string.to_glib_none().0, 20 | length, 21 | &mut position, 22 | ); 23 | } 24 | position 25 | } 26 | } 27 | 28 | impl> EditableTextExtManual for O {} 29 | -------------------------------------------------------------------------------- /gdk/src/event_pad_button.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventPadButton(crate::Event); 7 | 8 | event_wrapper!(EventPadButton, GdkEventPadButton); 9 | event_subtype!( 10 | EventPadButton, 11 | ffi::GDK_PAD_BUTTON_PRESS | ffi::GDK_PAD_BUTTON_RELEASE 12 | ); 13 | 14 | impl EventPadButton { 15 | #[doc(alias = "get_time")] 16 | pub fn time(&self) -> u32 { 17 | self.as_ref().time 18 | } 19 | 20 | #[doc(alias = "get_group")] 21 | pub fn group(&self) -> u32 { 22 | self.as_ref().group 23 | } 24 | 25 | #[doc(alias = "get_button")] 26 | pub fn button(&self) -> u32 { 27 | self.as_ref().button 28 | } 29 | 30 | #[doc(alias = "get_mode")] 31 | pub fn mode(&self) -> u32 { 32 | self.as_ref().mode 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gtk/src/buildable.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Buildable; 4 | use glib::translate::*; 5 | use glib::IsA; 6 | 7 | mod sealed { 8 | pub trait Sealed {} 9 | impl> Sealed for T {} 10 | } 11 | 12 | pub trait BuildableExtManual: IsA + sealed::Sealed + 'static { 13 | #[doc(alias = "gtk_buildable_get_name")] 14 | #[doc(alias = "get_buildable_name")] 15 | fn buildable_name(&self) -> Option { 16 | unsafe { from_glib_none(ffi::gtk_buildable_get_name(self.as_ref().to_glib_none().0)) } 17 | } 18 | 19 | #[doc(alias = "gtk_buildable_set_name")] 20 | fn set_buildable_name(&self, name: &str) { 21 | unsafe { 22 | ffi::gtk_buildable_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0); 23 | } 24 | } 25 | } 26 | 27 | impl> BuildableExtManual for O {} 28 | -------------------------------------------------------------------------------- /examples/icon_view/README.md: -------------------------------------------------------------------------------- 1 | # IconView example 2 | 3 | This example demonstrates how to create a toplevel `Window`, set its title, size and 4 | position, how to add a `IconView` to this `Window` and how to set the model of the `IconView` 5 | 6 | A Gtk.IconView is a widget that displays a collection of icons in a grid view. 7 | It supports features such as drag and drop, multiple selections and item reordering. 8 | Similarly to Gtk.TreeView, Gtk.IconView uses a Gtk.ListStore for its model. 9 | 10 | Instead of using cell renderers, Gtk.IconView requires that one of the columns in its 11 | Gtk.ListStore contains GdkPixbuf.Pixbuf objects. 12 | 13 | The example is using icons from the current icon theme. To view all icons and their names please 14 | install gtk3-icon-browser: https://developer.gnome.org/gtk3/stable/gtk3-icon-browser.html 15 | 16 | Run it by executing: 17 | 18 | ```bash 19 | cargo run --bin icon_view 20 | ``` 21 | 22 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /examples/notebook/main.rs: -------------------------------------------------------------------------------- 1 | mod notebook; 2 | 3 | use gtk::prelude::*; 4 | 5 | use notebook::Notebook; 6 | 7 | fn main() { 8 | let application = gtk::Application::new( 9 | Some("com.github.gtk-rs.examples.notebook"), 10 | Default::default(), 11 | ); 12 | 13 | application.connect_activate(build_ui); 14 | 15 | application.run(); 16 | } 17 | 18 | fn build_ui(application: >k::Application) { 19 | let window = gtk::ApplicationWindow::new(application); 20 | 21 | window.set_title("Notebook"); 22 | window.set_position(gtk::WindowPosition::Center); 23 | window.set_default_size(640, 480); 24 | 25 | let mut notebook = Notebook::new(); 26 | 27 | for i in 1..4 { 28 | let title = format!("sheet {i}"); 29 | let label = gtk::Label::new(Some(&*title)); 30 | notebook.create_tab(&title, label.upcast()); 31 | } 32 | 33 | window.add(¬ebook.notebook); 34 | window.show_all(); 35 | } 36 | -------------------------------------------------------------------------------- /examples/list_box_model/row_data/mod.rs: -------------------------------------------------------------------------------- 1 | //! Our GObject subclass for carrying a name and count for the ListBox model 2 | //! 3 | //! Both name and count are stored in a RefCell to allow for interior mutability 4 | //! and are exposed via normal GObject properties. This allows us to use property 5 | //! bindings below to bind the values with what widgets display in the UI 6 | 7 | mod imp; 8 | 9 | use gtk::glib; 10 | 11 | // Public part of the RowData type. This behaves like a normal gtk-rs-style GObject 12 | // binding 13 | glib::wrapper! { 14 | pub struct RowData(ObjectSubclass); 15 | } 16 | 17 | // Constructor for new instances. This simply calls glib::Object::new() with 18 | // initial values for our two properties and then returns the new instance 19 | impl RowData { 20 | pub fn new(name: &str, count: u32) -> RowData { 21 | glib::Object::builder() 22 | .property("name", name) 23 | .property("count", count) 24 | .build() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/gtk-rs/gtk-rs-core/core:latest 2 | 3 | RUN dnf update -y && \ 4 | dnf install xorg-x11-server-Xvfb procps-ng \ 5 | dbus-devel libxkbcommon-devel wayland-devel wayland-protocols-devel mesa-libEGL-devel \ 6 | libXi-devel libXrandr-devel libXcursor-devel libXdamage-devel libXinerama-devel libXtst-devel -y && \ 7 | dnf clean all -y 8 | 9 | RUN git clone https://gitlab.gnome.org/GNOME/at-spi2-atk.git --depth=1 && \ 10 | (cd /at-spi2-atk && \ 11 | meson setup builddir --prefix=/usr --buildtype release -Dtests=false -Datk:introspection=false -Dat-spi2-core:introspection=no && \ 12 | meson install -C builddir) && \ 13 | git clone https://gitlab.gnome.org/GNOME/gtk.git --depth=1 -b gtk-3-24 && \ 14 | (cd /gtk && \ 15 | meson setup builddir --prefix=/usr --buildtype release -Dintrospection=false -Dexamples=false -Dtests=false -Ddemos=false -Dlibepoxy:tests=false && \ 16 | meson install -C builddir) && \ 17 | rm -rf /at-spi2-atk /gtk 18 | -------------------------------------------------------------------------------- /gdkwayland/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The gtk-rs Project Developers"] 3 | description = "FFI bindings to libgdk-3-wayland" 4 | homepage = "https://gtk-rs.org/" 5 | keywords = ["gdk", "ffi", "gtk-rs", "gnome"] 6 | license = "MIT" 7 | name = "gdkwayland-sys" 8 | repository = "https://github.com/gtk-rs/gtk3-rs" 9 | version = "0.19.0" 10 | edition = "2021" 11 | rust-version = "1.70" 12 | 13 | [lib] 14 | name = "gdk_wayland_sys" 15 | 16 | [features] 17 | v3_24 = ["gdk/v3_24"] 18 | v3_24_22 = ["v3_24"] 19 | 20 | [dependencies] 21 | libc = "0.2" 22 | 23 | [dependencies.glib] 24 | package = "glib-sys" 25 | git = "https://github.com/gtk-rs/gtk-rs-core" 26 | 27 | [dependencies.gobject] 28 | package = "gobject-sys" 29 | git = "https://github.com/gtk-rs/gtk-rs-core" 30 | 31 | [dependencies.gdk] 32 | package = "gdk-sys" 33 | path = "../../gdk/sys" 34 | 35 | [build-dependencies] 36 | pkg-config = "0.3.7" 37 | system-deps = "6" 38 | 39 | [package.metadata.docs.rs] 40 | rustdoc-args = ["--cfg", "docsrs"] 41 | -------------------------------------------------------------------------------- /gdk/src/event_pad_axis.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventPadAxis(crate::Event); 7 | 8 | event_wrapper!(EventPadAxis, GdkEventPadAxis); 9 | event_subtype!(EventPadAxis, ffi::GDK_PAD_RING | ffi::GDK_PAD_STRIP); 10 | 11 | impl EventPadAxis { 12 | #[doc(alias = "get_time")] 13 | pub fn time(&self) -> u32 { 14 | self.as_ref().time 15 | } 16 | 17 | #[doc(alias = "get_group")] 18 | pub fn group(&self) -> u32 { 19 | self.as_ref().group 20 | } 21 | 22 | #[doc(alias = "get_index")] 23 | pub fn index(&self) -> u32 { 24 | self.as_ref().index 25 | } 26 | 27 | #[doc(alias = "get_mode")] 28 | pub fn mode(&self) -> u32 { 29 | self.as_ref().mode 30 | } 31 | 32 | #[doc(alias = "get_value")] 33 | pub fn value(&self) -> f64 { 34 | self.as_ref().value 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gtk/src/page_range.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | use std::fmt; 5 | 6 | glib::wrapper! { 7 | #[doc(alias = "GtkPageRange")] 8 | pub struct PageRange(BoxedInline); 9 | } 10 | 11 | impl PageRange { 12 | pub fn new(start: i32, end: i32) -> PageRange { 13 | skip_assert_initialized!(); 14 | unsafe { PageRange::unsafe_from(ffi::GtkPageRange { start, end }) } 15 | } 16 | 17 | #[doc(alias = "get_start")] 18 | pub fn start(&self) -> i32 { 19 | self.inner.start 20 | } 21 | 22 | #[doc(alias = "get_end")] 23 | pub fn end(&self) -> i32 { 24 | self.inner.end 25 | } 26 | } 27 | 28 | impl fmt::Debug for PageRange { 29 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 30 | f.debug_struct("PageRange") 31 | .field("start", &self.start()) 32 | .field("end", &self.end()) 33 | .finish() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gdkx11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gdkx11" 3 | license = "MIT" 4 | homepage = "https://gtk-rs.org/" 5 | authors = ["The gtk-rs Project Developers"] 6 | keywords = ["gdkx11", "gdk", "gtk-rs", "gnome", "GUI"] 7 | readme = "README.md" 8 | documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdkx11/" 9 | version = "0.19.0" 10 | description = "Rust bindings for the GDK X11 library" 11 | repository = "https://github.com/gtk-rs/gtk3-rs" 12 | exclude = ["gir-files/*"] 13 | edition = "2021" 14 | rust-version = "1.70" 15 | 16 | [lib] 17 | name = "gdkx11" 18 | 19 | [features] 20 | v3_24 = ["ffi/v3_24_2"] 21 | 22 | [package.metadata.docs.rs] 23 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 24 | 25 | [dependencies] 26 | libc = "0.2" 27 | x11 = "2.18" 28 | ffi = { package = "gdkx11-sys", path = "sys" } 29 | glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } 30 | gdk = { path = "../gdk" } 31 | gio = { git = "https://github.com/gtk-rs/gtk-rs-core" } 32 | 33 | [dev-dependencies] 34 | gir-format-check = "^0.1" 35 | -------------------------------------------------------------------------------- /gtk/src/color_chooser.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ColorChooser; 4 | use crate::Orientation; 5 | use gdk::RGBA; 6 | use glib::object::IsA; 7 | use glib::translate::*; 8 | use libc::c_int; 9 | 10 | mod sealed { 11 | pub trait Sealed {} 12 | impl> Sealed for T {} 13 | } 14 | 15 | pub trait ColorChooserExtManual: IsA + sealed::Sealed + 'static { 16 | #[doc(alias = "gtk_color_chooser_add_palette")] 17 | fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: &[RGBA]) { 18 | unsafe { 19 | ffi::gtk_color_chooser_add_palette( 20 | self.as_ref().to_glib_none().0, 21 | orientation.into_glib(), 22 | colors_per_line, 23 | colors.len() as c_int, 24 | colors.as_ptr() as *mut gdk::ffi::GdkRGBA, 25 | ) 26 | } 27 | } 28 | } 29 | 30 | impl> ColorChooserExtManual for O {} 31 | -------------------------------------------------------------------------------- /atk/src/auto/no_op_object_factory.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ObjectFactory; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "AtkNoOpObjectFactory")] 10 | pub struct NoOpObjectFactory(Object) @extends ObjectFactory; 11 | 12 | match fn { 13 | type_ => || ffi::atk_no_op_object_factory_get_type(), 14 | } 15 | } 16 | 17 | impl NoOpObjectFactory { 18 | pub const NONE: Option<&'static NoOpObjectFactory> = None; 19 | 20 | #[doc(alias = "atk_no_op_object_factory_new")] 21 | pub fn new() -> NoOpObjectFactory { 22 | assert_initialized_main_thread!(); 23 | unsafe { ObjectFactory::from_glib_full(ffi::atk_no_op_object_factory_new()).unsafe_cast() } 24 | } 25 | } 26 | 27 | impl Default for NoOpObjectFactory { 28 | fn default() -> Self { 29 | Self::new() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gtk/src/auto/bin.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{Buildable, Container, Widget}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GtkBin")] 10 | pub struct Bin(Object) @extends Container, Widget, @implements Buildable; 11 | 12 | match fn { 13 | type_ => || ffi::gtk_bin_get_type(), 14 | } 15 | } 16 | 17 | impl Bin { 18 | pub const NONE: Option<&'static Bin> = None; 19 | } 20 | 21 | mod sealed { 22 | pub trait Sealed {} 23 | impl> Sealed for T {} 24 | } 25 | 26 | pub trait BinExt: IsA + sealed::Sealed + 'static { 27 | #[doc(alias = "gtk_bin_get_child")] 28 | #[doc(alias = "get_child")] 29 | fn child(&self) -> Option { 30 | unsafe { from_glib_none(ffi::gtk_bin_get_child(self.as_ref().to_glib_none().0)) } 31 | } 32 | } 33 | 34 | impl> BinExt for O {} 35 | -------------------------------------------------------------------------------- /gtk/src/text_iter.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::TextAttributes; 4 | use crate::TextIter; 5 | use glib::translate::*; 6 | use std::convert::TryFrom; 7 | 8 | impl TextIter { 9 | #[doc(alias = "gtk_text_iter_get_attributes")] 10 | #[doc(alias = "get_attributes")] 11 | pub fn is_attributes(&self, values: &TextAttributes) -> bool { 12 | unsafe { 13 | from_glib(ffi::gtk_text_iter_get_attributes( 14 | self.to_glib_none().0, 15 | mut_override(values.to_glib_none().0), 16 | )) 17 | } 18 | } 19 | 20 | #[doc(alias = "gtk_text_iter_get_char")] 21 | #[doc(alias = "get_char")] 22 | pub fn char(&self) -> Option { 23 | let ret = unsafe { ffi::gtk_text_iter_get_char(self.to_glib_none().0) }; 24 | 25 | if ret == 0 { 26 | return None; 27 | } 28 | 29 | Some(TryFrom::try_from(ret).expect("conversion from an invalid Unicode value attempted")) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gdkwayland/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The gtk-rs Project Developers"] 3 | description = "Rust bindings of the GDK-Wayland 3 library" 4 | documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdkwayland/" 5 | edition = "2021" 6 | homepage = "https://gtk-rs.org/" 7 | keywords = ["gdk", "gdk-wayland", "gtk-rs", "gnome", "GUI"] 8 | license = "MIT" 9 | name = "gdkwayland" 10 | readme = "README.md" 11 | repository = "https://github.com/gtk-rs/gtk3-rs" 12 | version = "0.19.0" 13 | rust-version = "1.70" 14 | 15 | [features] 16 | v3_24 = ["ffi/v3_24", "gdk/v3_24"] 17 | v3_24_22 = ["v3_24", "ffi/v3_24_22"] 18 | 19 | [package.metadata.docs.rs] 20 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 21 | 22 | [dependencies] 23 | ffi = { path = "./sys", package = "gdkwayland-sys" } 24 | gdk = { path = "../gdk" } 25 | glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } 26 | libc = "0.2" 27 | wayland-client = "0.30" 28 | wayland-backend = { version = "0.1", features = ["client_system"] } 29 | 30 | [dev-dependencies] 31 | gir-format-check = "^0.1" 32 | -------------------------------------------------------------------------------- /gtk/src/im_context_simple.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::IMContextSimple; 4 | use glib::translate::*; 5 | use glib::IsA; 6 | use std::path::Path; 7 | 8 | mod sealed { 9 | pub trait Sealed {} 10 | impl> Sealed for T {} 11 | } 12 | 13 | pub trait IMContextSimpleExtManual: IsA + sealed::Sealed + 'static { 14 | #[doc(alias = "gtk_im_context_simple_add_compose_file")] 15 | fn add_compose_file>(&self, compose_file: P) { 16 | unsafe { 17 | let compose_file = compose_file.as_ref(); 18 | ffi::gtk_im_context_simple_add_compose_file( 19 | self.as_ref().to_glib_none().0, 20 | compose_file.to_glib_none().0, 21 | ); 22 | } 23 | } 24 | 25 | //#[doc(alias="gtk_im_context_simple_add_table")] 26 | //fn add_table(&self, data: &[u16], max_seq_len: u32, n_seqs: u32); 27 | } 28 | 29 | impl> IMContextSimpleExtManual for O {} 30 | -------------------------------------------------------------------------------- /gdk/src/event_dnd.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventDND(crate::Event); 7 | 8 | event_wrapper!(EventDND, GdkEventDND); 9 | event_subtype!( 10 | EventDND, 11 | ffi::GDK_DRAG_ENTER 12 | | ffi::GDK_DRAG_LEAVE 13 | | ffi::GDK_DRAG_MOTION 14 | | ffi::GDK_DRAG_STATUS 15 | | ffi::GDK_DROP_START 16 | | ffi::GDK_DROP_FINISHED 17 | ); 18 | 19 | impl EventDND { 20 | #[doc(alias = "get_context")] 21 | pub fn context(&self) -> Option { 22 | unsafe { from_glib_none(self.as_ref().context) } 23 | } 24 | 25 | #[doc(alias = "get_time")] 26 | pub fn time(&self) -> u32 { 27 | self.as_ref().time 28 | } 29 | 30 | #[doc(alias = "get_root")] 31 | pub fn root(&self) -> (i16, i16) { 32 | let x_root = self.as_ref().x_root; 33 | let y_root = self.as_ref().y_root; 34 | (x_root, y_root) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | -------------------------------------------------------------------------------- /gdkx11/src/auto/x11_keymap.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "GdkX11Keymap")] 9 | pub struct X11Keymap(Object) @extends gdk::Keymap; 10 | 11 | match fn { 12 | type_ => || ffi::gdk_x11_keymap_get_type(), 13 | } 14 | } 15 | 16 | impl X11Keymap { 17 | #[doc(alias = "gdk_x11_keymap_get_group_for_state")] 18 | #[doc(alias = "get_group_for_state")] 19 | pub fn group_for_state(&self, state: u32) -> i32 { 20 | unsafe { ffi::gdk_x11_keymap_get_group_for_state(self.to_glib_none().0, state) } 21 | } 22 | 23 | #[doc(alias = "gdk_x11_keymap_key_is_modifier")] 24 | pub fn key_is_modifier(&self, keycode: u32) -> bool { 25 | unsafe { 26 | from_glib(ffi::gdk_x11_keymap_key_is_modifier( 27 | self.to_glib_none().0, 28 | keycode, 29 | )) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gtk/src/entry_completion.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Entry; 4 | use crate::EntryCompletion; 5 | use crate::Widget; 6 | use glib::object::IsA; 7 | use glib::translate::*; 8 | use glib::Cast; 9 | 10 | mod sealed { 11 | pub trait Sealed {} 12 | impl> Sealed for T {} 13 | } 14 | 15 | pub trait EntryCompletionExtManual: IsA + sealed::Sealed + 'static { 16 | #[doc(alias = "gtk_entry_completion_get_entry")] 17 | #[doc(alias = "get_entry")] 18 | fn entry(&self) -> Option { 19 | unsafe { 20 | Option::::from_glib_none(ffi::gtk_entry_completion_get_entry( 21 | self.as_ref().to_glib_none().0, 22 | )) 23 | .map(|widget| { 24 | widget 25 | .downcast() 26 | .expect("Non-Entry widget received from get_entry method") 27 | }) 28 | } 29 | } 30 | } 31 | 32 | impl> EntryCompletionExtManual for O {} 33 | -------------------------------------------------------------------------------- /gtk/src/enums.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::IconSize; 4 | use crate::ResponseType; 5 | use glib::translate::{from_glib, IntoGlib}; 6 | 7 | impl IconSize { 8 | pub fn unscaled() -> IconSize { 9 | skip_assert_initialized!(); 10 | IconSize::__Unknown(-1) 11 | } 12 | } 13 | 14 | impl From for i32 { 15 | fn from(val: IconSize) -> i32 { 16 | skip_assert_initialized!(); 17 | val.into_glib() as _ 18 | } 19 | } 20 | 21 | impl From for IconSize { 22 | fn from(val: i32) -> Self { 23 | skip_assert_initialized!(); 24 | unsafe { from_glib(val as ffi::GtkIconSize) } 25 | } 26 | } 27 | 28 | impl From for i32 { 29 | fn from(val: ResponseType) -> i32 { 30 | skip_assert_initialized!(); 31 | val.into_glib() as _ 32 | } 33 | } 34 | 35 | impl From for ResponseType { 36 | fn from(val: i32) -> Self { 37 | skip_assert_initialized!(); 38 | unsafe { from_glib(val as ffi::GtkResponseType) } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/list_box_model/model/imp.rs: -------------------------------------------------------------------------------- 1 | //! Defines the implementation of our model 2 | 3 | use gio::subclass::prelude::*; 4 | use gtk::{gio, glib, prelude::*}; 5 | 6 | use std::cell::RefCell; 7 | 8 | use crate::row_data::RowData; 9 | 10 | #[derive(Debug, Default)] 11 | pub struct Model(pub RefCell>); 12 | 13 | /// Basic declaration of our type for the GObject type system 14 | #[glib::object_subclass] 15 | impl ObjectSubclass for Model { 16 | const NAME: &'static str = "Model"; 17 | type Type = super::Model; 18 | type ParentType = glib::Object; 19 | type Interfaces = (gio::ListModel,); 20 | } 21 | 22 | impl ObjectImpl for Model {} 23 | 24 | impl ListModelImpl for Model { 25 | fn item_type(&self) -> glib::Type { 26 | RowData::static_type() 27 | } 28 | fn n_items(&self) -> u32 { 29 | self.0.borrow().len() as u32 30 | } 31 | fn item(&self, position: u32) -> Option { 32 | self.0 33 | .borrow() 34 | .get(position as usize) 35 | .map(|o| o.clone().upcast::()) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gtk/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "Gtk" 4 | version = "3.0" 5 | min_cfg_version = "3.22.30" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "GObject", 12 | "Gio", 13 | "Atk", 14 | "GdkPixbuf", 15 | "Gdk", 16 | "Pango", 17 | "Cairo", 18 | ] 19 | 20 | manual = [ 21 | "xlib.Window", 22 | ] 23 | 24 | ignore = [ 25 | "Gtk.BINARY_AGE", 26 | "Gtk.INTERFACE_AGE", 27 | "Gtk.MAJOR_VERSION", 28 | "Gtk.MICRO_VERSION", 29 | "Gtk.MINOR_VERSION", 30 | ] 31 | 32 | [[object]] 33 | name = "Gtk.EventControllerKey" 34 | status = "generate" 35 | version = "3.24" 36 | 37 | [[object]] 38 | name = "Gtk.EventControllerMotion" 39 | status = "generate" 40 | version = "3.24" 41 | 42 | [[object]] 43 | name = "Gtk.EventControllerScroll" 44 | status = "generate" 45 | version = "3.24" 46 | 47 | [[object]] 48 | name = "Gtk.FontChooserLevel" 49 | status = "generate" 50 | version = "3.24" 51 | 52 | [[object]] 53 | name = "Gtk.GestureStyle" 54 | status = "generate" 55 | version = "3.24" 56 | -------------------------------------------------------------------------------- /gtk/release_process.md: -------------------------------------------------------------------------------- 1 | # Release process 2 | 3 | Since gtk-rs has multiple crates which have inter-dependencies, it's a bit painful to make a new release. So here are the multiple steps: 4 | 5 | * Merge `master` branch into `crate` branch in every repository (starting with `sys` and ending with `gtk`). (/!\ `cairo-sys` is in `cairo` repository, not `sys` /!\) 6 | * Update crate version in `Cargo.toml` and the number of its `gtk-rs` dependencies. 7 | * Open pull requests to `crate` branches to corresponding repositories. 8 | * Once pull requests have been merged, publish all crates to `crates.io` (using the `cargo publish` command). 9 | * Merge `pending` branch into `master` in the `gtk-rs/examples` repository (by opening a pull request of course). 10 | * Update badges version number in the `_data/crates.json` in the `gtk-rs/gtk-rs.github.io` repository. 11 | * Write a blog post (add the file into `_posts` folder in `gtk-rs.github.io` repository) announcing the new release. 12 | * Update crate version of the `master` branches on every repository. 13 | 14 | NOTE: Pull requests on the `crate` branch aren't build. 15 | -------------------------------------------------------------------------------- /gtk/src/combo_box.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ComboBox; 4 | use glib::object::IsA; 5 | use glib::translate::*; 6 | 7 | mod sealed { 8 | pub trait Sealed {} 9 | impl> Sealed for T {} 10 | } 11 | 12 | pub trait ComboBoxExtManual: IsA + sealed::Sealed + 'static { 13 | #[doc(alias = "gtk_combo_box_set_active")] 14 | fn set_active(&self, index_: Option) { 15 | let index_ = match index_ { 16 | Some(i) => i as _, 17 | None => -1, 18 | }; 19 | unsafe { 20 | ffi::gtk_combo_box_set_active(self.as_ref().to_glib_none().0, index_); 21 | } 22 | } 23 | 24 | #[doc(alias = "gtk_combo_box_get_active")] 25 | #[doc(alias = "get_active")] 26 | fn active(&self) -> Option { 27 | match unsafe { ffi::gtk_combo_box_get_active(self.as_ref().to_glib_none().0) } { 28 | -1 => None, 29 | x => Some(x as _), 30 | } 31 | } 32 | } 33 | 34 | impl> ComboBoxExtManual for O {} 35 | -------------------------------------------------------------------------------- /atk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/atk/" 3 | categories = ["api-bindings", "gui"] 4 | license = "MIT" 5 | description = "Rust bindings for the ATK library" 6 | name = "atk" 7 | homepage = "https://gtk-rs.org/" 8 | authors = ["The gtk-rs Project Developers"] 9 | readme = "README.md" 10 | version = "0.19.0" 11 | keywords = ["atk", "gtk-rs", "gnome", "accessibility"] 12 | repository = "https://github.com/gtk-rs/gtk3-rs" 13 | exclude = ["gir-files/*"] 14 | edition = "2021" 15 | rust-version = "1.70" 16 | 17 | [lib] 18 | name = "atk" 19 | 20 | [features] 21 | v2_30 = ["ffi/v2_30"] 22 | v2_32 = ["v2_30", "ffi/v2_32"] 23 | v2_34 = ["v2_32", "ffi/v2_34"] 24 | v2_38 = ["v2_34", "ffi/v2_38"] 25 | v2_46 = ["v2_38", "ffi/v2_46"] 26 | v2_50 = ["v2_46", "ffi/v2_50"] 27 | 28 | [package.metadata.docs.rs] 29 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 30 | 31 | [dependencies] 32 | libc = "0.2" 33 | ffi = { package = "atk-sys", path = "sys" } 34 | glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } 35 | 36 | [dev-dependencies] 37 | gir-format-check = "^0.1" 38 | -------------------------------------------------------------------------------- /examples/cairo_threads/README.md: -------------------------------------------------------------------------------- 1 | # Cairo Threads 2 | 3 | This example runs four worker threads rendering parts of the image independently at different 4 | paces in a sort of double buffered way. 5 | 6 | +---+---+ 7 | | 0 | 1 | 8 | +---+---+ 9 | | 2 | 3 | 10 | +---+---+ 11 | 12 | Each worker thread waits for an image to render into, sleeps for a while, does the drawing, then 13 | sends the image back and waits for the next one. 14 | The GUI thread holds an image per image part at all times and these images are painted on a 15 | DrawingArea in its 'draw' signal handler whenever needed. 16 | Additionally the GUI thread has a channel for receiving the images from the worker threads. If 17 | there is a new image, the old image stored by the GUI thread is replaced with the new one and 18 | the old image is sent back to the worker thread. Then the appropriate part of the DrawingArea is 19 | invalidated prompting a redraw. 20 | 21 | The two images per thread are allocated and initialized once and sent back and forth repeatedly. 22 | 23 | Run it by executing: 24 | 25 | ```bash 26 | cargo run --bin cairo_threads 27 | ``` 28 | 29 | 30 | ![screenshot](screenshot.png) -------------------------------------------------------------------------------- /gdk/src/screen.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Screen; 4 | use glib::translate::*; 5 | 6 | impl Screen { 7 | #[doc(alias = "gdk_screen_get_font_options")] 8 | #[doc(alias = "get_font_options")] 9 | pub fn font_options(&self) -> Option { 10 | unsafe { 11 | from_glib_none(mut_override(ffi::gdk_screen_get_font_options( 12 | self.to_glib_none().0, 13 | ))) 14 | } 15 | } 16 | 17 | #[doc(alias = "gdk_screen_get_setting")] 18 | #[doc(alias = "get_setting")] 19 | pub fn setting(&self, name: &str) -> Option { 20 | unsafe { 21 | let mut value = glib::Value::uninitialized(); 22 | let done: bool = from_glib(ffi::gdk_screen_get_setting( 23 | self.to_glib_none().0, 24 | name.to_glib_none().0, 25 | value.to_glib_none_mut().0, 26 | )); 27 | 28 | if done { 29 | Some(value) 30 | } else { 31 | None 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gtk/src/requisition.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | use std::mem; 5 | 6 | #[repr(C)] 7 | pub struct Requisition { 8 | pub width: i32, 9 | pub height: i32, 10 | } 11 | 12 | #[doc(hidden)] 13 | impl Uninitialized for Requisition { 14 | #[inline] 15 | unsafe fn uninitialized() -> Self { 16 | mem::zeroed() 17 | } 18 | } 19 | 20 | #[doc(hidden)] 21 | impl<'a> ToGlibPtr<'a, *const ffi::GtkRequisition> for Requisition { 22 | type Storage = &'a Self; 23 | 24 | #[inline] 25 | fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GtkRequisition, Self> { 26 | let ptr: *const Requisition = self; 27 | Stash(ptr as *const ffi::GtkRequisition, self) 28 | } 29 | } 30 | 31 | #[doc(hidden)] 32 | impl<'a> ToGlibPtrMut<'a, *mut ffi::GtkRequisition> for Requisition { 33 | type Storage = &'a mut Self; 34 | 35 | #[inline] 36 | fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::GtkRequisition, Self> { 37 | let ptr: *mut Requisition = &mut *self; 38 | StashMut(ptr as *mut ffi::GtkRequisition, self) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gdk/src/event_owner_change.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventOwnerChange(crate::Event); 7 | 8 | event_wrapper!(EventOwnerChange, GdkEventOwnerChange); 9 | event_subtype!(EventOwnerChange, ffi::GDK_OWNER_CHANGE); 10 | 11 | impl EventOwnerChange { 12 | #[doc(alias = "get_owner")] 13 | pub fn owner(&self) -> Option { 14 | unsafe { from_glib_none(self.as_ref().owner) } 15 | } 16 | 17 | #[doc(alias = "get_reason")] 18 | pub fn reason(&self) -> crate::OwnerChange { 19 | unsafe { from_glib(self.as_ref().reason) } 20 | } 21 | 22 | #[doc(alias = "get_selection")] 23 | pub fn selection(&self) -> crate::Atom { 24 | unsafe { from_glib_none(self.as_ref().selection as *mut _) } 25 | } 26 | 27 | #[doc(alias = "get_time")] 28 | pub fn time(&self) -> u32 { 29 | self.as_ref().time 30 | } 31 | 32 | #[doc(alias = "get_selection_time")] 33 | pub fn selection_time(&self) -> u32 { 34 | self.as_ref().selection_time 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /atk/src/auto/no_op_object.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ 6 | Action, Component, Document, EditableText, Hypertext, Image, Object, Selection, Table, 7 | TableCell, Text, Value, Window, 8 | }; 9 | use glib::{prelude::*, translate::*}; 10 | 11 | glib::wrapper! { 12 | #[doc(alias = "AtkNoOpObject")] 13 | pub struct NoOpObject(Object) @extends Object, @implements Action, Component, Document, EditableText, Hypertext, Image, Selection, Table, TableCell, Text, Value, Window; 14 | 15 | match fn { 16 | type_ => || ffi::atk_no_op_object_get_type(), 17 | } 18 | } 19 | 20 | impl NoOpObject { 21 | pub const NONE: Option<&'static NoOpObject> = None; 22 | 23 | #[doc(alias = "atk_no_op_object_new")] 24 | pub fn new(obj: &impl IsA) -> NoOpObject { 25 | assert_initialized_main_thread!(); 26 | unsafe { 27 | Object::from_glib_full(ffi::atk_no_op_object_new(obj.as_ref().to_glib_none().0)) 28 | .unsafe_cast() 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gdk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gdk" 3 | license = "MIT" 4 | homepage = "https://gtk-rs.org/" 5 | authors = ["The gtk-rs Project Developers"] 6 | keywords = ["gdk", "gtk", "gtk-rs", "gnome", "GUI"] 7 | readme = "README.md" 8 | documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdk/" 9 | version = "0.19.0" 10 | description = "Rust bindings for the GDK 3 library" 11 | repository = "https://github.com/gtk-rs/gtk3-rs" 12 | exclude = [ 13 | "gir-files/*", 14 | ] 15 | edition = "2021" 16 | rust-version = "1.70" 17 | 18 | [lib] 19 | name = "gdk" 20 | 21 | [features] 22 | v3_24 = ["ffi/v3_24"] 23 | unsafe-assume-initialized = [] 24 | 25 | [package.metadata.docs.rs] 26 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 27 | 28 | [dependencies] 29 | libc = "0.2" 30 | ffi = { package = "gdk-sys", path = "sys" } 31 | cairo-rs = { git = "https://github.com/gtk-rs/gtk-rs-core" } 32 | gdk-pixbuf = { git = "https://github.com/gtk-rs/gtk-rs-core" } 33 | gio = { git = "https://github.com/gtk-rs/gtk-rs-core" } 34 | glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } 35 | pango = { git = "https://github.com/gtk-rs/gtk-rs-core" } 36 | 37 | [dev-dependencies] 38 | gir-format-check = "^0.1" 39 | -------------------------------------------------------------------------------- /gtk/src/tree_row_reference.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::TreeIter; 4 | use crate::TreePath; 5 | use crate::TreeRowReference; 6 | use glib::object::IsA; 7 | use glib::translate::*; 8 | use libc::c_int; 9 | 10 | impl TreeRowReference { 11 | // rustdoc-stripper-ignore-next 12 | /// This is unsafe because new_order bounds can't be checked. 13 | #[allow(clippy::missing_safety_doc)] 14 | #[doc(alias = "gtk_tree_row_reference_reordered")] 15 | pub unsafe fn reordered>( 16 | proxy: &T, 17 | path: &TreePath, 18 | iter: Option<&TreeIter>, 19 | new_order: &[u32], 20 | ) { 21 | assert_initialized_main_thread!(); 22 | assert!( 23 | iter.is_some() || path.depth() == 0, 24 | "If 'iter' is None, 'path' must point to the root." 25 | ); 26 | ffi::gtk_tree_row_reference_reordered( 27 | proxy.as_ref().to_glib_none().0, 28 | mut_override(path.to_glib_none().0), 29 | mut_override(iter.to_glib_none().0), 30 | mut_override(new_order.as_ptr() as *const c_int), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/gtk_builder_basics/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::glib; 2 | use gtk::prelude::*; 3 | use gtk::{ApplicationWindow, Builder, Button, MessageDialog}; 4 | 5 | fn main() { 6 | let application = gtk::Application::new( 7 | Some("com.github.gtk-rs.examples.builder_basics"), 8 | Default::default(), 9 | ); 10 | 11 | application.connect_activate(build_ui); 12 | 13 | application.run(); 14 | } 15 | 16 | fn build_ui(application: >k::Application) { 17 | let glade_src = include_str!("builder_basics.ui"); 18 | let builder = Builder::from_string(glade_src); 19 | 20 | let window: ApplicationWindow = builder.object("window1").expect("Couldn't get window1"); 21 | window.set_application(Some(application)); 22 | let bigbutton: Button = builder.object("button1").expect("Couldn't get button1"); 23 | let dialog: MessageDialog = builder 24 | .object("messagedialog1") 25 | .expect("Couldn't get messagedialog1"); 26 | 27 | dialog.connect_delete_event(|dialog, _| { 28 | dialog.hide(); 29 | glib::Propagation::Stop 30 | }); 31 | 32 | bigbutton.connect_clicked(glib::clone!(@weak dialog => move |_| dialog.show_all())); 33 | window.show_all(); 34 | } 35 | -------------------------------------------------------------------------------- /atk/src/auto/hyperlink_impl.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::Hyperlink; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "AtkHyperlinkImpl")] 10 | pub struct HyperlinkImpl(Interface); 11 | 12 | match fn { 13 | type_ => || ffi::atk_hyperlink_impl_get_type(), 14 | } 15 | } 16 | 17 | impl HyperlinkImpl { 18 | pub const NONE: Option<&'static HyperlinkImpl> = None; 19 | } 20 | 21 | mod sealed { 22 | pub trait Sealed {} 23 | impl> Sealed for T {} 24 | } 25 | 26 | pub trait HyperlinkImplExt: IsA + sealed::Sealed + 'static { 27 | #[doc(alias = "atk_hyperlink_impl_get_hyperlink")] 28 | #[doc(alias = "get_hyperlink")] 29 | fn hyperlink(&self) -> Option { 30 | unsafe { 31 | from_glib_full(ffi::atk_hyperlink_impl_get_hyperlink( 32 | self.as_ref().to_glib_none().0, 33 | )) 34 | } 35 | } 36 | } 37 | 38 | impl> HyperlinkImplExt for O {} 39 | -------------------------------------------------------------------------------- /atk/src/attribute.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | use glib::GString; 5 | use std::fmt; 6 | 7 | #[doc(alias = "AtkAttribute")] 8 | pub struct Attribute { 9 | pub name: GString, 10 | pub value: GString, 11 | } 12 | 13 | impl fmt::Display for Attribute { 14 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 15 | f.debug_struct("Attribute") 16 | .field("name", &self.name) 17 | .field("value", &self.value) 18 | .finish() 19 | } 20 | } 21 | 22 | #[doc(hidden)] 23 | impl FromGlib for Attribute { 24 | unsafe fn from_glib(value: ffi::AtkAttribute) -> Self { 25 | skip_assert_initialized!(); 26 | Self { 27 | name: from_glib_full(value.name), 28 | value: from_glib_full(value.value), 29 | } 30 | } 31 | } 32 | 33 | #[doc(hidden)] 34 | impl IntoGlib for Attribute { 35 | type GlibType = ffi::AtkAttribute; 36 | 37 | fn into_glib(self) -> ffi::AtkAttribute { 38 | ffi::AtkAttribute { 39 | name: self.name.to_glib_none().0, 40 | value: self.value.to_glib_none().0, 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /gtk/src/tree_view_column.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::{prelude::TreeViewColumnExt, CellRenderer, TreeViewColumn}; 4 | use glib::object::IsA; 5 | 6 | impl TreeViewColumn { 7 | #[doc(alias = "gtk_tree_view_column_new_with_attributes")] 8 | pub fn with_attributes( 9 | title: &str, 10 | cell_renderer: &impl IsA, 11 | attributes: &[(&str, i32)], 12 | ) -> Self { 13 | assert_initialized_main_thread!(); 14 | let tree_view_column = TreeViewColumn::new(); 15 | tree_view_column.set_title(title); 16 | tree_view_column.pack_start(cell_renderer, true); 17 | tree_view_column.set_attributes(cell_renderer, attributes); 18 | 19 | tree_view_column 20 | } 21 | 22 | #[doc(alias = "gtk_tree_view_column_set_attributes")] 23 | pub fn set_attributes( 24 | &self, 25 | cell_renderer: &impl IsA, 26 | attributes: &[(&str, i32)], 27 | ) { 28 | self.clear_attributes(cell_renderer); 29 | attributes.iter().for_each(|(attribute, column)| { 30 | self.add_attribute(cell_renderer, attribute, *column); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gtk/src/radio_tool_button.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::RadioToolButton; 4 | use crate::ToolItem; 5 | use glib::object::{Cast, ObjectExt}; 6 | use glib::translate::*; 7 | use std::ptr; 8 | 9 | impl RadioToolButton { 10 | #[doc(alias = "gtk_radio_tool_button_new")] 11 | pub fn new() -> Self { 12 | assert_initialized_main_thread!(); 13 | unsafe { 14 | ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new(ptr::null_mut())).unsafe_cast() 15 | } 16 | } 17 | 18 | #[doc(alias = "gtk_radio_tool_button_new_from_stock")] 19 | pub fn from_stock(stock_id: &str) -> Self { 20 | assert_initialized_main_thread!(); 21 | unsafe { 22 | ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new_from_stock( 23 | ptr::null_mut(), 24 | stock_id.to_glib_none().0, 25 | )) 26 | .unsafe_cast() 27 | } 28 | } 29 | 30 | pub fn join_group(&self, group: Option<&RadioToolButton>) { 31 | self.set_property("group", group); 32 | } 33 | } 34 | 35 | impl Default for RadioToolButton { 36 | fn default() -> Self { 37 | Self::new() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gdk/src/change_data.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] 4 | pub enum ChangeData<'a> { 5 | UChars(&'a [u8]), 6 | UShorts(&'a [u16]), 7 | ULongs(&'a [libc::c_ulong]), 8 | UChar(u8), 9 | UShort(u16), 10 | ULong(libc::c_ulong), 11 | } 12 | 13 | #[doc(hidden)] 14 | impl<'a> ChangeData<'a> { 15 | pub fn to_glib(&self) -> *const u8 { 16 | match *self { 17 | Self::UChars(d) => d.as_ptr() as *const _, 18 | Self::UShorts(d) => d.as_ptr() as *const _, 19 | Self::ULongs(d) => d.as_ptr() as *const _, 20 | Self::UChar(d) => &d as *const _ as *const _, 21 | Self::UShort(d) => &d as *const _ as *const _, 22 | Self::ULong(d) => &d as *const _ as *const _, 23 | } 24 | } 25 | 26 | pub fn len(&self) -> usize { 27 | match *self { 28 | Self::UChars(d) => d.len(), 29 | Self::UShorts(d) => d.len(), 30 | Self::ULongs(d) => d.len(), 31 | Self::UChar(_) | Self::UShort(_) | Self::ULong(_) => 1, 32 | } 33 | } 34 | 35 | pub fn is_empty(&self) -> bool { 36 | self.len() != 0 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gdkwayland/src/wayland_seat.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use gdk::prelude::*; 4 | use glib::translate::ToGlibPtr; 5 | 6 | use wayland_client::backend::ObjectId; 7 | use wayland_client::protocol::wl_seat::WlSeat; 8 | use wayland_client::Proxy; 9 | 10 | glib::wrapper! { 11 | #[doc(alias = "GdkWaylandSeat")] 12 | pub struct WaylandSeat(Object) @extends gdk::Seat; 13 | 14 | match fn { 15 | type_ => || ffi::gdk_wayland_seat_get_type(), 16 | } 17 | } 18 | 19 | impl WaylandSeat { 20 | #[doc(alias = "gdk_wayland_seat_get_wl_seat")] 21 | #[doc(alias = "get_wl_seat")] 22 | pub fn wl_seat(&self) -> Option { 23 | unsafe { 24 | let seat_ptr = ffi::gdk_wayland_seat_get_wl_seat(self.to_glib_none().0); 25 | if seat_ptr.is_null() { 26 | None 27 | } else { 28 | let display = self.display()?.unsafe_cast::(); 29 | let cnx = display.connection(); 30 | let id = ObjectId::from_ptr(WlSeat::interface(), seat_ptr as *mut _).unwrap(); 31 | 32 | WlSeat::from_id(&cnx, id).ok() 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gdkx11/src/rt.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::cell::Cell; 4 | use std::sync::atomic::{AtomicBool, Ordering}; 5 | 6 | thread_local! { 7 | static IS_MAIN_THREAD: Cell = Cell::new(false) 8 | } 9 | 10 | static INITIALIZED: AtomicBool = AtomicBool::new(false); 11 | 12 | macro_rules! assert_initialized_main_thread { 13 | () => { 14 | if !crate::rt::is_initialized_main_thread() { 15 | if crate::rt::is_initialized() { 16 | panic!("GDK may only be used from the main thread."); 17 | } else { 18 | panic!("GDK has not been initialized. Call `gdk::init` or `gtk::init` first."); 19 | } 20 | } 21 | }; 22 | } 23 | 24 | /// No-op. 25 | macro_rules! skip_assert_initialized { 26 | () => {}; 27 | } 28 | 29 | /// Returns `true` if GDK has been initialized. 30 | #[inline] 31 | pub fn is_initialized() -> bool { 32 | skip_assert_initialized!(); 33 | INITIALIZED.load(Ordering::Acquire) 34 | } 35 | 36 | /// Returns `true` if GDK has been initialized and this is the main thread. 37 | #[inline] 38 | pub fn is_initialized_main_thread() -> bool { 39 | skip_assert_initialized!(); 40 | IS_MAIN_THREAD.with(|c| c.get()) 41 | } 42 | -------------------------------------------------------------------------------- /examples/header_bar/main.rs: -------------------------------------------------------------------------------- 1 | mod title_bar; 2 | 3 | use gtk::prelude::*; 4 | use gtk::{ApplicationWindow, CheckButton, Label, Stack, WindowPosition}; 5 | use title_bar::TitleBar; 6 | 7 | fn build_ui(application: >k::Application) { 8 | let window = ApplicationWindow::builder() 9 | .application(application) 10 | .title("HeaderBar example") 11 | .window_position(WindowPosition::Center) 12 | .build(); 13 | 14 | let stack = Stack::builder().expand(true).build(); 15 | window.add(&stack); 16 | 17 | let check_button = CheckButton::builder() 18 | .expand(true) 19 | .label("check button") 20 | .build(); 21 | stack.add_titled(&check_button, "check_button", "check button"); 22 | let label = Label::builder().label("Hello world").build(); 23 | stack.add_titled(&label, "label", "label"); 24 | 25 | let title_bar = TitleBar::new(); 26 | window.set_titlebar(Some(title_bar.header())); 27 | title_bar.set_stack(&stack); 28 | 29 | window.show_all(); 30 | } 31 | 32 | fn main() { 33 | let application = gtk::Application::new( 34 | Some("com.github.gtk-rs.examples.menu_bar"), 35 | Default::default(), 36 | ); 37 | 38 | application.connect_activate(build_ui); 39 | 40 | application.run(); 41 | } 42 | -------------------------------------------------------------------------------- /gdk/src/event_selection.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventSelection(crate::Event); 7 | 8 | event_wrapper!(EventSelection, GdkEventSelection); 9 | event_subtype!( 10 | EventSelection, 11 | ffi::GDK_SELECTION_CLEAR | ffi::GDK_SELECTION_NOTIFY | ffi::GDK_SELECTION_REQUEST 12 | ); 13 | 14 | impl EventSelection { 15 | #[doc(alias = "get_selection")] 16 | pub fn selection(&self) -> crate::Atom { 17 | unsafe { from_glib_none(self.as_ref().selection as *mut _) } 18 | } 19 | 20 | #[doc(alias = "get_target")] 21 | pub fn target(&self) -> crate::Atom { 22 | unsafe { from_glib_none(self.as_ref().target as *mut _) } 23 | } 24 | 25 | #[doc(alias = "get_property")] 26 | pub fn property(&self) -> crate::Atom { 27 | unsafe { from_glib_none(self.as_ref().property as *mut _) } 28 | } 29 | 30 | #[doc(alias = "get_time")] 31 | pub fn time(&self) -> u32 { 32 | self.as_ref().time 33 | } 34 | 35 | #[doc(alias = "get_requestor")] 36 | pub fn requestor(&self) -> Option { 37 | unsafe { from_glib_none(self.as_ref().requestor) } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gtk/src/pad_controller.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::PadActionEntry; 4 | use crate::PadController; 5 | use glib::translate::*; 6 | 7 | impl PadController { 8 | #[doc(alias = "gtk_pad_controller_set_action_entries")] 9 | pub fn set_action_entries(&self, entries: &[PadActionEntry]) { 10 | let n_entries = entries.len() as i32; 11 | let entry_strings = entries 12 | .iter() 13 | .map(|e| (e.label().to_glib_none(), e.action_name().to_glib_none())) 14 | .collect::, Stash<_, _>)>>(); 15 | let entries = entries 16 | .iter() 17 | .zip(entry_strings.iter()) 18 | .map(|(e, (label, action_name))| ffi::GtkPadActionEntry { 19 | type_: e.type_().into_glib(), 20 | index: e.index(), 21 | mode: e.mode(), 22 | label: label.0, 23 | action_name: action_name.0, 24 | }) 25 | .collect::>(); 26 | unsafe { 27 | ffi::gtk_pad_controller_set_action_entries( 28 | self.to_glib_none().0, 29 | entries.as_ptr(), 30 | n_entries, 31 | ); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gdkwayland/src/wayland_monitor.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use gdk::prelude::*; 4 | use glib::translate::ToGlibPtr; 5 | 6 | use wayland_client::backend::ObjectId; 7 | use wayland_client::protocol::wl_output::WlOutput; 8 | use wayland_client::Proxy; 9 | 10 | glib::wrapper! { 11 | #[doc(alias = "GdkWaylandMonitor")] 12 | pub struct WaylandMonitor(Object) @extends gdk::Monitor; 13 | 14 | match fn { 15 | type_ => || ffi::gdk_wayland_monitor_get_type(), 16 | } 17 | } 18 | 19 | impl WaylandMonitor { 20 | #[doc(alias = "gdk_wayland_monitor_get_wl_output")] 21 | #[doc(alias = "get_wl_output")] 22 | pub fn wl_output(&self) -> Option { 23 | unsafe { 24 | let output_ptr = ffi::gdk_wayland_monitor_get_wl_output(self.to_glib_none().0); 25 | if output_ptr.is_null() { 26 | None 27 | } else { 28 | let display = self.display()?.unsafe_cast::(); 29 | let cnx = display.connection(); 30 | let id = ObjectId::from_ptr(WlOutput::interface(), output_ptr as *mut _).unwrap(); 31 | 32 | WlOutput::from_id(&cnx, id).ok() 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gdk/src/auto/device_tool.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{AxisFlags, DeviceToolType}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GdkDeviceTool")] 10 | pub struct DeviceTool(Object); 11 | 12 | match fn { 13 | type_ => || ffi::gdk_device_tool_get_type(), 14 | } 15 | } 16 | 17 | impl DeviceTool { 18 | #[doc(alias = "gdk_device_tool_get_hardware_id")] 19 | #[doc(alias = "get_hardware_id")] 20 | pub fn hardware_id(&self) -> u64 { 21 | unsafe { ffi::gdk_device_tool_get_hardware_id(self.to_glib_none().0) } 22 | } 23 | 24 | #[doc(alias = "gdk_device_tool_get_serial")] 25 | #[doc(alias = "get_serial")] 26 | pub fn serial(&self) -> u64 { 27 | unsafe { ffi::gdk_device_tool_get_serial(self.to_glib_none().0) } 28 | } 29 | 30 | #[doc(alias = "gdk_device_tool_get_tool_type")] 31 | #[doc(alias = "get_tool_type")] 32 | pub fn tool_type(&self) -> DeviceToolType { 33 | unsafe { from_glib(ffi::gdk_device_tool_get_tool_type(self.to_glib_none().0)) } 34 | } 35 | 36 | pub fn axes(&self) -> AxisFlags { 37 | ObjectExt::property(self, "axes") 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gdk/src/auto/frame_timings.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct FrameTimings(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::gdk_frame_timings_ref(ptr), 13 | unref => |ptr| ffi::gdk_frame_timings_unref(ptr), 14 | type_ => || ffi::gdk_frame_timings_get_type(), 15 | } 16 | } 17 | 18 | impl FrameTimings { 19 | #[doc(alias = "gdk_frame_timings_get_complete")] 20 | #[doc(alias = "get_complete")] 21 | pub fn is_complete(&self) -> bool { 22 | unsafe { from_glib(ffi::gdk_frame_timings_get_complete(self.to_glib_none().0)) } 23 | } 24 | 25 | #[doc(alias = "gdk_frame_timings_get_frame_counter")] 26 | #[doc(alias = "get_frame_counter")] 27 | pub fn frame_counter(&self) -> i64 { 28 | unsafe { ffi::gdk_frame_timings_get_frame_counter(self.to_glib_none().0) } 29 | } 30 | 31 | #[doc(alias = "gdk_frame_timings_get_frame_time")] 32 | #[doc(alias = "get_frame_time")] 33 | pub fn frame_time(&self) -> i64 { 34 | unsafe { ffi::gdk_frame_timings_get_frame_time(self.to_glib_none().0) } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gtk/src/gesture_stylus.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[cfg(feature = "v3_24")] 4 | use crate::GestureStylus; 5 | use gdk::AxisUse; 6 | use glib::object::IsA; 7 | use glib::translate::*; 8 | 9 | mod sealed { 10 | pub trait Sealed {} 11 | impl> Sealed for T {} 12 | } 13 | 14 | pub trait GestureStylusExtManual: IsA + sealed::Sealed + 'static { 15 | #[cfg(feature = "v3_24")] 16 | #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))] 17 | #[doc(alias = "gtk_gesture_stylus_get_axes")] 18 | #[doc(alias = "get_axes")] 19 | fn axes(&self, axes: Vec) -> Option> { 20 | let mut values: Vec = Vec::new(); 21 | unsafe { 22 | let mut axes1: Vec = axes.iter().map(|a| a.into_glib()).collect(); 23 | axes1.push(gdk::ffi::GDK_AXIS_IGNORE); 24 | if from_glib(ffi::gtk_gesture_stylus_get_axes( 25 | self.as_ref().to_glib_none().0, 26 | axes1.as_mut_ptr(), 27 | values.as_mut_ptr() as *mut *mut f64, 28 | )) { 29 | Some(values) 30 | } else { 31 | None 32 | } 33 | } 34 | } 35 | } 36 | 37 | impl> GestureStylusExtManual for O {} 38 | -------------------------------------------------------------------------------- /atk/src/auto/plug.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{Component, Object}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "AtkPlug")] 10 | pub struct Plug(Object) @extends Object, @implements Component; 11 | 12 | match fn { 13 | type_ => || ffi::atk_plug_get_type(), 14 | } 15 | } 16 | 17 | impl Plug { 18 | pub const NONE: Option<&'static Plug> = None; 19 | 20 | #[doc(alias = "atk_plug_new")] 21 | pub fn new() -> Plug { 22 | assert_initialized_main_thread!(); 23 | unsafe { Object::from_glib_full(ffi::atk_plug_new()).unsafe_cast() } 24 | } 25 | } 26 | 27 | impl Default for Plug { 28 | fn default() -> Self { 29 | Self::new() 30 | } 31 | } 32 | 33 | mod sealed { 34 | pub trait Sealed {} 35 | impl> Sealed for T {} 36 | } 37 | 38 | pub trait AtkPlugExt: IsA + sealed::Sealed + 'static { 39 | #[doc(alias = "atk_plug_get_id")] 40 | #[doc(alias = "get_id")] 41 | fn id(&self) -> Option { 42 | unsafe { from_glib_full(ffi::atk_plug_get_id(self.as_ref().to_glib_none().0)) } 43 | } 44 | } 45 | 46 | impl> AtkPlugExt for O {} 47 | -------------------------------------------------------------------------------- /examples/clock/main.rs: -------------------------------------------------------------------------------- 1 | use chrono::Local; 2 | use gtk::glib; 3 | use gtk::prelude::*; 4 | 5 | fn current_time() -> String { 6 | format!("{}", Local::now().format("%Y-%m-%d %H:%M:%S")) 7 | } 8 | 9 | fn build_ui(application: >k::Application) { 10 | let window = gtk::ApplicationWindow::new(application); 11 | 12 | window.set_title("First GTK+ Clock"); 13 | window.set_border_width(10); 14 | window.set_position(gtk::WindowPosition::Center); 15 | window.set_default_size(260, 40); 16 | 17 | let time = current_time(); 18 | let label = gtk::Label::new(None); 19 | label.set_text(&time); 20 | 21 | window.add(&label); 22 | 23 | window.show_all(); 24 | 25 | // we are using a closure to capture the label (else we could also use a normal function) 26 | let tick = move || { 27 | let time = current_time(); 28 | label.set_text(&time); 29 | // we could return glib::ControlFlow::Break to stop our clock after this tick 30 | glib::ControlFlow::Continue 31 | }; 32 | 33 | // executes the closure once every second 34 | glib::timeout_add_seconds_local(1, tick); 35 | } 36 | 37 | fn main() { 38 | let application = 39 | gtk::Application::new(Some("com.github.gtk-rs.examples.clock"), Default::default()); 40 | 41 | application.connect_activate(build_ui); 42 | 43 | application.run(); 44 | } 45 | -------------------------------------------------------------------------------- /gtk/src/color_button.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ColorButton; 4 | use crate::Widget; 5 | use glib::object::Cast; 6 | use glib::object::IsA; 7 | use glib::translate::*; 8 | use std::mem; 9 | 10 | mod sealed { 11 | pub trait Sealed {} 12 | impl> Sealed for T {} 13 | } 14 | 15 | pub trait ColorButtonExtManual: IsA + sealed::Sealed + 'static { 16 | #[doc(alias = "gtk_color_button_new_with_color")] 17 | fn with_color(color: &gdk::Color) -> ColorButton { 18 | assert_initialized_main_thread!(); 19 | unsafe { Widget::from_glib_none(ffi::gtk_color_button_new_with_color(color)).unsafe_cast() } 20 | } 21 | 22 | #[doc(alias = "gtk_color_button_get_color")] 23 | #[doc(alias = "get_color")] 24 | fn color(&self) -> gdk::Color { 25 | unsafe { 26 | let mut color = mem::MaybeUninit::uninit(); 27 | ffi::gtk_color_button_get_color(self.as_ref().to_glib_none().0, color.as_mut_ptr()); 28 | color.assume_init() 29 | } 30 | } 31 | 32 | #[doc(alias = "gtk_color_button_set_color")] 33 | fn set_color(&self, color: &gdk::Color) { 34 | unsafe { ffi::gtk_color_button_set_color(self.as_ref().to_glib_none().0, color) } 35 | } 36 | } 37 | 38 | impl> ColorButtonExtManual for O {} 39 | -------------------------------------------------------------------------------- /gdkx11/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The gtk-rs Project Developers"] 3 | description = "FFI binding for libgdkx11" 4 | homepage = "https://gtk-rs.org/" 5 | keywords = ["gdkx11", "ffi", "gtk-rs", "gnome"] 6 | license = "MIT" 7 | repository = "https://github.com/gtk-rs/gtk3-rs" 8 | name = "gdkx11-sys" 9 | version = "0.19.0" 10 | build = "build.rs" 11 | edition = "2021" 12 | rust-version = "1.70" 13 | 14 | [package.metadata.docs.rs] 15 | rustdoc-args = ["--cfg", "docsrs"] 16 | features = [] 17 | rustc-args = ["--cfg", "docsrs"] 18 | 19 | [package.metadata.system-deps.gdk_x11_3_0] 20 | name = "gdk-x11-3.0" 21 | version = "3.22" 22 | 23 | [package.metadata.system-deps.gdk_x11_3_0.v3_24] 24 | version = "3.24" 25 | 26 | [package.metadata.system-deps.gdk_x11_3_0.v3_24_2] 27 | version = "3.24.2" 28 | 29 | [lib] 30 | name = "gdk_x11_sys" 31 | 32 | [dependencies] 33 | libc = "0.2" 34 | x11 = "2.18" 35 | 36 | [dependencies.gdk] 37 | package = "gdk-sys" 38 | path = "../../gdk/sys" 39 | 40 | [dependencies.glib] 41 | package = "glib-sys" 42 | git = "https://github.com/gtk-rs/gtk-rs-core" 43 | 44 | [dependencies.cairo] 45 | package = "cairo-sys-rs" 46 | git = "https://github.com/gtk-rs/gtk-rs-core" 47 | optional = true 48 | 49 | [build-dependencies] 50 | system-deps = "6" 51 | 52 | [dev-dependencies] 53 | shell-words = "1.0.0" 54 | tempfile = "3" 55 | 56 | [features] 57 | v3_24 = [] 58 | v3_24_2 = ["v3_24", "cairo"] 59 | -------------------------------------------------------------------------------- /examples/sync_widget/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::prelude::*; 2 | use gtk::{glib, Builder}; 3 | 4 | fn build_ui(application: >k::Application) { 5 | let glade_src = include_str!("sync_widgets.ui"); 6 | let builder = Builder::new(); 7 | builder 8 | .add_from_string(glade_src) 9 | .expect("Couldn't add from string"); 10 | 11 | let slider: gtk::Scale = builder.object("slider").expect("Couldn't get slider"); 12 | let spin_button: gtk::SpinButton = builder 13 | .object("spin_button") 14 | .expect("Couldn't get spin_button"); 15 | let slider_adj = slider.adjustment(); 16 | let spin_button_adj = spin_button.adjustment(); 17 | slider_adj 18 | .bind_property("value", &spin_button_adj, "value") 19 | .flags( 20 | glib::BindingFlags::DEFAULT 21 | | glib::BindingFlags::SYNC_CREATE 22 | | glib::BindingFlags::BIDIRECTIONAL, 23 | ) 24 | .build(); 25 | 26 | let window: gtk::ApplicationWindow = builder.object("window").expect("Couldn't get window"); 27 | window.set_application(Some(application)); 28 | 29 | window.show_all(); 30 | } 31 | 32 | fn main() { 33 | let application = gtk::Application::new( 34 | Some("com.github.gtk-rs.examples.sync_widgets"), 35 | Default::default(), 36 | ); 37 | 38 | application.connect_activate(build_ui); 39 | 40 | application.run(); 41 | } 42 | -------------------------------------------------------------------------------- /gtk/src/pad_action_entry.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::PadActionType; 4 | 5 | #[derive(Debug, Clone)] 6 | pub struct PadActionEntry { 7 | type_: PadActionType, 8 | index: i32, 9 | mode: i32, 10 | label: String, 11 | action_name: String, 12 | } 13 | 14 | impl PadActionEntry { 15 | pub fn new( 16 | type_: PadActionType, 17 | index: i32, 18 | mode: i32, 19 | label: &str, 20 | action_name: &str, 21 | ) -> PadActionEntry { 22 | assert_initialized_main_thread!(); 23 | PadActionEntry { 24 | type_, 25 | index, 26 | mode, 27 | label: label.to_owned(), 28 | action_name: action_name.to_owned(), 29 | } 30 | } 31 | 32 | #[doc(alias = "get_type")] 33 | pub fn type_(&self) -> PadActionType { 34 | self.type_ 35 | } 36 | 37 | #[doc(alias = "get_index")] 38 | pub fn index(&self) -> i32 { 39 | self.index 40 | } 41 | 42 | #[doc(alias = "get_mode")] 43 | pub fn mode(&self) -> i32 { 44 | self.mode 45 | } 46 | 47 | #[doc(alias = "get_label")] 48 | pub fn label(&self) -> &str { 49 | &self.label 50 | } 51 | 52 | #[doc(alias = "get_action_name")] 53 | pub fn action_name(&self) -> &str { 54 | &self.action_name 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /atk/src/auto/misc.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::{prelude::*, translate::*}; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "AtkMisc")] 9 | pub struct Misc(Object); 10 | 11 | match fn { 12 | type_ => || ffi::atk_misc_get_type(), 13 | } 14 | } 15 | 16 | impl Misc { 17 | pub const NONE: Option<&'static Misc> = None; 18 | 19 | #[doc(alias = "atk_misc_get_instance")] 20 | #[doc(alias = "get_instance")] 21 | pub fn instance() -> Option { 22 | assert_initialized_main_thread!(); 23 | unsafe { from_glib_none(ffi::atk_misc_get_instance()) } 24 | } 25 | } 26 | 27 | mod sealed { 28 | pub trait Sealed {} 29 | impl> Sealed for T {} 30 | } 31 | 32 | pub trait AtkMiscExt: IsA + sealed::Sealed + 'static { 33 | #[doc(alias = "atk_misc_threads_enter")] 34 | fn threads_enter(&self) { 35 | unsafe { 36 | ffi::atk_misc_threads_enter(self.as_ref().to_glib_none().0); 37 | } 38 | } 39 | 40 | #[doc(alias = "atk_misc_threads_leave")] 41 | fn threads_leave(&self) { 42 | unsafe { 43 | ffi::atk_misc_threads_leave(self.as_ref().to_glib_none().0); 44 | } 45 | } 46 | } 47 | 48 | impl> AtkMiscExt for O {} 49 | -------------------------------------------------------------------------------- /atk/README.md: -------------------------------------------------------------------------------- 1 | # Rust ATK bindings 2 | 3 | Project site is [here](https://gtk-rs.org/). 4 | 5 | __Rust__ bindings and wrappers for [ATK](https://developer.gnome.org/atk), 6 | part of [gtk3-rs](https://github.com/gtk-rs/gtk3-rs). 7 | 8 | ATK __2.28__ is the lowest supported version for the underlying library. 9 | 10 | ## Minimum supported Rust version 11 | 12 | Currently, the minimum supported Rust version is `1.70.0`. 13 | 14 | ## Documentation 15 | 16 | * [Rust API - Stable](https://gtk-rs.org/gtk3-rs/stable/latest/docs/atk/) 17 | * [Rust API - Development](https://gtk-rs.org/gtk3-rs/git/docs/atk) 18 | * [GTK Installation instructions](https://www.gtk.org/docs/installations/) 19 | 20 | ## Using 21 | 22 | We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), 23 | as [demonstrated here](https://gtk-rs.org/#using). 24 | 25 | If you want to track the bleeding edge, use the git dependency instead: 26 | 27 | ```toml 28 | [dependencies] 29 | atk = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "atk" } 30 | ``` 31 | 32 | Avoid mixing versioned and git crates like this: 33 | 34 | ```toml 35 | # This will not compile 36 | [dependencies] 37 | atk = "0.13" 38 | atk = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "atk" } 39 | ``` 40 | 41 | ### See Also 42 | 43 | * [glib](https://crates.io/crates/glib) 44 | 45 | ## License 46 | 47 | __atk__ is available under the MIT License, please refer to it. 48 | -------------------------------------------------------------------------------- /examples/notebook/notebook.rs: -------------------------------------------------------------------------------- 1 | use gtk::glib; 2 | use gtk::prelude::*; 3 | use gtk::{IconSize, Orientation, ReliefStyle, Widget}; 4 | 5 | pub struct Notebook { 6 | pub notebook: gtk::Notebook, 7 | tabs: Vec, 8 | } 9 | 10 | impl Notebook { 11 | pub fn new() -> Self { 12 | Self { 13 | notebook: gtk::Notebook::new(), 14 | tabs: Vec::new(), 15 | } 16 | } 17 | 18 | pub fn create_tab(&mut self, title: &str, widget: Widget) -> u32 { 19 | let close_image = gtk::Image::from_icon_name(Some("window-close"), IconSize::Button); 20 | let button = gtk::Button::new(); 21 | let label = gtk::Label::new(Some(title)); 22 | let tab = gtk::Box::new(Orientation::Horizontal, 0); 23 | 24 | button.set_relief(ReliefStyle::None); 25 | button.add(&close_image); 26 | 27 | tab.pack_start(&label, false, false, 0); 28 | tab.pack_start(&button, false, false, 0); 29 | tab.show_all(); 30 | 31 | let index = self.notebook.append_page(&widget, Some(&tab)); 32 | 33 | button.connect_clicked(glib::clone!(@weak self.notebook as notebook => move |_| { 34 | let index = notebook 35 | .page_num(&widget) 36 | .expect("Couldn't get page_num from notebook"); 37 | notebook.remove_page(Some(index)); 38 | })); 39 | 40 | self.tabs.push(tab); 41 | 42 | index 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /gtk/src/radio_button.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::RadioButton; 4 | use crate::Widget; 5 | use glib::object::Cast; 6 | use glib::translate::*; 7 | use std::ptr; 8 | 9 | impl RadioButton { 10 | #[doc(alias = "gtk_radio_button_new")] 11 | pub fn new() -> Self { 12 | assert_initialized_main_thread!(); 13 | unsafe { Widget::from_glib_none(ffi::gtk_radio_button_new(ptr::null_mut())).unsafe_cast() } 14 | } 15 | 16 | #[doc(alias = "gtk_radio_button_new_with_label")] 17 | pub fn with_label(label: &str) -> Self { 18 | assert_initialized_main_thread!(); 19 | unsafe { 20 | Widget::from_glib_none(ffi::gtk_radio_button_new_with_label( 21 | ptr::null_mut(), 22 | label.to_glib_none().0, 23 | )) 24 | .unsafe_cast() 25 | } 26 | } 27 | 28 | #[doc(alias = "gtk_radio_button_new_with_mnemonic")] 29 | pub fn with_mnemonic(label: &str) -> Self { 30 | assert_initialized_main_thread!(); 31 | unsafe { 32 | Widget::from_glib_none(ffi::gtk_radio_button_new_with_mnemonic( 33 | ptr::null_mut(), 34 | label.to_glib_none().0, 35 | )) 36 | .unsafe_cast() 37 | } 38 | } 39 | } 40 | 41 | impl Default for RadioButton { 42 | fn default() -> Self { 43 | Self::new() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /gtk/src/auto/text_attributes.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct TextAttributes(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::gtk_text_attributes_ref(ptr), 13 | unref => |ptr| ffi::gtk_text_attributes_unref(ptr), 14 | type_ => || ffi::gtk_text_attributes_get_type(), 15 | } 16 | } 17 | 18 | impl TextAttributes { 19 | #[doc(alias = "gtk_text_attributes_new")] 20 | pub fn new() -> TextAttributes { 21 | assert_initialized_main_thread!(); 22 | unsafe { from_glib_full(ffi::gtk_text_attributes_new()) } 23 | } 24 | 25 | #[doc(alias = "gtk_text_attributes_copy")] 26 | #[must_use] 27 | pub fn copy(&self) -> Option { 28 | unsafe { from_glib_full(ffi::gtk_text_attributes_copy(self.to_glib_none().0)) } 29 | } 30 | 31 | #[doc(alias = "gtk_text_attributes_copy_values")] 32 | pub fn copy_values(&self, dest: &TextAttributes) { 33 | unsafe { 34 | ffi::gtk_text_attributes_copy_values(self.to_glib_none().0, dest.to_glib_none().0); 35 | } 36 | } 37 | } 38 | 39 | impl Default for TextAttributes { 40 | fn default() -> Self { 41 | Self::new() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /gdk/src/event_key.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventKey(crate::Event); 7 | 8 | event_wrapper!(EventKey, GdkEventKey); 9 | event_subtype!(EventKey, ffi::GDK_KEY_PRESS | ffi::GDK_KEY_RELEASE); 10 | 11 | impl EventKey { 12 | #[doc(alias = "get_time")] 13 | pub fn time(&self) -> u32 { 14 | self.as_ref().time 15 | } 16 | 17 | #[doc(alias = "get_state")] 18 | pub fn state(&self) -> crate::ModifierType { 19 | unsafe { from_glib(self.as_ref().state) } 20 | } 21 | 22 | #[doc(alias = "get_keyval")] 23 | pub fn keyval(&self) -> crate::keys::Key { 24 | unsafe { from_glib(self.as_ref().keyval) } 25 | } 26 | 27 | #[doc(alias = "get_length")] 28 | pub fn length(&self) -> u32 { 29 | let length = self.as_ref().length; 30 | assert!(length >= 0, "Unexpected negative value"); 31 | length as u32 32 | } 33 | 34 | #[doc(alias = "get_hardware_keycode")] 35 | pub fn hardware_keycode(&self) -> u16 { 36 | self.as_ref().hardware_keycode 37 | } 38 | 39 | #[doc(alias = "get_group")] 40 | pub fn group(&self) -> u8 { 41 | self.as_ref().group 42 | } 43 | 44 | #[doc(alias = "get_is_modifier")] 45 | pub fn is_modifier(&self) -> bool { 46 | self.as_ref().is_modifier & 1 != 0 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/grid/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::glib; 2 | use gtk::prelude::*; 3 | use gtk::{ApplicationWindow, Builder, Button, Grid}; 4 | fn main() { 5 | let application = 6 | gtk::Application::new(Some("com.github.gtk-rs.examples.grid"), Default::default()); 7 | 8 | application.connect_activate(build_ui); 9 | 10 | application.run(); 11 | } 12 | 13 | fn build_ui(application: >k::Application) { 14 | let glade_src = include_str!("grid.ui"); 15 | let builder = Builder::from_string(glade_src); 16 | 17 | let window: ApplicationWindow = builder.object("window").expect("Couldn't get window"); 18 | window.set_application(Some(application)); 19 | let grid: Grid = builder.object("grid").expect("Couldn't get grid"); 20 | let button6: Button = builder.object("button6").expect("Couldn't get button6"); 21 | button6.connect_clicked(glib::clone!(@weak grid => move |button| { 22 | let height = grid.cell_height(button); 23 | let new_height = if height == 2 { 1 } else { 2 }; 24 | grid.set_cell_height(button, new_height); 25 | })); 26 | let button7: Button = builder.object("button7").expect("Couldn't get button7"); 27 | button7.connect_clicked(glib::clone!(@weak grid => move |button| { 28 | let left_attach = grid.cell_left_attach(button); 29 | let new_left_attach = if left_attach == 2 { 0 } else { left_attach + 1 }; 30 | grid.set_cell_left_attach(button, new_left_attach); 31 | })); 32 | 33 | window.show_all(); 34 | } 35 | -------------------------------------------------------------------------------- /examples/list_box_model/model/mod.rs: -------------------------------------------------------------------------------- 1 | //! Defines our custom model 2 | 3 | mod imp; 4 | 5 | use crate::row_data::RowData; 6 | use glib::subclass::prelude::*; 7 | use gtk::{gio, glib, prelude::*}; 8 | 9 | // Public part of the Model type. 10 | glib::wrapper! { 11 | pub struct Model(ObjectSubclass) @implements gio::ListModel; 12 | } 13 | 14 | // Constructor for new instances. This simply calls glib::Object::new() 15 | impl Model { 16 | #[allow(clippy::new_without_default)] 17 | pub fn new() -> Model { 18 | glib::Object::new() 19 | } 20 | 21 | pub fn append(&self, obj: &RowData) { 22 | let imp = self.imp(); 23 | let index = { 24 | // Borrow the data only once and ensure the borrow guard is dropped 25 | // before we emit the items_changed signal because the view 26 | // could call get_item / get_n_item from the signal handler to update its state 27 | let mut data = imp.0.borrow_mut(); 28 | data.push(obj.clone()); 29 | data.len() - 1 30 | }; 31 | // Emits a signal that 1 item was added, 0 removed at the position index 32 | self.items_changed(index as u32, 0, 1); 33 | } 34 | 35 | pub fn remove(&self, index: u32) { 36 | let imp = self.imp(); 37 | imp.0.borrow_mut().remove(index as usize); 38 | // Emits a signal that 1 item was removed, 0 added at the position index 39 | self.items_changed(index, 1, 0); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/pango_attributes/main.rs: -------------------------------------------------------------------------------- 1 | use gtk::pango; 2 | use gtk::prelude::*; 3 | 4 | fn build_ui(application: >k::Application) { 5 | let window = gtk::ApplicationWindow::new(application); 6 | 7 | window.set_title("Pango text attributes"); 8 | window.set_border_width(10); 9 | window.set_position(gtk::WindowPosition::Center); 10 | window.set_default_size(350, 70); 11 | 12 | let label = gtk::Label::new(Some("Some text")); 13 | let attr_list = pango::AttrList::new(); 14 | 15 | let mut attr = pango::AttrColor::new_background(65535, 0, 0); 16 | attr.set_start_index(0); 17 | attr.set_end_index(2); 18 | attr_list.insert(attr); 19 | 20 | let mut attr = pango::AttrInt::new_underline(pango::Underline::Single); 21 | attr.set_start_index(1); 22 | attr.set_end_index(4); 23 | attr_list.insert(attr); 24 | 25 | let mut attr = pango::AttrInt::new_strikethrough(true); 26 | attr.set_start_index(5); 27 | attr_list.insert(attr); 28 | 29 | let mut attr = pango::AttrFloat::new_scale(1.2); 30 | attr.set_start_index(6); 31 | attr_list.insert(attr); 32 | 33 | label.set_attributes(Some(&attr_list)); 34 | window.add(&label); 35 | 36 | window.show_all(); 37 | } 38 | 39 | fn main() { 40 | let application = gtk::Application::new( 41 | Some("com.github.gtk-rs.examples.pango_attributes"), 42 | Default::default(), 43 | ); 44 | 45 | application.connect_activate(build_ui); 46 | 47 | application.run(); 48 | } 49 | -------------------------------------------------------------------------------- /gtk/src/radio_menu_item.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::RadioMenuItem; 4 | use crate::Widget; 5 | use glib::object::Cast; 6 | use glib::translate::*; 7 | use std::ptr; 8 | 9 | impl RadioMenuItem { 10 | #[doc(alias = "gtk_radio_menu_item_new")] 11 | pub fn new() -> Self { 12 | assert_initialized_main_thread!(); 13 | unsafe { 14 | Widget::from_glib_none(ffi::gtk_radio_menu_item_new(ptr::null_mut())).unsafe_cast() 15 | } 16 | } 17 | 18 | #[doc(alias = "gtk_radio_menu_item_new_with_label")] 19 | pub fn with_label(label: &str) -> Self { 20 | assert_initialized_main_thread!(); 21 | unsafe { 22 | Widget::from_glib_none(ffi::gtk_radio_menu_item_new_with_label( 23 | ptr::null_mut(), 24 | label.to_glib_none().0, 25 | )) 26 | .unsafe_cast() 27 | } 28 | } 29 | 30 | #[doc(alias = "gtk_radio_menu_item_new_with_mnemonic")] 31 | pub fn with_mnemonic(label: &str) -> Self { 32 | assert_initialized_main_thread!(); 33 | unsafe { 34 | Widget::from_glib_none(ffi::gtk_radio_menu_item_new_with_mnemonic( 35 | ptr::null_mut(), 36 | label.to_glib_none().0, 37 | )) 38 | .unsafe_cast() 39 | } 40 | } 41 | } 42 | 43 | impl Default for RadioMenuItem { 44 | fn default() -> Self { 45 | Self::new() 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gtk/src/switch.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Switch; 4 | use glib::object::{Cast, IsA}; 5 | use glib::signal::{connect_raw, SignalHandlerId}; 6 | use glib::translate::*; 7 | use std::boxed::Box as Box_; 8 | use std::mem::transmute; 9 | 10 | mod sealed { 11 | pub trait Sealed {} 12 | impl> Sealed for T {} 13 | } 14 | 15 | pub trait SwitchExtManual: IsA + sealed::Sealed + 'static { 16 | fn connect_changed_active(&self, f: F) -> SignalHandlerId { 17 | unsafe extern "C" fn changed_active_trampoline( 18 | this: *mut ffi::GtkSwitch, 19 | _gparamspec: glib::ffi::gpointer, 20 | f: glib::ffi::gpointer, 21 | ) where 22 | T: IsA, 23 | { 24 | let f: &F = &*(f as *const F); 25 | f(Switch::from_glib_borrow(this).unsafe_cast_ref()) 26 | } 27 | unsafe { 28 | let f: Box_ = Box_::new(f); 29 | connect_raw( 30 | self.to_glib_none().0 as *mut _, 31 | b"notify::active\0".as_ptr() as *mut _, 32 | Some(transmute::<_, unsafe extern "C" fn()>( 33 | changed_active_trampoline:: as *const (), 34 | )), 35 | Box_::into_raw(f), 36 | ) 37 | } 38 | } 39 | } 40 | 41 | impl> SwitchExtManual for O {} 42 | -------------------------------------------------------------------------------- /gtk/src/app_chooser.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Widget; 4 | use gio::AppInfo; 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | pub struct AppChooser(Interface) @requires Widget; 10 | 11 | match fn { 12 | type_ => || ffi::gtk_app_chooser_get_type(), 13 | } 14 | } 15 | 16 | mod sealed { 17 | pub trait Sealed {} 18 | impl> Sealed for T {} 19 | } 20 | 21 | pub trait AppChooserExt: IsA + sealed::Sealed + 'static { 22 | #[doc(alias = "gtk_app_chooser_get_app_info")] 23 | #[doc(alias = "get_app_info")] 24 | fn app_info(&self) -> Option { 25 | unsafe { 26 | from_glib_full(ffi::gtk_app_chooser_get_app_info( 27 | self.as_ref().to_glib_none().0, 28 | )) 29 | } 30 | } 31 | 32 | #[doc(alias = "gtk_app_chooser_get_content_type")] 33 | #[doc(alias = "get_content_type")] 34 | fn content_type(&self) -> Option { 35 | unsafe { 36 | from_glib_full(ffi::gtk_app_chooser_get_content_type( 37 | self.as_ref().to_glib_none().0, 38 | )) 39 | } 40 | } 41 | 42 | #[doc(alias = "gtk_app_chooser_refresh")] 43 | fn refresh(&self) { 44 | unsafe { ffi::gtk_app_chooser_refresh(self.as_ref().to_glib_none().0) } 45 | } 46 | } 47 | 48 | impl> AppChooserExt for O {} 49 | -------------------------------------------------------------------------------- /gtk/src/functions.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | use glib::Slice; 5 | use std::ptr; 6 | 7 | #[doc(alias = "gtk_accelerator_parse_with_keycode")] 8 | pub fn accelerator_parse_with_keycode( 9 | accelerator: &str, 10 | ) -> Option<(u32, Slice, gdk::ModifierType)> { 11 | assert_initialized_main_thread!(); 12 | unsafe { 13 | let mut accelerator_key = std::mem::MaybeUninit::uninit(); 14 | let mut accelerator_codes_ptr = ptr::null_mut(); 15 | let mut accelerator_mods = std::mem::MaybeUninit::uninit(); 16 | ffi::gtk_accelerator_parse_with_keycode( 17 | accelerator.to_glib_none().0, 18 | accelerator_key.as_mut_ptr(), 19 | &mut accelerator_codes_ptr, 20 | accelerator_mods.as_mut_ptr(), 21 | ); 22 | if !accelerator_codes_ptr.is_null() { 23 | let mut len = 0; 24 | if !accelerator_codes_ptr.is_null() { 25 | while ptr::read(accelerator_codes_ptr.add(len)) != 0 { 26 | len += 1; 27 | } 28 | } 29 | let accelerator_codes = Slice::from_glib_full_num(accelerator_codes_ptr, len); 30 | Some(( 31 | accelerator_key.assume_init(), 32 | accelerator_codes, 33 | from_glib(accelerator_mods.assume_init()), 34 | )) 35 | } else { 36 | None 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /atk/src/table.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::Table; 4 | use glib::object::IsA; 5 | use glib::translate::*; 6 | 7 | mod sealed { 8 | pub trait Sealed {} 9 | impl> Sealed for T {} 10 | } 11 | 12 | pub trait TableExtManual: IsA + sealed::Sealed + 'static { 13 | #[doc(alias = "atk_table_get_selected_columns")] 14 | #[doc(alias = "get_selected_columns")] 15 | fn selected_columns(&self) -> Vec { 16 | unsafe { 17 | let mut selected = ::std::ptr::null_mut(); 18 | let nb = 19 | ffi::atk_table_get_selected_columns(self.as_ref().to_glib_none().0, &mut selected); 20 | if nb <= 0 { 21 | Vec::new() 22 | } else { 23 | Vec::from_raw_parts(selected, nb as usize, nb as usize) 24 | } 25 | } 26 | } 27 | 28 | #[doc(alias = "atk_table_get_selected_rows")] 29 | #[doc(alias = "get_selected_rows")] 30 | fn selected_rows(&self) -> Vec { 31 | unsafe { 32 | let mut selected = ::std::ptr::null_mut(); 33 | let nb = 34 | ffi::atk_table_get_selected_rows(self.as_ref().to_glib_none().0, &mut selected); 35 | if nb <= 0 { 36 | Vec::new() 37 | } else { 38 | Vec::from_raw_parts(selected, nb as usize, nb as usize) 39 | } 40 | } 41 | } 42 | } 43 | 44 | impl> TableExtManual for O {} 45 | -------------------------------------------------------------------------------- /gdk/sys/build.rs: -------------------------------------------------------------------------------- 1 | #[cfg(not(docsrs))] 2 | use std::io; 3 | #[cfg(not(docsrs))] 4 | use std::io::prelude::*; 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | let _ = writeln!(io::stderr(), "{s}"); 15 | process::exit(1); 16 | } 17 | 18 | // It's safe to assume we can call this because we found the library OK 19 | // in find() 20 | check_features(); 21 | } 22 | 23 | #[cfg(not(docsrs))] 24 | fn check_features() { 25 | const PKG_CONFIG_PACKAGE: &str = "gdk-3.0"; 26 | 27 | // The pkg-config file defines a `targets` variable listing the 28 | // various backends that gdk was compiled for. 29 | // We extract that and create gdk_backend="x11" and the like 30 | // as configuration variables. 31 | // In addition we publish this as a variable which cargo will 32 | // provide to immediate dependents of this crate as an environment 33 | // variable for their `build.rs` runs called DEP_GDK_BACKENDS 34 | // For reference, the backend set at time of writing consists of: 35 | // x11 win32 quartz broadway wayland 36 | if let Ok(targets) = pkg_config::get_variable(PKG_CONFIG_PACKAGE, "targets") { 37 | println!("cargo:backends={targets}"); 38 | for target in targets.split_whitespace() { 39 | println!("cargo:rustc-cfg=gdk_backend=\"{target}\""); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/cairo_threads/image/image_holder.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | use std::rc::Rc; 3 | 4 | /// Helper struct that allows passing the pixels to the Cairo image surface and once the 5 | /// image surface is destroyed the pixels will be stored in the return_location. 6 | /// 7 | /// This allows us to give temporary ownership of the pixels to the Cairo surface and later 8 | /// retrieve them back in a safe way while ensuring that nothing else still has access to 9 | /// it. 10 | pub struct ImageHolder { 11 | image: Option>, 12 | return_location: Rc>>>, 13 | } 14 | 15 | impl ImageHolder { 16 | pub fn new(image: Option>, return_location: Rc>>>) -> Self { 17 | Self { 18 | image, 19 | return_location, 20 | } 21 | } 22 | } 23 | 24 | /// This stores the pixels back into the return_location as now nothing 25 | /// references the pixels anymore 26 | impl Drop for ImageHolder { 27 | fn drop(&mut self) { 28 | *self.return_location.borrow_mut() = Some(self.image.take().expect("Holding no image")); 29 | } 30 | } 31 | 32 | /// Needed for ImageSurface::create_for_data() to be able to access the pixels 33 | impl AsRef<[u8]> for ImageHolder { 34 | fn as_ref(&self) -> &[u8] { 35 | self.image.as_ref().expect("Holding no image").as_ref() 36 | } 37 | } 38 | 39 | impl AsMut<[u8]> for ImageHolder { 40 | fn as_mut(&mut self) -> &mut [u8] { 41 | self.image.as_mut().expect("Holding no image").as_mut() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /gtk/src/application.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::rt; 4 | use crate::Application; 5 | use gio::prelude::*; 6 | use gio::ApplicationFlags; 7 | use glib::signal::SignalHandlerId; 8 | use glib::translate::*; 9 | 10 | use std::cell::RefCell; 11 | use std::rc::Rc; 12 | 13 | impl Application { 14 | #[doc(alias = "gtk_application_new")] 15 | pub fn new(application_id: Option<&str>, flags: ApplicationFlags) -> Application { 16 | skip_assert_initialized!(); 17 | let app: Application = unsafe { 18 | from_glib_full(ffi::gtk_application_new( 19 | application_id.to_glib_none().0, 20 | flags.into_glib(), 21 | )) 22 | }; 23 | Application::register_startup_hook(&app); 24 | app 25 | } 26 | 27 | pub(crate) fn register_startup_hook(app: &Application) { 28 | skip_assert_initialized!(); 29 | let signalid: Rc>> = Rc::new(RefCell::new(None)); 30 | { 31 | let signalid_ = signalid.clone(); 32 | 33 | let id = app.connect_startup(move |app| { 34 | app.disconnect( 35 | signalid_ 36 | .borrow_mut() 37 | .take() 38 | .expect("Signal ID went missing"), 39 | ); 40 | unsafe { rt::set_initialized() } 41 | }); 42 | *signalid.borrow_mut() = Some(id); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /gdk/src/event_touchpad_swipe.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct EventTouchpadSwipe(crate::Event); 7 | 8 | event_wrapper!(EventTouchpadSwipe, GdkEventTouchpadSwipe); 9 | event_subtype!(EventTouchpadSwipe, ffi::GDK_TOUCHPAD_SWIPE); 10 | 11 | impl EventTouchpadSwipe { 12 | pub fn is_phase(&self) -> bool { 13 | unsafe { from_glib(self.as_ref().phase as _) } 14 | } 15 | 16 | #[doc(alias = "get_n_fingers")] 17 | pub fn n_fingers(&self) -> i8 { 18 | self.as_ref().n_fingers 19 | } 20 | 21 | #[doc(alias = "get_time")] 22 | pub fn time(&self) -> u32 { 23 | self.as_ref().time 24 | } 25 | 26 | #[doc(alias = "get_position")] 27 | pub fn position(&self) -> (f64, f64) { 28 | let x = self.as_ref().x; 29 | let y = self.as_ref().y; 30 | (x, y) 31 | } 32 | 33 | #[doc(alias = "get_delta")] 34 | pub fn delta(&self) -> (f64, f64) { 35 | let dx = self.as_ref().dx; 36 | let dy = self.as_ref().dy; 37 | (dx, dy) 38 | } 39 | 40 | #[doc(alias = "get_root")] 41 | pub fn root(&self) -> (f64, f64) { 42 | let x_root = self.as_ref().x_root; 43 | let y_root = self.as_ref().y_root; 44 | (x_root, y_root) 45 | } 46 | 47 | #[doc(alias = "get_state")] 48 | pub fn state(&self) -> crate::ModifierType { 49 | unsafe { from_glib(self.as_ref().state) } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /gdkx11/src/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod x11_app_launch_context; 6 | pub use self::x11_app_launch_context::X11AppLaunchContext; 7 | 8 | mod x11_cursor; 9 | pub use self::x11_cursor::X11Cursor; 10 | 11 | mod x11_device_core; 12 | pub use self::x11_device_core::X11DeviceCore; 13 | 14 | mod x11_device_manager_core; 15 | pub use self::x11_device_manager_core::X11DeviceManagerCore; 16 | 17 | mod x11_device_manager_xi2; 18 | pub use self::x11_device_manager_xi2::X11DeviceManagerXI2; 19 | 20 | mod x11_device_xi2; 21 | pub use self::x11_device_xi2::X11DeviceXI2; 22 | 23 | mod x11_display; 24 | pub use self::x11_display::X11Display; 25 | 26 | mod x11_display_manager; 27 | pub use self::x11_display_manager::X11DisplayManager; 28 | 29 | mod x11_drag_context; 30 | pub use self::x11_drag_context::X11DragContext; 31 | 32 | mod x11gl_context; 33 | pub use self::x11gl_context::X11GLContext; 34 | 35 | mod x11_keymap; 36 | pub use self::x11_keymap::X11Keymap; 37 | 38 | mod x11_monitor; 39 | pub use self::x11_monitor::X11Monitor; 40 | 41 | mod x11_screen; 42 | pub use self::x11_screen::X11Screen; 43 | 44 | mod x11_visual; 45 | pub use self::x11_visual::X11Visual; 46 | 47 | mod x11_window; 48 | pub use self::x11_window::X11Window; 49 | 50 | pub(crate) mod functions; 51 | 52 | pub(crate) mod builders { 53 | pub use super::x11_device_manager_xi2::X11DeviceManagerXI2Builder; 54 | pub use super::x11_device_xi2::X11DeviceXI2Builder; 55 | } 56 | -------------------------------------------------------------------------------- /gtk/src/recent_chooser_dialog.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::RecentChooserDialog; 4 | use crate::RecentManager; 5 | use crate::Widget; 6 | use crate::Window; 7 | use glib::object::{Cast, IsA}; 8 | use glib::translate::*; 9 | use std::ptr; 10 | 11 | impl RecentChooserDialog { 12 | #[doc(alias = "gtk_recent_chooser_dialog_new")] 13 | pub fn new>(title: Option<&str>, parent: Option<&T>) -> RecentChooserDialog { 14 | assert_initialized_main_thread!(); 15 | unsafe { 16 | Widget::from_glib_none(ffi::gtk_recent_chooser_dialog_new( 17 | title.to_glib_none().0, 18 | parent.map(|p| p.as_ref()).to_glib_none().0, 19 | ptr::null_mut(), 20 | )) 21 | .unsafe_cast() 22 | } 23 | } 24 | 25 | #[doc(alias = "gtk_recent_chooser_dialog_new_for_manager")] 26 | #[doc(alias = "new_for_manager")] 27 | pub fn for_manager>( 28 | title: Option<&str>, 29 | parent: Option<&T>, 30 | manager: &RecentManager, 31 | ) -> RecentChooserDialog { 32 | assert_initialized_main_thread!(); 33 | unsafe { 34 | Widget::from_glib_none(ffi::gtk_recent_chooser_dialog_new_for_manager( 35 | title.to_glib_none().0, 36 | parent.map(|p| p.as_ref()).to_glib_none().0, 37 | manager.to_glib_none().0, 38 | ptr::null_mut(), 39 | )) 40 | .unsafe_cast() 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /atk/src/auto/socket.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{Component, Object}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "AtkSocket")] 10 | pub struct Socket(Object) @extends Object, @implements Component; 11 | 12 | match fn { 13 | type_ => || ffi::atk_socket_get_type(), 14 | } 15 | } 16 | 17 | impl Socket { 18 | pub const NONE: Option<&'static Socket> = None; 19 | 20 | #[doc(alias = "atk_socket_new")] 21 | pub fn new() -> Socket { 22 | assert_initialized_main_thread!(); 23 | unsafe { Object::from_glib_full(ffi::atk_socket_new()).unsafe_cast() } 24 | } 25 | } 26 | 27 | impl Default for Socket { 28 | fn default() -> Self { 29 | Self::new() 30 | } 31 | } 32 | 33 | mod sealed { 34 | pub trait Sealed {} 35 | impl> Sealed for T {} 36 | } 37 | 38 | pub trait AtkSocketExt: IsA + sealed::Sealed + 'static { 39 | #[doc(alias = "atk_socket_embed")] 40 | fn embed(&self, plug_id: &str) { 41 | unsafe { 42 | ffi::atk_socket_embed(self.as_ref().to_glib_none().0, plug_id.to_glib_none().0); 43 | } 44 | } 45 | 46 | #[doc(alias = "atk_socket_is_occupied")] 47 | fn is_occupied(&self) -> bool { 48 | unsafe { from_glib(ffi::atk_socket_is_occupied(self.as_ref().to_glib_none().0)) } 49 | } 50 | } 51 | 52 | impl> AtkSocketExt for O {} 53 | -------------------------------------------------------------------------------- /gdk/src/auto/drawing_context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::Window; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GdkDrawingContext")] 10 | pub struct DrawingContext(Object); 11 | 12 | match fn { 13 | type_ => || ffi::gdk_drawing_context_get_type(), 14 | } 15 | } 16 | 17 | impl DrawingContext { 18 | #[doc(alias = "gdk_drawing_context_get_cairo_context")] 19 | #[doc(alias = "get_cairo_context")] 20 | pub fn cairo_context(&self) -> Option { 21 | unsafe { 22 | from_glib_none(ffi::gdk_drawing_context_get_cairo_context( 23 | self.to_glib_none().0, 24 | )) 25 | } 26 | } 27 | 28 | #[doc(alias = "gdk_drawing_context_get_clip")] 29 | #[doc(alias = "get_clip")] 30 | pub fn clip(&self) -> Option { 31 | unsafe { from_glib_full(ffi::gdk_drawing_context_get_clip(self.to_glib_none().0)) } 32 | } 33 | 34 | #[doc(alias = "gdk_drawing_context_get_window")] 35 | #[doc(alias = "get_window")] 36 | pub fn window(&self) -> Option { 37 | unsafe { from_glib_none(ffi::gdk_drawing_context_get_window(self.to_glib_none().0)) } 38 | } 39 | 40 | #[doc(alias = "gdk_drawing_context_is_valid")] 41 | pub fn is_valid(&self) -> bool { 42 | unsafe { from_glib(ffi::gdk_drawing_context_is_valid(self.to_glib_none().0)) } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /gdkx11/README.md: -------------------------------------------------------------------------------- 1 | # Rust GDKX11 bindings 2 | 3 | Project site is [here](https://gtk-rs.org/). 4 | 5 | __Rust__ bindings and wrappers for [GDKX11](https://developer.gnome.org/gdk3/stable/gdk3-X-Window-System-Interaction.html), 6 | part of [gtk3-rs](https://github.com/gtk-rs/gtk3-rs). 7 | 8 | GDKX11 __3.22__ is the lowest supported version for the underlying library. 9 | 10 | ## Minimum supported Rust version 11 | 12 | Currently, the minimum supported Rust version is `1.70.0`. 13 | 14 | ## Documentation 15 | 16 | * [Rust API - Stable](https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdkx11/) 17 | * [Rust API - Development](https://gtk-rs.org/gtk3-rs/git/docs/gdkx11) 18 | * [GTK Installation instructions](https://www.gtk.org/docs/installations/) 19 | 20 | ## Using 21 | 22 | We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), 23 | as [demonstrated here](https://gtk-rs.org/#using). 24 | 25 | If you want to track the bleeding edge, use the git dependency instead: 26 | 27 | ```toml 28 | [dependencies] 29 | gdkx11 = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "gdkx11" } 30 | ``` 31 | 32 | Avoid mixing versioned and git crates like this: 33 | 34 | ```toml 35 | # This will not compile 36 | [dependencies] 37 | gdkx11 = "0.13" 38 | gdkx11 = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "gdkx11" } 39 | ``` 40 | 41 | ### See Also 42 | 43 | * [glib](https://crates.io/crates/glib) 44 | * [gio](https://crates.io/crates/gio) 45 | * [gdk](https://crates.io/crates/gdk) 46 | 47 | ## License 48 | 49 | __gdkx11__ is available under the MIT License, please refer to it. 50 | -------------------------------------------------------------------------------- /gtk/src/subclass/plug.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::subclass::prelude::*; 4 | 5 | use glib::translate::*; 6 | use glib::Cast; 7 | 8 | use super::window::WindowImpl; 9 | use crate::Plug; 10 | 11 | pub trait PlugImpl: PlugImplExt + WindowImpl { 12 | fn embedded(&self) { 13 | self.parent_embedded() 14 | } 15 | } 16 | 17 | mod sealed { 18 | pub trait Sealed {} 19 | impl Sealed for T {} 20 | } 21 | 22 | pub trait PlugImplExt: ObjectSubclass + sealed::Sealed { 23 | fn parent_embedded(&self) { 24 | unsafe { 25 | let data = Self::type_data(); 26 | let parent_class = data.as_ref().parent_class() as *mut ffi::GtkPlugClass; 27 | if let Some(f) = (*parent_class).embedded { 28 | f(self.obj().unsafe_cast_ref::().to_glib_none().0) 29 | } 30 | } 31 | } 32 | } 33 | 34 | impl PlugImplExt for T {} 35 | 36 | unsafe impl IsSubclassable for Plug { 37 | fn class_init(class: &mut ::glib::Class) { 38 | Self::parent_class_init::(class); 39 | 40 | if !crate::rt::is_initialized() { 41 | panic!("GTK has to be initialized first"); 42 | } 43 | 44 | let klass = class.as_mut(); 45 | klass.embedded = Some(plug_embedded::); 46 | } 47 | } 48 | 49 | unsafe extern "C" fn plug_embedded(ptr: *mut ffi::GtkPlug) { 50 | let instance = &*(ptr as *mut T::Instance); 51 | let imp = instance.imp(); 52 | 53 | imp.embedded() 54 | } 55 | -------------------------------------------------------------------------------- /atk/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies] 2 | system-deps = "6" 3 | 4 | [dependencies] 5 | libc = "0.2" 6 | 7 | [dependencies.glib] 8 | package = "glib-sys" 9 | git = "https://github.com/gtk-rs/gtk-rs-core" 10 | 11 | [dependencies.gobject] 12 | package = "gobject-sys" 13 | git = "https://github.com/gtk-rs/gtk-rs-core" 14 | 15 | [dev-dependencies] 16 | shell-words = "1.0.0" 17 | tempfile = "3" 18 | 19 | [features] 20 | v2_30 = [] 21 | v2_32 = ["v2_30"] 22 | v2_34 = ["v2_32"] 23 | v2_38 = ["v2_34"] 24 | v2_46 = ["v2_38"] 25 | v2_50 = ["v2_46"] 26 | 27 | [lib] 28 | name = "atk_sys" 29 | 30 | [package] 31 | authors = ["The gtk-rs Project Developers"] 32 | build = "build.rs" 33 | description = "FFI bindings to libatk-1" 34 | homepage = "https://gtk-rs.org/" 35 | keywords = ["atk", "ffi", "gtk-rs", "gnome"] 36 | license = "MIT" 37 | links = "atk-1.0" 38 | name = "atk-sys" 39 | repository = "https://github.com/gtk-rs/gtk3-rs" 40 | version = "0.19.0" 41 | edition = "2021" 42 | rust-version = "1.70" 43 | 44 | [package.metadata.docs.rs] 45 | rustdoc-args = ["--cfg", "docsrs"] 46 | features = [] 47 | rustc-args = ["--cfg", "docsrs"] 48 | 49 | [package.metadata.system-deps.atk] 50 | name = "atk" 51 | version = "2.28" 52 | 53 | [package.metadata.system-deps.atk.v2_30] 54 | version = "2.30" 55 | 56 | [package.metadata.system-deps.atk.v2_32] 57 | version = "2.32" 58 | 59 | [package.metadata.system-deps.atk.v2_34] 60 | version = "2.34" 61 | 62 | [package.metadata.system-deps.atk.v2_38] 63 | version = "2.38" 64 | 65 | [package.metadata.system-deps.atk.v2_46] 66 | version = "2.46" 67 | 68 | [package.metadata.system-deps.atk.v2_50] 69 | version = "2.50" 70 | -------------------------------------------------------------------------------- /gdk/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies] 2 | pkg-config = "0.3.7" 3 | system-deps = "6" 4 | 5 | [dependencies] 6 | libc = "0.2" 7 | 8 | [dependencies.cairo] 9 | package = "cairo-sys-rs" 10 | git = "https://github.com/gtk-rs/gtk-rs-core" 11 | 12 | [dependencies.gdk_pixbuf] 13 | package = "gdk-pixbuf-sys" 14 | git = "https://github.com/gtk-rs/gtk-rs-core" 15 | 16 | [dependencies.gio] 17 | package = "gio-sys" 18 | git = "https://github.com/gtk-rs/gtk-rs-core" 19 | 20 | [dependencies.glib] 21 | package = "glib-sys" 22 | git = "https://github.com/gtk-rs/gtk-rs-core" 23 | 24 | [dependencies.gobject] 25 | package = "gobject-sys" 26 | git = "https://github.com/gtk-rs/gtk-rs-core" 27 | 28 | [dependencies.pango] 29 | package = "pango-sys" 30 | git = "https://github.com/gtk-rs/gtk-rs-core" 31 | 32 | [dev-dependencies] 33 | shell-words = "1.0.0" 34 | tempfile = "3" 35 | 36 | [features] 37 | v3_24 = [] 38 | 39 | [lib] 40 | name = "gdk_sys" 41 | 42 | [package] 43 | authors = ["The gtk-rs Project Developers"] 44 | build = "build.rs" 45 | description = "FFI bindings to libgdk-3" 46 | homepage = "https://gtk-rs.org/" 47 | keywords = ["gdk", "ffi", "gtk-rs", "gnome"] 48 | license = "MIT" 49 | links = "gdk-3" 50 | name = "gdk-sys" 51 | repository = "https://github.com/gtk-rs/gtk3-rs" 52 | version = "0.19.0" 53 | edition = "2021" 54 | rust-version = "1.70" 55 | 56 | [package.metadata.docs.rs] 57 | rustdoc-args = ["--cfg", "docsrs"] 58 | features = [] 59 | rustc-args = ["--cfg", "docsrs"] 60 | 61 | [package.metadata.system-deps.gdk_3_0] 62 | name = "gdk-3.0" 63 | version = "3.22" 64 | 65 | [package.metadata.system-deps.gdk_3_0.v3_24] 66 | version = "3.24" 67 | -------------------------------------------------------------------------------- /examples/clone_macro/main.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | use std::rc::Rc; 3 | 4 | use gtk::glib; 5 | use gtk::{prelude::*, Application, ApplicationWindow, Button}; 6 | 7 | #[derive(Default)] 8 | struct State { 9 | started: bool, 10 | count: i32, 11 | } 12 | 13 | impl State { 14 | fn new() -> Self { 15 | Self { 16 | started: false, 17 | count: 0, 18 | } 19 | } 20 | } 21 | 22 | fn main() { 23 | let application = 24 | Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default()); 25 | 26 | let state = Rc::new(RefCell::new(State::new())); 27 | 28 | { 29 | let state2 = Rc::new(RefCell::new(State::new())); 30 | 31 | application.connect_activate(glib::clone!(@weak state, @strong state2 => move |app| { 32 | state.borrow_mut().started = true; 33 | 34 | let window = ApplicationWindow::new(app); 35 | window.set_title("First GTK+ Program"); 36 | window.set_default_size(350, 70); 37 | 38 | let button = Button::with_label("Click me!"); 39 | button.connect_clicked(glib::clone!(@weak state, @weak state2 => move |_| { 40 | let mut state = state.borrow_mut(); 41 | let mut state2 = state2.borrow_mut(); 42 | println!("Clicked (started: {}): {} - {}!", state.started, state.count, state2.count); 43 | state.count += 1; 44 | state2.count += 1; 45 | })); 46 | window.add(&button); 47 | 48 | window.show_all(); 49 | })); 50 | } 51 | 52 | application.run(); 53 | } 54 | --------------------------------------------------------------------------------