Author: hadess
Date: Fri Feb  8 20:52:09 2008
New Revision: 5086
URL: http://svn.gnome.org/viewvc/totem?rev=5086&view=rev

Log:
2008-02-08  Bastien Nocera  <[EMAIL PROTECTED]>

        * src/backend/bacon-video-widget-gst-0.10.c:
        (bacon_video_widget_can_play):
        * src/backend/bacon-video-widget-xine.c:
        (bacon_video_widget_can_play):
        * src/backend/bacon-video-widget.h:
        Change the API to give a more detailed information as to why it
        can't play a specific media

        * src/totem.c: (totem_action_load_media):
        Better error message depending on the retval of _can_play()



Modified:
   trunk/ChangeLog
   trunk/src/backend/bacon-video-widget-gst-0.10.c
   trunk/src/backend/bacon-video-widget-xine.c
   trunk/src/backend/bacon-video-widget.h
   trunk/src/totem.c

Modified: trunk/src/backend/bacon-video-widget-gst-0.10.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-gst-0.10.c     (original)
+++ trunk/src/backend/bacon-video-widget-gst-0.10.c     Fri Feb  8 20:52:09 2008
@@ -3889,10 +3889,10 @@
   return res;
 }
 
-gboolean
+BaconVideoWidgetCanPlayStatus
 bacon_video_widget_can_play (BaconVideoWidget * bvw, TotemDiscMediaType type)
 {
-  gboolean res;
+  BaconVideoWidgetCanPlayStatus res;
 
   g_return_val_if_fail (bvw != NULL, FALSE);
   g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
@@ -3900,24 +3900,27 @@
 
   switch (type) {
     case MEDIA_TYPE_VCD:
-      res = TRUE;
+      res = BVW_CAN_PLAY_SUCCESS;
       break;
     case MEDIA_TYPE_DVD: {
       GstElement *element;
 
       element = gst_element_factory_make ("dvdreadsrc", "test_dvdsrc");
-      res = (element != NULL);
-      if (element != NULL)
+      if (element == NULL) {
+        res = BVW_CAN_PLAY_MISSING_PLUGINS;
+      } else {
         g_object_unref (element);
+        res = BVW_CAN_PLAY_SUCCESS;
+      }
       break;
     }
     case MEDIA_TYPE_CDDA:
     default:
-      res = FALSE;
+      res = BVW_CAN_PLAY_UNSUPPORTED;
       break;
   }
 
-  GST_DEBUG ("type=%d, can_play=%s", type, (res) ? "TRUE" : "FALSE");
+  GST_DEBUG ("type=%d, can_play=%d", type, res);
   return res;
 }
 
@@ -4007,6 +4010,10 @@
       break;
     }
 
+    case MEDIA_TYPE_DVB: {
+      //FIXME
+    }
+
     default:
       mrls = NULL;
       break;

Modified: trunk/src/backend/bacon-video-widget-xine.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-xine.c (original)
+++ trunk/src/backend/bacon-video-widget-xine.c Fri Feb  8 20:52:09 2008
@@ -3452,21 +3452,41 @@
                        XINE_STREAM_INFO_SEEKABLE);
 }
 
-gboolean
+BaconVideoWidgetCanPlayStatus
 bacon_video_widget_can_play (BaconVideoWidget *bvw, TotemDiscMediaType type)
 {
        switch (type)
        {
        case MEDIA_TYPE_DVD:
-               return bvw->priv->can_dvd;
+               if (bvw->priv->can_dvd != FALSE)
+                       return BVW_CAN_PLAY_SUCCESS;
+               break;
        case MEDIA_TYPE_VCD:
-               return bvw->priv->can_vcd;
+               if (bvw->priv->can_vcd != FALSE)
+                       return BVW_CAN_PLAY_SUCCESS;
+               break;
        case MEDIA_TYPE_DVB:
-               return bvw->priv->can_dvb;
+               if (bvw->priv->can_dvb != FALSE) {
+                       char *path;
+
+                       path = g_build_filename (g_get_home_dir (),
+                                                ".xine",
+                                                "channels.conf",
+                                                NULL);
+                       if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == 
FALSE) {
+                               g_free (path);
+                               return BVW_CAN_PLAY_MISSING_CHANNELS;
+                       }
+                       g_free (path);
+                       return BVW_CAN_PLAY_SUCCESS;
+               }
+               break;
        case MEDIA_TYPE_CDDA:
        default:
-               return FALSE;
+               return BVW_CAN_PLAY_UNSUPPORTED;
        }
