Location: PHPKode > projects > Multimedia Files Scanner > drvscan.php
<?php

// License (see LICENSE.txt)
// by aaff http://multifis.sourceforge.net

class DrvScan {

var $gui;
var $clistnumrows;
var $clistnumcolumns;
var $files;
var $slash;
var $cancel;

// Constructor, setting style and slash type "\" "/" (win, unix)
function DrvScan() {

  if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {

    $this->slash = "\\";

  } else {

    $this->slash = "/";

  }

  DEFINE("VERSION",'0.25a');
  DEFINE("TITLE","MultiFiS");
  
  $this->clistnumcolumns = 5;

// Themes??

//work
#		$strStyle = "AceIce";			//thinice
#		$strStyle = "A-Warm-Place";		//notif
#		$strStyle = "Basic";			//metal
#		$strStyle = "Blue";				//engradient
#		$strStyle = "Brushed";			//engradient
#		$strStyle = "Crowberry";		//raleigh
#		$strStyle = "emacsdef";			//engradient
#		$strStyle = "flat";				//flat
#		$strStyle = "grey";				//engradient
#		$strStyle = "informer";			//none?
#		$strStyle = "Jade";				//raleigh
#		$strStyle = "mac";				//engradient
#		$strStyle = "metal";			//metal
#		$strStyle = "notif";			//notif
# 	$strStyle = "redmond95";		//redmond95
#		$strStyle = "Subliminal";		//flat
#		$strStyle = "thinice";			//thinice
  $strStyle = "whistlerK";		//whistler

//don't work
#		$strStyle = "AquaX";			//pixmap
#		$strStyle = "mozilla-modern-2";	//pixmap
#		$strStyle = "4Missy";			//pixmap
#		$strStyle = "23_oz-Glass";		//pixmap
#		$strStyle = "3000_xeno";		//xeno
#		$strStyle = "DreamWorks";		//pixmap

  if ( isset( $strStyle)) {
  
    GTK::rc_parse( GTK::rc_get_theme_dir() . "/" . $strStyle . "/gtk/gtkrc");
	
	}

// Fin Themes


  if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {

    $this->slash = "\\";

  } else {

    $this->slash = "/";

  }


  $this->main(); // Calling main loop

}

// main loop

function main() {


// Some widgets style	

// $this->gui['window']->style = 'style "ventana" {
//bg[PRELIGHT] = {0.831, 0.816, 0.784}
//bg[NORMAL] = {0.831, 0.816, 0.784}
//bg[ACTIVE] = {0.831, 0.816, 0.784}
  $this->gui['style']->style = 'style "ventana" {
  font = "-adobe-verdana-medium-r-normal--*-103-*-*-*-*-*-*"
  bg[NORMAL] = { 0.85, 0.85 , 0.85 }
  }
  widget "*" style "ventana"

  style "mp3infoframe" {
  fg[NORMAL] = { 0.090, 0.471, 0.796 }
  bg[NORMAL] = { 0.9, 0.9, 0.9 }
  bg[SELECTED] = { 0.1, 0.4, 0.9 }
  fg[SELECTED] = { 1.0, 1.0, 1.0 }
  }
  widget "*mp3infoframe*" style "mp3infoframe"

  style "mp3infolabel" {
  fg[NORMAL] = { 0.0, 0.0, 0.0 }

  }
  widget "*mp3infolabel*" style "mp3infolabel"
  style "mp3clist" {
  fg[NORMAL] = { 0.090, 0.471, 0.796 }
  bg[SELECTED] = { 0.1, 0.4, 0.9 }
  fg[SELECTED] = { 1.0, 1.0, 1.0 }
  }
  widget "*mp3clist*" style "mp3clist"';

  gtk::rc_parse_string($this->gui['style']->style);

  $this->gui['window'] = &new GtkWindow();

  $this->gui['window']->connect('destroy', array(&$this,'destroy'));
	
  $this->gui['window']->connect('delete-event', array(&$this,'delete_event'));
	
  $this->gui['window']->set_default_size(600,400);

