Skip to content

Commit

Permalink
Remove needless ScreenInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 14, 2024
1 parent 005f8d0 commit 9316ce2
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 76 deletions.
3 changes: 1 addition & 2 deletions lib/rabbit/canvas.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2004-2021 Sutou Kouhei <[email protected]>
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -110,7 +110,6 @@ class Canvas
def_delegators(:@renderer, :confirm)

def_delegators(:@renderer, :display?, :printable?)
def_delegators(:@renderer, :x_dpi, :y_dpi)

def_delegators(:@renderer, :whiteouting?, :blackouting?)
def_delegators(:@renderer, :toggle_whiteout, :toggle_blackout)
Expand Down
17 changes: 16 additions & 1 deletion lib/rabbit/frame.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]>
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require "forwardable"
require "rabbit/gtk"
require "rexml/text"
Expand All @@ -17,7 +33,6 @@

module Rabbit
class Frame
include ScreenInfo
extend Forwardable

def_delegators(:@window, :icon, :icon=, :set_icon)
Expand Down
9 changes: 1 addition & 8 deletions lib/rabbit/renderer/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2004-2019 Kouhei Sutou <[email protected]>
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -33,7 +33,6 @@ module Base

def_delegators(:@canvas, :reload_source)

attr_reader :x_dpi, :y_dpi
attr_accessor :base_width
attr_accessor :base_height
attr_accessor :paper_width, :paper_height, :slides_per_page
Expand Down Expand Up @@ -76,7 +75,6 @@ def initialize(canvas)
@graffiti_line_width = nil
@draw_scaled_image = true
clean
init_dpi
init_gl_parameters
end

Expand Down Expand Up @@ -359,11 +357,6 @@ def not_support_method(name)
@canvas.logger.warn(msg)
end

def init_dpi
@x_dpi = 72
@y_dpi = 72
end

def init_gl_parameters
angle = 0.0 * (Math::PI / 180.0)
axis_x = 1.0
Expand Down
21 changes: 16 additions & 5 deletions lib/rabbit/renderer/display/drawing-area-primitive.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]>
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require 'rabbit/gtk'

require "rabbit/utils"
Expand Down Expand Up @@ -117,11 +133,6 @@ def display?
end

private
def init_dpi
@x_dpi = ScreenInfo.screen_x_resolution
@y_dpi = ScreenInfo.screen_y_resolution
end

def init_drawing_area
@area = Gtk::DrawingArea.new
@area.can_focus = true
Expand Down
7 changes: 1 addition & 6 deletions lib/rabbit/renderer/offscreen.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2016-2019 Sutou Kouhei <[email protected]>
# Copyright (C) 2016-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -118,11 +118,6 @@ def init_color
def offscreen_renderer?
true
end

def init_dpi
@x_dpi = ScreenInfo.screen_x_resolution
@y_dpi = ScreenInfo.screen_y_resolution
end
end
end
end
10 changes: 2 additions & 8 deletions lib/rabbit/renderer/printer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2005-2019 Sutou Kouhei <[email protected]>
# Copyright (C) 2005-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -183,19 +183,13 @@ def init_color
@background = make_color(@background_color)
end

def init_dpi
super
@x_dpi = 300
@y_dpi = 300
end

def update_layout
@layout = PrintLayout.create(self, @canvas)
end

def create_context(output=nil)
surface = find_surface(filename, output)
surface.set_fallback_resolution(@x_dpi, @y_dpi)
surface.set_fallback_resolution(300, 300)
::Cairo::Context.new(surface)
end

Expand Down
7 changes: 1 addition & 6 deletions lib/rabbit/renderer/screen.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2018 Kouhei Sutou <[email protected]>
# Copyright (C) 2018-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -213,11 +213,6 @@ def draw_slide(slide, simulation, &block)
end

private
def init_dpi
@x_dpi = ScreenInfo.screen_x_resolution
@y_dpi = ScreenInfo.screen_y_resolution
end

def init_ui
@fixed = Gtk::Fixed.new
@fixed.can_focus = true
Expand Down
41 changes: 1 addition & 40 deletions lib/rabbit/utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2004-2024 Kouhei Sutou <[email protected]>
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]>
#
# 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
Expand Down Expand Up @@ -384,45 +384,6 @@ def run(cmd, *args, progress: nil)
end
end

module ScreenInfo
module_function
def default_screen
Gdk::Screen.default
end

def screen_width
default_screen.width
end

def screen_width_mm
default_screen.width_mm
end

def screen_height
default_screen.height
end

def screen_height_mm
default_screen.height_mm
end

def screen_x_resolution
screen_width / mm_to_inch(screen_width_mm)
end

def screen_y_resolution
screen_height / mm_to_inch(screen_height_mm)
end

def screen_depth
default_screen.system_visual.depth
end

def mm_to_inch(mm)
mm / 25.4
end
end

module HTML
module_function
def a_link(start_a, label, label_only)
Expand Down

0 comments on commit 9316ce2

Please sign in to comment.