Logo Search packages:      
Sourcecode: xcfa version File versions

split.c

/*
 * file      : split.c
 * project   : xcfa
 * with      : Gtk-2
 *
 * copyright : (C) 2003,2004,2005,2006,2007,2008,2009 by Claude Bulin
 *
 * xcfa - GTK+ implementation of the GNU shell command
 * GNU General Public License
 *
 * 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
 * OLD ADRESS:
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * NEW ADRESS:
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
#include <stdlib.h>

#include "support.h"
#include "global.h"
#include "config_user.h"
#include "fileselect.h"
#include "utils.h"
#include "options.h"
#include "file.h"
#include "dragNdrop.h"
#include "prg_init.h"
#include "split.h"
#include "gtkmarkscale.h"
#include "jogshuttle.h"
#include "player.h"
#include "win_info.h"



/*
*---------------------------------------------------------------------------
* VARIABLES
*---------------------------------------------------------------------------
*/

extern gint        n_drag_types;                /* Drag And Drop  */
VAR_SPLIT          VarSplit;              /* Declaration          */
VAR_SPLIT_ALLOC         *VarSplitAlloc = NULL;        /* Declaration          */

gdouble                 OldValueMarkA = 0.0;          /**/
gdouble                 OldValue = 0.0;               /**/
gdouble                 OldValueMarkB = 0.0;          /**/

gdouble                 CopyAdrValueMarkA;            /* Spin-Memory debut    */
gdouble                 CopyAdrValueMarkB;            /* Spin-Memory fin      */

/*
*---------------------------------------------------------------------------
* VARIABLES SPLIT DECOUPE
*---------------------------------------------------------------------------
*/

enum
{
      SPLIT_DECOUPE_COUPE_A = 0,
      SPLIT_DECOUPE_COUPE_B,
      SPLIT_DECOUPE_NAME_FILE,
      SPLIT_DECOUPE_NAME_FILE_EDITABLE,
      SPLIT_DECOUPE_POINTER_STRUCT,
      SPLIT_DECOUPE_NUM_COLUMNS
};

typedef struct
{
      gchar       *CoupeA;    /* Debut                      */
      gchar       *CoupeB;    /* Fin                              */
      gchar       *Name;            /* Le nom du futur fichier en decoupe     */
      gboolean     NameEditable;    /* TRUE                             */
      gpointer     AdrStruct; /* Adresse: &DECOUPES_FIC_SPLIT           */

} ARTICLES_SPLIT_DECOUPE_FILE;

GArray *ArticlesSplitDecoupeFile = NULL;

/*
*---------------------------------------------------------------------------
* VARIABLES SPLIT
*---------------------------------------------------------------------------
*/

enum
{
      SPLIT_NBRCOUPE_FILE = 0,
      SPLIT_TYPE_FILE,
      SPLIT_DUREE_FILE,
      SPLIT_NAME_FILE,
      SPLIT_POINTER_STRUCT,
      SPLIT_NUM_COLUMNS
};
typedef struct
{
      gchar       *NbrCoupe;  /* Total fichiers en decoupes       */
      gchar       *Type;            /* wav, ogg ou mp3                  */
      gchar       *Time;            /* Duree                      */
      gchar       *Name;            /* Le nom du fichier                */
      gpointer     AdrDetail; /* Adresse: &DETAIL                 */

} ARTICLES_SPLIT_FILE;

GArray *ArticlesSplitFile = NULL;

gint split_get_SPLIT_POINTER_STRUCT (void)
{
      return (SPLIT_POINTER_STRUCT);
}
gint split_get_SPLIT_NBRCOUPE_FILE (void)
{
      return (SPLIT_NBRCOUPE_FILE);
}

/*
*---------------------------------------------------------------------------
* SPLIT DECOUPE
*---------------------------------------------------------------------------
*/
void split_update_nmr_alloc_in_glist (void);
guint split_get_temps_total (void);
void split_get_detail_percent (gdouble ValueMark, gint *H, gint *M, gint *S, gdouble *C);
void split_set_new_info (void);

gint CPT_ENTER_SELECTION_ROW_DECOUPE_SPLIT = 0;

/* Renvoie TRUE si au moins un element de decoupe existe
*/
gboolean split_decoupe_is_elements (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;

      if(detail != NULL && (FicSplit = detail->fic_split) != NULL) {
            if (FicSplit->ListDecoupes != NULL) return (TRUE);
      }

      return (FALSE);
}

/* Renvoie un pointeur different de NULL si une ligne est en selection
*/

DECOUPES_FIC_SPLIT *split_decoupe_get_first_line_is_selected (void)
{
      GtkTreeIter        iter;
      GtkTreeModel            *model = NULL;
      GList             *list = NULL;
      GtkTreePath       *path;
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = NULL;

      if (VarSplit.Adr_Details_Tree_Model == NULL) return (NULL);
      if (VarSplit.Adr_Details_TreeView == NULL) return (NULL);
      if (VarSplit.Adr_Details_Line_Selected == NULL) return (NULL);

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_Details_TreeView));
      list = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Details_Line_Selected, &model));
      if (list) {
            if ((path = list->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &DecoupeFicSplit, -1);
            }
      }
      return ((DECOUPES_FIC_SPLIT *)DecoupeFicSplit);
}

void split_decoupe_set_value_DEBUT (gdouble ValueMarkA)
{
      GtkTreeIter        iter;
      GtkTreeModel            *model = NULL;
      GList             *list = NULL;
      GList             *LIST = NULL;
      GtkTreePath       *path;
      gchar             *Mess = NULL;
      /*DECOUPES_FIC_SPLIT    *SplitDetails = NULL;*/

      if (VarSplit.Adr_Details_Tree_Model == NULL) return;
      if (VarSplit.Adr_Details_TreeView == NULL) return;
      if (VarSplit.Adr_Details_Line_Selected == NULL) return;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_Details_TreeView));
      if ((LIST = gtk_tree_selection_get_selected_rows (VarSplit.Adr_Details_Line_Selected, &model))) {
            list = g_list_first (LIST);
            if ((path = list->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  Mess = split_get_label_mark_A (ValueMarkA, 0);
                  gtk_list_store_set (GTK_LIST_STORE (VarSplit.Adr_Details_Tree_Model),
                                    &iter,
                                    SPLIT_DECOUPE_COUPE_A,
                                    Mess,
                                    -1);
                  /*gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DETAILS_POINTER_STRUCT, &SplitDetails, -1);
                  g_free (SplitDetails->CoupeA);
                  SplitDetails->CoupeA = NULL;
                  SplitDetails->CoupeA = g_strdup (Mess);*/
                  g_free (Mess);
                  Mess = NULL;
            }
      }
}
void split_decoupe_set_value_FIN (gdouble ValueMarkB)
{
      GtkTreeIter        iter;
      GtkTreeModel            *model = NULL;
      GList             *list = NULL;
      GList             *LIST = NULL;
      GtkTreePath       *path;
      gchar             *Mess = NULL;
      /*DECOUPES_FIC_SPLIT    *SplitDetails = NULL;*/

      if (VarSplit.Adr_Details_Tree_Model == NULL) return;
      if (VarSplit.Adr_Details_TreeView == NULL) return;
      if (VarSplit.Adr_Details_Line_Selected == NULL) return;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_Details_TreeView));
      if ((LIST = gtk_tree_selection_get_selected_rows (VarSplit.Adr_Details_Line_Selected, &model))) {
            list = g_list_first (LIST);
            if ((path = list->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  Mess = split_get_label_mark_B (ValueMarkB, 0);
                  gtk_list_store_set (GTK_LIST_STORE (VarSplit.Adr_Details_Tree_Model),
                                    &iter,
                                    SPLIT_DECOUPE_COUPE_B,
                                    Mess,
                                    -1);
                  /*gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &SplitDetails, -1);
                  g_free (SplitDetails->CoupeB);
                  SplitDetails->CoupeB = NULL;
                  SplitDetails->CoupeB = g_strdup (Mess);*/
                  g_free (Mess);
                  Mess = NULL;
            }
      }
}

/* Si aucune ligne en selection, selection de de la premiere ligne
*/
void split_decoupe_set_selected_line (void)
{
      if (split_decoupe_get_first_line_is_selected () == NULL) {

            GtkTreeIter    iter;

            if (VarSplit.Adr_Details_Tree_Model == NULL) return;
            if (VarSplit.Adr_Details_TreeView == NULL) return;
            if (VarSplit.Adr_Details_Line_Selected == NULL) return;

            if (gtk_tree_model_get_iter_first (VarSplit.Adr_Details_Tree_Model, &iter)) {
                  gtk_tree_selection_select_iter (VarSplit.Adr_Details_Line_Selected, &iter);
            }
      }
}

/* Renvoie le numero [ 0 .. N ] de la ligne en selection
*/
gint split_decoupe_get_num_line_is_selected (void)
{
      gint               NumLine = 0;
      gboolean           valid;
      GtkTreeIter        iter;
      DECOUPES_FIC_SPLIT      *detail = NULL;
      DECOUPES_FIC_SPLIT      *DetailSelected = split_decoupe_get_first_line_is_selected ();

      if (split_get_ptr_ficsplit () == NULL) return ((gint)NumLine);
      if (DetailSelected == NULL) return ((gint)NumLine);

      valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Details_Tree_Model, &iter);
      while (valid) {
            gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &detail, -1);
            if (detail) {
                  if (DetailSelected == detail) return ((gint)NumLine);
                  NumLine ++;
            }
            valid = gtk_tree_model_iter_next (VarSplit.Adr_Details_Tree_Model, &iter);
      }
      return ((gint)NumLine);
}

/* Place en selection la ligne numero [ p_NumLine ]
*/
void split_decoupe_set_selected_num_line (gint p_NumLine)
{
      gint               NumLine = 0;
      gboolean           valid;
      GtkTreeIter        iter;
      GtkTreeIter        OLDIter;
      DECOUPES_FIC_SPLIT      *detail = NULL;

      if ((valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Details_Tree_Model, &iter)) == FALSE) return;
      while (valid) {
            gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &detail, -1);
            if (detail) {
                  OLDIter = iter;
                  if (NumLine == p_NumLine) break;
                  NumLine ++;
            }
            valid = gtk_tree_model_iter_next (VarSplit.Adr_Details_Tree_Model, &iter);
      }
      gtk_tree_selection_select_iter (VarSplit.Adr_Details_Line_Selected, &OLDIter);
}

void split_decoupe_save_line_selected (void)
{
      FIC_SPLIT   *FicSplit = split_get_ptr_ficsplit ();

      if (FicSplit != NULL) {
            FicSplit->NumLine = split_decoupe_get_num_line_is_selected ();
      }
}

void split_decoupe_restitue_line_selected (void)
{
      FIC_SPLIT   *FicSplit = split_get_ptr_ficsplit ();

      if (FicSplit != NULL) {
            split_decoupe_set_selected_num_line (FicSplit->NumLine);
      }
}
void split_decoupe_inc_line_selected (void)
{
      FIC_SPLIT   *FicSplit = split_get_ptr_ficsplit ();

      if (FicSplit != NULL) {
            FicSplit->NumLine ++;
      }
}