  $this->gui['window']->set_border_width(10);

  $this->gui['window']->set_title(TITLE." v".VERSION);

  $this->gui['window']->set_position('GTK_WIN_POS_CENTER');

  $this->gui['scrolledwin'] = &new GtkScrolledWindow();

  $this->gui['scrolledwin']->set_usize(640, 300);

  $this->gui['hbox'] = &new GtkVBox(); // Caja general MenĂº, Ventana con clist, botones y status

  $this->gui['hbox']->set_spacing(3);

  $this->gui['hbox3'] = &new GtkHBox();
	

// Menu
	
  $this->gui['Gtk_AccelGroup'] = &new GtkAccelGroup();

  $this->gui['Gtk_ItemFactory'] = &new GtkItemFactory(GtkMenuBar::get_type(), '<main>', $this->gui['Gtk_AccelGroup']);

  $this->gui['Gtk_ItemFactory']->create_items(array(
  array('/_File', '', null,0, '<Branch>'),
    array('/_File/_New', '<control>n', array( &$this, 'borrar_lista'), 2, ''),
    array('/_File/_Save', '<control>s', array( &$this, 'save_file'), 2, ''),
    array('/_File/_Quit', '<control>q', array( &$this, 'cerrar'), 2, ''),
    array('/_Edit', '', null,0, '<Branch>'),
//array('/_Editar/Desahacer', '<control>Z', array( &$this, 'deshacer'), 2, ''),
//array('/_Editar/Rehacer', '<shift><control>Z', array( &$this, 'rehacer'), 2, ''),
//array('/_Editar/Cortar', '<control>x', array( &$this, 'cortar'), 2, ''),
    array('/_Edit/_Remove Selected', '<control>r', array( &$this, 'remove'), 2, ''),
//array('/_Edit/Get Selected Info', '', array( &$this, 'pegar'), 2, ''),
    array('/_Edit/_Search', '<control>f', array( &$this, 'search_win'), 2, ''),
    array('/_Edit/_Options','<control>o',array(&$this,'options'),2,''),
    array('/_Tools/Check for _update', '<control>U', array(&$this,"check_for_update"), 2, ''),
//array('/_Editar/Ir a la linea', '<control><alt>l', quit, 2, ''),
//array('/_Herramientas', '', null, 0, '<Branch>'),
//array('/_Herramientas/Debugger', '', array( &$this, 'debugger'), 2, ''),
    array('/_Help', '', null,0, '<Branch>'),
    array('/_Help/About MultiFiS', 'F1', array(&$this,'about'),0,'')));


// Frame with mp3 information

  $this->gui['mp3infoframe'] = &new GtkFrame('Selected MP3 Information');

  $this->gui['mp3infoframe']->set_name("mp3infoframe");


// Frame->ScrolledWin

  $this->gui['mp3infoscrolled'] = &new GtkScrolledWindow();

  $this->gui['mp3infoscrolled']->set_policy(GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);

  $this->gui['mp3infoscrolled']->set_usize(600, 100);

  $this->gui['mp3infoscrolled']->set_border_width(5);


// Frame->Scrolledwin->HBox

  $this->gui['mp3infovbox'] = &new GtkHbox();

// Frame->Scrolledwin->Hbox->Label

  $this->gui['mp3infolabel'] = &new GtkLabel();

  $this->gui['mp3infolabel']->set_justify(GTK_JUSTIFY_LEFT);

  $this->gui['mp3infolabel']->set_text("None Selected");

  $this->gui['mp3infolabel']->Set_Alignment(0.0, 0.0);

  $this->gui['mp3infolabel']->set_name("mp3infolabel");


// Packing Frame

	$this->gui['mp3infoframe']->add($this->gui['mp3infoscrolled']);
		
	$this->gui['mp3infoscrolled']->add_with_viewport($this->gui['mp3infovbox']);
		
	$this->gui['mp3infovbox']->pack_start($this->gui['mp3infolabel'],true,true);

	$this->gui['mp3infolabel']->show();

	$this->gui['mp3infoframe']->show();

