GTK Example Drag&DROP files in the window?

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

GTK Example Drag&DROP files in the window?

Postby VANYA » Aug 20, 2017 7:29

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: 782
Joined: Oct 19, 2017 15:00
Location: 't Zand, NL
Contact:

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

Postby Munair » Nov 08, 2017 21:56

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

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

Postby D.J.Peters » Nov 09, 2017 0:08

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: 782
Joined: Oct 19, 2017 15:00
Location: 't Zand, NL
Contact:

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

Postby Munair » Nov 09, 2017 6:38

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: 7478
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Nov 09, 2017 8:25

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: 782
Joined: Oct 19, 2017 15:00
Location: 't Zand, NL
Contact:

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

Postby Munair » Nov 09, 2017 9:21

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: 3369
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

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

Postby TJF » Feb 11, 2018 15:49

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.

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 3 guests