Class: ManabuDesktop::Screens::Components::ServerListItem
- Inherits:
-
Object
- Object
- ManabuDesktop::Screens::Components::ServerListItem
- Defined in:
- lib/screens/components/server_list_item.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#list_box_row ⇒ Object
readonly
Returns the value of attribute list_box_row.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #_build_ability_menu_lbr(ability) ⇒ Object
- #_generate ⇒ Object
- #_get_ability_icon(ability) ⇒ Object
- #_populate_menu(builder) ⇒ Object
-
#initialize(client, user, server, port = 80) ⇒ ServerListItem
constructor
A new instance of ServerListItem.
Constructor Details
#initialize(client, user, server, port = 80) ⇒ ServerListItem
Returns a new instance of ServerListItem.
9 10 11 12 13 14 15 16 |
# File 'lib/screens/components/server_list_item.rb', line 9 def initialize(client, user, server, port = 80) @client = client @user = user @server = server @port = port super() _generate() end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def client @client end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def label @label end |
#list_box_row ⇒ Object (readonly)
Returns the value of attribute list_box_row.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def list_box_row @list_box_row end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def server @server end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/screens/components/server_list_item.rb', line 7 def user @user end |
Instance Method Details
#_build_ability_menu_lbr(ability) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/screens/components/server_list_item.rb', line 45 def (ability) builder = Gtk::Builder.new() builder.add_from_file("#{__dir__}/../../../layouts/server_menu_item.glade") = builder.get_object('server_menu_item.ListBoxRow') # TODO find the *actual* way to git children by ID box = .children[0] box.children[0].set_pixbuf(_get_ability_icon(ability)) box.children[2].label = I18n.t("g.#{ability.to_s}") #menu_item.ability = ability #menu_item.signal_connect 'set-focus-child' do |item| # ManabuDesktop::Screens.const_get(ability).new(@client) #end end |
#_generate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/screens/components/server_list_item.rb', line 18 def _generate() sib_builder = Gtk::Builder.new() sib_builder.add_from_file("#{__dir__}/../../../layouts/server_listbox.glade") @list_box_row = sib_builder.get_object('server_instance.ListBoxRow') @label = sib_builder.get_object('server_id.Label') @label.set_label("#{@user}@#{@server}:#{@port}") @menu_button = sib_builder.get_object('server_menu.Button') @menu_popover = sib_builder.get_object('server_menu.Popover') (sib_builder) @list_box_row.show_all() end |
#_get_ability_icon(ability) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/screens/components/server_list_item.rb', line 60 def _get_ability_icon(ability) case ability when :Toolbox pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:hammer_wrench].paths[:png][:px16]) when :Roster pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:student].paths[:png][:px16]) when :Courses pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:notebook].paths[:png][:px16]) when :Exams pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:white_check_mark].paths[:png][:px16]) when :Administration pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:wrench].paths[:png][:px16]) else pixbuf = GdkPixbuf::Pixbuf.new( file: ManabuDesktop::Tools.emojidex.emoji[:question].paths[:png][:px16]) end pixbuf end |
#_populate_menu(builder) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/screens/components/server_list_item.rb', line 30 def (builder) list_box = builder.get_object('server_menu.ListBox') list_box.add((:Toolbox)) list_box.add((:Roster)) list_box.add((:Courses)) list_box.add((:Exams)) list_box.add((:Administration)) list_box.show_all() @menu_button.signal_connect 'clicked' do || ManabuDesktop::Screens.Toolbox.new(@client) @menu_popover.visible = true end end |