  $this->gui['mp3infovbox']->show();

  $this->gui['mp3infoscrolled']->show();

// Bottom Buttons

  $this->gui['boton_scan'] = &new GtkButton('Scan!');

  $this->gui['boton_scan']->connect('clicked',array(&$this,'select_file'));

  $this->gui['boton_retrieve_tags'] = &new GtkButton('Retrieve Tags');

  $this->gui['boton_retrieve_tags']->connect('clicked',array(&$this,'retrieve_tags'),&$this->files);
	
  $this->gui['boton_borrar_todo'] = &new GtkButton('Empty List');

  $this->gui['boton_borrar_todo']->connect('clicked',array(&$this,'borrar_lista'));

// Clist

  $this->gui['clist'] = &new GtkClist(6,array('File Path','File','Length','Bitrate','Channels','Size'));
  $this->gui['clist']->set_column_visibility(0,false);

  $this->gui['clist']->set_name("mp3clist");

  $this->gui['clist']->set_selection_mode(GTK_SELECTION_EXTENDED);

  $this->gui['clist']->connect("select-row",array(&$this,"show_mp3_info"));
  
  $this->gui['clist']->connect('click_column', array(&$this,'sort_list'));
  
		
// Main Window

 	$this->gui['titulo'] = &new GtkLabel('MP3 DriveScanner');

  $this->gui['StatusBar'] = &new GtkStatusBar();

  $this->gui['StatusBar']->push($this->gui['StatusBar']->get_context_id("Status: ok"),"Status: ok");

  $this->gui['StatusBar']->show();

  $this->gui['titulo']->show();

  $this->gui['window']->add($this->gui['hbox']);

  $this->gui['window']->add_accel_group($this->gui['Gtk_AccelGroup']);

//$this->gui['hbox']->pack_start($this->gui['titulo'],false);

  $this->gui['hbox']->pack_start($this->gui['Gtk_ItemFactory']->get_widget('<main>'),false,false);

  $this->gui['hbox']->pack_start($this->gui['scrolledwin']);

//$this->gui['hbox2'] = &new GtkVBox();

//$this->gui['scrolledwin']->add_with_viewport($this->gui['hbox2']);

//	$this->gui['hbox2']->pack_start($this->gui['clist']);

  $this->gui['scrolledwin']->add($this->gui['clist']);

  $this->gui['hbox']->pack_start($this->gui['mp3infoframe'], false, false);

  $this->gui['hbox']->pack_start($this->gui['hbox3']);

  $this->gui['hbox']->pack_start($this->gui['StatusBar']);

  $this->gui['hbox3']->pack_start($this->gui['boton_scan']);

  $this->gui['hbox3']->pack_start($this->gui['boton_retrieve_tags']);

  $this->gui['hbox3']->pack_start($this->gui['boton_borrar_todo']);

  $this->gui['tt_Scan'] = &new GtkTooltips();

  $this->gui['tt_Scan']->set_delay(300);

  $this->gui['tt_Scan']->set_tip($this->gui['boton_scan'], 'Gets multimedia files on selected directory and subdirectories');

  $this->gui['tt_Scan']->enable();
  
  $this->gui['tt_Retrieve'] = &new GtkTooltips();

  $this->gui['tt_Retrieve']->set_delay(300);

  $this->gui['tt_Retrieve']->set_tip($this->gui['boton_retrieve_tags'], 'Gets information of Scanned files');
  
  $this->gui['tt_Retrieve']->enable();

  $this->gui['window']->show_all();

// Starting main loop!

