GtkGesture ラスト、GtkGestureDrag を。
マウスでドラッグすると文字列が着いてくるサンプルコード。
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #!/usr/bin/env python3 import gi, sys gi.require_version( 'Gtk' , '4.0' ) from gi.repository import Gtk class Win(Gtk.ApplicationWindow): ''' GtkGestureDrag Sample Code ''' def __init__( self , app): Gtk.ApplicationWindow.__init__( self , application = app) # var self .offset_x = 50 self .offset_y = 50 self .draw_x = 0 self .draw_y = 0 # gesture drag drag = Gtk.GestureDrag() drag.connect( 'drag-begin' , self .on_gesture_drag_begin) drag.connect( 'drag-update' , self .on_gesture_drag_update) drag.connect( 'drag-end' , self .on_gesture_drag_end) self .add_controller(drag) # view self .view = Gtk.DrawingArea() self .view.set_draw_func( self .view_draw_func) self .set_child( self .view) # resize self .set_default_size( 400 , 300 ) def view_draw_func( self , da, cr, width, height): cr.move_to( self .draw_x + self .offset_x, self .draw_y + self .offset_y) cr.set_font_size( 36 ) cr.show_text( 'Drag and Drop' ) def on_gesture_drag_begin( self , ges, offset_x, offset_y): pass def on_gesture_drag_end( self , ges, offset_x, offset_y): self .offset_x + = offset_x self .offset_y + = offset_y def on_gesture_drag_update( self , ges, offset_x, offset_y): self .draw_x = offset_x self .draw_y = offset_y self .view.queue_draw() class App(Gtk.Application): def __init__( self ): Gtk.Application.__init__( self ) def do_startup( self ): Gtk.Application.do_startup( self ) Win( self ) def do_activate( self ): self .props.active_window.present() app = App() app.run(sys.argv) |
それと残りに GtkGestureStylus なんてのがあるけど。
どう考えてもスタイラスペン用途だよなって。
持っていないし GNOME てか Linux での使い道も思いつかない。
クリスタが Linux 対応するはずがないし、適材適所だよ。
なので無視でいいかなって。
ところでコレはファイルマネージャからのドロップではない。
GTK4 は drag_dest_add_uri_targets が使えないね。
Drag & dropping files with GTK4 – Platform – GNOME Discourse
こんなのを見つけたけど同じ所でクラッシュする。
うーん、今日もゲンナリするくらい進まない。