void split_decoupe_set_new_info (void)
{
      /*
      DECOUPES_FIC_SPLIT *split_decoupe_get_first_line_is_selected (void)
      */
      DETAIL                  *detail = split_get_first_line_is_selected ();
      FIC_SPLIT         *FicSplit = split_get_ptr_ficsplit ();
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = split_decoupe_get_first_line_is_selected ();

      if (VarSplit.SplitSelect != SPLIT_SELECT_IS_TACHE_AJOUTER &&
          VarSplit.SplitSelect != SPLIT_SELECT_IS_TACHE_MODIFIER) return;

      if (detail != NULL &&
          FicSplit != NULL &&
          DecoupeFicSplit != NULL &&
          (detail->type_infosong_file_is == FILE_IS_MP3 ||
           detail->type_infosong_file_is == FILE_IS_OGG ||
           detail->type_infosong_file_is == FILE_IS_WAV ||
           detail->type_infosong_file_is == FILE_IS_FLAC ||
           detail->type_infosong_file_is == FILE_IS_WAVPACK)) {

            VarSplit.AdrValue            = &DecoupeFicSplit->AdrValue;

            VarPlayer.PercentTempsActuel = *VarSplit.AdrValue;

            /*VarPlayer.GUINT_TempsTotal   = FicSplit->GUINT_TempsTotal;*/

            OldValueMarkA                = DecoupeFicSplit->AdrValueMarkA;
            OldValue                     = DecoupeFicSplit->AdrValue;
            OldValueMarkB                = DecoupeFicSplit->AdrValueMarkB;

            VarSplit.AdrValueMarkA       = &DecoupeFicSplit->AdrValueMarkA;
            VarSplit.AdrValueMarkB       = &DecoupeFicSplit->AdrValueMarkB;

            gtk_markscale_set_SecTime (VarPlayer.GUINT_TempsTotal);
            split_set_label_mark_A (*VarSplit.AdrValueMarkA);
            split_set_label_mark_B (*VarSplit.AdrValueMarkB);

            gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkA);
            gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkB);

            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), *VarSplit.AdrValue);
            split_hscale_from_split_change_value (*VarSplit.AdrValue);
            /*split_set_flag_buttons_audio ();*/
      }
      split_set_flag_buttons_audio ();
}

void split_decoupe_affiche_glist (void)
{
      GtkAdjustment                 *Adj = NULL;
      DETAIL                        *detail = NULL;
      GtkTreeIter              iter;
      gdouble                        AdjValue;
      FIC_SPLIT               *FicSplit = NULL;
      GList                   *ListDecoupes = NULL;
      GList                   *List = NULL;
      GList                   *BeginList = NULL;
      DECOUPES_FIC_SPLIT            *DecoupeFicSplit = NULL;
      ARTICLES_SPLIT_DECOUPE_FILE    Foo;
      GtkTreeModel                  *model = NULL;
      GtkTreePath             *path;

      gtk_list_store_clear (GTK_LIST_STORE (VarSplit.Adr_Details_List_Store));

      /* Reajustement de la liste */
      Adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (VarSplit.Adr_Details_scroll));
      AdjValue = gtk_adjustment_get_value (Adj);
      gtk_adjustment_set_value (Adj, AdjValue);
      gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (VarSplit.Adr_Details_scroll), Adj);

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);

                  if (detail == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((FicSplit = detail->fic_split) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((ListDecoupes = FicSplit->ListDecoupes) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }

                  List = g_list_first (ListDecoupes);
                  while (List) {
                        if ((DecoupeFicSplit = (DECOUPES_FIC_SPLIT *)List->data)) {

                              Foo.CoupeA         = g_strdup (split_get_label_mark_A (DecoupeFicSplit->AdrValueMarkA, FicSplit->GUINT_TempsTotal));
                              Foo.CoupeB         = g_strdup (split_get_label_mark_B (DecoupeFicSplit->AdrValueMarkB, FicSplit->GUINT_TempsTotal));
                              Foo.Name           = g_strdup (DecoupeFicSplit->Name);
                              Foo.NameEditable   = TRUE;
                              Foo.AdrStruct      = DecoupeFicSplit;

                              g_array_append_vals (ArticlesSplitDecoupeFile, &Foo, 1);
                              gtk_list_store_append (VarSplit.Adr_Details_List_Store, &iter);
                              gtk_list_store_set (VarSplit.Adr_Details_List_Store, &iter,
                                          SPLIT_DECOUPE_COUPE_A,              Foo.CoupeA,
                                          SPLIT_DECOUPE_COUPE_B,              Foo.CoupeB,
                                          SPLIT_DECOUPE_NAME_FILE,            Foo.Name,
                                          SPLIT_DECOUPE_NAME_FILE_EDITABLE,   Foo.NameEditable,
                                          SPLIT_DECOUPE_POINTER_STRUCT,       Foo.AdrStruct,
                                          -1);
                        }
                        List = g_list_next(List);
                  }
            }
            BeginList = g_list_next(BeginList);
      }

      /*split_decoupe_set_new_info ();*/
      split_update_nmr_alloc_in_glist ();
      if (VarSplit.SplitSelect == SPLIT_SELECT_IS_TACHE_AJOUTER ||
          VarSplit.SplitSelect == SPLIT_SELECT_IS_TACHE_MODIFIER)
            split_decoupe_restitue_line_selected ();
      split_set_flag_buttons_audio ();
}

static void split_decoupe_name_edited (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer data)
{
      GtkTreeModel            *model = (GtkTreeModel *)data;
      GtkTreePath       *path = gtk_tree_path_new_from_string (path_string);
      GtkTreeIter        iter;
      gint               column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = NULL;
      gchar             *NewStr = NULL;
      gchar             *Ptr = NULL;
      
      gtk_tree_model_get_iter (model, &iter, path);

      if (column == SPLIT_DECOUPE_NAME_FILE) {
            gint   Num_cell;
            gchar *old_text;
            ARTICLES_SPLIT_DECOUPE_FILE
                  *StructDetail = NULL;

            /* Suppression du caracteres '/' interdit si il existe */
            NewStr = g_strdup (new_text);
            if (strchr (NewStr, '/')) {
                  while ((Ptr = strchr (NewStr, '/'))) {
                        strcpy (Ptr, Ptr+1);
                  }
            }

            gtk_tree_model_get (model, &iter, SPLIT_DECOUPE_NAME_FILE, &old_text, -1);
            g_free (old_text);
            old_text = NULL;
            Num_cell = gtk_tree_path_get_indices (path)[0];
            g_free (g_array_index (ArticlesSplitDecoupeFile, ARTICLES_SPLIT_DECOUPE_FILE, Num_cell).Name);
            g_array_index (ArticlesSplitDecoupeFile, ARTICLES_SPLIT_DECOUPE_FILE, Num_cell).Name = NULL;
            g_array_index (ArticlesSplitDecoupeFile, ARTICLES_SPLIT_DECOUPE_FILE, Num_cell).Name = g_strdup (NewStr);

            gtk_tree_model_get (VarSplit.Adr_Details_Tree_Model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &StructDetail, -1);

            if (StructDetail && StructDetail->Name) {
                  g_free (StructDetail->Name);
                  StructDetail->Name = NULL;
                  StructDetail->Name = g_strdup (NewStr);
            }
            
            /* actualise le nom */
            gtk_list_store_set (GTK_LIST_STORE (model),
                              &iter,
                              SPLIT_DECOUPE_NAME_FILE,
                              g_array_index (ArticlesSplitDecoupeFile, ARTICLES_SPLIT_DECOUPE_FILE, Num_cell).Name,
                              -1);

            /* actualise le nom de la structure */
            gtk_tree_model_get (model, &iter, SPLIT_DECOUPE_POINTER_STRUCT, &DecoupeFicSplit, -1);
            if (DecoupeFicSplit != NULL) {
                  g_free (DecoupeFicSplit->Name);
                  DecoupeFicSplit->Name = NULL;
                  DecoupeFicSplit->Name = g_strdup (NewStr);
            
            }
            g_free (NewStr);
            NewStr = NULL;
      }
      gtk_tree_path_free (path);
}

void split_decoupe_changed_selection_row (GtkTreeSelection *selection, gpointer data)
{
      DECOUPES_FIC_SPLIT *DecoupeFicSplit = split_decoupe_get_first_line_is_selected ();

      VarSplit.Adr_Details_Line_Selected = selection;
      split_set_flag_buttons_audio ();

      if (DecoupeFicSplit == NULL) return;

      split_decoupe_set_new_info ();
      if (CPT_ENTER_SELECTION_ROW_DECOUPE_SPLIT == 2) {
            split_decoupe_save_line_selected ();
            CPT_ENTER_SELECTION_ROW_DECOUPE_SPLIT = 0;
      }
}

void split_set_option (SPLIT_SELECT SplitSelect)
{
      switch (VarSplit.SplitSelect) {
      case SPLIT_SELECT_IS_NONE :
      case SPLIT_SELECT_IS_FILE :
      gtk_label_set_text (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_button_ajouter_detail_split"))), _("Ajouter la tache "));
            break;
      case SPLIT_SELECT_IS_TACHE_MODIFIER :
      gtk_label_set_text (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_button_ajouter_detail_split"))), _("Modifier la tache"));
            break;
      case SPLIT_SELECT_IS_TACHE_AJOUTER :
      gtk_label_set_text (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_button_ajouter_detail_split"))), _("Ajouter la tache "));
            break;
      }
}

gboolean split_decoupe_event_click_mouse (GtkWidget *treeview, GdkEventButton *event, gpointer data)
{
      GtkTreePath       *path;
      GtkTreeViewColumn *column;
      gint               Pos_X = 0, Pos_Y = 0;

      /* Single clicks only */
      if (event->type != GDK_BUTTON_PRESS) return (FALSE);

      /* Si pas de selection a cet endroit retour */
      if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(treeview),
                                (gint)event->x, (gint)event->y,
                                 &path, &column, &Pos_X, &Pos_Y)) return (FALSE);
      CPT_ENTER_SELECTION_ROW_DECOUPE_SPLIT = 2;

      VarSplit.SplitSelect = SPLIT_SELECT_IS_TACHE_MODIFIER;
      split_set_option (VarSplit.SplitSelect);

      /*{
      gdouble value = gtk_markscale_get_value_A ();

      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value +0.1);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);

      VarPlayer.Button = GDK_BUTTON_RELEASE;

      VarPlayer.PercentTempsActuel = value;

      split_hscale_from_split_change_value (value);
      }*/
      return (FALSE);
}
void split_decoupe_del_from_file (void)
{
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = split_decoupe_get_first_line_is_selected ();
      DETAIL                  *detail = NULL;
      FIC_SPLIT         *FicSplit = NULL;
      GList             *List = NULL;
      GList             *freeglist = NULL;
      GtkTreeModel            *model = NULL;
      GList             *BeginList = NULL;
      GtkTreePath       *path;
      GtkTreeIter        iter;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);

                  if (detail == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if (DecoupeFicSplit == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }

                  List = g_list_first (FicSplit->ListDecoupes);
                  while (List) {
                        if (DecoupeFicSplit && DecoupeFicSplit == (DECOUPES_FIC_SPLIT *)List->data) {
                              /* COORDONNEES A SUPPRIMER POUR freeglist */
                              freeglist = List;
                              freeglist->data = NULL;
                              List = g_list_next (List);
                              /*  SUPPRESSION STRUCTURE DE LA LISTE */
                              g_free (DecoupeFicSplit->Name);
                              DecoupeFicSplit->Name = NULL;
                              g_free (DecoupeFicSplit);
                              DecoupeFicSplit = NULL;
                              /* SUPPRESSION  LISTE ACTUELLE DU GLIST */
                              FicSplit->ListDecoupes = g_list_remove_link (FicSplit->ListDecoupes, freeglist);

                              List = g_list_first (FicSplit->ListDecoupes);
                              break;
                        }
                        List = g_list_next (List);
                  }
            }
            BeginList = g_list_next(BeginList);
      }

      split_decoupe_set_new_info ();
      split_decoupe_affiche_glist ();
      split_update_nmr_alloc_in_glist ();

      VarSplit.SplitSelect = SPLIT_SELECT_IS_TACHE_AJOUTER;
      split_set_option (VarSplit.SplitSelect);
      split_set_new_info ();
}

