first commit

master
Zac 4 years ago
commit 1c5b38b3a9
  1. 494
      glade/main.glade
  2. 494
      glade/main.glade~
  3. 177
      main.go
  4. 29
      settings.go
  5. 15
      settings_linux.go

@ -0,0 +1,494 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkDialog" id="LoginPopup">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Login To Mastodon</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="margin_left">74</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="LoginAuthBtn">
<property name="label" translatable="yes">Login</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="LoginCancelBtn">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="LoginInstanceEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="placeholder_text" translatable="yes">https://</property>
<property name="input_purpose">url</property>
<property name="input_hints">GTK_INPUT_HINT_LOWERCASE | GTK_INPUT_HINT_NONE</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Instance URL: </property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LoginAuthLbl">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="label" translatable="yes">Auth Code:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="LoginAuthEntry">
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="MainWindow">
<property name="name">MainWindow</property>
<property name="width_request">440</property>
<property name="height_request">640</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Untitled App</property>
<property name="default_width">440</property>
<property name="default_height">640</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="AccountList">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBoxRow">
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkButton" id="AddAccountBtn">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Settings</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="NewTootBtn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">New Toot</property>
<property name="use_underline">True</property>
<property name="icon_name">accessories-text-editor</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Home</property>
<property name="use_underline">True</property>
<property name="icon_name">go-home</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Notifications</property>
<property name="use_underline">True</property>
<property name="icon_name">emblem-important</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Local</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-dialog-authentication</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Federated</property>
<property name="use_underline">True</property>
<property name="icon_name">emblem-unreadable</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="TootList">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="TootBoostImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="TootFaveImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkPopoverMenu" id="TootOptions">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<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="expand">False</property>
<property name="fill">True</property>
<property name="position">0</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="expand">False</property>
<property name="fill">True</property>
<property name="position">1</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="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="submenu">main</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkImage" id="TootReplyImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkMenuButton" id="TootMenuBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="align_widget">TootOptionsHolder</property>
<property name="popover">TootOptions</property>
<child>
<placeholder/>
</child>
</object>
<object class="GtkBox" id="TootTemplate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage">
<property name="name">TootUserIcon</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="TootContent">
<property name="name">TootContent</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="TootReplyBtn">
<property name="name">TootReplyBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Reply</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootReplyImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootBoostBtn">
<property name="name">TootBoostBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Boost</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootBoostImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootFaveBtn">
<property name="name">TootFaveBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Favorite</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootFaveImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootOptionsHolder">
<property name="name">TootOptionsHolder</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="label_widget">TootMenuBtn</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>

@ -0,0 +1,494 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkDialog" id="LoginPopup">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Login To Mastodon</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="margin_left">74</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="LoginAuthBtn">
<property name="label" translatable="yes">Login</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="LoginCancelBtn">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="LoginInstanceEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="placeholder_text" translatable="yes">https://</property>
<property name="input_purpose">url</property>
<property name="input_hints">GTK_INPUT_HINT_LOWERCASE | GTK_INPUT_HINT_NONE</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Instance URL: </property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LoginAuthLbl">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Auth Code:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="MainWindow">
<property name="name">MainWindow</property>
<property name="width_request">440</property>
<property name="height_request">640</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Untitled App</property>
<property name="default_width">440</property>
<property name="default_height">640</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="AccountList">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBoxRow">
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkButton" id="AddAccountBtn">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Settings</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="NewTootBtn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">New Toot</property>
<property name="use_underline">True</property>
<property name="icon_name">accessories-text-editor</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Home</property>
<property name="use_underline">True</property>
<property name="icon_name">go-home</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Notifications</property>
<property name="use_underline">True</property>
<property name="icon_name">emblem-important</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Local</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-dialog-authentication</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_vertical">False</property>
<property name="label" translatable="yes">Federated</property>
<property name="use_underline">True</property>
<property name="icon_name">emblem-unreadable</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="TootList">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="TootBoostImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="TootFaveImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkPopoverMenu" id="TootOptions">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<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="expand">False</property>
<property name="fill">True</property>
<property name="position">0</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="expand">False</property>
<property name="fill">True</property>
<property name="position">1</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="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="submenu">main</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkImage" id="TootReplyImg">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkMenuButton" id="TootMenuBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="align_widget">TootOptionsHolder</property>
<property name="popover">TootOptions</property>
<child>
<placeholder/>
</child>
</object>
<object class="GtkBox" id="TootTemplate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage">
<property name="name">TootUserIcon</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="TootContent">
<property name="name">TootContent</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="TootReplyBtn">
<property name="name">TootReplyBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Reply</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootReplyImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootBoostBtn">
<property name="name">TootBoostBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Boost</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootBoostImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootFaveBtn">
<property name="name">TootFaveBtn</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Favorite</property>
<property name="use_underline">True</property>
<property name="icon_widget">TootFaveImg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="TootOptionsHolder">
<property name="name">TootOptionsHolder</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="label_widget">TootMenuBtn</property>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>

