diff --git a/lib/rabbit/cursor-manager.rb b/lib/rabbit/cursor-manager.rb index 15dfc477..380e9b7a 100644 --- a/lib/rabbit/cursor-manager.rb +++ b/lib/rabbit/cursor-manager.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2015 Kouhei Sutou +# Copyright (C) 2006-2024 Sutou Kouhei # # 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 @@ -39,17 +39,17 @@ def keep(name) @stocks[name].push(@current) end - def restore(drawable, name) + def restore(surface, name) if name.nil? type = @current else type = @stocks[name].pop end - drawable.cursor = type_to_cursor(type) + surface.cursor = type_to_cursor(type) end - def update(drawable, type) - drawable.cursor = type_to_cursor(type) + def update(surface, type) + surface.cursor = type_to_cursor(type) end private diff --git a/lib/rabbit/gtk.rb b/lib/rabbit/gtk.rb index 2d4f8ff3..de30d671 100644 --- a/lib/rabbit/gtk.rb +++ b/lib/rabbit/gtk.rb @@ -44,7 +44,14 @@ def call(*args, &block) end end - class ApplicationWindow + class Widget + # For GTK 3 + unless method_defined?(:surface) + def native + self + end + end + # GTK 4 renames Gdk::Window to Gdk::Surface unless method_defined?(:surface) alias_method :surface, :window diff --git a/lib/rabbit/renderer/display/base.rb b/lib/rabbit/renderer/display/base.rb index 55229f3e..fd7257b6 100644 --- a/lib/rabbit/renderer/display/base.rb +++ b/lib/rabbit/renderer/display/base.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2019 Kouhei Sutou +# Copyright (C) 2006-2024 Sutou Kouhei # # 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 @@ -25,7 +25,7 @@ module Base include HookHandler def initialize(*args, &block) - @drawable = nil + @surface = nil @size = nil @size_dirty = true super @@ -154,9 +154,9 @@ def draw_slide(slide, simulation) end private - def set_drawable(drawable) - @drawable = drawable - set_default_size(@drawable.width, @drawable.height) + def set_surface(surface) + @surface = surface + set_default_size(@surface.width, @surface.height) end def set_default_size(w, h) diff --git a/lib/rabbit/renderer/display/cursor.rb b/lib/rabbit/renderer/display/cursor.rb index 2864a6a2..1c2d99cf 100644 --- a/lib/rabbit/renderer/display/cursor.rb +++ b/lib/rabbit/renderer/display/cursor.rb @@ -1,3 +1,19 @@ +# Copyright (C) 2004-2024 Sutou Kouhei +# +# 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/cursor-manager" module Rabbit @@ -19,13 +35,13 @@ def keep_cursor(name) end def restore_cursor(name) - @cursor_manager.restore(@drawable, name) + @cursor_manager.restore(@surface, name) end def update_cursor(cursor_type, update_current_cursor=false) @cursor_manager.current = cursor_type if update_current_cursor cursor_type = :pencil if @graffiti_mode - @cursor_manager.update(@drawable, cursor_type) + @cursor_manager.update(@surface, cursor_type) end end end diff --git a/lib/rabbit/renderer/display/drawing-area-base.rb b/lib/rabbit/renderer/display/drawing-area-base.rb index c10cf14c..bb81cb57 100644 --- a/lib/rabbit/renderer/display/drawing-area-base.rb +++ b/lib/rabbit/renderer/display/drawing-area-base.rb @@ -1,3 +1,19 @@ +# Copyright (C) 2004-2024 Sutou Kouhei +# +# 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/renderer/display/drawing-area-primitive" require "rabbit/renderer/display/menu" require "rabbit/renderer/display/progress" @@ -289,7 +305,7 @@ def set_motion_notify_event end def paint(color_name) - context = @drawable.create_cairo_context + context = @surface.create_cairo_context context.set_source_rgba(*Color.parse(color_name).to_a) context.paint end @@ -313,9 +329,9 @@ def draw_current_slide_pixbuf(pixbuf) width, height = pixbuf.width, pixbuf.height x = @adjustment_x * width y = @adjustment_y * height - @drawable.draw_pixbuf(@foreground, pixbuf, - x, y, 0, 0, width, height, - Gdk::RGB::DITHER_NORMAL, 0, 0) + @surface.draw_pixbuf(@foreground, pixbuf, + x, y, 0, 0, width, height, + Gdk::RGB::DITHER_NORMAL, 0, 0) if @adjustment_x != 0 or @adjustment_y != 0 draw_next_slide end @@ -353,9 +369,9 @@ def draw_next_slide_pixbuf(pixbuf) src_height = -adjustment_height end - @drawable.draw_pixbuf(@foreground, pixbuf, src_x, src_y, - dest_x, dest_y, src_width, src_height, - Gdk::RGB::DITHER_NORMAL, 0, 0) + @surface.draw_pixbuf(@foreground, pixbuf, src_x, src_y, + dest_x, dest_y, src_width, src_height, + Gdk::RGB::DITHER_NORMAL, 0, 0) end def configured_after(widget, event) diff --git a/lib/rabbit/renderer/display/drawing-area-primitive.rb b/lib/rabbit/renderer/display/drawing-area-primitive.rb index a4277fff..9c01a7c6 100644 --- a/lib/rabbit/renderer/display/drawing-area-primitive.rb +++ b/lib/rabbit/renderer/display/drawing-area-primitive.rb @@ -152,7 +152,7 @@ def set_map end def mapped(widget) - set_drawable(widget.window) + set_surface(widget.native.surface) end def set_draw @@ -199,8 +199,8 @@ def set_configure_event end def configured(x, y, w, h) - @real_width = @drawable.width - @real_height = @drawable.height + @real_width = @surface.width + @real_height = @surface.height @size_dirty = true end @@ -225,7 +225,7 @@ def set_configure_event_after def configured_after(widget, event) update_size(event.width, event.height) - reload_theme if @drawable + reload_theme if @surface end def reload_theme(&callback) diff --git a/lib/rabbit/renderer/display/gesture.rb b/lib/rabbit/renderer/display/gesture.rb index 49813734..a6022df7 100644 --- a/lib/rabbit/renderer/display/gesture.rb +++ b/lib/rabbit/renderer/display/gesture.rb @@ -1,3 +1,19 @@ +# Copyright (C) 2006-2024 Sutou Kouhei +# +# 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/gesture/handler" module Rabbit @@ -49,7 +65,7 @@ def init_gesture first_move = !@gesture.moved? handled = @gesture.button_motion(event.x, event.y, width, height) queue_draw if handled or first_move - init_renderer(@drawable) + init_renderer(@surface) @gesture.draw_last_locus(self) finish_renderer true diff --git a/lib/rabbit/renderer/engine/cairo.rb b/lib/rabbit/renderer/engine/cairo.rb index e132a79d..73271410 100644 --- a/lib/rabbit/renderer/engine/cairo.rb +++ b/lib/rabbit/renderer/engine/cairo.rb @@ -1,3 +1,19 @@ +# Copyright (C) 2005-2024 Sutou Kouhei +# +# 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 "cairo" require "stringio" @@ -25,8 +41,8 @@ def background_image=(pixbuf) pixbuf end - def init_renderer(drawable) - init_context(drawable.create_cairo_context) + def init_renderer(surface) + init_context(surface.create_cairo_context) end def finish_renderer