void split_decoupe_button_del_file_clicked (void)
{
      if (split_decoupe_get_first_line_is_selected () == NULL) {
            return;
      }
      split_decoupe_del_from_file ();
}

void split_detail_button_nettoyer_tout_split_clicked (void)
{
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = NULL;
      DETAIL                  *detail = NULL;
      FIC_SPLIT         *FicSplit = NULL;
      GList             *List = NULL;
      GtkTreeModel            *model = NULL;
      GList             *BeginList = NULL;
      GtkTreePath       *path;
      GtkTreeIter        iter;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);

                  if (detail == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }

                  if ((List = g_list_first (FicSplit->ListDecoupes)) != NULL) {
                        while (List) {
                              if ((DecoupeFicSplit = (DECOUPES_FIC_SPLIT *)List->data) != NULL) {
                                    /*  SUPPRESSION STRUCTURE DE LA LISTE */
                                    g_free (DecoupeFicSplit->Name);
                                    DecoupeFicSplit->Name = NULL;
                                    g_free (DecoupeFicSplit);
                                    DecoupeFicSplit = NULL;
                                    List->data = NULL;
                              }
                              List = g_list_next (List);
                        }
                        g_list_free (FicSplit->ListDecoupes);
                        FicSplit->ListDecoupes = NULL;
                  }
            }
            BeginList = g_list_next(BeginList);
      }

      split_decoupe_set_new_info ();
      split_decoupe_affiche_glist ();
      split_update_nmr_alloc_in_glist ();

      VarSplit.SplitSelect = SPLIT_SELECT_IS_TACHE_AJOUTER;
      split_set_option (VarSplit.SplitSelect);
      split_set_new_info ();
}


void split_ctrl_file (gboolean BoolMarqueurDebut, gboolean BoolLeft)
{
      gdouble value = 0.0;

      if (BoolMarqueurDebut == TRUE)
            value = gtk_markscale_get_value_A ();
      else  value = gtk_markscale_get_value_B ();

      if (BoolLeft == TRUE)
            value -= 0.1;
      else  value += 0.1;
      if (value < 0.0) value = 0.0;
      if (value > 100.0) value = 100.0;

      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis)));
      split_hscale_from_split_change_value (value);

      if (BoolMarqueurDebut == TRUE)
            gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, value);
      else  gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, value);

      if (BoolMarqueurDebut == TRUE)
            *VarSplit.AdrValueMarkA = value;
      else  *VarSplit.AdrValueMarkB = value;

      if (BoolMarqueurDebut == TRUE)
            split_set_label_mark_A (value);
      else  split_set_label_mark_B (value);

      if (BoolMarqueurDebut == TRUE)
            split_copy_mark_A_split_clicked ();
      else  split_copy_mark_B_split_clicked ();
}

void split_action_key (SPLIT_SELECT SplitSelect)
{
      switch (VarSplit.SplitSelect) {
      
      case SPLIT_SELECT_IS_NONE :
            break;

      case SPLIT_SELECT_IS_FILE :         
            if (keys.BoolGDK_Control_L == TRUE) {
                  if (keys.BoolGDK_KP_Add || keys.BoolGDK_plus || keys.BoolGDK_Right) {
                        /*PRINT("MARQUEUR FICHIER GAUCHE PLUS");*/
                        split_ctrl_file (TRUE, FALSE);
                  }
                  else if (keys.BoolGDK_KP_Subtract || keys.BoolGDK_minus || keys.BoolGDK_Left) {
                        /*PRINT("MARQUEUR FICHIER GAUCHE MOINS");*/
                        split_ctrl_file (TRUE, TRUE);
                  }
            }
            else if (keys.BoolGDK_Control_R == TRUE) {
                  if (keys.BoolGDK_KP_Add || keys.BoolGDK_plus || keys.BoolGDK_Right) {
                        /*PRINT("MARQUEUR FICHIER DROITE PLUS");*/
                        split_ctrl_file (FALSE, FALSE);
                  }
                  else if (keys.BoolGDK_KP_Subtract || keys.BoolGDK_minus || keys.BoolGDK_Left) {
                        /*PRINT("MARQUEUR FICHIER DROITE MOINS");*/
                        split_ctrl_file (FALSE, TRUE);
                  }
            }
            break;

      case SPLIT_SELECT_IS_TACHE_MODIFIER :
            break;

      case SPLIT_SELECT_IS_TACHE_AJOUTER :
            if (keys.BoolGDK_Control_L == TRUE) {
                  if (keys.BoolGDK_KP_Add || keys.BoolGDK_plus || keys.BoolGDK_Right) {
                        /*PRINT("MARQUEUR TACHE GAUCHE PLUS");*/
                        split_ctrl_file (TRUE, FALSE);
                  }
                  else if (keys.BoolGDK_KP_Subtract || keys.BoolGDK_minus || keys.BoolGDK_Left) {
                        /*PRINT("MARQUEUR TACHE GAUCHE MOINS");*/
                        split_ctrl_file (TRUE, TRUE);
                  }
            }
            else if (keys.BoolGDK_Control_R == TRUE) {
                  if (keys.BoolGDK_KP_Add || keys.BoolGDK_plus || keys.BoolGDK_Right) {
                        /*PRINT("MARQUEUR TACHE DROITE PLUS");*/
                        split_ctrl_file (FALSE, FALSE);
                  }
                  else if (keys.BoolGDK_KP_Subtract || keys.BoolGDK_minus || keys.BoolGDK_Left) {
                        /*PRINT("MARQUEUR TACHE DROITE MOINS");*/
                        split_ctrl_file (FALSE, TRUE);
                  }
            }
            break;
      }
}

gboolean split_decoupe_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
      if (event->keyval == GDK_Delete) {
            if (split_decoupe_get_first_line_is_selected () != NULL) {
                  split_decoupe_button_del_file_clicked ();
                  return (FALSE);
            }
      }
      else {
            split_action_key (VarSplit.SplitSelect);
      }
      return (TRUE);
}

static void split_decoupe_add_columns_scrolledwindow (GtkTreeView *treeview)
{
      GtkTreeModel      *model = gtk_tree_view_get_model (treeview);
      GtkCellRenderer   *renderer;
      GtkTreeViewColumn *column;

      /* SIGNAL : Ligne actuellement selectionnee 'changed'
      */
      VarSplit.Adr_Details_Line_Selected = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
      g_signal_connect(G_OBJECT(VarSplit.Adr_Details_Line_Selected),
                   "changed",
                         G_CALLBACK(split_decoupe_changed_selection_row),
                         model);

      /* SIGNAL : 'button-press-event'
      */
      g_signal_connect(G_OBJECT(treeview),
                   "button-press-event",
                         (GCallback) split_decoupe_event_click_mouse,
                   model);

      /* SIGNAL 'key-press-event'
      */
      g_signal_connect(G_OBJECT(treeview),
                   "key-press-event",
                         (GCallback) split_decoupe_key_press_event,
                   model);

      /* SPLIT_DECOUPE_COUPE_A
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_DECOUPE_COUPE_A);
      VarSplit.Adr_ColumnSplitDetailsName =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("DEBUT"),
                                          renderer,
                                          "markup", SPLIT_DECOUPE_COUPE_A,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 95);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* SPLIT_DECOUPE_COUPE_B
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_DECOUPE_COUPE_B);
      VarSplit.Adr_ColumnSplitDetailsName =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("FIN"),
                                          renderer,
                                          "markup", SPLIT_DECOUPE_COUPE_B,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 95);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* SPLIT_DECOUPE_NAME_FILE
      *  SPLIT_DECOUPE_NAME_FILE_EDITABLE
      */
      VarSplit.rendererDetails =
      renderer = gtk_cell_renderer_text_new ();
      g_signal_connect (renderer, "edited", G_CALLBACK (split_decoupe_name_edited), model);
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_DECOUPE_NAME_FILE);
      VarSplit.Adr_ColumnSplitDetailsName =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("NOMS"),
                                          renderer,
                                          "markup", SPLIT_DECOUPE_NAME_FILE,
                                          "editable", SPLIT_DECOUPE_NAME_FILE_EDITABLE,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);
}
void split_decoupe_scrolledwindow_realize (GtkWidget *widget)
{
      GtkListStore *store;
      GtkTreeModel *model;
      GtkWidget    *treeview;

      VarSplit.SplitSelect = SPLIT_SELECT_IS_NONE;

      VarSplit.Adr_Details_scroll = widget;
      ArticlesSplitDecoupeFile = g_array_sized_new (FALSE, FALSE, sizeof (ARTICLES_SPLIT_DECOUPE_FILE), 1);
      VarSplit.Adr_Details_List_Store = store =
      gtk_list_store_new (    SPLIT_DECOUPE_NUM_COLUMNS,    /* SPLIT_DECOUPE_NUM_COLUMNS        */
                        G_TYPE_STRING,                /* SPLIT_DECOUPE_COUPE_A            */
                        G_TYPE_STRING,                /* SPLIT_DECOUPE_COUPE_B            */
                        G_TYPE_STRING,                /* SPLIT_DECOUPE_NAME_FILE          */
                        G_TYPE_BOOLEAN,               /* SPLIT_DECOUPE_NAME_FILE_EDITABLE */
                        G_TYPE_POINTER                /* SPLIT_DECOUPE_POINTER_STRUCT           */
                     );

      VarSplit.Adr_Details_Tree_Model = model = GTK_TREE_MODEL (store);

      /* creation de tree view
       */
      VarSplit.Adr_Details_TreeView =
      treeview = gtk_tree_view_new_with_model (model);
      gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
      gtk_tree_selection_set_mode (
            gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)), GTK_SELECTION_SINGLE);
      g_object_unref (model);
      gtk_container_add (GTK_CONTAINER (widget), treeview);
      split_decoupe_add_columns_scrolledwindow (GTK_TREE_VIEW (treeview));

      gtk_widget_show_all (widget);
}

/*
*---------------------------------------------------------------------------
* SPLIT FILE
*---------------------------------------------------------------------------
*/

