File: relational_menu.rb

package info (click to toggle)
mikutter 5.0.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,700 kB
  • sloc: ruby: 21,307; sh: 181; makefile: 19
file content (47 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

module Plugin::MastodonAccountViewer
  class RelationalMenu < Gtk::Menu
    def initialize(relation)
      super()

      @relation = relation

      ssc(:selection_done) do
        destroy
        false
      end

      ssc(:cancel) do
        destroy
        false
      end

      append(gen_menu_mute)
      append(gen_menu_block)
    end

    private

    def gen_menu_mute
      item = Gtk::MenuItem.new(@relation.mute? ? _('ミュート解除する') : _('ミュートする'))
      item.ssc(:activate) do
        @relation.request_update_mute_status(!@relation.mute?)
        true
      end
      item
    end

    def gen_menu_block
      item = Gtk::MenuItem.new(@relation.blocked? ? _('ブロック解除する') : _('ブロックする'))
      item.ssc(:activate) do
        @relation.request_update_block_status(!@relation.blocked?)
      end
      item
    end

    def _(*rest)
      Plugin[:mastodon_account_viewer]._(*rest)
    end
  end
end