lib/rabbit/command/rabbit-slide.rb in rabbit-3.0.0 vs lib/rabbit/command/rabbit-slide.rb in rabbit-3.0.1

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2012-2019 Kouhei Sutou <kou@cozmixng.org> +# Copyright (C) 2012-2021 Sutou Kouhei <kou@cozmixng.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. @@ -104,10 +104,12 @@ format = _("Usage: %s COMMAND [OPTIONS]\n" \ " e.g.: %s new \\\n" \ " --id rubykaigi2012 \\\n" \ " --base-name rabbit-introduction \\\n" \ " --markup-language rd \\\n" \ + " --width 800 \\\n" \ + " --height 450 \\\n" \ " --name \"Kouhei Sutou\" \\\n" \ " --email kou@cozmixng.org \\\n" \ " --rubygems-user kou \\\n" \ " --slideshare-user kou \\\n" \ " --speaker-deck-user kou") @@ -216,10 +218,26 @@ _("(e.g.: %s)") % presentation_end_time_example, _("(optional)")) do |time| @data.slide_conf.presentation_end_time = time end + width_example = "--width=800" + parser.on("--width=WIDTH", Integer, + _("The default slide width"), + _("(e.g.: %s)") % width_example, + _("(optional)")) do |width| + @data.slide_conf.width = width + end + + height_example = "--width=450" + parser.on("--height=HEIGHT", Integer, + _("The default slide height"), + _("(e.g.: %s)") % height_example, + _("(optional)")) do |height| + @data.slide_conf.height = height + end + parser.separator(_("Your information")) messages = [ _("Author name of the new slide"), _("(e.g.: %s)") % "--name=\"Kouhei Sutou\"", @@ -322,10 +340,24 @@ def apply(entry) apply_value(entry.text) end end + class IntegerMapper + def initialize(data) + @data = data + end + + def attach(entry) + entry.value = value if value + end + + def apply(entry) + apply_value(entry.value_as_int) + end + end + class SlideIDMapper < TextMapper private def valid?(value) not value.empty? end @@ -372,15 +404,39 @@ id = id.to_sym if id @data.author_conf.markup_language = id end end + class SlideWidthMapper < IntegerMapper + private + def value + @data.slide_conf.width + end + + def apply_value(value) + @data.slide_conf.width = value + end + end + + class SlideHeightMapper < IntegerMapper + private + def value + @data.slide_conf.height + end + + def apply_value(value) + @data.slide_conf.height = value + end + end + def build_gui_mappers { "slide-id" => SlideIDMapper.new(@data), "slide-base-name" => SlideBaseNameMapper.new(@data), "slide-markup-language" => SlideMarkupLanguageMapper.new(@data), + "slide-width" => SlideWidthMapper.new(@data), + "slide-height" => SlideHeightMapper.new(@data), } end def show_gui require "rabbit/gtk" @@ -482,9 +538,11 @@ end def generate_dot_rabbit create_file(".rabbit") do |dot_rabbit| options = [] + size = [@data.slide_conf.width, @data.slide_conf.height].join(",") + options << "--size #{size}" if @data.author_conf.markup_language.nil? and @data.allotted_time options << "--allotted-time #{@data.allotted_time}" end options << slide_path dot_rabbit.puts(options.join("\n"))