GList *split_ajouter_decoupe_from_file (void)
{
      DETAIL                        *detail = NULL;
      FIC_SPLIT               *FicSplit = NULL;
      DECOUPES_FIC_SPLIT            *NewDecoupeFicSplit = NULL;
      gchar                   *Ptr = NULL;
      gchar                   *Name = NULL;
      GtkTreeModel                  *model = NULL;
      GList                   *BeginList = NULL;
      GtkTreePath             *path;
      GtkTreeIter              iter;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  
                  if (detail == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  NewDecoupeFicSplit = (DECOUPES_FIC_SPLIT *)g_malloc0 (sizeof (DECOUPES_FIC_SPLIT));

                  Ptr = strrchr (detail->namefile, '/');
                  Ptr ++;
                  Name = g_strdup (Ptr);
                  Ptr = strrchr (Name, '.');
                  *Ptr = '\0';
                  NewDecoupeFicSplit->Name          = g_strdup_printf ("%s + %d", Name, g_list_length (FicSplit->ListDecoupes) +1);
                  NewDecoupeFicSplit->AdrValueMarkA = FicSplit->AdrValueMarkA;
                  NewDecoupeFicSplit->AdrValue      = FicSplit->AdrValue;
                  NewDecoupeFicSplit->AdrValueMarkB = FicSplit->AdrValueMarkB;

                  FicSplit->ListDecoupes  = g_list_append (FicSplit->ListDecoupes, NewDecoupeFicSplit);

                  g_free (Name);
                  Name = NULL;
                  Ptr = NULL;
            }
            BeginList = g_list_next(BeginList);
      }

      return ((GList *)FicSplit->ListDecoupes);
}

void split_ajouter_decoupe_from_decoupe (void)
{
      DETAIL                        *detail = NULL;
      FIC_SPLIT               *FicSplit = NULL;
      DECOUPES_FIC_SPLIT            *NewDecoupeFicSplit = NULL;
      gchar                   *Ptr = NULL;
      gchar                   *Name = NULL;

      if ((detail = split_get_first_line_is_selected ()) == NULL) return;
      if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) return;
      NewDecoupeFicSplit = (DECOUPES_FIC_SPLIT *)g_malloc0 (sizeof (DECOUPES_FIC_SPLIT));

      Ptr = strrchr (detail->namefile, '/');
      Ptr ++;
      Name = g_strdup (Ptr);
      Ptr = strrchr (Name, '.');
      *Ptr = '\0';
      NewDecoupeFicSplit->Name          = g_strdup_printf ("%s + %d", Name, g_list_length (FicSplit->ListDecoupes) +1);
      NewDecoupeFicSplit->AdrValueMarkA = *VarSplit.AdrValueMarkA;
      NewDecoupeFicSplit->AdrValueMarkB = *VarSplit.AdrValueMarkB;

      FicSplit->ListDecoupes  = g_list_append (FicSplit->ListDecoupes, NewDecoupeFicSplit);

      g_free (Name);
      Name = NULL;
      Ptr = NULL;
}

void split_modifier_decoupe (void)
{
      DECOUPES_FIC_SPLIT      *DecoupeFicSplit = split_decoupe_get_first_line_is_selected ();

      if (DecoupeFicSplit != NULL) {
            DecoupeFicSplit->AdrValueMarkA = *VarSplit.AdrValueMarkA;
            DecoupeFicSplit->AdrValueMarkB = *VarSplit.AdrValueMarkB;
      }
}

void split_button_ajouter_decoupe_clicked (void)
{
      switch (VarSplit.SplitSelect) {
      case SPLIT_SELECT_IS_NONE :
            /* Tache is none */
            PRINT("Tache is none");
            break;
      case SPLIT_SELECT_IS_FILE :
            /* Ajouter la tache */
            PRINT("Ajouter la tache");
            split_ajouter_decoupe_from_file ();
            split_decoupe_affiche_glist ();
            break;
      case SPLIT_SELECT_IS_TACHE_MODIFIER :
            /* Modifier la tache */
            PRINT("Modifier la tache");
            split_modifier_decoupe ();
            split_decoupe_affiche_glist ();
            break;
      case SPLIT_SELECT_IS_TACHE_AJOUTER :
            /* Ajouter la tache */
            PRINT("Ajouter la tache");
            split_ajouter_decoupe_from_decoupe ();
            *VarSplit.AdrValueMarkA = OldValueMarkA;
            *VarSplit.AdrValue      = OldValue;
            *VarSplit.AdrValueMarkB = OldValueMarkB;
            split_decoupe_inc_line_selected ();
            split_decoupe_affiche_glist ();
            break;
      }
}

gint split_get_nbr_select_line (void)
{
      DETAIL                        *detail = NULL;
      FIC_SPLIT               *FicSplit = NULL;
      GtkTreeModel                  *model = NULL;
      GList                   *BeginList = NULL;
      GtkTreePath             *path;
      GtkTreeIter              iter;
      gint                     nbr_select_line = 0;
      
      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  if (detail != NULL && (FicSplit = (FIC_SPLIT *)detail->fic_split) != NULL) {
                        nbr_select_line ++;
                  }
            }
            BeginList = g_list_next(BeginList);
      }
      return (nbr_select_line);
}
/*
void split_set_Marks (void)
{
      DETAIL                        *detail = NULL;
      FIC_SPLIT               *FicSplit = NULL;
      GtkTreeModel                  *model = NULL;
      GList                   *BeginList = NULL;
      GtkTreePath             *path;
      GtkTreeIter              iter;
      
      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  if (detail != NULL && (FicSplit = (FIC_SPLIT *)detail->fic_split) != NULL) {
                        FicSplit->AdrValueMarkA = OldValueMarkA;
                        FicSplit->AdrValue      = OldValue;
                        FicSplit->AdrValueMarkB = OldValueMarkB;
                  }
            }
            BeginList = g_list_next(BeginList);
      }
}
*/
void split_set_new_info (void)
{
      DETAIL                  *detail = split_get_first_line_is_selected ();
      FIC_SPLIT         *FicSplit = split_get_ptr_ficsplit ();
      gint               H, M, S;
      gdouble                  C;

      if (VarSplit.SplitSelect != SPLIT_SELECT_IS_FILE) return;
      
      if (detail != NULL &&
          FicSplit != NULL &&
          (detail->type_infosong_file_is == FILE_IS_MP3 ||
           detail->type_infosong_file_is == FILE_IS_OGG ||
           detail->type_infosong_file_is == FILE_IS_WAV ||
           detail->type_infosong_file_is == FILE_IS_FLAC ||
           detail->type_infosong_file_is == FILE_IS_WAVPACK)) {

/*
if (split_get_nbr_select_line () > 1) {
      split_set_Marks ();
}
*/
            VarSplit.AdrValue            = &FicSplit->AdrValue;

            VarPlayer.PercentTempsActuel = *VarSplit.AdrValue;

            VarPlayer.DOUBLE_TempsTotal  = (gdouble)FicSplit->GUINT_TempsTotal;
            VarPlayer.GUINT_TempsTotal   = FicSplit->GUINT_TempsTotal;

            VarSplit.AdrValueMarkA       = &FicSplit->AdrValueMarkA;
            VarSplit.AdrValueMarkB       = &FicSplit->AdrValueMarkB;

            OldValueMarkA                = FicSplit->AdrValueMarkA;
            OldValue                     = FicSplit->AdrValue;
            OldValueMarkB                = FicSplit->AdrValueMarkB;

            gtk_markscale_set_SecTime (VarPlayer.GUINT_TempsTotal);
            split_set_label_mark_A (*VarSplit.AdrValueMarkA);
            split_set_label_mark_B (*VarSplit.AdrValueMarkB);

            gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkA);
            gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkB);

            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), *VarSplit.AdrValue);
            split_hscale_from_split_change_value (*VarSplit.AdrValue);
            split_set_flag_buttons_audio ();

            /*
            void gtk_spin_button_set_range (GtkSpinButton *spin_button, gdouble min, gdouble max);
            */
            split_get_detail_percent (100.0, &H, &M, &S, &C);
            /*
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonHeuresDebut, 0.0, (gdouble)H);
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonMinutesDebut, 0.0, (gdouble)M);
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonSecondesDebut, 0.0, (gdouble)S);
            */

            /*
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonHeuresFin, 0.0, (gdouble)H);
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonMinutesFin, 0.0, (gdouble)M);
            gtk_spin_button_set_range (VarSplit.AdrSpinbuttonSecondesFin, 0.0, (gdouble)S);
            */
      }
      split_set_flag_buttons_audio ();
}

FIC_SPLIT *split_get_ptr_ficsplit (void)
{
      DETAIL            *detail = NULL;

      if ((detail = split_get_first_line_is_selected ()) == NULL) return (NULL);
      return ((FIC_SPLIT *)detail->fic_split);
}
GList *split_get_glist_ficsplit (void)
{
      FIC_SPLIT *FicSplit = split_get_ptr_ficsplit ();

      if (FicSplit != NULL) return ((GList *)FicSplit->ListDecoupes);
      return ((GList *)NULL);
}

/* Renvoie un pointeur different de NULL si une ligne est en selection
*/
DETAIL *split_get_first_line_is_selected (void)
{
      GtkTreeIter       iter;
      GtkTreeModel     *model = NULL;
      GList            *list = NULL;
      GtkTreePath      *path;
      DETAIL           *detail = NULL;

      if (VarSplit.Adr_Tree_Model == NULL) return (NULL);
      if (VarSplit.Adr_TreeView == NULL) return (NULL);
      if (VarSplit.Adr_Line_Selected == NULL) return (NULL);

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      if ((list = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model))) != NULL) {
            if ((path = list->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
            }
      }
      return (detail);
}

/* Renvoie le numero [ 0 .. N ] de la ligne en selection
*/
gint split_get_num_line_is_selected (void)
{
      gint         NumLine = -1;
      DETAIL            *DetailSelected = NULL;

      if ((DetailSelected = split_get_first_line_is_selected ()) != NULL) {

            gboolean     valid;
            GtkTreeIter  iter;
            DETAIL            *detail = NULL;

            valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Tree_Model, &iter);
            while (valid) {
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  if (detail) {
                        NumLine ++;
                        if (DetailSelected == detail) return ((gint)NumLine);
                  }
                  valid = gtk_tree_model_iter_next (VarSplit.Adr_Tree_Model, &iter);
            }
      }
      return ((gint)NumLine);
}
/* Renvoie le numero [ 0 .. N ] de la ligne en selection
*/
gint split_get_num_all_line_is_selected (void)
{
      gint         NumLine = -1;
      DETAIL            *DetailSelected = NULL;

      if ((DetailSelected = split_get_first_line_is_selected ()) != NULL) {

            gboolean     valid;
            GtkTreeIter  iter;
            DETAIL            *detail = NULL;

            valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Tree_Model, &iter);
            while (valid) {
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  if (detail) {
                        NumLine ++;
                  }
                  valid = gtk_tree_model_iter_next (VarSplit.Adr_Tree_Model, &iter);
            }
      }
      return ((gint)NumLine);
}


/* Place en selection la ligne numero [ p_NumLine ]
*/
void split_set_selected_num_line (gint p_NumLine)
{
      gint         NumLine = 0;
      gboolean     valid;
      GtkTreeIter  iter;
      GtkTreeIter  OLDIter;
      DETAIL            *detail = NULL;
      gboolean     Bool = FALSE;

      gtk_tree_selection_unselect_all (VarSplit.Adr_Line_Selected);
      if ((valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Tree_Model, &iter)) == FALSE) return;
      while (valid) {
            gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
            if (detail) {
                  Bool = TRUE;
                  OLDIter = iter;
                  if (NumLine == p_NumLine) break;
                  NumLine ++;
            }
            valid = gtk_tree_model_iter_next (VarSplit.Adr_Tree_Model, &iter);
      }
      if (Bool == TRUE)
            gtk_tree_selection_select_iter (VarSplit.Adr_Line_Selected, &OLDIter);
}

