Logo Search packages:      
Sourcecode: xcfa version File versions

prg_init.c

 /*
 * file      : prg_init.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/>.
 * 
 */


#include <gtk/gtk.h>
#include "support.h"

#include <string.h>

#include "global.h"
#include "cd_audio.h"
#include "file.h"
#include "utils.h"
#include "options.h"
#include "poche.h"
#include "win_info.h"
#include "prg_init.h"


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

enum
{
      NUM_TREE_Nom = 0,
      NUM_TREE_Status,
      NUM_TREE_Action,
      NUM_TREE_ALL_COLUMN
};

enum
{
      PRGEXT_NAME = 0,
      PRGEXT_STATUS,
      PRGEXT_COMMENT,
      PRGEXT_NUM_COLUMN,
      PRGEXT_TOTAL_COLUMN
};


VAR_PRGEXTERN var_prgextern;


typedef struct
{
      gchar       *Name;
      gchar       *Name1;
      gchar       *Name2;
      gchar       *Name3;
      TYPE_PROGINIT      TypeProgInit;
      GdkPixbuf   *Pixbuf;
      gchar       *Comment;
      gboolean    *BoolPresent;
      gchar       *NamePackInstall;

} VAR_PRGINIT;

#define MAX_DATAS_STRUCT_PRGINIT 28
VAR_PRGINIT VarPrgInit [ MAX_DATAS_STRUCT_PRGINIT ];

PRGINIT PrgInit;


void prginit_affiche_glist (gint p_index)
{
      gchar       *Name;
      GtkAdjustment     *Adj = NULL;
      gdouble            AdjValue;
      GtkTreeIter  iter;

      /* PRINT_FUNC_LF(); */

      /* Reajustement de la liste */
      Adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (var_prgextern.Adr_scroll));
      AdjValue = gtk_adjustment_get_value (Adj);
      gtk_adjustment_set_value (Adj, AdjValue);
      gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (var_prgextern.Adr_scroll), Adj);
      gtk_list_store_prepend (var_prgextern.Adr_List_Store, &iter);
      
      if (*VarPrgInit[ p_index ].BoolPresent)
            Name = g_strdup_printf ("<span color=\"black\"><b>%s</b></span>", VarPrgInit[ p_index ].Name);
      else  Name = g_strdup_printf ("<span color=\"red\"><b>%s</b></span>", VarPrgInit[ p_index ].Name);
      
      gtk_list_store_set (var_prgextern.Adr_List_Store, &iter,
                        PRGEXT_NAME,            Name,
                        PRGEXT_STATUS,          VarPrgInit[ p_index ].Pixbuf,
                        PRGEXT_COMMENT,         VarPrgInit[ p_index ].Comment,
                        PRGEXT_NUM_COLUMN,      p_index,    
                        -1);
      /*g_print("%s\n\t%p\n\t\t%s\n", VarPrgInit[ p_index ].Name,VarPrgInit[ p_index ].Pixbuf,VarPrgInit[ p_index ].Comment);*/
      g_free (Name);
      Name = NULL;
}

void prginit_init (void)
{
      gint  index;
      
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            VarPrgInit[ index ].Name            = NULL;
            VarPrgInit[ index ].Name1           = NULL;
            VarPrgInit[ index ].Name2           = NULL;
            VarPrgInit[ index ].Name3           = NULL;
            VarPrgInit[ index ].TypeProgInit    = BOOL_NONE;
            VarPrgInit[ index ].Pixbuf          = NULL;
            VarPrgInit[ index ].Comment         = NULL;
            VarPrgInit[ index ].BoolPresent     = FALSE;
            VarPrgInit[ index ].NamePackInstall = NULL;
      }
}

gboolean prginit_add_glist (TYPE_PROGINIT  TypeProgInit,
                      gboolean            *BoolPresent,
                      gchar         *Name1,
                      gchar         *Name2,
                      gchar         *Name3,
                      gchar         *PackInstall,
                      gchar         *Description
                      )
{
      gboolean    Bool_1,  Bool_2,  Bool_3;
      gint        index;
      
      /* Chercher index */
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++)
            if (VarPrgInit[ index ].TypeProgInit == BOOL_NONE) break;
      
      Bool_1 = utils_scan_by_which (Name1, NULL);
      if (*Name2 != '\0') Bool_2 = utils_scan_by_which (Name2, NULL);
      else            Bool_2 = FALSE;
      if (*Name3 != '\0') Bool_3 = utils_scan_by_which (Name3, NULL);
      else            Bool_3 = FALSE;
