changeset 16246:683d7592d9dc

Support for GTK 2.x. Patch by Onur Kucuk (onur . delipenguen net).
author reimar
date Wed, 17 Aug 2005 18:41:15 +0000
parents 48a698d9b937
children abfc9f282df2
files Gui/mplayer/gtk/about.c Gui/mplayer/gtk/opts.c Gui/mplayer/widgets.c configure
diffstat 4 files changed, 67 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/mplayer/gtk/about.c	Wed Aug 17 17:36:45 2005 +0000
+++ b/Gui/mplayer/gtk/about.c	Wed Aug 17 18:41:15 2005 +0000
@@ -28,6 +28,11 @@
   GtkWidget     * AboutText;
   GtkWidget     * Ok;
 
+#ifdef HAVE_GTK2_GUI
+  GtkTextBuffer * AboutTextBuffer;
+  GtkTextIter   iter;
+#endif //HAVE_GTK2_GUI
+
   GtkStyle      * pixmapstyle;
   GdkPixmap     * pixmapwid;
   GdkBitmap     * mask;
@@ -67,11 +72,21 @@
   gtk_box_pack_start( GTK_BOX( vbox ),scrolledwindow1,TRUE,TRUE,0 );
   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );
 
+#ifdef HAVE_GTK2_GUI
+  AboutText = gtk_text_view_new();
+  AboutTextBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (AboutText));
+  gtk_text_buffer_get_iter_at_offset (AboutTextBuffer, &iter, 0);  
+#else  
   AboutText=gtk_text_new( NULL,NULL );
+#endif
   gtk_widget_set_name( AboutText,"AboutText" );
   gtk_widget_show( AboutText );
   gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),AboutText );
+#ifdef HAVE_GTK2_GUI  
+  gtk_text_buffer_insert (AboutTextBuffer, &iter,   
+#else  
   gtk_text_insert( GTK_TEXT( AboutText ),NULL,NULL,NULL,
+#endif
   	"\n" 
 	MSGTR_ABOUT_UHU 
 	"             (http://www.uhulinux.hu/)\n" 
--- a/Gui/mplayer/gtk/opts.c	Wed Aug 17 17:36:45 2005 +0000
+++ b/Gui/mplayer/gtk/opts.c	Wed Aug 17 18:41:15 2005 +0000
@@ -736,8 +736,10 @@
 	     !strncmp( ao_driver[0],"esd",3 ) ||
 	     !strncmp( ao_driver[0],"sdl",3 ) )
 	  gtk_widget_set_sensitive( AConfig,TRUE );
+#ifndef HAVE_GTK2_GUI
         if ( !strncmp( ao_driver[0],"arts",4 ) )
           gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, MSGTR_PREFERENCES_ArtsBroken);
+#endif
 	break;
    case 1: // video driver 
 	gtk_clist_get_text( GTK_CLIST( CLVDrivers ),row,0,(char **)&vo_driver ); 
--- a/Gui/mplayer/widgets.c	Wed Aug 17 17:36:45 2005 +0000
+++ b/Gui/mplayer/widgets.c	Wed Aug 17 18:41:15 2005 +0000
@@ -217,7 +217,15 @@
 	  gtk_widget_destroy( PopUpMenu );
 	 }
         PopUpMenu=create_PopUpMenu();