void split_button_importer_split_clicked (void)
{
      fileselect_create (_PATH_IMPORT_FILE_SPLIT_MP3OGG_, NULL);
}
void split_hscale_from_split_change_value (gdouble value)
{
      gchar    *Mess = NULL;
      gint      sec;
      gdouble   dsec;
      gint      hundr;
      guint     TempsTotal = split_get_temps_total ();

      if (value < 0.0) value = 0.0;
      if (value > 100.0) value = 100;
      if (VarSplit.AdrValue == NULL) return;
      *VarSplit.AdrValue = value;
      VarPlayer.PercentTempsActuel = value;

      sec = (gint) (((gdouble)TempsTotal * value) / 100.0);
      dsec  = ((gdouble)TempsTotal * value) / 100.0;
      hundr = (dsec - (gdouble)sec) * 1000.0;
      if (hundr >= 1000) hundr = 999;

      if (PlayerExec_is_activate () == TRUE &&
          VarPlayer.Button == GDK_BUTTON_RELEASE &&
          VarPlayer.BoolPushButton != PUSH_BUTTON_PAUSE) {

            PlayerExec_fifo_seek_with_hundr (value);
            VarPlayer.Button = -1;
      }
      if (VarPlayer.Button == GDK_BUTTON_RELEASE) VarPlayer.Button = -1;

      if (sec < 0) sec = 0;
      if (hundr < 0) hundr = 0;
      Mess = g_strdup_printf ("%02d:%02d:%02d.%03d  ", (sec/60)/60, (sec/60)%60, sec%60, hundr);
      gtk_label_set_use_markup (GTK_LABEL (VarSplit.AdrLabelDepuis), TRUE);
      gtk_label_set_markup (GTK_LABEL (VarSplit.AdrLabelDepuis), Mess);
      g_free (Mess);
      Mess = NULL;
}
void split_with_mplayer (gdouble percent)
{
      if (VarPlayer.Button != GDK_BUTTON_PRESS) {
            split_hscale_from_split_change_value (percent);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), percent);
            Player_set_value_time (percent);
      }
}
void split_set_flag_buttons_audio (void)
{
      gboolean    BoolOk        = split_get_first_line_is_selected () != NULL ? TRUE : FALSE;
      gboolean    BoolDecoupeOk = split_decoupe_get_first_line_is_selected () != NULL ? TRUE : FALSE;
      gboolean    BoolElements  = split_decoupe_is_elements ();

      if (!BoolOk && !BoolDecoupeOk) {
            gtk_label_set_markup (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_selection_split"))), _("<b> Selection </b>"));
      }
      else if (BoolDecoupeOk) {
            gtk_label_set_markup (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_selection_split"))), _("<b> Selection tache </b>"));
      }
      else if (BoolOk) {
            gtk_label_set_markup (GTK_LABEL (GTK_WIDGET (lookup_widget (wind_main, "label_selection_split"))), _("<b> Selection fichier </b>"));
      }
      
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_importer_split")), TRUE);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "eventbox_combobox_dest_split")), TRUE);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_import_cue_split")), TRUE);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_nettoyer_detail_split")), BoolDecoupeOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_nettoyer_tout_detail_split")), BoolElements);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_remove_file_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_nettoyer_tout_split")), BoolOk);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "eventbox_hbox_from_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_set_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_set_mark_B_split")), BoolOk);


      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_goto_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "togglebutton_sync_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_heure_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_minute_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_secondes_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_coller_mark_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_goto_mark_B_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "togglebutton_sync_mark_B_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_heure_mark_B_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_minute_mark_B_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "spinbutton_secondes_mark_B_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_coller_mark_B_split")), BoolOk);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "eventbox_jogg")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_stop_lecture_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_lecture_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_debut_lecture_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_recule_lecture_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_avance_lecture_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_fin_lecture_split")), BoolOk);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_ajouter_detail_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_action_split")), BoolOk);

      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_set_mark_B_to_A_split")), BoolOk);
      gtk_widget_set_sensitive (GTK_WIDGET (lookup_widget (wind_main, "button_set_mark_B_to_A_SYNC_split")), BoolOk);
}

gint split_get_pos_struct (void)
{
      return (SPLIT_POINTER_STRUCT);
}
void split_set_combobox_dest (GtkWidget *widget)
{
      utils_clear_elements_combobox (widget);
      gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Conversion(s) vers la source"));
      gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Choix d'une nouvelle destination"));
      gtk_combo_box_append_text (GTK_COMBO_BOX (widget), Config_User.Path_Destination_split);
      gtk_combo_box_set_active (GTK_COMBO_BOX (widget), Config_User.Value_choice_split);
}
void split_combobox_dest_split_realize (GtkWidget *widget)
{
      split_set_combobox_dest (widget);
      VarSplit.AdrComboboxDest = GTK_COMBO_BOX (widget);
      VarSplit.DetailActif = NULL;
}
void split_import_file (gchar *path)
{
      if (options_verif_dossier_is_ok (path) == TRUE) {
            if (utils_test_write (path) == TRUE) {
                  g_free (Config_User.Path_Destination_split);
                  Config_User.Path_Destination_split = NULL;
                  Config_User.Path_Destination_split = g_strdup (path);

                  split_set_combobox_dest (GTK_WIDGET(VarSplit.AdrComboboxDest));

                  Config_User.Value_choice_split = 0;
                  gtk_combo_box_set_active (GTK_COMBO_BOX (VarSplit.AdrComboboxDest), Config_User.Value_choice_split);

                  Config_User.Value_choice_split = 2;
                  gtk_combo_box_set_active (GTK_COMBO_BOX (VarSplit.AdrComboboxDest), Config_User.Value_choice_split);
            }
      }
}
void split_combobox_dest_split_changed (void)
{
      if (VarSplit.AdrComboboxDest) {
            switch (gtk_combo_box_get_active (VarSplit.AdrComboboxDest)) {
            case 0 :
                  Config_User.Value_choice_split = 0;
                  break;
            case 1 :
                  gtk_combo_box_set_active (GTK_COMBO_BOX (VarSplit.AdrComboboxDest), Config_User.Value_choice_split);
                  fileselect_create (_PATH_DESTINATION_SPLIT_, split_import_file);
                  break;
            case 2 :
                  Config_User.Value_choice_split = 2;
                  break;
            }
      }
}

void split_changed_selection_row (GtkTreeSelection *selection, gpointer data)
{
      VarSplit.SplitSelect = SPLIT_SELECT_IS_FILE;
      split_set_option (VarSplit.SplitSelect);

      VarSplit.Adr_Line_Selected = selection;
      split_decoupe_affiche_glist ();
      split_set_new_info ();
      split_set_flag_buttons_audio ();
}

static void split_drag_data_received_file (GtkWidget     *widget,
                              GdkDragContext     *drag_context,
                              gint                x,
                              gint                y,
                              GtkSelectionData   *data,
                              guint               info,
                              guint               time)
{
      if (gtk_drag_get_source_widget(drag_context) != widget) {
            dragndrop_list_drag_data (widget, (gchar *)data->data);
      }
}

gboolean split_test_prg_extern (void)
{
      if (PrgInit.bool_mp3splt == FALSE && PrgInit.bool_mplayer == FALSE) {
            utils_puts_statusbar_global (_("mplayer + mp3splt NOT FOUND / ABSENT"));
            return (FALSE);
      }
      else if (PrgInit.bool_mp3splt == FALSE) {
            utils_puts_statusbar_global (_("mp3splt NOT FOUND / ABSENT"));
            return (FALSE);
      }
      else if (PrgInit.bool_mplayer == FALSE) {
            utils_puts_statusbar_global (_("mplayer NOT FOUND / ABSENT"));
            return (FALSE);
      }
      utils_puts_statusbar_global ("");
      return (TRUE);
}

static void split_drag_data_drop_file (GtkWidget *widget,
                              GdkDragContext *dc,
                              GtkSelectionData *selection_data,
                              guint info,
                              guint t,
                              gpointer data)
{
      GtkTreeIter       iter;
      GtkTreeModel     *model = NULL;
      GList            *begin_list = NULL;
      GList            *list = NULL;
      GtkTreePath      *path;
      DETAIL           *detail = NULL;
      gchar            *text = NULL;

      if (split_test_prg_extern () == FALSE) return;

      model = gtk_tree_view_get_model (GTK_TREE_VIEW(widget));
      begin_list = gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model);
      list = g_list_first (begin_list);
      while (list) {
            if ((path = list->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  if (detail == NULL) {
                        list = g_list_next (list);
                        continue;
                  }
                  text = g_strdup (detail->namefile);
                  gtk_selection_data_set (selection_data,
                                    GDK_SELECTION_TYPE_STRING,
                                    8,
                                    (const guchar *)text,
                                    strlen(text)
                                    );
                  g_free (text);
                  text = NULL;
            }
            list = g_list_next (list);
      }
}
gboolean split_file_event (GtkWidget *treeview, GdkEvent *event, gpointer user_data)
{
      return (FALSE);
}
gboolean split_event_click_mouse_file (GtkWidget *treeview, GdkEventButton *event, gpointer data)
{
      GtkTreePath       *path;
      GtkTreeViewColumn *column;
      gint               Pos_X = 0, Pos_Y = 0;

      /* Single clicks only */
      if (event->type != GDK_BUTTON_PRESS) return (FALSE);

      /* Si pas de selection a cet endroit retour */
      if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(treeview),
                                (gint)event->x, (gint)event->y,
                                 &path, &column, &Pos_X, &Pos_Y)) return (FALSE);

      split_decoupe_save_line_selected ();
      return (FALSE);
}

void split_button_remove_file_split_clicked (void)
{
      GtkTreeIter       iter;
      GtkTreeModel     *model = NULL;
      GList            *BeginList = NULL;
      GList            *list = NULL;
      GtkTreePath      *path;
      DETAIL           *detail = NULL;
      gint          NumLine;

      split_decoupe_del_from_file ();
      
      /* marque les structures a detruires dans le glist 'entefile' */
      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      if ((BeginList = gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model))) {
            list = g_list_first (BeginList);
            while (list) {
                  if ((path = list->data)) {
                        gtk_tree_model_get_iter (model, &iter, path);
                        gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                        /* Marquage */
                        if (detail) detail->remove = STRUCT_FIC_REMOVE_SPLIT;
                  }
                  list = g_list_next (list);
            }

            NumLine = split_get_num_line_is_selected ();
            fileanalyze_modify_glist_entetefile ();
            if (NumLine == -1) NumLine ++;
            split_set_selected_num_line (NumLine);
      }
}

void split_button_nettoyer_tout_split_clicked (void)
{
      gtk_tree_selection_select_all (VarSplit.Adr_Line_Selected);
      split_button_remove_file_split_clicked ();
}

gboolean split_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
      if (event->keyval == GDK_Delete) {
            if (split_get_first_line_is_selected () != NULL) {
                  split_button_remove_file_split_clicked ();
                  return (FALSE);
            }
      }
      else {
            split_action_key (VarSplit.SplitSelect);
      }
      return (TRUE);
}