g_print ("%s%s\t%s%s\t%s%s\n", Bool_1?"*":" ",Name1, Bool_2?"*":" ",Name2, Bool_3?"*":" ",Name3);
      
      VarPrgInit[ index ].BoolPresent = BoolPresent;
      *VarPrgInit[ index ].BoolPresent = Bool_1 | Bool_2  | Bool_3;
      if (*VarPrgInit[ index ].BoolPresent)
            VarPrgInit[ index ].Pixbuf          = var_prgextern.Pixbuf_Ok;
      else  VarPrgInit[ index ].Pixbuf          = var_prgextern.Pixbuf_Coche;
      
      VarPrgInit[ index ].Name1  = g_strdup (Name1);
      VarPrgInit[ index ].Name2  = g_strdup (Name2);
      VarPrgInit[ index ].Name3  = g_strdup (Name3);
      if (Bool_1 == TRUE)
            VarPrgInit[ index ].Name  = g_strdup (Name1);
      else if (Bool_2 == TRUE)
            VarPrgInit[ index ].Name  = g_strdup (Name2);
      else if (Bool_3 == TRUE)
            VarPrgInit[ index ].Name  = g_strdup (Name3);
      else  VarPrgInit[ index ].Name  = g_strdup (Name1);
      
      VarPrgInit[ index ].Comment         = g_strdup (Description);
      VarPrgInit[ index ].NamePackInstall = g_strdup (PackInstall);
      VarPrgInit[ index ].TypeProgInit    = TypeProgInit;
            
      if (TypeProgInit == BOOL_CHECKMP3)
            PrgInit.name_checkmp3 = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_NORMALIZE)
            PrgInit.name_normalize = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_MPPENC)
            PrgInit.name_mppenc = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_MPPDEC)
            PrgInit.name_mppdec = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_APE)
            PrgInit.name_ape = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_ICEDAX)
            PrgInit.name_cdda2wav_icedax = g_strdup (VarPrgInit[ index ].Name);
      else if (TypeProgInit == BOOL_CDDA2WAV)
            PrgInit.name_cdda2wav_icedax = g_strdup (VarPrgInit[ index ].Name);

      prginit_affiche_glist (index);
      
      return (TRUE);
}


GList *prginit_get_glist_prog (GList *list)
{
      gint         index;

      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Selected) {
                  list =  g_list_append (list, g_strdup (VarPrgInit[ index ].Name));
            }
      }
      return ((GList *)list);
}
GList *prginit_get_glist_install (GList *list)
{
      gint         index;

      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Selected) {
                  list =  g_list_append (list, g_strdup (VarPrgInit[ index ].NamePackInstall));
            }
      }
      return ((GList *)list);
}
GList *prginit_remove_glist_prog (GList *list)
{
      GList *new = NULL;
      gchar *ptr = NULL;

      new = g_list_first (list);
      while (new) {
            if ((ptr = (gchar*)new->data)) {
                  g_free (ptr);
                  ptr = NULL;
                  new->data = NULL;
            }
            new = g_list_next(new);
      }
      g_list_free (list);
      list = NULL;
      return ((GList*)NULL);
}
gboolean prginit_is_selected (void)
{
      gint         index;

      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Selected) return (TRUE);
      }
      
      return (FALSE);
}