+
+       return BVW_CAN_PLAY_MISSING_PLUGINS;
 }
 
 char **

Modified: trunk/src/backend/bacon-video-widget.h
==============================================================================
--- trunk/src/backend/bacon-video-widget.h      (original)
+++ trunk/src/backend/bacon-video-widget.h      Fri Feb  8 20:52:09 2008
@@ -171,7 +171,15 @@
                                                  int speed);
 int bacon_video_widget_get_connection_speed      (BaconVideoWidget *bvw);
 
-gboolean bacon_video_widget_can_play             (BaconVideoWidget *bvw,
+typedef enum {
+       BVW_CAN_PLAY_SUCCESS,
+       BVW_CAN_PLAY_MISSING_CHANNELS,
+       BVW_CAN_PLAY_MISSING_PLUGINS,
+       BVW_CAN_PLAY_UNSUPPORTED
+} BaconVideoWidgetCanPlayStatus;
+
+BaconVideoWidgetCanPlayStatus bacon_video_widget_can_play
+                                                (BaconVideoWidget *bvw,
                                                  TotemDiscMediaType type);
 
 gchar **bacon_video_widget_get_mrls             (BaconVideoWidget *bvw,

Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c   (original)
+++ trunk/src/totem.c   Fri Feb  8 20:52:09 2008
@@ -481,15 +481,22 @@
        char **mrls;
        char *msg;
        gboolean retval;
+       BaconVideoWidgetCanPlayStatus status;
 
-       if (bacon_video_widget_can_play (totem->bvw, type) == FALSE) {
-               if (type == MEDIA_TYPE_DVD || type == MEDIA_TYPE_VCD)
+       status = bacon_video_widget_can_play (totem->bvw, type);
+
+       if (status != BVW_CAN_PLAY_SUCCESS) {
+               if (status == BVW_CAN_PLAY_MISSING_CHANNELS) {
+                       //FIXME we need to launch the scanner
+                       return FALSE;
+               } else if (status == BVW_CAN_PLAY_UNSUPPORTED) {
+                       msg = g_strdup_printf(_("Totem cannot play this type of 
media (%s) because it is not supported."), _(totem_cd_get_human_readable_name 
(type)));
+               } else if (status == BVW_CAN_PLAY_MISSING_PLUGINS) {
                        msg = g_strdup_printf(_("Totem cannot play this type of 
media (%s) because it does not have the appropriate plugins to be able to read 
from the disc."), _(totem_cd_get_human_readable_name (type)));
-               else
-                       msg = g_strdup_printf (_("Totem cannot play this type 
of media (%s) because you do not have the appropriate plugins to handle it."), 
_(totem_cd_get_human_readable_name (type)));
-               totem_interface_error_with_link (msg, _("Please install the 
necessary plugins and restart Totem to be able to play this media."),
-                               "http://www.gnome.org/projects/totem/#codecs";, 
_("More information about media plugins"),
-                               GTK_WINDOW (totem->win), totem);
+                       totem_interface_error_with_link (msg, _("Please install 
the necessary plugins and restart Totem to be able to play this media."),
+                                                        
"http://www.gnome.org/projects/totem/#codecs";, _("More information about media 
plugins"),
+                                                        GTK_WINDOW 
(totem->win), totem);
+               }
                g_free (msg);
                return FALSE;
        }
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit 
your options and select the modules ('topics') you want.
Module maintainer? It is possible to set the reply-to to your development 
mailing list. Email [EMAIL PROTECTED] if interested.

Reply via email to