/* Construction SPLIT
*/
static void split_add_columns_scrolledwindow_file (GtkTreeView *treeview)
{
      GtkTreeModel      *model = gtk_tree_view_get_model (treeview);
      GtkCellRenderer   *renderer;
      GtkTreeViewColumn *column;

      /* SIGNAL : Ligne actuellement selectionnee 'changed'
      */
      VarSplit.Adr_Line_Selected = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
      g_signal_connect(G_OBJECT(VarSplit.Adr_Line_Selected),
                   "changed",
                         G_CALLBACK(split_changed_selection_row),
                         model);

      /* SIGNAL : 'button-press-event'
      */
      g_signal_connect(G_OBJECT(treeview),
                   "button-press-event",
                         (GCallback) split_event_click_mouse_file,
                   model);

      /* SIGNAL 'key-press-event'
      */
      g_signal_connect(G_OBJECT(treeview),
                   "key-press-event",
                         (GCallback) split_key_press_event,
                   model);

      /* SIGNAL : 'event'
      */
      g_signal_connect(G_OBJECT(treeview),
                   "event",
                         (GCallback) split_file_event,
                   model);

      /* Drag and drop support
      *  SIGNAL : 'drag-data-received'
      */
      gtk_drag_dest_set (GTK_WIDGET (treeview),
                     GTK_DEST_DEFAULT_MOTION |
                     GTK_DEST_DEFAULT_DROP,
                     drag_types, n_drag_types,
                     GDK_ACTION_COPY| GDK_ACTION_MOVE );
      g_signal_connect(G_OBJECT(treeview),
                   "drag-data-received",
                   G_CALLBACK(split_drag_data_received_file),
                   NULL);

      gtk_drag_source_set(
                  GTK_WIDGET(treeview),
                  GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
                  drag_types, n_drag_types,
                  GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_DEFAULT
                  );

      g_signal_connect(G_OBJECT(treeview),
                        "drag-data-get",
                   G_CALLBACK(split_drag_data_drop_file),
                   treeview);

      /* SPLIT_NBRCOUPE_FILE
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_NBRCOUPE_FILE);
      VarSplit.Adr_ColumnSplitCoupes =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("FICHIERS"),
                                          renderer,
                                          "markup", SPLIT_NBRCOUPE_FILE,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 70);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* SPLIT_TYPE_FILE
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_TYPE_FILE);
      VarSplit.Adr_ColumnSplitType =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("TYPE"),
                                          renderer,
                                          "markup", SPLIT_TYPE_FILE,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 70);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* SPLIT_DUREE_FILE
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_DUREE_FILE);
      VarSplit.Adr_ColumnSplitTime =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("TEMPS"),
                                          renderer,
                                          "markup", SPLIT_DUREE_FILE,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 70);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* SPLIT_NAME_FILE
      */
      VarSplit.renderer =
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      g_object_set_data (G_OBJECT (renderer), "column", (gint *)SPLIT_NAME_FILE);
      VarSplit.Adr_ColumnSplitName =
      column = gtk_tree_view_column_new_with_attributes (
                                          _("NOM"),
                                          renderer,
                                          "markup", SPLIT_NAME_FILE,
                                          NULL
                                            );
      gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                           GTK_TREE_VIEW_COLUMN_FIXED);
      gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);
}
void split_scrolledwindow_file_split_realize (GtkWidget *widget)
{
      GtkListStore *store;
      GtkTreeModel *model;
      GtkWidget    *treeview;

      VarSplit.Adr_scroll = widget;
      ArticlesSplitFile = g_array_sized_new (FALSE, FALSE, sizeof (ARTICLES_SPLIT_FILE), 1);
      VarSplit.Adr_List_Store = store =
      gtk_list_store_new (    SPLIT_NUM_COLUMNS,      /* TOTAL NUMBER               */
                        G_TYPE_STRING,          /* SPLIT_NBRCOUPE_FILE        */
                        G_TYPE_STRING,          /* SPLIT_TYPE_FILE            */
                        G_TYPE_STRING,          /* SPLIT_DUREE_FILE           */
                        G_TYPE_STRING,          /* SPLIT_NAME_FILE            */
                        G_TYPE_POINTER          /* SPLIT_POINTER_STRUCT       */
                     );

      VarSplit.Adr_Tree_Model = model = GTK_TREE_MODEL (store);

      /* creation de tree view
       */
      VarSplit.Adr_TreeView =
      treeview = gtk_tree_view_new_with_model (model);
      gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
      gtk_tree_selection_set_mode (
            gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
            /*GTK_SELECTION_SINGLE*/
            GTK_SELECTION_MULTIPLE
            );
      g_object_unref (model);
      gtk_container_add (GTK_CONTAINER (widget), treeview);
      split_add_columns_scrolledwindow_file (GTK_TREE_VIEW (treeview));

      gtk_widget_show_all (widget);
}
void split_label_depuis_split_realize (GtkWidget *widget)
{
      VarSplit.AdrLabelDepuis = widget;
}
void on_hscale_from_split_realize (GtkWidget *widget, gpointer user_data)
{
      VarSplit.AdrHscaleFrom = widget;
}
gboolean on_hscale_from_split_change_value (GtkRange *range, GtkScrollType scroll, gdouble value, gpointer user_data)
{
      guint sec;
      guint TempsTotal = split_get_temps_total ();

      if (value < 0.0) value = 0.0;
      if (value > 100.0) value = 100.0;
      sec = ((gdouble)TempsTotal * value) / 100.0;

      split_hscale_from_split_change_value (value);
      return FALSE;
}
gboolean split_event (GtkWidget *treeview, GdkEvent *event, gpointer user_data)
{
      if (event->type == GDK_BUTTON_PRESS) {
            VarPlayer.Button = GDK_BUTTON_PRESS;
      }
      if (event->type == GDK_BUTTON_RELEASE) {
            VarPlayer.Button = GDK_BUTTON_RELEASE;
      }

      return (FALSE);
}
void split_hbox_from_split_realize (GtkWidget *widget)
{
      VarSplit.AdrAdjustDepuis = gtk_adjustment_new (0, 0, 100.0, 0.001, 1, 0);
      VarSplit.AdrHscaleFromSplit = gtk_markscale_new (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));
      gtk_widget_show (VarSplit.AdrHscaleFromSplit);
      gtk_scale_set_draw_value (GTK_SCALE (VarSplit.AdrHscaleFromSplit), FALSE);
      gtk_box_pack_start (GTK_BOX (widget), VarSplit.AdrHscaleFromSplit, TRUE, TRUE, 0);

      GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
      gtk_scale_set_value_pos (GTK_SCALE (VarSplit.AdrHscaleFromSplit), GTK_POS_LEFT);

      g_signal_connect ((gpointer) VarSplit.AdrHscaleFromSplit, "realize", G_CALLBACK (on_hscale_from_split_realize), NULL);
      g_signal_connect ((gpointer) VarSplit.AdrHscaleFromSplit, "change_value", G_CALLBACK (on_hscale_from_split_change_value), NULL);
      g_signal_connect ((gpointer) VarSplit.AdrHscaleFromSplit, "event",G_CALLBACK (split_event), NULL);
}

/* AFFICHAGE
*/
gboolean split_is_dupply (gchar *namefile)
{
      GtkTreeIter    iter;
      DETAIL        *detail = NULL;
      gboolean       valid;

      if (VarSplit.Adr_Tree_Model == NULL) return (FALSE);

      valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Tree_Model, &iter);
      while (valid) {
            gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
            if (detail) {
                  if (strcmp (namefile, detail->namefile) == 0) return (TRUE);
            }
            valid = gtk_tree_model_iter_next (VarSplit.Adr_Tree_Model, &iter);
      }
      return (FALSE);
}

void split_affiche_glist (void)
{
      GtkAdjustment           *Adj = NULL;
      DETAIL                  *detail = NULL;
      FIC_SPLIT         *FicSplit = NULL;
      FIC_MP3OGG        *FicMp3Ogg = NULL;
      FIC_WAV                 *FicWav = NULL;
      FIC               *Fic = NULL;
      GList             *list = NULL;
      ARTICLES_SPLIT_FILE      Foo;
      GtkTreeIter        iter;
      gdouble                  AdjValue;
      gint               NumLine;

      NumLine = split_get_num_all_line_is_selected ();

      gtk_list_store_clear (GTK_LIST_STORE (VarSplit.Adr_List_Store));

      /* Reajustement de la liste */
      Adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (VarSplit.Adr_scroll));
      AdjValue = gtk_adjustment_get_value (Adj);
      gtk_adjustment_set_value (Adj, AdjValue);
      gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (VarSplit.Adr_scroll), Adj);

      list = g_list_first (entetefile);
      while (list) {
            if (!(detail = (DETAIL *)list->data)) {
                  list = g_list_next(list);
                  continue;
            }

            switch (detail->choice_treeview) {
            case _TREEVIEW_ALL_ :
                  list = g_list_next(list);
                  continue;
                  break;
            case _TREEVIEW_SPLIT_ :
            case _TREEVIEW_SPLIT_ALL_ :
                  break;
            }

            FicSplit  = (FIC_SPLIT *)detail->fic_split;
            FicMp3Ogg = (FIC_MP3OGG *)detail->fic_mp3ogg;
            FicWav    = (FIC_WAV *)detail->fic_wav;
            Fic       = (FIC *)detail->fic;

            if (Fic == NULL && FicWav == NULL && FicMp3Ogg == NULL) {
                  list = g_list_next(list);
                  continue;
            }
            if (FicSplit == NULL) {
                  list = g_list_next(list);
                  continue;
            }
            if (split_is_dupply (detail->namefile) == TRUE) {
                  list = g_list_next(list);
                  continue;
            }

            Foo.NbrCoupe    = g_strdup ("0");
            Foo.Type        = g_strdup_printf ("%s%s", detail->BoolCueFile == TRUE ? "Cue/" : "",  infosong_get_str_type_file_is (detail->type_infosong_file_is));
            /*Foo.Type        = g_strdup (infosong_get_str_type_file_is (detail->type_infosong_file_is));*/
            Foo.Time        = g_strdup (file_get_time_file (detail));
            Foo.Name        = fileanalyze_get_name_without_path_ext (detail->namefile, FALSE);
            Foo.AdrDetail   = detail;

            g_array_append_vals (ArticlesSplitFile, &Foo, 1);
            gtk_list_store_append (VarSplit.Adr_List_Store, &iter);
            gtk_list_store_set (VarSplit.Adr_List_Store, &iter,
                        SPLIT_NBRCOUPE_FILE,          Foo.NbrCoupe,
                        SPLIT_TYPE_FILE,        Foo.Type,
                        SPLIT_DUREE_FILE,       Foo.Time,
                        SPLIT_NAME_FILE,        Foo.Name,
                        SPLIT_POINTER_STRUCT,         Foo.AdrDetail,
                        -1);
            list = g_list_next(list);
      }
      split_set_new_info ();
      split_set_selected_num_line (NumLine +1);
      split_set_flag_buttons_audio ();
      split_update_nmr_alloc_in_glist ();
}