gboolean prginit_get_etat (gboolean bool_scan)
{
      gchar       *Name = NULL;
      GtkTreeIter  iter;
      gboolean     valid;
      gint         index;
      gboolean     Bool_1,  Bool_2,  Bool_3;
      
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {

            Bool_1 = utils_scan_by_which (VarPrgInit[ index ].Name1, NULL);
            if (*VarPrgInit[ index ].Name2 != '\0') Bool_2 = utils_scan_by_which (VarPrgInit[ index ].Name2, NULL);
            else                          Bool_2 = FALSE;
            if (*VarPrgInit[ index ].Name3 != '\0') Bool_3 = utils_scan_by_which (VarPrgInit[ index ].Name3, NULL);
            else                          Bool_3 = FALSE;
/*
g_print ("%s%s\t%s%s\t%s%s\n", Bool_1?"*":" ",VarPrgInit[ index ].Name1, Bool_2?"*":" ",VarPrgInit[ index ].Name2, Bool_3?"*":" ",VarPrgInit[ index ].Name3);
*/    
            *VarPrgInit[ index ].BoolPresent = Bool_1 | Bool_2  | Bool_3;
            g_free (VarPrgInit[ index ].Name);
            VarPrgInit[ index ].Name = NULL;
            
            if (Bool_1 == TRUE)
                  VarPrgInit[ index ].Name  = g_strdup (VarPrgInit[ index ].Name1);
            else if (Bool_2 == TRUE)
                  VarPrgInit[ index ].Name  = g_strdup (VarPrgInit[ index ].Name2);
            else if (Bool_3 == TRUE)
                  VarPrgInit[ index ].Name  = g_strdup (VarPrgInit[ index ].Name3);
            else  VarPrgInit[ index ].Name  = g_strdup (VarPrgInit[ index ].Name1);

            if (*VarPrgInit[ index ].BoolPresent == TRUE) {
                  VarPrgInit[ index ].Pixbuf          = var_prgextern.Pixbuf_Ok;
            }
            else if (*VarPrgInit[ index ].BoolPresent == FALSE) {
                  if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Ok)
                        VarPrgInit[ index ].Pixbuf = var_prgextern.Pixbuf_Coche;
            }

            if (VarPrgInit[ index ].TypeProgInit == BOOL_CDDA2WAV) {
                  if (utils_scan_by_which ("icedax", NULL) == TRUE) {
                        
                        VarPrgInit[ index ].TypeProgInit = BOOL_ICEDAX;
                        
                        g_free (PrgInit.name_cdda2wav_icedax);
                        PrgInit.name_cdda2wav_icedax = NULL;
                        
                        g_free (VarPrgInit[ index ].Name);
                        VarPrgInit[ index ].Name = NULL;
                        g_free (VarPrgInit[ index ].Name1);
                        VarPrgInit[ index ].Name1 = NULL;
                        g_free (VarPrgInit[ index ].Name2);
                        VarPrgInit[ index ].Name2 = NULL;
                        g_free (VarPrgInit[ index ].Name3);
                        VarPrgInit[ index ].Name3 = NULL;

                        PrgInit.name_cdda2wav_icedax = g_strdup ("icedax");
                        VarPrgInit[ index ].Name     = g_strdup ("icedax");
                        VarPrgInit[ index ].Name1    = g_strdup ("icedax");
                        VarPrgInit[ index ].Name2    = g_strdup ("icedax");
                        VarPrgInit[ index ].Name3    = g_strdup ("icedax");
                  }
            }
      }

      valid = gtk_tree_model_get_iter_first (var_prgextern.Adr_Tree_Model, &iter);
      while (valid) {
            gtk_tree_model_get (var_prgextern.Adr_Tree_Model, &iter, PRGEXT_NUM_COLUMN, &index, -1);
            
            if (*VarPrgInit[ index ].BoolPresent)
                  Name = g_strdup_printf ("<span color=\"black\"><b>%s</b></span>", VarPrgInit[ index ].Name);
            else  Name = g_strdup_printf ("<span color=\"red\"><b>%s</b></span>", VarPrgInit[ index ].Name);
            gtk_list_store_set (var_prgextern.Adr_List_Store, &iter, PRGEXT_NAME, Name, -1);
            g_free (Name);
            Name = NULL;
            
            gtk_list_store_set (var_prgextern.Adr_List_Store, &iter, PRGEXT_STATUS, VarPrgInit[ index ].Pixbuf, -1);
            
            valid = gtk_tree_model_iter_next (var_prgextern.Adr_Tree_Model, &iter);
      }
      
      var_prgextern.Bool_Goto_Page_Options =
            PrgInit.bool_cdparanoia &
            PrgInit.bool_cdda2wav &
            PrgInit.bool_flac &
            PrgInit.bool_lame &
            PrgInit.bool_oggenc &
            PrgInit.bool_mpg321 &
            PrgInit.bool_ps2pdf &
            PrgInit.bool_sox &
            PrgInit.bool_normalize &
            PrgInit.bool_checkmp3 &
            PrgInit.bool_faad &
            PrgInit.bool_faac &
            PrgInit.bool_mplayer &
            PrgInit.bool_w32codecs &
            PrgInit.bool_shorten &
            PrgInit.bool_convert &
            PrgInit.bool_wavpack &
            PrgInit.bool_ape &
            PrgInit.bool_lsdvd &
            PrgInit.bool_vorbisgain &
            PrgInit.bool_mp3gain &
            PrgInit.bool_mp3splt &
            PrgInit.bool_wavsplit &
            PrgInit.bool_shntool &
            PrgInit.bool_cuetools &
            PrgInit.bool_aacplusenc;
      
      return (var_prgextern.Bool_Goto_Page_Options);
}

