File: openimg_gtk.rb

package info (click to toggle)
mikutter 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,780 kB
  • sloc: ruby: 22,912; sh: 186; makefile: 21
file content (42 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download
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
# -*- coding: utf-8 -*-

require 'gtk3'
require 'cairo'

module Plugin::OpenimgGtk; end

require_relative 'window'

Plugin.create(:openimg_gtk) do
  UserConfig[:openimg_window_size_width_percent] ||= 70
  UserConfig[:openimg_window_size_height_percent] ||= 70
  UserConfig[:openimg_window_size_reference] ||= :mainwindow
  UserConfig[:openimg_window_size_reference_manual_num] ||= 0

  filter_openimg_pixbuf_from_display_url do |photo, _, _|
    loader = GdkPixbuf::PixbufLoader.new
    [photo, loader, photo.download { |partial| loader.write partial }]
  end

  intent Plugin::Openimg::Photo do |intent_token|
    Plugin::OpenimgGtk::Window.new(intent_token.model, intent_token).start_loading.show_all
  end

  intent :photo do |intent_token|
    Plugin::OpenimgGtk::Window.new(intent_token.model, intent_token).start_loading.show_all
  end

  settings('画像ビューア') do
    settings('ウィンドウサイズ') do
      adjustment('幅 (%)', :openimg_window_size_width_percent, 1, 100)
      adjustment('高さ (%)', :openimg_window_size_height_percent, 1, 100)
      select('サイズの基準', :openimg_window_size_reference) do
        option(:mainwindow, 'メインウィンドウがあるディスプレイ')
        option(:full, 'デスクトップ全体')
        option(:manual, 'ディスプレイ番号を指定') do
          adjustment('ディスプレイ番号', :openimg_window_size_reference_manual_num, 0, 99)
        end
      end
    end
  end
end