void split_update_nmr_alloc_in_glist (void)
{
      gboolean     valid;
      GtkTreeIter  iter;
      DETAIL            *detail = NULL;
      FIC_SPLIT   *FicSplit = NULL;
      gint         NbrAlloc = 0;

      valid = gtk_tree_model_get_iter_first (VarSplit.Adr_Tree_Model, &iter);
      while (valid) {
            gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
            if (detail) {
                  if ((FicSplit = (FIC_SPLIT *)detail->fic_split) != NULL) {
                        gchar *Str = NULL;

                        if ((NbrAlloc = g_list_length (FicSplit->ListDecoupes)) == 0)
                              Str = g_strdup_printf ("%d", NbrAlloc);
                        else  Str = g_strdup_printf ("<b>%d</b>", NbrAlloc);
                        gtk_list_store_set (VarSplit.Adr_List_Store, &iter, SPLIT_NBRCOUPE_FILE, Str, -1);

                        g_free (Str);
                        Str = NULL;
                  }
            }
            valid = gtk_tree_model_iter_next (VarSplit.Adr_Tree_Model, &iter);
      }
}

void split_button_goto_mark_A_split_clicked (void)
{
      gdouble value = gtk_markscale_get_value_A ();

      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value +0.1);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);

      VarPlayer.Button = GDK_BUTTON_RELEASE;

      VarPlayer.PercentTempsActuel = value;

      split_hscale_from_split_change_value (value);
}

void split_button_goto_mark_B_split_clicked (void)
{
      gdouble value = gtk_markscale_get_value_B ();

      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value +0.1);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);

      VarPlayer.Button = GDK_BUTTON_RELEASE;

      split_hscale_from_split_change_value (value);
}

void split_set_valuesAB (gdouble ValueMarkA, gdouble ValueMarkB);

void split_button_set_mark_A_split_clicked (void)
{
      gdouble value = gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));

      if (value > *VarSplit.AdrValueMarkB) {
            *VarSplit.AdrValueMarkB = value + 2.0;
            if (*VarSplit.AdrValueMarkB > 100.0) *VarSplit.AdrValueMarkB = 100.0;

            gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkB);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), *VarSplit.AdrValueMarkB);
            split_set_label_mark_B (*VarSplit.AdrValueMarkB);
      }
      *VarSplit.AdrValueMarkA = value;

      gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, value);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value + 1.0);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
      split_set_label_mark_A (value);
      split_copy_mark_A_split_clicked ();

      split_set_valuesAB (*VarSplit.AdrValueMarkA, *VarSplit.AdrValueMarkB);
}

void split_button_set_mark_B_split_clicked (void)
{
      gdouble value = gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));
      if (value < *VarSplit.AdrValueMarkA) {
            *VarSplit.AdrValueMarkA = value - 2.0;
            if (*VarSplit.AdrValueMarkA < 0.0) *VarSplit.AdrValueMarkA = 0.0;

            gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, *VarSplit.AdrValueMarkA);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), *VarSplit.AdrValueMarkA);
            split_set_label_mark_A (*VarSplit.AdrValueMarkA);
      }
      *VarSplit.AdrValueMarkB = value;

      gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, value);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value -1.0);
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
      split_set_label_mark_B (value);
      split_copy_mark_B_split_clicked ();

      split_set_valuesAB (*VarSplit.AdrValueMarkA, *VarSplit.AdrValueMarkB);
}

gdouble split_get_percent (gint H, gint M, gdouble S)
{
      gdouble            SecondesTempsActuel = 0.0;
      gdouble            PercentTempsActuel = 0.0;
      FIC_SPLIT   *FicSplit = split_get_ptr_ficsplit ();
      gint  sec;
      gint  hundr;

      sec = S;
      hundr = (S - (gdouble)sec) * 10.0;
      /*
      g_print("S   = %f\n", S);
      g_print("   sec = %d\n", sec);
      g_print("         hundr = %d\n", hundr);
      g_print("         hundr = %f\n", (gdouble)hundr / 10.0);
      g_print("         hundr = %f\n", (gdouble)hundr / 100.0);
      g_print("         hundr = %f\n", (gdouble)hundr / 1000.0);
      g_print("         hundr = %f\n", (gdouble)hundr / 10000.0);
      */
      SecondesTempsActuel = (gdouble)((H * 60) * 60) + (gdouble)(M * 60) + S + ((gdouble)hundr / 10000.0);

      /* POURCENTAGE */
      if (FicSplit != NULL) {
            /*PercentTempsActuel = (SecondesTempsActuel / (gdouble)FicSplit->GUINT_TempsTotal ) * 100.0;*/
            PercentTempsActuel = (SecondesTempsActuel / (gdouble)split_get_temps_total () ) * 100.0;
      }

      return ((gdouble)PercentTempsActuel);
}

void split_get_detail_percent (gdouble ValueMark, gint *H, gint *M, gint *S, gdouble *C)
{
      gint     sec;
      gdouble  dsec;
      gint     hundr;
      guint       TempsTotal = split_get_temps_total ();

      sec   = (gint) (((gdouble)TempsTotal * ValueMark) / 100.0);
      dsec  = ((gdouble)TempsTotal * ValueMark) / 100.0;
      hundr = (dsec - (gdouble)sec) * 10.0;

      *H = (gint)(sec / 60) / 60;
      *M = (gint)(sec / 60) % 60;
      *S = (gint)sec % 60;
      *C = hundr;
}

gchar *split_get_label_mark_A (gdouble ValueMarkA, guint p_TempsTotal)
{
      gchar   *Mess = NULL;
      gint     sec;
      gdouble  dsec;
      gint     hundr;
      guint    TempsTotal;
      
      
      if ((TempsTotal = p_TempsTotal) == 0)
            TempsTotal = split_get_temps_total ();

      sec   = (gint) (((gdouble)TempsTotal * ValueMarkA) / 100.0);
      dsec  = ((gdouble)TempsTotal * ValueMarkA) / 100.0;
      hundr = (dsec - (gdouble)sec) * 1000.0;

      if (hundr >= 1000) hundr = 999;
      Mess = g_strdup_printf ("  %02d:%02d:%02d.%03d  ", (sec/60)/60, (sec/60)%60, sec%60, hundr);
      return (Mess);
}

void split_set_label_mark_A (gdouble ValueMarkA)
{
      gchar   *Mess = NULL;

      Mess = split_get_label_mark_A (ValueMarkA, 0);
      gtk_label_set_use_markup (GTK_LABEL (VarSplit.AdrLabelMarkA), TRUE);
      gtk_label_set_markup (GTK_LABEL (VarSplit.AdrLabelMarkA), Mess);
      g_free (Mess);
      Mess = NULL;
}

gchar *split_get_label_mark_B (gdouble ValueMarkB, guint p_TempsTotal)
{
      gchar   *Mess = NULL;
      gint     sec;
      gdouble  dsec;
      gint     hundr;
      guint    TempsTotal;

      if ((TempsTotal = p_TempsTotal) == 0)
            TempsTotal = split_get_temps_total ();

      sec   = (gint) (((gdouble)TempsTotal * ValueMarkB) / 100.0);
      dsec  = ((gdouble)TempsTotal * ValueMarkB) / 100.0;
      hundr = (dsec - (gdouble)sec) * 1000.0;

      if (hundr >= 1000) hundr = 999;
      Mess = g_strdup_printf ("  %02d:%02d:%02d.%03d  ", (sec/60)/60, (sec/60)%60, sec%60, hundr);
      return (Mess);
}

void split_set_label_mark_B (gdouble ValueMarkB)
{
      gchar   *Mess = NULL;

      Mess = split_get_label_mark_B (ValueMarkB, 0);
      gtk_label_set_use_markup (GTK_LABEL (VarSplit.AdrLabelMarkB), TRUE);
      gtk_label_set_markup (GTK_LABEL (VarSplit.AdrLabelMarkB), Mess);
      g_free (Mess);
      Mess = NULL;
}

void split_label_mark_A_realize (GtkWidget *widget)
{
      VarSplit.AdrLabelMarkA = widget;
      VarSplit.AdrValueMarkA = NULL;
      split_set_label_mark_A (0.0);
}

void split_label_mark_B_realize (GtkWidget *widget)
{
      VarSplit.AdrLabelMarkB = widget;
      VarSplit.AdrValueMarkB = NULL;
      split_set_label_mark_B (100.0);
}

/*
guint OLD_split_get_temps_total (void)
{
      DETAIL            *detail = NULL;
      FIC_SPLIT   *FicSplit = NULL;
      GtkTreeModel                  *model = NULL;
      GList                   *BeginList = NULL;
      GtkTreePath             *path;
      GtkTreeIter              iter;
      guint                    TempsTotal = 0;
      
      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  
                  if (detail != NULL && (FicSplit = (FIC_SPLIT *)detail->fic_split) != NULL) {
                        
                        if (TempsTotal == 0) {
                              TempsTotal = (guint)FicSplit->GUINT_TempsTotal;
                        }
                        else {
                              TempsTotal = MAX(TempsTotal,(guint)FicSplit->GUINT_TempsTotal);
                        }
                  }
            }
            BeginList = g_list_next(BeginList);
      }
      return ((guint)TempsTotal);
}
*/
guint split_get_temps_total (void)
{
      DETAIL            *detail = NULL;
      FIC_SPLIT   *FicSplit = NULL;

      if ((detail = split_get_first_line_is_selected ()) == NULL) return (0);
      if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) return (0);
      return ((guint)FicSplit->GUINT_TempsTotal);
}

void split_spinbutton_set_mark_A_split_value_changed (void)
{
      if (VarSplit.AdrSpinbuttonHeuresDebut && VarSplit.AdrSpinbuttonMinutesDebut && VarSplit.AdrSpinbuttonSecondesDebut) {
            
            gint H, M;
            gdouble S;
            
            H = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonHeuresDebut);
            M = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonMinutesDebut);
            S = gtk_spin_button_get_value (VarSplit.AdrSpinbuttonSecondesDebut);
            CopyAdrValueMarkA = split_get_percent (H, M, S);
      }
}

void split_spinbutton_set_mark_B_split_value_changed (void)
{
      if (VarSplit.AdrSpinbuttonHeuresFin && VarSplit.AdrSpinbuttonMinutesFin && VarSplit.AdrSpinbuttonSecondesFin) {

            gint H, M;
            gdouble S;

            H = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonHeuresFin);
            M = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonMinutesFin);
            S = gtk_spin_button_get_value (VarSplit.AdrSpinbuttonSecondesFin);
            CopyAdrValueMarkB = split_get_percent (H, M, S);
      }
}

void split_copy_mark_A_split_clicked (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;

      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GTK_WIDGET (lookup_widget (wind_main, "togglebutton_sync_mark_A_split"))))) {

            if (detail != NULL && (FicSplit = detail->fic_split) != NULL) {

                  gint H, M, S;
                  gdouble C;

                  CopyAdrValueMarkA = FicSplit->AdrValueMarkA;
                  split_get_detail_percent (CopyAdrValueMarkA, &H, &M, &S, &C);

                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonHeuresDebut), (gdouble)H);
                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonMinutesDebut), (gdouble)M);
                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonSecondesDebut), (gdouble)S + (C / 10.0));
            }
      }
}
void split_copy_mark_B_split_clicked (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;

      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GTK_WIDGET (lookup_widget (wind_main, "togglebutton_sync_mark_B_split"))))) {

            if (detail != NULL && (FicSplit = detail->fic_split) != NULL) {

                  gint H, M, S;
                  gdouble C;

                  CopyAdrValueMarkB = FicSplit->AdrValueMarkB;
                  split_get_detail_percent (CopyAdrValueMarkB, &H, &M, &S, &C);

                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonHeuresFin), (gdouble)H);
                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonMinutesFin), (gdouble)M);
                  gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonSecondesFin), (gdouble)S + (C / 10.0));
            }
      }
}

