class TootFrame

Public Class Methods

new(window, mastodon) click to toggle source
# File lib/legion/ui.rb, line 32
def initialize(window, mastodon)
        @tootFrame = TkFrame.new(window)
        @options = Hash[:visibility => "public", :sensitive => 'false', :spoiler_text => '']
        @visibility = ['public', 'unlisted', 'private', 'direct']
        @text = text = TkText.new(@tootFrame, 'width' => '50', 'height'=> '30')
        @button = TkButton.new(@tootFrame, 'text' => 'toot', 'command' => proc{mastodon.Toot(@text.value, @options);@text.value=""})
        @mediabutton = TkButton.new(@tootFrame, 'text' => 'media', 'command' => proc{mastodon.MediaUpload(Tk.getOpenFile)})
        @nsfw_button = TkButton.new(@tootFrame, 'text' => 'nsfw', 'command' => proc{@options[:sensitive] == 'true' ? @options[:sensitive] = 'false' : @options[:sensitive] = 'true' })
        @cw_button = TkButton.new(@tootFrame, 'text' => 'cw', 'command' => proc{@options[:spoiler_text] == "" ? @options[:spoiler_text] = "Contents Warning!" : @options[:spoiler_text] = ""; @options[:sensitive] == 'true' ? @options[:sensitive] = 'false' : @options[:sensitive] = 'true' })
        @quitbutton = TkButton.new(@tootFrame, 'text' => 'quit', 'command' => proc{exit})
end

Public Instance Methods

AccountMenu(window, streaming) click to toggle source
# File lib/legion/ui.rb, line 60
def AccountMenu(window, streaming)

        Dotenv.load

        menu = TkMenu.new(window)
        url = ENV["MASTODON_URL"].split(",")
        procArray = Array.new

        url.each do |address|
                menu.add('command', 'label' => "#{address}", 'command' => proc{streaming.num = url.index(address);}, 'underline' => 0)
        end

        return menu
end
Button_pack() click to toggle source
# File lib/legion/ui.rb, line 52
def Button_pack
        @button.pack('side' => 'left', 'fill' => 'both')
end
CwButton_pack() click to toggle source
# File lib/legion/ui.rb, line 99
def CwButton_pack
        @cw_button.pack('side' => 'left', 'fill' => 'both')
end
MediaButton_pack() click to toggle source
# File lib/legion/ui.rb, line 56
def MediaButton_pack
        @mediabutton.pack('side' => 'left', 'fill' => 'both')
end
MenuBar_pack(window, streaming) click to toggle source
NsfwButton_pack() click to toggle source
# File lib/legion/ui.rb, line 95
def NsfwButton_pack
        @nsfw_button.pack('side' => 'left', 'fill' => 'both')
end
Quitbutton_pack() click to toggle source
# File lib/legion/ui.rb, line 103
def Quitbutton_pack
        @quitbutton.pack('side' => 'right', 'fill' => 'both')
end
Text_pack() click to toggle source
# File lib/legion/ui.rb, line 48
def Text_pack
        @text.pack('side' => 'top', 'fill' => 'both')
end
TootFrame_pack() click to toggle source
# File lib/legion/ui.rb, line 44
def TootFrame_pack
        @tootFrame.pack('side' => 'left', 'fill' => 'both')
end
VisibilityMenu(window) click to toggle source
# File lib/legion/ui.rb, line 75
def VisibilityMenu(window)

        menu = TkMenu.new(window)

        @visibility.each do |visibility|
                menu.add('command', 'label' => "#{visibility}", 'command' => proc{@options[:visibility] = visibility;})
        end

        return menu
end
set(window, streaming) click to toggle source
# File lib/legion/ui.rb, line 107
def set(window, streaming)
        self.TootFrame_pack
        self.Text_pack
        self.Button_pack
        self.MediaButton_pack
        self.MenuBar_pack(window, streaming)
        self.NsfwButton_pack
        self.CwButton_pack
        self.Quitbutton_pack
end