adds vendor directory

vendors dependencies in standard `vendor` directory, managed by glide
This commit is contained in:
Jon Chen
2017-05-14 19:35:03 -07:00
parent 070aa50762
commit 737231705f
2173 changed files with 2312028 additions and 0 deletions

32
vendor/github.com/mattn/go-gtk/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,32 @@
*~
_obj
*.cgo?.*
_cgo_*
main
*.exe
tags
# example binaries
example/action/action
example/alignment/alignment
example/arrow/arrow
example/builder/builder
example/clipboard/clipboard
example/demo/demo
example/dnd/dnd
example/drawable/drawable
example/event/event
example/expander/expander
example/iconview/iconview
example/listview/listview
example/locale/locale
example/notebook/notebook
example/number/number
example/sourceview/sourceview
example/spinbutton/spinbutton
example/statusicon/statusicon
example/table/table
example/thread/thread
example/toolbar/toolbar
example/treeview/treeview
example/twitterstream/twitterstream

4
vendor/github.com/mattn/go-gtk/.gitmodules generated vendored Normal file
View File

@@ -0,0 +1,4 @@
[submodule "docs"]
path = docs
url = git@github.com:mattn/go-gtk.git
branch = gh-pages

1
vendor/github.com/mattn/go-gtk/.test generated vendored Executable file
View File

@@ -0,0 +1 @@
make example

28
vendor/github.com/mattn/go-gtk/Makefile generated vendored Normal file
View File

@@ -0,0 +1,28 @@
include example/example.mk
.DEFAULT_GOAL := all
.PHONY: all
all:
cd pango && go get -x
cd glib && go get -x
cd gdk && go get -x
cd gdkpixbuf && go get -x
cd gtk && go get -x
cd gtksourceview && go get -x
#cd gtkgl && go get -x .
#cd gtkspell && go get -x .
.PHONY: all
fmt:
cd pango && go fmt .
cd glib && go fmt .
cd gdk && go fmt .
cd gdkpixbuf && go fmt .
cd gtk && go fmt .
cd gtksourceview && go fmt .
#cd gtkgl && go fmt .
#cd gtkspell && go fmt .
.PHONY: clean
clean: clean-example
@true

259
vendor/github.com/mattn/go-gtk/README.md generated vendored Normal file
View File

@@ -0,0 +1,259 @@
# go-gtk
## WHATS
Go bindings for GTK
## SCREENSHOT
![Go GTK!](https://github.com/mattn/go-gtk/raw/gh-pages/static/images/screenshot.png "Go GTK!")
## INSTALL
You can experiment with go-gtk
by running the various example programs:
git clone https://github.com/mattn/go-gtk
cd go-gtk
make example
./example/demo/demo
Or
go get github.com/mattn/go-gtk/gtk
Don't forget, that you need the GTK-Development-Packages.
If you use linux, you should install `libgtk+-2.0` and packages that depend on gtk.
On Debian and Debian derived distributions you can run (as root):
apt-get install libgtk2.0-dev libglib2.0-dev libgtksourceview2.0-dev
If you use windows, find gtk binary packages from here:
* http://www.gtk.org/download/windows.php
## LICENSE
The library is available under the same terms and conditions as the Go, the BSD style license, and the LGPL (GNU Lesser General Public License). The idea is that if you can use Go (and Gtk) in a project, you should also be able to use go-gtk.
## AUTHOR
* Yasuhiro Matsumoto
## CONTRIBUTE AUTHORS
* David Roundy
* Mark Andrew Gerads
* Tobias Kortkamp
* Mikhail Trushnikov
* Federico Sogaro
* Crazy2be
* Daniël de Kok
* Erik Lissel
* Jeffrey Bolle
* Leonhard Küper
* Matt Joiner
* SQP
* Steven T
* Taru Karttunen
* Utkan Güngördü
* matiaslina
* Dag Robøle
* Denis Dyakov
## GOAL
Hopefully support following widgets and methods enough to run general application.
(output of tools/gogtkinfo)
Main Loop and Events : 30% ( 8/ 26)
GtkAccelGroup : 15% ( 3/ 19)
GtkAccelMap : 0% ( 0/ 14)
GtkClipboard : 25% ( 8/ 31)
Drag and Drop : 11% ( 4/ 35)
GtkIconTheme : 0% ( 0/ 31)
GtkStockItem : 66% ( 4/ 6)
Themeable Stock Images : 0% ( 0/ 41)
Resource Files : 14% ( 4/ 28)
GtkSettings : 40% ( 6/ 15)
GtkBinding : 0% ( 0/ 14)
Graphics Contexts : 0% ( 0/ 2)
GtkStyle : 9% ( 6/ 64)
Selections : 8% ( 4/ 47)
Version Information : 0% ( 0/ 6)
Testing : 0% ( 0/ 16)
Filesystem Utilities : 0% ( 0/ 7)
GtkDialog : 45% ( 9/ 20)
GtkMessageDialog : 62% ( 5/ 8)
GtkWindow : 49% ( 50/102)
GtkWindowGroup : 0% ( 0/ 5)
GtkAboutDialog : 90% ( 29/ 32)
GtkAssistant : 91% ( 21/ 23)
GtkOffscreenWindow : 0% ( 0/ 3)
GtkAccelLabel : 83% ( 5/ 6)
GtkImage : 32% ( 10/ 31)
GtkLabel : 86% ( 39/ 45)
GtkProgressBar : 100% ( 12/ 12)
GtkStatusbar : 77% ( 7/ 9)
GtkInfoBar : 100% ( 12/ 12)
GtkStatusIcon : 68% ( 26/ 38)
GtkSpinner : 100% ( 3/ 3)
GtkButton : 100% ( 28/ 28)
GtkCheckButton : 100% ( 3/ 3)
GtkRadioButton : 100% ( 8/ 8)
GtkToggleButton : 100% ( 9/ 9)
GtkLinkButton : 75% ( 6/ 8)
GtkScaleButton : 100% ( 9/ 9)
GtkVolumeButton : 100% ( 1/ 1)
GtkEntry : 41% ( 26/ 63)
GtkEntryBuffer : 72% ( 8/ 11)
GtkEntryCompletion : 96% ( 25/ 26)
GtkHScale : 100% ( 2/ 2)
GtkVScale : 100% ( 2/ 2)
GtkSpinButton : 100% ( 30/ 30)
GtkEditable : 100% ( 13/ 13)
GtkTextIter : 25% ( 23/ 91)
GtkTextMark : 0% ( 0/ 7)
GtkTextBuffer : 67% ( 52/ 77)
GtkTextTag : 83% ( 5/ 6)
GtkTextAttributes : 100% ( 5/ 5)
GtkTextTagTable : 83% ( 5/ 6)
GtkTextView : 29% ( 19/ 64)
GtkTreePath : 90% ( 18/ 20)
GtkTreeRowReference : 60% ( 6/ 10)
GtkTreeIter : 100% ( 2/ 2)
GtkTreeModel : 57% ( 15/ 26)
GtkTreeSelection : 78% ( 18/ 23)
GtkTreeViewColumn : 61% ( 34/ 55)
GtkTreeView : 18% ( 18/ 98)
GtkTreeView drag-and-drop : 0% ( 0/ 7)
GtkCellView : 0% ( 0/ 11)
GtkIconView : 17% ( 11/ 62)
GtkTreeSortable : 62% ( 5/ 8)
GtkTreeModelSort : 0% ( 0/ 9)
GtkTreeModelFilter : 0% ( 0/ 11)
GtkCellLayout : 0% ( 0/ 9)
GtkCellRenderer : 100% ( 2/ 2)
GtkCellEditable : 0% ( 0/ 3)
GtkCellRendererAccel : 100% ( 1/ 1)
GtkCellRendererCombo : 100% ( 1/ 1)
GtkCellRendererPixbuf : 100% ( 1/ 1)
GtkCellRendererProgress : 100% ( 1/ 1)
GtkCellRendererSpin : 100% ( 1/ 1)
GtkCellRendererText : 100% ( 2/ 2)
GtkCellRendererToggle : 100% ( 7/ 7)
GtkCellRendererSpinner : 100% ( 1/ 1)
GtkListStore : 84% ( 16/ 19)
GtkTreeStore : 80% ( 17/ 21)
GtkComboBox : 78% ( 30/ 38)
GtkComboBoxText : 100% ( 7/ 7)
GtkComboBoxEntry : 80% ( 4/ 5)
GtkMenu : 50% ( 15/ 30)
GtkMenuBar : 100% ( 8/ 8)
GtkMenuItem : 90% ( 18/ 20)
GtkImageMenuItem : 54% ( 6/ 11)
GtkRadioMenuItem : 44% ( 4/ 9)
GtkCheckMenuItem : 100% ( 10/ 10)
GtkSeparatorMenuItem : 100% ( 1/ 1)
GtkTearoffMenuItem : 100% ( 1/ 1)
GtkToolShell : 0% ( 0/ 9)
GtkToolbar : 63% ( 24/ 38)
GtkToolItem : 76% ( 19/ 25)
GtkToolPalette : 59% ( 13/ 22)
GtkToolItemGroup : 47% ( 8/ 17)
GtkSeparatorToolItem : 100% ( 3/ 3)
GtkToolButton : 100% ( 15/ 15)
GtkMenuToolButton : 85% ( 6/ 7)
GtkToggleToolButton : 100% ( 5/ 5)
GtkRadioToolButton : 33% ( 2/ 6)
GtkUIManager : 29% ( 5/ 17)
GtkActionGroup : 55% ( 11/ 20)
GtkAction : 93% ( 44/ 47)
GtkToggleAction : 100% ( 6/ 6)
GtkRadioAction : 100% ( 5/ 5)
GtkRecentAction : 75% ( 3/ 4)
GtkActivatable : 66% ( 4/ 6)
GtkColorButton : 100% ( 10/ 10)
GtkColorSelectionDialog : 0% ( 0/ 2)
GtkColorSelection : 0% ( 0/ 21)
GtkHSV : 0% ( 0/ 8)
GtkFileChooser : 22% ( 13/ 58)
GtkFileChooserButton : 18% ( 2/ 11)
GtkFileChooserDialog : 100% ( 1/ 1)
GtkFileChooserWidget : 50% ( 1/ 2)
GtkFileFilter : 55% ( 5/ 9)
GtkFontButton : 100% ( 14/ 14)
GtkFontSelection : 28% ( 4/ 14)
GtkFontSelectionDialog : 100% ( 8/ 8)
GtkInputDialog : 0% ( 0/ 1)
GtkAlignment : 100% ( 4/ 4)
GtkAspectFrame : 0% ( 0/ 2)
GtkHBox : 100% ( 1/ 1)
GtkVBox : 100% ( 1/ 1)
GtkHButtonBox : 0% ( 0/ 5)
GtkVButtonBox : 0% ( 0/ 5)
GtkFixed : 100% ( 5/ 5)
GtkHPaned : 100% ( 1/ 1)
GtkVPaned : 100% ( 1/ 1)
GtkLayout : 100% ( 12/ 12)
GtkNotebook : 90% ( 50/ 55)
GtkTable : 93% ( 14/ 15)
GtkExpander : 87% ( 14/ 16)
GtkOrientable : 0% ( 0/ 2)
GtkFrame : 100% ( 9/ 9)
GtkHSeparator : 100% ( 1/ 1)
GtkVSeparator : 100% ( 1/ 1)
GtkScrollbar : 100% ( 0/ 0)
GtkHScrollbar : 100% ( 1/ 1)
GtkVScrollbar : 100% ( 1/ 1)
GtkScrolledWindow : 86% ( 13/ 15)
GtkPrintOperation : 13% ( 5/ 36)
GtkPrintContext : 18% ( 2/ 11)
GtkPrintSettings : 0% ( 0/ 74)
GtkPageSetup : 0% ( 0/ 25)
GtkPaperSize : 0% ( 0/ 21)
GtkPrinter : 0% ( 0/ 23)
GtkPrintJob : 0% ( 0/ 10)
GtkPrintUnixDialog : 0% ( 0/ 18)
GtkPageSetupUnixDialog : 0% ( 0/ 5)
GtkAdjustment : 83% ( 15/ 18)
GtkArrow : 100% ( 2/ 2)
GtkCalendar : 0% ( 0/ 17)
GtkDrawingArea : 100% ( 2/ 2)
GtkEventBox : 20% ( 1/ 5)
GtkHandleBox : 0% ( 0/ 8)
GtkIMContextSimple : 0% ( 0/ 2)
GtkIMMulticontext : 0% ( 0/ 4)
GtkSizeGroup : 100% ( 8/ 8)
GtkTooltip : 60% ( 6/ 10)
GtkViewport : 100% ( 9/ 9)
GtkAccessible : 100% ( 3/ 3)
GtkBin : 100% ( 1/ 1)
GtkBox : 100% ( 11/ 11)
GtkButtonBox : 0% ( 0/ 10)
GtkContainer : 48% ( 16/ 33)
GtkItem : 100% ( 3/ 3)
GtkMenuShell : 0% ( 0/ 11)
GtkMisc : 100% ( 4/ 4)
GtkObject : 100% ( 2/ 2)
GtkPaned : 88% ( 8/ 9)
GtkRange : 53% ( 16/ 30)
GtkScale : 90% ( 9/ 10)
GtkSeparator : 100% ( 0/ 0)
GtkWidget : 54% (101/187)
GtkIMContext : 0% ( 0/ 11)
GtkPlug : 0% ( 0/ 7)
GtkSocket : 0% ( 0/ 5)
GtkRecentManager : 0% ( 0/ 37)
GtkRecentChooser : 0% ( 0/ 33)
GtkRecentChooserDialog : 0% ( 0/ 2)
GtkRecentChooserMenu : 0% ( 0/ 4)
GtkRecentChooserWidget : 0% ( 0/ 2)
GtkRecentFilter : 0% ( 0/ 12)
GtkBuildable : 0% ( 0/ 10)
Total progress : 47% (1519/3180)

4
vendor/github.com/mattn/go-gtk/TODO generated vendored Normal file
View File

@@ -0,0 +1,4 @@
* more widgets.
* main loop handling (using goroutine) (done)
* split gtksourceview from gtk package (done)
* copyright header in sources

BIN
vendor/github.com/mattn/go-gtk/data/go-gtk-logo.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
vendor/github.com/mattn/go-gtk/data/mattn-logo.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
vendor/github.com/mattn/go-gtk/data/win32-demo.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
vendor/github.com/mattn/go-gtk/data/win32-twitter.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

222
vendor/github.com/mattn/go-gtk/example/action/action.go generated vendored Normal file
View File

@@ -0,0 +1,222 @@
package main
import (
"fmt"
"reflect"
"unsafe"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func CreateWindow() *gtk.Window {
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetDefaultSize(700, 300)
vbox := gtk.NewVBox(false, 1)
CreateMenuAndToolbar(window, vbox)
CreateActivatableDemo(vbox)
window.Add(vbox)
return window
}
func CreateMenuAndToolbar(w *gtk.Window, vbox *gtk.VBox) {
action_group := gtk.NewActionGroup("my_group")
ui_manager := CreateUIManager()
accel_group := ui_manager.GetAccelGroup()
w.AddAccelGroup(accel_group)
AddFileMenuActions(action_group)
AddEditMenuActions(action_group)
AddChoicesMenuActions(action_group)
ui_manager.InsertActionGroup(action_group, 0)
menubar := ui_manager.GetWidget("/MenuBar")
vbox.PackStart(menubar, false, false, 0)
toolbar := ui_manager.GetWidget("/ToolBar")
vbox.PackStart(toolbar, false, false, 0)
eventbox := gtk.NewEventBox()
vbox.PackStart(eventbox, false, false, 0)
// label := gtk.NewLabel("Right-click to see the popup menu.")
// vbox.PackStart(label, false, false, 0)
}
func CreateActivatableDemo(vbox *gtk.VBox) {
action_entry := gtk.NewAction("ActionEntry",
"Button attached to Action", "", gtk.STOCK_INFO)
action_entry.Connect("activate", func() {
fmt.Println("Action clicked")
})
frame1 := gtk.NewFrame("GtkActivatable interface demonstration")
frame1.SetBorderWidth(5)
hbox2 := gtk.NewHBox(false, 5)
hbox2.SetSizeRequest(400, 50)
hbox2.SetBorderWidth(5)
button1 := gtk.NewButton()
button1.SetSizeRequest(250, 0)
button1.SetRelatedAction(action_entry)
hbox2.PackStart(button1, false, false, 0)
hbox2.PackStart(gtk.NewVSeparator(), false, false, 0)
button2 := gtk.NewButtonWithLabel("Hide Action")
button2.SetSizeRequest(150, 0)
button2.Connect("clicked", func() {
action_entry.SetVisible(false)
fmt.Println("Hide Action")
})
hbox2.PackStart(button2, false, false, 0)
button3 := gtk.NewButtonWithLabel("Unhide Action")
button3.SetSizeRequest(150, 0)
button3.Connect("clicked", func() {
action_entry.SetVisible(true)
fmt.Println("Show Action")
})
hbox2.PackStart(button3, false, false, 0)
frame1.Add(hbox2)
vbox.PackStart(frame1, false, true, 0)
}
func CreateUIManager() *gtk.UIManager {
UI_INFO := `
<ui>
<menubar name='MenuBar'>
<menu action='FileMenu'>
<menu action='FileNew'>
<menuitem action='FileNewStandard' />
<menuitem action='FileNewFoo' />
<menuitem action='FileNewGoo' />
</menu>
<separator />
<menuitem action='FileQuit' />
</menu>
<menu action='EditMenu'>
<menuitem action='EditCopy' />
<menuitem action='EditPaste' />
<menuitem action='EditSomething' />
</menu>
<menu action='ChoicesMenu'>
<menuitem action='ChoiceOne'/>
<menuitem action='ChoiceTwo'/>
<menuitem action='ChoiceThree'/>
<separator />
<menuitem action='ChoiceToggle'/>
</menu>
</menubar>
<toolbar name='ToolBar'>
<toolitem action='FileNewStandard' />
<toolitem action='FileQuit' />
</toolbar>
<popup name='PopupMenu'>
<menuitem action='EditCopy' />
<menuitem action='EditPaste' />
<menuitem action='EditSomething' />
</popup>
</ui>
`
ui_manager := gtk.NewUIManager()
ui_manager.AddUIFromString(UI_INFO)
return ui_manager
}
func OnMenuFileNewGeneric() {
fmt.Println("A File|New menu item was selected.")
}
func OnMenuFileQuit() {
fmt.Println("quit app...")
gtk.MainQuit()
}
func OnMenuOther(ctx *glib.CallbackContext) {
v := reflect.ValueOf(ctx.Target())
if v.Kind() == reflect.Ptr {
fmt.Printf("Item %s(%p) was selected", v.Elem(), v.Interface())
fmt.Println()
if w, ok := v.Elem().Interface().(gtk.IWidget); ok {
v := reflect.ValueOf(ctx.Target())
v2 := v.Elem()
fmt.Println(v.Kind(), v2.Kind())
fmt.Println("Menu item ", w.GetName(), " was selected")
}
}
}
func OnMenuOther2(widget unsafe.Pointer, event unsafe.Pointer,
data unsafe.Pointer) {
fmt.Println("Menu item ", "", " was selected")
}
func AddFileMenuActions(action_group *gtk.ActionGroup) {
action_group.AddAction(gtk.NewAction("FileMenu", "File", "", ""))
action_filenewmenu := gtk.NewAction("FileNew", "", "", gtk.STOCK_NEW)
action_group.AddAction(action_filenewmenu)
action_new := gtk.NewAction("FileNewStandard", "_New",
"Create a new file", gtk.STOCK_NEW)
action_new.Connect("activate", OnMenuFileNewGeneric)
action_group.AddActionWithAccel(action_new, "")
action_new_foo := gtk.NewAction("FileNewFoo", "New Foo",
"Create new foo", gtk.STOCK_NEW)
action_new_foo.Connect("activate", OnMenuFileNewGeneric)
action_group.AddAction(action_new_foo)
action_new_goo := gtk.NewAction("FileNewGoo", "_New Goo",
"Create new goo", gtk.STOCK_NEW)
action_new_goo.Connect("activate", OnMenuFileNewGeneric)
action_group.AddAction(action_new_goo)
action_filequit := gtk.NewAction("FileQuit", "", "", gtk.STOCK_QUIT)
action_filequit.Connect("activate", OnMenuFileQuit)
action_group.AddActionWithAccel(action_filequit, "")
}
func AddEditMenuActions(action_group *gtk.ActionGroup) {
action_group.AddAction(gtk.NewAction("EditMenu", "Edit", "", ""))
action_editcopy := gtk.NewAction("EditCopy", "", "", gtk.STOCK_COPY)
action_editcopy.Connect("activate", OnMenuOther)
action_group.AddActionWithAccel(action_editcopy, "")
action_editpaste := gtk.NewAction("EditPaste", "", "", gtk.STOCK_PASTE)
action_editpaste.Connect("activate", OnMenuOther)
action_group.AddActionWithAccel(action_editpaste, "")
action_editsomething := gtk.NewAction("EditSomething", "Something", "", "")
action_editsomething.Connect("activate", OnMenuOther)
action_group.AddActionWithAccel(action_editsomething, "<control><alt>S")
}
func AddChoicesMenuActions(action_group *gtk.ActionGroup) {
action_group.AddAction(gtk.NewAction("ChoicesMenu", "Choices", "", ""))
var ra_list []*gtk.RadioAction
ra_one := gtk.NewRadioAction("ChoiceOne", "One", "", "", 1)
ra_list = append(ra_list, ra_one)
ra_two := gtk.NewRadioAction("ChoiceTwo", "Two", "", "", 2)
ra_list = append(ra_list, ra_two)
ra_three := gtk.NewRadioAction("ChoiceThree", "Three", "", "", 2)
ra_list = append(ra_list, ra_three)
var sl *glib.SList
for _, ra := range ra_list {
ra.SetGroup(sl)
sl = ra.GetGroup()
action_group.AddAction(ra)
}
ra_last := gtk.NewToggleAction("ChoiceToggle", "Toggle", "", "")
ra_last.SetActive(true)
action_group.AddAction(ra_last)
}
func main() {
gtk.Init(nil)
window := CreateWindow()
window.SetPosition(gtk.WIN_POS_CENTER)
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("destroy pending...")
gtk.MainQuit()
}, "foo")
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,43 @@
package main
import (
"github.com/mattn/go-gtk/gtk"
"os"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Alignment")
window.Connect("destroy", gtk.MainQuit)
notebook := gtk.NewNotebook()
window.Add(notebook)
align := gtk.NewAlignment(0.5, 0.5, 0.5, 0.5)
notebook.AppendPage(align, gtk.NewLabel("Alignment"))
button := gtk.NewButtonWithLabel("Hello World!")
align.Add(button)
fixed := gtk.NewFixed()
notebook.AppendPage(fixed, gtk.NewLabel("Fixed"))
button2 := gtk.NewButtonWithLabel("Pulse")
fixed.Put(button2, 30, 30)
progress := gtk.NewProgressBar()
fixed.Put(progress, 30, 70)
button.Connect("clicked", func() {
progress.SetFraction(0.1 + 0.9*progress.GetFraction()) //easter egg
})
button2.Connect("clicked", func() {
progress.Pulse()
})
window.ShowAll()
window.SetSizeRequest(200, 200)
gtk.Main()
}

48
vendor/github.com/mattn/go-gtk/example/arrow/arrow.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package main
import (
"github.com/mattn/go-gtk/gtk"
"os"
)
func createArrowButton(at gtk.ArrowType, st gtk.ShadowType) *gtk.Button {
b := gtk.NewButton()
a := gtk.NewArrow(at, st)
b.Add(a)
b.Show()
a.Show()
return b
}
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Arrow Buttons")
window.Connect("destroy", gtk.MainQuit)
box := gtk.NewHBox(false, 0)
box.Show()
window.Add(box)
up := createArrowButton(gtk.ARROW_UP, gtk.SHADOW_IN)
down := createArrowButton(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
left := createArrowButton(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
right := createArrowButton(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)
box.PackStart(up, false, false, 3)
box.PackStart(down, false, false, 3)
box.PackStart(left, false, false, 3)
box.PackStart(right, false, false, 3)
up.Clicked(func() { println("↑") })
down.Clicked(func() { println("↓") })
left.Clicked(func() { println("←") })
right.Clicked(func() { println("→") })
window.Show()
gtk.Main()
}

View File

@@ -0,0 +1,26 @@
package main
import (
"os"
"github.com/mattn/go-gtk/example/builder/callback"
"github.com/mattn/go-gtk/gtk"
)
//"github.com/mattn/go-gtk/example/builder/callback"
func main() {
gtk.Init(&os.Args)
builder := gtk.NewBuilder()
builder.AddFromFile("hello.ui")
obj := builder.GetObject("window1")
window := gtk.WidgetFromObject(obj)
window.Show()
window.Connect("destroy", gtk.MainQuit)
callback.Init(builder)
gtk.Main()
}

View File

@@ -0,0 +1,37 @@
package callback
import (
"unsafe"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
var aboutdialog *gtk.AboutDialog
func Init(builder *gtk.Builder) {
aboutdialog = &gtk.AboutDialog{
*(*gtk.Dialog)(unsafe.Pointer(&builder.GetObject("aboutdialog1").Object))}
builder.ConnectSignalsFull(func(builder *gtk.Builder, obj *glib.GObject, sig, handler string, conn *glib.GObject, flags glib.ConnectFlags, user_data interface{}) {
switch handler {
case "on_imagemenuitem1_activate":
obj.SignalConnect(sig, on_imagemenuitem1_activate, user_data, flags)
case "on_show_aboutdialog_activate":
obj.SignalConnect(sig, on_show_aboutdialog_activate, user_data, flags)
case "gtk_widget_hide":
obj.SignalConnect(sig, func(c *glib.CallbackContext) {
gtk.WidgetFromObject(c.Target().(*glib.GObject)).Hide()
}, nil, flags)
}
}, nil)
}
//export on_imagemenuitem1_activate
func on_imagemenuitem1_activate() {
gtk.MainQuit()
}
//export on_show_aboutdialog_activate
func on_show_aboutdialog_activate() {
aboutdialog.Run()
}

139
vendor/github.com/mattn/go-gtk/example/builder/hello.ui generated vendored Normal file
View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAboutDialog" id="aboutdialog1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="program_name">go-gtk builder</property>
<property name="version">0.1</property>
<property name="copyright">The library is available under the same terms and conditions as the Go,
the BSD style license, and the LGPL (Lesser GNU Public License).
The idea is that if you can use Go (and Gtk) in a project, you should also be able to use go-gtk.</property>
<property name="comments" translatable="yes">example program for go-gtk</property>
<property name="website">https://github.com/mattn/go-gtk</property>
<property name="authors">Yasuhiro Matsumoto</property>
<signal name="response" handler="gtk_widget_hide" swapped="no"/>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">../../data/mattn-logo.png</property>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="title" translatable="yes">builder</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="file">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="exit">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="do_exit">
<property name="label">gtk-quit</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_imagemenuitem1_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="help">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_justified">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="about">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="show_aboutdialog">
<property name="label">gtk-about</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_show_aboutdialog_activate" after="yes" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="linkbutton1">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup">&lt;b&gt;http://mattn.kaoriya.net/&lt;/b&gt;</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="uri">http://mattn.kaoriya.net/</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -0,0 +1,19 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
clipboard := gtk.NewClipboardGetForDisplay(
gdk.DisplayGetDefault(),
gdk.SELECTION_CLIPBOARD)
fmt.Println(clipboard.WaitForText())
clipboard.SetText("helloworld")
gtk.MainIterationDo(true)
clipboard.Store()
gtk.MainIterationDo(true)
}

355
vendor/github.com/mattn/go-gtk/example/demo/demo.go generated vendored Normal file
View File

@@ -0,0 +1,355 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/gdkpixbuf"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
)
func uniq(strings []string) (ret []string) {
return
}
func authors() []string {
if b, err := exec.Command("git", "log").Output(); err == nil {
lines := strings.Split(string(b), "\n")
var a []string
r := regexp.MustCompile(`^Author:\s*([^ <]+).*$`)
for _, e := range lines {
ms := r.FindStringSubmatch(e)
if ms == nil {
continue
}
a = append(a, ms[1])
}
sort.Strings(a)
var p string
lines = []string{}
for _, e := range a {
if p == e {
continue
}
lines = append(lines, e)
p = e
}
return lines
}
return []string{"Yasuhiro Matsumoto <mattn.jp@gmail.com>"}
}
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
//--------------------------------------------------------
// GtkVBox
//--------------------------------------------------------
vbox := gtk.NewVBox(false, 1)
//--------------------------------------------------------
// GtkMenuBar
//--------------------------------------------------------
menubar := gtk.NewMenuBar()
vbox.PackStart(menubar, false, false, 0)
//--------------------------------------------------------
// GtkVPaned
//--------------------------------------------------------
vpaned := gtk.NewVPaned()
vbox.Add(vpaned)
//--------------------------------------------------------
// GtkFrame
//--------------------------------------------------------
frame1 := gtk.NewFrame("Demo")
framebox1 := gtk.NewVBox(false, 1)
frame1.Add(framebox1)
frame2 := gtk.NewFrame("Demo")
framebox2 := gtk.NewVBox(false, 1)
frame2.Add(framebox2)
vpaned.Pack1(frame1, false, false)
vpaned.Pack2(frame2, false, false)
//--------------------------------------------------------
// GtkImage
//--------------------------------------------------------
dir, _ := filepath.Split(os.Args[0])
imagefile := filepath.Join(dir, "../../data/go-gtk-logo.png")
label := gtk.NewLabel("Go Binding for GTK")
label.ModifyFontEasy("DejaVu Serif 15")
framebox1.PackStart(label, false, true, 0)
//--------------------------------------------------------
// GtkEntry
//--------------------------------------------------------
entry := gtk.NewEntry()
entry.SetText("Hello world")
framebox1.Add(entry)
image := gtk.NewImageFromFile(imagefile)
framebox1.Add(image)
//--------------------------------------------------------
// GtkScale
//--------------------------------------------------------
scale := gtk.NewHScaleWithRange(0, 100, 1)
scale.Connect("value-changed", func() {
fmt.Println("scale:", int(scale.GetValue()))
})
framebox2.Add(scale)
//--------------------------------------------------------
// GtkHBox
//--------------------------------------------------------
buttons := gtk.NewHBox(false, 1)
//--------------------------------------------------------
// GtkButton
//--------------------------------------------------------
button := gtk.NewButtonWithLabel("Button with label")
button.Clicked(func() {
fmt.Println("button clicked:", button.GetLabel())
messagedialog := gtk.NewMessageDialog(
button.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
entry.GetText())
messagedialog.Response(func() {
fmt.Println("Dialog OK!")
//--------------------------------------------------------
// GtkFileChooserDialog
//--------------------------------------------------------
filechooserdialog := gtk.NewFileChooserDialog(
"Choose File...",
button.GetTopLevelAsWindow(),
gtk.FILE_CHOOSER_ACTION_OPEN,
gtk.STOCK_OK,
gtk.RESPONSE_ACCEPT)
filter := gtk.NewFileFilter()
filter.AddPattern("*.go")
filechooserdialog.AddFilter(filter)
filechooserdialog.Response(func() {
fmt.Println(filechooserdialog.GetFilename())
filechooserdialog.Destroy()
})
filechooserdialog.Run()
messagedialog.Destroy()
})
messagedialog.Run()
})
buttons.Add(button)
//--------------------------------------------------------
// GtkFontButton
//--------------------------------------------------------
fontbutton := gtk.NewFontButton()
fontbutton.Connect("font-set", func() {
fmt.Println("title:", fontbutton.GetTitle())
fmt.Println("fontname:", fontbutton.GetFontName())
fmt.Println("use_size:", fontbutton.GetUseSize())
fmt.Println("show_size:", fontbutton.GetShowSize())
})
buttons.Add(fontbutton)
framebox2.PackStart(buttons, false, false, 0)
buttons = gtk.NewHBox(false, 1)
//--------------------------------------------------------
// GtkToggleButton
//--------------------------------------------------------
togglebutton := gtk.NewToggleButtonWithLabel("ToggleButton with label")
togglebutton.Connect("toggled", func() {
if togglebutton.GetActive() {
togglebutton.SetLabel("ToggleButton ON!")
} else {
togglebutton.SetLabel("ToggleButton OFF!")
}
})
buttons.Add(togglebutton)
//--------------------------------------------------------
// GtkCheckButton
//--------------------------------------------------------
checkbutton := gtk.NewCheckButtonWithLabel("CheckButton with label")
checkbutton.Connect("toggled", func() {
if checkbutton.GetActive() {
checkbutton.SetLabel("CheckButton CHECKED!")
} else {
checkbutton.SetLabel("CheckButton UNCHECKED!")
}
})
buttons.Add(checkbutton)
//--------------------------------------------------------
// GtkRadioButton
//--------------------------------------------------------
buttonbox := gtk.NewVBox(false, 1)
radiofirst := gtk.NewRadioButtonWithLabel(nil, "Radio1")
buttonbox.Add(radiofirst)
buttonbox.Add(gtk.NewRadioButtonWithLabel(radiofirst.GetGroup(), "Radio2"))
buttonbox.Add(gtk.NewRadioButtonWithLabel(radiofirst.GetGroup(), "Radio3"))
buttons.Add(buttonbox)
//radiobutton.SetMode(false);
radiofirst.SetActive(true)
framebox2.PackStart(buttons, false, false, 0)
//--------------------------------------------------------
// GtkVSeparator
//--------------------------------------------------------
vsep := gtk.NewVSeparator()
framebox2.PackStart(vsep, false, false, 0)
//--------------------------------------------------------
// GtkComboBoxEntry
//--------------------------------------------------------
combos := gtk.NewHBox(false, 1)
comboboxentry := gtk.NewComboBoxText()
comboboxentry.AppendText("Monkey")
comboboxentry.AppendText("Tiger")
comboboxentry.AppendText("Elephant")
comboboxentry.Connect("changed", func() {
fmt.Println("value:", comboboxentry.GetActiveText())
})
combos.Add(comboboxentry)
//--------------------------------------------------------
// GtkComboBox
//--------------------------------------------------------
combobox := gtk.NewComboBoxText()
combobox.AppendText("Peach")
combobox.AppendText("Banana")
combobox.AppendText("Apple")
combobox.SetActive(1)
combobox.Connect("changed", func() {
fmt.Println("value:", combobox.GetActiveText())
})
combos.Add(combobox)
framebox2.PackStart(combos, false, false, 0)
//--------------------------------------------------------
// GtkTextView
//--------------------------------------------------------
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
textview := gtk.NewTextView()
var start, end gtk.TextIter
buffer := textview.GetBuffer()
buffer.GetStartIter(&start)
buffer.Insert(&start, "Hello ")
buffer.GetEndIter(&end)
buffer.Insert(&end, "World!")
tag := buffer.CreateTag("bold", map[string]string{
"background": "#FF0000", "weight": "700"})
buffer.GetStartIter(&start)
buffer.GetEndIter(&end)
buffer.ApplyTag(tag, &start, &end)
swin.Add(textview)
framebox2.Add(swin)
buffer.Connect("changed", func() {
fmt.Println("changed")
})
//--------------------------------------------------------
// GtkMenuItem
//--------------------------------------------------------
cascademenu := gtk.NewMenuItemWithMnemonic("_File")
menubar.Append(cascademenu)
submenu := gtk.NewMenu()
cascademenu.SetSubmenu(submenu)
var menuitem *gtk.MenuItem
menuitem = gtk.NewMenuItemWithMnemonic("E_xit")
menuitem.Connect("activate", func() {
gtk.MainQuit()
})
submenu.Append(menuitem)
cascademenu = gtk.NewMenuItemWithMnemonic("_View")
menubar.Append(cascademenu)
submenu = gtk.NewMenu()
cascademenu.SetSubmenu(submenu)
checkmenuitem := gtk.NewCheckMenuItemWithMnemonic("_Disable")
checkmenuitem.Connect("activate", func() {
vpaned.SetSensitive(!checkmenuitem.GetActive())
})
submenu.Append(checkmenuitem)
menuitem = gtk.NewMenuItemWithMnemonic("_Font")
menuitem.Connect("activate", func() {
fsd := gtk.NewFontSelectionDialog("Font")
fsd.SetFontName(fontbutton.GetFontName())
fsd.Response(func() {
fmt.Println(fsd.GetFontName())
fontbutton.SetFontName(fsd.GetFontName())
fsd.Destroy()
})
fsd.SetTransientFor(window)
fsd.Run()
})
submenu.Append(menuitem)
cascademenu = gtk.NewMenuItemWithMnemonic("_Help")
menubar.Append(cascademenu)
submenu = gtk.NewMenu()
cascademenu.SetSubmenu(submenu)
menuitem = gtk.NewMenuItemWithMnemonic("_About")
menuitem.Connect("activate", func() {
dialog := gtk.NewAboutDialog()
dialog.SetName("Go-Gtk Demo!")
dialog.SetProgramName("demo")
dialog.SetAuthors(authors())
dir, _ := filepath.Split(os.Args[0])
imagefile := filepath.Join(dir, "../../data/mattn-logo.png")
pixbuf, _ := gdkpixbuf.NewPixbufFromFile(imagefile)
dialog.SetLogo(pixbuf)
dialog.SetLicense("The library is available under the same terms and conditions as the Go, the BSD style license, and the LGPL (Lesser GNU Public License). The idea is that if you can use Go (and Gtk) in a project, you should also be able to use go-gtk.")
dialog.SetWrapLicense(true)
dialog.Run()
dialog.Destroy()
})
submenu.Append(menuitem)
//--------------------------------------------------------
// GtkStatusbar
//--------------------------------------------------------
statusbar := gtk.NewStatusbar()
context_id := statusbar.GetContextId("go-gtk")
statusbar.Push(context_id, "GTK binding for Go!")
framebox2.PackStart(statusbar, false, false, 0)
//--------------------------------------------------------
// Event
//--------------------------------------------------------
window.Add(vbox)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}