/* Update du treeview
*/
void prginit_update_glist (void)
{

      if (var_prgextern.Adr_Tree_Model == NULL) return;

      prginit_get_etat (TRUE);
            
      cdaudio_affiche_glist_audio_cd ();
      file_pixbuf_update_glist_file ();
      file_set_flag_buttons_audio_file ();
      cdaudio_set_flag_buttons_audio_cd ();

      if (var_prgextern.button_selection_globale)
            gtk_widget_set_sensitive (GTK_WIDGET (var_prgextern.button_selection_globale), prginit_is_not_installed ());
      if(var_prgextern.button_goto_install)
            gtk_widget_set_sensitive (GTK_WIDGET (var_prgextern.button_goto_install), prginit_get_bool_install ());
}
gboolean prginit_set_selected (void)
{
      gint        index;
      gboolean    bool_sel = FALSE;

      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Coche) {
                  VarPrgInit[ index ].Pixbuf = var_prgextern.Pixbuf_Selected;
                  bool_sel = TRUE;
            }
      }
      prginit_update_glist ();
      return (bool_sel);
}

/* Suppression du treeview et des structure associees
*/
void prginit_remove_install (void)
{
      gint        index;
      
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Name)             g_free (VarPrgInit[ index ].Name);
            if (VarPrgInit[ index ].Name1)                  g_free (VarPrgInit[ index ].Name1);
            if (VarPrgInit[ index ].Name2)                  g_free (VarPrgInit[ index ].Name2);
            if (VarPrgInit[ index ].Name3)                  g_free (VarPrgInit[ index ].Name3);
            if (VarPrgInit[ index ].Comment)          g_free (VarPrgInit[ index ].Comment);
            if (VarPrgInit[ index ].NamePackInstall)  g_free (VarPrgInit[ index ].NamePackInstall);
      }
}

gboolean prginit_get_bool_install (void)
{
      gint        index;
      
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].Pixbuf == var_prgextern.Pixbuf_Selected) return (TRUE);
      }
      
      return (FALSE);
}
gboolean prginit_is_not_installed (void)
{
      gint        index;
      
      for (index = 0; index < MAX_DATAS_STRUCT_PRGINIT; index ++) {
            if (VarPrgInit[ index ].BoolPresent == NULL) g_print("(VarPrgInit[ %02d ].BoolPresent == NULL\n", index);
            if (VarPrgInit[ index ].BoolPresent != NULL && *VarPrgInit[ index ].BoolPresent == FALSE) return (TRUE);
      }
      
      return (FALSE);
}

