2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2001-08-26 00:28:56 +00:00
|
|
|
#include <sys/wait.h>
|
2001-08-25 21:04:29 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2002-01-15 17:03:19 +00:00
|
|
|
#include <gdk/gdkprivate.h>
|
2001-08-25 21:04:29 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2002-07-05 23:47:00 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2002-01-15 17:03:19 +00:00
|
|
|
#include <gdk/gdk.h>
|
2001-08-25 21:04:29 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "widgets.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "app.h"
|
|
|
|
#include "wm/ws.h"
|
2002-07-05 23:47:00 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
#include "gtk/menu.h"
|
|
|
|
#include "play.h"
|
|
|
|
#include "gtk/fs.h"
|
|
|
|
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "../config.h"
|
|
|
|
#include "../help_mp.h"
|
|
|
|
#include "../mp_msg.h"
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-03-06 18:42:56 +00:00
|
|
|
GtkWidget * PopUpMenu = NULL;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2001-09-20 10:27:24 +00:00
|
|
|
GtkWidget * WarningPixmap;
|
|
|
|
GtkWidget * ErrorPixmap;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
int gtkPopupMenu = 0;
|
|
|
|
int gtkPopupMenuParam = 0;
|
2002-05-01 09:29:06 +00:00
|
|
|
int gtkInited = 0;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
#include "gtk/sb.h"
|
|
|
|
#include "gtk/pl.h"
|
|
|
|
#include "gtk/fs.h"
|
|
|
|
#include "gtk/mb.h"
|
|
|
|
#include "gtk/about.h"
|
|
|
|
#include "gtk/opts.h"
|
2001-11-14 16:04:25 +00:00
|
|
|
#include "gtk/menu.h"
|
2002-06-04 16:38:18 +00:00
|
|
|
#include "gtk/url.h"
|
2002-07-03 18:57:52 +00:00
|
|
|
#include "gtk/eq.h"
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
#include "pixmaps/MPlayer_mini.xpm"
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
// --- init & close gtk
|
2002-01-15 17:03:19 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
GdkPixmap * gtkIcon = NULL;
|
|
|
|
GdkBitmap * gtkIconMask = NULL;
|
|
|
|
Pixmap guiIcon;
|
|
|
|
Pixmap guiIconMask;
|
|
|
|
|
2002-05-28 11:55:17 +00:00
|
|
|
void gtkInit( void )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2004-12-15 01:22:24 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" );
|
2007-02-04 13:08:26 +00:00
|
|
|
#ifdef HAVE_GTK2_GUI
|
|
|
|
gtk_disable_setlocale();
|
|
|
|
#endif
|
2002-05-28 11:55:17 +00:00
|
|
|
gtk_init( 0,NULL );
|
2002-05-20 13:56:16 +00:00
|
|
|
// gdk_set_use_xshm( TRUE );
|
2002-07-05 23:47:00 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
GtkWidget * win;
|
|
|
|
win=gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
|
|
|
|
|
|
|
if ( !gtkIcon )
|
|
|
|
gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],MPlayer_mini_xpm );
|
|
|
|
|
|
|
|
guiIcon=GDK_WINDOW_XWINDOW( gtkIcon );
|
|
|
|
guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask );
|
|
|
|
|
|
|
|
gtk_widget_destroy( win );
|
|
|
|
}
|
|
|
|
|
2002-05-01 09:29:06 +00:00
|
|
|
gtkInited=1;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
void gtkAddIcon( GtkWidget * window )
|
2002-11-02 16:09:05 +00:00
|
|
|
{ wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); }
|
2002-07-05 23:47:00 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
void gtkClearList( GtkWidget * list )
|
|
|
|
{ gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
|
|
|
|
|
|
int gtkFindCList( GtkWidget * list,char * item )
|
|
|
|
{
|
|
|
|
gint j,t;
|
|
|
|
gchar * tmpstr;
|
|
|
|
for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
|
|
{
|
|
|
|
gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
|
|
if ( !strcmp( tmpstr,item ) ) return j;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
|
|
}
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
void gtkEventHandling( void )
|
|
|
|
{
|
|
|
|
int i;
|
2002-08-04 19:23:58 +00:00
|
|
|
for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 );
|
2002-02-23 15:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- funcs
|
|
|
|
|
2006-07-14 16:57:24 +00:00
|
|
|
void gtkMessageBox( int type,const gchar * str )
|
2002-02-23 15:12:55 +00:00
|
|
|
{
|
2002-05-01 09:29:06 +00:00
|
|
|
if ( !gtkInited ) return;
|
2002-05-20 13:56:16 +00:00
|
|
|
ShowMessageBox( str );
|
2002-02-23 15:12:55 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str );
|
2002-08-31 14:27:41 +00:00
|
|
|
/* enable linewrapping by alex */
|
|
|
|
// GTK_LABEL(gtkMessageBoxText)->max_width = 80;
|
|
|
|
if (strlen(str) > 80)
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
|
|
|
|
else
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
|
2002-02-23 15:12:55 +00:00
|
|
|
switch( type)
|
|
|
|
{
|
|
|
|
case GTK_MB_FATAL:
|
|
|
|
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError );
|
|
|
|
gtk_widget_hide( WarningPixmap );
|
|
|
|
gtk_widget_show( ErrorPixmap );
|
|
|
|
break;
|
|
|
|
case GTK_MB_ERROR:
|
|
|
|
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error );
|
|
|
|
gtk_widget_hide( WarningPixmap );
|
|
|
|
gtk_widget_show( ErrorPixmap );
|
|
|
|
break;
|
|
|
|
case GTK_MB_WARNING:
|
|
|
|
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning );
|
|
|
|
gtk_widget_show( WarningPixmap );
|
|
|
|
gtk_widget_hide( ErrorPixmap );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gtk_widget_show( MessageBox );
|
2002-07-25 20:26:38 +00:00
|
|
|
gtkSetLayer( MessageBox );
|
|
|
|
if ( type == GTK_MB_FATAL )
|
2002-11-27 22:48:56 +00:00
|
|
|
while ( MessageBox ) gtk_main_iteration_do( 0 );
|
2002-02-23 15:12:55 +00:00
|
|
|
}
|
|
|
|
|
2002-05-06 15:05:07 +00:00
|
|
|
void gtkSetLayer( GtkWidget * wdg )
|
2003-01-09 20:47:14 +00:00
|
|
|
{
|
|
|
|
wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen );
|
|
|
|
gtkActive( wdg );
|
|
|
|
}
|
2002-05-06 15:05:07 +00:00
|
|
|
|
2002-05-20 13:56:16 +00:00
|
|
|
void gtkActive( GtkWidget * wdg )
|
2002-11-02 16:09:05 +00:00
|
|
|
{ wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); }
|
2002-05-20 13:56:16 +00:00
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
void gtkShow( int type,char * param )
|
|
|
|
{
|
|
|
|
switch( type )
|
|
|
|
{
|
2002-07-03 18:57:52 +00:00
|
|
|
case evEqualizer:
|
|
|
|
ShowEqualizer();
|
|
|
|
gtkSetLayer( Equalizer );
|
|
|
|
break;
|
2002-02-23 15:12:55 +00:00
|
|
|
case evSkinBrowser:
|
2002-05-20 13:56:16 +00:00
|
|
|
ShowSkinBrowser();
|
2002-05-11 16:37:58 +00:00
|
|
|
// gtkClearList( SkinList );
|
2006-03-27 11:39:27 +00:00
|
|
|
if ( gtkFillSkinList( sbMPlayerPrefixDir ) &&
|
|
|
|
gtkFillSkinList( sbMPlayerPrefixDir_obsolete ) &&
|
|
|
|
gtkFillSkinList( sbMPlayerDirInHome ) &&
|
|
|
|
gtkFillSkinList( sbMPlayerDirInHome_obsolete ) )
|
2002-02-23 15:12:55 +00:00
|
|
|
{
|
|
|
|
gtkSetDefaultToCList( SkinList,param );
|
2002-07-05 23:47:00 +00:00
|
|
|
gtk_clist_sort( GTK_CLIST( SkinList ) );
|
2002-02-23 15:12:55 +00:00
|
|
|
gtk_widget_show( SkinBrowser );
|
2002-05-11 16:37:58 +00:00
|
|
|
gtkSetLayer( SkinBrowser );
|
2002-05-28 21:52:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-04 19:23:58 +00:00
|
|
|
gtk_widget_destroy( SkinBrowser );
|
2002-05-28 21:52:37 +00:00
|
|
|
gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." );
|
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evPreferences:
|
2002-07-25 20:26:38 +00:00
|
|
|
ShowPreferences();
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evPlayList:
|
2002-07-12 00:53:26 +00:00
|
|
|
ShowPlayList();
|
|
|
|
gtkSetLayer( PlayList );
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evLoad:
|
2002-07-02 21:10:42 +00:00
|
|
|
ShowFileSelect( fsVideoSelector,0 );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtkSetLayer( fsFileSelect );
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evFirstLoad:
|
2002-07-02 21:10:42 +00:00
|
|
|
ShowFileSelect( fsVideoSelector,0 );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtkSetLayer( fsFileSelect );
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evLoadSubtitle:
|
2002-07-02 21:10:42 +00:00
|
|
|
ShowFileSelect( fsSubtitleSelector,0 );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtkSetLayer( fsFileSelect );
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
2002-07-02 22:31:50 +00:00
|
|
|
case evLoadAudioFile:
|
|
|
|
ShowFileSelect( fsAudioSelector,0 );
|
|
|
|
gtkSetLayer( fsFileSelect );
|
|
|
|
break;
|
2002-02-23 15:12:55 +00:00
|
|
|
case evAbout:
|
2002-05-20 13:56:16 +00:00
|
|
|
ShowAboutBox();
|
2002-11-27 22:48:56 +00:00
|
|
|
gtkSetLayer( About );
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
|
|
|
case evShowPopUpMenu:
|
|
|
|
gtkPopupMenu=evNone;
|
|
|
|
gtkPopupMenuParam=0;
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( PopUpMenu )
|
|
|
|
{
|
|
|
|
gtk_widget_hide( PopUpMenu );
|
|
|
|
gtk_widget_destroy( PopUpMenu );
|
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
PopUpMenu=create_PopUpMenu();
|
|
|
|
gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
|
|
|
|
break;
|
|
|
|
case evHidePopUpMenu:
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( PopUpMenu )
|
|
|
|
{
|
|
|
|
gtk_widget_hide( PopUpMenu );
|
|
|
|
gtk_widget_destroy( PopUpMenu );
|
|
|
|
PopUpMenu=NULL;
|
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
2002-06-04 16:38:18 +00:00
|
|
|
case evPlayNetwork:
|
|
|
|
ShowURLDialogBox();
|
2002-07-19 20:51:48 +00:00
|
|
|
gtkSetLayer( URL );
|
2002-06-04 16:38:18 +00:00
|
|
|
break;
|
2002-02-23 15:12:55 +00:00
|
|
|
}
|
|
|
|
}
|