64
vendor/github.com/mattn/go-gtk/example/dnd/dnd.go generated vendored Normal file
View File

@@ -0,0 +1,64 @@
package main
import (
"os"
"strings"
"unsafe"
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK DND")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
targets := []gtk.TargetEntry{
{"text/uri-list", 0, 0},
{"STRING", 0, 1},
{"text/plain", 0, 2},
}
dest := gtk.NewLabel("drop me file")
dest.DragDestSet(
gtk.DEST_DEFAULT_MOTION|
gtk.DEST_DEFAULT_HIGHLIGHT|
gtk.DEST_DEFAULT_DROP,
targets,
gdk.ACTION_COPY)
dest.DragDestAddUriTargets()
dest.Connect("drag-data-received", func(ctx *glib.CallbackContext) {
sdata := gtk.NewSelectionDataFromNative(unsafe.Pointer(ctx.Args(3)))
if sdata != nil {
a := (*[2000]uint8)(sdata.GetData())
files := strings.Split(string(a[0:sdata.GetLength()-1]), "\n")
for i := range files {
filename, _, _ := glib.FilenameFromUri(files[i])
files[i] = filename
}
dialog := gtk.NewMessageDialog(
window,
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
strings.Join(files, "\n"))
dialog.SetTitle("D&D")
dialog.Response(func() {
dialog.Destroy()
})
dialog.Run()
}
})
vbox.Add(dest)
window.Add(vbox)
window.SetSizeRequest(300, 100)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,92 @@
package main
import (
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
"unsafe"
)
type point struct {
x int
y int
}
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK DrawingArea")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
drawingarea := gtk.NewDrawingArea()
var p1, p2 point
var gdkwin *gdk.Window
var pixmap *gdk.Pixmap
var gc *gdk.GC
p1.x = -1
p1.y = -1
colors := []string{
"black",
"gray",
"blue",
"purple",
"red",
"orange",
"yellow",
"green",
"darkgreen",
}
drawingarea.Connect("configure-event", func() {
if pixmap != nil {
pixmap.Unref()
}
allocation := drawingarea.GetAllocation()
pixmap = gdk.NewPixmap(drawingarea.GetWindow().GetDrawable(), allocation.Width, allocation.Height, 24)
gc = gdk.NewGC(pixmap.GetDrawable())
gc.SetRgbFgColor(gdk.NewColor("white"))
pixmap.GetDrawable().DrawRectangle(gc, true, 0, 0, -1, -1)
gc.SetRgbFgColor(gdk.NewColor(colors[0]))
gc.SetRgbBgColor(gdk.NewColor("white"))
})
drawingarea.Connect("motion-notify-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
mev := *(**gdk.EventMotion)(unsafe.Pointer(&arg))
var mt gdk.ModifierType
if mev.IsHint != 0 {
gdkwin.GetPointer(&p2.x, &p2.y, &mt)
} else {
p2.x, p2.y = int(mev.X), int(mev.Y)
}
if p1.x != -1 && p2.x != -1 && (gdk.EventMask(mt)&gdk.BUTTON_PRESS_MASK) != 0 {
pixmap.GetDrawable().DrawLine(gc, p1.x, p1.y, p2.x, p2.y)
gdkwin.Invalidate(nil, false)
}
colors = append(colors[1:], colors[0])
gc.SetRgbFgColor(gdk.NewColor(colors[0]))
p1 = p2
})
drawingarea.Connect("expose-event", func() {
if pixmap == nil {
return
}
gdkwin.GetDrawable().DrawDrawable(gc, pixmap.GetDrawable(), 0, 0, 0, 0, -1, -1)
})
drawingarea.SetEvents(int(gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK))
vbox.Add(drawingarea)
window.Add(vbox)
window.SetSizeRequest(400, 400)
window.ShowAll()
gdkwin = drawingarea.GetWindow()
gtk.Main()
}