void prginit_scan (void)
{
      /* Init structs */
      prginit_init ();
      /* Set structs */
prginit_add_glist (BOOL_CONVERT,    &PrgInit.bool_convert,    "convert",           "",          "",         "imagemagick",          _(" [imagemagick] Manipulation de formats d'images"));
prginit_add_glist (BOOL_SHORTEN,    &PrgInit.bool_shorten,    "shorten",           "",          "",         "shorten",        _(" Forte compression au format wave"));
      if (HostConf.BoolCpuIs64Bits == TRUE) {
prginit_add_glist (BOOL_W32CODECS,  &PrgInit.bool_w32codecs,  "w64codecs",         "",          "",         "w64codecs",            _(" Codecs video non supportes par mplayer / <b><i>PAS indispensable</i></b>"));
      } else {
prginit_add_glist (BOOL_W32CODECS,  &PrgInit.bool_w32codecs,  "w32codecs",         "",          "",         "w32codecs",            _(" Codecs video non supportes par mplayer / <b><i>PAS indispensable</i></b>"));
      }
prginit_add_glist (BOOL_MPLAYER,    &PrgInit.bool_mplayer,    "mplayer",           "",          "",         "mplayer",        _(" Lecteur et extracteur"));
prginit_add_glist (BOOL_FAAC,       &PrgInit.bool_faac,       "faac",        "",          "",         "faac",                 _(" Audio Codeur freeware"));
prginit_add_glist (BOOL_FAAD,       &PrgInit.bool_faad,       "faad",        "",          "",         "faad",                 _(" MPEG-4 AAC decodeur"));
prginit_add_glist (BOOL_CHECKMP3,   &PrgInit.bool_checkmp3,   "checkmp3",          "mp3check",  "mp3_check",      "checkmp3",       _(" Cherche des renseignements sur les formats mp3"));
prginit_add_glist (BOOL_NORMALIZE,  &PrgInit.bool_normalize,  "normalize",         "normalize-audio", "",         "normalize-audio",      _(" Normaliseur de fichier wav"));
prginit_add_glist (BOOL_SOX,        &PrgInit.bool_sox,        "sox",         "",          "",         "sox",                  _(" Transformation universelle de fichiers son"));
prginit_add_glist (BOOL_PS2PDF,           &PrgInit.bool_ps2pdf,     "ps2pdf",      "",          "",         "ps2pdf",         _(" Conversion  fichier  *.PS vers  *.PDF"));
prginit_add_glist (BOOL_MPG321,           &PrgInit.bool_mpg321,     "mpg321",      "",          "",         "mpg321",         _(" Conversion mp3 : wav"));
prginit_add_glist (BOOL_OGGENC,           &PrgInit.bool_oggenc,     "oggenc",      "",          "",         "vorbis-tools",         _(" [Vorbis-tools] Conversion wav : ogg"));
prginit_add_glist (BOOL_LAME,       &PrgInit.bool_lame,       "lame",        "",          "",         "lame",                 _(" Conversion wav : mp3"));
prginit_add_glist (BOOL_FLAC,       &PrgInit.bool_flac,       "flac",        "",          "",         "flac",                 _(" Conversion wav : flac / <b><i>METAFLAC DOIT ETRE SUPERIEUR A LA VERSION: 1.1.2</i></b>"));
prginit_add_glist (BOOL_WAVPACK,    &PrgInit.bool_wavpack,    "wavpack",           "",          "",         "wavpack",        _(" [wavpack] WAVPACK  Hybrid Lossless Audio Compressor"));
      if (HostConf.BoolCpuIs64Bits == TRUE) {
prginit_add_glist (BOOL_MPPDEC,           &PrgInit.bool_mppdec,     "mpc123",      "mppdec",          "",         "mpc123",         _(" MPC Decodeur"));
      } else {
prginit_add_glist (BOOL_MPPDEC,           &PrgInit.bool_mppdec,     "mppdec",      "mpc123",          "",         "musepack-decoder",     _(" MPC Decodeur"));
      }
      if (HostConf.BoolCpuIs64Bits == TRUE) {
prginit_add_glist (BOOL_MPPENC,           &PrgInit.bool_mppenc,     "mppenc",      "",          "",         "musepack-encoder",     _(" MPC Encodeur"));
      } else {
prginit_add_glist (BOOL_MPPENC,           &PrgInit.bool_mppenc,     "mppenc",      "",          "",         "musepack-encoder",     _(" MPC Encodeur"));
      }
prginit_add_glist (BOOL_APE,        &PrgInit.bool_ape,        "mac",         "",          "",         "mac",                  _(" Monkey's Audio"));
prginit_add_glist (BOOL_LSDVD,            &PrgInit.bool_lsdvd,      "lsdvd",       "",          "",         "lsdvd",          _(" Cherche les informations d'un dvd"));
prginit_add_glist (BOOL_CDPARANOIA, &PrgInit.bool_cdparanoia, "cdparanoia",      "",            "",         "cdparanoia",           _(" Extracteur cd audio"));
      if (utils_scan_by_which ("icedax", NULL)) {
prginit_add_glist (BOOL_ICEDAX,           &PrgInit.bool_cdda2wav,   "icedax",      "",          "",         "icedax",         _(" Extracteur cd audio"));
      }
      else {
prginit_add_glist (BOOL_CDDA2WAV,   &PrgInit.bool_cdda2wav,   "cdda2wav",          "",          "",         "cdda2wav",       _(" Extracteur cd audio"));
      }
prginit_add_glist (BOOL_MP3GAIN,    &PrgInit.bool_mp3gain,    "mp3gain",           "",          "",         "mp3gain",        _(" Normaliseur de fichier mp3"));
prginit_add_glist (BOOL_WAVSPLIT,   &PrgInit.bool_wavsplit,   "wavsplit",          "",          "",         "wavsplit",       _(" Decoupage de fichiers sans decodage"));
prginit_add_glist (BOOL_MP3SPLT,    &PrgInit.bool_mp3splt,    "mp3splt",           "",          "",         "mp3splt",        _(" Decoupage de fichiers sans decodage"));
prginit_add_glist (BOOL_SHNTOOL,    &PrgInit.bool_shntool,    "shntool",           "",          "",         "shntool",        _(" Decoupage de fichiers sans decodage"));
prginit_add_glist (BOOL_CUETOOLS,   &PrgInit.bool_cuetools,   "cuebreakpoints",  "",            "",         "cuetools",       _(" Decoupage de fichiers sans decodage"));
prginit_add_glist (BOOL_VORBISGAIN, &PrgInit.bool_vorbisgain, "vorbisgain",      "",            "",         "vorbisgain",           _(" Normaliseur de fichier ogg"));
prginit_add_glist (BOOL_AACPLUSENC, &PrgInit.bool_aacplusenc, "aacplusenc",      "",            "",         "aacplusenc",           _(" AAC+ encoder"));

      prginit_get_etat (TRUE);
      pocheevnt_add_elements_combobox_preview ();
}

