class Plugin::ListSettings::Tab

Constants

DESCRIPTION
LIST
NAME
PUBLICITY
SLUG

Attributes

plugin[RW]

Public Class Methods

new(plugin) click to toggle source
Calls superclass method Gtk::CRUD.new
# File core/plugin/list_settings/tab.rb, line 15
def initialize(plugin)
  type_strict plugin => Plugin
  @plugin = plugin
  super()
  self.dialog_title = @plugin._('リスト') end

Public Instance Methods

buttons(box_klass) click to toggle source
# File core/plugin/list_settings/tab.rb, line 30
def buttons(box_klass)
  box_klass.new(false, 4).closeup(create_button).closeup(update_button).closeup(delete_button).closeup(extract_button) end
column_schemer() click to toggle source
# File core/plugin/list_settings/tab.rb, line 21
def column_schemer
  [{:kind => :text, :type => String, :label => @plugin._('リスト名')},
   {:type => UserList},
   {:type => String, :widget => :input, :label => @plugin._('リストの名前')},
   {:type => String, :widget => :input, :label => @plugin._('リスト説明')},
   {:type => TrueClass, :widget => :boolean, :label => @plugin._('公開')},
  ].freeze
end
extract_button() click to toggle source
# File core/plugin/list_settings/tab.rb, line 42
def extract_button
  if not defined? @extract_button
    @extract_button = Gtk::Button.new(Plugin[:list_settings]._("タブを作成"))
    @extract_button.ssc(:clicked) {
      record_extract(nil, nil) } end
  @extract_button end
menu_pop(widget, event) click to toggle source
on_created(iter) click to toggle source
# File core/plugin/list_settings/tab.rb, line 53
def on_created(iter)
  iter[SLUG] = "@#{Service.primary.user}/#{iter[NAME]}"
  Service.primary.add_list(user: Service.primary.user_obj,
                           mode: iter[PUBLICITY],
                           name: iter[NAME],
                           description: iter[DESCRIPTION]){ |event, list|
    if :success == event and list
      Plugin.call(:list_created, Service.primary, UserLists.new([list]))
      if not(destroyed?)
        iter[LIST] = list
        iter[SLUG] = list[:full_name] end end } end
on_deleted(iter) click to toggle source
# File core/plugin/list_settings/tab.rb, line 81
def on_deleted(iter)
  list = iter[LIST]
  if list
    Service.primary.delete_list(list_id: list[:id]){ |event, deleted_list|
      if event == :success
        Plugin.call(:list_destroy, Service.primary, UserLists.new([deleted_list]))
        model.remove(iter) if not destroyed? end
    }.terminate end end
on_extract(iter) click to toggle source
# File core/plugin/list_settings/tab.rb, line 90
def on_extract(iter)
  list = iter[LIST]
  if list
    dialog = Gtk::Dialog.new(Plugin[:list_settings]._("リスト「%{list_name}」の抽出タブを作成 - %{mikutter}") % {
                               mikutter: Environment::NAME,
                               list_name: list[:name]
                             }, nil, nil,
                             [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
                             [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT])
    prompt = Gtk::Entry.new
    prompt.text = list[:name]
    dialog.vbox.
      add(Gtk::HBox.new(false, 8).
           closeup(Gtk::Label.new(Plugin[:list_settings]._("タブの名前"))).
           add(prompt).show_all)
    dialog.run{ |response|
      if Gtk::Dialog::RESPONSE_ACCEPT == response
        Plugin.call :extract_tab_create,
                    name: prompt.text,
                    icon: Skin.get_path('list.png'),
                    sources: [:"#{list.user.idname}_list_#{list[:id]}"] end
      dialog.destroy
      prompt = dialog = nil } end
end
on_updated(iter) click to toggle source
# File core/plugin/list_settings/tab.rb, line 65
def on_updated(iter)
  list = iter[LIST]
  if list
    if list[:name] != iter[NAME] || list[:description] != iter[DESCRIPTION] || list[:mode] != iter[PUBLICITY]
      Service.primary.update_list(id: list[:id],
                                  name: iter[NAME],
                                  description: iter[DESCRIPTION],
                                  mode: iter[PUBLICITY]){ |event, updated_list|
        if not(destroyed?) and event == :success and updated_list
          iter[SLUG] = updated_list[:full_name]
          iter[LIST] = updated_list
          iter[NAME] = updated_list[:name]
          iter[DESCRIPTION] = updated_list[:description]
          iter[PUBLICITY] = updated_list[:mode] end
      }.terminate end end end
record_extract(optional, widget) click to toggle source
# File core/plugin/list_settings/tab.rb, line 49
def record_extract(optional, widget)
  self.selection.selected_each {|model, path, iter|
    on_extract(iter) } end