48
vendor/github.com/mattn/go-gtk/example/event/event.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
"unsafe"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Events")
window.Connect("destroy", gtk.MainQuit)
event := make(chan interface{})
window.Connect("key-press-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
event <- *(**gdk.EventKey)(unsafe.Pointer(&arg))
})
window.Connect("motion-notify-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
event <- *(**gdk.EventMotion)(unsafe.Pointer(&arg))
})
go func() {
for {
e := <-event
switch ev := e.(type) {
case *gdk.EventKey:
fmt.Println("key-press-event:", ev.Keyval)
break
case *gdk.EventMotion:
fmt.Println("motion-notify-event:", int(ev.X), int(ev.Y))
break
}
}
}()
window.SetEvents(int(gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK))
window.SetSizeRequest(400, 400)
window.ShowAll()
gtk.Main()
}

59
vendor/github.com/mattn/go-gtk/example/example.mk generated vendored Normal file
View File

@@ -0,0 +1,59 @@
EXAMPLES := \
example/action/action \
example/alignment/alignment \
example/builder/builder \
example/clipboard/clipboard \
example/demo/demo \
example/arrow/arrow \
example/dnd/dnd \
example/drawable/drawable \
example/event/event \
example/expander/expander \
example/iconview/iconview \
example/listview/listview \
example/locale/locale \
example/notebook/notebook \
example/number/number \
example/sourceview/sourceview \
example/spinbutton/spinbutton \
example/statusicon/statusicon \
example/table/table \
example/thread/thread \
example/toolbar/toolbar \
example/treeview/treeview \
example/twitterstream/twitterstream
.PHONY: example
example: $(EXAMPLES)
@true
.PHONY: clean-example
clean-example:
rm -f $(EXAMPLES)
%: %.go
cd $(@D) && go build -x
example/action/action: example/action/action.go
example/alignment/alignment: example/alignment/alignment.go
example/builder/builder: example/builder/builder.go
example/clipboard/clipboard: example/clipboard/clipboard.go
example/demo/demo: example/demo/demo.go
example/arrow/arrow: example/arrow/arrow.go
example/dnd/dnd: example/dnd/dnd.go
example/drawable/drawable: example/drawable/drawable.go
example/event/event: example/event/event.go
example/expander/expander: example/expander/expander.go
example/iconview/iconview: example/iconview/iconview.go
example/listview/listview: example/listview/listview.go
example/locale/locale: example/locale/locale.go
example/notebook/notebook: example/notebook/notebook.go
example/number/number: example/number/number.go
example/sourceview/sourceview: example/sourceview/sourceview.go
example/spinbutton/spinbutton: example/spinbutton/spinbutton.go
example/statusicon/statusicon: example/statusicon/statusicon.go
example/table/table: example/table/table.go
example/thread/thread: example/thread/thread.go
example/toolbar/toolbar: example/toolbar/toolbar.go
example/treeview/treeview: example/treeview/treeview.go
example/twitterstream/twitterstream: example/twitterstream/twitterstream.go

View File

@@ -0,0 +1,24 @@
package main
import (
"github.com/mattn/go-gtk/gtk"
"os"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("We love Expander")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
expander := gtk.NewExpander("dan the ...")
expander.Add(gtk.NewLabel("404 contents not found"))
vbox.PackStart(expander, false, false, 0)
window.Add(vbox)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,40 @@
package main
import (
"os"
"unsafe"
"github.com/mattn/go-gtk/gdkpixbuf"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Icon View")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING)
iconview := gtk.NewIconViewWithModel(store)
iconview.SetPixbufColumn(0)
iconview.SetTextColumn(1)
swin.Add(iconview)
gtk.StockListIDs().ForEach(func(d unsafe.Pointer, v interface{}) {
id := glib.GPtrToString(d)
var iter gtk.TreeIter
store.Append(&iter)
store.Set(&iter,
0, gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf,
1, id)
})
window.Add(swin)
window.SetSizeRequest(500, 200)
window.ShowAll()
gtk.Main()
}

21
vendor/github.com/mattn/go-gtk/example/idle/idle.go generated vendored Normal file
View File

@@ -0,0 +1,21 @@
package main
import (
"fmt"
"time"
"github.com/mattn/go-gtk/glib"
)
func main() {
glib.IdleAdd(func() bool {
fmt.Println("start")
return false
})
glib.TimeoutAdd(1000, func() bool {
fmt.Println(fmt.Sprintf("%v", time.Now()))
return true
})
glib.NewMainLoop(nil, false).Run()
}

View File

@@ -0,0 +1,46 @@
package main
import (
"os"
"unsafe"
"github.com/mattn/go-gtk/gdkpixbuf"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Stock Icons")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetType())
treeview := gtk.NewTreeView()
swin.Add(treeview)
treeview.SetModel(store)
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("check", gtk.NewCellRendererToggle(), "active", 1))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 2))
n := 0
gtk.StockListIDs().ForEach(func(d unsafe.Pointer, v interface{}) {
id := glib.GPtrToString(d)
var iter gtk.TreeIter
store.Append(&iter)
store.Set(&iter,
0, id,
1, (n == 1),
2, gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf,
)
n = 1 - n
})
window.Add(swin)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,17 @@
package main
import "github.com/mattn/go-gtk/gtk"
import "github.com/mattn/go-gtk/glib"
import "fmt"
import "syscall"
func main() {
gtk.SetLocale()
bs, _, _, err := glib.LocaleFromUtf8("こんにちわ世界\n")
if err == nil {
syscall.Write(syscall.Stdout, bs)
} else {
fmt.Println(err.Message())
}
}

View File

@@ -0,0 +1,42 @@
package main
import (
"github.com/mattn/go-gtk/gtk"
"os"
"strconv"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Notebook")
window.Connect("destroy", gtk.MainQuit)
notebook := gtk.NewNotebook()
for n := 1; n <= 10; n++ {
page := gtk.NewFrame("demo" + strconv.Itoa(n))
notebook.AppendPage(page, gtk.NewLabel("demo"+strconv.Itoa(n)))
vbox := gtk.NewHBox(false, 1)
prev := gtk.NewButtonWithLabel("go prev")
prev.Clicked(func() {
notebook.PrevPage()
})
vbox.Add(prev)
next := gtk.NewButtonWithLabel("go next")
next.Clicked(func() {
notebook.NextPage()
})
vbox.Add(next)
page.Add(vbox)
}
window.Add(notebook)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,56 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
"strconv"
"unsafe"
)
func main() {
gtk.Init(&os.Args)
dialog := gtk.NewDialog()
dialog.SetTitle("number input")
vbox := dialog.GetVBox()
label := gtk.NewLabel("Numnber:")
vbox.Add(label)
input := gtk.NewEntry()
input.SetEditable(true)
vbox.Add(input)
input.Connect("insert-text", func(ctx *glib.CallbackContext) {
a := (*[2000]uint8)(unsafe.Pointer(ctx.Args(0)))
p := (*int)(unsafe.Pointer(ctx.Args(2)))
i := 0
for a[i] != 0 {
i++
}
s := string(a[0:i])
if s == "." {
if *p == 0 {
input.StopEmission("insert-text")
}
} else {
_, err := strconv.ParseFloat(s, 64)
if err != nil {
input.StopEmission("insert-text")
}
}
})
button := gtk.NewButtonWithLabel("OK")
button.Connect("clicked", func() {
fmt.Println(input.GetText())
gtk.MainQuit()
})
vbox.Add(button)
dialog.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,61 @@
package main
import (
"github.com/mattn/go-gtk/gtk"
gsv "github.com/mattn/go-gtk/gtksourceview"
"os"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("SourceView")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
sourcebuffer := gsv.NewSourceBufferWithLanguage(gsv.SourceLanguageManagerGetDefault().GetLanguage("cpp"))
sourceview := gsv.NewSourceViewWithBuffer(sourcebuffer)
var start gtk.TextIter
sourcebuffer.GetStartIter(&start)
sourcebuffer.BeginNotUndoableAction()
sourcebuffer.Insert(&start, `#include <iostream>
template<class T>
struct foo_base {
T operator+(T const &rhs) const {
T tmp(static_cast<T const &>(*this));
tmp += rhs;
return tmp;
}
};
class foo : public foo_base<foo> {
private:
int v;
public:
foo(int v) : v(v) {}
foo &operator+=(foo const &rhs){
this->v += rhs.v;
return *this;
}
operator int() { return v; }
};
int main(void) {
foo a(1), b(2);
a += b;
std::cout << (int)a << std::endl;
}
`)
sourcebuffer.EndNotUndoableAction()
swin.Add(sourceview)
window.Add(swin)
window.SetSizeRequest(400, 300)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,56 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"strconv"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
//--------------------------------------------------------
// GtkHBox
//--------------------------------------------------------
fixed := gtk.NewFixed()
//--------------------------------------------------------
// GtkSpinButton
//--------------------------------------------------------
spinbutton1 := gtk.NewSpinButtonWithRange(1.0, 10.0, 1.0)
spinbutton1.SetDigits(3)
spinbutton1.Spin(gtk.SPIN_STEP_FORWARD, 7.0)
fixed.Put(spinbutton1, 40, 50)
spinbutton1.OnValueChanged(func() {
val := spinbutton1.GetValueAsInt()
fval := spinbutton1.GetValue()
fmt.Println("SpinButton changed, new value: " + strconv.Itoa(val) + " | " + strconv.FormatFloat(fval, 'f', 2, 64))
min, max := spinbutton1.GetRange()
fmt.Println("Range: " + strconv.FormatFloat(min, 'f', 2, 64) + " " + strconv.FormatFloat(max, 'f', 2, 64))
fmt.Println("Digits: " + strconv.Itoa(int(spinbutton1.GetDigits())))
})
adjustment := gtk.NewAdjustment(2.0, 1.0, 8.0, 2.0, 0.0, 0.0)
spinbutton2 := gtk.NewSpinButton(adjustment, 1.0, 1)
spinbutton2.SetRange(0.0, 20.0)
spinbutton2.SetValue(18.0)
spinbutton2.SetIncrements(2.0, 4.0)
fixed.Put(spinbutton2, 150, 50)
//--------------------------------------------------------
// Event
//--------------------------------------------------------
window.Add(fixed)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,40 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
)
func main() {
gtk.Init(&os.Args)
glib.SetApplicationName("go-gtk-statusicon-example")
mi := gtk.NewMenuItemWithLabel("Popup!")
mi.Connect("activate", func() {
gtk.MainQuit()
})
nm := gtk.NewMenu()
nm.Append(mi)
nm.ShowAll()
si := gtk.NewStatusIconFromStock(gtk.STOCK_FILE)
si.SetTitle("StatusIcon Example")
si.SetTooltipMarkup("StatusIcon Example")
si.Connect("popup-menu", func(cbx *glib.CallbackContext) {
nm.Popup(nil, nil, gtk.StatusIconPositionMenu, si, uint(cbx.Args(0)), uint32(cbx.Args(1)))
})
fmt.Println(`
Can you see statusicon in systray?
If you don't see it and if you use 'unity', try following.
# gsettings set com.canonical.Unity.Panel systray-whitelist \
"$(gsettings get com.canonical.Unity.Panel systray-whitelist \|
sed -e "s/]$/, 'go-gtk-statusicon-example']/")"
`)
gtk.Main()
}

31
vendor/github.com/mattn/go-gtk/example/table/table.go generated vendored Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/gtk"
"os"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Table")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
table := gtk.NewTable(5, 5, false)
for y := uint(0); y < 5; y++ {
for x := uint(0); x < 5; x++ {
table.Attach(gtk.NewButtonWithLabel(fmt.Sprintf("%02d:%02d", x, y)), x, x+1, y, y+1, gtk.FILL, gtk.FILL, 5, 5)
}
}
swin.AddWithViewPort(table)
window.Add(swin)
window.SetDefaultSize(200, 200)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,55 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"unsafe"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.SetIconName("textview")
window.Connect("destroy", gtk.MainQuit)
textview := gtk.NewTextView()
textview.SetEditable(true)
textview.SetCursorVisible(true)
var iter gtk.TextIter
buffer := textview.GetBuffer()
buffer.GetStartIter(&iter)
buffer.Insert(&iter, "Hello ")
tag := buffer.CreateTag("bold", map[string]string{"background": "#FF0000", "weight": "700"})
buffer.InsertWithTag(&iter, "Google!", tag)
u := "http://www.google.com"
tag.SetData("tag-name", unsafe.Pointer(&u))
textview.Connect("event-after", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
if ev := *(**gdk.EventAny)(unsafe.Pointer(&arg)); ev.Type != gdk.BUTTON_RELEASE {
return
}
ev := *(**gdk.EventButton)(unsafe.Pointer(&arg))
var iter gtk.TextIter
textview.GetIterAtLocation(&iter, int(ev.X), int(ev.Y))
tags := iter.GetTags()
for n := uint(0); n < tags.Length(); n++ {
vv := tags.NthData(n)
tag := gtk.NewTextTagFromPointer(vv)
u := *(*string)(tag.GetData("tag-name"))
fmt.Println(u)
}
})
window.Add(textview)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,51 @@
package main
import (
"runtime"
"strconv"
"time"
"github.com/mattn/go-gtk/gdk"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
runtime.GOMAXPROCS(10)
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
label1 := gtk.NewLabel("")
vbox.Add(label1)
label2 := gtk.NewLabel("")
vbox.Add(label2)
window.Add(vbox)
window.SetSizeRequest(100, 100)
window.ShowAll()
time.Sleep(1000 * 1000 * 100)
go (func() {
for i := 0; i < 300000; i++ {
gdk.ThreadsEnter()
label1.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
go (func() {
for i := 300000; i >= 0; i-- {
gdk.ThreadsEnter()
label2.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
gtk.Main()
}

View File

@@ -0,0 +1,108 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, "")
vbox := gtk.NewVBox(false, 0)
toolbar := gtk.NewToolbar()
toolbar.SetStyle(gtk.TOOLBAR_ICONS)
vbox.PackStart(toolbar, false, false, 5)
btnnew := gtk.NewToolButtonFromStock(gtk.STOCK_NEW)
btnclose := gtk.NewToolButtonFromStock(gtk.STOCK_CLOSE)
separator := gtk.NewSeparatorToolItem()
btncustom := gtk.NewToolButton(nil, "Custom")
btnmenu := gtk.NewMenuToolButtonFromStock("gtk.STOCK_CLOSE")
btnmenu.SetArrowTooltipText("This is a tool tip")
btnnew.OnClicked(onToolButtonClicked)
btnclose.OnClicked(onToolButtonClicked)
btncustom.OnClicked(onToolButtonClicked)
toolmenu := gtk.NewMenu()
menuitem := gtk.NewMenuItemWithMnemonic("8")
menuitem.Show()
toolmenu.Append(menuitem)
menuitem = gtk.NewMenuItemWithMnemonic("16")
menuitem.Show()
toolmenu.Append(menuitem)
menuitem = gtk.NewMenuItemWithMnemonic("32")
menuitem.Show()
toolmenu.Append(menuitem)
btnmenu.SetMenu(toolmenu)
toolbar.Insert(btnnew, -1)
toolbar.Insert(btnclose, -1)
toolbar.Insert(separator, -1)
toolbar.Insert(btncustom, -1)
toolbar.Insert(btnmenu, -1)
hbox := gtk.NewHBox(false, 0)
vbox.PackStart(hbox, true, true, 0)
toolbar2 := gtk.NewToolbar()
toolbar2.SetOrientation(gtk.ORIENTATION_VERTICAL)
hbox.PackStart(toolbar2, false, false, 5)
btnhelp := gtk.NewToolButtonFromStock(gtk.STOCK_HELP)
btnhelp.OnClicked(onToolButtonClicked)
toolbar2.Insert(btnhelp, -1)
btntoggle := gtk.NewToggleToolButton()
btntoggle2 := gtk.NewToggleToolButtonFromStock(gtk.STOCK_ITALIC)
toolbar2.Insert(btntoggle, -1)
toolbar2.Insert(btntoggle2, -1)
for i := 0; i < toolbar.GetNItems(); i++ {
gti := toolbar.GetNthItem(i)
switch gti.(type) {
case *gtk.ToolButton:
fmt.Printf("toolbar[%d] is a *gtk.ToolButton\n", i)
w := gti.(*gtk.ToolButton).GetIconWidget()
gti.(*gtk.ToolButton).SetIconWidget(w)
case *gtk.ToggleToolButton:
fmt.Printf("toolbar[%d] is a *gtk.ToggleToolButton\n", i)
gti.(*gtk.ToggleToolButton).SetActive(true)
case *gtk.SeparatorToolItem:
fmt.Printf("toolbar[%d] is a *gtk.SeparatorToolItem\n", i)
default:
fmt.Printf("toolbar: Item is of unknown type\n")
}
}
for i := 0; i < toolbar2.GetNItems(); i++ {
gti := toolbar2.GetNthItem(i)
switch gti.(type) {
case *gtk.ToolButton:
fmt.Printf("toolbar2[%d] is a *gtk.ToolButton\n", i)
case *gtk.ToggleToolButton:
fmt.Printf("toolbar2[%d] is a *gtk.ToggleToolButton\n", i)
gti.(*gtk.ToggleToolButton).SetActive(true)
case *gtk.SeparatorToolItem:
fmt.Printf("toolbar2[%d] is a *gtk.SeparatorToolItem\n", i)
default:
fmt.Printf("toolbar2: Item is of unknown type\n")
}
}
window.Add(vbox)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}
func onToolButtonClicked() {
fmt.Println("ToolButton clicked")
}

View File

@@ -0,0 +1,78 @@
package main
import (
"fmt"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, "")
box := gtk.NewHPaned()
palette := gtk.NewToolPalette()
group := gtk.NewToolItemGroup("Tools")
b := gtk.NewToolButtonFromStock(gtk.STOCK_NEW)
b.OnClicked(func() { fmt.Println("You clicked new!") })
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_CLOSE)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_REDO)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_REFRESH)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_QUIT)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_YES)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_NO)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_PRINT)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_NETWORK)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_INFO)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_HOME)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_INDEX)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_FIND)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_FILE)
group.Insert(b, -1)
b = gtk.NewToolButtonFromStock(gtk.STOCK_EXECUTE)
group.Insert(b, -1)
palette.Add(group)
bcopy := gtk.NewToolButtonFromStock(gtk.STOCK_COPY)
bcut := gtk.NewToolButtonFromStock(gtk.STOCK_CUT)
bdelete := gtk.NewToolButtonFromStock(gtk.STOCK_DELETE)
group = gtk.NewToolItemGroup("Stuff")
group.Insert(bcopy, -1)
group.Insert(bcut, -1)
group.Insert(bdelete, -1)
palette.Add(group)
frame := gtk.NewVBox(false, 1)
align := gtk.NewAlignment(0, 0, 0, 0)
image := gtk.NewImageFromFile("./turkey.jpg")
align.Add(image)
frame.Add(align)
box.Pack1(palette, true, false)
box.Pack2(frame, false, false)
window.Add(box)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,60 @@
package main
import (
"github.com/mattn/go-gtk/gdkpixbuf"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
"os"
"strconv"
)
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Folder View")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewTreeStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
swin.Add(treeview)
treeview.SetModel(store.ToTreeModel())
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("pixbuf", gtk.NewCellRendererPixbuf(), "pixbuf", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("text", gtk.NewCellRendererText(), "text", 1))
for n := 1; n <= 10; n++ {
var iter1, iter2, iter3 gtk.TreeIter
store.Append(&iter1, nil)
store.Set(&iter1, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf, "Folder"+strconv.Itoa(n))
store.Append(&iter2, &iter1)
store.Set(&iter2, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf, "SubFolder"+strconv.Itoa(n))
store.Append(&iter3, &iter2)
store.Set(&iter3, gtk.NewImage().RenderIcon(gtk.STOCK_FILE, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf, "File"+strconv.Itoa(n))
}
treeview.Connect("row_activated", func() {
var path *gtk.TreePath
var column *gtk.TreeViewColumn
treeview.GetCursor(&path, &column)
mes := "TreePath is: " + path.String()
dialog := gtk.NewMessageDialog(
treeview.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
mes)
dialog.SetTitle("TreePath")
dialog.Response(func() {
dialog.Destroy()
})
dialog.Run()
})
window.Add(swin)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}

View File

@@ -0,0 +1,6 @@
{
"AccessSecret": "ACCCESS_TOKEN_SECRET",
"AccessToken": "ACCESS_TOKEN",
"ClientSecret": "CLIENT_SECRET",
"ClientToken": "CLIENT_TOKEN"
}

View File