/* Evenements souris pour le scrolledwindow
*/
gboolean prginit_traite_button_press_event (GtkWidget *treeview, GdkEventButton *event, gpointer data)
{
      GtkTreePath        *path;
      GtkTreeViewColumn  *column;
      gint                Pos_X = 0, Pos_Y = 0;
      GtkTreeIter         iter;
      GtkTreeModel       *model = (GtkTreeModel *)data;
      gint            num;
      
      /* PRINT_FUNC_LF(); */

      /* 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);

      /* Recuperation de la structure */
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_model_get (var_prgextern.Adr_Tree_Model, &iter, PRGEXT_NUM_COLUMN, &num, -1);

      /*
      enum
      {
            NUM_TREE_Nom
            NUM_TREE_Status
            NUM_TREE_Action
      };
      */    
      if (gtk_tree_view_get_column (GTK_TREE_VIEW(treeview), NUM_TREE_Status) == column) {
      /*if (strcmp(column->title, "Status") == 0) {*/
      
            /* position du curseur a l'instant du click */
            if (Pos_X < 18 || Pos_X > 30) return (FALSE);
            if (Pos_Y < 6 || Pos_Y > 18) return (FALSE);
            
            if (VarPrgInit[ num ].Pixbuf == var_prgextern.Pixbuf_Selected) {
                  VarPrgInit[ num ].Pixbuf = var_prgextern.Pixbuf_Coche;
                  gtk_list_store_set (var_prgextern.Adr_List_Store, &iter, PRGEXT_STATUS, var_prgextern.Pixbuf_Coche, -1);
            }
            else if (VarPrgInit[ num ].Pixbuf == var_prgextern.Pixbuf_Coche) {
                  VarPrgInit[ num ].Pixbuf = var_prgextern.Pixbuf_Selected;
                  gtk_list_store_set (var_prgextern.Adr_List_Store, &iter, PRGEXT_STATUS, var_prgextern.Pixbuf_Selected, -1);
            }
            /*
            g_print("NUM COLONNE = %d\n",num);
            g_print("%s\n\t%p\n\t\t%s\n", VarPrgInit[ num ].Name, VarPrgInit[ num ].Pixbuf, VarPrgInit[ num ].Comment);
            */
      }

      if (var_prgextern.button_selection_globale)
            gtk_widget_set_sensitive (GTK_WIDGET (var_prgextern.button_selection_globale), prginit_is_not_installed ());
      if(var_prgextern.button_goto_install)
            gtk_widget_set_sensitive (GTK_WIDGET (var_prgextern.button_goto_install), prginit_get_bool_install ());
      
      return (FALSE);
}