+#ifdef HAVE_GTK2_GUI
+        // Ugly hack, but we don't want to loose events
+        while(!GTK_WIDGET_VISIBLE(PopUpMenu)) {
+           gtk_menu_popup(GTK_MENU(PopUpMenu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
+           gtk_main_iteration();
+        }
+#else
         gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
+#endif //HAVE_GTK2_GUI
         break;
    case evHidePopUpMenu:
         if ( PopUpMenu ) 
--- a/configure	Wed Aug 17 17:36:45 2005 +0000
+++ b/configure	Wed Aug 17 18:41:15 2005 +0000
@@ -155,7 +155,8 @@
 
 Optional features:
   --disable-mencoder     disable mencoder (a/v encoder) compilation [enable]
-  --enable-gui           enable gmplayer compilation (GTK 1.2 GUI) [disable]
+  --enable-gui           enable gmplayer compilation (GTK+ GUI) [disable]
+  --enable-old-gtk       force using GTK 1.2 for GUI  [disable]
   --enable-largefiles    enable support for files > 2 GBytes [disable]
   --enable-linux-devfs   set default devices to devfs ones [disable]
   --enable-termcap       use termcap database for key codes [autodetect]
@@ -1441,6 +1442,7 @@
 _lirc=auto
 _lircc=auto
 _gui=no
+_gtk1=no
 _termcap=auto
 _termios=auto
 _3dfx=no
@@ -1693,6 +1695,7 @@
   --disable-lircc)	_lircc=no	;;
   --enable-gui)		_gui=yes	;;
   --disable-gui)	_gui=no		;;
+  --enable-old-gtk)	_gtk1=yes	;;
   --enable-termcap)	_termcap=yes	;;
   --disable-termcap)	_termcap=no	;;
   --enable-termios)	_termios=yes    ;;
@@ -6629,8 +6632,40 @@
   fi
   echores "$_xshape"
 
-
-  # Check for GTK:
+#Check for GTK
+if test "$_gtk1" = no ; then
+  #Check for GTK2 :
+  echocheck "GTK+ version"
+
+  if pkg-config gtk+-2.0 --exists ; then
+    _gtk=`pkg-config gtk+-2.0 --modversion 2>/dev/null`
+    _inc_gtk=`pkg-config gtk+-2.0 --cflags 2>/dev/null`
+    _ld_gtk=`pkg-config gtk+-2.0 --libs 2>/dev/null`
+    echores "$_gtk"
+
+    # Check for GLIB2
+    if pkg-config glib-2.0 --exists ; then
+      echocheck "glib version"
+      _glib=`pkg-config glib-2.0 --modversion 2>/dev/null`
+      _inc_glib=`pkg-config glib-2.0 --cflags 2>/dev/null`
+      _ld_glib=`pkg-config glib-2.0 --libs 2>/dev/null`
+      echores "$_glib"
+
+      _def_gui='#define HAVE_NEW_GUI 1'
+      _def_gtk2_gui='#define HAVE_GTK2_GUI 1'
+      _ld_gui='$(GTKLIB) $(GLIBLIB)'
+    else
+      _gtk1=yes
+      echo "GLIB-2 devel packages were not found, trying GTK 1.2"
+    fi
+  else
+    echo "GTK-2 devel packages were not found, trying GTK 1.2"
+    _gtk1=yes
+  fi
+fi
+
+if test "$_gtk1" = yes ; then
+  # Check for old GTK (1.2.x)
   echocheck "GTK version"
   if test -z "$_gtkconfig" ; then
     if ( gtk-config --version ) >/dev/null 2>&1 ; then
@@ -6663,7 +6698,9 @@
   echores "$_glib (using $_glibconfig)"
 
   _def_gui='#define HAVE_NEW_GUI 1'
+  _def_gtk2_gui='#undef HAVE_GTK2_GUI'
   _ld_gui='$(GTKLIB) $(GLIBLIB)'
+fi
 
   echo "Creating Gui/config.mak"
   cat > Gui/config.mak << EOF
@@ -6678,6 +6715,7 @@
 
 else
   _def_gui='#undef HAVE_NEW_GUI'
+  _def_gtk2_gui='#undef HAVE_GTK2_GUI'
 fi
 # --------------- GUI specific tests end -------------------
 
@@ -7440,6 +7478,7 @@
 
 /* gui support, please do not edit this option */
 $_def_gui
+$_def_gtk2_gui
 
 /* Audio output drivers */
 $_def_ossaudio