@@ -0,0 +1,249 @@
package main
import (
"bufio"
"compress/gzip"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"runtime"
"strings"
"sync"
"github.com/garyburd/go-oauth/oauth"
"github.com/mattn/go-gtk/gdkpixbuf"
"github.com/mattn/go-gtk/gtk"
)
var (
alive = true
)
func readURL(url string) ([]byte, *http.Response) {
r, err := http.Get(url)
if err != nil {
return nil, nil
}
var b []byte
if b, err = ioutil.ReadAll(r.Body); err != nil {
return nil, nil
}
return b, r
}
func bytes2pixbuf(data []byte, typ string) *gdkpixbuf.Pixbuf {
var loader *gdkpixbuf.Loader
if strings.Index(typ, "jpeg") >= 0 {
loader, _ = gdkpixbuf.NewLoaderWithMimeType("image/jpeg")
} else {
loader, _ = gdkpixbuf.NewLoaderWithMimeType("image/png")
}
loader.SetSize(24, 24)
loader.Write(data)
loader.Close()
return loader.GetPixbuf()
}
type tweet struct {
Text string
Identifier string `json:"id_str"`
Source string
User struct {
Name string
ScreenName string `json:"screen_name"`
FollowersCount int `json:"followers_count"`
ProfileImageUrl string `json:"profile_image_url"`
}
Place *struct {
Id string
FullName string `json:"full_name"`
}
Entities struct {
HashTags []struct {
Indices [2]int
Text string
}
UserMentions []struct {
Indices [2]int
ScreenName string `json:"screen_name"`
} `json:"user_mentions"`
Urls []struct {
Indices [2]int
Url string
DisplayUrl string `json:"display_url"`
ExpandedUrl *string `json:"expanded_url"`
}
}
}
func stream(client *oauth.Client, cred *oauth.Credentials, f func(*tweet)) {
param := make(url.Values)
uri := "https://userstream.twitter.com/1.1/user.json"
client.SignParam(cred, "GET", uri, param)
uri = uri + "?" + param.Encode()
res, err := http.Get(uri)
if err != nil {
log.Fatal("failed to get tweets:", err)
}
defer res.Body.Close()
if res.StatusCode != 200 {
log.Fatal("failed to get tweets:", err)
}
var buf *bufio.Reader
if res.Header.Get("Content-Encoding") == "gzip" {
gr, err := gzip.NewReader(res.Body)
if err != nil {
log.Fatal("failed to make gzip decoder:", err)
}
buf = bufio.NewReader(gr)
} else {
buf = bufio.NewReader(res.Body)
}
var last []byte
for alive {
b, _, err := buf.ReadLine()
last = append(last, b...)
var t tweet
err = json.Unmarshal(last, &t)
if err != nil {
continue
}
last = []byte{}
if t.Text == "" {
continue
}
f(&t)
}
}
func post(client *oauth.Client, cred *oauth.Credentials, s string) {
param := make(url.Values)
param.Set("status", s)
uri := "https://api.twitter.com/1.1/statuses/update.json"
client.SignParam(cred, "POST", uri, param)
res, err := http.PostForm(uri, url.Values(param))
if err != nil {
log.Println("failed to post tweet:", err)
return
}
defer res.Body.Close()
if res.StatusCode != 200 {
log.Println("failed to get timeline:", err)
return
}
}
func display(t *tweet, buffer *gtk.TextBuffer, tag *gtk.TextTag) {
var iter gtk.TextIter
pixbufbytes, resp := readURL(t.User.ProfileImageUrl)
buffer.GetStartIter(&iter)
if resp != nil {
buffer.InsertPixbuf(&iter, bytes2pixbuf(pixbufbytes, resp.Header.Get("Content-Type")))
}
buffer.Insert(&iter, " ")
buffer.InsertWithTag(&iter, t.User.ScreenName, tag)
buffer.Insert(&iter, ":"+t.Text+"\n")
gtk.MainIterationDo(false)
}
func show(client *oauth.Client, cred *oauth.Credentials, f func(t *tweet)) {
param := make(url.Values)
uri := "https://api.twitter.com/1.1/statuses/home_timeline.json"
client.SignParam(cred, "GET", uri, param)
uri = uri + "?" + param.Encode()
res, err := http.Get(uri)
if err != nil {
return
}
defer res.Body.Close()
if res.StatusCode != 200 {
return
}
var tweets []tweet
json.NewDecoder(res.Body).Decode(&tweets)
for _, t := range tweets {
f(&t)
}
}
func main() {
b, err := ioutil.ReadFile("settings.json")
if err != nil {
fmt.Println(`"settings.json" not found: `, err)
return
}
var config map[string]string
err = json.Unmarshal(b, &config)
if err != nil {
fmt.Println(`can't read "settings.json": `, err)
return
}
client := &oauth.Client{Credentials: oauth.Credentials{config["ClientToken"], config["ClientSecret"]}}
cred := &oauth.Credentials{config["AccessToken"], config["AccessSecret"]}
runtime.LockOSThread()
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Twitter!")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
scrolledwin := gtk.NewScrolledWindow(nil, nil)
textview := gtk.NewTextView()
textview.SetEditable(false)
textview.SetCursorVisible(false)
scrolledwin.Add(textview)
vbox.Add(scrolledwin)
buffer := textview.GetBuffer()
tag := buffer.CreateTag("blue", map[string]string{"foreground": "#0000FF", "weight": "700"})
hbox := gtk.NewHBox(false, 1)
vbox.PackEnd(hbox, false, true, 5)
label := gtk.NewLabel("Tweet")
hbox.PackStart(label, false, false, 5)
text := gtk.NewEntry()
hbox.PackEnd(text, true, true, 5)
text.Connect("activate", func() {
t := text.GetText()
text.SetText("")
post(client, cred, t)
})
window.Add(vbox)
window.SetSizeRequest(800, 500)
window.ShowAll()
var mutex sync.Mutex
go func() {
show(client, cred, func(t *tweet) {
mutex.Lock()
display(t, buffer, tag)
mutex.Unlock()
})
stream(client, cred, func(t *tweet) {
mutex.Lock()
display(t, buffer, tag)
var start, end gtk.TextIter
buffer.GetIterAtLine(&start, buffer.GetLineCount()-2)
buffer.GetEndIter(&end)
buffer.Delete(&start, &end)
mutex.Unlock()
})
}()
for alive {
mutex.Lock()
alive = gtk.MainIterationDo(false)
mutex.Unlock()
}
}

3008
vendor/github.com/mattn/go-gtk/gdk/gdk.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

23
vendor/github.com/mattn/go-gtk/gdk/gdk.go.h generated vendored Normal file
View File

@@ -0,0 +1,23 @@
#ifndef GO_GDK_H
#define GO_GDK_H
#include <gdk/gdk.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
static gchar* toGstr(char* s) { return (gchar*)s; }
static void freeCstr(char* s) { free(s); }
static GdkWindow* toGdkWindow(void* w) { return GDK_WINDOW(w); }
static GdkDragContext* toGdkDragContext(void* l) { return (GdkDragContext*)l; }
static GdkFont* toGdkFont(void* l) { return (GdkFont*)l; }
static void* _gdk_display_get_default() {
return (void*) gdk_display_get_default();
}
#endif

1
vendor/github.com/mattn/go-gtk/gdk/gdk_freebsd.go generated vendored Symbolic link
View File

@@ -0,0 +1 @@
gdk_linux.go

15
vendor/github.com/mattn/go-gtk/gdk/gdk_linux.go generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// +build !cgocheck
package gdk
/*
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
// #cgo pkg-config: gdk-2.0 gthread-2.0
*/
import "C"
import "unsafe"
func (v *Window) GetNativeWindowID() int32 {
return int32(C.gdk_x11_drawable_get_xid((*C.GdkDrawable)(unsafe.Pointer(v.GWindow))))
}

View File

@@ -0,0 +1,33 @@
// +build !with-x11
package gdk
/*
#cgo pkg-config: gdk-2.0 gthread-2.0
#cgo CFLAGS: -x objective-c
#include <gdk/gdk.h>
#include <gdk/gdkquartz.h>
// Must return void* to avoid "struct size calculation error off=8 bytesize=0"
// See:
// - https://github.com/golang/go/issues/12065
// - http://thread0.me/2015/07/gogoa-cocoa-bindings-for-go/
void* getNsWindow(GdkWindow *w) {
return (void*) gdk_quartz_window_get_nswindow(w);
}
*/
import "C"
import "unsafe"
type NSWindow struct {
ID unsafe.Pointer
}
func (v *Window) GetNativeWindow() *NSWindow {
return &NSWindow{
unsafe.Pointer(C.getNsWindow(v.GWindow)),
}
}

15
vendor/github.com/mattn/go-gtk/gdk/gdk_windows.go generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// +build !cgocheck
package gdk
/*
#include <gdk/gdk.h>
#include <gdk/gdkwin32.h>
// #cgo pkg-config: gdk-2.0 gthread-2.0
*/
import "C"
import "unsafe"
func (v *Window) GetNativeWindowID() int32 {
return int32(uintptr(unsafe.Pointer(C.gdk_win32_drawable_get_handle((*C.GdkDrawable)(unsafe.Pointer(v.GWindow))))))
}

16
vendor/github.com/mattn/go-gtk/gdk/gdk_x11_darwin.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
// +build with-x11
package gdk
/*
#cgo pkg-config: gdk-2.0 gthread-2.0
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
*/
import "C"
import "unsafe"
func (v *Window) GetNativeWindowID() int32 {
return int32(C.gdk_x11_drawable_get_xid((*C.GdkDrawable)(unsafe.Pointer(v.GWindow))))
}

520
vendor/github.com/mattn/go-gtk/gdkpixbuf/gdkpixbuf.go generated vendored Normal file
View File

