/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     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 18, 2021

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

#define SLASH '/'

//--------------- COPY CLIPBOARD signals program list rows

//---------------------------------------------------------------------------------------------------------------
//      on_entry2_copy_clipboard  on_entry3_copy_clipboard on_entry4_copy_clipboard   on_entry7_copy_clipboard
//      on_entry8_copy_clipboard  on_entry9_copy_clipboard on_entry10_copy_clipboard  on_entry11_copy_clipboard
//      on_entry12_copy_clipboard on_entry13_copy_clipboard on_entry14_copy_clipboard on_entry15_copy_clipboard
//---------------------------------------------------------------------------------------------------------------

#define ENTRY_COPY_CLIPBOARD(NBR) \
        void on_entry## NBR ##_copy_clipboard(GtkEntry  *e) { \
        copyClipRow=e## NBR ##Row; }

ENTRY_COPY_CLIPBOARD(2)  ENTRY_COPY_CLIPBOARD(3)  ENTRY_COPY_CLIPBOARD(4)
ENTRY_COPY_CLIPBOARD(7)  ENTRY_COPY_CLIPBOARD(8)  ENTRY_COPY_CLIPBOARD(9)
ENTRY_COPY_CLIPBOARD(10) ENTRY_COPY_CLIPBOARD(11) ENTRY_COPY_CLIPBOARD(12)
ENTRY_COPY_CLIPBOARD(13) ENTRY_COPY_CLIPBOARD(14) ENTRY_COPY_CLIPBOARD(15)

//---------------------------------------------
//---------------------------------------------
//	INSERT TEXT into an entry box signals
//---------------------------------------------
//---------------------------------------------

//-------------------------------------------------------------------------------
//      on_entry1_insert_text    on_entry3_insert_text
//      on_entry4_insert_text  on_entry2_insert_text  on_entry7_insert_text
//      on_entry8_insert_text  on_entry9_insert_text  on_entry10_insert_text
//      on_entry11_insert_text on_entry12_insert_text on_entry13_insert_text
//      on_entry14_insert_text on_entry15_insert_text
//-------------------------------------------------------------------------------


//------------------------
//	Linux version
//------------------------

#define ENTRY_INSERT(NBR) \
        void on_entry## NBR ##_insert_text(GtkEditable  *entry, gchar *edit) { \
        int i = gtk_entry_get_text_length (GTK_ENTRY(entry)); \
        if (i>STR_MAX) { Message("Entry Error"); return; } \
        entry_insert(entry,edit); }

ENTRY_INSERT(1)  // top row - Linux only


ENTRY_INSERT(3)  ENTRY_INSERT(4)  ENTRY_INSERT(2)
ENTRY_INSERT(7)  ENTRY_INSERT(8)  ENTRY_INSERT(9)
ENTRY_INSERT(10) ENTRY_INSERT(11) ENTRY_INSERT(12)
ENTRY_INSERT(13) ENTRY_INSERT(14) ENTRY_INSERT(15)

//---------------------------------------------------------------------
//---------------------------------------------------------------------


#define ENTRY_TOP_CHANGED(NBR) \
        void on_entry## NBR ##_changed(GtkEntry  *entry, gchar *preedit, gpointer user_data) { \
        int i = gtk_entry_get_text_length (entry); \
        if (i>STR_MAX) { Message("Entry Error"); \
                gtk_editable_delete_text (GTK_EDITABLE(entry), 0, -1 ); \
                return; } \
        entry_changed(entry, preedit, user_data, 0); }

//----------------------------------------------
//----------------------------------------------
//	ENTRY CHANGED signals program list rows
//----------------------------------------------
//----------------------------------------------

//-----------------------------------------------------------------------------------
//      on_entry2_changed  on_entry3_changed on_entry4_changed   on_entry7_changed
//      on_entry8_changed  on_entry9_changed on_entry10_changed  on_entry11_changed
//      on_entry12_changed on_entry13_changed on_entry14_changed on_entry15_changed
//-----------------------------------------------------------------------------------


//----------------------
//	Linux version
//----------------------