/* Creation du scrolledwindow et des evenements associes
*/
static void prginit_add_columns (GtkTreeView *treeview)
{
      GtkCellRenderer   *renderer;
      GtkTreeViewColumn *column;
      GtkTreeModel      *model = gtk_tree_view_get_model (treeview);

      /*PRINT_FUNC_LF();*/

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

      /* SIGNAL 'changed'
      */
      var_prgextern.Adr_Line_Selected = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
      gtk_tree_selection_set_mode (var_prgextern.Adr_Line_Selected, GTK_SELECTION_BROWSE);

      /* PRGEXT_NAME
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.0, NULL);
      column = gtk_tree_view_column_new_with_attributes (_("Nom"),
                                         renderer,
                                         /*"text", PRGEXT_NAME,*/
                                         "markup", PRGEXT_NAME,
                                         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), 110);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);

      /* PRGEXT_STATUS
      */
      renderer = gtk_cell_renderer_pixbuf_new ();
      g_object_set (renderer, "xalign", 0.5, NULL);
      column = gtk_tree_view_column_new_with_attributes (
                                          _("Status"),
                                          renderer,
                                          "pixbuf", PRGEXT_STATUS,
                                          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);

      /* PRGEXT_COMMENT
      */
      renderer = gtk_cell_renderer_text_new ();
      g_object_set (renderer, "xalign", 0.0, NULL);
      column = gtk_tree_view_column_new_with_attributes (
                                          _("Action"),
                                          renderer,
                                          /*"text", PRGEXT_COMMENT,*/
                                          "markup", PRGEXT_COMMENT,
                                          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), 160);
      gtk_tree_view_column_set_alignment (GTK_TREE_VIEW_COLUMN (column), 0.5);
      gtk_tree_view_append_column (treeview, column);
}

GdkPixbuf *prginit_init_pixbufs_file (char *NameFilePixbuf)
{
      GdkPixbuf *NewPixbuf = NULL;
      GError    *error = NULL;
      gchar     *Pathname_Pixbuf = NULL;

      /* PRINT_FUNC_LF(); */

      Pathname_Pixbuf = utils_get_pathname (NameFilePixbuf);

      /* load pixbuf
      */
      NewPixbuf = gdk_pixbuf_new_from_file(Pathname_Pixbuf, &error);
      if (error) {
            GDK_PIXBUF_ERROR;
            g_critical ("Could not load pixbuf: %s\n", error->message);
            g_error_free (error);
            g_free (Pathname_Pixbuf);
            Pathname_Pixbuf = NULL;
            return (NULL);
      }

      g_free (Pathname_Pixbuf);
      Pathname_Pixbuf = NULL;

      return (NewPixbuf);
}

/* Initialisation du scrolledwindow
*/
void prginit_make_scrolledwindow (GtkWidget *widget)
{
      GtkTreeModel *model;
      GtkWidget    *treeview;
      GtkListStore *store;

      /* PRINT_FUNC_LF(); */

      var_prgextern.Pixbuf_Coche     = prginit_init_pixbufs_file ("coche.png");
      var_prgextern.Pixbuf_Selected  = prginit_init_pixbufs_file ("selected.png");
      var_prgextern.Pixbuf_Ok        = prginit_init_pixbufs_file ("prg-ok.png");

      var_prgextern.Adr_scroll = widget;
      var_prgextern.Adr_List_Store =
      store = gtk_list_store_new (PRGEXT_TOTAL_COLUMN,      /* Nombre total de colonnes */
                            G_TYPE_STRING,            /* Name */
                            GDK_TYPE_PIXBUF,          /* Status */
                            G_TYPE_STRING,            /* Commentaire */
                            G_TYPE_INT
                            );
      var_prgextern.Adr_Tree_Model = model = GTK_TREE_MODEL (store);

      treeview = gtk_tree_view_new_with_model (model);
      gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);

      g_object_unref (model);
      gtk_container_add (GTK_CONTAINER (widget), treeview);

      /* add columns to the tree view */
      prginit_add_columns (GTK_TREE_VIEW (treeview));

      prginit_scan ();

      /*gtk_widget_show (widget);*/
      gtk_widget_show_all (widget);
}





Generated by  Doxygen 1.6.0   Back to index