@@ -0,0 +1,520 @@
// +build !cgocheck
package gdkpixbuf
// #include "gdkpixbuf.go.h"
// #cgo pkg-config: gdk-pixbuf-2.0
import "C"
import "github.com/mattn/go-gtk/glib"
import (
"log"
"runtime"
"unsafe"
)
func gstring(s *C.char) *C.gchar { return C.toGstr(s) }
func cstring(s *C.gchar) *C.char { return C.toCstr(s) }
func gostring(s *C.gchar) string { return C.GoString(cstring(s)) }
func gbool(b bool) C.gboolean {
if b {
return C.gboolean(1)
}
return C.gboolean(0)
}
func gobool(b C.gboolean) bool {
if b != 0 {
return true
}
return false
}
func cfree(s *C.char) { C.freeCstr(s) }
func panic_if_version_older(major int, minor int, micro int, function string) {
if C._check_version(C.int(major), C.int(minor), C.int(micro)) == 0 {
log.Panicf("%s is not provided on your Glib, version %d.%d is required\n", function, major, minor)
}
}
func panic_if_version_older_auto(major, minor, micro int) {
if C._check_version(C.int(major), C.int(minor), C.int(micro)) != 0 {
return
}
formatStr := "%s is not provided on your Glib, version %d.%d is required\n"
if pc, _, _, ok := runtime.Caller(1); ok {
log.Panicf(formatStr, runtime.FuncForPC(pc).Name(), major, minor)
} else {
log.Panicf("Glib version %d.%d is required (unknown caller, see stack)\n",
major, minor)
}
}
func deprecated_since(major int, minor int, micro int, function string) {
if C._check_version(C.int(major), C.int(minor), C.int(micro)) != 0 {
log.Printf("\nWarning: %s is deprecated since glib %d.%d\n", function, major, minor)
}
}
func argumentPanic(message string) {
if pc, _, _, ok := runtime.Caller(2); ok {
log.Panicf("Arguments error: %s : %s\n",
runtime.FuncForPC(pc).Name(), message)
} else {
log.Panicln("Arguments error: (unknown caller, see stack):", message)
}
}
//-----------------------------------------------------------------------
// Pixbuf
//-----------------------------------------------------------------------
type Pixbuf struct {
*GdkPixbuf
*glib.GObject
}
type GdkPixbuf struct {
GPixbuf *C.GdkPixbuf
}
func NewGdkPixbuf(p unsafe.Pointer) *GdkPixbuf {
return &GdkPixbuf{(*C.GdkPixbuf)(p)}
}
// File Loading
// GdkPixbuf * gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height);
func NewPixbuf(colorspace Colorspace, hasAlpha bool, bitsPerSample, width, height int) *Pixbuf {
gpixbuf := C.gdk_pixbuf_new(
C.GdkColorspace(colorspace),
gbool(hasAlpha),
C.int(bitsPerSample),
C.int(width),
C.int(height),
)
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
func NewPixbufFromFile(filename string) (*Pixbuf, *glib.Error) {
var err *C.GError
ptr := C.CString(filename)
defer cfree(ptr)
gpixbuf := C.gdk_pixbuf_new_from_file(ptr, &err)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
func NewPixbufFromFileAtSize(filename string, width, heigth int) (*Pixbuf, *glib.Error) {
var err *C.GError
ptr := C.CString(filename)
defer cfree(ptr)
gpixbuf := C.gdk_pixbuf_new_from_file_at_size(ptr, C.int(width), C.int(heigth), &err)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
func NewPixbufFromFileAtScale(filename string, width, height int, preserve_aspect_ratio bool) (*Pixbuf, *glib.Error) {
var err *C.GError
ptr := C.CString(filename)
defer cfree(ptr)
gpixbuf := C.gdk_pixbuf_new_from_file_at_scale(ptr, C.int(width), C.int(height), gbool(preserve_aspect_ratio), &err)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
// NewPixbufFromData creates a Pixbuf from image data in a byte array
//
// Can be used for reading Base64 encoded images easily with the output from base64.StdEncoding.DecodeString("...")
func NewPixbufFromData(buffer []byte) (*Pixbuf, *glib.Error) {
var err *C.GError
loader := C.gdk_pixbuf_loader_new()
C.gdk_pixbuf_loader_write(loader, C.to_gucharptr(unsafe.Pointer(&buffer[0])), C.gsize(len(buffer)), &err)
gpixbuf := C.gdk_pixbuf_loader_get_pixbuf(loader)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
// NewPixbufFromBytes creates a Pixbuf from image data in a byte array
//
// Can be used for reading Base64 encoded images easily with the output from base64.StdEncoding.DecodeString("...")
func NewPixbufFromBytes(buffer []byte) (*Pixbuf, *glib.Error) {
var err *C.GError
loader := C.gdk_pixbuf_loader_new()
C.gdk_pixbuf_loader_write(loader, C.to_gucharptr(unsafe.Pointer(&buffer[0])), C.gsize(len(buffer)), &err)
gpixbuf := C.gdk_pixbuf_loader_get_pixbuf(loader)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
func NewPixbufFromXpmData(data **byte) (*Pixbuf, *glib.Error) {
var err *C.GError
gpixbuf := C.gdk_pixbuf_new_from_xpm_data(
(**C.char)(unsafe.Pointer(data)),
)
if err != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(err))
}
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}, nil
}
func GetType() int {
return int(C.gdk_pixbuf_get_type())
}
func GetFileInfo(filename string, width, height *int) *Format {
ptr := C.CString(filename)
defer cfree(ptr)
var w, h C.gint
format := &Format{C.gdk_pixbuf_get_file_info(gstring(ptr), &w, &h)}
*width = int(w)
*height = int(h)
return format
}
// Scaling
type InterpType int
const (
INTERP_NEAREST InterpType = iota
INTERP_TILES
INTERP_BILINEAR
INTERP_HYPER
)
func (p *Pixbuf) ScaleSimple(width, height int, interp InterpType) *Pixbuf {
gpixbuf := C.gdk_pixbuf_scale_simple(p.GPixbuf, C.int(width), C.int(height), C.GdkInterpType(interp))
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
func (p *Pixbuf) Scale(x, y, width, height int, offsetX, offsetY, scaleX, scaleY float64, interp InterpType) *Pixbuf {
var gpixbuf *C.GdkPixbuf
C.gdk_pixbuf_scale(
p.GPixbuf,
gpixbuf,
C.int(x), C.int(y),
C.int(width), C.int(height),
C.double(offsetX), C.double(offsetY),
C.double(scaleX), C.double(scaleY),
C.GdkInterpType(interp))
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
// gdk_pixbuf_composite_color_simple
// gdk_pixbuf_composite
// gdk_pixbuf_composite_color
type PixbufRotation int
const (
PIXBUF_ROTATE_NONE PixbufRotation = 0
PIXBUF_ROTATE_COUNTERCLOCKWISE PixbufRotation = 90
PIXBUF_ROTATE_UPSIDEDOWN PixbufRotation = 180
PIXBUF_ROTATE_CLOCKWISE PixbufRotation = 270
)
func (p *Pixbuf) RotateSimple(angle PixbufRotation) *Pixbuf {
gpixbuf := C.gdk_pixbuf_rotate_simple(p.GPixbuf, C.GdkPixbufRotation(angle))
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
func (p *Pixbuf) Flip(horizontal bool) *Pixbuf {
gpixbuf := C.gdk_pixbuf_flip(p.GPixbuf, gbool(horizontal))
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
func (p *Pixbuf) Fill(pixel uint32) {
C.gdk_pixbuf_fill(p.GPixbuf, C.guint32(pixel))
}
// The GdkPixbuf Structure
type Colorspace int
const (
GDK_COLORSPACE_RGB Colorspace = iota
)
type PixbufAlphaMode int
const (
GDK_PIXBUF_ALPHA_BILEVEL PixbufAlphaMode = iota
GDK_PIXBUF_ALPHA_FULL
)
func (p *Pixbuf) GetColorspace() Colorspace {
return Colorspace(C.gdk_pixbuf_get_colorspace(p.GPixbuf))
}
func (p *Pixbuf) GetNChannels() int {
return int(C.gdk_pixbuf_get_n_channels(p.GPixbuf))
}
func (p *Pixbuf) GetHasAlpha() bool {
return gobool(C.gdk_pixbuf_get_has_alpha(p.GPixbuf))
}
func (p *Pixbuf) GetBitsPerSample() int {
return int(C.gdk_pixbuf_get_bits_per_sample(p.GPixbuf))
}
func (p *Pixbuf) GetPixels() []byte {
ptr := C.gdk_pixbuf_get_pixels(
p.GPixbuf,
)
return (*[1 << 30]byte)(unsafe.Pointer(ptr))[:]
}
// guchar * gdk_pixbuf_get_pixels_with_length (const GdkPixbuf *pixbuf, guint *length);
//
// Retuns a slice of byte backed by a C array of pixbuf data.
func (p *Pixbuf) GetPixelsWithLength() []byte {
panic_if_version_older(2, 26, 0, "gdk_pixbuf_get_pixels_with_length()")
length := C.guint(0)
ptr := C._gdk_pixbuf_get_pixels_with_length(
p.GPixbuf,
&length,
)
return (*[1 << 30]byte)(unsafe.Pointer(ptr))[:length]
}
func (p *Pixbuf) GetWidth() int {
return int(C.gdk_pixbuf_get_width(p.GPixbuf))
}
func (p *Pixbuf) GetHeight() int {
return int(C.gdk_pixbuf_get_height(p.GPixbuf))
}
func (p *Pixbuf) GetRowstride() int {
return int(C.gdk_pixbuf_get_rowstride(p.GPixbuf))
}
// gdk_pixbuf_get_byte_length
// gdk_pixbuf_get_option
// File saving
func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
if len(options)%2 != 0 {
argumentPanic("Save options must be even (key and value)")
}
pfilename := C.CString(filename)
defer cfree(pfilename)
psavetype := C.CString(savetype)
defer cfree(psavetype)
klen := len(options) / 2
keys := C.makeCstrv(C.int(klen + 1))
vals := C.makeCstrv(C.int(klen + 1))
for i := 0; i < klen; i++ {
C.setCstr(keys, C.int(i), C.CString(options[2*i]))
C.setCstr(vals, C.int(i), C.CString(options[2*i+1]))
}
C.setCstr(keys, C.int(klen), nil)
C.setCstr(vals, C.int(klen), nil)
defer func() {
for i := 0; i < klen; i++ {
cfree(C.getCstr(keys, C.int(i)))
cfree(C.getCstr(vals, C.int(i)))
}
C.freeCstrv(keys)
C.freeCstrv(vals)
}()
var err *C.GError
C.gdk_pixbuf_savev(p.GPixbuf, pfilename, psavetype, keys, vals, &err)
if err != nil {
return glib.ErrorFromNative(unsafe.Pointer(err))
}
return nil
}
//-----------------------------------------------------------------------
// Animation
//-----------------------------------------------------------------------
type Animation struct {
GPixbufAnimation *C.GdkPixbufAnimation
}
//-----------------------------------------------------------------------
// Format
//-----------------------------------------------------------------------
type Format struct {
GPixbufFormat *C.GdkPixbufFormat
}
// gdk_pixbuf_get_formats
func (v *Format) GetName() string {
return gostring(C.gdk_pixbuf_format_get_name(v.GPixbufFormat))
}
func (v *Format) GetDescription() string {
return gostring(C.gdk_pixbuf_format_get_description(v.GPixbufFormat))
}
func (v *Format) GetMimeTypes() []string {
gstrv := C.gdk_pixbuf_format_get_mime_types(v.GPixbufFormat)
defer C.g_strfreev(gstrv)
s := make([]string, 0)
for i := 0; C.getGstr(gstrv, C.int(i)) != nil; i++ {
s = append(s, gostring(C.getGstr(gstrv, C.int(i))))
}
return s
}
func (v *Format) GetExtensions() []string {
gstrv := C.gdk_pixbuf_format_get_extensions(v.GPixbufFormat)
defer C.g_strfreev(gstrv)
s := make([]string, 0)
for i := 0; C.getGstr(gstrv, C.int(i)) != nil; i++ {
s = append(s, gostring(C.getGstr(gstrv, C.int(i))))
}
return s
}
func (v *Format) IsWritable() bool {
return gobool(C.gdk_pixbuf_format_is_writable(v.GPixbufFormat))
}
func (v *Format) IsScalable() bool {
return gobool(C.gdk_pixbuf_format_is_scalable(v.GPixbufFormat))
}
func (v *Format) IsDisabled() bool {
return gobool(C.gdk_pixbuf_format_is_disabled(v.GPixbufFormat))
}
func (v *Format) SetDisabled(disabled bool) {
C.gdk_pixbuf_format_set_disabled(v.GPixbufFormat, gbool(disabled))
}
func (v *Format) GetLicense() string {
return gostring(C.gdk_pixbuf_format_get_license(v.GPixbufFormat))
}
//-----------------------------------------------------------------------
// Loader
//-----------------------------------------------------------------------
type Loader struct {
GPixbufLoader *C.GdkPixbufLoader
}
func NewLoader() *Loader {
return &Loader{
C.gdk_pixbuf_loader_new()}
}
func NewLoaderWithType(image_type string) (loader *Loader, err *glib.Error) {
var gerr *C.GError
ptr := C.CString(image_type)
defer cfree(ptr)
loader = &Loader{
C.gdk_pixbuf_loader_new_with_type(ptr, &gerr)}
if gerr != nil {
err = glib.ErrorFromNative(unsafe.Pointer(gerr))
}
return
}
func NewLoaderWithMimeType(mime_type string) (loader *Loader, err *glib.Error) {
var error *C.GError
ptr := C.CString(mime_type)
defer cfree(ptr)
loader = &Loader{
C.gdk_pixbuf_loader_new_with_mime_type(ptr, &error)}
err = glib.ErrorFromNative(unsafe.Pointer(error))
return
}
func (v Loader) GetPixbuf() *Pixbuf {
gpixbuf := C.gdk_pixbuf_loader_get_pixbuf(v.GPixbufLoader)
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
}
func (v Loader) Write(buf []byte) (bool, *glib.Error) {
var err *C.GError
var pbuf *byte
pbuf = &buf[0]
ret := gobool(C.gdk_pixbuf_loader_write(v.GPixbufLoader, C.to_gucharptr(unsafe.Pointer(pbuf)), C.gsize(len(buf)), &err))
if err != nil {
return ret, glib.ErrorFromNative(unsafe.Pointer(err))
}
return ret, nil
}
func (v Loader) Close() (bool, *glib.Error) {
var err *C.GError
ret := gobool(C.gdk_pixbuf_loader_close(v.GPixbufLoader, &err))
if err != nil {
return ret, glib.ErrorFromNative(unsafe.Pointer(err))
}
return ret, nil
}
//func (v Loader) GetPixbufAnimation() *Animation {
// return &Animation {
// C.gdk_pixbuf_loader_get_animation(v.GPixbufLoader) };
//}
func (v Loader) SetSize(width int, height int) {
C.gdk_pixbuf_loader_set_size(v.GPixbufLoader, C.int(width), C.int(height))
}
func (v Loader) GetFormat() *Format {
return &Format{
C.gdk_pixbuf_loader_get_format(v.GPixbufLoader)}
}
// FINISH

View File

@@ -0,0 +1,48 @@
#ifndef GO_GDK_PIXBUF_H
#define GO_GDK_PIXBUF_H
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
//static const gchar* to_gcharptr(const char* s) { return (const gchar*)s; }
static guchar* to_gucharptr(void* s) { return (guchar*)s; }
static inline GdkPixbuf* toGdkPixbuf(void* p) { return GDK_PIXBUF(p); }
static inline gchar* toGstr(const char* s) { return (gchar*)s; }
static inline char* toCstr(const gchar* s) { return (char*)s; }
static inline void freeCstr(char* s) { free(s); }
static inline char** makeCstrv(int count) {
return (char**)malloc(sizeof(char*) * count);
}
static guchar* _gdk_pixbuf_get_pixels_with_length(const GdkPixbuf *pixbuf, guint *length) {
#if GDK_PIXBUF_MAJOR >= 2 && GDK_PIXBUF_MINOR >= 26
return gdk_pixbuf_get_pixels_with_length(pixbuf, length);
#else
return NULL;
#endif
}
//
static inline void freeCstrv(char** cstrv) { free(cstrv); }
static inline char* getCstr(char** cstrv, int n) { return cstrv[n]; }
static inline void setCstr(char** cstrv, int n, char* str) { cstrv[n] = str; }
static inline gchar* getGstr(gchar** gstrv, int n) { return gstrv[n]; }
static int _check_version(int major, int minor, int micro) {
if (GDK_PIXBUF_MAJOR > major) return 1;
if (GDK_PIXBUF_MAJOR < major) return 0;
if (GDK_PIXBUF_MINOR > minor) return 1;
if (GDK_PIXBUF_MINOR < minor) return 0;
if (GDK_PIXBUF_MICRO > micro) return 1;
return 0;
}
#endif

1052
vendor/github.com/mattn/go-gtk/glib/glib.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

218
vendor/github.com/mattn/go-gtk/glib/glib.go.h generated vendored Normal file
View File

@@ -0,0 +1,218 @@
#ifndef GO_GLIB_H
#define GO_GLIB_H
#include <glib.h>
#include <glib-object.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static GList* to_list(void* l) {
return (GList*)l;
}
static GSList* to_slist(void* sl) {
return (GSList*)sl;
}
static GError* to_error(void* err) {
return (GError*)err;
}
static inline GObject* to_GObject(void* o) { return G_OBJECT(o); }
static inline gchar* to_gcharptr(const char* s) { return (gchar*)s; }
static inline char* to_charptr(const gchar* s) { return (char*)s; }
static inline char* to_charptr_from_gpointer(gpointer s) { return (char*)s; }
static inline char* to_charptr_voidp(const void* s) { return (char*)s; }
static inline void free_string(char* s) { free(s); }
static inline gchar* next_string(gchar* s) { return (gchar*)(s + strlen(s) + 1); }
static gboolean _g_utf8_validate(void* str, int len, void* ppbar) {
return g_utf8_validate((const gchar*)str, (gssize)len, (const gchar**)ppbar);
}
static gchar* _g_locale_to_utf8(void* opsysstring, int len, int* bytes_read, int* bytes_written, GError** error) {
return g_locale_from_utf8((const gchar*)opsysstring, (gssize)len, (gsize*)bytes_read, (gsize*)bytes_written, error);
}
static gchar* _g_locale_from_utf8(char* utf8string, int len, int* bytes_read, int* bytes_written, GError** error) {
return g_locale_from_utf8((const gchar*)utf8string, (gssize)len, (gsize*)bytes_read, (gsize*)bytes_written, error);
}
static void _g_object_set_ptr(gpointer object, const gchar *property_name, void* value) {
g_object_set(object, property_name, value, NULL);
}
static void _g_object_set_addr(gpointer object, const gchar *property_name, void* value) {
g_object_set(object, property_name, *(gpointer**)value, NULL);
}
//static void _g_object_get(gpointer object, const gchar *property_name, void* value) {
// g_object_get(object, property_name, value, NULL);
//}
static void g_value_init_int(GValue* gv) { g_value_init(gv, G_TYPE_INT); }
static void g_value_init_string(GValue* gv) { g_value_init(gv, G_TYPE_STRING); }
static GValue* init_gvalue_string_type() {
GValue* gv = g_new0(GValue, 1);
g_value_init(gv, G_TYPE_STRING);
return gv;
}
static GValue* init_gvalue_string(gchar* val) {
GValue* gv = init_gvalue_string_type();
g_value_set_string(gv, val);
return gv;
}
static GValue* init_gvalue_int_type() {
GValue* gv = g_new0(GValue, 1);
g_value_init(gv, G_TYPE_INT);
return gv;
}
static GValue* init_gvalue_int(gint val) {
GValue* gv = init_gvalue_int_type();
g_value_set_int(gv, val);
return gv;
}
static GValue* init_gvalue_uint(guint val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_UINT); g_value_set_uint(gv, val); return gv; }
static GValue* init_gvalue_int64(gint64 val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_INT64); g_value_set_int64(gv, val); return gv; }
static GValue* init_gvalue_double(gdouble val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_DOUBLE); g_value_set_double(gv, val); return gv; }
static GValue* init_gvalue_byte(guchar val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_UCHAR); g_value_set_uchar(gv, val); return gv; }
static GValue* init_gvalue_bool(gboolean val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_BOOLEAN); g_value_set_boolean(gv, val); return gv; }
//static GValue* init_gvalue_pointer(gpointer val) { GValue* gv = g_new0(GValue, 1); g_value_init(gv, G_TYPE_POINTER); g_value_set_pointer(gv, val); return gv; }
typedef struct {
char *name;
int func_no;
void* target;
uintptr_t* args;
int args_no;
void* ret;
gulong id;
} callback_info;
static uintptr_t callback_info_get_arg(callback_info* cbi, int idx) {
return cbi->args[idx];
}
extern void _go_glib_callback(callback_info* cbi);
static uintptr_t _glib_callback(void *data, ...) {
va_list ap;
callback_info *cbi = (callback_info*) data;
int i;
cbi->args = (uintptr_t*)malloc(sizeof(uintptr_t)*cbi->args_no);
va_start(ap, data);
for (i = 0; i < cbi->args_no; i++) {
cbi->args[i] = va_arg(ap, uintptr_t);
}
va_end(ap);
_go_glib_callback(cbi);
free(cbi->args);
return *(uintptr_t*)(&cbi->ret);
}
static void free_callback_info(gpointer data, GClosure *closure) {
g_slice_free(callback_info, data);
}
static callback_info* _g_signal_connect(void* obj, gchar* name, int func_no, int flags) {
GSignalQuery query;
callback_info* cbi;
guint signal_id = g_signal_lookup(name, G_OBJECT_TYPE(obj));
g_signal_query(signal_id, &query);
cbi = g_slice_new0(callback_info);
cbi->name = g_strdup(name);
cbi->func_no = func_no;
cbi->args = NULL;
cbi->target = obj;
cbi->args_no = query.n_params;
if (((GConnectFlags)flags) == G_CONNECT_AFTER)
cbi->id = g_signal_connect_data((gpointer)obj, name, G_CALLBACK(_glib_callback), (gpointer)cbi, free_callback_info, G_CONNECT_AFTER);
else
cbi->id = g_signal_connect_data((gpointer)obj, name, G_CALLBACK(_glib_callback), (gpointer)cbi, free_callback_info, G_CONNECT_SWAPPED);
return cbi;
}
static void _g_signal_emit_by_name(gpointer instance, const gchar *detailed_signal) {
g_signal_emit_by_name(instance, detailed_signal);
}
static gulong _g_signal_callback_id(callback_info* cbi) {
return cbi->id;
}
typedef struct {
int func_no;
gboolean ret;
guint id;
} sourcefunc_info;
extern void _go_glib_sourcefunc(sourcefunc_info* sfi);
static gboolean _go_sourcefunc(void *data) {
sourcefunc_info *sfi = (sourcefunc_info*) data;
_go_glib_sourcefunc(sfi);
return sfi->ret;
}
static void free_sourcefunc_info(gpointer data) {
g_slice_free(sourcefunc_info, data);
}
static sourcefunc_info* _g_idle_add(int func_no) {
sourcefunc_info* sfi;
sfi = g_slice_new0(sourcefunc_info);
sfi->func_no = func_no;
sfi->id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, _go_sourcefunc, sfi, free_sourcefunc_info);
return sfi;
}
static sourcefunc_info* _g_timeout_add(guint interval, int func_no) {
sourcefunc_info* sfi;
sfi = g_slice_new0(sourcefunc_info);
sfi->func_no = func_no;
sfi->id = g_timeout_add_full(G_PRIORITY_DEFAULT, interval, _go_sourcefunc, sfi, free_sourcefunc_info);
return sfi;
}
static void _g_thread_init(GThreadFunctions *vtable) {
#if !GLIB_CHECK_VERSION(2,32,0)
#ifdef G_THREADS_ENABLED
g_thread_init(vtable);
#endif
#endif
}
#if !GLIB_CHECK_VERSION(2,28,0)
static const gchar *
g_get_user_runtime_dir (void)
{
#ifndef G_OS_WIN32
static const gchar *runtime_dir;
static gsize initialised;
if (g_once_init_enter (&initialised)) {
runtime_dir = g_strdup (getenv ("XDG_RUNTIME_DIR"));
if (runtime_dir == NULL)
g_warning ("XDG_RUNTIME_DIR variable not set. Falling back to XDG cache dir.");
g_once_init_leave (&initialised, 1);
}
if (runtime_dir)
return runtime_dir;
/* Both fallback for UNIX and the default
* in Windows: use the user cache directory.
*/
#endif
return g_get_user_cache_dir ();
}
#endif
#endif

11272
vendor/github.com/mattn/go-gtk/gtk/gtk.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

873
vendor/github.com/mattn/go-gtk/gtk/gtk.go.h generated vendored Normal file
View File

