/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     Internet Radio Automation & Encoding Toolkit
#+
#+     Copyright (C) 2018, 2019, 2020, 2021 by Kevin C. O'Kane
#+
#+     Kevin C. O'Kane
#+     kc.okane@gmail.com
#+     https://www.cs.uni.edu/~okane
#+     https://threadsafebooks.com/
#+
#+ 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//	April 20, 2021

#include "includes.h"
#include "common-externs.h"

#define SLASH '/'

//--------------------------------------------------------------
//      on_p22_button_press_event on_p23_button_press_event
//      on_p24_button_press_event on_p25_button_press_event
//--------------------------------------------------------------

#define ALT_P_BUTTON_PRESS(NBR) \
        gboolean on_p## NBR ##_button_press_event \
                (GtkButton *btn, GdkEventButton *event, gpointer user_data) {  \
                if (event->state == GDK_CONTROL_MASK)  \
                        if (drag_source == -1) \
                                { gtkSetCursor(GDK_HAND1); drag_source =  SP->begin + NBR - 22;  return TRUE; }  \
                        else { drag_target = SP->begin + NBR - 22; gtkSetCursor(GDK_TOP_LEFT_ARROW); \
                                on_p## NBR ##_drag_end (GTK_WIDGET(btn), NULL); return TRUE; } \
                drag_source = drag_target = -1; gtkSetCursor(GDK_TOP_LEFT_ARROW); \
                if (event->button == 1 ) return FALSE; /* left click */  \
                Message(mediaProbe(SP->Xbegin + NBR - 22)); \
                return TRUE; \
                }

ALT_P_BUTTON_PRESS(22) ALT_P_BUTTON_PRESS(23) ALT_P_BUTTON_PRESS(24) ALT_P_BUTTON_PRESS(25)


//----------------------------------------------------------------------------------------
//      on_p22_scroll_event  on_p23_scroll_event on_p24_scroll_event on_p25_scroll_event
//----------------------------------------------------------------------------------------

#define ALT_P_BUTTON_SCROLL(NBR) \
        gboolean on_p## NBR ##_scroll_event(GtkEntry *b, GdkEventScroll *e) { \
                return scroll_event2(e, 4); }

ALT_P_BUTTON_SCROLL(22) ALT_P_BUTTON_SCROLL(23) ALT_P_BUTTON_SCROLL(24) ALT_P_BUTTON_SCROLL(25)


//---------------------------------------------------------------------
//      on_p22_clicked on_p23_clicked on_p24_clicked on_p25_clicked
//---------------------------------------------------------------------

#define P_ALT_CLICKED(NBR1,FILE_NAME) \
        void on_p## NBR1 ##_clicked(GtkButton *b) { \
               moveToTop(FILE_NAME); updateTimes(); \
                }

P_ALT_CLICKED(22, SP->Xbegin+0) P_ALT_CLICKED(23,SP->Xbegin+1)
P_ALT_CLICKED(24,SP->Xbegin+2)  P_ALT_CLICKED(25,SP->Xbegin+3)