  Gtk::main();
	
}

 function delete_event() {

return false;

 }

 function destroy() {

Gtk::main_quit();

 }
 
 function sort_list($clist, $column) {

   $clist->set_sort_column($column);

		if ($clist->sort_type == GTK_SORT_ASCENDING) {
		
         $clist->set_sort_type(GTK_SORT_DESCENDING);
					
      } else {
         $clist->set_sort_type(GTK_SORT_ASCENDING);
         
      }

   	$clist->sort();
 }

 ////////////////////
 // File selection
 ////////////////////
 
 	function save_file() {

		$fs = &new GtkFileSelection("Save...");
		$fs->connect('delete_event', 'delete_event');
		//$fs->hide_fileop_buttons();
		$fs->show();
		$button_ok = $fs->ok_button;
		$button_cancel = $fs->cancel_button;
		$entry_selection = $fs->selection_entry;
		$button_ok->connect('clicked', array(&$this,'save'),$fs,$entry_selection);
		$button_cancel->connect('clicked','hide_object',$fs);

	}
	
   function save($button_ok,$fs,$entry_selection) {

      $fs->hide();
      $filename = $fs->get_filename();


      $fp = fopen($filename,"w");

      for($i=0;$i<$this->clistnumrows;$i++) {

         //echo $this->gui['clist']->get_text($i,1)."\r\n";

         fputs($fp,$this->gui['clist']->get_text($i,0)."|".$this->gui['clist']->get_text($i,1)."|".$this->gui['clist']->get_text($i,2)."\r\n");

      }

      fclose($fp);

   }
   
 function search_win() {
       
   $this->gui['Search'] = &new GtkWindow(GTK_WINDOW_DIALOG);

   Gtk::grab_add($this->gui['Search']);

   $this->gui['Search']->connect('destroy',array( &$this, 'cerrar_ventana'), $widget);

   $this->gui['Search']->set_usize(350,200);

   $this->gui['Search']->set_title('Search');

   $this->gui['Search']->set_position(GTK_WIN_POS_CENTER);

   $this->gui['Search_Box'] = new GtkVBox(false,0);

  $this->gui['Search_Label'] = &new GtkLabel("Search");

  $this->gui['Search_Label']->set_justify(GTK_JUSTIFY_FILL);

//$this->gui['About_Box']->pack_start($this->gui['Logo']);

  $this->gui['Search_Box']->pack_start($this->gui['Search_Label']) ;
  
  $this->gui['Search_Entry'] = &new GtkEntry();
  
  $this->gui['Search_Box']->pack_start($this->gui['Search_Entry']);

  $this->gui['Search_ButtonBox'] = &new GtkHButtonBox();
  
  $this->gui['Search_ButtonBox']->set_layout(GTK_BUTTONBOX_SPREAD);

  $this->gui['Search_Ok'] = &new GtkButton('OK');

  $this->gui['Search_Ok']->connect('clicked',array(&$this, 'search'),$widget);

  $this->gui['Search_Ok']->set_usize(25,25);
  
  $this->gui['Search_Cancel'] = &new GtkButton('Cancel');

  $this->gui['Search_Cancel']->connect('clicked',array(&$this, 'cerrar_ventana'),$widget);

  $this->gui['Search_Cancel']->set_usize(25,25);

  $this->gui['Search_ButtonBox']->pack_start($this->gui['Search_Ok'],FALSE,FALSE,3);

  $this->gui['Search_ButtonBox']->pack_end($this->gui['Search_Cancel'],FALSE,FALSE,3);

  $this->gui['Search_VBox'] = new GtkVBox();

  $this->gui['Search_VBox']->pack_start($this->gui['Search_Box']);

  $this->gui['Search_VBox']->pack_end($this->gui['Search_ButtonBox']);

  $this->gui['Search']->add($this->gui['Search_VBox']);

  $this->gui['Search']->show_all();
  
}

   function search() {
   
      $entrytext = $this->gui['Search_Entry']->get_text();
      
      $this->cerrar_ventana($this->gui['Search']);
      
      echo $entrytext."\n";
      
      $this->gui['clist']->freeze();
      
      $this->gui['clist']->unselect_all();

      for($i = 0;$i<$this->clistnumrows;$i++) {
      
         if(stristr($this->gui['clist']->get_text($i,1),$entrytext) != false) {
         
            echo "si!\n";
            $this->gui['clist']->select_row($i,0);
            
         }
         
      }
      
      $this->gui['clist']->thaw();
   
   }

   function select_file() {
	
      $selected_filename = filedialog("Select directory or drive",false);

      echo "selected ". $selected_filename . "\n";

      if(is_dir($selected_filename)) {
			
      $this->gui['clist']->clear();
			
      $this->gui['clist']->freeze();
			
      $this->gui['StatusBar']->push($this->gui['StatusBar']->get_context_id("Status: Loading"),"Status: Loading");
			
      $this->Loading(true);

      $row = directory_scan($selected_filename,&$this);	

      if($row[0] != NULL) {

      foreach($row as $mp3file) {
		
         //$fileonly = explode("\\",$mp3file);
					
         //$files[] = end($fileonly);
					
         //$this->files[] = $mp3file;
	
         $this->clistnumrows++;	

         echo $mp3file." ".$this->slash."\n\n";				

         $this->gui['clist']->insert(0,array($mp3file,end(explode($this->slash,$mp3file)),'','','',''));
				
      }

   }
			
 $this->gui['clist']->columns_autosize();
			
 $this->gui['clist']->thaw();
			
 $this->gui['StatusBar']->pop($this->gui['StatusBar']->get_context_id("Status: Loading"));

 $this->Loading(false);

} else {

 echo "No es un directorio!\n";

}

 }
	
	function retrieve_tags($button,$files) {
	
	
//if($this->files[0] == NULL) {
if($this->gui['clist']->get_text(0,0) == NULL) {

 echo "No files\n";return;

}

		$this->gui['StatusBar']->push($this->gui['StatusBar']->get_context_id("Status: Loading"),"Status: Loading");

$this->gui['clist']->freeze();

$this->Loading(true);

 // list ($pixmap, $mask) = gdk::pixmap_create_from_xpm($this->gui['clist']->window, NULL, "prueba.xpm");

for($i=0;$i<$this->clistnumrows;$i++) {
	
 while (gtk::events_pending()){

gtk::main_iteration();

 }
	
// echo $this->files[$i]."\n";
 echo $this->gui['clist']->get_text($i,0)."\n";
 
 $currentfile = $this->gui['clist']->get_text($i,0);
	
 //$fileinfo = getallfileinfo($file,true,true,true);

 if(strtolower(substr($currentfile,-3)) == "wma") {
$assume = "asf";
 } else {
$assume = strtolower(substr($currentfile,-3));
 }

 $fileinfo = getallfileinfo($currentfile,$assume);



 //echo $fileinfo['filesize']." ".$fileinfo['playtime_string']."\n";

 if($fileinfo['comments']['artist'][0] == NULL AND $fileinfo['comments']['title'][0] != NULL) {

$titlestr = $fileinfo['comments']['title'][0];

 } elseif($fileinfo['comments']['artist'][0] != NULL AND $fileinfo['comments']['title'][0] != NULL) {

$titlestr = $fileinfo['comments']['artist'][0]." - ".$fileinfo['comments']['title'][0];

 } else {

$titlestr = $fileinfo['filename'];

 }


 //$this->gui['clist']->set_pixtext($this->clistnumrows-$i-1,0,$titlestr,2,$pixmap,$mask);

 $this->gui['clist']->set_text($i,1,$titlestr);

 $this->gui['clist']->set_text($i,2,$fileinfo['playtime_string']);

 $this->gui['clist']->set_text($i,3,number_format($fileinfo['audio']['bitrate']/1000,2)." Kbps");

 $this->gui['clist']->set_text($i,4,$fileinfo['audio']['channels']);

 $this->gui['clist']->set_text($i,5,number_format($fileinfo['filesize']/(1024*1024),2)." Mb");

 if($this->cancel == true) {

$this->cancel = false;

$this->Loading(false);

$this->gui['clist']->thaw();

return;

 }
	
}

$this->gui['clist']->thaw();

$this->Loading(false);

$this->gui['StatusBar']->pop($this->gui['StatusBar']->get_context_id("Status: Loading"));

//var_dump($fileinfo);
	
 }

 function borrar_lista() {
	
$this->gui['clist']->clear();

//$this->files = array();

$this->clistnumrows = 0;

 }