@@ -0,0 +1,873 @@
#ifndef GO_GTK_H
#define GO_GTK_H
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#ifdef _WIN32
#include <windows.h>
#else
//Why is this necessary?
//#include <gdk/gdkx.h>
//#include <gdk/gdkquartz.h>
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <pthread.h>
static void _gtk_init(int* argc, char*** argv) {
gtk_init((int*)argc, (char***)argv);
}
static GtkClipboard* _gtk_clipboard_get_for_display(void* display, void* selection) {
return gtk_clipboard_get_for_display((GdkDisplay*)display, (GdkAtom)selection);
}
static int _gtk_selection_data_get_length(void* selection_data) {
return (int) gtk_selection_data_get_length((GtkSelectionData*)selection_data);
}
static void* _gtk_selection_data_get_data(void* selection_data) {
return (char*) gtk_selection_data_get_data((GtkSelectionData*)selection_data);
}
static char* _gtk_selection_data_get_text(void* selection_data) {
return (char*) gtk_selection_data_get_text((GtkSelectionData*)selection_data);
}
static void _gtk_drag_finish(void *context, gboolean success, gboolean del, guint32 time_) {
gtk_drag_finish((GdkDragContext*) context, success, del, time_);
}
static GtkWidget* _gtk_message_dialog_new(GtkWidget* parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, gchar *message) {
return gtk_message_dialog_new(
GTK_WINDOW(parent),
flags,
type,
buttons,
message, NULL);
}
static GtkWidget* _gtk_message_dialog_new_with_markup(GtkWidget* parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, gchar *message) {
return gtk_message_dialog_new_with_markup(
GTK_WINDOW(parent),
flags,
type,
buttons,
message, NULL);
}
static GtkWidget* _gtk_file_chooser_dialog_new(const gchar* title,
GtkWidget* parent, int file_chooser_action, int action, const gchar* button) {
return gtk_file_chooser_dialog_new(
title,
GTK_WINDOW(parent),
file_chooser_action,
button,
action,
NULL);
}
static GtkWidget* _gtk_file_chooser_widget_new(int file_chooser_action) {
return gtk_file_chooser_widget_new(file_chooser_action);
}
static GtkTreePath* _gtk_tree_model_get_path(GtkTreeModel* tree_model, GtkTreeIter* iter) {
return gtk_tree_model_get_path(tree_model, iter);
}
static void _gtk_text_buffer_insert_with_tag(GtkTextBuffer* buffer, GtkTextIter* iter, const gchar* text, gint len, GtkTextTag* tag) {
gtk_text_buffer_insert_with_tags(buffer, iter, text, len, tag, NULL);
}
//static void _gtk_text_buffer_insert_with_tags_by_name(GtkTextBuffer* buffer, GtkTextIter* iter, const gchar* text, gint len, const gchar* first_tag_name, ...);
static GtkTextTag* _gtk_text_buffer_create_tag(GtkTextBuffer* buffer, const gchar* tag_name) {
return gtk_text_buffer_create_tag(buffer, tag_name, NULL);
}
static void _gtk_widget_hide_on_delete(GtkWidget* w) {
g_signal_connect(GTK_WIDGET(w), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
}
static void _gtk_text_iter_assign(GtkTextIter* one, GtkTextIter* two) {
*one = *two;
}
static void _apply_property(void* obj, const gchar* prop, const gchar* val) {
GParamSpec *pspec;
GValue fromvalue = { 0, };
GValue tovalue = { 0, };
pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj), prop);
if (!pspec) return;
g_value_init(&fromvalue, G_TYPE_STRING);
g_value_set_string(&fromvalue, val);
g_value_init(&tovalue, G_PARAM_SPEC_VALUE_TYPE(pspec));
g_value_transform(&fromvalue, &tovalue);
g_object_set_property((GObject *)obj, prop, &tovalue);
g_value_unset(&fromvalue);
g_value_unset(&tovalue);
}
static GtkTreeViewColumn* _gtk_tree_view_column_new_with_attribute(gchar* title, GtkCellRenderer* cell) {
return gtk_tree_view_column_new_with_attributes(title, cell, NULL);
}
static GtkTreeViewColumn* _gtk_tree_view_column_new_with_attributes(gchar* title, GtkCellRenderer* cell, gchar* prop, gint column) {
return gtk_tree_view_column_new_with_attributes(title, cell, prop, column, NULL);
}
static void _gtk_list_store_set_ptr(GtkListStore* list_store, GtkTreeIter* iter, gint column, void* data) {
gtk_list_store_set(list_store, iter, column, data, -1);
}
static void _gtk_list_store_set_addr(GtkListStore* list_store, GtkTreeIter* iter, gint column, void* data) {
gtk_list_store_set(list_store, iter, column, *(gpointer*)data, -1);
}
static void _gtk_tree_store_set_ptr(GtkTreeStore* tree_store, GtkTreeIter* iter, gint column, void* data) {
gtk_tree_store_set(tree_store, iter, column, data, -1);
}
static void _gtk_tree_store_set_addr(GtkTreeStore* tree_store, GtkTreeIter* iter, gint column, void* data) {
gtk_tree_store_set(tree_store, iter, column, *(gpointer*)data, -1);
}
//static void _gtk_range_get_value(GtkRange* range, gdouble* value) {
// *value = gtk_range_get_value(range);
//}
static GtkTreeIter* _gtk_tree_iter_new() {
return (GtkTreeIter*)malloc(sizeof(GtkTreeIter));
}
typedef struct {
GtkTreeModel* model;
GtkTreeIter* a;
GtkTreeIter* b;
gint columnNum;
void* gots;
int ret;
} _gtk_sort_func_info;
extern void _go_call_sort_func(_gtk_sort_func_info* gsfi);
static gint sortable_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer gsfi) {
gint gret = 0;
_gtk_sort_func_info* gsfil = (_gtk_sort_func_info*) gsfi;
gsfil->model = model;
gsfil->a = a;
gsfil->b = b;
_go_call_sort_func(gsfil);
gret = gsfil->ret;
return gret;
}
static void free_sort_func(gpointer gsfi) {
free(gsfi);
}
static void _gtk_tree_sortable_set_sort_func(GtkTreeSortable* ts, gint col, void* gots) {
_gtk_sort_func_info* gsfi = malloc(sizeof(_gtk_sort_func_info));
gsfi->columnNum = col;
gsfi->gots = gots;
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ts), col, sortable_sort_func, (gpointer) gsfi, free_sort_func);
}
extern void _go_gtk_builder_connect_signals_full_cb(void* builder, void* object, gchar *signal_name, gchar *handler_name, void* connect_object, int flags, void* user_data);
static void _gtk_builder_connect_signals_full(GtkBuilder *builder, void* user_data) {
gtk_builder_connect_signals_full(builder, (GtkBuilderConnectFunc)_go_gtk_builder_connect_signals_full_cb, user_data);
}
typedef struct {
GtkMenu *menu;
gint x;
gint y;
gboolean push_in;
gpointer data;
} _gtk_menu_position_func_info;
extern void _go_gtk_menu_position_func(_gtk_menu_position_func_info* gmpfi);
static void _c_gtk_menu_position_func(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) {
_gtk_menu_position_func_info gmpfi;
gmpfi.menu = menu;
gmpfi.x = *x;
gmpfi.y = *y;
gmpfi.push_in = *push_in;
gmpfi.data = user_data;
_go_gtk_menu_position_func(&gmpfi);
*x = gmpfi.x;
*y = gmpfi.y;
*push_in = gmpfi.push_in;
#ifdef _WIN32
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
gint h = GTK_WIDGET(menu)->requisition.height;
if (*y + h > rect.bottom) *y -= h;
#endif
}
static void _gtk_menu_popup(GtkWidget *menu, GtkWidget *parent_menu_shell, GtkWidget *parent_menu_item, void* data, guint button, guint32 activate_time) {
gtk_menu_popup(GTK_MENU(menu), parent_menu_shell, parent_menu_item, _c_gtk_menu_position_func, (gpointer) data, button, activate_time);
}
extern gboolean _go_gtk_tree_selection_select_func(gpointer sel, gpointer model, gpointer path, gboolean selected, gpointer payload);
static gboolean _c_gtk_tree_selection_select_func(GtkTreeSelection *sel, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer payload) {
return _go_gtk_tree_selection_select_func(sel, model, path, selected, payload);
}
static void _go_gtk_tree_selection_set_select_function(GtkTreeSelection *sel, void * payload) {
gtk_tree_selection_set_select_function(sel, _c_gtk_tree_selection_select_func, payload, NULL);
}
static void _gtk_container_child_set_bool(GtkContainer* container, GtkWidget* child, const gchar* propname, gboolean value) {
gtk_container_child_set(container, child, propname, value, NULL);
}
static void _gtk_container_child_set_int(GtkContainer* container, GtkWidget* child, const gchar* propname, gint value) {
gtk_container_child_set(container, child, propname, value, NULL);
}
static inline GType* make_gtypes(int count) {
return g_new0(GType, count);
}
static inline void destroy_gtypes(GType* types) {
g_free(types);
}
static inline void set_gtype(GType* types, int n, int type) {
types[n] = (GType) type;
}
static inline gchar** make_strings(int count) {
return (gchar**)malloc(sizeof(gchar*) * count);
}
static inline void destroy_strings(gchar** strings) {
free(strings);
}
static inline gchar* get_string(gchar** strings, int n) {
return strings[n];
}
static inline void set_string(gchar** strings, int n, gchar* str) {
strings[n] = str;
}
static GSList* to_gslist(void* gs) {
return (GSList*)gs;
}
static int _check_version(int major, int minor, int micro) {
return GTK_CHECK_VERSION(major, minor, micro);
}
static void _gtk_tree_iter_assign(void* iter, void* to) {
*(GtkTreeIter*)iter = *(GtkTreeIter*)to;
}
static GtkWidget* _gtk_dialog_get_vbox(GtkWidget* w) {
return GTK_DIALOG(w)->vbox;
}
//////////////////////////////////////////////
// ############# Version Control #############
//////////////////////////////////////////////
#if GTK_CHECK_VERSION(2,14,0)
static gdouble _gtk_adjustment_get_lower(GtkAdjustment* adjustment) {
return gtk_adjustment_get_lower(adjustment);
}
static void _gtk_adjustment_set_lower(GtkAdjustment* adjustment, gdouble lower) {
gtk_adjustment_set_lower(adjustment, lower);
}
static gdouble _gtk_adjustment_get_upper(GtkAdjustment* adjustment) {
return gtk_adjustment_get_upper(adjustment);
}
static void _gtk_adjustment_set_upper(GtkAdjustment* adjustment, gdouble upper) {
gtk_adjustment_set_upper(adjustment, upper);
}
static gdouble _gtk_adjustment_get_step_increment(GtkAdjustment* adjustment) {
return gtk_adjustment_get_step_increment(adjustment);
}
static void _gtk_adjustment_set_step_increment(GtkAdjustment* adjustment, gdouble step_increment) {
gtk_adjustment_set_step_increment(adjustment, step_increment);
}
static gdouble _gtk_adjustment_get_page_increment(GtkAdjustment* adjustment) {
return gtk_adjustment_get_page_increment(adjustment);
}
static void _gtk_adjustment_set_page_increment(GtkAdjustment* adjustment, gdouble page_increment) {
gtk_adjustment_set_page_increment(adjustment, page_increment);
}
static gdouble _gtk_adjustment_get_page_size(GtkAdjustment* adjustment) {
return gtk_adjustment_get_page_size(adjustment);
}
static void _gtk_adjustment_set_page_size(GtkAdjustment* adjustment, gdouble page_size) {
gtk_adjustment_set_page_size(adjustment, page_size);
}
static void _gtk_adjustment_configure(GtkAdjustment* adjustment, gdouble value, gdouble lower, gdouble upper, gdouble step_increment, gdouble page_increment, gdouble page_size) {
gtk_adjustment_configure(adjustment, value, lower, upper, step_increment, page_increment, page_size);
}
#else //GTK_CHECK_VERSION(2,14,0)
static gdouble _gtk_adjustment_get_lower(GtkAdjustment* adjustment) {
return 0f;
}
static void _gtk_adjustment_set_lower(GtkAdjustment* adjustment, gdouble lower) {
}
static gdouble _gtk_adjustment_get_upper(GtkAdjustment* adjustment) {
return 0f;
}
static void _gtk_adjustment_set_upper(GtkAdjustment* adjustment, gdouble upper) {
}
static gdouble _gtk_adjustment_get_step_increment(GtkAdjustment* adjustment) {
return 0f;
}
static void _gtk_adjustment_set_step_increment(GtkAdjustment* adjustment, gdouble step_increment) {
}
static gdouble _gtk_adjustment_get_page_increment(GtkAdjustment* adjustment) {
return 0f;
}
static void _gtk_adjustment_set_page_increment(GtkAdjustment* adjustment, gdouble page_increment) {
}
static gdouble _gtk_adjustment_get_page_size(GtkAdjustment* adjustment) {
return 0f;
}
static void _gtk_adjustment_set_page_size(GtkAdjustment* adjustment, gdouble page_size) {
}
static void _gtk_adjustment_configure(GtkAdjustment* adjustment, gdouble value, gdouble lower, gdouble upper, gdouble step_increment, gdouble page_increment, gdouble page_size) {
}
#endif //GTK_CHECK_VERSION(2,14,0)
#if GTK_CHECK_VERSION(2,18,0)
static gboolean _gtk_cell_renderer_toggle_get_activatable(GtkCellRendererToggle *toggle) {
return gtk_cell_renderer_toggle_get_activatable(toggle);
}
static void _gtk_cell_renderer_toggle_set_activatable(GtkCellRendererToggle *toggle, gboolean setting) {
gtk_cell_renderer_toggle_set_activatable(toggle, setting);
}
static void _gtk_menu_set_reserve_toggle_size(GtkMenu *menu, gboolean reserve_toggle_size) {
gtk_menu_set_reserve_toggle_size(menu, reserve_toggle_size);
}
static gboolean _gtk_menu_get_reserve_toggle_size(GtkMenu *menu) {
return gtk_menu_get_reserve_toggle_size(menu);
}
static gboolean _gtk_range_get_flippable(GtkRange *range) {
return gtk_range_get_flippable(range);
}
static void _gtk_range_set_flippable(GtkRange *range, gboolean flippable) {
gtk_range_set_flippable(range, flippable);
}
static void _gtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation) {
gtk_widget_get_allocation(widget, allocation);
}
static void _gtk_widget_set_allocation(GtkWidget *widget, const GtkAllocation *allocation) {
gtk_widget_set_allocation(widget, allocation);
}
static gboolean _gtk_widget_get_app_paintable(GtkWidget *widget) {
return gtk_widget_get_app_paintable(widget);
}
static gboolean _gtk_widget_get_can_default(GtkWidget *widget) {
return gtk_widget_get_can_default(widget);
}
static void _gtk_widget_set_can_default(GtkWidget *widget, gboolean can_default) {
gtk_widget_set_can_default(widget, can_default);
}
static gboolean _gtk_widget_get_can_focus(GtkWidget *widget) {
return gtk_widget_get_can_focus(widget);
}
static void _gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus) {
gtk_widget_set_can_focus(widget, can_focus);
}
static gboolean _gtk_widget_get_double_buffered(GtkWidget *widget) {
return gtk_widget_get_double_buffered(widget);
}
static gboolean _gtk_widget_get_has_window(GtkWidget *widget) {
return gtk_widget_get_has_window(widget);
}
static void _gtk_widget_set_has_window(GtkWidget *widget, gboolean has_window) {
gtk_widget_set_has_window(widget, has_window);
}
static gboolean _gtk_widget_get_sensitive(GtkWidget *widget) {
return gtk_widget_get_sensitive(widget);
}
static gboolean _gtk_widget_is_sensitive(GtkWidget *widget) {
return gtk_widget_is_sensitive(widget);
}
static GtkStateType _gtk_widget_get_state(GtkWidget *widget) {
return gtk_widget_get_state(widget);
}
static gboolean _gtk_widget_get_visible(GtkWidget *widget) {
return gtk_widget_get_visible(widget);
}
static void _gtk_widget_set_visible(GtkWidget *widget, gboolean visible) {
gtk_widget_set_visible(widget, visible);
}
static gboolean _gtk_widget_has_default(GtkWidget *widget) {
return gtk_widget_has_default(widget);
}
static gboolean _gtk_widget_has_focus(GtkWidget *widget) {
return gtk_widget_has_focus(widget);
}
static gboolean _gtk_widget_has_grab(GtkWidget *widget) {
return gtk_widget_has_grab(widget);
}
static gboolean _gtk_widget_is_drawable(GtkWidget *widget) {
return gtk_widget_is_drawable(widget);
}
static gboolean _gtk_widget_is_toplevel(GtkWidget *widget) {
return gtk_widget_is_toplevel(widget);
}
static void _gtk_widget_set_window(GtkWidget *widget, GdkWindow *window) {
gtk_widget_set_window(widget, window);
}
static void _gtk_widget_set_receives_default(GtkWidget *widget, gboolean receives_default) {
gtk_widget_set_receives_default(widget, receives_default);
}
static gboolean _gtk_widget_get_receives_default(GtkWidget *widget) {
return gtk_widget_get_receives_default(widget);
}
static GtkWidget* _gtk_info_bar_new() {
return gtk_info_bar_new();
}
static void _gtk_info_bar_add_action_widget(GtkInfoBar *info_bar, GtkWidget *child, gint response_id) {
gtk_info_bar_add_action_widget(info_bar, child, response_id);
}
static GtkWidget* _gtk_info_bar_add_button(GtkInfoBar *info_bar, const gchar *button_text, gint response_id) {
return gtk_info_bar_add_button(info_bar, button_text, response_id);
}
static void _gtk_info_bar_set_response_sensitive(GtkInfoBar *info_bar, gint response_id, gboolean setting) {
gtk_info_bar_set_response_sensitive(info_bar, response_id, setting);
}
static void _gtk_info_bar_set_default_response(GtkInfoBar *info_bar, gint response_id) {
gtk_info_bar_set_default_response(info_bar, response_id);
}
static void _gtk_info_bar_response(GtkInfoBar *info_bar, gint response_id) {
gtk_info_bar_response(info_bar, response_id);
}
static void _gtk_info_bar_set_message_type(GtkInfoBar *info_bar, GtkMessageType message_type) {
gtk_info_bar_set_message_type(info_bar, message_type);
}
static GtkMessageType _gtk_info_bar_get_message_type(GtkInfoBar *info_bar) {
return gtk_info_bar_get_message_type(info_bar);
}
static GtkWidget* _gtk_info_bar_get_action_area(GtkInfoBar *info_bar) {
return gtk_info_bar_get_action_area(info_bar);
}
static GtkWidget* _gtk_info_bar_get_content_area(GtkInfoBar *info_bar) {
return gtk_info_bar_get_content_area(info_bar);
}
static GtkWidget* _gtk_entry_new_with_buffer(GtkEntryBuffer *buffer) {
return gtk_entry_new_with_buffer(buffer);
}
static GtkEntryBuffer* _gtk_entry_get_buffer(GtkEntry *entry) {
return gtk_entry_get_buffer(entry);
}
static void _gtk_entry_set_buffer(GtkEntry *entry, GtkEntryBuffer *buffer) {
gtk_entry_set_buffer(entry, buffer);
}
static GtkEntryBuffer* _gtk_entry_buffer_new(const gchar *initial_chars, gint n_initial_chars) {
return gtk_entry_buffer_new(initial_chars, n_initial_chars);
}
static const gchar* _gtk_entry_buffer_get_text(GtkEntryBuffer *buffer) {
return gtk_entry_buffer_get_text(buffer);
}
static void _gtk_entry_buffer_set_text(GtkEntryBuffer *buffer, const gchar *chars, gint n_chars) {
gtk_entry_buffer_set_text(buffer, chars, n_chars);
}
//static gsize _gtk_entry_buffer_get_bytes(GtkEntryBuffer *buffer) {
// return gtk_entry_buffer_get_bytes(buffer);
//}
static guint _gtk_entry_buffer_get_length(GtkEntryBuffer *buffer) {
return gtk_entry_buffer_get_length(buffer);
}
static gint _gtk_entry_buffer_get_max_length(GtkEntryBuffer *buffer) {
return gtk_entry_buffer_get_max_length(buffer);
}
static void _gtk_entry_buffer_set_max_length(GtkEntryBuffer *buffer, gint max_length) {
gtk_entry_buffer_set_max_length(buffer, max_length);
}
static guint _gtk_entry_buffer_insert_text(GtkEntryBuffer *buffer, guint position, const gchar *chars, gint n_chars) {
return gtk_entry_buffer_insert_text(buffer, position, chars, n_chars);
}
static guint _gtk_entry_buffer_delete_text(GtkEntryBuffer *buffer, guint position, gint n_chars) {
return gtk_entry_buffer_delete_text(buffer, position, n_chars);
}
static void _gtk_status_icon_set_title(GtkStatusIcon *status_icon, const gchar *title) {
gtk_status_icon_set_title(status_icon, title);
}
static const gchar* _gtk_status_icon_get_title(GtkStatusIcon *status_icon) {
return gtk_status_icon_get_title(status_icon);
}
#else //!GTK_CHECK_VERSION(2,18,0)
static gboolean _gtk_cell_renderer_toggle_get_activatable(GtkCellRendererToggle *toggle) {
return 0;
}
static void _gtk_cell_renderer_toggle_set_activatable(GtkCellRendererToggle *toggle, gboolean setting) {
}
static void _gtk_menu_set_reserve_toggle_size(GtkMenu *menu, gboolean reserve_toggle_size) {
}
static gboolean _gtk_menu_get_reserve_toggle_size(GtkMenu *menu) {
return 0;
}
static gboolean _gtk_range_get_flippable(GtkRange *range) {
return 0;
}
static void _gtk_range_set_flippable(GtkRange *range, gboolean flippable) {
}
static void _gtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation) {
}
static void _gtk_widget_set_allocation(GtkWidget *widget, const GtkAllocation *allocation) {
}
static gboolean _gtk_widget_get_app_paintable(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_get_can_default(GtkWidget *widget) {
return 0;
}
static void _gtk_widget_set_can_default(GtkWidget *widget, gboolean can_default) {
}
static gboolean _gtk_widget_get_can_focus(GtkWidget *widget) {
return 0;
}
static void _gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus) {
}
static gboolean _gtk_widget_get_double_buffered(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_get_has_window(GtkWidget *widget) {
return 0;
}
static void _gtk_widget_set_has_window(GtkWidget *widget, gboolean has_window) {
}
static gboolean _gtk_widget_get_sensitive(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_is_sensitive(GtkWidget *widget) {
return 0;
}
static GtkStateType _gtk_widget_get_state(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_get_visible(GtkWidget *widget) {
return 0;
}
static void _gtk_widget_set_visible(GtkWidget *widget, gboolean visible) {
}
static gboolean _gtk_widget_has_default(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_has_focus(GtkWidget *widget) {
return 0:
}
static gboolean _gtk_widget_has_grab(GtkWidget *widget) {
return 0;
}
static gboolean _gtk_widget_is_drawable(GtkWidget *widget) {
return 0:
}
static gboolean _gtk_widget_is_toplevel(GtkWidget *widget) {
return 0;
}
static void _gtk_widget_set_window(GtkWidget *widget, GdkWindow *window) {
}
static void _gtk_widget_set_receives_default(GtkWidget *widget, gboolean receives_default) {
}
static gboolean _gtk_widget_get_receives_default(GtkWidget *widget) {
return 0;
}
static GtkWidget* _gtk_info_bar_new() {
return NULL;
}
static void _gtk_info_bar_add_action_widget(GtkInfoBar *info_bar, GtkWidget *child, gint response_id) {
}
static GtkWidget* _gtk_info_bar_add_button(GtkInfoBar *info_bar, const gchar *button_text, gint response_id) {
return NULL;
}
static void _gtk_info_bar_set_response_sensitive(GtkInfoBar *info_bar, gint response_id, gboolean setting) {
}
static void _gtk_info_bar_set_default_response(GtkInfoBar *info_bar, gint response_id) {
}
static void _gtk_info_bar_response(GtkInfoBar *info_bar, gint response_id) {
}
static void _gtk_info_bar_set_message_type(GtkInfoBar *info_bar, GtkMessageType message_type) {
}
static GtkMessageType _gtk_info_bar_get_message_type(GtkInfoBar *info_bar) {
return 0;
}
static GtkWidget* _gtk_info_bar_get_action_area(GtkInfoBar *info_bar) {
return NULL;
}
static GtkWidget* _gtk_info_bar_get_content_area(GtkInfoBar *info_bar) {
return NULL;
}
static GtkWidget* _gtk_entry_new_with_buffer(GtkEntryBuffer *buffer) {
return NULL;
}
static GtkEntryBuffer* _gtk_entry_get_buffer(GtkEntry *entry) {
return NULL;
}
static void _gtk_entry_set_buffer(GtkEntry *entry, GtkEntryBuffer *buffer) {
}
static GtkEntryBuffer* _gtk_entry_buffer_new(const gchar *initial_chars, gint n_initial_chars) {
return NULL;
}
static const gchar* _gtk_entry_buffer_get_text(GtkEntryBuffer *buffer) {
return NULL;
}
static void _gtk_entry_buffer_set_text(GtkEntryBuffer *buffer, const gchar *chars, gint n_chars) {
}
//static gsize _gtk_entry_buffer_get_bytes(GtkEntryBuffer *buffer) {
// return 0;
//}
static guint _gtk_entry_buffer_get_length(GtkEntryBuffer *buffer) {
return 0;
}
static gint _gtk_entry_buffer_get_max_length(GtkEntryBuffer *buffer) {
return 0;
}
static void _gtk_entry_buffer_set_max_length(GtkEntryBuffer *buffer, gint max_length) {
}
static guint _gtk_entry_buffer_insert_text(GtkEntryBuffer *buffer, guint position, const gchar *chars, gint n_chars) {
return 0;
}
static guint _gtk_entry_buffer_delete_text(GtkEntryBuffer *buffer, guint position, gint n_chars) {
return 0;
}
static void _gtk_status_icon_set_title(GtkStatusIcon *status_icon, const gchar *title) {
}
static const gchar* _gtk_status_icon_get_title(GtkStatusIcon *status_icon) {
return NULL;
}
#endif //GTK_CHECK_VERSION(2,18,0)
#if GTK_CHECK_VERSION(2,20,0)
static GtkWidget* _gtk_dialog_get_widget_for_response(GtkDialog* dialog, gint id) {
return gtk_dialog_get_widget_for_response(dialog, id);
}
static GdkWindow* _gtk_viewport_get_bin_window(GtkViewport *viewport) {
return gtk_viewport_get_bin_window(viewport);
}
static void _gtk_status_icon_set_name(GtkStatusIcon *status_icon, const gchar *name) {
gtk_status_icon_set_name(status_icon, name);
}
#else //GTK_CHECK_VERSION(2,20,0)
static GtkWidget* _gtk_dialog_get_widget_for_response(GtkDialog* dialog, gint id) {
return NULL;
}
static GdkWindow* _gtk_viewport_get_bin_window(GtkViewport *viewport) {
return NULL;
}
static void _gtk_status_icon_set_name(GtkStatusIcon *status_icon, const gchar *name) {
}
#endif //GTK_CHECK_VERSION(2,20,0)
#if GTK_CHECK_VERSION(2,22,0)
static GtkWidget* _gtk_accessible_get_widget(GtkAccessible *accessible) {
return gtk_accessible_get_widget(accessible);
}
static void _gtk_accessible_set_widget(GtkAccessible *accessible, GtkWidget *widget) {
gtk_accessible_set_widget(accessible, widget);
}
static GdkWindow* _gtk_viewport_get_view_window(GtkViewport *viewport) {
return gtk_viewport_get_view_window(viewport);
}
#else //GTK_CHECK_VERSION(2,22,0)
static GtkWidget* _gtk_accessible_get_widget(GtkAccessible *accessible) {
return NULL;
}
static void _gtk_accessible_set_widget(GtkAccessible *accessible, GtkWidget *widget) {
}
static GdkWindow* _gtk_viewport_get_view_window(GtkViewport *viewport) {
return NULL;
}
#endif //GTK_CHECK_VERSION(2,22,0)
#if GTK_CHECK_VERSION(2,24,0)
static GtkWidget* _gtk_combo_box_new_with_entry(void) {
return gtk_combo_box_new_with_entry();
}
static GtkWidget* _gtk_combo_box_new_with_model_and_entry(GtkTreeModel *model) {
return gtk_combo_box_new_with_model_and_entry(model);
}
static GtkWidget* _gtk_combo_box_text_new(void) {
return gtk_combo_box_text_new();
}
static GtkWidget* _gtk_combo_box_text_new_with_entry(void) {
return gtk_combo_box_text_new_with_entry();
}
static void _gtk_combo_box_text_append_text(GtkComboBoxText *combo_box, const gchar *text) {
gtk_combo_box_text_append_text(combo_box, text);
}
static void _gtk_combo_box_text_insert_text(GtkComboBoxText *combo_box, gint position, const gchar *text) {
gtk_combo_box_text_insert_text(combo_box, position, text);
}
static void _gtk_combo_box_text_prepend_text(GtkComboBoxText *combo_box, const gchar *text) {
gtk_combo_box_text_prepend_text(combo_box, text);
}
static void _gtk_combo_box_text_remove(GtkComboBoxText *combo_box, gint position) {
gtk_combo_box_text_remove(combo_box, position);
}
static gchar* _gtk_combo_box_text_get_active_text(GtkComboBoxText *combo_box) {
return gtk_combo_box_text_get_active_text(combo_box);
}
static void _gtk_notebook_set_group_name(GtkNotebook* notebook, const gchar* group_name) {
gtk_notebook_set_group_name(notebook, group_name);
}
static const gchar* _gtk_notebook_get_group_name(GtkNotebook* notebook) {
return gtk_notebook_get_group_name(notebook);
}
#else //GTK_CHECK_VERSION(2,24,0)
typedef GtkComboBox GtkComboBoxText;
static GtkWidget* _gtk_combo_box_new_with_entry(void) {
return NULL;
}
static GtkWidget* _gtk_combo_box_new_with_model_and_entry(GtkTreeModel *model) {
return NULL;
}
static GtkWidget* _gtk_combo_box_text_new(void) {
return NULL;
}
static GtkWidget* _gtk_combo_box_text_new_with_entry(void) {
return NULL;
}
static void _gtk_combo_box_text_append_text(GtkComboBoxText *combo_box, const gchar *text) {
}
static void _gtk_combo_box_text_insert_text(GtkComboBoxText *combo_box, gint position, const gchar *text) {
}
static void _gtk_combo_box_text_prepend_text(GtkComboBoxText *combo_box, const gchar *text) {
}
static void _gtk_combo_box_text_remove(GtkComboBoxText *combo_box, gint position) {
}
static gchar* _gtk_combo_box_text_get_active_text(GtkComboBoxText *combo_box) {
return NULL;
}
static void _gtk_notebook_set_group_name(GtkNotebook* notebook, const gchar* group_name) {
}
static const gchar* _gtk_notebook_get_group_name(GtkNotebook* notebook) {
return NULL;
}
#endif //GTK_CHECK_VERSION(2,24,0)
static GtkCellRenderer* _gtk_cell_renderer_spinner_new(void) {
#ifdef GTK_CELL_RENDERER_SPINNER //2.20
return gtk_cell_renderer_spinner_new();
#else
return gtk_cell_renderer_spin_new();
#endif
}
//////////////////////////////////////////////
// ################# Casting #################
//////////////////////////////////////////////
static inline void freeCstr(char* s) { free(s); }
static inline gchar** nextGstr(gchar** s) { return (s+1); }
static inline gchar* toGstr(const char* s) { return (gchar*)s; }
static inline char* toCstr(const gchar* s) { return (char*)s; }
//static inline char* toCstrU(const guchar* s) { return (char*)s; }
//static inline char* toCstrV(const void* s) { return (char*)s; }
static inline GObject* toGObject(void* o) { return G_OBJECT(o); }
static inline GValue* toGValue(void* s) { return (GValue*)s; }
static inline GtkWindow* toGWindow(GtkWidget* w) { return GTK_WINDOW(w); }
static inline GtkDialog* toGDialog(GtkWidget* w) { return GTK_DIALOG(w); }
static inline GtkAboutDialog* toGAboutDialog(GtkWidget* w) { return GTK_ABOUT_DIALOG(w); }
static inline GtkContainer* toGContainer(GtkWidget* w) { return GTK_CONTAINER(w); }
static inline GtkFileChooser* toGFileChooser(GtkWidget* w) { return GTK_FILE_CHOOSER(w); }
static inline GtkFontSelection* toGFontSelection(GtkWidget* w) { return GTK_FONT_SELECTION(w); }
static inline GtkFontSelectionDialog* toGFontSelectionDialog(GtkWidget* w) { return GTK_FONT_SELECTION_DIALOG(w); }
static inline GtkMisc* toGMisc(GtkWidget* w) { return GTK_MISC(w); }
static inline GtkLabel* toGLabel(GtkWidget* w) { return GTK_LABEL(w); }
static inline GtkButton* toGButton(GtkWidget* w) { return GTK_BUTTON(w); }
static inline GtkSpinButton* toGSpinButton(GtkWidget* w) { return GTK_SPIN_BUTTON(w); }
static inline GtkRadioButton* toGRadioButton(GtkWidget* w) { return GTK_RADIO_BUTTON(w); }
static inline GtkFontButton* toGFontButton(GtkWidget* w) { return GTK_FONT_BUTTON(w); }
static inline GtkLinkButton* toGLinkButton(GtkWidget* w) { return GTK_LINK_BUTTON(w); }
static inline GtkComboBox* toGComboBox(GtkWidget* w) { return GTK_COMBO_BOX(w); }
static inline GtkComboBoxEntry* toGComboBoxEntry(GtkWidget* w) { return GTK_COMBO_BOX_ENTRY(w); }
static inline GtkMessageDialog* toGMessageDialog(GtkWidget* w) { return GTK_MESSAGE_DIALOG(w); }
#if GTK_CHECK_VERSION(2,24,0)
static inline GtkComboBoxText* toGComboBoxText(GtkWidget* w) { return GTK_COMBO_BOX_TEXT(w); }
#else
static inline GtkComboBoxText* toGComboBoxText(GtkWidget* w) { return w; }
#endif
static inline GtkAccessible* toGAccessible(void* w) { return GTK_ACCESSIBLE(w); }
static inline GtkBin* toGBin(GtkWidget* w) { return GTK_BIN(w); }
static inline GtkStatusbar* toGStatusbar(GtkWidget* w) { return GTK_STATUSBAR(w); }
static inline GtkInfoBar* toGInfoBar(GtkWidget* w) { return GTK_INFO_BAR(w); }
static inline GtkFrame* toGFrame(GtkWidget* w) { return GTK_FRAME(w); }
static inline GtkBox* toGBox(GtkWidget* w) { return GTK_BOX(w); }
static inline GtkPaned* toGPaned(GtkWidget* w) { return GTK_PANED(w); }
static inline GtkToggleButton* toGToggleButton(GtkWidget* w) { return GTK_TOGGLE_BUTTON(w); }
static inline GtkAccelLabel* toGAccelLabel(GtkWidget* w) { return GTK_ACCEL_LABEL(w); }
static inline GtkEntry* toGEntry(GtkWidget* w) { return GTK_ENTRY(w); }
static inline GtkScaleButton* toGScaleButton(GtkWidget* w) { return GTK_SCALE_BUTTON(w); }
static inline GtkStyle* toGStyle(GtkObject* o) { return GTK_STYLE(o); }
static inline GtkAdjustment* toGAdjustment(GtkObject* o) { return GTK_ADJUSTMENT(o); }
static inline GtkArrow* toGArrow(GtkWidget* w) { return GTK_ARROW(w); }
static inline GtkTextView* toGTextView(GtkWidget* w) { return GTK_TEXT_VIEW(w); }
static inline GtkTextBuffer* toGTextBuffer(void* w) { return GTK_TEXT_BUFFER(w); }
static inline GtkTextTag* toGTextTag(void* o) { return GTK_TEXT_TAG(o); }
static inline GtkMenu* toGMenu(GtkWidget* w) { return GTK_MENU(w); }
static inline GtkMenuBar* toGMenuBar(GtkWidget* w) { return GTK_MENU_BAR(w); }
static inline GtkMenuShell* toGMenuShell(GtkWidget* w) { return GTK_MENU_SHELL(w); }
static inline GtkMenuItem* toGMenuItem(GtkWidget* w) { return GTK_MENU_ITEM(w); }
static inline GtkItem* toGItem(GtkWidget* w) { return GTK_ITEM(w); }
static inline GtkToolbar* toGToolbar(GtkWidget* w) { return GTK_TOOLBAR(w); }
static inline GtkToolItem* toGToolItem(GtkWidget* w) { return GTK_TOOL_ITEM(w); }
static inline GtkSeparatorToolItem* toGSeparatorToolItem(GtkWidget* w) { return GTK_SEPARATOR_TOOL_ITEM(w); }
static inline GtkToolButton* toGToolButton(GtkWidget* w) { return GTK_TOOL_BUTTON(w); }
static inline GtkToolPalette* toGToolPalette(GtkWidget* w) { return GTK_TOOL_PALETTE(w); }
static inline GtkToolItemGroup* toGToolItemGroup(GtkWidget* w) { return GTK_TOOL_ITEM_GROUP(w); }
static inline GtkMenuToolButton* toGMenuToolButton(GtkWidget* w) { return GTK_MENU_TOOL_BUTTON(w); }
static inline GtkToggleToolButton* toGToggleToolButton(GtkWidget* w) { return GTK_TOGGLE_TOOL_BUTTON(w); }
static inline GtkScrolledWindow* toGScrolledWindow(GtkWidget* w) { return GTK_SCROLLED_WINDOW(w); }
static inline GtkViewport* toGViewport(GtkWidget* w) { return GTK_VIEWPORT(w); }
static inline GtkWidget* toGWidget(void* w) { return GTK_WIDGET(w); }
static inline GdkWindow* toGdkWindow(void* w) { return GDK_WINDOW(w); }
static inline GdkScreen* toGdkScreen(void* s) { return GDK_SCREEN(s); }
static inline GtkTreeView* toGTreeView(GtkWidget* w) { return GTK_TREE_VIEW(w); }
static inline GtkIconView* toGIconView(GtkWidget* w) { return GTK_ICON_VIEW(w); }
static inline GtkTreeSortable* toGTreeSortable(GtkTreeModel* m) { return GTK_TREE_SORTABLE(m); }
static inline GtkEditable* toGEditable(GtkWidget* w) { return GTK_EDITABLE(w); }
static inline GtkCellRendererText* toGCellRendererText(GtkCellRenderer* w) { return GTK_CELL_RENDERER_TEXT(w); }
static inline GtkCellRendererToggle* toGCellRendererToggle(GtkCellRenderer* w) { return GTK_CELL_RENDERER_TOGGLE(w); }
static inline GtkScale* toGScale(GtkWidget* w) { return GTK_SCALE(w); }
static inline GtkRange* toGRange(GtkWidget* w) { return GTK_RANGE(w); }
static inline GtkTreeModel* toGTreeModelFromListStore(GtkListStore* w) { return GTK_TREE_MODEL(w); }
static inline GtkTreeModel* toGTreeModelFromTreeStore(GtkTreeStore* w) { return GTK_TREE_MODEL(w); }
static inline GtkListStore* toGListStore(void* w) { return GTK_LIST_STORE(w); }
static inline GtkImage* toGImage(GtkWidget* w) { return GTK_IMAGE(w); }
static inline GtkNotebook* toGNotebook(GtkWidget* w) { return GTK_NOTEBOOK(w); }
static inline GtkTable* toGTable(GtkWidget* w) { return GTK_TABLE(w); }
static inline GtkDrawingArea* toGDrawingArea(GtkWidget* w) { return GTK_DRAWING_AREA(w); }
static inline GtkSpinner* toGSpinner(GtkWidget* w) { return GTK_SPINNER(w); }
static inline GtkAssistant* toGAssistant(GtkWidget* w) { return GTK_ASSISTANT(w); }
static inline GtkExpander* toGExpander(GtkWidget* w) { return GTK_EXPANDER(w); }
static inline GtkAlignment* toGAlignment(GtkWidget* w) { return GTK_ALIGNMENT(w); }
static inline GtkProgressBar* toGProgressBar(GtkWidget* w) { return GTK_PROGRESS_BAR(w); }
static inline GtkFixed* toGFixed(GtkWidget* w) { return GTK_FIXED(w); }
static inline GtkCheckMenuItem* toGCheckMenuItem(GtkWidget* w) { return GTK_CHECK_MENU_ITEM(w); }
static inline GtkRadioMenuItem* toGRadioMenuItem(GtkWidget* w) { return GTK_RADIO_MENU_ITEM(w); }
static inline GtkFileFilter* toGFileFilter(gpointer p) { return GTK_FILE_FILTER(p); }
static inline GtkTreePath* to_GTreePath(gpointer p) { return (GtkTreePath *)p; }
static inline GtkTreeSelection* to_GTreeSelection(void *p) { return GTK_TREE_SELECTION(p); }
static inline GtkTreeModel* to_GTreeModel(void *p) { return GTK_TREE_MODEL(p); }
static inline GtkLayout* toGLayout(GtkWidget* w) { return GTK_LAYOUT(w); }
static inline GtkColorButton* toGColorButton(GtkWidget* w) { return GTK_COLOR_BUTTON(w); }
static inline GtkImageMenuItem* toGImageMenuItem(GtkWidget* w) { return GTK_IMAGE_MENU_ITEM(w); }
static inline GtkAction* toGAction(void* o) { return GTK_ACTION(o); }
static inline GtkToggleAction* toGToggleAction(void* o) { return GTK_TOGGLE_ACTION(o); }
static inline GtkRadioAction* toGRadioAction(void* o) { return GTK_RADIO_ACTION(o); }
static inline GtkRecentAction* toGRecentAction(void* o) { return GTK_RECENT_ACTION(o); }
static inline GtkActionGroup* toGActionGroup(void* o) { return GTK_ACTION_GROUP(o); }
static inline GtkActivatable* toGActivatable(GtkWidget* w) { return GTK_ACTIVATABLE(w); }
static inline GtkUIManager* toGUIManager(void* o) { return GTK_UI_MANAGER(o); }
#endif

58
vendor/github.com/mattn/go-gtk/gtk/gtk_test.go generated vendored Normal file
View File

@@ -0,0 +1,58 @@
package gtk
import (
"testing"
)
func TestUpdateTreeViewColumns(t *testing.T) {
Init(nil)
columnsDesc := []struct {
Title string
Type string
GTKType ICellRenderer
}{
{"Col_1", "text", NewCellRendererText()},
{"Col_2", "text", NewCellRendererText()},
}
tw := NewTreeView()
for i, c := range columnsDesc {
tw.AppendColumn(NewTreeViewColumnWithAttributes(c.Title, c.GTKType, c.Type, i))
}
columns := tw.GetColumns()
if len(columns) != len(columnsDesc) {
t.Error("Wrong number of the columns:", len(columns), len(columnsDesc))
} else {
for i, _ := range columnsDesc {
if columns[i].GetTitle() != columnsDesc[i].Title {
t.Error("Wrong column title:", columns[i].GetTitle(), columnsDesc[i].Title)
}
}
}
for lastIndex := len(columns) - 1; lastIndex >= 0; {
c := columns[lastIndex]
after := tw.RemoveColumn(c)
numbersColumns := lastIndex
if numbersColumns != after {
t.Error("Failed remove column:", numbersColumns, after)
}
lastIndex -= 1
if lastIndex >= 0 {
if title := tw.GetColumns()[lastIndex].GetTitle(); title != columnsDesc[lastIndex].Title {
t.Error("Wrong column title:", title, columnsDesc[lastIndex].Title)
}
}
}
if count := len(tw.GetColumns()); count != 0 {
t.Error("Wrong number of the columns:", count)
}
}

13
vendor/github.com/mattn/go-gtk/gtk/gtk_x11.go generated vendored Normal file
View File

@@ -0,0 +1,13 @@
// +build with-x11
package gtk
import (
"unsafe"
"github.com/mattn/go-gtk/gdk"
)
func (v *Window) XID() int32 {
return gdk.WindowFromUnsafe(unsafe.Pointer(v.GWidget.window)).GetNativeWindowID()
}

34
vendor/github.com/mattn/go-gtk/gtkgl/gdkgl.go generated vendored Normal file
View File

@@ -0,0 +1,34 @@
// +build !cgocheck
package gtkgl
const (
ATTR_NONE = 0
ATTR_USE_GL = 1
ATTR_BUFFER_SIZE = 2
ATTR_LEVEL = 3
ATTR_RGBA = 4
ATTR_DOUBLEBUFFER = 5
ATTR_STEREO = 6
ATTR_AUX_BUFFERS = 7
ATTR_RED_SIZE = 8
ATTR_GREEN_SIZE = 9
ATTR_BLUE_SIZE = 10
ATTR_ALPGHA_SIZE = 11
ATTR_DEPTH_SIZE = 12
ATTR_STENCIL_SIZE = 13
ATTR_ACCUM_RED_SIZE = 14
ATTR_ACCUM_GREEN_SIZE = 15
ATTR_ACCUM_BLUE_SIZE = 16
ATTR_ACCUM_ALPHA_SIZE = 17
)
const (
ATTR_X_VISUAL_TYPE_EXT = 0x22
ATTR_TRANSPARENT_TYPE_EXT = 0x23
ATTR_TRANSPARENT_INDEX_VALUE_EXT = 0x24
ATTR_TRANSPARENT_RED_VALUE_EXT = 0x25
ATTR_TRANSPARENT_GREEN_VALUE_EXT = 0x26
ATTR_TRANSPARENT_BLUE_VALUE_EXT = 0x27
ATTR_TRANSPARENT_ALPHA_VALUE_EXT = 0x28
)

28
vendor/github.com/mattn/go-gtk/gtkgl/gtkgl.go.h generated vendored Normal file
View File

@@ -0,0 +1,28 @@
#ifndef GO_GTKGL_H
#define GO_GTKGL_H
#include <gtkgl/gdkgl.h>
#include <gtkgl/gtkglarea.h>
#include <stdlib.h>
#include <string.h>
void *make_area(int attr_count, int *attrs) {
if (attr_count > 0 && attrs[attr_count-1] == 0) {
// already null terminated; use the pointer directly
return gtk_gl_area_new(attrs);
} else {
// make a null terminated copy of the attribute list
GtkWidget *area = NULL;
int *zattrs = malloc((attr_count+1)*sizeof(int));
if (!zattrs) {
return NULL;
}
memcpy(zattrs, attrs, attr_count * sizeof(attrs));
zattrs[attr_count] = 0;
area = gtk_gl_area_new(zattrs);
free(zattrs);
return area;
}
}
#endif

27
vendor/github.com/mattn/go-gtk/gtkgl/gtkglarea.go generated vendored Normal file
View File

@@ -0,0 +1,27 @@
// +build !cgocheck
package gtkgl
// #include "gtkgl.go.h"
// #cgo pkg-config: gtkgl-2.0
import "C"
import "github.com/mattn/go-gtk/gtk"
import "unsafe"
type GLArea struct {
gtk.DrawingArea
}
func NewGLArea(attrList []int) *GLArea {
return &GLArea{gtk.DrawingArea{
*gtk.WidgetFromNative(C.make_area(C.int(len(attrList)), (*C.int)(unsafe.Pointer(&attrList[0]))))}}
}
func (v *GLArea) MakeCurrent() {
C.gtk_gl_area_make_current((*C.GtkGLArea)(unsafe.Pointer(v.GWidget)))
}
func (v *GLArea) SwapBuffers() {
C.gtk_gl_area_swap_buffers((*C.GtkGLArea)(unsafe.Pointer(v.GWidget)))
}

View File

@@ -0,0 +1,405 @@
// +build !cgocheck
package gtksourceview
// #include "gtksourceview.go.h"
// #cgo pkg-config: gtksourceview-2.0
import "C"
import (
"unsafe"
"github.com/mattn/go-gtk/gtk"
)
func gstring(s *C.char) *C.gchar { return C.toGstr(s) }
func cstring(s *C.gchar) *C.char { return C.toCstr(s) }
func gostring(s *C.gchar) string { return C.GoString(cstring(s)) }
func gbool(b bool) C.gboolean {
if b {
return C.gboolean(1)
}
return C.gboolean(0)
}
func gobool(b C.gboolean) bool {
if b != 0 {
return true
}
return false
}
func cfree(s *C.char) { C.freeCstr(s) }
//-----------------------------------------------------------------------
// GtkSourceBuffer
//-----------------------------------------------------------------------
type SourceBuffer struct {
GSourceBuffer *C.GtkSourceBuffer
*gtk.TextBuffer
}
func NewSourceBuffer() *SourceBuffer {
v := C.gtk_source_buffer_new(nil)
return &SourceBuffer{v, gtk.NewTextBufferFromPointer(unsafe.Pointer(v))}
}
func NewSourceBufferWithLanguage(lang *SourceLanguage) *SourceBuffer {
v := C.gtk_source_buffer_new_with_language(lang.GSourceLanguage)
return &SourceBuffer{v, gtk.NewTextBufferFromPointer(unsafe.Pointer(v))}
}
func (v *SourceBuffer) GetNativeBuffer() unsafe.Pointer {
return unsafe.Pointer(v.GSourceBuffer)
}
func (v *SourceBuffer) SetHighlightSyntax(highlight bool) {
C.gtk_source_buffer_set_highlight_syntax(v.GSourceBuffer, gbool(highlight))
}
func (v *SourceBuffer) GetHighlightSyntax() bool {
return gobool(C.gtk_source_buffer_get_highlight_syntax(v.GSourceBuffer))
}
func (v *SourceBuffer) SetHighlightMatchingBrackets(hl bool) {
C.gtk_source_buffer_set_highlight_matching_brackets(v.GSourceBuffer, gbool(hl))
}
func (v *SourceBuffer) SetLanguage(lang *SourceLanguage) {
C.gtk_source_buffer_set_language(v.GSourceBuffer, lang.GSourceLanguage)
}
func (v *SourceBuffer) GetLanguage() *SourceLanguage {
return &SourceLanguage{C.gtk_source_buffer_get_language(v.GSourceBuffer)}
}
func (v *SourceBuffer) BeginNotUndoableAction() {
C.gtk_source_buffer_begin_not_undoable_action(v.GSourceBuffer)
}
func (v *SourceBuffer) EndNotUndoableAction() {
C.gtk_source_buffer_end_not_undoable_action(v.GSourceBuffer)
}
func (v *SourceBuffer) SetStyleScheme(scheme *SourceStyleScheme) {
C.gtk_source_buffer_set_style_scheme(v.GSourceBuffer, scheme.GSourceStyleScheme)
}
//-----------------------------------------------------------------------
// GtkSourceView
//-----------------------------------------------------------------------
type SourceView struct {
gtk.TextView
}
func NewSourceView() *SourceView {
return &SourceView{gtk.TextView{gtk.Container{
*gtk.WidgetFromNative(unsafe.Pointer(C.gtk_source_view_new()))}}}
}
func NewSourceViewWithBuffer(buf *SourceBuffer) *SourceView {
return &SourceView{gtk.TextView{gtk.Container{
*gtk.WidgetFromNative(unsafe.Pointer(C.gtk_source_view_new_with_buffer(buf.GSourceBuffer)))}}}
}
func (v *SourceView) ToNativeSourceView() *C.GtkSourceView {
return C.toGtkSourceView(unsafe.Pointer(v.GWidget))
}
func (v *SourceView) SetAutoIndent(enable bool) {
C.gtk_source_view_set_auto_indent(v.ToNativeSourceView(), gbool(enable))
}
func (v *SourceView) GetAutoIndent() bool {
return gobool(C.gtk_source_view_get_auto_indent(v.ToNativeSourceView()))
}
func (v *SourceView) SetHighlightCurrentLine(enable bool) {
C.gtk_source_view_set_highlight_current_line(v.ToNativeSourceView(), gbool(enable))
}
func (v *SourceView) GetHighlightCurrentLine() bool {
return gobool(C.gtk_source_view_get_highlight_current_line(v.ToNativeSourceView()))
}
func (v *SourceView) SetShowLineNumbers(enable bool) {
C.gtk_source_view_set_show_line_numbers(v.ToNativeSourceView(), gbool(enable))
}
func (v *SourceView) GetShowLineNumbers() bool {
return gobool(C.gtk_source_view_get_show_line_numbers(v.ToNativeSourceView()))
}
func (v *SourceView) SetRightMarginPosition(pos uint) {
C.gtk_source_view_set_right_margin_position(v.ToNativeSourceView(), C.guint(pos))
}
func (v *SourceView) GetRightMarginPosition() uint {
return uint(C.gtk_source_view_get_right_margin_position(v.ToNativeSourceView()))
}
func (v *SourceView) SetIndentWidth(width int) {
C.gtk_source_view_set_indent_width(v.ToNativeSourceView(), C.gint(width))
}
func (v *SourceView) GetIndentWidth() int {
return int(C.gtk_source_view_get_indent_width(v.ToNativeSourceView()))
}
func (v *SourceView) SetShowRightMargin(enable bool) {
C.gtk_source_view_set_show_right_margin(v.ToNativeSourceView(), gbool(enable))
}
func (v *SourceView) GetShowRightMargin() bool {
return gobool(C.gtk_source_view_get_show_right_margin(v.ToNativeSourceView()))
}
func (v *SourceView) SetInsertSpacesInsteadOfTabs(enable bool) {
C.gtk_source_view_set_insert_spaces_instead_of_tabs(v.ToNativeSourceView(), gbool(enable))
}
func (v *SourceView) GetInsertSpacesInsteadOfTabs() bool {
return gobool(C.gtk_source_view_get_insert_spaces_instead_of_tabs(v.ToNativeSourceView()))
}
type SourceDrawSpacesFlags int
const (
SOURCE_DRAW_SPACES_SPACE SourceDrawSpacesFlags = 1 << 0
SOURCE_DRAW_SPACES_TAB SourceDrawSpacesFlags = 1 << 1
SOURCE_DRAW_SPACES_NEWLINE SourceDrawSpacesFlags = 1 << 2
SOURCE_DRAW_SPACES_NBSP SourceDrawSpacesFlags = 1 << 3
SOURCE_DRAW_SPACES_LEADING SourceDrawSpacesFlags = 1 << 4
SOURCE_DRAW_SPACES_TEXT SourceDrawSpacesFlags = 1 << 5
SOURCE_DRAW_SPACES_TRAILING SourceDrawSpacesFlags = 1 << 6
SOURCE_DRAW_SPACES_ALL SourceDrawSpacesFlags = (SOURCE_DRAW_SPACES_SPACE |
SOURCE_DRAW_SPACES_TAB |
SOURCE_DRAW_SPACES_NEWLINE |
SOURCE_DRAW_SPACES_NBSP |
SOURCE_DRAW_SPACES_LEADING |
SOURCE_DRAW_SPACES_TEXT |
SOURCE_DRAW_SPACES_TRAILING)
)
func (v *SourceView) SetDrawSpaces(flags SourceDrawSpacesFlags) {
C.gtk_source_view_set_draw_spaces(v.ToNativeSourceView(),
C.GtkSourceDrawSpacesFlags(flags))
}
func (v *SourceView) GetDrawSpaces() SourceDrawSpacesFlags {
return SourceDrawSpacesFlags(C.gtk_source_view_get_draw_spaces(v.ToNativeSourceView()))
}
func (v *SourceView) SetTabWidth(width uint) {
C.gtk_source_view_set_tab_width(v.ToNativeSourceView(),
C.guint(width))
}
func (v *SourceView) GetTabWidth() uint {
return uint(C.gtk_source_view_get_tab_width(v.ToNativeSourceView()))
}
type SourceSmartHomeEndType int
const (
SOURCE_SMART_HOME_END_DISABLED SourceSmartHomeEndType = 0
SOURCE_SMART_HOME_END_BEFORE SourceSmartHomeEndType = 1
SOURCE_SMART_HOME_END_AFTER SourceSmartHomeEndType = 2
SOURCE_SMART_HOME_END_ALWAYS SourceSmartHomeEndType = 3
)
func (v *SourceView) SetSmartHomeEnd(flags SourceSmartHomeEndType) {
C.gtk_source_view_set_smart_home_end(v.ToNativeSourceView(),
C.GtkSourceSmartHomeEndType(flags))
}
func (v *SourceView) GetSmartHomeEnd() SourceSmartHomeEndType {
return SourceSmartHomeEndType(C.gtk_source_view_get_smart_home_end(v.ToNativeSourceView()))
}
//-----------------------------------------------------------------------
// GtkSourceLanguage
//-----------------------------------------------------------------------
type SourceLanguage struct {
GSourceLanguage *C.GtkSourceLanguage
}
func (v *SourceLanguage) GetId() string {
return gostring(C.gtk_source_language_get_id(v.GSourceLanguage))
}
func (v *SourceLanguage) GetName() string {
return gostring(C.gtk_source_language_get_name(v.GSourceLanguage))
}
func (v *SourceLanguage) GetSection() string {
return gostring(C.gtk_source_language_get_section(v.GSourceLanguage))
}
func (v *SourceLanguage) GetHidden() bool {
return gobool(C.gtk_source_language_get_hidden(v.GSourceLanguage))
}
func (v *SourceLanguage) GetMetadata(name string) string {
cname := C.CString(name)
defer cfree(cname)
return gostring(C.gtk_source_language_get_metadata(v.GSourceLanguage, gstring(cname)))
}
func (v *SourceLanguage) GetMimeTypes() []string {
var types []string
ctypes := C.gtk_source_language_get_mime_types(v.GSourceLanguage)
for {
types = append(types, gostring(*ctypes))
ctypes = C.nextGstr(ctypes)
if *ctypes == nil {
break
}
}
return types
}
func (v *SourceLanguage) GetGlobs() []string {
var globs []string
cglobs := C.gtk_source_language_get_globs(v.GSourceLanguage)
for {
globs = append(globs, gostring(*cglobs))
cglobs = C.nextGstr(cglobs)
if *cglobs == nil {
break
}
}
return globs
}
func (v *SourceLanguage) GetStyleName(styleId string) string {
cstyleId := C.CString(styleId)
defer cfree(cstyleId)
return gostring(C.gtk_source_language_get_metadata(v.GSourceLanguage, gstring(cstyleId)))
}
func (v *SourceLanguage) GetStyleIds() []string {
var ids []string
cids := C.gtk_source_language_get_globs(v.GSourceLanguage)
for {
ids = append(ids, gostring(*cids))
cids = C.nextGstr(cids)
if *cids == nil {
break
}
}
return ids
}
//FINISH
//-----------------------------------------------------------------------
// GtkSourceLanguageManager
//-----------------------------------------------------------------------
type SourceLanguageManager struct {
GSourceLanguageManager *C.GtkSourceLanguageManager
}
func NewSourceLanguageManager() *SourceLanguageManager {
return &SourceLanguageManager{C.gtk_source_language_manager_new()}
}
func SourceLanguageManagerGetDefault() *SourceLanguageManager {
return &SourceLanguageManager{C.gtk_source_language_manager_get_default()}
}
func (v *SourceLanguageManager) SetSearchPath(paths []string) {
cpaths := C.make_strings(C.int(len(paths) + 1))
for i, path := range paths {
ptr := C.CString(path)
defer cfree(ptr)
C.set_string(cpaths, C.int(i), gstring(ptr))
}
C.set_string(cpaths, C.int(len(paths)), nil)
C.gtk_source_language_manager_set_search_path(v.GSourceLanguageManager, cpaths)
C.destroy_strings(cpaths)
}
func (v *SourceLanguageManager) GetSearchPath() []string {
var dirs []string
cdirs := C.gtk_source_language_manager_get_search_path(v.GSourceLanguageManager)
for {
dirs = append(dirs, gostring(*cdirs))
cdirs = C.nextGstr(cdirs)
if *cdirs == nil {
break
}
}
return dirs
}
func (v *SourceLanguageManager) GetLanguageIds() []string {
var ids []string
cids := C.gtk_source_language_manager_get_language_ids(v.GSourceLanguageManager)
for {
ids = append(ids, gostring(*cids))
cids = C.nextGstr(cids)
if *cids == nil {
break
}
}
return ids
}
func (v *SourceLanguageManager) GetLanguage(id string) *SourceLanguage {
cid := C.CString(id)
defer cfree(cid)
return &SourceLanguage{C.gtk_source_language_manager_get_language(v.GSourceLanguageManager, gstring(cid))}
}
func (v *SourceLanguageManager) GuessLanguage(filename string, contentType string) *SourceLanguage {
if filename == "" {
cct := C.CString(contentType)
defer cfree(cct)
return &SourceLanguage{C.gtk_source_language_manager_guess_language(v.GSourceLanguageManager, nil, gstring(cct))}
}
cfn := C.CString(filename)
defer cfree(cfn)
return &SourceLanguage{C.gtk_source_language_manager_guess_language(v.GSourceLanguageManager, gstring(cfn), nil)}
}
//FINISH
//-----------------------------------------------------------------------
// GtkSourceStyle
//-----------------------------------------------------------------------
type SourceStyleScheme struct {
GSourceStyleScheme *C.GtkSourceStyleScheme
}
// gtk_source_style_scheme_get_id
// gtk_source_style_scheme_get_name
// gtk_source_style_scheme_get_description
// gtk_source_style_scheme_get_authors
// gtk_source_style_scheme_get_filename
// gtk_source_style_scheme_get_style
//-----------------------------------------------------------------------
// GtkSourceStyleSchemeManager
//-----------------------------------------------------------------------
type SourceStyleSchemeManager struct {
GSourceStyleSchemeManager *C.GtkSourceStyleSchemeManager
}
func NewSourceStyleSchemeManager() *SourceStyleSchemeManager {
return &SourceStyleSchemeManager{C.gtk_source_style_scheme_manager_new()}
}
func (v *SourceStyleSchemeManager) GetScheme(scheme_id string) *SourceStyleScheme {
cscheme_id := C.CString(scheme_id)
defer cfree(cscheme_id)
return &SourceStyleScheme{C.gtk_source_style_scheme_manager_get_scheme(v.GSourceStyleSchemeManager, gstring(cscheme_id))}
}
// gtk_source_style_scheme_manager_get_default
// gtk_source_style_scheme_manager_set_search_path
// gtk_source_style_scheme_manager_append_search_path
// gtk_source_style_scheme_manager_prepend_search_path
// gtk_source_style_scheme_manager_get_search_path
// gtk_source_style_scheme_manager_get_scheme_ids
// gtk_source_style_scheme_manager_force_rescan

View File

@@ -0,0 +1,30 @@
#ifndef GO_GTKSOURCEVIEW_H
#define GO_GTKSOURCEVIEW_H
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcebuffer.h>
#include <gtksourceview/gtksourcelanguage.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
#include <stdlib.h>
static inline gchar** make_strings(int count) {
return (gchar**)malloc(sizeof(gchar*) * count);
}
static inline void destroy_strings(gchar** strings) {
free(strings);
}
static inline void set_string(gchar** strings, int n, gchar* str) {
strings[n] = str;
}
static inline GObject* toGObject(void* o) { return G_OBJECT(o); }
static inline gchar* toGstr(const char* s) { return (gchar*)s; }
static inline char* toCstr(const gchar* s) { return (char*)s; }
static inline gchar** nextGstr(gchar** s) { return (s+1); }
static inline void freeCstr(char* s) { free(s); }
static GtkSourceView* toGtkSourceView(void* w) { return GTK_SOURCE_VIEW(w); }
#endif

56
vendor/github.com/mattn/go-gtk/gtkspell/gtkspell.go generated vendored Normal file
View File

@@ -0,0 +1,56 @@
// +build !cgocheck
package gtkspell
/*
#include <gtk/gtk.h>
#include <gtkspell/gtkspell.h>
#include <stdlib.h>
static GtkTextView* to_GtkTextView(void* w) { return GTK_TEXT_VIEW(w); }
static inline gchar* to_gcharptr(const char* s) { return (gchar*)s; }
*/
// #cgo pkg-config: gtkspell-2.0
import "C"
import "unsafe"
import "github.com/mattn/go-gtk/glib"
import "github.com/mattn/go-gtk/gtk"
//-----------------------------------------------------------------------
// GtkSpell
//-----------------------------------------------------------------------
type GtkSpell struct {
Spell *C.GtkSpell
}
func New(textview *gtk.TextView, language string) (*GtkSpell, *glib.Error) {
var lang *C.char
if len(language) > 0 {
lang = C.CString(language)
defer C.free(unsafe.Pointer(lang))
}
var gerror *C.GError
v := C.gtkspell_new_attach(C.to_GtkTextView(unsafe.Pointer(&textview.Widget)), C.to_gcharptr(lang), &gerror)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return &GtkSpell{v}, nil
}
func (spell *GtkSpell) SetLanguage(language string) *glib.Error {
lang := C.CString(language)
defer C.free(unsafe.Pointer(lang))
var gerror *C.GError
C.gtkspell_set_language(spell.Spell, C.to_gcharptr(lang), &gerror)
if gerror != nil {
return glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return nil
}
func (spell *GtkSpell) Recheck() {
C.gtkspell_recheck_all(spell.Spell)
}

101
vendor/github.com/mattn/go-gtk/pango/pango.go generated vendored Normal file
View File

@@ -0,0 +1,101 @@
// +build !cgocheck
package pango
// #include "pango.go.h"
// #cgo pkg-config: pango
import "C"
import "unsafe"
const (
SCALE = C.PANGO_SCALE
)
func bool2gboolean(b bool) C.gboolean {
if b {
return C.gboolean(1)
}
return C.gboolean(0)
}
func gboolean2bool(b C.gboolean) bool {
if b != 0 {
return true
}
return false
}
type WrapMode int
const (
WRAP_WORD WrapMode = 0
WRAP_CHAR WrapMode = 1
WRAP_WORD_CHAR WrapMode = 2
)
type EllipsizeMode int
const (
ELLIPSIZE_NONE EllipsizeMode = 0
ELLIPSIZE_START EllipsizeMode = 1
ELLIPSIZE_MIDDLE EllipsizeMode = 2
ELLIPSIZE_END EllipsizeMode = 3
)
type Context struct {
GContext *C.PangoContext
}
type Layout struct {
GLayout *C.PangoLayout
}
type FontDescription struct {
GFontDescription *C.PangoFontDescription
}
func ContextFromUnsafe(context unsafe.Pointer) *Context {
return &Context{(*C.PangoContext)(context)}
}
func (v *Layout) Unref() {
C.g_object_unref(C.gpointer(v.GLayout))
}
func (v *Layout) SetWidth(width int) {
C.pango_layout_set_width(v.GLayout, C.int(width))
}
func (v *Layout) SetFontDescription(d *FontDescription) {
C.pango_layout_set_font_description(v.GLayout, d.GFontDescription)
}
func (v *Layout) SetText(s string) {
cs := C.CString(s)
C.pango_layout_set_text(v.GLayout, cs, -1)
C.free(unsafe.Pointer(cs))
}
func NewLayout(ctx *Context) *Layout {
return &Layout{C.pango_layout_new(ctx.GContext)}
}
func NewFontDescription() *FontDescription {
return &FontDescription{C.pango_font_description_new()}
}
func (v *FontDescription) Free() {
C.pango_font_description_free(v.GFontDescription)
}
func (v *FontDescription) SetSize(size int) {
C.pango_font_description_set_size(v.GFontDescription, C.gint(size))
}
func (v *FontDescription) Copy() *FontDescription {
return &FontDescription{C.pango_font_description_copy(v.GFontDescription)}
}
func (f *FontDescription) GetSize() int {
return int(C.pango_font_description_get_size(f.GFontDescription))
}

23
vendor/github.com/mattn/go-gtk/pango/pango.go.h generated vendored Normal file
View File

@@ -0,0 +1,23 @@
#ifndef GO_PANGO_H
#define GO_PANGO_H
#ifndef uintptr
#define uintptr unsigned int*
#endif
#include <pango/pango.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
//static const gchar* to_gcharptr(const char* s) { return (const gchar*)s; }
//static guchar* to_gucharptr(void* s) { return (guchar*)s; }
//static void free_string(char* s) { free(s); }
//static gchar* to_gcharptr(char* s) { return (gchar*)s; }
//static void free_string(char* s) { free(s); }
#endif

View File

@@ -0,0 +1,106 @@
/*
Simple tool to approximatively count the progress of go-gtk library.
Counts line starting by "func" (binding done) or starting by "//" and containing "gtk_" (binding to do) for each section (starting by a "// text" comment preceded by a "//------------")
*/
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"sort"
"strings"
)
func main() {
list := make([]string, 0, 100)
alphabeticalOrder := flag.Bool("a", false, "alphabetical order")
githubCode := flag.Bool("g", false, "prepend spaces to each line so github will format them as code")
flag.Parse()
fname := flag.Arg(0)
if fname == "" {
fmt.Println("Usage: gogtkinfo [-ag] file")
return
}
file, err := os.Open(fname)
if err != nil {
log.Print(err.Error())
return
}
defer file.Close()
rd := bufio.NewReader(file)
var currentSection, sectionAlertName string
var cDone, cTodo, p, tDone, tTodo int
var sectionAlert, falseAlarm bool
for {
var l string
if falseAlarm {
falseAlarm = false
} else {
line, isPrefix, err := rd.ReadLine()
if err != nil {
break
}
if isPrefix {
return
}
l = string(line)
}
if strings.HasPrefix(l, "//---------------") {
if sectionAlertName == "" {
sectionAlert = true
} else {
if currentSection != "" {
cTot := cDone + cTodo
if cTot == 0 {
p = 100
} else {
p = 100 * cDone / cTot
}
s := fmt.Sprintf("%-30s: %3d%% (%3d/%3d)\n", currentSection, p, cDone, cTot)
list = append(list, s)
}
currentSection = sectionAlertName
tDone += cDone
tTodo += cTodo
cDone = 0
cTodo = 0
sectionAlertName = ""
}
} else if sectionAlert {
if strings.HasPrefix(l, "//") && len(l) > 3 && !strings.Contains(l, "gtk_") {
sectionAlertName = strings.TrimSpace(l[2:len(l)])
} else {
falseAlarm = true
}
sectionAlert = false
} else if strings.HasPrefix(l, "func") {
cDone++
} else if strings.HasPrefix(l, "//") && strings.Contains(l, "gtk_") {
cTodo++
}
}
if *alphabeticalOrder {
sort.StringSlice(list).Sort()
}
for _, s := range list {
if *githubCode {
fmt.Print(" ")
}
fmt.Print(s)
}
tTot := tDone + tTodo
if tTot == 0 {
p = 0
} else {
p = 100 * tDone / tTot
}
if *githubCode {
fmt.Print("\n ")
} else {
fmt.Print("\n")
}
fmt.Printf("Total progress : %18d%% (%d/%d)\n", p, tDone, tTot)
}