void split_coller_mark_A_split_clicked (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;

      if (detail != NULL && (FicSplit = detail->fic_split) != NULL) {

            gint H, M;
            gdouble  S;
            gdouble value;

            H = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonHeuresDebut);
            M = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonMinutesDebut);
            S = gtk_spin_button_get_value (VarSplit.AdrSpinbuttonSecondesDebut);

            value =
            *VarSplit.AdrValueMarkA =
            FicSplit->AdrValue =
            FicSplit->AdrValueMarkA =
            CopyAdrValueMarkA = split_get_percent (H, M, S);
            
            split_set_valuesAB (*VarSplit.AdrValueMarkA, *VarSplit.AdrValueMarkB);
            split_set_new_info ();
            gtk_markscale_set_value_A (VarSplit.AdrHscaleFromSplit, value);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value + 1.0);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
            split_set_label_mark_A (value);
      }
}
void split_coller_mark_B_split_clicked (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;

      if (detail != NULL && (FicSplit = detail->fic_split) != NULL) {

            gint H, M;
            gdouble  S;
            gdouble value;

            H = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonHeuresFin);
            M = gtk_spin_button_get_value_as_int (VarSplit.AdrSpinbuttonMinutesFin);
            S = gtk_spin_button_get_value (VarSplit.AdrSpinbuttonSecondesFin);

            value =
            *VarSplit.AdrValueMarkB =
            FicSplit->AdrValue =
            FicSplit->AdrValueMarkB =
            CopyAdrValueMarkB = split_get_percent (H, M, S);
            
            split_set_valuesAB (*VarSplit.AdrValueMarkA, *VarSplit.AdrValueMarkB);
            split_set_new_info ();
            gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, value);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value + 1.0);
            gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
            split_set_label_mark_B (value);
      }
}

void split_jogg_event (GdkEvent *event)
{
      gdouble val;
      static gdouble value = 0.0;

      if (event->type == GDK_BUTTON_PRESS) {
            VarPlayer.Button = GDK_BUTTON_PRESS;
      }
      if (event->type == GDK_BUTTON_RELEASE) {
            VarPlayer.Button = GDK_BUTTON_RELEASE;
      }

      if (!VarSplit.AdrAdjustDepuis) return;
      if (!VarSplit.AdrJogg) return;

      value = gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));
      val = jog_shuttle_get_value (VarSplit.AdrJogg);
      value += val;

      if (value < 0.0) value = 0.0;
      if (value > 100.0) value = 100.0;

      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
      split_hscale_from_split_change_value (value);
}

void split_button_set_mark_B_to_A_split_clicked (void)
{
      *VarSplit.AdrValueMarkA = *VarSplit.AdrValueMarkB;
      *VarSplit.AdrValue = *VarSplit.AdrValueMarkA;

      split_button_set_mark_A_split_clicked ();
      split_copy_mark_A_split_clicked ();
      
      *VarSplit.AdrValue = *VarSplit.AdrValueMarkB = 100.0;
      
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), 100.0);
      split_hscale_from_split_change_value (100.0);
      gtk_markscale_set_value_B (VarSplit.AdrHscaleFromSplit, 100.0);
      split_button_set_mark_B_split_clicked ();
}
void split_button_set_mark_B_to_A_SYNC_split_clicked (void)
{
      DETAIL            *detail = split_get_first_line_is_selected ();
      FIC_SPLIT   *FicSplit = NULL;
      gint         H, M, S;
      gdouble C;

      if (detail != NULL && (FicSplit = detail->fic_split) != NULL) {

            PRINT_FUNC_LF();

            CopyAdrValueMarkA = CopyAdrValueMarkB;
            split_get_detail_percent (CopyAdrValueMarkA, &H, &M, &S, &C);

            gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonHeuresDebut), (gdouble)H);
            gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonMinutesDebut), (gdouble)M);
            gtk_spin_button_set_value (GTK_SPIN_BUTTON (VarSplit.AdrSpinbuttonSecondesDebut), (gdouble)S);
      }
}

void split_set_valuesAB (gdouble ValueMarkA, gdouble ValueMarkB)
{
      DETAIL                        *detail = NULL;
      FIC_SPLIT               *FicSplit = NULL;
      GtkTreeModel                  *model = NULL;
      GList                   *BeginList = NULL;
      GtkTreePath             *path;
      GtkTreeIter              iter;
      gboolean                 BoolOK = FALSE;
      
      gdouble                        SecDebut = 0.0;
      gdouble                        SecFin = 0.0;
      gdouble                        SEC;
      gdouble                        ValueMark;
      
      model = gtk_tree_view_get_model (GTK_TREE_VIEW(VarSplit.Adr_TreeView));
      BeginList = g_list_first (gtk_tree_selection_get_selected_rows (VarSplit.Adr_Line_Selected, &model));
      while (BeginList) {
            if ((path = BeginList->data)) {
                  gtk_tree_model_get_iter (model, &iter, path);
                  gtk_tree_model_get (VarSplit.Adr_Tree_Model, &iter, SPLIT_POINTER_STRUCT, &detail, -1);
                  
                  if (detail == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  if ((FicSplit = (FIC_SPLIT *)detail->fic_split) == NULL) {
                        BeginList = g_list_next(BeginList);
                        continue;
                  }
                  
                  if (BoolOK == FALSE) {
                        BoolOK = TRUE;
                        
                        SEC = (((gdouble)FicSplit->GUINT_TempsTotal * ValueMarkA) / 100.0);
                        FicSplit->AdrValueMarkA = ValueMarkA;
                        FicSplit->AdrValueMarkA = (SEC / (gdouble)FicSplit->GUINT_TempsTotal ) * 100.0;
                        
                        SEC = (((gdouble)FicSplit->GUINT_TempsTotal * ValueMarkB) / 100.0);
                        FicSplit->AdrValueMarkB = ValueMarkB;
                        FicSplit->AdrValueMarkB = (SEC / (gdouble)FicSplit->GUINT_TempsTotal ) * 100.0;
                        
                        SecDebut = (((gdouble)FicSplit->GUINT_TempsTotal * FicSplit->AdrValueMarkA) / 100.0);
                        SecFin   = (((gdouble)FicSplit->GUINT_TempsTotal * FicSplit->AdrValueMarkB) / 100.0);
                  }
                  else {
                        /* VALUE-MARK-A */
                        ValueMark = 0.0;
                        do {
                              SEC = (((gdouble)FicSplit->GUINT_TempsTotal * ValueMark) / 100.0);
                              if (SecDebut != SEC) ValueMark += 0.001;
                        } while (SEC <= SecDebut);
                        
                        FicSplit->AdrValueMarkA = (SEC / (gdouble)FicSplit->GUINT_TempsTotal ) * 100.0;
                        
                        /* VALUE */
                        FicSplit->AdrValue = FicSplit->AdrValueMarkA;
                        
                        /* VALUE-MARK-B */
                        ValueMark = 0.0;
                        do {
                              SEC = (((gdouble)FicSplit->GUINT_TempsTotal * ValueMark) / 100.0);
                              if (SecFin != SEC) ValueMark += 0.001;
                        } while (SEC <= SecFin);
                        
                        FicSplit->AdrValueMarkB = (SEC / (gdouble)FicSplit->GUINT_TempsTotal ) * 100.0;
                  }
            }
            BeginList = g_list_next(BeginList);
      }
}





void split_MAJ (void)
{
      /*VarPlayer.DOUBLE_TempsActuel = 0.0;*/
      /*VarPlayer.PercentTempsActuel = 0.0;*/
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), VarPlayer.PercentTempsActuel);
      split_hscale_from_split_change_value (VarPlayer.PercentTempsActuel);
      split_set_flag_buttons_audio ();
}

void split_button_lecture_split_clicked (void)
{
      DETAIL  *detail = NULL;

      /* Fenetre d'alerte si MPLAYER absent */
      if (PrgInit.bool_mplayer == FALSE) {
            gtk_notebook_set_current_page (GTK_NOTEBOOK (lookup_widget (wind_main, "notebook_general")), NOTEBOOK_PRGEXTERNES);
            gtk_notebook_set_current_page (GTK_NOTEBOOK (lookup_widget (wind_main, "notebook_app_externes")), NOTEBOOK_OPTIONS_PRGEXTERNES);
            return;
      }
      
      /*  La lecture commence uniquement avec un appuis sur ce bouton */
      if ((detail = split_get_first_line_is_selected ()) != NULL) {
            
            GList *list = NULL;
            gint   sec;
            
            VarPlayer.PercentTempsActuel = *VarSplit.AdrValue;
            sec = (gint) ((VarPlayer.DOUBLE_TempsTotal * VarPlayer.PercentTempsActuel) / 100.0);
            list = g_list_append (list, g_strdup ("-ss"));
            list = g_list_append (list, g_strdup_printf ("%d", sec));
            list = g_list_append (list, g_strdup (detail->namefile));
            
            PlayerExec_set_list (LIST_PLAY_FROM_SPLIT, 0.0, VarPlayer.GUINT_TempsTotal, list);

            split_set_flag_buttons_audio ();
      
            gtk_widget_hide (GTK_WIDGET (VarSplit.AdrButtonPlay));
            gtk_widget_show (GTK_WIDGET (VarSplit.AdrButtonStop));
            /*gtk_widget_set_sensitive (GTK_WIDGET (VarSplit.AdrButtonStop), TRUE);*/
      }
}
void split_button_stop_lecture_split_clicked (void)
{
      VarPlayer.BoolPushButton = PUSH_BUTTON_STOP;
      PlayerExec_fifo_quit ();
      split_MAJ ();
      gtk_widget_show (GTK_WIDGET (VarSplit.AdrButtonPlay));
      gtk_widget_hide (GTK_WIDGET (VarSplit.AdrButtonStop));
      /*gtk_widget_set_sensitive (GTK_WIDGET (VarSplit.AdrButtonStop), FALSE);*/
      split_with_mplayer (VarPlayer.PercentTempsActuel);
}
void split_button_debut_lecture_split_clicked (void)
{
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), 0.0);
      VarPlayer.Button = GDK_BUTTON_RELEASE;
      VarPlayer.PercentTempsActuel = 0.0;
      split_hscale_from_split_change_value (0.0);
}
void split_button_recule_lecture_split_clicked (void)
{
      static gdouble value = 0.0;
      
      value = gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));
      value -= 0.1;
      if (value < 0.0) value = 0.0;
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
      split_hscale_from_split_change_value (value);
      PlayerExec_fifo_seek_with_hundr (value);
}
void split_button_avance_lecture_split_clicked (void)
{
      static gdouble value = 0.0;
      
      value = gtk_adjustment_get_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis));
      value += 0.1;
      if (value > 100.0) value = 100.0;
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), value);
      split_hscale_from_split_change_value (value);
      PlayerExec_fifo_seek_with_hundr (value);
}
void split_button_fin_lecture_split_clicked (void)
{
      gtk_adjustment_set_value (GTK_ADJUSTMENT (VarSplit.AdrAdjustDepuis), 100.0);
      VarPlayer.Button = GDK_BUTTON_RELEASE;
      VarPlayer.PercentTempsActuel = 100.0;
      split_hscale_from_split_change_value (100.0);
}






Generated by  Doxygen 1.6.0   Back to index