function about() {

  $this->gui['About'] = new GtkWindow(GTK_WINDOW_DIALOG);

  Gtk::grab_add($this->gui['About']);

  $this->gui['About']->connect('destroy',array( &$this, 'cerrar_ventana'), $widget);

  $this->gui['About']->set_usize(350,150);

  $this->gui['About']->set_title('About MultiFiS v'.VERSION);

  $this->gui['About']->set_position(GTK_WIN_POS_CENTER);

  $this->gui['About_Box'] = new GtkVBox(false,0);

// list($logo, $logomask) = gdk::pixmap_create_from_xpm($this->gui['Gtk_Window']->window,$this->fondo,"imagenes/logo.xpm");

// $this->gui['Logo'] = &new GtkPixmap($logo, $logomask);

  $mensaje= " DriveScanner v".VERSION." \n- Author:\n-- aaff <hide@address.com>\n\n This program uses getid3 library:\n - http://getid3.sourceforge.net";

  $this->gui['About_Label'] = &new GtkLabel($mensaje);

  $this->gui['About_Label']->set_justify(GTK_JUSTIFY_FILL);

//$this->gui['About_Box']->pack_start($this->gui['Logo']);

  $this->gui['About_Box']->pack_start($this->gui['About_Label']) ;

  $this->gui['Caja_Boton'] = &new gtkhbuttonbox();

  $this->gui['Boton'] = &new GtkButton('OK');

  $this->gui['Boton']->connect('clicked',array(&$this, 'cerrar_ventana'),$widget);

  $this->gui['Boton']->set_usize(25,25);

  $this->gui['Caja_Boton'] ->pack_start($this->gui['Boton'],FALSE,FALSE,3);

  $this->gui['About_Caja'] = new GtkVBox();

  $this->gui['About_Caja']->pack_start($this->gui['About_Box']);

  $this->gui['About_Caja']->pack_end($this->gui['Caja_Boton']);

  $this->gui['About']->add($this->gui['About_Caja']);

  $this->gui['About']->show_all();

}

 function check_for_update() {

$this->gui['UpdateWin'] = new GtkWindow(GTK_WINDOW_DIALOG);

Gtk::grab_add($this->gui['UpdateWin']);

$this->gui['UpdateWin']->set_usize(350,200);

$this->gui['UpdateWin']->set_title('Check for Update');

$this->gui['UpdateWin']->set_position(GTK_WIN_POS_CENTER);

$this->gui['UpdateWin']->connect('delete-event', array(&$this,'delete_event'));

$this->gui['UpdateWin_Text'] = &new GtkText();

$this->gui['UpdateWin_Text']->insert(null,null,null,"Connecting...");

//$this->gui['UpdateWin_Text']->set_justify(GTK_JUSTIFY_FILL);

$this->gui['UpdateWin_ButtonBox'] = &new gtkhbuttonbox();

$this->gui['UpdateWin_ButtonBox']->set_layout(GTK_BUTTONBOX_SPREAD);

$this->gui['UpdateWin_Cancel'] = &new GtkButton('Cancel');

$this->gui['UpdateWin_Cancel']->connect('clicked',array(&$this, 'cerrar_ventana'));

$this->gui['UpdateWin_Cancel']->set_usize(25,25);

$this->gui['UpdateWin_Download'] = &new GtkButton('Download');

$this->gui['UpdateWin_Download']->set_usize(25,25);

$this->gui['UpdateWin_Download']->set_sensitive(false);

$this->gui['UpdateWin_ButtonBox']->pack_start($this->gui['UpdateWin_Download'],false,false,3);

$this->gui['UpdateWin_ButtonBox']->pack_start($this->gui['UpdateWin_Cancel'],true,true,3);

$this->gui['UpdateWin_Vbox'] = new GtkVBox();

$this->gui['UpdateWin_Vbox']->pack_start($this->gui['UpdateWin_Text']);

//$this->gui['Loading_Caja']->pack_start($this->gui['Loading_Vbox']);

$this->gui['UpdateWin_Vbox']->pack_end($this->gui['UpdateWin_ButtonBox'],true,true);

$this->gui['UpdateWin']->add($this->gui['UpdateWin_Vbox']);

$this->gui['UpdateWin']->show_all();

while(gtk::events_pending()) {

 gtk::main_iteration();

}

$fp = fopen("http://multifis.sourceforge.net/updatecheck.php?version=".VERSION,"r");

while(!feof($fp)) {

 $readline = fgets($fp,1024);

 if(trim($readline) == "<!--checkstart-->") {

$readline = fgets($fp,1024); break;

 }

}

fclose($fp);

echo $readline."\n";

$text = "Current Version: ".VERSION."\nNew Version: ".end(explode("#",trim($readline)))."\n";

$this->gui['UpdateWin_Text']->insert(null,null,null,"\n".$text);





 }

 function Loading($open) {

if($open == true) {

 if(class_exists("Loading")) {

$this->gui['Loading']->show();

 } else {

$this->gui['Loading'] = new GtkWindow(GTK_WINDOW_POPUP);

Gtk::grab_add($this->gui['Loading']);

$this->gui['Loading']->set_usize(350,200);

$this->gui['Loading']->set_title('Loading');

$this->gui['Loading']->set_position(GTK_WIN_POS_CENTER);

$this->gui['window']->hide();

//$this->gui['Loading']->connect('destroy', array(&$this,'destroy'));

//$this->gui['Loading']->connect('delete-event', array(&$this,'destroy'));

//$this->gui['Loading_Vbox'] = new GtkVBox(false,0);

// list($logo, $logomask) = gdk::pixmap_create_from_xpm($this->gui['Gtk_Window']->window,$this->fondo,"imagenes/logo.xpm");

// $this->gui['Logo'] = &new GtkPixmap($logo, $logomask);

$this->gui['Loading_Label'] = &new GtkLabel('Loading: Please Wait');

$this->gui['Loading_Label']->set_justify(GTK_JUSTIFY_FILL);

//$this->gui['Ayuda_Box']->pack_start($this->gui['Logo']);

//$this->gui['Loading_Vbox']->pack_start($this->gui['Loading_Label']) ;

$this->gui['Loading_Caja_Boton'] = &new gtkhbuttonbox();

$this->gui['Loading_Cancel'] = &new GtkButton('Cancel');

$this->gui['Loading_Cancel']->connect('clicked',array(&$this, 'cancel'));

$this->gui['Loading_Cancel']->set_usize(25,25);

$this->gui['Loading_Caja_Boton']->pack_start($this->gui['Loading_Cancel'],FALSE,FALSE,3);

$this->gui['Loading_Caja'] = new GtkVBox();

$this->gui['Loading_Caja']->pack_start($this->gui['Loading_Label']);

//$this->gui['Loading_Caja']->pack_start($this->gui['Loading_Vbox']);

$this->gui['Loading_Caja']->pack_end($this->gui['Loading_Caja_Boton']);

$this->gui['Loading']->add($this->gui['Loading_Caja']);

$this->gui['Loading']->show_all();

 }

} else {

 $this->cerrar_ventana($this->gui['Loading']);

 $this->gui['window']->show();

}

 }

 function options() {

$this->gui['OptionsWin'] = new GtkWindow(GTK_WINDOW_DIALOG);

Gtk::grab_add($this->gui['OptionsWin']);

$this->gui['OptionsWin']->set_usize(350,200);

$this->gui['OptionsWin']->set_title('Options');

$this->gui['OptionsWin']->set_position(GTK_WIN_POS_CENTER);

$this->gui['OptionsWin']->connect('delete-event', array(&$this,'delete_event'));

$this->gui['OptionsWin_Clist'] = &new GtkClist(1,array("files"));

//$this->gui['UpdateWin_Text']->insert(null,null,null,"Connecting...");

//$this->gui['UpdateWin_Text']->set_justify(GTK_JUSTIFY_FILL);

$this->gui['OptionsWin_ButtonBox'] = &new gtkhbuttonbox();

$this->gui['OptionsWin_ButtonBox']->set_layout(GTK_BUTTONBOX_SPREAD);

$this->gui['OptionsWin_Ok'] = &new GtkButton('Ok');

$this->gui['OptionsWin_Ok']->connect('clicked',array(&$this, 'cerrar_ventana'));

$this->gui['OptionsWin_Ok']->set_usize(25,25);

$this->gui['OptionsWin_Add'] = &new GtkButton('Add');

$this->gui['OptionsWin_Add']->set_usize(25,25);

$this->gui['OptionsWin_Add']->connect('clicked',array(&$this,'add_db'));

$this->gui['OptionsWin_ButtonBox']->pack_start($this->gui['OptionsWin_Add'],false,false,3);

$this->gui['OptionsWin_ButtonBox']->pack_start($this->gui['OptionsWin_Ok'],true,true,3);

$this->gui['OptionsWin_Vbox'] = new GtkVBox();

$this->gui['OptionsWin_Vbox']->pack_start($this->gui['OptionsWin_Clist']);

$this->gui['OptionsWin_Vbox']->pack_end($this->gui['OptionsWin_ButtonBox'],true,true);

$this->gui['OptionsWin']->add($this->gui['OptionsWin_Vbox']);

$this->gui['OptionsWin']->show_all();

 }

 function show_mp3_info() {

$file = $this->gui['clist']->get_text($this->gui['clist']->selection[0],0);

echo "Selected ->".$file." -> ".$this->gui['clist']->selection[0]." -> ".($this->clistnumrows-$this->gui['clist']->selection[0])."\n";

$fileinfo = getallfileinfo($file,'mp3');

//echo $fileinfo['filesize']." ".$fileinfo['playtime_string']."\n";

if($fileinfo['comments']['artist'][0] == NULL AND $fileinfo['comments']['title'][0] != NULL) {

 $titlestr = $fileinfo['comments']['title'][0];

} elseif($fileinfo['comments']['artist'][0] != NULL AND $fileinfo['comments']['title'][0] != NULL) {

 $titlestr = $fileinfo['comments']['artist'][0]." - ".$fileinfo['comments']['title'][0];

} else {

 $titlestr = $fileinfo['filename'];

}

/*
$this->gui['clist']->set_text($i,0,$titlestr);
$this->gui['clist']->set_text($i,1,$fileinfo['playtime_string']);
$this->gui['clist']->set_text($i,2,number_format($fileinfo['audio']['bitrate']/1000,2)." Kbps");
$this->gui['clist']->set_text($i,3,$fileinfo['audio']['channels']);
$this->gui['clist']->set_text($i,4,number_format($fileinfo['filesize']/(1024*1024),2)." Mb");
*/


$titlestr = str_replace(chr(0)," ",$titlestr);

$mp3infotext = end(explode($this->slash,$file))."\n\nTitle: ".$titlestr."\n\n";

$mp3infotext .= "Length: ".$fileinfo['playtime_string']."\n\n";

$mp3infotext .= "Bitrate: ".number_format($fileinfo['audio']['bitrate']/1000,2)." Kbps\n\n";

$mp3infotext .= "Channels: ".$fileinfo['audio']['channels']."\n\n";

$mp3infotext .= "File Size: ".number_format($fileinfo['filesize']/(1024*1024),2)." Mb\n\n";

$this->gui['mp3infolabel']->set_text("Selected: ".$mp3infotext);

 }

 function cerrar_ventana($widget) {

$window = $widget->get_toplevel();

Gtk::grab_remove($window);

$window->hide();

 }

 function cancel() {

$this->cancel = true;

 }


 function nada() {

echo "hola :)\n";

 }

 function add_db() {

echo filedialog("Not working...",true);

 }

 function update() {

$fp = fopen("http://multifis.sourceforge.net/updatecheck.php?version=".VERSION,"r");

while(!feof($fp)) {

$readline = fgets($fp,1024);

 if(trim($readline) == "<!--checkstart-->") {

$readline = fgets($fp,1024); break;

 }

}

fclose($fp);

echo $readline."\n";

}

}
?>
Return current item: Multimedia Files Scanner