├── .gitignore ├── LICENSE ├── README.md ├── gtk3 ├── build.gradle.kts ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── linuxX64Main │ └── kotlin │ │ ├── GtkDsl.kt │ │ ├── gtk3 │ │ ├── AboutDialog.kt │ │ ├── AccelLabel.kt │ │ ├── ActionBar.kt │ │ ├── Adjustment.kt │ │ ├── AppChooserButton.kt │ │ ├── AppChooserDialog.kt │ │ ├── AppChooserWidget.kt │ │ ├── ApplicationWindow.kt │ │ ├── AspectFrame.kt │ │ ├── Assistant.kt │ │ ├── Bin.kt │ │ ├── Box.kt │ │ ├── Button.kt │ │ ├── ButtonBox.kt │ │ ├── Calendar.kt │ │ ├── CellView.kt │ │ ├── CheckButton.kt │ │ ├── CheckMenuItem.kt │ │ ├── ColorButton.kt │ │ ├── ColorChooserDialog.kt │ │ ├── ColorChooserWidget.kt │ │ ├── ComboBox.kt │ │ ├── ComboBoxText.kt │ │ ├── Container.kt │ │ ├── Dialog.kt │ │ ├── DrawingArea.kt │ │ ├── Entry.kt │ │ ├── EventBox.kt │ │ ├── Expander.kt │ │ ├── FileChooserButton.kt │ │ ├── FileChooserDialog.kt │ │ ├── FileChooserWidget.kt │ │ ├── FileFilter.kt │ │ ├── Fixed.kt │ │ ├── FlowBox.kt │ │ ├── FlowBoxChild.kt │ │ ├── FontButton.kt │ │ ├── FontChooserDialog.kt │ │ ├── FontChooserWidget.kt │ │ ├── Frame.kt │ │ ├── GLArea.kt │ │ ├── Grid.kt │ │ ├── HeaderBar.kt │ │ ├── IconView.kt │ │ ├── Image.kt │ │ ├── InfoBar.kt │ │ ├── Invisible.kt │ │ ├── Label.kt │ │ ├── Layout.kt │ │ ├── LevelBar.kt │ │ ├── LinkButton.kt │ │ ├── ListBox.kt │ │ ├── ListBoxRow.kt │ │ ├── LockButton.kt │ │ ├── Menu.kt │ │ ├── MenuBar.kt │ │ ├── MenuButton.kt │ │ ├── MenuItem.kt │ │ ├── MenuShell.kt │ │ ├── MenuToolButton.kt │ │ ├── MessageDialog.kt │ │ ├── Misc.kt │ │ ├── ModelButton.kt │ │ ├── Notebook.kt │ │ ├── OffscreenWindow.kt │ │ ├── Overlay.kt │ │ ├── Paned.kt │ │ ├── PlacesSidebar.kt │ │ ├── ProgressBar.kt │ │ ├── RadioButton.kt │ │ ├── RadioMenuItem.kt │ │ ├── RadioToolButton.kt │ │ ├── Range.kt │ │ ├── RecentChooserDialog.kt │ │ ├── RecentChooserMenu.kt │ │ ├── RecentChooserWidget.kt │ │ ├── RecentFilter.kt │ │ ├── Revealer.kt │ │ ├── Scale.kt │ │ ├── ScaleButton.kt │ │ ├── Scrollbar.kt │ │ ├── ScrolledWindow.kt │ │ ├── SearchBar.kt │ │ ├── SearchEntry.kt │ │ ├── Separator.kt │ │ ├── SeparatorMenuItem.kt │ │ ├── SeparatorToolItem.kt │ │ ├── ShortcutLabel.kt │ │ ├── ShortcutsGroup.kt │ │ ├── ShortcutsSection.kt │ │ ├── ShortcutsShortcut.kt │ │ ├── ShortcutsWindow.kt │ │ ├── SpinButton.kt │ │ ├── Spinner.kt │ │ ├── Stack.kt │ │ ├── StackSidebar.kt │ │ ├── StackSwitcher.kt │ │ ├── Statusbar.kt │ │ ├── Switch.kt │ │ ├── TextView.kt │ │ ├── ToggleButton.kt │ │ ├── ToggleToolButton.kt │ │ ├── ToolButton.kt │ │ ├── ToolItem.kt │ │ ├── ToolItemGroup.kt │ │ ├── ToolPalette.kt │ │ ├── Toolbar.kt │ │ ├── TreeView.kt │ │ ├── TreeViewColumn.kt │ │ ├── Viewport.kt │ │ ├── Widget.kt │ │ └── Window.kt │ │ ├── helpers.kt │ │ └── signals.kt │ └── nativeInterop │ └── cinterop │ └── gtk3.def ├── kngtk-generator ├── build.gradle.kts ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── src │ ├── main │ │ └── kotlin │ │ │ ├── generator.kt │ │ │ ├── helpers.kt │ │ │ ├── kotlinpoetdsl.kt │ │ │ ├── main.kt │ │ │ └── types.kt │ └── test │ │ └── kotlin │ │ └── GeneratorTest.kt └── testData │ └── generator │ ├── enumparam.gir │ ├── enumparam.kt │ ├── properties.gir │ └── properties.kt └── sample ├── .gitignore ├── CMakeLists.txt ├── KotlinCMakeModule ├── CMakeDetermineKotlinCompiler.cmake ├── CMakeKotlinCompiler.cmake.in ├── CMakeKotlinInformation.cmake ├── CMakeTestKotlinCompiler.cmake └── version ├── README.md ├── build.gradle └── src └── main ├── c_interop └── libgtk3.def └── kotlin ├── Application.kt ├── Dsl.kt ├── Signal.kt ├── TreeModel.kt ├── fileManager.kt ├── files.kt ├── gtk3 ├── AboutDialog.kt ├── AccelLabel.kt ├── ActionBar.kt ├── Adjustment.kt ├── AppChooserButton.kt ├── AppChooserDialog.kt ├── AppChooserWidget.kt ├── ApplicationWindow.kt ├── AspectFrame.kt ├── Assistant.kt ├── Bin.kt ├── Box.kt ├── Button.kt ├── ButtonBox.kt ├── Calendar.kt ├── CellView.kt ├── CheckButton.kt ├── CheckMenuItem.kt ├── ColorButton.kt ├── ColorChooserDialog.kt ├── ColorChooserWidget.kt ├── ComboBox.kt ├── ComboBoxText.kt ├── Container.kt ├── Dialog.kt ├── DrawingArea.kt ├── Entry.kt ├── EventBox.kt ├── Expander.kt ├── FileChooserButton.kt ├── FileChooserDialog.kt ├── FileChooserWidget.kt ├── FileFilter.kt ├── Fixed.kt ├── FlowBox.kt ├── FlowBoxChild.kt ├── FontButton.kt ├── FontChooserDialog.kt ├── FontChooserWidget.kt ├── Frame.kt ├── GLArea.kt ├── Grid.kt ├── HeaderBar.kt ├── IconView.kt ├── Image.kt ├── InfoBar.kt ├── Invisible.kt ├── Label.kt ├── Layout.kt ├── LevelBar.kt ├── LinkButton.kt ├── ListBox.kt ├── ListBoxRow.kt ├── LockButton.kt ├── Menu.kt ├── MenuBar.kt ├── MenuButton.kt ├── MenuItem.kt ├── MenuShell.kt ├── MenuToolButton.kt ├── MessageDialog.kt ├── Misc.kt ├── ModelButton.kt ├── Notebook.kt ├── OffscreenWindow.kt ├── Overlay.kt ├── Paned.kt ├── PlacesSidebar.kt ├── ProgressBar.kt ├── RadioButton.kt ├── RadioMenuItem.kt ├── RadioToolButton.kt ├── Range.kt ├── RecentChooserDialog.kt ├── RecentChooserMenu.kt ├── RecentChooserWidget.kt ├── RecentFilter.kt ├── Revealer.kt ├── Scale.kt ├── ScaleButton.kt ├── Scrollbar.kt ├── ScrolledWindow.kt ├── SearchBar.kt ├── SearchEntry.kt ├── Separator.kt ├── SeparatorMenuItem.kt ├── SeparatorToolItem.kt ├── ShortcutLabel.kt ├── ShortcutsGroup.kt ├── ShortcutsSection.kt ├── ShortcutsShortcut.kt ├── ShortcutsWindow.kt ├── SpinButton.kt ├── Spinner.kt ├── Stack.kt ├── StackSidebar.kt ├── StackSwitcher.kt ├── Statusbar.kt ├── Switch.kt ├── TextView.kt ├── ToggleButton.kt ├── ToggleToolButton.kt ├── ToolButton.kt ├── ToolItem.kt ├── ToolItemGroup.kt ├── ToolPalette.kt ├── Toolbar.kt ├── TreeView.kt ├── TreeViewColumn.kt ├── Viewport.kt ├── Widget.kt └── Window.kt ├── helpers.kt └── main.kt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .gradle 3 | build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The project is not maintained, please see https://gitlab.com/gtk-kn/gtk-kn for an alternative. 2 | 3 | # kotlin-native-gtk 4 | 5 | GTK+ bindings for Kotlin Native 6 | 7 | See https://victor.kropp.name/blog/kotlin-native-0.2-and-gtk/ for details 8 | -------------------------------------------------------------------------------- /gtk3/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("multiplatform") version "1.3.21" 3 | } 4 | 5 | group = "com.github.kropp" 6 | version = "0.1" 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | kotlin { 13 | linuxX64 { 14 | compilations.getByName("main") { 15 | val gtk3 by cinterops.creating {} 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gtk3/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /gtk3/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kropp/kotlin-native-gtk/4f9b2ffd4b71c69a077f4689719b56fe18f7b1d9/gtk3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gtk3/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gtk3/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /gtk3/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gtk3' 2 | 3 | enableFeaturePreview("GRADLE_METADATA") 4 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/GtkDsl.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | @DslMarker 4 | annotation class GtkDsl 5 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ActionBar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkActionBar 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_action_bar_get_center_widget 9 | import libgtk3.gtk_action_bar_new 10 | import libgtk3.gtk_action_bar_pack_end 11 | import libgtk3.gtk_action_bar_pack_start 12 | import libgtk3.gtk_action_bar_set_center_widget 13 | 14 | inline fun Container.actionBar(init: ActionBar.() -> Unit = {}): ActionBar = 15 | ActionBar().apply { init(); this@actionBar.add(this) } 16 | 17 | /** 18 | * GtkActionBar is designed to present contextual actions. It is 19 | * expected to be displayed below the content and expand horizontally 20 | * to fill the area. 21 | * 22 | * It allows placing children at the start or the end. In addition, it 23 | * contains an internal centered box which is centered with respect to 24 | * the full width of the box, even if the children at either side take 25 | * up different amounts of space. 26 | * 27 | * # CSS nodes 28 | * 29 | * GtkActionBar has a single CSS node with name actionbar. 30 | */ 31 | @GtkDsl 32 | open class ActionBar internal constructor(override val widgetPtr: CPointer? = null) : 33 | Bin() { 34 | private val self: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | val actionBar: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | /** 41 | * Retrieves the center bar widget of the bar. 42 | * 43 | * Sets the center widget for the #GtkActionBar. */ 44 | var centerWidget: CPointer 45 | get() = gtk_action_bar_get_center_widget(self)!!.reinterpret() 46 | set(value) { 47 | gtk_action_bar_set_center_widget(self, value?.reinterpret()) 48 | } 49 | 50 | /** 51 | * Creates a new #GtkActionBar widget. */ 52 | constructor() : this(gtk_action_bar_new()?.reinterpret()) 53 | 54 | /** 55 | * Adds @child to @action_bar, packed with reference to the 56 | * end of the @action_bar. 57 | */ 58 | fun packEnd(child: CPointer): Unit = gtk_action_bar_pack_end(self, child) 59 | 60 | /** 61 | * Adds @child to @action_bar, packed with reference to the 62 | * end of the @action_bar. 63 | */ 64 | fun packEnd(child: Widget): Unit = gtk_action_bar_pack_end(self, child.widgetPtr?.reinterpret()) 65 | 66 | /** 67 | * Adds @child to @action_bar, packed with reference to the 68 | * start of the @action_bar. 69 | */ 70 | fun packStart(child: CPointer): Unit = gtk_action_bar_pack_start(self, child) 71 | 72 | /** 73 | * Adds @child to @action_bar, packed with reference to the 74 | * start of the @action_bar. 75 | */ 76 | fun packStart(child: Widget): Unit = gtk_action_bar_pack_start(self, 77 | child.widgetPtr?.reinterpret()) 78 | } 79 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/AppChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import kotlinx.cinterop.toKString 8 | import libgtk3.GFile 9 | import libgtk3.GtkAppChooserDialog 10 | import libgtk3.GtkDialogFlags 11 | import libgtk3.GtkWidget 12 | import libgtk3.GtkWindow 13 | import libgtk3.gtk_app_chooser_dialog_get_heading 14 | import libgtk3.gtk_app_chooser_dialog_get_widget 15 | import libgtk3.gtk_app_chooser_dialog_new 16 | import libgtk3.gtk_app_chooser_dialog_set_heading 17 | 18 | inline fun Container.appChooserDialog( 19 | parent: CPointer, 20 | flags: GtkDialogFlags, 21 | file: CPointer, 22 | init: AppChooserDialog.() -> Unit = {} 23 | ): AppChooserDialog = AppChooserDialog(parent, flags, file).apply { init(); 24 | this@appChooserDialog.add(this) } 25 | 26 | /** 27 | * #GtkAppChooserDialog shows a #GtkAppChooserWidget inside a #GtkDialog. 28 | * 29 | * Note that #GtkAppChooserDialog does not have any interesting methods 30 | * of its own. Instead, you should get the embedded #GtkAppChooserWidget 31 | * using gtk_app_chooser_dialog_get_widget() and call its methods if 32 | * the generic #GtkAppChooser interface is not sufficient for your needs. 33 | * 34 | * To set the heading that is shown above the #GtkAppChooserWidget, 35 | * use gtk_app_chooser_dialog_set_heading().Returns the #GtkAppChooserWidget of this dialog. 36 | */ 37 | @GtkDsl 38 | open class AppChooserDialog internal constructor(override val widgetPtr: CPointer? = 39 | null) : Dialog() { 40 | private val self: CPointer? 41 | get() = widgetPtr!!.reinterpret() 42 | 43 | val appChooserDialog: CPointer? 44 | get() = widgetPtr!!.reinterpret() 45 | 46 | /** 47 | * Returns the text to display at the top of the dialog. 48 | * 49 | * Sets the text to display at the top of the dialog. 50 | * If the heading is not set, the dialog displays a default text. */ 51 | var heading: String 52 | get() = gtk_app_chooser_dialog_get_heading(self)?.toKString() ?: "" 53 | set(value) { 54 | gtk_app_chooser_dialog_set_heading(self, value) 55 | } 56 | 57 | val widget: CPointer 58 | get() = gtk_app_chooser_dialog_get_widget(self)!!.reinterpret() 59 | 60 | /** 61 | * Creates a new #GtkAppChooserDialog for the provided #GFile, 62 | * to allow the user to select an application for it. */ 63 | constructor( 64 | parent: CPointer, 65 | flags: GtkDialogFlags, 66 | file: CPointer 67 | ) : this(gtk_app_chooser_dialog_new(parent?.reinterpret(), flags, 68 | file?.reinterpret())?.reinterpret()) 69 | } 70 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/AspectFrame.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Float 5 | import kotlin.String 6 | import kotlin.Unit 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.reinterpret 9 | import libgtk3.GtkAspectFrame 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_aspect_frame_new 12 | import libgtk3.gtk_aspect_frame_set 13 | import libgtk3.gtk_false 14 | import libgtk3.gtk_true 15 | 16 | inline fun Container.aspectFrame( 17 | label: String, 18 | xalign: Float, 19 | yalign: Float, 20 | ratio: Float, 21 | obey_child: Boolean, 22 | init: AspectFrame.() -> Unit = {} 23 | ): AspectFrame = AspectFrame(label, xalign, yalign, ratio, obey_child).apply { init(); 24 | this@aspectFrame.add(this) } 25 | 26 | /** 27 | * The #GtkAspectFrame is useful when you want 28 | * pack a widget so that it can resize but always retains 29 | * the same aspect ratio. For instance, one might be 30 | * drawing a small preview of a larger image. #GtkAspectFrame 31 | * derives from #GtkFrame, so it can draw a label and 32 | * a frame around the child. The frame will be 33 | * “shrink-wrapped” to the size of the child. 34 | * 35 | * # CSS nodes 36 | * 37 | * GtkAspectFrame uses a CSS node with name frame. 38 | */ 39 | @GtkDsl 40 | open class AspectFrame internal constructor(override val widgetPtr: CPointer? = null) : 41 | Frame() { 42 | private val self: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | val aspectFrame: CPointer? 46 | get() = widgetPtr!!.reinterpret() 47 | 48 | /** 49 | * Create a new #GtkAspectFrame. */ 50 | constructor( 51 | label: String, 52 | xalign: Float, 53 | yalign: Float, 54 | ratio: Float, 55 | obey_child: Boolean 56 | ) : this(gtk_aspect_frame_new(label, xalign, yalign, ratio, 57 | if (obey_child) gtk_true() else gtk_false())?.reinterpret()) 58 | 59 | /** 60 | * Set parameters for an existing #GtkAspectFrame. 61 | */ 62 | fun set( 63 | xalign: Float, 64 | yalign: Float, 65 | ratio: Float, 66 | obey_child: Boolean 67 | ): Unit = gtk_aspect_frame_set(self, xalign, yalign, ratio, 68 | if (obey_child) gtk_true() else gtk_false()) 69 | } 70 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Bin.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkBin 6 | import libgtk3.GtkWidget 7 | import libgtk3.gtk_bin_get_child 8 | 9 | /** 10 | * The #GtkBin widget is a container with just one child. 11 | * It is not very useful itself, but it is useful for deriving subclasses, 12 | * since it provides common code needed for handling a single child widget. 13 | * 14 | * Many GTK+ widgets are subclasses of #GtkBin, including #GtkWindow, 15 | * #GtkButton, #GtkFrame, #GtkHandleBox or #GtkScrolledWindow.Gets the child of the #GtkBin, or 16 | %NULL if the bin contains 17 | * no child widget. The returned widget does not have a reference 18 | * added, so you do not need to unref it. */ 19 | @GtkDsl 20 | abstract class Bin : Container() { 21 | private val self: CPointer 22 | get() = widgetPtr!!.reinterpret() 23 | 24 | val child: CPointer 25 | get() = gtk_bin_get_child(self)!!.reinterpret() 26 | } 27 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/CheckButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkCheckButton 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_check_button_new 9 | 10 | inline fun Container.checkButton(init: CheckButton.() -> Unit = {}): CheckButton = 11 | CheckButton().apply { init(); this@checkButton.add(this) } 12 | 13 | /** 14 | * A #GtkCheckButton places a discrete #GtkToggleButton next to a widget, 15 | * (usually a #GtkLabel). See the section on #GtkToggleButton widgets for 16 | * more information about toggle/check buttons. 17 | * 18 | * The important signal ( #GtkToggleButton::toggled ) is also inherited from 19 | * #GtkToggleButton. 20 | * 21 | * # CSS nodes 22 | * 23 | * |[ 24 | * checkbutton 25 | * ├── check 26 | * ╰── 27 | * ]| 28 | * 29 | * A GtkCheckButton with indicator (see gtk_toggle_button_set_mode()) has a 30 | * main CSS node with name checkbutton and a subnode with name check. 31 | * 32 | * |[ 33 | * button.check 34 | * ├── check 35 | * ╰── 36 | * ]| 37 | * 38 | * A GtkCheckButton without indicator changes the name of its main node 39 | * to button and adds a .check style class to it. The subnode is invisible 40 | * in this case. 41 | */ 42 | @GtkDsl 43 | open class CheckButton internal constructor(override val widgetPtr: CPointer? = null) : 44 | ToggleButton() { 45 | private val self: CPointer? 46 | get() = widgetPtr!!.reinterpret() 47 | 48 | val checkButton: CPointer? 49 | get() = widgetPtr!!.reinterpret() 50 | 51 | /** 52 | * Creates a new #GtkCheckButton. */ 53 | constructor() : this(gtk_check_button_new()?.reinterpret()) 54 | } 55 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ColorButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointed 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import kotlinx.cinterop.toKString 13 | import libgtk3.GtkColorButton 14 | import libgtk3.GtkWidget 15 | import libgtk3.gtk_color_button_get_title 16 | import libgtk3.gtk_color_button_new 17 | import libgtk3.gtk_color_button_set_title 18 | 19 | inline fun Container.colorButton(init: ColorButton.() -> Unit = {}): ColorButton = 20 | ColorButton().apply { init(); this@colorButton.add(this) } 21 | 22 | private fun ColorButton_onColorSet_Handler(sender: CPointer?, _data: COpaquePointer?) { 23 | _data?.asStableRef()?.get()?.onColorSet?.emit() 24 | } 25 | 26 | /** 27 | * The #GtkColorButton is a button which displays the currently selected 28 | * color and allows to open a color selection dialog to change the color. 29 | * It is suitable widget for selecting a color in a preference dialog. 30 | * 31 | * # CSS nodes 32 | * 33 | * GtkColorButton has a single CSS node with name button. To differentiate 34 | * it from a plain #GtkButton, it gets the .color style class. 35 | */ 36 | @GtkDsl 37 | open class ColorButton internal constructor(override val widgetPtr: CPointer? = null) : 38 | Button() { 39 | private val self: CPointer? 40 | get() = widgetPtr!!.reinterpret() 41 | 42 | val colorButton: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | val onColorSet: Signal?, COpaquePointer?) -> 46 | Unit>> by lazy { Signal?, 47 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "color-set", 48 | staticCFunction(::ColorButton_onColorSet_Handler)) } 49 | 50 | /** 51 | * Gets the title of the color selection dialog. 52 | * 53 | * Sets the title for the color selection dialog. */ 54 | var title: String 55 | get() = gtk_color_button_get_title(self)?.toKString() ?: "" 56 | set(value) { 57 | gtk_color_button_set_title(self, value) 58 | } 59 | 60 | /** 61 | * Creates a new color button. 62 | * 63 | * This returns a widget in the form of a small button containing 64 | * a swatch representing the current selected color. When the button 65 | * is clicked, a color-selection dialog will open, allowing the user 66 | * to select a color. The swatch will be updated to reflect the new 67 | * color when the user finishes. */ 68 | constructor() : this(gtk_color_button_new()?.reinterpret()) 69 | } 70 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ColorChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkColorChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_color_chooser_dialog_new 11 | 12 | inline fun Container.colorChooserDialog( 13 | title: String, 14 | parent: CPointer, 15 | init: ColorChooserDialog.() -> Unit = {} 16 | ): ColorChooserDialog = ColorChooserDialog(title, parent).apply { init(); 17 | this@colorChooserDialog.add(this) } 18 | 19 | /** 20 | * The #GtkColorChooserDialog widget is a dialog for choosing 21 | * a color. It implements the #GtkColorChooser interface. 22 | */ 23 | @GtkDsl 24 | open class ColorChooserDialog internal constructor(override val widgetPtr: CPointer? = 25 | null) : Dialog() { 26 | private val self: CPointer? 27 | get() = widgetPtr!!.reinterpret() 28 | 29 | val colorChooserDialog: CPointer? 30 | get() = widgetPtr!!.reinterpret() 31 | 32 | /** 33 | * Creates a new #GtkColorChooserDialog. */ 34 | constructor(title: String, parent: CPointer) : 35 | this(gtk_color_chooser_dialog_new(title, parent?.reinterpret())?.reinterpret()) 36 | } 37 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ColorChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkColorChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_color_chooser_widget_new 9 | 10 | inline fun Container.colorChooserWidget(init: ColorChooserWidget.() -> Unit = {}): 11 | ColorChooserWidget = ColorChooserWidget().apply { init(); this@colorChooserWidget.add(this) 12 | } 13 | 14 | /** 15 | * The #GtkColorChooserWidget widget lets the user select a 16 | * color. By default, the chooser presents a predefined palette 17 | * of colors, plus a small number of settable custom colors. 18 | * It is also possible to select a different color with the 19 | * single-color editor. To enter the single-color editing mode, 20 | * use the context menu of any color of the palette, or use the 21 | * '+' button to add a new custom color. 22 | * 23 | * The chooser automatically remembers the last selection, as well 24 | * as custom colors. 25 | * 26 | * To change the initially selected color, use gtk_color_chooser_set_rgba(). 27 | * To get the selected color use gtk_color_chooser_get_rgba(). 28 | * 29 | * The #GtkColorChooserWidget is used in the #GtkColorChooserDialog 30 | * to provide a dialog for selecting colors. 31 | * 32 | * # CSS names 33 | * 34 | * GtkColorChooserWidget has a single CSS node with name colorchooser. 35 | */ 36 | @GtkDsl 37 | open class ColorChooserWidget internal constructor(override val widgetPtr: CPointer? = 38 | null) : Box() { 39 | private val self: CPointer? 40 | get() = widgetPtr!!.reinterpret() 41 | 42 | val colorChooserWidget: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | /** 46 | * Creates a new #GtkColorChooserWidget. */ 47 | constructor() : this(gtk_color_chooser_widget_new()?.reinterpret()) 48 | } 49 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/FlowBoxChild.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Int 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CFunction 7 | import kotlinx.cinterop.COpaquePointer 8 | import kotlinx.cinterop.CPointed 9 | import kotlinx.cinterop.CPointer 10 | import kotlinx.cinterop.asStableRef 11 | import kotlinx.cinterop.reinterpret 12 | import kotlinx.cinterop.staticCFunction 13 | import libgtk3.GtkFlowBoxChild 14 | import libgtk3.GtkWidget 15 | import libgtk3.gtk_flow_box_child_changed 16 | import libgtk3.gtk_flow_box_child_get_index 17 | import libgtk3.gtk_flow_box_child_is_selected 18 | import libgtk3.gtk_flow_box_child_new 19 | 20 | inline fun Container.flowBoxChild(init: FlowBoxChild.() -> Unit = {}): FlowBoxChild = 21 | FlowBoxChild().apply { init(); this@flowBoxChild.add(this) } 22 | 23 | private fun FlowBoxChild_onActivate_Handler(sender: CPointer?, _data: COpaquePointer?) 24 | { 25 | _data?.asStableRef()?.get()?.onActivate?.emit() 26 | } 27 | 28 | /** 29 | * Gets the current index of the @child in its #GtkFlowBox container. 30 | */ 31 | @GtkDsl 32 | open class FlowBoxChild internal constructor(override val widgetPtr: CPointer? = null) : 33 | Bin() { 34 | private val self: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | val flowBoxChild: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | val onActivate: Signal?, COpaquePointer?) -> 41 | Unit>> by lazy { Signal?, 42 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "activate", 43 | staticCFunction(::FlowBoxChild_onActivate_Handler)) } 44 | 45 | val index: Int 46 | get() = gtk_flow_box_child_get_index(self) 47 | 48 | /** 49 | * Creates a new #GtkFlowBoxChild, to be used as a child 50 | * of a #GtkFlowBox. */ 51 | constructor() : this(gtk_flow_box_child_new()?.reinterpret()) 52 | 53 | /** 54 | * Marks @child as changed, causing any state that depends on this 55 | * to be updated. This affects sorting and filtering. 56 | * 57 | * Note that calls to this method must be in sync with the data 58 | * used for the sorting and filtering functions. For instance, if 59 | * the list is mirroring some external data set, and *two* children 60 | * changed in the external data set when you call 61 | * gtk_flow_box_child_changed() on the first child, the sort function 62 | * must only read the new data for the first of the two changed 63 | * children, otherwise the resorting of the children will be wrong. 64 | * 65 | * This generally means that if you don’t fully control the data 66 | * model, you have to duplicate the data that affects the sorting 67 | * and filtering functions into the widgets themselves. Another 68 | * alternative is to call gtk_flow_box_invalidate_sort() on any 69 | * model change, but that is more expensive. 70 | */ 71 | fun changed(): Unit = gtk_flow_box_child_changed(self) 72 | 73 | /** 74 | * Returns whether the @child is currently selected in its 75 | * #GtkFlowBox container. 76 | */ 77 | fun isSelected(): Boolean = gtk_flow_box_child_is_selected(self) != 0 78 | } 79 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/FontChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkFontChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_font_chooser_dialog_new 11 | 12 | inline fun Container.fontChooserDialog( 13 | title: String, 14 | parent: CPointer, 15 | init: FontChooserDialog.() -> Unit = {} 16 | ): FontChooserDialog = FontChooserDialog(title, parent).apply { init(); 17 | this@fontChooserDialog.add(this) } 18 | 19 | /** 20 | * The #GtkFontChooserDialog widget is a dialog for selecting a font. 21 | * It implements the #GtkFontChooser interface. 22 | * 23 | * # GtkFontChooserDialog as GtkBuildable 24 | * 25 | * The GtkFontChooserDialog implementation of the #GtkBuildable 26 | * interface exposes the buttons with the names “select_button” 27 | * and “cancel_button”. 28 | */ 29 | @GtkDsl 30 | open class FontChooserDialog internal constructor(override val widgetPtr: CPointer? = 31 | null) : Dialog() { 32 | private val self: CPointer? 33 | get() = widgetPtr!!.reinterpret() 34 | 35 | val fontChooserDialog: CPointer? 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | /** 39 | * Creates a new #GtkFontChooserDialog. */ 40 | constructor(title: String, parent: CPointer) : 41 | this(gtk_font_chooser_dialog_new(title, parent?.reinterpret())?.reinterpret()) 42 | } 43 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/FontChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkFontChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_font_chooser_widget_new 9 | 10 | inline fun Container.fontChooserWidget(init: FontChooserWidget.() -> Unit = {}): FontChooserWidget = 11 | FontChooserWidget().apply { init(); this@fontChooserWidget.add(this) } 12 | 13 | /** 14 | * The #GtkFontChooserWidget widget lists the available fonts, 15 | * styles and sizes, allowing the user to select a font. It is 16 | * used in the #GtkFontChooserDialog widget to provide a 17 | * dialog box for selecting fonts. 18 | * 19 | * To set the font which is initially selected, use 20 | * gtk_font_chooser_set_font() or gtk_font_chooser_set_font_desc(). 21 | * 22 | * To get the selected font use gtk_font_chooser_get_font() or 23 | * gtk_font_chooser_get_font_desc(). 24 | * 25 | * To change the text which is shown in the preview area, use 26 | * gtk_font_chooser_set_preview_text(). 27 | * 28 | * # CSS nodes 29 | * 30 | * GtkFontChooserWidget has a single CSS node with name fontchooser. 31 | */ 32 | @GtkDsl 33 | open class FontChooserWidget internal constructor(override val widgetPtr: CPointer? = 34 | null) : Box() { 35 | private val self: CPointer? 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | val fontChooserWidget: CPointer? 39 | get() = widgetPtr!!.reinterpret() 40 | 41 | /** 42 | * Creates a new #GtkFontChooserWidget. */ 43 | constructor() : this(gtk_font_chooser_widget_new()?.reinterpret()) 44 | } 45 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Invisible.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkInvisible 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_invisible_new 9 | 10 | inline fun Container.invisible(init: Invisible.() -> Unit = {}): Invisible = 11 | Invisible().apply { init(); this@invisible.add(this) } 12 | 13 | /** 14 | * The #GtkInvisible widget is used internally in GTK+, and is probably not 15 | * very useful for application developers. 16 | * 17 | * It is used for reliable pointer grabs and selection handling in the code 18 | * for drag-and-drop. 19 | */ 20 | @GtkDsl 21 | open class Invisible internal constructor(override val widgetPtr: CPointer? = null) : 22 | Widget() { 23 | private val self: CPointer? 24 | get() = widgetPtr!!.reinterpret() 25 | 26 | val invisible: CPointer? 27 | get() = widgetPtr!!.reinterpret() 28 | 29 | /** 30 | * Creates a new #GtkInvisible. */ 31 | constructor() : this(gtk_invisible_new()?.reinterpret()) 32 | } 33 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Layout.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Int 4 | import kotlin.UInt 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CPointer 7 | import kotlinx.cinterop.reinterpret 8 | import libgtk3.GdkWindow 9 | import libgtk3.GtkAdjustment 10 | import libgtk3.GtkLayout 11 | import libgtk3.GtkWidget 12 | import libgtk3.gtk_layout_get_bin_window 13 | import libgtk3.gtk_layout_move 14 | import libgtk3.gtk_layout_new 15 | import libgtk3.gtk_layout_put 16 | import libgtk3.gtk_layout_set_size 17 | 18 | inline fun Container.layout( 19 | hadjustment: CPointer, 20 | vadjustment: CPointer, 21 | init: Layout.() -> Unit = {} 22 | ): Layout = Layout(hadjustment, vadjustment).apply { init(); this@layout.add(this) } 23 | 24 | /** 25 | * #GtkLayout is similar to #GtkDrawingArea in that it’s a “blank slate” and 26 | * doesn’t do anything except paint a blank background by default. It’s 27 | * different in that it supports scrolling natively due to implementing 28 | * #GtkScrollable, and can contain child widgets since it’s a #GtkContainer. 29 | * 30 | * If you just want to draw, a #GtkDrawingArea is a better choice since it has 31 | * lower overhead. If you just need to position child widgets at specific 32 | * points, then #GtkFixed provides that functionality on its own. 33 | * 34 | * When handling expose events on a #GtkLayout, you must draw to the #GdkWindow 35 | * returned by gtk_layout_get_bin_window(), rather than to the one returned by 36 | * gtk_widget_get_window() as you would for a #GtkDrawingArea.Retrieve the bin window of the layout 37 | used for drawing operations. 38 | */ 39 | @GtkDsl 40 | open class Layout internal constructor(override val widgetPtr: CPointer? = null) : 41 | Container() { 42 | private val self: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | val layout: CPointer? 46 | get() = widgetPtr!!.reinterpret() 47 | 48 | val binWindow: CPointer 49 | get() = gtk_layout_get_bin_window(self)!!.reinterpret() 50 | 51 | /** 52 | * Creates a new #GtkLayout. Unless you have a specific adjustment 53 | * you’d like the layout to use for scrolling, pass %NULL for 54 | * @hadjustment and @vadjustment. */ 55 | constructor(hadjustment: CPointer, vadjustment: CPointer) : 56 | this(gtk_layout_new(hadjustment?.reinterpret(), 57 | vadjustment?.reinterpret())?.reinterpret()) 58 | 59 | /** 60 | * Moves a current child of @layout to a new position. 61 | */ 62 | fun move( 63 | child_widget: CPointer, 64 | x: Int, 65 | y: Int 66 | ): Unit = gtk_layout_move(self, child_widget, x, y) 67 | 68 | /** 69 | * Moves a current child of @layout to a new position. 70 | */ 71 | fun move( 72 | child_widget: Widget, 73 | x: Int, 74 | y: Int 75 | ): Unit = gtk_layout_move(self, child_widget.widgetPtr?.reinterpret(), x, y) 76 | 77 | /** 78 | * Adds @child_widget to @layout, at position (@x,@y). 79 | * @layout becomes the new parent container of @child_widget. 80 | */ 81 | fun put( 82 | child_widget: CPointer, 83 | x: Int, 84 | y: Int 85 | ): Unit = gtk_layout_put(self, child_widget, x, y) 86 | 87 | /** 88 | * Adds @child_widget to @layout, at position (@x,@y). 89 | * @layout becomes the new parent container of @child_widget. 90 | */ 91 | fun put( 92 | child_widget: Widget, 93 | x: Int, 94 | y: Int 95 | ): Unit = gtk_layout_put(self, child_widget.widgetPtr?.reinterpret(), x, y) 96 | 97 | /** 98 | * Sets the size of the scrollable area of the layout. 99 | */ 100 | fun setSize(width: UInt, height: UInt): Unit = gtk_layout_set_size(self, width, height) 101 | } 102 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/LinkButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.String 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CFunction 7 | import kotlinx.cinterop.COpaquePointer 8 | import kotlinx.cinterop.CPointed 9 | import kotlinx.cinterop.CPointer 10 | import kotlinx.cinterop.asStableRef 11 | import kotlinx.cinterop.reinterpret 12 | import kotlinx.cinterop.staticCFunction 13 | import kotlinx.cinterop.toKString 14 | import libgtk3.GtkLinkButton 15 | import libgtk3.GtkWidget 16 | import libgtk3.gtk_false 17 | import libgtk3.gtk_link_button_get_uri 18 | import libgtk3.gtk_link_button_get_visited 19 | import libgtk3.gtk_link_button_new 20 | import libgtk3.gtk_link_button_set_uri 21 | import libgtk3.gtk_link_button_set_visited 22 | import libgtk3.gtk_true 23 | 24 | inline fun Container.linkButton(uri: String, init: LinkButton.() -> Unit = {}): LinkButton = 25 | LinkButton(uri).apply { init(); this@linkButton.add(this) } 26 | 27 | private fun LinkButton_onActivateLink_Handler(sender: CPointer?, _data: 28 | COpaquePointer?) { 29 | _data?.asStableRef()?.get()?.onActivateLink?.emit() 30 | } 31 | 32 | /** 33 | * A GtkLinkButton is a #GtkButton with a hyperlink, similar to the one 34 | * used by web browsers, which triggers an action when clicked. It is useful 35 | * to show quick links to resources. 36 | * 37 | * A link button is created by calling either gtk_link_button_new() or 38 | * gtk_link_button_new_with_label(). If using the former, the URI you pass 39 | * to the constructor is used as a label for the widget. 40 | * 41 | * The URI bound to a GtkLinkButton can be set specifically using 42 | * gtk_link_button_set_uri(), and retrieved using gtk_link_button_get_uri(). 43 | * 44 | * By default, GtkLinkButton calls gtk_show_uri_on_window() when the button is 45 | * clicked. This behaviour can be overridden by connecting to the 46 | * #GtkLinkButton::activate-link signal and returning %TRUE from the 47 | * signal handler. 48 | * 49 | * # CSS nodes 50 | * 51 | * GtkLinkButton has a single CSS node with name button. To differentiate 52 | * it from a plain #GtkButton, it gets the .link style class. 53 | */ 54 | @GtkDsl 55 | open class LinkButton internal constructor(override val widgetPtr: CPointer? = null) : 56 | Button() { 57 | private val self: CPointer? 58 | get() = widgetPtr!!.reinterpret() 59 | 60 | val linkButton: CPointer? 61 | get() = widgetPtr!!.reinterpret() 62 | 63 | val onActivateLink: Signal?, COpaquePointer?) -> 64 | Unit>> by lazy { Signal?, 65 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "activate-link", 66 | staticCFunction(::LinkButton_onActivateLink_Handler)) } 67 | 68 | /** 69 | * Retrieves the URI set using gtk_link_button_set_uri(). 70 | * 71 | * Sets @uri as the URI where the #GtkLinkButton points. As a side-effect 72 | * this unsets the “visited” state of the button. */ 73 | var uri: String 74 | get() = gtk_link_button_get_uri(self)?.toKString() ?: "" 75 | set(value) { 76 | gtk_link_button_set_uri(self, value) 77 | } 78 | 79 | /** 80 | * Retrieves the “visited” state of the URI where the #GtkLinkButton 81 | * points. The button becomes visited when it is clicked. If the URI 82 | * is changed on the button, the “visited” state is unset again. 83 | * 84 | * The state may also be changed using gtk_link_button_set_visited(). 85 | * 86 | * Sets the “visited” state of the URI where the #GtkLinkButton 87 | * points. See gtk_link_button_get_visited() for more details. */ 88 | var visited: Boolean 89 | get() = gtk_link_button_get_visited(self) != 0 90 | set(value) { 91 | gtk_link_button_set_visited(self, if (value) gtk_true() else gtk_false()) 92 | } 93 | 94 | /** 95 | * Creates a new #GtkLinkButton with the URI as its text. */ 96 | constructor(uri: String) : this(gtk_link_button_new(uri)?.reinterpret()) 97 | } 98 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/LockButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GPermission 7 | import libgtk3.GtkLockButton 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_lock_button_get_permission 10 | import libgtk3.gtk_lock_button_new 11 | import libgtk3.gtk_lock_button_set_permission 12 | 13 | inline fun Container.lockButton(permission: CPointer, init: LockButton.() -> Unit = 14 | {}): LockButton = LockButton(permission).apply { init(); this@lockButton.add(this) } 15 | 16 | /** 17 | * GtkLockButton is a widget that can be used in control panels or 18 | * preference dialogs to allow users to obtain and revoke authorizations 19 | * needed to operate the controls. The required authorization is represented 20 | * by a #GPermission object. Concrete implementations of #GPermission may use 21 | * PolicyKit or some other authorization framework. To obtain a PolicyKit-based 22 | * #GPermission, use polkit_permission_new(). 23 | * 24 | * If the user is not currently allowed to perform the action, but can obtain 25 | * the permission, the widget looks like this: 26 | * 27 | * ![](lockbutton-locked.png) 28 | * 29 | * and the user can click the button to request the permission. Depending 30 | * on the platform, this may pop up an authentication dialog or ask the user 31 | * to authenticate in some other way. Once the user has obtained the permission, 32 | * the widget changes to this: 33 | * 34 | * ![](lockbutton-unlocked.png) 35 | * 36 | * and the permission can be dropped again by clicking the button. If the user 37 | * is not able to obtain the permission at all, the widget looks like this: 38 | * 39 | * ![](lockbutton-sorry.png) 40 | * 41 | * If the user has the permission and cannot drop it, the button is hidden. 42 | * 43 | * The text (and tooltips) that are shown in the various cases can be adjusted 44 | * with the #GtkLockButton:text-lock, #GtkLockButton:text-unlock, 45 | * #GtkLockButton:tooltip-lock, #GtkLockButton:tooltip-unlock and 46 | * #GtkLockButton:tooltip-not-authorized properties. 47 | */ 48 | @GtkDsl 49 | open class LockButton internal constructor(override val widgetPtr: CPointer? = null) : 50 | Button() { 51 | private val self: CPointer? 52 | get() = widgetPtr!!.reinterpret() 53 | 54 | val lockButton: CPointer? 55 | get() = widgetPtr!!.reinterpret() 56 | 57 | /** 58 | * Obtains the #GPermission object that controls @button. 59 | * 60 | * Sets the #GPermission object that controls @button. */ 61 | var permission: CPointer 62 | get() = gtk_lock_button_get_permission(self)!!.reinterpret() 63 | set(value) { 64 | gtk_lock_button_set_permission(self, value?.reinterpret()) 65 | } 66 | 67 | /** 68 | * Creates a new lock button which reflects the @permission. */ 69 | constructor(permission: CPointer) : 70 | this(gtk_lock_button_new(permission?.reinterpret())?.reinterpret()) 71 | } 72 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/MenuBar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkMenuBar 7 | import libgtk3.GtkPackDirection 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_menu_bar_get_child_pack_direction 10 | import libgtk3.gtk_menu_bar_get_pack_direction 11 | import libgtk3.gtk_menu_bar_new 12 | import libgtk3.gtk_menu_bar_set_child_pack_direction 13 | import libgtk3.gtk_menu_bar_set_pack_direction 14 | 15 | inline fun Container.menuBar(init: MenuBar.() -> Unit = {}): MenuBar = MenuBar().apply { init(); 16 | this@menuBar.add(this) } 17 | 18 | /** 19 | * The #GtkMenuBar is a subclass of #GtkMenuShell which contains one or 20 | * more #GtkMenuItems. The result is a standard menu bar which can hold 21 | * many menu items. 22 | * 23 | * # CSS nodes 24 | * 25 | * GtkMenuBar has a single CSS node with name menubar. 26 | */ 27 | @GtkDsl 28 | open class MenuBar internal constructor(override val widgetPtr: CPointer? = null) : 29 | MenuShell() { 30 | private val self: CPointer? 31 | get() = widgetPtr!!.reinterpret() 32 | 33 | val menuBar: CPointer? 34 | get() = widgetPtr!!.reinterpret() 35 | 36 | /** 37 | * Retrieves the current child pack direction of the menubar. 38 | * See gtk_menu_bar_set_child_pack_direction(). 39 | * 40 | * Sets how widgets should be packed inside the children of a menubar. */ 41 | var childPackDirection: GtkPackDirection 42 | get() = gtk_menu_bar_get_child_pack_direction(self) 43 | set(value) { 44 | gtk_menu_bar_set_child_pack_direction(self, value) 45 | } 46 | 47 | /** 48 | * Retrieves the current pack direction of the menubar. 49 | * See gtk_menu_bar_set_pack_direction(). 50 | * 51 | * Sets how items should be packed inside a menubar. */ 52 | var packDirection: GtkPackDirection 53 | get() = gtk_menu_bar_get_pack_direction(self) 54 | set(value) { 55 | gtk_menu_bar_set_pack_direction(self, value) 56 | } 57 | 58 | /** 59 | * Creates a new #GtkMenuBar */ 60 | constructor() : this(gtk_menu_bar_new()?.reinterpret()) 61 | } 62 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Misc.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkMisc 6 | 7 | /** 8 | * The #GtkMisc widget is an abstract widget which is not useful itself, but 9 | * is used to derive subclasses which have alignment and padding attributes. 10 | * 11 | * The horizontal and vertical padding attributes allows extra space to be 12 | * added around the widget. 13 | * 14 | * The horizontal and vertical alignment attributes enable the widget to be 15 | * positioned within its allocated area. Note that if the widget is added to 16 | * a container in such a way that it expands automatically to fill its 17 | * allocated area, the alignment settings will not alter the widget's position. 18 | * 19 | * Note that the desired effect can in most cases be achieved by using the 20 | * #GtkWidget:halign, #GtkWidget:valign and #GtkWidget:margin properties 21 | * on the child widget, so GtkMisc should not be used in new code. To reflect 22 | * this fact, all #GtkMisc API has been deprecated. */ 23 | @GtkDsl 24 | abstract class Misc : Widget() { 25 | private val self: CPointer 26 | get() = widgetPtr!!.reinterpret() 27 | } 28 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/OffscreenWindow.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GdkPixbuf 7 | import libgtk3.GtkOffscreenWindow 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_offscreen_window_get_pixbuf 10 | import libgtk3.gtk_offscreen_window_new 11 | 12 | inline fun Container.offscreenWindow(init: OffscreenWindow.() -> Unit = {}): OffscreenWindow = 13 | OffscreenWindow().apply { init(); this@offscreenWindow.add(this) } 14 | 15 | /** 16 | * GtkOffscreenWindow is strictly intended to be used for obtaining 17 | * snapshots of widgets that are not part of a normal widget hierarchy. 18 | * Since #GtkOffscreenWindow is a toplevel widget you cannot obtain 19 | * snapshots of a full window with it since you cannot pack a toplevel 20 | * widget in another toplevel. 21 | * 22 | * The idea is to take a widget and manually set the state of it, 23 | * add it to a GtkOffscreenWindow and then retrieve the snapshot 24 | * as a #cairo_surface_t or #GdkPixbuf. 25 | * 26 | * GtkOffscreenWindow derives from #GtkWindow only as an implementation 27 | * detail. Applications should not use any API specific to #GtkWindow 28 | * to operate on this object. It should be treated as a #GtkBin that 29 | * has no parent widget. 30 | * 31 | * When contained offscreen widgets are redrawn, GtkOffscreenWindow 32 | * will emit a #GtkWidget::damage-event signal.Retrieves a snapshot of the contained widget in the 33 | form of 34 | * a #GdkPixbuf. This is a new pixbuf with a reference count of 1, 35 | * and the application should unreference it once it is no longer 36 | * needed. 37 | */ 38 | @GtkDsl 39 | open class OffscreenWindow internal constructor(override val widgetPtr: CPointer? = null) 40 | : Window() { 41 | private val self: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | val offscreenWindow: CPointer? 45 | get() = widgetPtr!!.reinterpret() 46 | 47 | val pixbuf: CPointer 48 | get() = gtk_offscreen_window_get_pixbuf(self)!!.reinterpret() 49 | 50 | /** 51 | * Creates a toplevel container widget that is used to retrieve 52 | * snapshots of widgets without showing them on the screen. */ 53 | constructor() : this(gtk_offscreen_window_new()?.reinterpret()) 54 | } 55 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/RadioToolButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GSList 7 | import libgtk3.GtkRadioToolButton 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_radio_tool_button_get_group 10 | import libgtk3.gtk_radio_tool_button_new 11 | import libgtk3.gtk_radio_tool_button_set_group 12 | 13 | inline fun Container.radioToolButton(group: CPointer, init: RadioToolButton.() -> Unit = 14 | {}): RadioToolButton = RadioToolButton(group).apply { init(); this@radioToolButton.add(this) 15 | } 16 | 17 | /** 18 | * A #GtkRadioToolButton is a #GtkToolItem that contains a radio button, 19 | * that is, a button that is part of a group of toggle buttons where only 20 | * one button can be active at a time. 21 | * 22 | * Use gtk_radio_tool_button_new() to create a new GtkRadioToolButton. Use 23 | * gtk_radio_tool_button_new_from_widget() to create a new GtkRadioToolButton 24 | * that is part of the same group as an existing GtkRadioToolButton. 25 | * 26 | * # CSS nodes 27 | * 28 | * GtkRadioToolButton has a single CSS node with name toolbutton. 29 | */ 30 | @GtkDsl 31 | open class RadioToolButton internal constructor(override val widgetPtr: CPointer? = null) 32 | : ToggleToolButton() { 33 | private val self: CPointer? 34 | get() = widgetPtr!!.reinterpret() 35 | 36 | val radioToolButton: CPointer? 37 | get() = widgetPtr!!.reinterpret() 38 | 39 | /** 40 | * Returns the radio button group @button belongs to. 41 | * 42 | * Adds @button to @group, removing it from the group it belonged to before. */ 43 | var group: CPointer 44 | get() = gtk_radio_tool_button_get_group(self)!!.reinterpret() 45 | set(value) { 46 | gtk_radio_tool_button_set_group(self, value?.reinterpret()) 47 | } 48 | 49 | /** 50 | * Creates a new #GtkRadioToolButton, adding it to @group. */ 51 | constructor(group: CPointer) : 52 | this(gtk_radio_tool_button_new(group?.reinterpret())?.reinterpret()) 53 | } 54 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/RecentChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkRecentChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_recent_chooser_dialog_new 11 | 12 | inline fun Container.recentChooserDialog( 13 | title: String, 14 | parent: CPointer, 15 | first_button_text: String, 16 | init: RecentChooserDialog.() -> Unit = {} 17 | ): RecentChooserDialog = RecentChooserDialog(title, parent, first_button_text).apply { init(); 18 | this@recentChooserDialog.add(this) } 19 | 20 | /** 21 | * #GtkRecentChooserDialog is a dialog box suitable for displaying the recently 22 | * used documents. This widgets works by putting a #GtkRecentChooserWidget inside 23 | * a #GtkDialog. It exposes the #GtkRecentChooserIface interface, so you can use 24 | * all the #GtkRecentChooser functions on the recent chooser dialog as well as 25 | * those for #GtkDialog. 26 | * 27 | * Note that #GtkRecentChooserDialog does not have any methods of its own. 28 | * Instead, you should use the functions that work on a #GtkRecentChooser. 29 | * 30 | * ## Typical usage ## {#gtkrecentchooser-typical-usage} 31 | * 32 | * In the simplest of cases, you can use the following code to use 33 | * a #GtkRecentChooserDialog to select a recently used file: 34 | * 35 | * |[ 36 | * GtkWidget *dialog; 37 | * gint res; 38 | * 39 | * dialog = gtk_recent_chooser_dialog_new ("Recent Documents", 40 | * parent_window, 41 | * _("_Cancel"), 42 | * GTK_RESPONSE_CANCEL, 43 | * _("_Open"), 44 | * GTK_RESPONSE_ACCEPT, 45 | * NULL); 46 | * 47 | * res = gtk_dialog_run (GTK_DIALOG (dialog)); 48 | * if (res == GTK_RESPONSE_ACCEPT) 49 | * { 50 | * GtkRecentInfo *info; 51 | * GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (dialog); 52 | * 53 | * info = gtk_recent_chooser_get_current_item (chooser); 54 | * open_file (gtk_recent_info_get_uri (info)); 55 | * gtk_recent_info_unref (info); 56 | * } 57 | * 58 | * gtk_widget_destroy (dialog); 59 | * ]| 60 | * 61 | * Recently used files are supported since GTK+ 2.10. 62 | */ 63 | @GtkDsl 64 | open class RecentChooserDialog internal constructor(override val widgetPtr: CPointer? = 65 | null) : Dialog() { 66 | private val self: CPointer? 67 | get() = widgetPtr!!.reinterpret() 68 | 69 | val recentChooserDialog: CPointer? 70 | get() = widgetPtr!!.reinterpret() 71 | 72 | /** 73 | * Creates a new #GtkRecentChooserDialog. This function is analogous to 74 | * gtk_dialog_new_with_buttons(). */ 75 | constructor( 76 | title: String, 77 | parent: CPointer, 78 | first_button_text: String 79 | ) : this(gtk_recent_chooser_dialog_new(title, parent?.reinterpret(), 80 | first_button_text)?.reinterpret()) 81 | } 82 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/RecentChooserMenu.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkRecentChooserMenu 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_false 10 | import libgtk3.gtk_recent_chooser_menu_get_show_numbers 11 | import libgtk3.gtk_recent_chooser_menu_new 12 | import libgtk3.gtk_recent_chooser_menu_set_show_numbers 13 | import libgtk3.gtk_true 14 | 15 | inline fun Container.recentChooserMenu(init: RecentChooserMenu.() -> Unit = {}): RecentChooserMenu = 16 | RecentChooserMenu().apply { init(); this@recentChooserMenu.add(this) } 17 | 18 | /** 19 | * #GtkRecentChooserMenu is a widget suitable for displaying recently used files 20 | * inside a menu. It can be used to set a sub-menu of a #GtkMenuItem using 21 | * gtk_menu_item_set_submenu(), or as the menu of a #GtkMenuToolButton. 22 | * 23 | * Note that #GtkRecentChooserMenu does not have any methods of its own. Instead, 24 | * you should use the functions that work on a #GtkRecentChooser. 25 | * 26 | * Note also that #GtkRecentChooserMenu does not support multiple filters, as it 27 | * has no way to let the user choose between them as the #GtkRecentChooserWidget 28 | * and #GtkRecentChooserDialog widgets do. Thus using gtk_recent_chooser_add_filter() 29 | * on a #GtkRecentChooserMenu widget will yield the same effects as using 30 | * gtk_recent_chooser_set_filter(), replacing any currently set filter 31 | * with the supplied filter; gtk_recent_chooser_remove_filter() will remove 32 | * any currently set #GtkRecentFilter object and will unset the current filter; 33 | * gtk_recent_chooser_list_filters() will return a list containing a single 34 | * #GtkRecentFilter object. 35 | * 36 | * Recently used files are supported since GTK+ 2.10. 37 | */ 38 | @GtkDsl 39 | open class RecentChooserMenu internal constructor(override val widgetPtr: CPointer? = 40 | null) : Menu() { 41 | private val self: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | val recentChooserMenu: CPointer? 45 | get() = widgetPtr!!.reinterpret() 46 | 47 | /** 48 | * Returns the value set by gtk_recent_chooser_menu_set_show_numbers(). 49 | * 50 | * Sets whether a number should be added to the items of @menu. The 51 | * numbers are shown to provide a unique character for a mnemonic to 52 | * be used inside ten menu item’s label. Only the first the items 53 | * get a number to avoid clashes. */ 54 | var showNumbers: Boolean 55 | get() = gtk_recent_chooser_menu_get_show_numbers(self) != 0 56 | set(value) { 57 | gtk_recent_chooser_menu_set_show_numbers(self, if (value) gtk_true() else gtk_false()) 58 | } 59 | 60 | /** 61 | * Creates a new #GtkRecentChooserMenu widget. 62 | * 63 | * This kind of widget shows the list of recently used resources as 64 | * a menu, each item as a menu item. Each item inside the menu might 65 | * have an icon, representing its MIME type, and a number, for mnemonic 66 | * access. 67 | * 68 | * This widget implements the #GtkRecentChooser interface. 69 | * 70 | * This widget creates its own #GtkRecentManager object. See the 71 | * gtk_recent_chooser_menu_new_for_manager() function to know how to create 72 | * a #GtkRecentChooserMenu widget bound to another #GtkRecentManager object. */ 73 | constructor() : this(gtk_recent_chooser_menu_new()?.reinterpret()) 74 | } 75 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/RecentChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkRecentChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_recent_chooser_widget_new 9 | 10 | inline fun Container.recentChooserWidget(init: RecentChooserWidget.() -> Unit = {}): 11 | RecentChooserWidget = RecentChooserWidget().apply { init(); 12 | this@recentChooserWidget.add(this) } 13 | 14 | /** 15 | * #GtkRecentChooserWidget is a widget suitable for selecting recently used 16 | * files. It is the main building block of a #GtkRecentChooserDialog. Most 17 | * applications will only need to use the latter; you can use 18 | * #GtkRecentChooserWidget as part of a larger window if you have special needs. 19 | * 20 | * Note that #GtkRecentChooserWidget does not have any methods of its own. 21 | * Instead, you should use the functions that work on a #GtkRecentChooser. 22 | * 23 | * Recently used files are supported since GTK+ 2.10. 24 | */ 25 | @GtkDsl 26 | open class RecentChooserWidget internal constructor(override val widgetPtr: CPointer? = 27 | null) : Box() { 28 | private val self: CPointer? 29 | get() = widgetPtr!!.reinterpret() 30 | 31 | val recentChooserWidget: CPointer? 32 | get() = widgetPtr!!.reinterpret() 33 | 34 | /** 35 | * Creates a new #GtkRecentChooserWidget object. This is an embeddable widget 36 | * used to access the recently used resources list. */ 37 | constructor() : this(gtk_recent_chooser_widget_new()?.reinterpret()) 38 | } 39 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Revealer.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.UInt 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CPointer 7 | import kotlinx.cinterop.reinterpret 8 | import libgtk3.GtkRevealer 9 | import libgtk3.GtkRevealerTransitionType 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_false 12 | import libgtk3.gtk_revealer_get_child_revealed 13 | import libgtk3.gtk_revealer_get_reveal_child 14 | import libgtk3.gtk_revealer_get_transition_duration 15 | import libgtk3.gtk_revealer_get_transition_type 16 | import libgtk3.gtk_revealer_new 17 | import libgtk3.gtk_revealer_set_reveal_child 18 | import libgtk3.gtk_revealer_set_transition_duration 19 | import libgtk3.gtk_revealer_set_transition_type 20 | import libgtk3.gtk_true 21 | 22 | inline fun Container.revealer(init: Revealer.() -> Unit = {}): Revealer = Revealer().apply { init(); 23 | this@revealer.add(this) } 24 | 25 | /** 26 | * The GtkRevealer widget is a container which animates 27 | * the transition of its child from invisible to visible. 28 | * 29 | * The style of transition can be controlled with 30 | * gtk_revealer_set_transition_type(). 31 | * 32 | * These animations respect the #GtkSettings:gtk-enable-animations 33 | * setting. 34 | * 35 | * # CSS nodes 36 | * 37 | * GtkRevealer has a single CSS node with name revealer. 38 | * 39 | * The GtkRevealer widget was added in GTK+ 3.10.Returns whether the child is fully revealed, in 40 | other words whether 41 | * the transition to the revealed state is completed. 42 | */ 43 | @GtkDsl 44 | open class Revealer internal constructor(override val widgetPtr: CPointer? = null) : 45 | Bin() { 46 | private val self: CPointer? 47 | get() = widgetPtr!!.reinterpret() 48 | 49 | val revealer: CPointer? 50 | get() = widgetPtr!!.reinterpret() 51 | 52 | val childRevealed: Boolean 53 | get() = gtk_revealer_get_child_revealed(self) != 0 54 | 55 | /** 56 | * Returns whether the child is currently 57 | * revealed. See gtk_revealer_set_reveal_child(). 58 | * 59 | * This function returns %TRUE as soon as the transition 60 | * is to the revealed state is started. To learn whether 61 | * the child is fully revealed (ie the transition is completed), 62 | * use gtk_revealer_get_child_revealed(). 63 | * 64 | * Tells the #GtkRevealer to reveal or conceal its child. 65 | * 66 | * The transition will be animated with the current 67 | * transition type of @revealer. */ 68 | var revealChild: Boolean 69 | get() = gtk_revealer_get_reveal_child(self) != 0 70 | set(value) { 71 | gtk_revealer_set_reveal_child(self, if (value) gtk_true() else gtk_false()) 72 | } 73 | 74 | /** 75 | * Returns the amount of time (in milliseconds) that 76 | * transitions will take. 77 | * 78 | * Sets the duration that transitions will take. */ 79 | var transitionDuration: UInt 80 | get() = gtk_revealer_get_transition_duration(self) 81 | set(value) { 82 | gtk_revealer_set_transition_duration(self, value) 83 | } 84 | 85 | /** 86 | * Gets the type of animation that will be used 87 | * for transitions in @revealer. 88 | * 89 | * Sets the type of animation that will be used for 90 | * transitions in @revealer. Available types include 91 | * various kinds of fades and slides. */ 92 | var transitionType: GtkRevealerTransitionType 93 | get() = gtk_revealer_get_transition_type(self) 94 | set(value) { 95 | gtk_revealer_set_transition_type(self, value) 96 | } 97 | 98 | /** 99 | * Creates a new #GtkRevealer. */ 100 | constructor() : this(gtk_revealer_new()?.reinterpret()) 101 | } 102 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Scrollbar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkAdjustment 7 | import libgtk3.GtkOrientation 8 | import libgtk3.GtkScrollbar 9 | import libgtk3.GtkWidget 10 | import libgtk3.gtk_scrollbar_new 11 | 12 | inline fun Container.scrollbar( 13 | orientation: GtkOrientation, 14 | adjustment: CPointer, 15 | init: Scrollbar.() -> Unit = {} 16 | ): Scrollbar = Scrollbar(orientation, adjustment).apply { init(); this@scrollbar.add(this) } 17 | 18 | /** 19 | * The #GtkScrollbar widget is a horizontal or vertical scrollbar, 20 | * depending on the value of the #GtkOrientable:orientation property. 21 | * 22 | * Its position and movement are controlled by the adjustment that is passed to 23 | * or created by gtk_scrollbar_new(). See #GtkAdjustment for more details. The 24 | * #GtkAdjustment:value field sets the position of the thumb and must be between 25 | * #GtkAdjustment:lower and #GtkAdjustment:upper - #GtkAdjustment:page-size. The 26 | * #GtkAdjustment:page-size represents the size of the visible scrollable area. 27 | * The fields #GtkAdjustment:step-increment and #GtkAdjustment:page-increment 28 | * fields are added to or subtracted from the #GtkAdjustment:value when the user 29 | * asks to move by a step (using e.g. the cursor arrow keys or, if present, the 30 | * stepper buttons) or by a page (using e.g. the Page Down/Up keys). 31 | * 32 | * # CSS nodes 33 | * 34 | * |[ 35 | * scrollbar[.fine-tune] 36 | * ╰── contents 37 | * ├── [button.up] 38 | * ├── [button.down] 39 | * ├── trough 40 | * │ ╰── slider 41 | * ├── [button.up] 42 | * ╰── [button.down] 43 | * ]| 44 | * 45 | * GtkScrollbar has a main CSS node with name scrollbar and a subnode for its 46 | * contents, with subnodes named trough and slider. 47 | * 48 | * The main node gets the style class .fine-tune added when the scrollbar is 49 | * in 'fine-tuning' mode. 50 | * 51 | * If steppers are enabled, they are represented by up to four additional 52 | * subnodes with name button. These get the style classes .up and .down to 53 | * indicate in which direction they are moving. 54 | * 55 | * Other style classes that may be added to scrollbars inside #GtkScrolledWindow 56 | * include the positional classes (.left, .right, .top, .bottom) and style 57 | * classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering). 58 | */ 59 | @GtkDsl 60 | open class Scrollbar internal constructor(override val widgetPtr: CPointer? = null) : 61 | Range() { 62 | private val self: CPointer? 63 | get() = widgetPtr!!.reinterpret() 64 | 65 | val scrollbar: CPointer? 66 | get() = widgetPtr!!.reinterpret() 67 | 68 | /** 69 | * Creates a new scrollbar with the given orientation. */ 70 | constructor(orientation: GtkOrientation, adjustment: CPointer) : 71 | this(gtk_scrollbar_new(orientation, adjustment?.reinterpret())?.reinterpret()) 72 | } 73 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Separator.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkOrientation 7 | import libgtk3.GtkSeparator 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_separator_new 10 | 11 | inline fun Container.separator(orientation: GtkOrientation, init: Separator.() -> Unit = {}): 12 | Separator = Separator(orientation).apply { init(); this@separator.add(this) } 13 | 14 | /** 15 | * GtkSeparator is a horizontal or vertical separator widget, depending on the 16 | * value of the #GtkOrientable:orientation property, used to group the widgets 17 | * within a window. It displays a line with a shadow to make it appear sunken 18 | * into the interface. 19 | * 20 | * # CSS nodes 21 | * 22 | * GtkSeparator has a single CSS node with name separator. The node 23 | * gets one of the .horizontal or .vertical style classes. 24 | */ 25 | @GtkDsl 26 | open class Separator internal constructor(override val widgetPtr: CPointer? = null) : 27 | Widget() { 28 | private val self: CPointer? 29 | get() = widgetPtr!!.reinterpret() 30 | 31 | val separator: CPointer? 32 | get() = widgetPtr!!.reinterpret() 33 | 34 | /** 35 | * Creates a new #GtkSeparator with the given orientation. */ 36 | constructor(orientation: GtkOrientation) : this(gtk_separator_new(orientation)?.reinterpret()) 37 | } 38 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/SeparatorMenuItem.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkSeparatorMenuItem 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_separator_menu_item_new 9 | 10 | inline fun Container.separatorMenuItem(init: SeparatorMenuItem.() -> Unit = {}): SeparatorMenuItem = 11 | SeparatorMenuItem().apply { init(); this@separatorMenuItem.add(this) } 12 | 13 | /** 14 | * The #GtkSeparatorMenuItem is a separator used to group 15 | * items within a menu. It displays a horizontal line with a shadow to 16 | * make it appear sunken into the interface. 17 | * 18 | * # CSS nodes 19 | * 20 | * GtkSeparatorMenuItem has a single CSS node with name separator. 21 | */ 22 | @GtkDsl 23 | open class SeparatorMenuItem internal constructor(override val widgetPtr: CPointer? = 24 | null) : MenuItem() { 25 | private val self: CPointer? 26 | get() = widgetPtr!!.reinterpret() 27 | 28 | val separatorMenuItem: CPointer? 29 | get() = widgetPtr!!.reinterpret() 30 | 31 | /** 32 | * Creates a new #GtkSeparatorMenuItem. */ 33 | constructor() : this(gtk_separator_menu_item_new()?.reinterpret()) 34 | } 35 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/SeparatorToolItem.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkSeparatorToolItem 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_false 10 | import libgtk3.gtk_separator_tool_item_get_draw 11 | import libgtk3.gtk_separator_tool_item_new 12 | import libgtk3.gtk_separator_tool_item_set_draw 13 | import libgtk3.gtk_true 14 | 15 | inline fun Container.separatorToolItem(init: SeparatorToolItem.() -> Unit = {}): SeparatorToolItem = 16 | SeparatorToolItem().apply { init(); this@separatorToolItem.add(this) } 17 | 18 | /** 19 | * A #GtkSeparatorToolItem is a #GtkToolItem that separates groups of other 20 | * #GtkToolItems. Depending on the theme, a #GtkSeparatorToolItem will 21 | * often look like a vertical line on horizontally docked toolbars. 22 | * 23 | * If the #GtkToolbar child property “expand” is %TRUE and the property 24 | * #GtkSeparatorToolItem:draw is %FALSE, a #GtkSeparatorToolItem will act as 25 | * a “spring” that forces other items to the ends of the toolbar. 26 | * 27 | * Use gtk_separator_tool_item_new() to create a new #GtkSeparatorToolItem. 28 | * 29 | * # CSS nodes 30 | * 31 | * GtkSeparatorToolItem has a single CSS node with name separator. 32 | */ 33 | @GtkDsl 34 | open class SeparatorToolItem internal constructor(override val widgetPtr: CPointer? = 35 | null) : ToolItem() { 36 | private val self: CPointer? 37 | get() = widgetPtr!!.reinterpret() 38 | 39 | val separatorToolItem: CPointer? 40 | get() = widgetPtr!!.reinterpret() 41 | 42 | /** 43 | * Returns whether @item is drawn as a line, or just blank. 44 | * See gtk_separator_tool_item_set_draw(). 45 | * 46 | * Whether @item is drawn as a vertical line, or just blank. 47 | * Setting this to %FALSE along with gtk_tool_item_set_expand() is useful 48 | * to create an item that forces following items to the end of the toolbar. */ 49 | var draw: Boolean 50 | get() = gtk_separator_tool_item_get_draw(self) != 0 51 | set(value) { 52 | gtk_separator_tool_item_set_draw(self, if (value) gtk_true() else gtk_false()) 53 | } 54 | 55 | /** 56 | * Create a new #GtkSeparatorToolItem */ 57 | constructor() : this(gtk_separator_tool_item_new()?.reinterpret()) 58 | } 59 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ShortcutLabel.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import kotlinx.cinterop.toKString 8 | import libgtk3.GtkShortcutLabel 9 | import libgtk3.GtkWidget 10 | import libgtk3.gtk_shortcut_label_get_accelerator 11 | import libgtk3.gtk_shortcut_label_get_disabled_text 12 | import libgtk3.gtk_shortcut_label_new 13 | import libgtk3.gtk_shortcut_label_set_accelerator 14 | import libgtk3.gtk_shortcut_label_set_disabled_text 15 | 16 | inline fun Container.shortcutLabel(accelerator: String, init: ShortcutLabel.() -> Unit = {}): 17 | ShortcutLabel = ShortcutLabel(accelerator).apply { init(); this@shortcutLabel.add(this) } 18 | 19 | /** 20 | * #GtkShortcutLabel is a widget that represents a single keyboard shortcut or gesture 21 | * in the user interface. 22 | */ 23 | @GtkDsl 24 | open class ShortcutLabel internal constructor(override val widgetPtr: CPointer? = null) : 25 | Box() { 26 | private val self: CPointer? 27 | get() = widgetPtr!!.reinterpret() 28 | 29 | val shortcutLabel: CPointer? 30 | get() = widgetPtr!!.reinterpret() 31 | 32 | /** 33 | * Retrieves the current accelerator of @self. 34 | * 35 | * Sets the accelerator to be displayed by @self. */ 36 | var accelerator: String 37 | get() = gtk_shortcut_label_get_accelerator(self)?.toKString() ?: "" 38 | set(value) { 39 | gtk_shortcut_label_set_accelerator(self, value) 40 | } 41 | 42 | /** 43 | * Retrieves the text that is displayed when no accelerator is set. 44 | * 45 | * Sets the text to be displayed by @self when no accelerator is set. */ 46 | var disabledText: String 47 | get() = gtk_shortcut_label_get_disabled_text(self)?.toKString() ?: "" 48 | set(value) { 49 | gtk_shortcut_label_set_disabled_text(self, value) 50 | } 51 | 52 | /** 53 | * Creates a new #GtkShortcutLabel with @accelerator set. */ 54 | constructor(accelerator: String) : this(gtk_shortcut_label_new(accelerator)?.reinterpret()) 55 | } 56 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ShortcutsGroup.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkShortcutsGroup 6 | 7 | /** 8 | * A GtkShortcutsGroup represents a group of related keyboard shortcuts 9 | * or gestures. The group has a title. It may optionally be associated with 10 | * a view of the application, which can be used to show only relevant shortcuts 11 | * depending on the application context. 12 | * 13 | * This widget is only meant to be used with #GtkShortcutsWindow. */ 14 | @GtkDsl 15 | abstract class ShortcutsGroup : Box() { 16 | private val self: CPointer 17 | get() = widgetPtr!!.reinterpret() 18 | } 19 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ShortcutsSection.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Int 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointed 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import libgtk3.GtkShortcutsSection 13 | 14 | private fun ShortcutsSection_onChangeCurrentPage_Handler( 15 | sender: CPointer?, 16 | `object`: Int, 17 | _data: COpaquePointer? 18 | ) { 19 | _data?.asStableRef()?.get()?.onChangeCurrentPage?.emit(`object`) 20 | } 21 | 22 | /** 23 | * A GtkShortcutsSection collects all the keyboard shortcuts and gestures 24 | * for a major application mode. If your application needs multiple sections, 25 | * you should give each section a unique #GtkShortcutsSection:section-name and 26 | * a #GtkShortcutsSection:title that can be shown in the section selector of 27 | * the GtkShortcutsWindow. 28 | * 29 | * The #GtkShortcutsSection:max-height property can be used to influence how 30 | * the groups in the section are distributed over pages and columns. 31 | * 32 | * This widget is only meant to be used with #GtkShortcutsWindow. */ 33 | @GtkDsl 34 | abstract class ShortcutsSection : Box() { 35 | private val self: CPointer 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | val onChangeCurrentPage: Signal1?, 40 | Int, 41 | COpaquePointer? 42 | ) -> Unit>> by lazy { Signal1?, 44 | Int, 45 | COpaquePointer? 46 | ) -> Unit>>(widgetPtr!!, this, "change-current-page", 47 | staticCFunction(::ShortcutsSection_onChangeCurrentPage_Handler)) } 48 | } 49 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ShortcutsShortcut.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkShortcutsShortcut 6 | 7 | /** 8 | * A GtkShortcutsShortcut represents a single keyboard shortcut or gesture 9 | * with a short text. This widget is only meant to be used with #GtkShortcutsWindow. */ 10 | @GtkDsl 11 | abstract class ShortcutsShortcut : Box() { 12 | private val self: CPointer 13 | get() = widgetPtr!!.reinterpret() 14 | } 15 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ShortcutsWindow.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CFunction 5 | import kotlinx.cinterop.COpaquePointer 6 | import kotlinx.cinterop.CPointed 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import libgtk3.GtkShortcutsWindow 12 | 13 | private fun ShortcutsWindow_onClose_Handler(sender: CPointer?, _data: COpaquePointer?) 14 | { 15 | _data?.asStableRef()?.get()?.onClose?.emit() 16 | } 17 | 18 | private fun ShortcutsWindow_onSearch_Handler(sender: CPointer?, _data: COpaquePointer?) 19 | { 20 | _data?.asStableRef()?.get()?.onSearch?.emit() 21 | } 22 | 23 | /** 24 | * A GtkShortcutsWindow shows brief information about the keyboard shortcuts 25 | * and gestures of an application. The shortcuts can be grouped, and you can 26 | * have multiple sections in this window, corresponding to the major modes of 27 | * your application. 28 | * 29 | * Additionally, the shortcuts can be filtered by the current view, to avoid 30 | * showing information that is not relevant in the current application context. 31 | * 32 | * The recommended way to construct a GtkShortcutsWindow is with GtkBuilder, 33 | * by populating a #GtkShortcutsWindow with one or more #GtkShortcutsSection 34 | * objects, which contain #GtkShortcutsGroups that in turn contain objects of 35 | * class #GtkShortcutsShortcut. 36 | * 37 | * # A simple example: 38 | * 39 | * ![](gedit-shortcuts.png) 40 | * 41 | * This example has as single section. As you can see, the shortcut groups 42 | * are arranged in columns, and spread across several pages if there are too 43 | * many to find on a single page. 44 | * 45 | * The .ui file for this example can be found 46 | [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-gedit.ui). 47 | * 48 | * # An example with multiple views: 49 | * 50 | * ![](clocks-shortcuts.png) 51 | * 52 | * This example shows a #GtkShortcutsWindow that has been configured to show only 53 | * the shortcuts relevant to the "stopwatch" view. 54 | * 55 | * The .ui file for this example can be found 56 | [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-clocks.ui). 57 | * 58 | * # An example with multiple sections: 59 | * 60 | * ![](builder-shortcuts.png) 61 | * 62 | * This example shows a #GtkShortcutsWindow with two sections, "Editor Shortcuts" 63 | * and "Terminal Shortcuts". 64 | * 65 | * The .ui file for this example can be found 66 | [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-builder.ui). */ 67 | @GtkDsl 68 | abstract class ShortcutsWindow : Window() { 69 | private val self: CPointer 70 | get() = widgetPtr!!.reinterpret() 71 | 72 | val onClose: Signal?, COpaquePointer?) -> 73 | Unit>> by lazy { Signal?, 74 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "close", 75 | staticCFunction(::ShortcutsWindow_onClose_Handler)) } 76 | 77 | val onSearch: Signal?, COpaquePointer?) -> 78 | Unit>> by lazy { Signal?, 79 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "search", 80 | staticCFunction(::ShortcutsWindow_onSearch_Handler)) } 81 | } 82 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Spinner.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkSpinner 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_spinner_new 9 | import libgtk3.gtk_spinner_start 10 | import libgtk3.gtk_spinner_stop 11 | 12 | inline fun Container.spinner(init: Spinner.() -> Unit = {}): Spinner = Spinner().apply { init(); 13 | this@spinner.add(this) } 14 | 15 | /** 16 | * A GtkSpinner widget displays an icon-size spinning animation. 17 | * It is often used as an alternative to a #GtkProgressBar for 18 | * displaying indefinite activity, instead of actual progress. 19 | * 20 | * To start the animation, use gtk_spinner_start(), to stop it 21 | * use gtk_spinner_stop(). 22 | * 23 | * # CSS nodes 24 | * 25 | * GtkSpinner has a single CSS node with the name spinner. When the animation is 26 | * active, the :checked pseudoclass is added to this node. 27 | */ 28 | @GtkDsl 29 | open class Spinner internal constructor(override val widgetPtr: CPointer? = null) : 30 | Widget() { 31 | private val self: CPointer? 32 | get() = widgetPtr!!.reinterpret() 33 | 34 | val spinner: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | /** 38 | * Returns a new spinner widget. Not yet started. */ 39 | constructor() : this(gtk_spinner_new()?.reinterpret()) 40 | 41 | /** 42 | * Starts the animation of the spinner. 43 | */ 44 | fun start(): Unit = gtk_spinner_start(self) 45 | 46 | /** 47 | * Stops the animation of the spinner. 48 | */ 49 | fun stop(): Unit = gtk_spinner_stop(self) 50 | } 51 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/StackSidebar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkStack 7 | import libgtk3.GtkStackSidebar 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_stack_sidebar_get_stack 10 | import libgtk3.gtk_stack_sidebar_new 11 | import libgtk3.gtk_stack_sidebar_set_stack 12 | 13 | inline fun Container.stackSidebar(init: StackSidebar.() -> Unit = {}): StackSidebar = 14 | StackSidebar().apply { init(); this@stackSidebar.add(this) } 15 | 16 | /** 17 | * A GtkStackSidebar enables you to quickly and easily provide a 18 | * consistent "sidebar" object for your user interface. 19 | * 20 | * In order to use a GtkStackSidebar, you simply use a GtkStack to 21 | * organize your UI flow, and add the sidebar to your sidebar area. You 22 | * can use gtk_stack_sidebar_set_stack() to connect the #GtkStackSidebar 23 | * to the #GtkStack. 24 | * 25 | * # CSS nodes 26 | * 27 | * GtkStackSidebar has a single CSS node with name stacksidebar and 28 | * style class .sidebar. 29 | * 30 | * When circumstances require it, GtkStackSidebar adds the 31 | * .needs-attention style class to the widgets representing the stack 32 | * pages. 33 | */ 34 | @GtkDsl 35 | open class StackSidebar internal constructor(override val widgetPtr: CPointer? = null) : 36 | Bin() { 37 | private val self: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | val stackSidebar: CPointer? 41 | get() = widgetPtr!!.reinterpret() 42 | 43 | /** 44 | * Retrieves the stack. 45 | * See gtk_stack_sidebar_set_stack(). 46 | * 47 | * Set the #GtkStack associated with this #GtkStackSidebar. 48 | * 49 | * The sidebar widget will automatically update according to the order 50 | * (packing) and items within the given #GtkStack. */ 51 | var stack: CPointer 52 | get() = gtk_stack_sidebar_get_stack(self)!!.reinterpret() 53 | set(value) { 54 | gtk_stack_sidebar_set_stack(self, value?.reinterpret()) 55 | } 56 | 57 | /** 58 | * Creates a new sidebar. */ 59 | constructor() : this(gtk_stack_sidebar_new()?.reinterpret()) 60 | } 61 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/StackSwitcher.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkStack 7 | import libgtk3.GtkStackSwitcher 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_stack_switcher_get_stack 10 | import libgtk3.gtk_stack_switcher_new 11 | import libgtk3.gtk_stack_switcher_set_stack 12 | 13 | inline fun Container.stackSwitcher(init: StackSwitcher.() -> Unit = {}): StackSwitcher = 14 | StackSwitcher().apply { init(); this@stackSwitcher.add(this) } 15 | 16 | /** 17 | * The GtkStackSwitcher widget acts as a controller for a 18 | * #GtkStack; it shows a row of buttons to switch between 19 | * the various pages of the associated stack widget. 20 | * 21 | * All the content for the buttons comes from the child properties 22 | * of the #GtkStack; the button visibility in a #GtkStackSwitcher 23 | * widget is controlled by the visibility of the child in the 24 | * #GtkStack. 25 | * 26 | * It is possible to associate multiple #GtkStackSwitcher widgets 27 | * with the same #GtkStack widget. 28 | * 29 | * The GtkStackSwitcher widget was added in 3.10. 30 | * 31 | * # CSS nodes 32 | * 33 | * GtkStackSwitcher has a single CSS node named stackswitcher and 34 | * style class .stack-switcher. 35 | * 36 | * When circumstances require it, GtkStackSwitcher adds the 37 | * .needs-attention style class to the widgets representing the 38 | * stack pages. 39 | */ 40 | @GtkDsl 41 | open class StackSwitcher internal constructor(override val widgetPtr: CPointer? = null) : 42 | Box() { 43 | private val self: CPointer? 44 | get() = widgetPtr!!.reinterpret() 45 | 46 | val stackSwitcher: CPointer? 47 | get() = widgetPtr!!.reinterpret() 48 | 49 | /** 50 | * Retrieves the stack. 51 | * See gtk_stack_switcher_set_stack(). 52 | * 53 | * Sets the stack to control. */ 54 | var stack: CPointer 55 | get() = gtk_stack_switcher_get_stack(self)!!.reinterpret() 56 | set(value) { 57 | gtk_stack_switcher_set_stack(self, value?.reinterpret()) 58 | } 59 | 60 | /** 61 | * Create a new #GtkStackSwitcher. */ 62 | constructor() : this(gtk_stack_switcher_new()?.reinterpret()) 63 | } 64 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Switch.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointed 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import libgtk3.GtkSwitch 13 | import libgtk3.GtkWidget 14 | import libgtk3.gtk_false 15 | import libgtk3.gtk_switch_get_active 16 | import libgtk3.gtk_switch_get_state 17 | import libgtk3.gtk_switch_new 18 | import libgtk3.gtk_switch_set_active 19 | import libgtk3.gtk_switch_set_state 20 | import libgtk3.gtk_true 21 | 22 | inline fun Container.switch(init: Switch.() -> Unit = {}): Switch = Switch().apply { init(); 23 | this@switch.add(this) } 24 | 25 | private fun Switch_onActivate_Handler(sender: CPointer?, _data: COpaquePointer?) { 26 | _data?.asStableRef()?.get()?.onActivate?.emit() 27 | } 28 | 29 | private fun Switch_onStateSet_Handler( 30 | sender: CPointer?, 31 | state: Boolean, 32 | _data: COpaquePointer? 33 | ) { 34 | _data?.asStableRef()?.get()?.onStateSet?.emit(state) 35 | } 36 | 37 | /** 38 | * #GtkSwitch is a widget that has two states: on or off. The user can control 39 | * which state should be active by clicking the empty area, or by dragging the 40 | * handle. 41 | * 42 | * GtkSwitch can also handle situations where the underlying state changes with 43 | * a delay. See #GtkSwitch::state-set for details. 44 | * 45 | * # CSS nodes 46 | * 47 | * |[ 48 | * switch 49 | * ╰── slider 50 | * ]| 51 | * 52 | * GtkSwitch has two css nodes, the main node with the name switch and a subnode 53 | * named slider. Neither of them is using any style classes. 54 | */ 55 | @GtkDsl 56 | open class Switch internal constructor(override val widgetPtr: CPointer? = null) : 57 | Widget() { 58 | private val self: CPointer? 59 | get() = widgetPtr!!.reinterpret() 60 | 61 | val switch: CPointer? 62 | get() = widgetPtr!!.reinterpret() 63 | 64 | val onActivate: Signal?, COpaquePointer?) -> Unit>> by 65 | lazy { Signal?, COpaquePointer?) -> 66 | Unit>>(widgetPtr!!, this, "activate", staticCFunction(::Switch_onActivate_Handler)) } 67 | 68 | val onStateSet: Signal1?, 70 | Boolean, 71 | COpaquePointer? 72 | ) -> Unit>> by lazy { Signal1?, 74 | Boolean, 75 | COpaquePointer? 76 | ) -> Unit>>(widgetPtr!!, this, "state-set", 77 | staticCFunction(::Switch_onStateSet_Handler)) } 78 | 79 | /** 80 | * Gets whether the #GtkSwitch is in its “on” or “off” state. 81 | * 82 | * Changes the state of @sw to the desired one. */ 83 | var active: Boolean 84 | get() = gtk_switch_get_active(self) != 0 85 | set(value) { 86 | gtk_switch_set_active(self, if (value) gtk_true() else gtk_false()) 87 | } 88 | 89 | /** 90 | * Gets the underlying state of the #GtkSwitch. 91 | * 92 | * Sets the underlying state of the #GtkSwitch. 93 | * 94 | * Normally, this is the same as #GtkSwitch:active, unless the switch 95 | * is set up for delayed state changes. This function is typically 96 | * called from a #GtkSwitch::state-set signal handler. 97 | * 98 | * See #GtkSwitch::state-set for details. */ 99 | var state: Boolean 100 | get() = gtk_switch_get_state(self) != 0 101 | set(value) { 102 | gtk_switch_set_state(self, if (value) gtk_true() else gtk_false()) 103 | } 104 | 105 | /** 106 | * Creates a new #GtkSwitch widget. */ 107 | constructor() : this(gtk_switch_new()?.reinterpret()) 108 | } 109 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/ToggleToolButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointed 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import libgtk3.GtkToggleToolButton 13 | import libgtk3.GtkWidget 14 | import libgtk3.gtk_false 15 | import libgtk3.gtk_toggle_tool_button_get_active 16 | import libgtk3.gtk_toggle_tool_button_new 17 | import libgtk3.gtk_toggle_tool_button_set_active 18 | import libgtk3.gtk_true 19 | 20 | inline fun Container.toggleToolButton(init: ToggleToolButton.() -> Unit = {}): ToggleToolButton = 21 | ToggleToolButton().apply { init(); this@toggleToolButton.add(this) } 22 | 23 | private fun ToggleToolButton_onToggled_Handler(sender: CPointer?, _data: 24 | COpaquePointer?) { 25 | _data?.asStableRef()?.get()?.onToggled?.emit() 26 | } 27 | 28 | /** 29 | * A #GtkToggleToolButton is a #GtkToolItem that contains a toggle 30 | * button. 31 | * 32 | * Use gtk_toggle_tool_button_new() to create a new GtkToggleToolButton. 33 | * 34 | * # CSS nodes 35 | * 36 | * GtkToggleToolButton has a single CSS node with name togglebutton. 37 | */ 38 | @GtkDsl 39 | open class ToggleToolButton internal constructor(override val widgetPtr: CPointer? = 40 | null) : ToolButton() { 41 | private val self: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | val toggleToolButton: CPointer? 45 | get() = widgetPtr!!.reinterpret() 46 | 47 | val onToggled: Signal?, COpaquePointer?) -> 48 | Unit>> by lazy { Signal?, 49 | COpaquePointer?) -> Unit>>(widgetPtr!!, this, "toggled", 50 | staticCFunction(::ToggleToolButton_onToggled_Handler)) } 51 | 52 | /** 53 | * Queries a #GtkToggleToolButton and returns its current state. 54 | * Returns %TRUE if the toggle button is pressed in and %FALSE if it is raised. 55 | * 56 | * Sets the status of the toggle tool button. Set to %TRUE if you 57 | * want the GtkToggleButton to be “pressed in”, and %FALSE to raise it. 58 | * This action causes the toggled signal to be emitted. */ 59 | var active: Boolean 60 | get() = gtk_toggle_tool_button_get_active(self) != 0 61 | set(value) { 62 | gtk_toggle_tool_button_set_active(self, if (value) gtk_true() else gtk_false()) 63 | } 64 | 65 | /** 66 | * Returns a new #GtkToggleToolButton */ 67 | constructor() : this(gtk_toggle_tool_button_new()?.reinterpret()) 68 | } 69 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/gtk3/Viewport.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GdkWindow 7 | import libgtk3.GtkAdjustment 8 | import libgtk3.GtkShadowType 9 | import libgtk3.GtkViewport 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_viewport_get_bin_window 12 | import libgtk3.gtk_viewport_get_shadow_type 13 | import libgtk3.gtk_viewport_get_view_window 14 | import libgtk3.gtk_viewport_new 15 | import libgtk3.gtk_viewport_set_shadow_type 16 | 17 | inline fun Container.viewport( 18 | hadjustment: CPointer, 19 | vadjustment: CPointer, 20 | init: Viewport.() -> Unit = {} 21 | ): Viewport = Viewport(hadjustment, vadjustment).apply { init(); this@viewport.add(this) } 22 | 23 | /** 24 | * The #GtkViewport widget acts as an adaptor class, implementing 25 | * scrollability for child widgets that lack their own scrolling 26 | * capabilities. Use GtkViewport to scroll child widgets such as 27 | * #GtkGrid, #GtkBox, and so on. 28 | * 29 | * If a widget has native scrolling abilities, such as #GtkTextView, 30 | * #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow 31 | * with gtk_container_add(). If a widget does not, you must first add the 32 | * widget to a #GtkViewport, then add the viewport to the scrolled window. 33 | * gtk_container_add() does this automatically if a child that does not 34 | * implement #GtkScrollable is added to a #GtkScrolledWindow, so you can 35 | * ignore the presence of the viewport. 36 | * 37 | * The GtkViewport will start scrolling content only if allocated less 38 | * than the child widget’s minimum size in a given orientation. 39 | * 40 | * # CSS nodes 41 | * 42 | * GtkViewport has a single CSS node with name viewport.Gets the bin window of the #GtkViewport.Gets 43 | the view window of the #GtkViewport. 44 | */ 45 | @GtkDsl 46 | open class Viewport internal constructor(override val widgetPtr: CPointer? = null) : 47 | Bin() { 48 | private val self: CPointer? 49 | get() = widgetPtr!!.reinterpret() 50 | 51 | val viewport: CPointer? 52 | get() = widgetPtr!!.reinterpret() 53 | 54 | val binWindow: CPointer 55 | get() = gtk_viewport_get_bin_window(self)!!.reinterpret() 56 | 57 | /** 58 | * Gets the shadow type of the #GtkViewport. See 59 | * gtk_viewport_set_shadow_type(). 60 | * 61 | * Sets the shadow type of the viewport. */ 62 | var shadowType: GtkShadowType 63 | get() = gtk_viewport_get_shadow_type(self) 64 | set(value) { 65 | gtk_viewport_set_shadow_type(self, value) 66 | } 67 | 68 | val viewWindow: CPointer 69 | get() = gtk_viewport_get_view_window(self)!!.reinterpret() 70 | 71 | /** 72 | * Creates a new #GtkViewport with the given adjustments, or with default 73 | * adjustments if none are given. */ 74 | constructor(hadjustment: CPointer, vadjustment: CPointer) : 75 | this(gtk_viewport_new(hadjustment?.reinterpret(), 76 | vadjustment?.reinterpret())?.reinterpret()) 77 | } 78 | -------------------------------------------------------------------------------- /gtk3/src/linuxX64Main/kotlin/helpers.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.* 4 | 5 | fun CPointer>?.toList(): List { 6 | if (this == null) return emptyList() 7 | val result = mutableListOf() 8 | var i = 0 9 | while (true) { 10 | val it = this[i] ?: break 11 | result += it.toKString() 12 | i++ 13 | } 14 | return result 15 | } 16 | -------------------------------------------------------------------------------- /gtk3/src/nativeInterop/cinterop/gtk3.def: -------------------------------------------------------------------------------- 1 | package = libgtk3 2 | headers = gtk/gtk.h gtk/gtkx.h gdk-pixbuf/gdk-pixbuf.h 3 | headerFilter = gtk/* gdk/* gdk-pixbuf/* gobject/* gio/* 4 | compilerOpts = -I/usr/include -I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/x86_64-linux-gnu/ -I/usr/include/gdk-pixbuf-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/lib/glib-2.0/include -I/usr/lib64/glib-2.0/include 5 | linkerOpts = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 6 | -------------------------------------------------------------------------------- /kngtk-generator/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.3.21" 3 | } 4 | 5 | group = "kngtk-generator" 6 | version = "0.1" 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | implementation(kotlin("stdlib-jdk8")) 14 | implementation("com.squareup", "kotlinpoet", "1.0.1") 15 | implementation("org.jdom", "jdom2", "2.0.6") 16 | 17 | testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.4.0") 18 | testImplementation("org.hamcrest", "hamcrest", "2.1") 19 | } 20 | -------------------------------------------------------------------------------- /kngtk-generator/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /kngtk-generator/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kropp/kotlin-native-gtk/4f9b2ffd4b71c69a077f4689719b56fe18f7b1d9/kngtk-generator/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kngtk-generator/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /kngtk-generator/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /kngtk-generator/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kngtk-generator' 2 | 3 | -------------------------------------------------------------------------------- /kngtk-generator/src/main/kotlin/kotlinpoetdsl.kt: -------------------------------------------------------------------------------- 1 | import com.squareup.kotlinpoet.* 2 | 3 | fun FileSpec.Builder.build(init: FileSpec.Builder.() -> Unit) = apply(init).build() 4 | 5 | fun FileSpec.Builder.addType(name: String, init: TypeSpec.Builder.() -> Unit) { 6 | addType(TypeSpec.classBuilder(name).apply(init).build()) 7 | } 8 | 9 | fun FileSpec.Builder.addFunction(name: String, init: FunSpec.Builder.() -> Unit) { 10 | addFunction(FunSpec.builder(name).apply(init).build()) 11 | } 12 | 13 | fun TypeSpec.Builder.addFunction(name: String, init: FunSpec.Builder.() -> Unit) { 14 | addFunction(FunSpec.builder(name).apply(init).build()) 15 | } 16 | 17 | fun TypeSpec.Builder.primaryConstructor(init: FunSpec.Builder.() -> Unit) { 18 | primaryConstructor(FunSpec.constructorBuilder().apply(init).build()) 19 | } 20 | 21 | fun TypeSpec.Builder.ctr(init: FunSpec.Builder.() -> Unit) { 22 | addFunction(FunSpec.constructorBuilder().apply(init).build()) 23 | } 24 | 25 | fun TypeSpec.Builder.addVarProperty(name: String, type: TypeName, init: PropertySpec.Builder.() -> Unit) { 26 | addProperty(PropertySpec.builder(name, type).mutable(true).apply(init).build()) 27 | } 28 | 29 | fun PropertySpec.Builder.getter(init: FunSpec.Builder.() -> Unit) { 30 | getter(FunSpec.getterBuilder().apply(init).build()) 31 | } 32 | fun PropertySpec.Builder.setter(type: TypeName, init: FunSpec.Builder.() -> Unit) { 33 | setter(FunSpec.setterBuilder().addParameter("value", type).apply(init).build()) 34 | } 35 | 36 | fun TypeSpec.Builder.addProperty(name: String, type: TypeName, init: FunSpec.Builder.() -> Unit) { 37 | addProperty(PropertySpec.builder(name.validate(), type).getter(FunSpec.getterBuilder().apply(init).build()).build()) 38 | } 39 | 40 | fun TypeSpec.Builder.addPrivateProperty(name: String, type: TypeName, init: FunSpec.Builder.() -> Unit) { 41 | addProperty(PropertySpec.builder(name, type, KModifier.PRIVATE).getter(FunSpec.getterBuilder().apply(init).build()).build()) 42 | } 43 | 44 | private fun String.validate() = when(this) { 45 | "object" -> "obj" 46 | else -> this 47 | } -------------------------------------------------------------------------------- /kngtk-generator/src/main/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | import org.jdom2.input.SAXBuilder 2 | import java.io.File 3 | 4 | const val basePath = "/usr/share/gir-1.0/" 5 | 6 | object Generator { 7 | @JvmStatic 8 | fun main(args: Array) { 9 | val gdkGir = SAXBuilder().build(File(basePath + "Gdk-3.0.gir")) 10 | val gtkGir = SAXBuilder().build(File(basePath + "Gtk-3.0.gir")) 11 | 12 | val enums = allEnums(gdkGir, gtkGir) 13 | 14 | gtkGir.rootElement.getChild("namespace", introspectionNs)?.let { ns -> 15 | ns.getChildren("class", introspectionNs)?.forEach { 16 | if (it.shouldGenerateBindingClass()) { 17 | it.processClass(enums)?.writeTo(File("../gtk3/src/linuxX64Main/kotlin")) 18 | } 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /kngtk-generator/src/main/kotlin/types.kt: -------------------------------------------------------------------------------- 1 | import com.squareup.kotlinpoet.* 2 | import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy 3 | import org.jdom2.Document 4 | import org.jdom2.Namespace 5 | 6 | val introspectionNs = Namespace.getNamespace("http://www.gtk.org/introspection/core/1.0") 7 | val cNs = Namespace.getNamespace("http://www.gtk.org/introspection/c/1.0") 8 | val glibNs = Namespace.getNamespace("http://www.gtk.org/introspection/glib/1.0") 9 | 10 | const val NS = "gtk3" 11 | const val LIB = "libgtk3" 12 | 13 | const val CINTEROP = "kotlinx.cinterop" 14 | 15 | val STRING = String::class.asClassName() 16 | 17 | val LIST = ClassName("kotlin.collections", "List") 18 | val CPointer = ClassName(CINTEROP, "CPointer") 19 | val ByteVar = ClassName(CINTEROP, "ByteVar") 20 | val ByteVarPtr = CPointer.parameterizedBy(ByteVar) 21 | val CPointed = ClassName(CINTEROP, "CPointed") 22 | val COpaquePointer = ClassName(CINTEROP, "COpaquePointer") 23 | val CFunction = ClassName(CINTEROP, "CFunction") 24 | val TypeName.ptr get() = CPointer.parameterizedBy(this) 25 | val GtkWidget = ClassName(LIB, "GtkWidget") 26 | val Widget = ClassName(NS, "Widget") 27 | val Container = ClassName(NS, "Container") 28 | val Signal = ClassName(NS, "Signal") 29 | val Signal1 = ClassName(NS, "Signal1") 30 | val Signal2 = ClassName(NS, "Signal2") 31 | val Signal3 = ClassName(NS, "Signal3") 32 | val Signal4 = ClassName(NS, "Signal4") 33 | val Signal5 = ClassName(NS, "Signal5") 34 | val Signal6 = ClassName(NS, "Signal6") 35 | val Dsl = ClassName(NS, "GtkDsl") 36 | 37 | fun FileSpec.Builder.convertTypeTo(expr: String, type: TypeName) = when { 38 | type == STRING -> { 39 | addImport(CINTEROP, "toKString") 40 | "$expr?.toKString() ?: \"\"" 41 | } 42 | type == BOOLEAN -> "$expr·!=·0" 43 | (type as? ParameterizedTypeName)?.rawType == LIST -> "$expr.toList()" 44 | (type as? ParameterizedTypeName)?.rawType == CPointer -> { 45 | addImport(CINTEROP, "reinterpret") 46 | "$expr!!.reinterpret()" 47 | } 48 | else -> expr 49 | } 50 | 51 | fun FileSpec.Builder.convertTypeFrom(expr: String, type: TypeName?, convertBoolean: Boolean = true) = when { 52 | type == BOOLEAN && convertBoolean -> { 53 | addImport(LIB, "gtk_true", "gtk_false") 54 | "if·($expr)·gtk_true()·else·gtk_false()" 55 | } 56 | type == ByteVarPtr -> { 57 | addImport(CINTEROP, "toKString") 58 | "$expr.toKString()" 59 | } 60 | (type as? ParameterizedTypeName)?.rawType == LIST -> { 61 | addImport(CINTEROP, "memScoped") 62 | addImport(CINTEROP, "cstr") 63 | addImport(CINTEROP, "ptr") 64 | addImport(CINTEROP, "toCValues") 65 | "memScoped { ($expr.map { it.cstr.ptr } + listOf(null)).toCValues() }" 66 | } 67 | (type as? ParameterizedTypeName)?.rawType == CPointer -> { 68 | addImport(CINTEROP, "reinterpret") 69 | "$expr?.reinterpret()" 70 | } 71 | (type as? ClassName)?.packageName == NS -> "$expr.widgetPtr?.reinterpret()" 72 | else -> expr 73 | } 74 | 75 | internal fun allEnums(vararg docs: Document) = docs.flatMap { 76 | it.rootElement.getChild("namespace", introspectionNs)?.children?.filter { it.name == "enumeration" || it.name == "bitfield" } ?: emptyList() 77 | }.map { 78 | it.getAttribute("name").value to it.getAttribute("type-name", glibNs).value.toTypeName() 79 | }.toMap() 80 | -------------------------------------------------------------------------------- /kngtk-generator/src/test/kotlin/GeneratorTest.kt: -------------------------------------------------------------------------------- 1 | import org.jdom2.input.SAXBuilder 2 | import org.junit.jupiter.api.Assertions.assertEquals 3 | import org.junit.jupiter.api.Test 4 | import java.io.File 5 | 6 | class GeneratorTest { 7 | @Test fun properties() = doTest("properties") 8 | @Test fun enumparam() = doTest("enumparam") 9 | 10 | private val testDataPath = "testData/generator" 11 | 12 | private fun doTest(name: String) { 13 | val actual = StringBuilder() 14 | val document = SAXBuilder().build(File("$testDataPath/$name.gir")) 15 | document.rootElement.getChild("namespace", introspectionNs)?.let { ns -> 16 | ns.getChildren("class", introspectionNs)?.forEach { 17 | it.processClass(allEnums(document))?.writeTo(actual) 18 | } 19 | } 20 | assertEquals(File("$testDataPath/$name.kt").readText(), actual.toString()) 21 | } 22 | } -------------------------------------------------------------------------------- /kngtk-generator/testData/generator/enumparam.gir: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 15 | Represents the orientation of widgets and other objects which can be switched 16 | between horizontal and vertical orientation on the fly, like #GtkToolbar or 17 | #GtkGesturePan. 18 | 22 | The element is in horizontal orientation. 23 | 24 | 28 | The element is in vertical orientation. 29 | 30 | 31 | 38 | 39 | 40 | 41 | 42 | Creates a new scrollbar with the given orientation. 43 | 44 | the new #GtkScrollbar. 45 | 46 | 47 | 48 | 49 | the scrollbar’s orientation. 50 | 51 | 52 | 56 | the #GtkAdjustment to use, or %NULL to create a new adjustment. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /kngtk-generator/testData/generator/enumparam.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | 3 | package gtk3 4 | 5 | import kotlin.ExperimentalUnsignedTypes 6 | import kotlin.Suppress 7 | import kotlin.Unit 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.reinterpret 10 | import libgtk3.GtkAdjustment 11 | import libgtk3.GtkOrientation 12 | import libgtk3.GtkScrollbar 13 | import libgtk3.GtkWidget 14 | import libgtk3.gtk_scrollbar_new 15 | 16 | @ExperimentalUnsignedTypes 17 | inline fun Container.scrollbar( 18 | orientation: GtkOrientation, 19 | adjustment: CPointer, 20 | init: Scrollbar.() -> Unit = {} 21 | ): Scrollbar = Scrollbar(orientation, adjustment).apply { init(); this@scrollbar.add(this) } 22 | 23 | @GtkDsl 24 | @ExperimentalUnsignedTypes 25 | open class Scrollbar internal constructor(override val widgetPtr: CPointer? = null) : 26 | Range() { 27 | private val self: CPointer? 28 | get() = widgetPtr!!.reinterpret() 29 | 30 | val scrollbar: CPointer? 31 | get() = widgetPtr!!.reinterpret() 32 | 33 | /** 34 | * Creates a new scrollbar with the given orientation. */ 35 | constructor(orientation: GtkOrientation, adjustment: CPointer) : 36 | this(gtk_scrollbar_new(orientation, adjustment?.reinterpret())?.reinterpret()) 37 | } 38 | -------------------------------------------------------------------------------- /kngtk-generator/testData/generator/properties.gir: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 18 | 21 | Returns the string which are displayed in the authors tab 22 | of the secondary credits dialog. 23 | 24 | A 25 | %NULL-terminated string array containing the authors. The array is 26 | owned by the about dialog and must not be modified. 27 | 28 | 29 | 30 | 31 | 32 | 33 | a #GtkAboutDialog 34 | 35 | 36 | 37 | 38 | 41 | Sets the strings which are displayed in the authors tab 42 | of the secondary credits dialog. 43 | 44 | 45 | 46 | 47 | 48 | a #GtkAboutDialog 49 | 50 | 51 | 52 | a %NULL-terminated array of strings 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /kngtk-generator/testData/generator/properties.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | 3 | package gtk3 4 | 5 | import kotlin.ExperimentalUnsignedTypes 6 | import kotlin.String 7 | import kotlin.Suppress 8 | import kotlin.collections.List 9 | import kotlinx.cinterop.CPointer 10 | import kotlinx.cinterop.cstr 11 | import kotlinx.cinterop.memScoped 12 | import kotlinx.cinterop.ptr 13 | import kotlinx.cinterop.reinterpret 14 | import kotlinx.cinterop.toCValues 15 | import libgtk3.GtkAboutDialog 16 | import libgtk3.gtk_about_dialog_get_authors 17 | import libgtk3.gtk_about_dialog_set_authors 18 | 19 | @GtkDsl 20 | @ExperimentalUnsignedTypes 21 | abstract class AboutDialog : Dialog() { 22 | private val self: CPointer 23 | get() = widgetPtr!!.reinterpret() 24 | 25 | /** 26 | * Returns the string which are displayed in the authors tab 27 | * of the secondary credits dialog. 28 | * 29 | * Sets the strings which are displayed in the authors tab 30 | * of the secondary credits dialog. */ 31 | var authors: List 32 | get() = gtk_about_dialog_get_authors(self).toList() 33 | set(value) { 34 | gtk_about_dialog_set_authors(self, memScoped { (value.map { it.cstr.ptr } + 35 | listOf(null)).toCValues() }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build-debug 2 | .gradle 3 | .idea 4 | build -------------------------------------------------------------------------------- /sample/KotlinCMakeModule/CMakeDetermineKotlinCompiler.cmake: -------------------------------------------------------------------------------- 1 | if (NOT CMAKE_Kotlin_COMPILER) 2 | #TODO determine Kotlin compiler in not hardcoded way 3 | set(Kotlin_BIN_PATH 4 | $ENV{HOME}/.konan/kotlin-native-macos-0.3/bin 5 | $ENV{HOME}/.konan/kotlin-native-linux-0.3/bin 6 | $ENV{HOME}/.konan/kotlin-native-macos-0.3.1/bin 7 | $ENV{HOME}/.konan/kotlin-native-linux-0.3.1/bin 8 | $ENV{HOME}/.konan/kotlin-native-macos-0.3.2/bin 9 | $ENV{HOME}/.konan/kotlin-native-linux-0.3.2/bin 10 | ) 11 | 12 | 13 | if (CMAKE_Kotlin_COMPILER_INIT) 14 | set(CMAKE_Kotlin_COMPILER ${CMAKE_Kotlin_COMPILER_INIT} CACHE PATH "Kotlin Compiler") 15 | else () 16 | find_program(CMAKE_Kotlin_COMPILER 17 | NAMES konanc 18 | PATHS ${Kotlin_BIN_PATH} 19 | ) 20 | endif () 21 | 22 | 23 | if (CMAKE_Kotlin_CINTEROP_INIT) 24 | set(CMAKE_Kotlin_CINTEROP ${CMAKE_Kotlin_CINTEROP_INIT} CACHE PATH "Kotlin Cinterop") 25 | else () 26 | find_program(CMAKE_Kotlin_CINTEROP 27 | NAMES cinterop 28 | PATHS ${Kotlin_BIN_PATH} 29 | ) 30 | endif () 31 | endif () 32 | 33 | mark_as_advanced(CMAKE_Kotlin_COMPILER) 34 | 35 | configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeKotlinCompiler.cmake.in 36 | ${CMAKE_PLATFORM_INFO_DIR}/CMakeKotlinCompiler.cmake @ONLY) 37 | 38 | set(CMAKE_Kotlin_COMPILER_ENV_VAR "KOTLIN_COMPILER") -------------------------------------------------------------------------------- /sample/KotlinCMakeModule/CMakeKotlinCompiler.cmake.in: -------------------------------------------------------------------------------- 1 | set(CMAKE_Kotlin_COMPILER "@CMAKE_Kotlin_COMPILER@") 2 | set(CMAKE_Kotlin_COMPILER_LOADED 1) 3 | 4 | set(CMAKE_Kotlin_SOURCE_FILE_EXTENSIONS kt;def) 5 | set(CMAKE_Kotlin_COMPILER_ENV_VAR "KOTLIN_COMPILER") -------------------------------------------------------------------------------- /sample/KotlinCMakeModule/CMakeTestKotlinCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_Kotlin_COMPILER_WORKS 1 CACHE INTERNAL "") #TODO do we really need to test something? -------------------------------------------------------------------------------- /sample/KotlinCMakeModule/version: -------------------------------------------------------------------------------- 1 | 2b96f239e8de124077142af69987b8ad3b30cfcd 2 | -------------------------------------------------------------------------------- /sample/README.md: -------------------------------------------------------------------------------- 1 | Kotlin/Native GTK bindings preview 2 | ====== 3 | 4 | This is a preview sample of a GTK wrapper library for Kotlin/Native 5 | 6 | To test it open project from `CMakeLists.txt` in CLion with Kotlin/Native plugin installed. 7 | 8 | Then run `main` function from `main.kt` 9 | 10 | It is only tested on Ubuntu 18.04, other distributions and OS will be supported in the future. 11 | 12 | Don't forget to install GTK dev dependencies before: 13 | `sudo apt install libgtk-3-dev` 14 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | maven { 5 | url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" 6 | } 7 | } 8 | 9 | dependencies { 10 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.7.1" 11 | } 12 | } 13 | 14 | apply plugin: 'konan' 15 | 16 | konan { 17 | targets = ['linux'] 18 | jvmArgs = ['-Xmx8g'] 19 | } 20 | 21 | def includePrefixes = [ '/usr/include' ] 22 | 23 | konanArtifacts { 24 | interop('libgtk3') { 25 | includePrefixes.each { 26 | includeDirs "$it/atk-1.0", "$it/gdk-pixbuf-2.0", "$it/cairo", "$it/pango-1.0", "$it/gtk-3.0", "$it/glib-2.0" 27 | } 28 | includeDirs '/opt/local/lib/glib-2.0/include', '/usr/lib/x86_64-linux-gnu/glib-2.0/include', '/usr/local/lib/glib-2.0/include' 29 | } 30 | 31 | program('HackathonDemo') { 32 | libraries { 33 | artifact 'libgtk3' 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /sample/src/main/c_interop/libgtk3.def: -------------------------------------------------------------------------------- 1 | headers = gtk/gtk.h gtk/gtkx.h gdk-pixbuf/gdk-pixbuf.h 2 | headerFilter = gtk/* gdk/* gdk-pixbuf/* gobject/* gio/* 3 | compilerOpts.linux = -I/usr/include -I/usr/include/x86_64-linux-gnu/ -I/usr/include/gdk-pixbuf-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/lib/glib-2.0/include -I/usr/lib64/glib-2.0/include 4 | linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -------------------------------------------------------------------------------- /sample/src/main/kotlin/Application.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.G_APPLICATION_FLAGS_NONE 5 | import libgtk3.g_application_run 6 | import libgtk3.g_object_unref 7 | import libgtk3.gtk_application_new 8 | 9 | fun Application_onActivate_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 10 | data?.asStableRef()?.get()?.onActivate?.invoke() 11 | } 12 | 13 | class Application(val id: String) { 14 | private val app = gtk_application_new(id, G_APPLICATION_FLAGS_NONE)!! 15 | 16 | val onActivate = Signal(app, this, "activate", staticCFunction(::Application_onActivate_Handler)) 17 | 18 | fun run(args: Array): Int { 19 | val status = memScoped { 20 | g_application_run(app.reinterpret(), args.size, args.map { it.cstr.ptr }.toCValues()) 21 | } 22 | g_object_unref(app) 23 | return status 24 | 25 | } 26 | 27 | fun createWindow(init: ApplicationWindow.() -> Unit = {}) = ApplicationWindow(app).apply(init) 28 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/Dsl.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import libgtk3.* 4 | 5 | @DslMarker 6 | annotation class GtkDsl 7 | 8 | inline fun Container.vbox(init: Box.() -> Unit) = box(GtkOrientation.GTK_ORIENTATION_VERTICAL, 0, init) 9 | inline fun Container.hbox(init: Box.() -> Unit) = box(GtkOrientation.GTK_ORIENTATION_HORIZONTAL, 0, init) 10 | 11 | inline fun Container.vbbox(init: ButtonBox.() -> Unit) = buttonBox(GtkOrientation.GTK_ORIENTATION_VERTICAL, init) 12 | inline fun Container.hbbox(init: ButtonBox.() -> Unit) = buttonBox(GtkOrientation.GTK_ORIENTATION_HORIZONTAL, init) 13 | 14 | inline fun window(init: Window.() -> Unit) = Window(GtkWindowType.GTK_WINDOW_TOPLEVEL).apply(init) 15 | 16 | inline fun Window.headerBar(init: HeaderBar.() -> Unit) = 17 | HeaderBar().apply { 18 | init() 19 | this@headerBar.titlebar = widgetPtr 20 | } 21 | 22 | inline fun Container.imageButton(id: String, init: Button.() -> Unit = {}) = button { 23 | image = gtk_image_new_from_icon_name(id, GtkIconSize.GTK_ICON_SIZE_SMALL_TOOLBAR) 24 | val context = gtk_widget_get_style_context(widgetPtr) 25 | gtk_style_context_add_class(context, "image-button") 26 | apply(init) 27 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/TreeModel.kt: -------------------------------------------------------------------------------- 1 | import kotlinx.cinterop.* 2 | import libgtk3.* 3 | 4 | class IconViewModel { 5 | val store = gtk_list_store_new(2, G_TYPE_STRING, libgtk3.gdk_pixbuf_get_type()) 6 | private val paths = mutableListOf() 7 | 8 | fun append(path: String, icon: String) { 9 | paths.add(path) 10 | memScoped { 11 | val iter = alloc() 12 | gtk_list_store_append(store, iter.ptr) 13 | val pixbuf = gdk_pixbuf_new_from_file(icon, null) 14 | gtk_list_store_set(store, iter.ptr, 0, path.cstr, 1, pixbuf, -1) 15 | g_object_unref(pixbuf) 16 | } 17 | } 18 | 19 | fun reset() { 20 | gtk_list_store_clear(store) 21 | paths.clear() 22 | } 23 | 24 | fun getByPath(path: CPointer?): String? { 25 | val indices = gtk_tree_path_get_indices(path) ?: return null 26 | val i = indices[0] 27 | return paths[i] 28 | } 29 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/fileManager.kt: -------------------------------------------------------------------------------- 1 | import gtk3.* 2 | import kotlinx.cinterop.CPointer 3 | import kotlinx.cinterop.reinterpret 4 | import kotlinx.cinterop.toKString 5 | import libgtk3.GFile 6 | import platform.posix.system 7 | 8 | private const val folder = "/usr/share/icons/Humanity/places/32/folder.svg" 9 | private const val file = "/usr/share/icons/Humanity/mimes/32/office-document.svg" 10 | 11 | var backButton: Button? = null 12 | var fwdButton: Button? = null 13 | var headerBar: HeaderBar? = null 14 | 15 | val iconViewModel = IconViewModel() 16 | val paths = mutableListOf() 17 | var current = -1 18 | 19 | fun buildModel(directory: String) { 20 | iconViewModel.reset() 21 | files(directory).forEach { 22 | iconViewModel.append(it, if (isDirectory("$directory/$it")) folder else file) 23 | } 24 | } 25 | 26 | fun openFile(path: String) { 27 | system("xdg-open '$path'") 28 | } 29 | 30 | fun navigate(path: String) { 31 | current++ 32 | // println("Navigating to $path") 33 | // println("Navigation stack ($current): ${paths.joinToString()}") 34 | while (paths.size > current) { 35 | paths.removeAt(current) 36 | } 37 | paths.add(path) 38 | update(path) 39 | } 40 | 41 | private fun update(path: String) { 42 | buildModel(path) 43 | headerBar?.title = path 44 | backButton?.sensitive = current > 0 45 | fwdButton?.sensitive = current < paths.size - 1 46 | } 47 | 48 | fun navigateBack() { 49 | if (current > 0) { 50 | current-- 51 | update(paths[current]) 52 | } 53 | } 54 | 55 | fun navigateForward() { 56 | if (current < paths.size - 1) { 57 | current++ 58 | update(paths[current]) 59 | } 60 | } 61 | 62 | fun Application.fileManager() = createWindow { 63 | setDefaultSize(800, 600) 64 | iconName = "user-home" 65 | 66 | headerBar = headerBar { 67 | showCloseButton = true 68 | 69 | backButton = imageButton("gtk-go-back") { 70 | onClicked += { navigateBack() } 71 | } 72 | fwdButton = imageButton("gtk-go-forward") { 73 | onClicked += { navigateForward() } 74 | } 75 | } 76 | 77 | hbox { 78 | placesSidebar { 79 | maxContentWidth = 200 80 | onOpenLocation += { file: CPointer?, _ -> 81 | libgtk3.g_file_get_path(file)?.toKString()?.let { navigate(it) } 82 | } 83 | } 84 | scrolledWindow(null, null) { 85 | minContentWidth = 600 86 | iconView { 87 | model = iconViewModel.store?.reinterpret() 88 | textColumn = 0 89 | pixbufColumn = 1 90 | 91 | onItemActivated += { 92 | val name = iconViewModel.getByPath(it) 93 | val path = "${paths[current]}/$name" 94 | if (isDirectory(path)) { 95 | navigate(path) 96 | } else { 97 | openFile(path) 98 | } 99 | } 100 | } 101 | } 102 | } 103 | 104 | navigate("/home") 105 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/files.kt: -------------------------------------------------------------------------------- 1 | import kotlinx.cinterop.* 2 | import platform.posix.* 3 | import kotlin.coroutines.experimental.buildSequence 4 | 5 | fun files(directory: String) = buildSequence { 6 | val dir = opendir(directory) 7 | while (true) { 8 | val entry = readdir(dir) ?: break 9 | val name = entry.pointed.d_name.toKString() 10 | if (name == "." || name == "..") continue 11 | yield(name) 12 | } 13 | closedir(dir) 14 | } 15 | 16 | fun isDirectory(filename: String) = memScoped { 17 | val s = alloc() 18 | if (stat(filename, s.ptr) == 0) { 19 | s.st_mode and S_IFMT == S_IFDIR 20 | } else false 21 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ActionBar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkActionBar 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_action_bar_get_center_widget 9 | import libgtk3.gtk_action_bar_new 10 | import libgtk3.gtk_action_bar_pack_end 11 | import libgtk3.gtk_action_bar_pack_start 12 | import libgtk3.gtk_action_bar_set_center_widget 13 | 14 | inline fun Container.actionBar(init: ActionBar.() -> Unit = {}): ActionBar = ActionBar().apply { init(); this@actionBar.add(this) } 15 | 16 | /** 17 | * GtkActionBar is designed to present contextual actions. It is 18 | * expected to be displayed below the content and expand horizontally 19 | * to fill the area. 20 | * 21 | * It allows placing children at the start or the end. In addition, it 22 | * contains an internal centered box which is centered with respect to 23 | * the full width of the box, even if the children at either side take 24 | * up different amounts of space. 25 | * 26 | * # CSS nodes 27 | * 28 | * GtkActionBar has a single CSS node with name actionbar. */ 29 | @GtkDsl 30 | open class ActionBar internal constructor(override val widgetPtr: CPointer? = null) : Bin() { 31 | private val self: CPointer? 32 | get() = widgetPtr!!.reinterpret() 33 | 34 | val actionBar: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | var centerWidget: CPointer? 38 | /** 39 | * Retrieves the center bar widget of the bar. */ 40 | get() = gtk_action_bar_get_center_widget(self)!!.reinterpret() 41 | /** 42 | * Sets the center widget for the #GtkActionBar. */ 43 | set(value) { 44 | gtk_action_bar_set_center_widget(self, value?.reinterpret()) 45 | } 46 | 47 | /** 48 | * Creates a new #GtkActionBar widget. */ 49 | constructor() : this(gtk_action_bar_new()?.reinterpret()) 50 | 51 | /** 52 | * Adds @child to @action_bar, packed with reference to the 53 | * end of the @action_bar. */ 54 | fun packEnd(child: CPointer?): Unit = gtk_action_bar_pack_end(self, child) 55 | 56 | /** 57 | * Adds @child to @action_bar, packed with reference to the 58 | * end of the @action_bar. */ 59 | fun packEnd(child: Widget): Unit = gtk_action_bar_pack_end(self, child.widgetPtr?.reinterpret()) 60 | 61 | /** 62 | * Adds @child to @action_bar, packed with reference to the 63 | * start of the @action_bar. */ 64 | fun packStart(child: CPointer?): Unit = gtk_action_bar_pack_start(self, child) 65 | 66 | /** 67 | * Adds @child to @action_bar, packed with reference to the 68 | * start of the @action_bar. */ 69 | fun packStart(child: Widget): Unit = gtk_action_bar_pack_start(self, child.widgetPtr?.reinterpret()) 70 | } 71 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/AppChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import kotlinx.cinterop.toKString 8 | import libgtk3.GFile 9 | import libgtk3.GtkAppChooserDialog 10 | import libgtk3.GtkDialogFlags 11 | import libgtk3.GtkWidget 12 | import libgtk3.GtkWindow 13 | import libgtk3.gtk_app_chooser_dialog_get_heading 14 | import libgtk3.gtk_app_chooser_dialog_get_widget 15 | import libgtk3.gtk_app_chooser_dialog_new 16 | import libgtk3.gtk_app_chooser_dialog_set_heading 17 | 18 | inline fun Container.appChooserDialog( 19 | parent: CPointer?, 20 | flags: GtkDialogFlags, 21 | file: CPointer?, 22 | init: AppChooserDialog.() -> Unit = {} 23 | ): AppChooserDialog = AppChooserDialog(parent, flags, file).apply { init(); this@appChooserDialog.add(this) } 24 | 25 | /** 26 | * #GtkAppChooserDialog shows a #GtkAppChooserWidget inside a #GtkDialog. 27 | * 28 | * Note that #GtkAppChooserDialog does not have any interesting methods 29 | * of its own. Instead, you should get the embedded #GtkAppChooserWidget 30 | * using gtk_app_chooser_dialog_get_widget() and call its methods if 31 | * the generic #GtkAppChooser interface is not sufficient for your needs. 32 | * 33 | * To set the heading that is shown above the #GtkAppChooserWidget, 34 | * use gtk_app_chooser_dialog_set_heading(). */ 35 | @GtkDsl 36 | open class AppChooserDialog internal constructor(override val widgetPtr: CPointer? = null) : Dialog() { 37 | private val self: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | val appChooserDialog: CPointer? 41 | get() = widgetPtr!!.reinterpret() 42 | 43 | var heading: String 44 | /** 45 | * Returns the text to display at the top of the dialog. */ 46 | get() = gtk_app_chooser_dialog_get_heading(self)?.toKString() ?: "" 47 | /** 48 | * Sets the text to display at the top of the dialog. 49 | * If the heading is not set, the dialog displays a default text. */ 50 | set(value) { 51 | gtk_app_chooser_dialog_set_heading(self, value) 52 | } 53 | 54 | val widget: CPointer? 55 | /** 56 | * Returns the #GtkAppChooserWidget of this dialog. */ 57 | get() = gtk_app_chooser_dialog_get_widget(self)!!.reinterpret() 58 | 59 | /** 60 | * Creates a new #GtkAppChooserDialog for the provided #GFile, 61 | * to allow the user to select an application for it. */ 62 | constructor( 63 | parent: CPointer?, 64 | flags: GtkDialogFlags, 65 | file: CPointer? 66 | ) : this(gtk_app_chooser_dialog_new(parent?.reinterpret(), flags, file?.reinterpret())?.reinterpret()) 67 | } 68 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/AspectFrame.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Float 5 | import kotlin.String 6 | import kotlin.Unit 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.reinterpret 9 | import libgtk3.GtkAspectFrame 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_aspect_frame_new 12 | import libgtk3.gtk_aspect_frame_set 13 | import libgtk3.gtk_false 14 | import libgtk3.gtk_true 15 | 16 | inline fun Container.aspectFrame( 17 | label: String, 18 | xalign: Float, 19 | yalign: Float, 20 | ratio: Float, 21 | obey_child: Boolean, 22 | init: AspectFrame.() -> Unit = {} 23 | ): AspectFrame = AspectFrame(label, xalign, yalign, ratio, obey_child).apply { init(); this@aspectFrame.add(this) } 24 | 25 | /** 26 | * The #GtkAspectFrame is useful when you want 27 | * pack a widget so that it can resize but always retains 28 | * the same aspect ratio. For instance, one might be 29 | * drawing a small preview of a larger image. #GtkAspectFrame 30 | * derives from #GtkFrame, so it can draw a label and 31 | * a frame around the child. The frame will be 32 | * “shrink-wrapped” to the size of the child. 33 | * 34 | * # CSS nodes 35 | * 36 | * GtkAspectFrame uses a CSS node with name frame. */ 37 | @GtkDsl 38 | open class AspectFrame internal constructor(override val widgetPtr: CPointer? = null) : Frame() { 39 | private val self: CPointer? 40 | get() = widgetPtr!!.reinterpret() 41 | 42 | val aspectFrame: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | /** 46 | * Create a new #GtkAspectFrame. */ 47 | constructor( 48 | label: String, 49 | xalign: Float, 50 | yalign: Float, 51 | ratio: Float, 52 | obey_child: Boolean 53 | ) : this(gtk_aspect_frame_new(label, xalign, yalign, ratio, if (obey_child) gtk_true() else gtk_false())?.reinterpret()) 54 | 55 | /** 56 | * Set parameters for an existing #GtkAspectFrame. */ 57 | fun set( 58 | xalign: Float, 59 | yalign: Float, 60 | ratio: Float, 61 | obey_child: Boolean 62 | ): Unit = gtk_aspect_frame_set(self, xalign, yalign, ratio, if (obey_child) gtk_true() else gtk_false()) 63 | } 64 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Bin.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkBin 6 | import libgtk3.GtkWidget 7 | import libgtk3.gtk_bin_get_child 8 | 9 | /** 10 | * The #GtkBin widget is a container with just one child. 11 | * It is not very useful itself, but it is useful for deriving subclasses, 12 | * since it provides common code needed for handling a single child widget. 13 | * 14 | * Many GTK+ widgets are subclasses of #GtkBin, including #GtkWindow, 15 | * #GtkButton, #GtkFrame, #GtkHandleBox or #GtkScrolledWindow. */ 16 | @GtkDsl 17 | abstract class Bin : Container() { 18 | private val self: CPointer 19 | get() = widgetPtr!!.reinterpret() 20 | 21 | val child: CPointer? 22 | /** 23 | * Gets the child of the #GtkBin, or %NULL if the bin contains 24 | * no child widget. The returned widget does not have a reference 25 | * added, so you do not need to unref it. */ 26 | get() = gtk_bin_get_child(self)!!.reinterpret() 27 | } 28 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/CheckButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkCheckButton 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_check_button_new 9 | 10 | inline fun Container.checkButton(init: CheckButton.() -> Unit = {}): CheckButton = CheckButton().apply { init(); this@checkButton.add(this) } 11 | 12 | /** 13 | * A #GtkCheckButton places a discrete #GtkToggleButton next to a widget, 14 | * (usually a #GtkLabel). See the section on #GtkToggleButton widgets for 15 | * more information about toggle/check buttons. 16 | * 17 | * The important signal ( #GtkToggleButton::toggled ) is also inherited from 18 | * #GtkToggleButton. 19 | * 20 | * # CSS nodes 21 | * 22 | * |[ 23 | * checkbutton 24 | * ├── check 25 | * ╰── 26 | * ]| 27 | * 28 | * A GtkCheckButton with indicator (see gtk_toggle_button_set_mode()) has a 29 | * main CSS node with name checkbutton and a subnode with name check. 30 | * 31 | * |[ 32 | * button.check 33 | * ├── check 34 | * ╰── 35 | * ]| 36 | * 37 | * A GtkCheckButton without indicator changes the name of its main node 38 | * to button and adds a .check style class to it. The subnode is invisible 39 | * in this case. */ 40 | @GtkDsl 41 | open class CheckButton internal constructor(override val widgetPtr: CPointer? = null) : ToggleButton() { 42 | private val self: CPointer? 43 | get() = widgetPtr!!.reinterpret() 44 | 45 | val checkButton: CPointer? 46 | get() = widgetPtr!!.reinterpret() 47 | 48 | /** 49 | * Creates a new #GtkCheckButton. */ 50 | constructor() : this(gtk_check_button_new()?.reinterpret()) 51 | } 52 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ColorButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import kotlinx.cinterop.toKString 12 | import libgtk3.GtkColorButton 13 | import libgtk3.GtkWidget 14 | import libgtk3.gtk_color_button_get_title 15 | import libgtk3.gtk_color_button_new 16 | import libgtk3.gtk_color_button_set_title 17 | 18 | inline fun Container.colorButton(init: ColorButton.() -> Unit = {}): ColorButton = ColorButton().apply { init(); this@colorButton.add(this) } 19 | 20 | private fun ColorButton_onColorSet_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 21 | data?.asStableRef()?.get()?.onColorSet?.invoke() 22 | } 23 | 24 | /** 25 | * The #GtkColorButton is a button which displays the currently selected 26 | * color and allows to open a color selection dialog to change the color. 27 | * It is suitable widget for selecting a color in a preference dialog. 28 | * 29 | * # CSS nodes 30 | * 31 | * GtkColorButton has a single CSS node with name button. To differentiate 32 | * it from a plain #GtkButton, it gets the .color style class. */ 33 | @GtkDsl 34 | open class ColorButton internal constructor(override val widgetPtr: CPointer? = null) : Button() { 35 | private val self: CPointer? 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | val colorButton: CPointer? 39 | get() = widgetPtr!!.reinterpret() 40 | 41 | val onColorSet: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "color-set", staticCFunction(::ColorButton_onColorSet_Handler)) } 42 | 43 | var title: String 44 | /** 45 | * Gets the title of the color selection dialog. */ 46 | get() = gtk_color_button_get_title(self)?.toKString() ?: "" 47 | /** 48 | * Sets the title for the color selection dialog. */ 49 | set(value) { 50 | gtk_color_button_set_title(self, value) 51 | } 52 | 53 | /** 54 | * Creates a new color button. 55 | * 56 | * This returns a widget in the form of a small button containing 57 | * a swatch representing the current selected color. When the button 58 | * is clicked, a color-selection dialog will open, allowing the user 59 | * to select a color. The swatch will be updated to reflect the new 60 | * color when the user finishes. */ 61 | constructor() : this(gtk_color_button_new()?.reinterpret()) 62 | } 63 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ColorChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkColorChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_color_chooser_dialog_new 11 | 12 | inline fun Container.colorChooserDialog( 13 | title: String, 14 | parent: CPointer?, 15 | init: ColorChooserDialog.() -> Unit = {} 16 | ): ColorChooserDialog = ColorChooserDialog(title, parent).apply { init(); this@colorChooserDialog.add(this) } 17 | 18 | /** 19 | * The #GtkColorChooserDialog widget is a dialog for choosing 20 | * a color. It implements the #GtkColorChooser interface. */ 21 | @GtkDsl 22 | open class ColorChooserDialog internal constructor(override val widgetPtr: CPointer? = null) : Dialog() { 23 | private val self: CPointer? 24 | get() = widgetPtr!!.reinterpret() 25 | 26 | val colorChooserDialog: CPointer? 27 | get() = widgetPtr!!.reinterpret() 28 | 29 | /** 30 | * Creates a new #GtkColorChooserDialog. */ 31 | constructor(title: String, parent: CPointer?) : this(gtk_color_chooser_dialog_new(title, parent?.reinterpret())?.reinterpret()) 32 | } 33 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ColorChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkColorChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_color_chooser_widget_new 9 | 10 | inline fun Container.colorChooserWidget(init: ColorChooserWidget.() -> Unit = {}): ColorChooserWidget = ColorChooserWidget().apply { init(); this@colorChooserWidget.add(this) } 11 | 12 | /** 13 | * The #GtkColorChooserWidget widget lets the user select a 14 | * color. By default, the chooser presents a predefined palette 15 | * of colors, plus a small number of settable custom colors. 16 | * It is also possible to select a different color with the 17 | * single-color editor. To enter the single-color editing mode, 18 | * use the context menu of any color of the palette, or use the 19 | * '+' button to add a new custom color. 20 | * 21 | * The chooser automatically remembers the last selection, as well 22 | * as custom colors. 23 | * 24 | * To change the initially selected color, use gtk_color_chooser_set_rgba(). 25 | * To get the selected color use gtk_color_chooser_get_rgba(). 26 | * 27 | * The #GtkColorChooserWidget is used in the #GtkColorChooserDialog 28 | * to provide a dialog for selecting colors. 29 | * 30 | * # CSS names 31 | * 32 | * GtkColorChooserWidget has a single CSS node with name colorchooser. */ 33 | @GtkDsl 34 | open class ColorChooserWidget internal constructor(override val widgetPtr: CPointer? = null) : Box() { 35 | private val self: CPointer? 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | val colorChooserWidget: CPointer? 39 | get() = widgetPtr!!.reinterpret() 40 | 41 | /** 42 | * Creates a new #GtkColorChooserWidget. */ 43 | constructor() : this(gtk_color_chooser_widget_new()?.reinterpret()) 44 | } 45 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/FlowBoxChild.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Int 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CFunction 7 | import kotlinx.cinterop.COpaquePointer 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import libgtk3.GtkFlowBoxChild 13 | import libgtk3.GtkWidget 14 | import libgtk3.gtk_flow_box_child_changed 15 | import libgtk3.gtk_flow_box_child_get_index 16 | import libgtk3.gtk_flow_box_child_is_selected 17 | import libgtk3.gtk_flow_box_child_new 18 | 19 | inline fun Container.flowBoxChild(init: FlowBoxChild.() -> Unit = {}): FlowBoxChild = FlowBoxChild().apply { init(); this@flowBoxChild.add(this) } 20 | 21 | private fun FlowBoxChild_onActivate_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 22 | data?.asStableRef()?.get()?.onActivate?.invoke() 23 | } 24 | 25 | @GtkDsl 26 | open class FlowBoxChild internal constructor(override val widgetPtr: CPointer? = null) : Bin() { 27 | private val self: CPointer? 28 | get() = widgetPtr!!.reinterpret() 29 | 30 | val flowBoxChild: CPointer? 31 | get() = widgetPtr!!.reinterpret() 32 | 33 | val onActivate: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "activate", staticCFunction(::FlowBoxChild_onActivate_Handler)) } 34 | 35 | val index: Int 36 | /** 37 | * Gets the current index of the @child in its #GtkFlowBox container. */ 38 | get() = gtk_flow_box_child_get_index(self) 39 | 40 | /** 41 | * Creates a new #GtkFlowBoxChild, to be used as a child 42 | * of a #GtkFlowBox. */ 43 | constructor() : this(gtk_flow_box_child_new()?.reinterpret()) 44 | 45 | /** 46 | * Marks @child as changed, causing any state that depends on this 47 | * to be updated. This affects sorting and filtering. 48 | * 49 | * Note that calls to this method must be in sync with the data 50 | * used for the sorting and filtering functions. For instance, if 51 | * the list is mirroring some external data set, and *two* children 52 | * changed in the external data set when you call 53 | * gtk_flow_box_child_changed() on the first child, the sort function 54 | * must only read the new data for the first of the two changed 55 | * children, otherwise the resorting of the children will be wrong. 56 | * 57 | * This generally means that if you don’t fully control the data 58 | * model, you have to duplicate the data that affects the sorting 59 | * and filtering functions into the widgets themselves. Another 60 | * alternative is to call gtk_flow_box_invalidate_sort() on any 61 | * model change, but that is more expensive. */ 62 | fun changed(): Unit = gtk_flow_box_child_changed(self) 63 | 64 | /** 65 | * Returns whether the @child is currently selected in its 66 | * #GtkFlowBox container. */ 67 | fun isSelected(): Boolean = gtk_flow_box_child_is_selected(self) != 0 68 | } 69 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/FontChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkFontChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_font_chooser_dialog_new 11 | 12 | inline fun Container.fontChooserDialog( 13 | title: String, 14 | parent: CPointer?, 15 | init: FontChooserDialog.() -> Unit = {} 16 | ): FontChooserDialog = FontChooserDialog(title, parent).apply { init(); this@fontChooserDialog.add(this) } 17 | 18 | /** 19 | * The #GtkFontChooserDialog widget is a dialog for selecting a font. 20 | * It implements the #GtkFontChooser interface. 21 | * 22 | * # GtkFontChooserDialog as GtkBuildable 23 | * 24 | * The GtkFontChooserDialog implementation of the #GtkBuildable 25 | * interface exposes the buttons with the names “select_button” 26 | * and “cancel_button”. */ 27 | @GtkDsl 28 | open class FontChooserDialog internal constructor(override val widgetPtr: CPointer? = null) : Dialog() { 29 | private val self: CPointer? 30 | get() = widgetPtr!!.reinterpret() 31 | 32 | val fontChooserDialog: CPointer? 33 | get() = widgetPtr!!.reinterpret() 34 | 35 | /** 36 | * Creates a new #GtkFontChooserDialog. */ 37 | constructor(title: String, parent: CPointer?) : this(gtk_font_chooser_dialog_new(title, parent?.reinterpret())?.reinterpret()) 38 | } 39 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/FontChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkFontChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_font_chooser_widget_new 9 | 10 | inline fun Container.fontChooserWidget(init: FontChooserWidget.() -> Unit = {}): FontChooserWidget = FontChooserWidget().apply { init(); this@fontChooserWidget.add(this) } 11 | 12 | /** 13 | * The #GtkFontChooserWidget widget lists the available fonts, 14 | * styles and sizes, allowing the user to select a font. It is 15 | * used in the #GtkFontChooserDialog widget to provide a 16 | * dialog box for selecting fonts. 17 | * 18 | * To set the font which is initially selected, use 19 | * gtk_font_chooser_set_font() or gtk_font_chooser_set_font_desc(). 20 | * 21 | * To get the selected font use gtk_font_chooser_get_font() or 22 | * gtk_font_chooser_get_font_desc(). 23 | * 24 | * To change the text which is shown in the preview area, use 25 | * gtk_font_chooser_set_preview_text(). 26 | * 27 | * # CSS nodes 28 | * 29 | * GtkFontChooserWidget has a single CSS node with name fontchooser. */ 30 | @GtkDsl 31 | open class FontChooserWidget internal constructor(override val widgetPtr: CPointer? = null) : Box() { 32 | private val self: CPointer? 33 | get() = widgetPtr!!.reinterpret() 34 | 35 | val fontChooserWidget: CPointer? 36 | get() = widgetPtr!!.reinterpret() 37 | 38 | /** 39 | * Creates a new #GtkFontChooserWidget. */ 40 | constructor() : this(gtk_font_chooser_widget_new()?.reinterpret()) 41 | } 42 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Invisible.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkInvisible 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_invisible_new 9 | 10 | inline fun Container.invisible(init: Invisible.() -> Unit = {}): Invisible = Invisible().apply { init(); this@invisible.add(this) } 11 | 12 | /** 13 | * The #GtkInvisible widget is used internally in GTK+, and is probably not 14 | * very useful for application developers. 15 | * 16 | * It is used for reliable pointer grabs and selection handling in the code 17 | * for drag-and-drop. */ 18 | @GtkDsl 19 | open class Invisible internal constructor(override val widgetPtr: CPointer? = null) : Widget() { 20 | private val self: CPointer? 21 | get() = widgetPtr!!.reinterpret() 22 | 23 | val invisible: CPointer? 24 | get() = widgetPtr!!.reinterpret() 25 | 26 | /** 27 | * Creates a new #GtkInvisible. */ 28 | constructor() : this(gtk_invisible_new()?.reinterpret()) 29 | } 30 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Layout.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Int 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GdkWindow 8 | import libgtk3.GtkAdjustment 9 | import libgtk3.GtkLayout 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_layout_get_bin_window 12 | import libgtk3.gtk_layout_move 13 | import libgtk3.gtk_layout_new 14 | import libgtk3.gtk_layout_put 15 | import libgtk3.gtk_layout_set_size 16 | 17 | inline fun Container.layout( 18 | hadjustment: CPointer?, 19 | vadjustment: CPointer?, 20 | init: Layout.() -> Unit = {} 21 | ): Layout = Layout(hadjustment, vadjustment).apply { init(); this@layout.add(this) } 22 | 23 | /** 24 | * #GtkLayout is similar to #GtkDrawingArea in that it’s a “blank slate” and 25 | * doesn’t do anything except paint a blank background by default. It’s 26 | * different in that it supports scrolling natively due to implementing 27 | * #GtkScrollable, and can contain child widgets since it’s a #GtkContainer. 28 | * 29 | * If you just want to draw, a #GtkDrawingArea is a better choice since it has 30 | * lower overhead. If you just need to position child widgets at specific 31 | * points, then #GtkFixed provides that functionality on its own. 32 | * 33 | * When handling expose events on a #GtkLayout, you must draw to the #GdkWindow 34 | * returned by gtk_layout_get_bin_window(), rather than to the one returned by 35 | * gtk_widget_get_window() as you would for a #GtkDrawingArea. */ 36 | @GtkDsl 37 | open class Layout internal constructor(override val widgetPtr: CPointer? = null) : Container() { 38 | private val self: CPointer? 39 | get() = widgetPtr!!.reinterpret() 40 | 41 | val layout: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | val binWindow: CPointer? 45 | /** 46 | * Retrieve the bin window of the layout used for drawing operations. */ 47 | get() = gtk_layout_get_bin_window(self)!!.reinterpret() 48 | 49 | /** 50 | * Creates a new #GtkLayout. Unless you have a specific adjustment 51 | * you’d like the layout to use for scrolling, pass %NULL for 52 | * @hadjustment and @vadjustment. */ 53 | constructor(hadjustment: CPointer?, vadjustment: CPointer?) : this(gtk_layout_new(hadjustment?.reinterpret(), vadjustment?.reinterpret())?.reinterpret()) 54 | 55 | /** 56 | * Moves a current child of @layout to a new position. */ 57 | fun move( 58 | child_widget: CPointer?, 59 | x: Int, 60 | y: Int 61 | ): Unit = gtk_layout_move(self, child_widget, x, y) 62 | 63 | /** 64 | * Moves a current child of @layout to a new position. */ 65 | fun move( 66 | child_widget: Widget, 67 | x: Int, 68 | y: Int 69 | ): Unit = gtk_layout_move(self, child_widget.widgetPtr?.reinterpret(), x, y) 70 | 71 | /** 72 | * Adds @child_widget to @layout, at position (@x,@y). 73 | * @layout becomes the new parent container of @child_widget. */ 74 | fun put( 75 | child_widget: CPointer?, 76 | x: Int, 77 | y: Int 78 | ): Unit = gtk_layout_put(self, child_widget, x, y) 79 | 80 | /** 81 | * Adds @child_widget to @layout, at position (@x,@y). 82 | * @layout becomes the new parent container of @child_widget. */ 83 | fun put( 84 | child_widget: Widget, 85 | x: Int, 86 | y: Int 87 | ): Unit = gtk_layout_put(self, child_widget.widgetPtr?.reinterpret(), x, y) 88 | 89 | /** 90 | * Sets the size of the scrollable area of the layout. */ 91 | fun setSize(width: Int, height: Int): Unit = gtk_layout_set_size(self, width, height) 92 | } 93 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/LinkButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.String 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CFunction 7 | import kotlinx.cinterop.COpaquePointer 8 | import kotlinx.cinterop.CPointer 9 | import kotlinx.cinterop.asStableRef 10 | import kotlinx.cinterop.reinterpret 11 | import kotlinx.cinterop.staticCFunction 12 | import kotlinx.cinterop.toKString 13 | import libgtk3.GtkLinkButton 14 | import libgtk3.GtkWidget 15 | import libgtk3.gtk_false 16 | import libgtk3.gtk_link_button_get_uri 17 | import libgtk3.gtk_link_button_get_visited 18 | import libgtk3.gtk_link_button_new 19 | import libgtk3.gtk_link_button_set_uri 20 | import libgtk3.gtk_link_button_set_visited 21 | import libgtk3.gtk_true 22 | 23 | inline fun Container.linkButton(uri: String, init: LinkButton.() -> Unit = {}): LinkButton = LinkButton(uri).apply { init(); this@linkButton.add(this) } 24 | 25 | private fun LinkButton_onActivateLink_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 26 | data?.asStableRef()?.get()?.onActivateLink?.invoke() 27 | } 28 | 29 | /** 30 | * A GtkLinkButton is a #GtkButton with a hyperlink, similar to the one 31 | * used by web browsers, which triggers an action when clicked. It is useful 32 | * to show quick links to resources. 33 | * 34 | * A link button is created by calling either gtk_link_button_new() or 35 | * gtk_link_button_new_with_label(). If using the former, the URI you pass 36 | * to the constructor is used as a label for the widget. 37 | * 38 | * The URI bound to a GtkLinkButton can be set specifically using 39 | * gtk_link_button_set_uri(), and retrieved using gtk_link_button_get_uri(). 40 | * 41 | * By default, GtkLinkButton calls gtk_show_uri_on_window() when the button is 42 | * clicked. This behaviour can be overridden by connecting to the 43 | * #GtkLinkButton::activate-link signal and returning %TRUE from the 44 | * signal handler. 45 | * 46 | * # CSS nodes 47 | * 48 | * GtkLinkButton has a single CSS node with name button. To differentiate 49 | * it from a plain #GtkButton, it gets the .link style class. */ 50 | @GtkDsl 51 | open class LinkButton internal constructor(override val widgetPtr: CPointer? = null) : Button() { 52 | private val self: CPointer? 53 | get() = widgetPtr!!.reinterpret() 54 | 55 | val linkButton: CPointer? 56 | get() = widgetPtr!!.reinterpret() 57 | 58 | val onActivateLink: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "activate-link", staticCFunction(::LinkButton_onActivateLink_Handler)) } 59 | 60 | var uri: String 61 | /** 62 | * Retrieves the URI set using gtk_link_button_set_uri(). */ 63 | get() = gtk_link_button_get_uri(self)?.toKString() ?: "" 64 | /** 65 | * Sets @uri as the URI where the #GtkLinkButton points. As a side-effect 66 | * this unsets the “visited” state of the button. */ 67 | set(value) { 68 | gtk_link_button_set_uri(self, value) 69 | } 70 | 71 | var visited: Boolean 72 | /** 73 | * Retrieves the “visited” state of the URI where the #GtkLinkButton 74 | * points. The button becomes visited when it is clicked. If the URI 75 | * is changed on the button, the “visited” state is unset again. 76 | * 77 | * The state may also be changed using gtk_link_button_set_visited(). */ 78 | get() = gtk_link_button_get_visited(self) != 0 79 | /** 80 | * Sets the “visited” state of the URI where the #GtkLinkButton 81 | * points. See gtk_link_button_get_visited() for more details. */ 82 | set(value) { 83 | gtk_link_button_set_visited(self, if (value) gtk_true() else gtk_false()) 84 | } 85 | 86 | /** 87 | * Creates a new #GtkLinkButton with the URI as its text. */ 88 | constructor(uri: String) : this(gtk_link_button_new(uri)?.reinterpret()) 89 | } 90 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/LockButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GPermission 7 | import libgtk3.GtkLockButton 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_lock_button_get_permission 10 | import libgtk3.gtk_lock_button_new 11 | import libgtk3.gtk_lock_button_set_permission 12 | 13 | inline fun Container.lockButton(permission: CPointer?, init: LockButton.() -> Unit = {}): LockButton = LockButton(permission).apply { init(); this@lockButton.add(this) } 14 | 15 | /** 16 | * GtkLockButton is a widget that can be used in control panels or 17 | * preference dialogs to allow users to obtain and revoke authorizations 18 | * needed to operate the controls. The required authorization is represented 19 | * by a #GPermission object. Concrete implementations of #GPermission may use 20 | * PolicyKit or some other authorization framework. To obtain a PolicyKit-based 21 | * #GPermission, use polkit_permission_new(). 22 | * 23 | * If the user is not currently allowed to perform the action, but can obtain 24 | * the permission, the widget looks like this: 25 | * 26 | * ![](lockbutton-locked.png) 27 | * 28 | * and the user can click the button to request the permission. Depending 29 | * on the platform, this may pop up an authentication dialog or ask the user 30 | * to authenticate in some other way. Once the user has obtained the permission, 31 | * the widget changes to this: 32 | * 33 | * ![](lockbutton-unlocked.png) 34 | * 35 | * and the permission can be dropped again by clicking the button. If the user 36 | * is not able to obtain the permission at all, the widget looks like this: 37 | * 38 | * ![](lockbutton-sorry.png) 39 | * 40 | * If the user has the permission and cannot drop it, the button is hidden. 41 | * 42 | * The text (and tooltips) that are shown in the various cases can be adjusted 43 | * with the #GtkLockButton:text-lock, #GtkLockButton:text-unlock, 44 | * #GtkLockButton:tooltip-lock, #GtkLockButton:tooltip-unlock and 45 | * #GtkLockButton:tooltip-not-authorized properties. */ 46 | @GtkDsl 47 | open class LockButton internal constructor(override val widgetPtr: CPointer? = null) : Button() { 48 | private val self: CPointer? 49 | get() = widgetPtr!!.reinterpret() 50 | 51 | val lockButton: CPointer? 52 | get() = widgetPtr!!.reinterpret() 53 | 54 | var permission: CPointer? 55 | /** 56 | * Obtains the #GPermission object that controls @button. */ 57 | get() = gtk_lock_button_get_permission(self)!!.reinterpret() 58 | /** 59 | * Sets the #GPermission object that controls @button. */ 60 | set(value) { 61 | gtk_lock_button_set_permission(self, value?.reinterpret()) 62 | } 63 | 64 | /** 65 | * Creates a new lock button which reflects the @permission. */ 66 | constructor(permission: CPointer?) : this(gtk_lock_button_new(permission)) 67 | } 68 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/MenuBar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkMenuBar 7 | import libgtk3.GtkPackDirection 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_menu_bar_get_child_pack_direction 10 | import libgtk3.gtk_menu_bar_get_pack_direction 11 | import libgtk3.gtk_menu_bar_new 12 | import libgtk3.gtk_menu_bar_set_child_pack_direction 13 | import libgtk3.gtk_menu_bar_set_pack_direction 14 | 15 | inline fun Container.menuBar(init: MenuBar.() -> Unit = {}): MenuBar = MenuBar().apply { init(); this@menuBar.add(this) } 16 | 17 | /** 18 | * The #GtkMenuBar is a subclass of #GtkMenuShell which contains one or 19 | * more #GtkMenuItems. The result is a standard menu bar which can hold 20 | * many menu items. 21 | * 22 | * # CSS nodes 23 | * 24 | * GtkMenuBar has a single CSS node with name menubar. */ 25 | @GtkDsl 26 | open class MenuBar internal constructor(override val widgetPtr: CPointer? = null) : MenuShell() { 27 | private val self: CPointer? 28 | get() = widgetPtr!!.reinterpret() 29 | 30 | val menuBar: CPointer? 31 | get() = widgetPtr!!.reinterpret() 32 | 33 | var childPackDirection: GtkPackDirection 34 | /** 35 | * Retrieves the current child pack direction of the menubar. 36 | * See gtk_menu_bar_set_child_pack_direction(). */ 37 | get() = gtk_menu_bar_get_child_pack_direction(self) 38 | /** 39 | * Sets how widgets should be packed inside the children of a menubar. */ 40 | set(value) { 41 | gtk_menu_bar_set_child_pack_direction(self, value) 42 | } 43 | 44 | var packDirection: GtkPackDirection 45 | /** 46 | * Retrieves the current pack direction of the menubar. 47 | * See gtk_menu_bar_set_pack_direction(). */ 48 | get() = gtk_menu_bar_get_pack_direction(self) 49 | /** 50 | * Sets how items should be packed inside a menubar. */ 51 | set(value) { 52 | gtk_menu_bar_set_pack_direction(self, value) 53 | } 54 | 55 | /** 56 | * Creates a new #GtkMenuBar */ 57 | constructor() : this(gtk_menu_bar_new()?.reinterpret()) 58 | } 59 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/MenuToolButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import libgtk3.GtkMenuToolButton 12 | import libgtk3.GtkWidget 13 | import libgtk3.gtk_menu_tool_button_get_menu 14 | import libgtk3.gtk_menu_tool_button_new 15 | import libgtk3.gtk_menu_tool_button_set_arrow_tooltip_markup 16 | import libgtk3.gtk_menu_tool_button_set_arrow_tooltip_text 17 | import libgtk3.gtk_menu_tool_button_set_menu 18 | 19 | inline fun Container.menuToolButton( 20 | icon_widget: CPointer?, 21 | label: String, 22 | init: MenuToolButton.() -> Unit = {} 23 | ): MenuToolButton = MenuToolButton(icon_widget, label).apply { init(); this@menuToolButton.add(this) } 24 | 25 | private fun MenuToolButton_onShowMenu_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 26 | data?.asStableRef()?.get()?.onShowMenu?.invoke() 27 | } 28 | 29 | /** 30 | * A #GtkMenuToolButton is a #GtkToolItem that contains a button and 31 | * a small additional button with an arrow. When clicked, the arrow 32 | * button pops up a dropdown menu. 33 | * 34 | * Use gtk_menu_tool_button_new() to create a new 35 | * #GtkMenuToolButton. 36 | * 37 | * # GtkMenuToolButton as GtkBuildable 38 | * 39 | * The GtkMenuToolButton implementation of the GtkBuildable interface 40 | * supports adding a menu by specifying “menu” as the “type” attribute 41 | * of a element. 42 | * 43 | * An example for a UI definition fragment with menus: 44 | * |[ 45 | * 46 | * 47 | * 48 | * 49 | * 50 | * ]| */ 51 | @GtkDsl 52 | open class MenuToolButton internal constructor(override val widgetPtr: CPointer? = null) : ToolButton() { 53 | private val self: CPointer? 54 | get() = widgetPtr!!.reinterpret() 55 | 56 | val menuToolButton: CPointer? 57 | get() = widgetPtr!!.reinterpret() 58 | 59 | val onShowMenu: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "show-menu", staticCFunction(::MenuToolButton_onShowMenu_Handler)) } 60 | 61 | var menu: CPointer? 62 | /** 63 | * Gets the #GtkMenu associated with #GtkMenuToolButton. */ 64 | get() = gtk_menu_tool_button_get_menu(self)!!.reinterpret() 65 | /** 66 | * Sets the #GtkMenu that is popped up when the user clicks on the arrow. 67 | * If @menu is NULL, the arrow button becomes insensitive. */ 68 | set(value) { 69 | gtk_menu_tool_button_set_menu(self, value?.reinterpret()) 70 | } 71 | 72 | /** 73 | * Creates a new #GtkMenuToolButton using @icon_widget as icon and 74 | * @label as label. */ 75 | constructor(icon_widget: CPointer?, label: String) : this(gtk_menu_tool_button_new(icon_widget?.reinterpret(), label)?.reinterpret()) 76 | 77 | /** 78 | * Sets the tooltip markup text to be used as tooltip for the arrow button 79 | * which pops up the menu. See gtk_tool_item_set_tooltip_text() for setting 80 | * a tooltip on the whole #GtkMenuToolButton. */ 81 | fun setArrowTooltipMarkup(markup: String): Unit = gtk_menu_tool_button_set_arrow_tooltip_markup(self, markup) 82 | 83 | /** 84 | * Sets the tooltip text to be used as tooltip for the arrow button which 85 | * pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a tooltip 86 | * on the whole #GtkMenuToolButton. */ 87 | fun setArrowTooltipText(text: String): Unit = gtk_menu_tool_button_set_arrow_tooltip_text(self, text) 88 | } 89 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Misc.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkMisc 6 | 7 | /** 8 | * The #GtkMisc widget is an abstract widget which is not useful itself, but 9 | * is used to derive subclasses which have alignment and padding attributes. 10 | * 11 | * The horizontal and vertical padding attributes allows extra space to be 12 | * added around the widget. 13 | * 14 | * The horizontal and vertical alignment attributes enable the widget to be 15 | * positioned within its allocated area. Note that if the widget is added to 16 | * a container in such a way that it expands automatically to fill its 17 | * allocated area, the alignment settings will not alter the widget's position. 18 | * 19 | * Note that the desired effect can in most cases be achieved by using the 20 | * #GtkWidget:halign, #GtkWidget:valign and #GtkWidget:margin properties 21 | * on the child widget, so GtkMisc should not be used in new code. To reflect 22 | * this fact, all #GtkMisc API has been deprecated. */ 23 | @GtkDsl 24 | abstract class Misc : Widget() { 25 | private val self: CPointer 26 | get() = widgetPtr!!.reinterpret() 27 | } 28 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/OffscreenWindow.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GdkPixbuf 7 | import libgtk3.GtkOffscreenWindow 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_offscreen_window_get_pixbuf 10 | import libgtk3.gtk_offscreen_window_new 11 | 12 | inline fun Container.offscreenWindow(init: OffscreenWindow.() -> Unit = {}): OffscreenWindow = OffscreenWindow().apply { init(); this@offscreenWindow.add(this) } 13 | 14 | /** 15 | * GtkOffscreenWindow is strictly intended to be used for obtaining 16 | * snapshots of widgets that are not part of a normal widget hierarchy. 17 | * Since #GtkOffscreenWindow is a toplevel widget you cannot obtain 18 | * snapshots of a full window with it since you cannot pack a toplevel 19 | * widget in another toplevel. 20 | * 21 | * The idea is to take a widget and manually set the state of it, 22 | * add it to a GtkOffscreenWindow and then retrieve the snapshot 23 | * as a #cairo_surface_t or #GdkPixbuf. 24 | * 25 | * GtkOffscreenWindow derives from #GtkWindow only as an implementation 26 | * detail. Applications should not use any API specific to #GtkWindow 27 | * to operate on this object. It should be treated as a #GtkBin that 28 | * has no parent widget. 29 | * 30 | * When contained offscreen widgets are redrawn, GtkOffscreenWindow 31 | * will emit a #GtkWidget::damage-event signal. */ 32 | @GtkDsl 33 | open class OffscreenWindow internal constructor(override val widgetPtr: CPointer? = null) : Window() { 34 | private val self: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | val offscreenWindow: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | val pixbuf: CPointer? 41 | /** 42 | * Retrieves a snapshot of the contained widget in the form of 43 | * a #GdkPixbuf. This is a new pixbuf with a reference count of 1, 44 | * and the application should unreference it once it is no longer 45 | * needed. */ 46 | get() = gtk_offscreen_window_get_pixbuf(self)!!.reinterpret() 47 | 48 | /** 49 | * Creates a toplevel container widget that is used to retrieve 50 | * snapshots of widgets without showing them on the screen. */ 51 | constructor() : this(gtk_offscreen_window_new()?.reinterpret()) 52 | } 53 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/RadioToolButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GSList 7 | import libgtk3.GtkRadioToolButton 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_radio_tool_button_get_group 10 | import libgtk3.gtk_radio_tool_button_new 11 | import libgtk3.gtk_radio_tool_button_set_group 12 | 13 | inline fun Container.radioToolButton(group: CPointer?, init: RadioToolButton.() -> Unit = {}): RadioToolButton = RadioToolButton(group).apply { init(); this@radioToolButton.add(this) } 14 | 15 | /** 16 | * A #GtkRadioToolButton is a #GtkToolItem that contains a radio button, 17 | * that is, a button that is part of a group of toggle buttons where only 18 | * one button can be active at a time. 19 | * 20 | * Use gtk_radio_tool_button_new() to create a new GtkRadioToolButton. Use 21 | * gtk_radio_tool_button_new_from_widget() to create a new GtkRadioToolButton 22 | * that is part of the same group as an existing GtkRadioToolButton. 23 | * 24 | * # CSS nodes 25 | * 26 | * GtkRadioToolButton has a single CSS node with name toolbutton. */ 27 | @GtkDsl 28 | open class RadioToolButton internal constructor(override val widgetPtr: CPointer? = null) : ToggleToolButton() { 29 | private val self: CPointer? 30 | get() = widgetPtr!!.reinterpret() 31 | 32 | val radioToolButton: CPointer? 33 | get() = widgetPtr!!.reinterpret() 34 | 35 | var group: CPointer? 36 | /** 37 | * Returns the radio button group @button belongs to. */ 38 | get() = gtk_radio_tool_button_get_group(self)!!.reinterpret() 39 | /** 40 | * Adds @button to @group, removing it from the group it belonged to before. */ 41 | set(value) { 42 | gtk_radio_tool_button_set_group(self, value?.reinterpret()) 43 | } 44 | 45 | /** 46 | * Creates a new #GtkRadioToolButton, adding it to @group. */ 47 | constructor(group: CPointer?) : this(gtk_radio_tool_button_new(group?.reinterpret())?.reinterpret()) 48 | } 49 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/RecentChooserDialog.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkRecentChooserDialog 8 | import libgtk3.GtkWidget 9 | import libgtk3.GtkWindow 10 | import libgtk3.gtk_recent_chooser_dialog_new 11 | 12 | inline fun Container.recentChooserDialog( 13 | title: String, 14 | parent: CPointer?, 15 | first_button_text: String, 16 | init: RecentChooserDialog.() -> Unit = {} 17 | ): RecentChooserDialog = RecentChooserDialog(title, parent, first_button_text).apply { init(); this@recentChooserDialog.add(this) } 18 | 19 | /** 20 | * #GtkRecentChooserDialog is a dialog box suitable for displaying the recently 21 | * used documents. This widgets works by putting a #GtkRecentChooserWidget inside 22 | * a #GtkDialog. It exposes the #GtkRecentChooserIface interface, so you can use 23 | * all the #GtkRecentChooser functions on the recent chooser dialog as well as 24 | * those for #GtkDialog. 25 | * 26 | * Note that #GtkRecentChooserDialog does not have any methods of its own. 27 | * Instead, you should use the functions that work on a #GtkRecentChooser. 28 | * 29 | * ## Typical usage ## {#gtkrecentchooser-typical-usage} 30 | * 31 | * In the simplest of cases, you can use the following code to use 32 | * a #GtkRecentChooserDialog to select a recently used file: 33 | * 34 | * |[ 35 | * GtkWidget *dialog; 36 | * gint res; 37 | * 38 | * dialog = gtk_recent_chooser_dialog_new ("Recent Documents", 39 | * parent_window, 40 | * _("_Cancel"), 41 | * GTK_RESPONSE_CANCEL, 42 | * _("_Open"), 43 | * GTK_RESPONSE_ACCEPT, 44 | * NULL); 45 | * 46 | * res = gtk_dialog_run (GTK_DIALOG (dialog)); 47 | * if (res == GTK_RESPONSE_ACCEPT) 48 | * { 49 | * GtkRecentInfo *info; 50 | * GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (dialog); 51 | * 52 | * info = gtk_recent_chooser_get_current_item (chooser); 53 | * open_file (gtk_recent_info_get_uri (info)); 54 | * gtk_recent_info_unref (info); 55 | * } 56 | * 57 | * gtk_widget_destroy (dialog); 58 | * ]| 59 | * 60 | * Recently used files are supported since GTK+ 2.10. */ 61 | @GtkDsl 62 | open class RecentChooserDialog internal constructor(override val widgetPtr: CPointer? = null) : Dialog() { 63 | private val self: CPointer? 64 | get() = widgetPtr!!.reinterpret() 65 | 66 | val recentChooserDialog: CPointer? 67 | get() = widgetPtr!!.reinterpret() 68 | 69 | /** 70 | * Creates a new #GtkRecentChooserDialog. This function is analogous to 71 | * gtk_dialog_new_with_buttons(). */ 72 | constructor( 73 | title: String, 74 | parent: CPointer?, 75 | first_button_text: String 76 | ) : this(gtk_recent_chooser_dialog_new(title, parent?.reinterpret(), first_button_text)?.reinterpret()) 77 | } 78 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/RecentChooserMenu.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkRecentChooserMenu 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_false 10 | import libgtk3.gtk_recent_chooser_menu_get_show_numbers 11 | import libgtk3.gtk_recent_chooser_menu_new 12 | import libgtk3.gtk_recent_chooser_menu_set_show_numbers 13 | import libgtk3.gtk_true 14 | 15 | inline fun Container.recentChooserMenu(init: RecentChooserMenu.() -> Unit = {}): RecentChooserMenu = RecentChooserMenu().apply { init(); this@recentChooserMenu.add(this) } 16 | 17 | /** 18 | * #GtkRecentChooserMenu is a widget suitable for displaying recently used files 19 | * inside a menu. It can be used to set a sub-menu of a #GtkMenuItem using 20 | * gtk_menu_item_set_submenu(), or as the menu of a #GtkMenuToolButton. 21 | * 22 | * Note that #GtkRecentChooserMenu does not have any methods of its own. Instead, 23 | * you should use the functions that work on a #GtkRecentChooser. 24 | * 25 | * Note also that #GtkRecentChooserMenu does not support multiple filters, as it 26 | * has no way to let the user choose between them as the #GtkRecentChooserWidget 27 | * and #GtkRecentChooserDialog widgets do. Thus using gtk_recent_chooser_add_filter() 28 | * on a #GtkRecentChooserMenu widget will yield the same effects as using 29 | * gtk_recent_chooser_set_filter(), replacing any currently set filter 30 | * with the supplied filter; gtk_recent_chooser_remove_filter() will remove 31 | * any currently set #GtkRecentFilter object and will unset the current filter; 32 | * gtk_recent_chooser_list_filters() will return a list containing a single 33 | * #GtkRecentFilter object. 34 | * 35 | * Recently used files are supported since GTK+ 2.10. */ 36 | @GtkDsl 37 | open class RecentChooserMenu internal constructor(override val widgetPtr: CPointer? = null) : Menu() { 38 | private val self: CPointer? 39 | get() = widgetPtr!!.reinterpret() 40 | 41 | val recentChooserMenu: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | var showNumbers: Boolean 45 | /** 46 | * Returns the value set by gtk_recent_chooser_menu_set_show_numbers(). */ 47 | get() = gtk_recent_chooser_menu_get_show_numbers(self) != 0 48 | /** 49 | * Sets whether a number should be added to the items of @menu. The 50 | * numbers are shown to provide a unique character for a mnemonic to 51 | * be used inside ten menu item’s label. Only the first the items 52 | * get a number to avoid clashes. */ 53 | set(value) { 54 | gtk_recent_chooser_menu_set_show_numbers(self, if (value) gtk_true() else gtk_false()) 55 | } 56 | 57 | /** 58 | * Creates a new #GtkRecentChooserMenu widget. 59 | * 60 | * This kind of widget shows the list of recently used resources as 61 | * a menu, each item as a menu item. Each item inside the menu might 62 | * have an icon, representing its MIME type, and a number, for mnemonic 63 | * access. 64 | * 65 | * This widget implements the #GtkRecentChooser interface. 66 | * 67 | * This widget creates its own #GtkRecentManager object. See the 68 | * gtk_recent_chooser_menu_new_for_manager() function to know how to create 69 | * a #GtkRecentChooserMenu widget bound to another #GtkRecentManager object. */ 70 | constructor() : this(gtk_recent_chooser_menu_new()?.reinterpret()) 71 | } 72 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/RecentChooserWidget.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkRecentChooserWidget 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_recent_chooser_widget_new 9 | 10 | inline fun Container.recentChooserWidget(init: RecentChooserWidget.() -> Unit = {}): RecentChooserWidget = RecentChooserWidget().apply { init(); this@recentChooserWidget.add(this) } 11 | 12 | /** 13 | * #GtkRecentChooserWidget is a widget suitable for selecting recently used 14 | * files. It is the main building block of a #GtkRecentChooserDialog. Most 15 | * applications will only need to use the latter; you can use 16 | * #GtkRecentChooserWidget as part of a larger window if you have special needs. 17 | * 18 | * Note that #GtkRecentChooserWidget does not have any methods of its own. 19 | * Instead, you should use the functions that work on a #GtkRecentChooser. 20 | * 21 | * Recently used files are supported since GTK+ 2.10. */ 22 | @GtkDsl 23 | open class RecentChooserWidget internal constructor(override val widgetPtr: CPointer? = null) : Box() { 24 | private val self: CPointer? 25 | get() = widgetPtr!!.reinterpret() 26 | 27 | val recentChooserWidget: CPointer? 28 | get() = widgetPtr!!.reinterpret() 29 | 30 | /** 31 | * Creates a new #GtkRecentChooserWidget object. This is an embeddable widget 32 | * used to access the recently used resources list. */ 33 | constructor() : this(gtk_recent_chooser_widget_new()?.reinterpret()) 34 | } 35 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Revealer.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Int 5 | import kotlin.Unit 6 | import kotlinx.cinterop.CPointer 7 | import kotlinx.cinterop.reinterpret 8 | import libgtk3.GtkRevealer 9 | import libgtk3.GtkRevealerTransitionType 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_false 12 | import libgtk3.gtk_revealer_get_child_revealed 13 | import libgtk3.gtk_revealer_get_reveal_child 14 | import libgtk3.gtk_revealer_get_transition_duration 15 | import libgtk3.gtk_revealer_get_transition_type 16 | import libgtk3.gtk_revealer_new 17 | import libgtk3.gtk_revealer_set_reveal_child 18 | import libgtk3.gtk_revealer_set_transition_duration 19 | import libgtk3.gtk_revealer_set_transition_type 20 | import libgtk3.gtk_true 21 | 22 | inline fun Container.revealer(init: Revealer.() -> Unit = {}): Revealer = Revealer().apply { init(); this@revealer.add(this) } 23 | 24 | /** 25 | * The GtkRevealer widget is a container which animates 26 | * the transition of its child from invisible to visible. 27 | * 28 | * The style of transition can be controlled with 29 | * gtk_revealer_set_transition_type(). 30 | * 31 | * These animations respect the #GtkSettings:gtk-enable-animations 32 | * setting. 33 | * 34 | * # CSS nodes 35 | * 36 | * GtkRevealer has a single CSS node with name revealer. 37 | * 38 | * The GtkRevealer widget was added in GTK+ 3.10. */ 39 | @GtkDsl 40 | open class Revealer internal constructor(override val widgetPtr: CPointer? = null) : Bin() { 41 | private val self: CPointer? 42 | get() = widgetPtr!!.reinterpret() 43 | 44 | val revealer: CPointer? 45 | get() = widgetPtr!!.reinterpret() 46 | 47 | val childRevealed: Boolean 48 | /** 49 | * Returns whether the child is fully revealed, in other words whether 50 | * the transition to the revealed state is completed. */ 51 | get() = gtk_revealer_get_child_revealed(self) != 0 52 | 53 | var revealChild: Boolean 54 | /** 55 | * Returns whether the child is currently 56 | * revealed. See gtk_revealer_set_reveal_child(). 57 | * 58 | * This function returns %TRUE as soon as the transition 59 | * is to the revealed state is started. To learn whether 60 | * the child is fully revealed (ie the transition is completed), 61 | * use gtk_revealer_get_child_revealed(). */ 62 | get() = gtk_revealer_get_reveal_child(self) != 0 63 | /** 64 | * Tells the #GtkRevealer to reveal or conceal its child. 65 | * 66 | * The transition will be animated with the current 67 | * transition type of @revealer. */ 68 | set(value) { 69 | gtk_revealer_set_reveal_child(self, if (value) gtk_true() else gtk_false()) 70 | } 71 | 72 | var transitionDuration: Int 73 | /** 74 | * Returns the amount of time (in milliseconds) that 75 | * transitions will take. */ 76 | get() = gtk_revealer_get_transition_duration(self) 77 | /** 78 | * Sets the duration that transitions will take. */ 79 | set(value) { 80 | gtk_revealer_set_transition_duration(self, value) 81 | } 82 | 83 | var transitionType: GtkRevealerTransitionType 84 | /** 85 | * Gets the type of animation that will be used 86 | * for transitions in @revealer. */ 87 | get() = gtk_revealer_get_transition_type(self) 88 | /** 89 | * Sets the type of animation that will be used for 90 | * transitions in @revealer. Available types include 91 | * various kinds of fades and slides. */ 92 | set(value) { 93 | gtk_revealer_set_transition_type(self, value) 94 | } 95 | 96 | /** 97 | * Creates a new #GtkRevealer. */ 98 | constructor() : this(gtk_revealer_new()?.reinterpret()) 99 | } 100 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Scrollbar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkAdjustment 7 | import libgtk3.GtkOrientation 8 | import libgtk3.GtkScrollbar 9 | import libgtk3.GtkWidget 10 | import libgtk3.gtk_scrollbar_new 11 | 12 | inline fun Container.scrollbar( 13 | orientation: GtkOrientation, 14 | adjustment: CPointer?, 15 | init: Scrollbar.() -> Unit = {} 16 | ): Scrollbar = Scrollbar(orientation, adjustment).apply { init(); this@scrollbar.add(this) } 17 | 18 | /** 19 | * The #GtkScrollbar widget is a horizontal or vertical scrollbar, 20 | * depending on the value of the #GtkOrientable:orientation property. 21 | * 22 | * Its position and movement are controlled by the adjustment that is passed to 23 | * or created by gtk_scrollbar_new(). See #GtkAdjustment for more details. The 24 | * #GtkAdjustment:value field sets the position of the thumb and must be between 25 | * #GtkAdjustment:lower and #GtkAdjustment:upper - #GtkAdjustment:page-size. The 26 | * #GtkAdjustment:page-size represents the size of the visible scrollable area. 27 | * The fields #GtkAdjustment:step-increment and #GtkAdjustment:page-increment 28 | * fields are added to or subtracted from the #GtkAdjustment:value when the user 29 | * asks to move by a step (using e.g. the cursor arrow keys or, if present, the 30 | * stepper buttons) or by a page (using e.g. the Page Down/Up keys). 31 | * 32 | * # CSS nodes 33 | * 34 | * |[ 35 | * scrollbar[.fine-tune] 36 | * ╰── contents 37 | * ├── [button.up] 38 | * ├── [button.down] 39 | * ├── trough 40 | * │ ╰── slider 41 | * ├── [button.up] 42 | * ╰── [button.down] 43 | * ]| 44 | * 45 | * GtkScrollbar has a main CSS node with name scrollbar and a subnode for its 46 | * contents, with subnodes named trough and slider. 47 | * 48 | * The main node gets the style class .fine-tune added when the scrollbar is 49 | * in 'fine-tuning' mode. 50 | * 51 | * If steppers are enabled, they are represented by up to four additional 52 | * subnodes with name button. These get the style classes .up and .down to 53 | * indicate in which direction they are moving. 54 | * 55 | * Other style classes that may be added to scrollbars inside #GtkScrolledWindow 56 | * include the positional classes (.left, .right, .top, .bottom) and style 57 | * classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering). */ 58 | @GtkDsl 59 | open class Scrollbar internal constructor(override val widgetPtr: CPointer? = null) : Range() { 60 | private val self: CPointer? 61 | get() = widgetPtr!!.reinterpret() 62 | 63 | val scrollbar: CPointer? 64 | get() = widgetPtr!!.reinterpret() 65 | 66 | /** 67 | * Creates a new scrollbar with the given orientation. */ 68 | constructor(orientation: GtkOrientation, adjustment: CPointer?) : this(gtk_scrollbar_new(orientation, adjustment?.reinterpret())?.reinterpret()) 69 | } 70 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Separator.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkOrientation 7 | import libgtk3.GtkSeparator 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_separator_new 10 | 11 | inline fun Container.separator(orientation: GtkOrientation, init: Separator.() -> Unit = {}): Separator = Separator(orientation).apply { init(); this@separator.add(this) } 12 | 13 | /** 14 | * GtkSeparator is a horizontal or vertical separator widget, depending on the 15 | * value of the #GtkOrientable:orientation property, used to group the widgets 16 | * within a window. It displays a line with a shadow to make it appear sunken 17 | * into the interface. 18 | * 19 | * # CSS nodes 20 | * 21 | * GtkSeparator has a single CSS node with name separator. The node 22 | * gets one of the .horizontal or .vertical style classes. */ 23 | @GtkDsl 24 | open class Separator internal constructor(override val widgetPtr: CPointer? = null) : Widget() { 25 | private val self: CPointer? 26 | get() = widgetPtr!!.reinterpret() 27 | 28 | val separator: CPointer? 29 | get() = widgetPtr!!.reinterpret() 30 | 31 | /** 32 | * Creates a new #GtkSeparator with the given orientation. */ 33 | constructor(orientation: GtkOrientation) : this(gtk_separator_new(orientation)?.reinterpret()) 34 | } 35 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/SeparatorMenuItem.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkSeparatorMenuItem 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_separator_menu_item_new 9 | 10 | inline fun Container.separatorMenuItem(init: SeparatorMenuItem.() -> Unit = {}): SeparatorMenuItem = SeparatorMenuItem().apply { init(); this@separatorMenuItem.add(this) } 11 | 12 | /** 13 | * The #GtkSeparatorMenuItem is a separator used to group 14 | * items within a menu. It displays a horizontal line with a shadow to 15 | * make it appear sunken into the interface. 16 | * 17 | * # CSS nodes 18 | * 19 | * GtkSeparatorMenuItem has a single CSS node with name separator. */ 20 | @GtkDsl 21 | open class SeparatorMenuItem internal constructor(override val widgetPtr: CPointer? = null) : MenuItem() { 22 | private val self: CPointer? 23 | get() = widgetPtr!!.reinterpret() 24 | 25 | val separatorMenuItem: CPointer? 26 | get() = widgetPtr!!.reinterpret() 27 | 28 | /** 29 | * Creates a new #GtkSeparatorMenuItem. */ 30 | constructor() : this(gtk_separator_menu_item_new()?.reinterpret()) 31 | } 32 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/SeparatorToolItem.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import libgtk3.GtkSeparatorToolItem 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_false 10 | import libgtk3.gtk_separator_tool_item_get_draw 11 | import libgtk3.gtk_separator_tool_item_new 12 | import libgtk3.gtk_separator_tool_item_set_draw 13 | import libgtk3.gtk_true 14 | 15 | inline fun Container.separatorToolItem(init: SeparatorToolItem.() -> Unit = {}): SeparatorToolItem = SeparatorToolItem().apply { init(); this@separatorToolItem.add(this) } 16 | 17 | /** 18 | * A #GtkSeparatorToolItem is a #GtkToolItem that separates groups of other 19 | * #GtkToolItems. Depending on the theme, a #GtkSeparatorToolItem will 20 | * often look like a vertical line on horizontally docked toolbars. 21 | * 22 | * If the #GtkToolbar child property “expand” is %TRUE and the property 23 | * #GtkSeparatorToolItem:draw is %FALSE, a #GtkSeparatorToolItem will act as 24 | * a “spring” that forces other items to the ends of the toolbar. 25 | * 26 | * Use gtk_separator_tool_item_new() to create a new #GtkSeparatorToolItem. 27 | * 28 | * # CSS nodes 29 | * 30 | * GtkSeparatorToolItem has a single CSS node with name separator. */ 31 | @GtkDsl 32 | open class SeparatorToolItem internal constructor(override val widgetPtr: CPointer? = null) : ToolItem() { 33 | private val self: CPointer? 34 | get() = widgetPtr!!.reinterpret() 35 | 36 | val separatorToolItem: CPointer? 37 | get() = widgetPtr!!.reinterpret() 38 | 39 | var draw: Boolean 40 | /** 41 | * Returns whether @item is drawn as a line, or just blank. 42 | * See gtk_separator_tool_item_set_draw(). */ 43 | get() = gtk_separator_tool_item_get_draw(self) != 0 44 | /** 45 | * Whether @item is drawn as a vertical line, or just blank. 46 | * Setting this to %FALSE along with gtk_tool_item_set_expand() is useful 47 | * to create an item that forces following items to the end of the toolbar. */ 48 | set(value) { 49 | gtk_separator_tool_item_set_draw(self, if (value) gtk_true() else gtk_false()) 50 | } 51 | 52 | /** 53 | * Create a new #GtkSeparatorToolItem */ 54 | constructor() : this(gtk_separator_tool_item_new()?.reinterpret()) 55 | } 56 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ShortcutLabel.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.String 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CPointer 6 | import kotlinx.cinterop.reinterpret 7 | import kotlinx.cinterop.toKString 8 | import libgtk3.GtkShortcutLabel 9 | import libgtk3.GtkWidget 10 | import libgtk3.gtk_shortcut_label_get_accelerator 11 | import libgtk3.gtk_shortcut_label_get_disabled_text 12 | import libgtk3.gtk_shortcut_label_new 13 | import libgtk3.gtk_shortcut_label_set_accelerator 14 | import libgtk3.gtk_shortcut_label_set_disabled_text 15 | 16 | inline fun Container.shortcutLabel(accelerator: String, init: ShortcutLabel.() -> Unit = {}): ShortcutLabel = ShortcutLabel(accelerator).apply { init(); this@shortcutLabel.add(this) } 17 | 18 | /** 19 | * #GtkShortcutLabel is a widget that represents a single keyboard shortcut or gesture 20 | * in the user interface. */ 21 | @GtkDsl 22 | open class ShortcutLabel internal constructor(override val widgetPtr: CPointer? = null) : Box() { 23 | private val self: CPointer? 24 | get() = widgetPtr!!.reinterpret() 25 | 26 | val shortcutLabel: CPointer? 27 | get() = widgetPtr!!.reinterpret() 28 | 29 | var accelerator: String 30 | /** 31 | * Retrieves the current accelerator of @self. */ 32 | get() = gtk_shortcut_label_get_accelerator(self)?.toKString() ?: "" 33 | /** 34 | * Sets the accelerator to be displayed by @self. */ 35 | set(value) { 36 | gtk_shortcut_label_set_accelerator(self, value) 37 | } 38 | 39 | var disabledText: String 40 | /** 41 | * Retrieves the text that is displayed when no accelerator is set. */ 42 | get() = gtk_shortcut_label_get_disabled_text(self)?.toKString() ?: "" 43 | /** 44 | * Sets the text to be displayed by @self when no accelerator is set. */ 45 | set(value) { 46 | gtk_shortcut_label_set_disabled_text(self, value) 47 | } 48 | 49 | /** 50 | * Creates a new #GtkShortcutLabel with @accelerator set. */ 51 | constructor(accelerator: String) : this(gtk_shortcut_label_new(accelerator)?.reinterpret()) 52 | } 53 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ShortcutsGroup.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkShortcutsGroup 6 | 7 | /** 8 | * A GtkShortcutsGroup represents a group of related keyboard shortcuts 9 | * or gestures. The group has a title. It may optionally be associated with 10 | * a view of the application, which can be used to show only relevant shortcuts 11 | * depending on the application context. 12 | * 13 | * This widget is only meant to be used with #GtkShortcutsWindow. */ 14 | @GtkDsl 15 | abstract class ShortcutsGroup : Box() { 16 | private val self: CPointer 17 | get() = widgetPtr!!.reinterpret() 18 | } 19 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ShortcutsSection.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Int 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import libgtk3.GtkShortcutsSection 12 | 13 | private fun ShortcutsSection_onChangeCurrentPage_Handler( 14 | sender: CPointer<*>?, 15 | `object`: Int, 16 | data: COpaquePointer? 17 | ) { 18 | data?.asStableRef()?.get()?.onChangeCurrentPage?.invoke(`object`) 19 | } 20 | 21 | /** 22 | * A GtkShortcutsSection collects all the keyboard shortcuts and gestures 23 | * for a major application mode. If your application needs multiple sections, 24 | * you should give each section a unique #GtkShortcutsSection:section-name and 25 | * a #GtkShortcutsSection:title that can be shown in the section selector of 26 | * the GtkShortcutsWindow. 27 | * 28 | * The #GtkShortcutsSection:max-height property can be used to influence how 29 | * the groups in the section are distributed over pages and columns. 30 | * 31 | * This widget is only meant to be used with #GtkShortcutsWindow. */ 32 | @GtkDsl 33 | abstract class ShortcutsSection : Box() { 34 | private val self: CPointer 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | val onChangeCurrentPage: Signal1?, 39 | Int, 40 | COpaquePointer? 41 | ) -> Unit>> by lazy { Signal1?, 43 | Int, 44 | COpaquePointer? 45 | ) -> Unit>>(widgetPtr!!, this, "change-current-page", staticCFunction(::ShortcutsSection_onChangeCurrentPage_Handler)) } 46 | } 47 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ShortcutsShortcut.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.GtkShortcutsShortcut 6 | 7 | /** 8 | * A GtkShortcutsShortcut represents a single keyboard shortcut or gesture 9 | * with a short text. This widget is only meant to be used with #GtkShortcutsWindow. */ 10 | @GtkDsl 11 | abstract class ShortcutsShortcut : Box() { 12 | private val self: CPointer 13 | get() = widgetPtr!!.reinterpret() 14 | } 15 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ShortcutsWindow.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CFunction 5 | import kotlinx.cinterop.COpaquePointer 6 | import kotlinx.cinterop.CPointer 7 | import kotlinx.cinterop.asStableRef 8 | import kotlinx.cinterop.reinterpret 9 | import kotlinx.cinterop.staticCFunction 10 | import libgtk3.GtkShortcutsWindow 11 | 12 | private fun ShortcutsWindow_onClose_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 13 | data?.asStableRef()?.get()?.onClose?.invoke() 14 | } 15 | 16 | private fun ShortcutsWindow_onSearch_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 17 | data?.asStableRef()?.get()?.onSearch?.invoke() 18 | } 19 | 20 | /** 21 | * A GtkShortcutsWindow shows brief information about the keyboard shortcuts 22 | * and gestures of an application. The shortcuts can be grouped, and you can 23 | * have multiple sections in this window, corresponding to the major modes of 24 | * your application. 25 | * 26 | * Additionally, the shortcuts can be filtered by the current view, to avoid 27 | * showing information that is not relevant in the current application context. 28 | * 29 | * The recommended way to construct a GtkShortcutsWindow is with GtkBuilder, 30 | * by populating a #GtkShortcutsWindow with one or more #GtkShortcutsSection 31 | * objects, which contain #GtkShortcutsGroups that in turn contain objects of 32 | * class #GtkShortcutsShortcut. 33 | * 34 | * # A simple example: 35 | * 36 | * ![](gedit-shortcuts.png) 37 | * 38 | * This example has as single section. As you can see, the shortcut groups 39 | * are arranged in columns, and spread across several pages if there are too 40 | * many to find on a single page. 41 | * 42 | * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-gedit.ui). 43 | * 44 | * # An example with multiple views: 45 | * 46 | * ![](clocks-shortcuts.png) 47 | * 48 | * This example shows a #GtkShortcutsWindow that has been configured to show only 49 | * the shortcuts relevant to the "stopwatch" view. 50 | * 51 | * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-clocks.ui). 52 | * 53 | * # An example with multiple sections: 54 | * 55 | * ![](builder-shortcuts.png) 56 | * 57 | * This example shows a #GtkShortcutsWindow with two sections, "Editor Shortcuts" 58 | * and "Terminal Shortcuts". 59 | * 60 | * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-builder.ui). */ 61 | @GtkDsl 62 | abstract class ShortcutsWindow : Window() { 63 | private val self: CPointer 64 | get() = widgetPtr!!.reinterpret() 65 | 66 | val onClose: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "close", staticCFunction(::ShortcutsWindow_onClose_Handler)) } 67 | 68 | val onSearch: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "search", staticCFunction(::ShortcutsWindow_onSearch_Handler)) } 69 | } 70 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Spinner.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkSpinner 7 | import libgtk3.GtkWidget 8 | import libgtk3.gtk_spinner_new 9 | import libgtk3.gtk_spinner_start 10 | import libgtk3.gtk_spinner_stop 11 | 12 | inline fun Container.spinner(init: Spinner.() -> Unit = {}): Spinner = Spinner().apply { init(); this@spinner.add(this) } 13 | 14 | /** 15 | * A GtkSpinner widget displays an icon-size spinning animation. 16 | * It is often used as an alternative to a #GtkProgressBar for 17 | * displaying indefinite activity, instead of actual progress. 18 | * 19 | * To start the animation, use gtk_spinner_start(), to stop it 20 | * use gtk_spinner_stop(). 21 | * 22 | * # CSS nodes 23 | * 24 | * GtkSpinner has a single CSS node with the name spinner. When the animation is 25 | * active, the :checked pseudoclass is added to this node. */ 26 | @GtkDsl 27 | open class Spinner internal constructor(override val widgetPtr: CPointer? = null) : Widget() { 28 | private val self: CPointer? 29 | get() = widgetPtr!!.reinterpret() 30 | 31 | val spinner: CPointer? 32 | get() = widgetPtr!!.reinterpret() 33 | 34 | /** 35 | * Returns a new spinner widget. Not yet started. */ 36 | constructor() : this(gtk_spinner_new()?.reinterpret()) 37 | 38 | /** 39 | * Starts the animation of the spinner. */ 40 | fun start(): Unit = gtk_spinner_start(self) 41 | 42 | /** 43 | * Stops the animation of the spinner. */ 44 | fun stop(): Unit = gtk_spinner_stop(self) 45 | } 46 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/StackSidebar.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkStack 7 | import libgtk3.GtkStackSidebar 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_stack_sidebar_get_stack 10 | import libgtk3.gtk_stack_sidebar_new 11 | import libgtk3.gtk_stack_sidebar_set_stack 12 | 13 | inline fun Container.stackSidebar(init: StackSidebar.() -> Unit = {}): StackSidebar = StackSidebar().apply { init(); this@stackSidebar.add(this) } 14 | 15 | /** 16 | * A GtkStackSidebar enables you to quickly and easily provide a 17 | * consistent "sidebar" object for your user interface. 18 | * 19 | * In order to use a GtkStackSidebar, you simply use a GtkStack to 20 | * organize your UI flow, and add the sidebar to your sidebar area. You 21 | * can use gtk_stack_sidebar_set_stack() to connect the #GtkStackSidebar 22 | * to the #GtkStack. 23 | * 24 | * # CSS nodes 25 | * 26 | * GtkStackSidebar has a single CSS node with name stacksidebar and 27 | * style class .sidebar. 28 | * 29 | * When circumstances require it, GtkStackSidebar adds the 30 | * .needs-attention style class to the widgets representing the stack 31 | * pages. */ 32 | @GtkDsl 33 | open class StackSidebar internal constructor(override val widgetPtr: CPointer? = null) : Bin() { 34 | private val self: CPointer? 35 | get() = widgetPtr!!.reinterpret() 36 | 37 | val stackSidebar: CPointer? 38 | get() = widgetPtr!!.reinterpret() 39 | 40 | var stack: CPointer? 41 | /** 42 | * Retrieves the stack. 43 | * See gtk_stack_sidebar_set_stack(). */ 44 | get() = gtk_stack_sidebar_get_stack(self)!!.reinterpret() 45 | /** 46 | * Set the #GtkStack associated with this #GtkStackSidebar. 47 | * 48 | * The sidebar widget will automatically update according to the order 49 | * (packing) and items within the given #GtkStack. */ 50 | set(value) { 51 | gtk_stack_sidebar_set_stack(self, value?.reinterpret()) 52 | } 53 | 54 | /** 55 | * Creates a new sidebar. */ 56 | constructor() : this(gtk_stack_sidebar_new()?.reinterpret()) 57 | } 58 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/StackSwitcher.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GtkStack 7 | import libgtk3.GtkStackSwitcher 8 | import libgtk3.GtkWidget 9 | import libgtk3.gtk_stack_switcher_get_stack 10 | import libgtk3.gtk_stack_switcher_new 11 | import libgtk3.gtk_stack_switcher_set_stack 12 | 13 | inline fun Container.stackSwitcher(init: StackSwitcher.() -> Unit = {}): StackSwitcher = StackSwitcher().apply { init(); this@stackSwitcher.add(this) } 14 | 15 | /** 16 | * The GtkStackSwitcher widget acts as a controller for a 17 | * #GtkStack; it shows a row of buttons to switch between 18 | * the various pages of the associated stack widget. 19 | * 20 | * All the content for the buttons comes from the child properties 21 | * of the #GtkStack; the button visibility in a #GtkStackSwitcher 22 | * widget is controlled by the visibility of the child in the 23 | * #GtkStack. 24 | * 25 | * It is possible to associate multiple #GtkStackSwitcher widgets 26 | * with the same #GtkStack widget. 27 | * 28 | * The GtkStackSwitcher widget was added in 3.10. 29 | * 30 | * # CSS nodes 31 | * 32 | * GtkStackSwitcher has a single CSS node named stackswitcher and 33 | * style class .stack-switcher. 34 | * 35 | * When circumstances require it, GtkStackSwitcher adds the 36 | * .needs-attention style class to the widgets representing the 37 | * stack pages. */ 38 | @GtkDsl 39 | open class StackSwitcher internal constructor(override val widgetPtr: CPointer? = null) : Box() { 40 | private val self: CPointer? 41 | get() = widgetPtr!!.reinterpret() 42 | 43 | val stackSwitcher: CPointer? 44 | get() = widgetPtr!!.reinterpret() 45 | 46 | var stack: CPointer? 47 | /** 48 | * Retrieves the stack. 49 | * See gtk_stack_switcher_set_stack(). */ 50 | get() = gtk_stack_switcher_get_stack(self)!!.reinterpret() 51 | /** 52 | * Sets the stack to control. */ 53 | set(value) { 54 | gtk_stack_switcher_set_stack(self, value?.reinterpret()) 55 | } 56 | 57 | /** 58 | * Create a new #GtkStackSwitcher. */ 59 | constructor() : this(gtk_stack_switcher_new()?.reinterpret()) 60 | } 61 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Switch.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import libgtk3.GtkSwitch 12 | import libgtk3.GtkWidget 13 | import libgtk3.gtk_false 14 | import libgtk3.gtk_switch_get_active 15 | import libgtk3.gtk_switch_get_state 16 | import libgtk3.gtk_switch_new 17 | import libgtk3.gtk_switch_set_active 18 | import libgtk3.gtk_switch_set_state 19 | import libgtk3.gtk_true 20 | 21 | inline fun Container.switch(init: Switch.() -> Unit = {}): Switch = Switch().apply { init(); this@switch.add(this) } 22 | 23 | private fun Switch_onActivate_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 24 | data?.asStableRef()?.get()?.onActivate?.invoke() 25 | } 26 | 27 | /** 28 | * #GtkSwitch is a widget that has two states: on or off. The user can control 29 | * which state should be active by clicking the empty area, or by dragging the 30 | * handle. 31 | * 32 | * GtkSwitch can also handle situations where the underlying state changes with 33 | * a delay. See #GtkSwitch::state-set for details. 34 | * 35 | * # CSS nodes 36 | * 37 | * |[ 38 | * switch 39 | * ╰── slider 40 | * ]| 41 | * 42 | * GtkSwitch has two css nodes, the main node with the name switch and a subnode 43 | * named slider. Neither of them is using any style classes. */ 44 | @GtkDsl 45 | open class Switch internal constructor(override val widgetPtr: CPointer? = null) : Widget() { 46 | private val self: CPointer? 47 | get() = widgetPtr!!.reinterpret() 48 | 49 | val switch: CPointer? 50 | get() = widgetPtr!!.reinterpret() 51 | 52 | val onActivate: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "activate", staticCFunction(::Switch_onActivate_Handler)) } 53 | 54 | var active: Boolean 55 | /** 56 | * Gets whether the #GtkSwitch is in its “on” or “off” state. */ 57 | get() = gtk_switch_get_active(self) != 0 58 | /** 59 | * Changes the state of @sw to the desired one. */ 60 | set(value) { 61 | gtk_switch_set_active(self, if (value) gtk_true() else gtk_false()) 62 | } 63 | 64 | var state: Boolean 65 | /** 66 | * Gets the underlying state of the #GtkSwitch. */ 67 | get() = gtk_switch_get_state(self) != 0 68 | /** 69 | * Sets the underlying state of the #GtkSwitch. 70 | * 71 | * Normally, this is the same as #GtkSwitch:active, unless the switch 72 | * is set up for delayed state changes. This function is typically 73 | * called from a #GtkSwitch::state-set signal handler. 74 | * 75 | * See #GtkSwitch::state-set for details. */ 76 | set(value) { 77 | gtk_switch_set_state(self, if (value) gtk_true() else gtk_false()) 78 | } 79 | 80 | /** 81 | * Creates a new #GtkSwitch widget. */ 82 | constructor() : this(gtk_switch_new()?.reinterpret()) 83 | } 84 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/ToggleToolButton.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Boolean 4 | import kotlin.Unit 5 | import kotlinx.cinterop.CFunction 6 | import kotlinx.cinterop.COpaquePointer 7 | import kotlinx.cinterop.CPointer 8 | import kotlinx.cinterop.asStableRef 9 | import kotlinx.cinterop.reinterpret 10 | import kotlinx.cinterop.staticCFunction 11 | import libgtk3.GtkToggleToolButton 12 | import libgtk3.GtkWidget 13 | import libgtk3.gtk_false 14 | import libgtk3.gtk_toggle_tool_button_get_active 15 | import libgtk3.gtk_toggle_tool_button_new 16 | import libgtk3.gtk_toggle_tool_button_set_active 17 | import libgtk3.gtk_true 18 | 19 | inline fun Container.toggleToolButton(init: ToggleToolButton.() -> Unit = {}): ToggleToolButton = ToggleToolButton().apply { init(); this@toggleToolButton.add(this) } 20 | 21 | private fun ToggleToolButton_onToggled_Handler(sender: CPointer<*>?, data: COpaquePointer?) { 22 | data?.asStableRef()?.get()?.onToggled?.invoke() 23 | } 24 | 25 | /** 26 | * A #GtkToggleToolButton is a #GtkToolItem that contains a toggle 27 | * button. 28 | * 29 | * Use gtk_toggle_tool_button_new() to create a new GtkToggleToolButton. 30 | * 31 | * # CSS nodes 32 | * 33 | * GtkToggleToolButton has a single CSS node with name togglebutton. */ 34 | @GtkDsl 35 | open class ToggleToolButton internal constructor(override val widgetPtr: CPointer? = null) : ToolButton() { 36 | private val self: CPointer? 37 | get() = widgetPtr!!.reinterpret() 38 | 39 | val toggleToolButton: CPointer? 40 | get() = widgetPtr!!.reinterpret() 41 | 42 | val onToggled: Signal?, COpaquePointer?) -> Unit>> by lazy { Signal?, COpaquePointer?) -> Unit>>(widgetPtr!!, this, "toggled", staticCFunction(::ToggleToolButton_onToggled_Handler)) } 43 | 44 | var active: Boolean 45 | /** 46 | * Queries a #GtkToggleToolButton and returns its current state. 47 | * Returns %TRUE if the toggle button is pressed in and %FALSE if it is raised. */ 48 | get() = gtk_toggle_tool_button_get_active(self) != 0 49 | /** 50 | * Sets the status of the toggle tool button. Set to %TRUE if you 51 | * want the GtkToggleButton to be “pressed in”, and %FALSE to raise it. 52 | * This action causes the toggled signal to be emitted. */ 53 | set(value) { 54 | gtk_toggle_tool_button_set_active(self, if (value) gtk_true() else gtk_false()) 55 | } 56 | 57 | /** 58 | * Returns a new #GtkToggleToolButton */ 59 | constructor() : this(gtk_toggle_tool_button_new()?.reinterpret()) 60 | } 61 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/gtk3/Viewport.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlin.Unit 4 | import kotlinx.cinterop.CPointer 5 | import kotlinx.cinterop.reinterpret 6 | import libgtk3.GdkWindow 7 | import libgtk3.GtkAdjustment 8 | import libgtk3.GtkShadowType 9 | import libgtk3.GtkViewport 10 | import libgtk3.GtkWidget 11 | import libgtk3.gtk_viewport_get_bin_window 12 | import libgtk3.gtk_viewport_get_shadow_type 13 | import libgtk3.gtk_viewport_get_view_window 14 | import libgtk3.gtk_viewport_new 15 | import libgtk3.gtk_viewport_set_shadow_type 16 | 17 | inline fun Container.viewport( 18 | hadjustment: CPointer?, 19 | vadjustment: CPointer?, 20 | init: Viewport.() -> Unit = {} 21 | ): Viewport = Viewport(hadjustment, vadjustment).apply { init(); this@viewport.add(this) } 22 | 23 | /** 24 | * The #GtkViewport widget acts as an adaptor class, implementing 25 | * scrollability for child widgets that lack their own scrolling 26 | * capabilities. Use GtkViewport to scroll child widgets such as 27 | * #GtkGrid, #GtkBox, and so on. 28 | * 29 | * If a widget has native scrolling abilities, such as #GtkTextView, 30 | * #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow 31 | * with gtk_container_add(). If a widget does not, you must first add the 32 | * widget to a #GtkViewport, then add the viewport to the scrolled window. 33 | * gtk_container_add() does this automatically if a child that does not 34 | * implement #GtkScrollable is added to a #GtkScrolledWindow, so you can 35 | * ignore the presence of the viewport. 36 | * 37 | * The GtkViewport will start scrolling content only if allocated less 38 | * than the child widget’s minimum size in a given orientation. 39 | * 40 | * # CSS nodes 41 | * 42 | * GtkViewport has a single CSS node with name viewport. */ 43 | @GtkDsl 44 | open class Viewport internal constructor(override val widgetPtr: CPointer? = null) : Bin() { 45 | private val self: CPointer? 46 | get() = widgetPtr!!.reinterpret() 47 | 48 | val viewport: CPointer? 49 | get() = widgetPtr!!.reinterpret() 50 | 51 | val binWindow: CPointer? 52 | /** 53 | * Gets the bin window of the #GtkViewport. */ 54 | get() = gtk_viewport_get_bin_window(self)!!.reinterpret() 55 | 56 | var shadowType: GtkShadowType 57 | /** 58 | * Gets the shadow type of the #GtkViewport. See 59 | * gtk_viewport_set_shadow_type(). */ 60 | get() = gtk_viewport_get_shadow_type(self) 61 | /** 62 | * Sets the shadow type of the viewport. */ 63 | set(value) { 64 | gtk_viewport_set_shadow_type(self, value) 65 | } 66 | 67 | val viewWindow: CPointer? 68 | /** 69 | * Gets the view window of the #GtkViewport. */ 70 | get() = gtk_viewport_get_view_window(self)!!.reinterpret() 71 | 72 | /** 73 | * Creates a new #GtkViewport with the given adjustments, or with default 74 | * adjustments if none are given. */ 75 | constructor(hadjustment: CPointer?, vadjustment: CPointer?) : this(gtk_viewport_new(hadjustment?.reinterpret(), vadjustment?.reinterpret())?.reinterpret()) 76 | } 77 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/helpers.kt: -------------------------------------------------------------------------------- 1 | package gtk3 2 | 3 | import kotlinx.cinterop.* 4 | 5 | fun CPointer>?.toList(): List { 6 | if (this == null) return emptyList() 7 | val result = mutableListOf() 8 | var i = 0 9 | while (true) { 10 | val it = this[i] ?: break 11 | result += it.toKString() 12 | i++ 13 | } 14 | return result 15 | } 16 | --------------------------------------------------------------------------------