@ -0,0 +1,177 @@
package main
import (
"github.com/gotk3/gotk3/gtk"
"github.com/henvic/browser"
"log"
"os"
"strconv"
"fmt"
"strings"
)
var (
mainBuilder *gtk.Builder
AccelGroup *gtk.AccelGroup
MainWindow *gtk.Window
SettingsPath string = GetSettingsDir()
firstRun bool = !SettingsFileExists()
)
func init() {
// init GTK
gtk.Init(&os.Args)
// set up our main GTKBuilder instance
mainBuilder, _ = gtk.BuilderNew()
if err := mainBuilder.AddFromFile("glade/main.glade"); err != nil {
log.Fatal("couldn't load glade file", err)
}
AccelGroup, _ = gtk.AccelGroupNew()
}
func main() {
// go ahead and set up our main window but don't show it
setupMainWindow()
// if this is our first run (a settings file wasn't found)
// then we display our first run dialog
if firstRun {
displayFirstRun()
} else {
MainWindow.ShowAll()
}
gtk.Main()
}
func displayFirstRun() {
obj, _ := mainBuilder.GetObject("LoginPopup")
popup := obj.(*gtk.Dialog)
popup.Connect("destroy", func() {
if firstRun {
gtk.MainQuit()
} else {
popup.Hide()
}
})
obj, _ = mainBuilder.GetObject("LoginCancelBtn")
cancelBtn := obj.(*gtk.Button)
cancelBtn.Connect("clicked", func() {
if firstRun {
gtk.MainQuit()
} else {
popup.Hide()
}
})
obj, _ = mainBuilder.GetObject("LoginAuthBtn")
authBtn := obj.(*gtk.Button)
// hook up our login button
authBtn.Connect("clicked", func() {
// go ahead and get a ref to our auth code entry
// because we need it either way
obj, _ := mainBuilder.GetObject("LoginAuthEntry")
authEntry := obj.(*gtk.Entry)
// if the auth entry isn't visible then we
// know that the user doesn't have their auth code
// so we make sure to unhide the auth stuff first
// before we try and get the code
if !authEntry.GetVisible() {
// get our entry and the text it contained
obj, _ = mainBuilder.GetObject("LoginInstanceEntry")
entry := obj.(*gtk.Entry)
text, _ := entry.GetText()
// show the auth code stuff
obj, _ := mainBuilder.GetObject("LoginAuthLbl")
lbl := obj.(*gtk.Label)
authEntry.Show()
lbl.Show()
// did the text start with https scheme?
// if not we fix it internally
if !strings.HasPrefix(text, "https://") {
last := strings.LastIndex(text, "/")
if last > -1 {
text = "https://" + text[last + 1:]
} else {
text = "https://" + text
}
}
// for debugging
//fmt.Println(text)
// this needs to be replaced with the
// generated auth code URL
browser.OpenURL(text)
} else {
// here we're assuming that the user has entered in the
// auth code so we grab it
text, _ := authEntry.GetText()
fmt.Println(text)
}
})
popup.ShowAll()
}
func setupMainWindow() {
obj, _ := mainBuilder.GetObject("MainWindow")
MainWindow = obj.(*gtk.Window)
MainWindow.AddAccelGroup(AccelGroup)
MainWindow.Connect("destroy", func() {
gtk.MainQuit()
})
obj, _ = mainBuilder.GetObject("NewTootBtn")
btn := obj.(*gtk.ToolButton)
btn.Connect("clicked", func() {
fmt.Println("new toot window!")
})
addAccelerator(&btn.Bin.Container.Widget, "<Ctrl>Return", "clicked")
MainWindow.Hide()
}
func addRow(bldr *gtk.Builder, i int) {
// make a new builder so we can pull a 'fresh' copy
// of our template
builder, _ := gtk.BuilderNewFromFile("glade/main.glade")
tmplObj, _ := builder.GetObject("TootTemplate")
listObj, _ := bldr.GetObject("TootList") // make sure we get the old
// listBox instead
contentObj, _ := builder.GetObject("TootContent")
tmpl := tmplObj.(*gtk.Box)
tootList := listObj.(*gtk.ListBox)
content := contentObj.(*gtk.Label)
content.SetLabel("This is a test toot number " + strconv.FormatInt(int64(i), 10))
row, _ := gtk.ListBoxRowNew()
row.Add(tmpl)
row.ShowAll()
tootList.Prepend(row)
}
func addAccelerator(w *gtk.Widget, controlString, signal string) {
key, mod := gtk.AcceleratorParse(controlString)
w.AddAccelerator(signal, AccelGroup, key, mod, gtk.ACCEL_VISIBLE)
}

@ -0,0 +1,29 @@
package main
import (
"os"
"log"
)
const SettingsFile string = "settings.toml"
func SettingsFileExists() bool {
if _, err := os.Stat(SettingsPath + SettingsFile); err != nil {
return false
}
return true
}
func WriteSettingsFile(data []string) {
sFile, err := os.Open(SettingsPath + SettingsFile)
defer sFile.Close()
if err != nil {
log.Fatal("couldn't open settings file")
}
for _, s := range data {
sFile.Write([]byte(s))
}
}

@ -0,0 +1,15 @@
// +build linux darwin
package main
import "os/user"
import "os"
func GetSettingsDir() string {
usr, _ := user.Current()
folder := usr.HomeDir + "/.config/GTKMasto/"
os.MkdirAll(folder, 0644)
return folder
}