#define ENTRY_CHANGED(NBR) \
        void on_entry## NBR ##_changed(GtkEntry  *entry, gchar *preedit, \
                gpointer user_data, GtkButton *b) { \
        entry_changed1(entry, preedit, user_data, e## NBR ##Row); }


ENTRY_CHANGED(2)  ENTRY_CHANGED(3)  ENTRY_CHANGED(4)
ENTRY_CHANGED(7)  ENTRY_CHANGED(8)  ENTRY_CHANGED(9)
ENTRY_CHANGED(10) ENTRY_CHANGED(11) ENTRY_CHANGED(12)
ENTRY_CHANGED(13) ENTRY_CHANGED(14) ENTRY_CHANGED(15)


//--------------- ENTRY BUTTON PRESSED EVENT signals

//      on_entry2_button_press_event  on_entry3_button_press_event
//      on_entry4_button_press_event   on_entry7_button_press_event
//      on_entry8_button_press_event  on_entry9_button_press_event
//      on_entry10_button_press_event  on_entry11_button_press_event
//      on_entry12_button_press_event on_entry13_button_press_event
//      on_entry14_button_press_event on_entry15_button_press_event
//------------------------------------------------------------------------------


//---------------------
//	Linux version
//---------------------

#define ENTRY_BUTTON_PRESS_EVENT(NBR) \
        void on_entry## NBR ##_button_press_event(GtkEntry  *entry, GdkEventButton *event) { \
                gtk_editable_select_region (GTK_EDITABLE(entry), 0, -1); \
                }

ENTRY_BUTTON_PRESS_EVENT(1)

ENTRY_BUTTON_PRESS_EVENT(7)  ENTRY_BUTTON_PRESS_EVENT(8)  ENTRY_BUTTON_PRESS_EVENT(9)
ENTRY_BUTTON_PRESS_EVENT(10) ENTRY_BUTTON_PRESS_EVENT(11) ENTRY_BUTTON_PRESS_EVENT(12)
ENTRY_BUTTON_PRESS_EVENT(13) ENTRY_BUTTON_PRESS_EVENT(14) ENTRY_BUTTON_PRESS_EVENT(2)
ENTRY_BUTTON_PRESS_EVENT(3)  ENTRY_BUTTON_PRESS_EVENT(4)  ENTRY_BUTTON_PRESS_EVENT(15)

//--------------- CUT CLIPBOARD signals program list rows

//----------------------------------------------------------------
//      on_entry2_cut_clipboard  on_entry3_cut_clipboard
//      on_entry4_cut_clipboard   on_entry7_cut_clipboard
//      on_entry8_cut_clipboard  on_entry9_cut_clipboard
//      on_entry10_cut_clipboard  on_entry11_cut_clipboard
//      on_entry12_cut_clipboard on_entry13_cut_clipboard
//      on_entry14_cut_clipboard on_entry15_cut_clipboard
//----------------------------------------------------------------

//---------------------
//	Linux version
//---------------------

#define ENTRY_CUT_CLIPBOARD(NBR) \
        void on_entry## NBR ##_cut_clipboard(GtkEntry  *b) { \
                strcpy(cutRow, ProgramArray[e## NBR ##Row]); \
                cutPlay = programData[e## NBR ##Row]->play; \
                cutPlayed = programPlayed[e## NBR ##Row]; \
                delRow(e## NBR ##Row); \
                DisplayProgramButtons(); \
                }

ENTRY_CUT_CLIPBOARD(2)  ENTRY_CUT_CLIPBOARD(3)  ENTRY_CUT_CLIPBOARD(4)
ENTRY_CUT_CLIPBOARD(7)  ENTRY_CUT_CLIPBOARD(8)  ENTRY_CUT_CLIPBOARD(9)
ENTRY_CUT_CLIPBOARD(10) ENTRY_CUT_CLIPBOARD(11) ENTRY_CUT_CLIPBOARD(12)
ENTRY_CUT_CLIPBOARD(13) ENTRY_CUT_CLIPBOARD(14) ENTRY_CUT_CLIPBOARD(15)


//--------------- PASTE CLIPBOARD signals program list rows

//-------------------------------------------------------------------------------------------
//      on_entry2_paste_clipboard  on_entry3_paste_clipboard on_entry4_paste_clipboard
//      on_entry7_paste_clipboard
//      on_entry8_paste_clipboard  on_entry9_paste_clipboard on_entry10_paste_clipboard
//      on_entry11_paste_clipboard
//      on_entry12_paste_clipboard on_entry13_paste_clipboard on_entry14_paste_clipboard
//      on_entry15_paste_clipboard
//-------------------------------------------------------------------------------------------

//--------------------
//	Linux version
//--------------------

#define ENTRY_PASTE_CLIPBOARD(NBR) \
        void on_entry## NBR ##_paste_clipboard(GtkEntry  *b) { paste( &e## NBR ##Row ); }


ENTRY_PASTE_CLIPBOARD(2)  ENTRY_PASTE_CLIPBOARD(3)  ENTRY_PASTE_CLIPBOARD(4)
ENTRY_PASTE_CLIPBOARD(7)  ENTRY_PASTE_CLIPBOARD(8)  ENTRY_PASTE_CLIPBOARD(9)
ENTRY_PASTE_CLIPBOARD(10) ENTRY_PASTE_CLIPBOARD(11) ENTRY_PASTE_CLIPBOARD(12)
ENTRY_PASTE_CLIPBOARD(13) ENTRY_PASTE_CLIPBOARD(14) ENTRY_PASTE_CLIPBOARD(15)
