added some files I've been using for playing around with various gtk widgets and Go

master
Zachary Epps 4 years ago
parent 327496cd41
commit 22dc998041
  1. 289
      testing/MastoClient.glade
  2. 47
      testing/reveal2.go

@ -0,0 +1,289 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkTextBuffer" id="TootComposeBuffer"/>
<object class="GtkRadioMenuItem" id="VisabilityGroup">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="draw_as_radio">True</property>
</object>
<object class="GtkMenu" id="VisabilityMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioMenuItem" id="Vis_Public">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Public</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_as_radio">True</property>
<property name="group">VisabilityGroup</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="Vis_Unlisted">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Unlisted</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">VisabilityGroup</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="Vis_Follower">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Followers Only</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">VisabilityGroup</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="Vis_DM">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">DM</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">VisabilityGroup</property>
</object>
</child>
</object>
<object class="GtkWindow" id="WindowVert">
<property name="width_request">370</property>
<property name="height_request">275</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">New Toot</property>
<property name="resizable">False</property>
<property name="default_width">370</property>
<property name="default_height">275</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkRevealer" id="CWRevealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">CW:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">41</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">6</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ToggleCW">
<property name="label" translatable="yes">CW</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Toot</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popup">VisabilityMenu</property>
<property name="use_popover">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<child>
<object class="GtkTextView" id="TootCompose">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_default">True</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="wrap_mode">word</property>
<property name="buffer">TootComposeBuffer</property>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkLabel" id="TootCharacterCount">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">281</property>
<property name="margin_right">33</property>
<property name="margin_top">162</property>
<property name="label" translatable="yes">500</property>
<attributes>
<attribute name="foreground" value="#8b178b178b17"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">6</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="Window">
<property name="width_request">-1</property>
<property name="height_request">40</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="RevealBtn">
<property name="label" translatable="yes">Reveal</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRevealer" id="TestRevealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">slide-right</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

@ -0,0 +1,47 @@
package main
import (
"github.com/gotk3/gotk3/gtk"
"os"
"strconv"
)
var tootAmt int64 = 500
func main() {
gtk.Init(&os.Args)
b, _ := gtk.BuilderNewFromFile("MastoClient.glade")
obj, _ := b.GetObject("WindowVert")
win := obj.(*gtk.Window)
obj, _ = b.GetObject("ToggleCW")
btn := obj.(*gtk.Button)
obj, _ = b.GetObject("CWRevealer")
r := obj.(*gtk.Revealer)
obj, _ = b.GetObject("TootComposeBuffer")
buf := obj.(*gtk.TextBuffer)
obj, _ = b.GetObject("TootCharacterCount")
charCnt := obj.(*gtk.Label)
charCnt.SetText(strconv.FormatInt(tootAmt, 10))
buf.Connect("changed", func(tbuf *gtk.TextBuffer) {
amt := tbuf.GetCharCount()
charCnt.SetText(strconv.FormatInt(tootAmt - int64(amt), 10))
})
win.Connect("destroy", func() {
gtk.MainQuit()
})
btn.Connect("clicked", func() {
r.SetRevealChild(!r.GetChildRevealed())
})
win.ShowAll()
gtk.Main()
}