GTK Example Drag&DROP files in the window?

Linux specific questions.
Post Reply
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

GTK Example Drag&DROP files in the window?

Post by VANYA »

Hi All!

Does anyone have an example DRAG&DROP files in to program? Only interested in examples of using GTK. Please do not send me to the GNOME documentation, I'm there to death will try a bunch of stuff. If there is an example and do not feel sorry to lay out, be kind. If there is an example on C \ C ++, it will also сome in handy.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by Munair »

You could try to find a C example via Google.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by D.J.Peters »

No comment ;-)

Code: Select all

#include once "fltk-c.bi"

function HandleCB cdecl (byval self as any ptr,byval event as FL_EVENT) as long
  static as integer ActiveDND=0
  select case as const event
  case FL_EVENT_DND_ENTER   : ActiveDND=1 : return 1
  case FL_EVENT_DND_LEAVE   : ActiveDND=0 : return 1
  case FL_EVENT_DND_DRAG , FL_EVENT_DND_RELEASE : return 1
  case FL_EVENT_PASTE
    if ActiveDND then
      beep
      print *Fl_EventText() : ActiveDND=0 : return 1
    end if
  end select
  return Fl_WindowExHandleBase(self,event)
end function
'
' main
'
var win = Fl_WindowExNew(640,480,"Drag file[s] over the window !")
Fl_WindowExSetHandleCB win,@HandleCB
Fl_WindowShow win
Fl_Run
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by Munair »

D.J.Peters wrote:No comment ;-)

Code: Select all

#include once "fltk-c.bi"

function HandleCB cdecl (byval self as any ptr,byval event as FL_EVENT) as long
  static as integer ActiveDND=0
  select case as const event
  case FL_EVENT_DND_ENTER   : ActiveDND=1 : return 1
  case FL_EVENT_DND_LEAVE   : ActiveDND=0 : return 1
  case FL_EVENT_DND_DRAG , FL_EVENT_DND_RELEASE : return 1
  case FL_EVENT_PASTE
    if ActiveDND then
      beep
      print *Fl_EventText() : ActiveDND=0 : return 1
    end if
  end select
  return Fl_WindowExHandleBase(self,event)
end function
'
' main
'
var win = Fl_WindowExNew(640,480,"Drag file[s] over the window !")
Fl_WindowExSetHandleCB win,@HandleCB
Fl_WindowShow win
Fl_Run
The OP said GTK.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by D.J.Peters »

Munair wrote:The OP said GTK.
I know but I show him how easy FLTK-c can be ;-)

every FLTK widget can receive files via drag and drop.
every FLTK widget can use the clipboard
every FLTK widget can use the printer
every FLTK widget can ...

Joshy
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by Munair »

While developing a GTK interface, I found some positive reviews here regarding FLTK which got me curious. So I tried to install it. But I cannot get it to work. See this thread: viewtopic.php?f=14&p=239001#p239001
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GTK Example Drag&DROP files in the window?

Post by TJF »

VANYA wrote:Hi All!

Does anyone have an example DRAG&DROP files in to program? Only interested in examples of using GTK. Please do not send me to the GNOME documentation, I'm there to death will try a bunch of stuff. If there is an example and do not feel sorry to lay out, be kind. If there is an example on C \ C ++, it will also сome in handy.
I posted an example years ago here:

Drag & Drop

Minor adaptations to the target_list should make it work with files as well.
Post Reply