Bug#233134: tag 233134 patch

Matt Kraai Matt Kraai <kraai@ftbfs.org>, 233134@bugs.debian.org
Thu, 29 Jul 2004 14:18:10 -0700


--T6xhMxlHU34Bk0ad
Content-Type: multipart/mixed; boundary="EP0wieDxd4TSJjHq"
Content-Disposition: inline


--EP0wieDxd4TSJjHq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

tag 233134 patch
thanks

The attached patch should fix this bug.

--=20
Matt Kraai            kraai@ftbfs.org            http://ftbfs.org/

--EP0wieDxd4TSJjHq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch
Content-Transfer-Encoding: quoted-printable

diff -ru sound-juicer-0.5.12.orig/src/sj-extracting.c sound-juicer-0.5.12/s=
rc/sj-extracting.c
--- sound-juicer-0.5.12.orig/src/sj-extracting.c	2004-06-01 02:53:47.000000=
000 -0700
+++ sound-juicer-0.5.12/src/sj-extracting.c	2004-07-29 13:02:32.000000000 -=
0700
@@ -435,7 +435,7 @@
   /* If we eject when finished, eject now, otherwise add a button */
   if (eject_finished) {
     eject_cdrom (device, GTK_WINDOW (main_window));
-  } else {
+  } else if (can_eject (device)) {
     gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Eject"), 2, NULL);
   }
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
diff -ru sound-juicer-0.5.12.orig/src/sj-main.c sound-juicer-0.5.12/src/sj-=
main.c
--- sound-juicer-0.5.12.orig/src/sj-main.c	2004-06-01 03:08:03.000000000 -0=
700
+++ sound-juicer-0.5.12/src/sj-main.c	2004-07-29 11:29:20.000000000 -0700
@@ -56,7 +56,7 @@
 static GtkWidget *title_entry, *artist_entry, *duration_label;
 static GtkWidget *track_listview, *extract_button;
 static GtkWidget *status_bar;
-static GtkWidget *extract_menuitem, *select_all_menuitem, *deselect_all_me=
nuitem;
+static GtkWidget *extract_menuitem, *eject_menuitem, *select_all_menuitem,=
 *deselect_all_menuitem;
 GtkListStore *track_store;
=20
 const char *base_path, *path_pattern, *file_pattern;
@@ -921,6 +921,7 @@
   select_all_menuitem =3D glade_xml_get_widget (glade, "select_all");
   deselect_all_menuitem =3D glade_xml_get_widget (glade, "deselect_all");
   extract_menuitem =3D glade_xml_get_widget (glade, "extract_menuitem");
+  eject_menuitem =3D glade_xml_get_widget (glade, "eject_menuitem");
   title_entry =3D glade_xml_get_widget (glade, "title_entry");
   artist_entry =3D glade_xml_get_widget (glade, "artist_entry");
   duration_label =3D glade_xml_get_widget (glade, "duration_label");
@@ -1003,6 +1004,9 @@
   tray_opened =3D tray_is_opened (device);
   poll_id =3D g_timeout_add (2000, poll_tray_opened, NULL);
=20
+  if (!can_eject (device))
+    gtk_widget_set_sensitive (eject_menuitem, FALSE);
+
   gtk_main ();
   g_object_unref (metadata);
   g_object_unref (extractor);
diff -ru sound-juicer-0.5.12.orig/src/sj-util.c sound-juicer-0.5.12/src/sj-=
util.c
--- sound-juicer-0.5.12.orig/src/sj-util.c	2004-05-28 04:01:03.000000000 -0=
700
+++ sound-juicer-0.5.12/src/sj-util.c	2004-07-29 14:15:44.000000000 -0700
@@ -95,6 +95,23 @@
 #include <gtk/gtklabel.h>
=20
 /**
+ * Is the CD-ROM drive capable of ejecting.
+ */
+gboolean
+can_eject (const char* device)
+{
+  int fd, result;
+  fd =3D open (device, O_RDONLY | O_NONBLOCK);
+  if (fd =3D=3D -1)
+    return FALSE;
+  result =3D ioctl (fd, CDROM_GET_CAPABILITY);
+  if (result =3D=3D -1)
+    return FALSE;
+  else
+    return (result & CDC_OPEN_TRAY) !=3D 0;
+}
+
+/**
  * Eject a CD-ROM, displaying any errors in a dialog.
  */
 void
diff -ru sound-juicer-0.5.12.orig/src/sj-util.h sound-juicer-0.5.12/src/sj-=
util.h
--- sound-juicer-0.5.12.orig/src/sj-util.h	2003-09-30 02:52:40.000000000 -0=
700
+++ sound-juicer-0.5.12/src/sj-util.h	2004-07-29 13:04:10.000000000 -0700
@@ -29,6 +29,8 @@
=20
 void mkdir_recursive (const char *path, mode_t permission_bits, GError **e=
rror);
=20
+gboolean can_eject (const char* device);
+
 void eject_cdrom (const char* device, GtkWindow *parent);
=20
 gboolean tray_is_opened (const char *device);

--EP0wieDxd4TSJjHq--

--T6xhMxlHU34Bk0ad
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBCWmRfNdgYxVXvBARAoWaAKCCxvlGTj3n9rF9pWgSrxCe2DXFYACgnqwj
W1eMn/InQ/ef+9ivxJLolkI=
=TTuC
-----END PGP SIGNATURE-----

--T6xhMxlHU34Bk0ad--