[Goodies-commits] r4721 - xfburn/trunk/xfburn

David Mohr squisher at xfce.org
Sun May 4 03:22:55 CEST 2008


Author: squisher
Date: 2008-05-04 01:22:55 +0000 (Sun, 04 May 2008)
New Revision: 4721

Modified:
   xfburn/trunk/xfburn/xfburn-device-box.c
   xfburn/trunk/xfburn/xfburn-device-list.c
   xfburn/trunk/xfburn/xfburn-device-list.h
Log:
Bugfixes:
 * Allow refresh of disc when blanking
 * Don't allow refresh when there is no detected drive
Keep track of disc profile.


Modified: xfburn/trunk/xfburn/xfburn-device-box.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-box.c	2008-05-04 00:51:17 UTC (rev 4720)
+++ xfburn/trunk/xfburn/xfburn-device-box.c	2008-05-04 01:22:55 UTC (rev 4721)
@@ -203,6 +203,7 @@
   GList *device = NULL;
   GtkListStore *store = NULL;
   GtkCellRenderer *cell;
+  GtkWidget *hbox;
   
   /* devices */
   store = gtk_list_store_new (DEVICE_N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
@@ -226,11 +227,16 @@
 
     device = g_list_next (device);
   }
+  gtk_widget_set_sensitive (priv->combo_device, device != NULL);
   
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox);
+  gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, BORDER);
+
   /* speed */
   priv->hbox_speed_selection = gtk_hbox_new (FALSE, 0);
   gtk_widget_show (priv->hbox_speed_selection);
-  gtk_box_pack_start (GTK_BOX (box), priv->hbox_speed_selection, FALSE, FALSE, BORDER);
+  gtk_box_pack_start (GTK_BOX (hbox), priv->hbox_speed_selection, TRUE, TRUE, BORDER);
 
   label = gtk_label_new_with_mnemonic (_("_Speed:"));
   gtk_widget_show (label);
@@ -246,12 +252,15 @@
   gtk_widget_show (priv->combo_speed);
   gtk_box_pack_start (GTK_BOX (priv->hbox_speed_selection), priv->combo_speed, TRUE, TRUE, BORDER);
 
+  /* refresh */
   img = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_SMALL_TOOLBAR);
   gtk_widget_show (img);
   button = gtk_button_new ();
   gtk_container_add (GTK_CONTAINER (button), img);
   gtk_widget_show (button);
-  gtk_box_pack_start (GTK_BOX (priv->hbox_speed_selection), button, FALSE, FALSE, 0);
+  //gtk_box_pack_start (GTK_BOX (priv->hbox_speed_selection), button, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+  gtk_widget_set_sensitive (button, device != NULL);
 
   g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (cb_speed_refresh_clicked), box);
 
@@ -273,6 +282,7 @@
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combo_mode), cell, "text", MODE_TEXT_COLUMN, NULL);
   gtk_widget_show (priv->combo_mode);
   gtk_box_pack_start (GTK_BOX (priv->hbox_mode_selection), priv->combo_mode, TRUE, TRUE, BORDER);
+  gtk_widget_set_sensitive (priv->combo_mode, device != NULL);
 
   /* status label */
   priv->status_label = gtk_label_new ("");
@@ -485,6 +495,7 @@
 check_disc_validity (XfburnDeviceBoxPrivate *priv)
 {
   enum burn_disc_status disc_status = xfburn_device_list_get_disc_status ();
+  //int media_no = xfburn_device_list_get_media_no ();
 
   if (!priv->blank_mode) {
     priv->valid_disc = (disc_status == BURN_DISC_BLANK) || (disc_status == BURN_DISC_APPENDABLE);
@@ -605,10 +616,9 @@
   XfburnDevice *device = NULL;
   
   device = xfburn_device_box_get_selected_device (box);
-  xfburn_device_refresh_supported_speeds (device);
+  if (xfburn_device_refresh_supported_speeds (device))
+    fill_combo_speed (box, device);
 
-  fill_combo_speed (box, device);
-
   g_signal_emit (G_OBJECT (box), signals[DISC_REFRESHED], 0, device);
 }
 

Modified: xfburn/trunk/xfburn/xfburn-device-list.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-list.c	2008-05-04 00:51:17 UTC (rev 4720)
+++ xfburn/trunk/xfburn/xfburn-device-list.c	2008-05-04 01:22:55 UTC (rev 4721)
@@ -38,6 +38,7 @@
 
 static GList *devices = NULL;
 static enum burn_disc_status disc_status;
+static int media_no = 0;
 
 #define CAN_BURN_CONDITION device->cdr || device->cdrw || device->dvdr || device->dvdram
 #define DEVICE_INFO_PRINTF "%s can burn: %d [cdr: %d, cdrw: %d, dvdr: %d, dvdram: %d]", device->name, CAN_BURN_CONDITION, device->cdr, device->cdrw, device->dvdr, device->dvdram
@@ -78,12 +79,12 @@
   return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b);
 }
 
+/* FIXME: rename function, as it is doing more than refresh speed */
 static void
 refresh_supported_speeds (XfburnDevice * device, struct burn_drive_info *drive_info)
 {
   struct burn_speed_descriptor *speed_list = NULL;
   char media_name[80];
-  int media_no;
   int factor;
   gint ret;
   //int i;
@@ -104,8 +105,14 @@
     disc_status = burn_disc_get_status (drive_info->drive);
   }
   */
+  DBG ("disc_status = %d", disc_status);
 
-  DBG ("disc_status = %d", disc_status);
+  if ((ret = burn_disc_get_profile(drive_info->drive, &media_no, media_name)) != 1) {
+    g_warning ("no profile could be retrieved");
+    media_no = 0;
+  }
+  DBG ("media_no = %d (%s), %s erasable", media_no, media_name, (burn_disc_erasable (drive_info->drive) ? "" : "NOT"));
+
   if (!(disc_status == BURN_DISC_BLANK || disc_status == BURN_DISC_APPENDABLE)) {
     DBG ("no writable / appendable disc found in drive, speed list not updated");
     return;
@@ -118,7 +125,7 @@
   if (ret > 0 && speed_list != NULL) {
     struct burn_speed_descriptor *el = speed_list;
     /* retrieve media type, so we can convert from 'kb/s' into 'x' rating */
-    if (burn_disc_get_profile(drive_info->drive, &media_no, media_name) == 1) {
+    if (media_no != 0) {
       /* this will fail if newer disk types get supported */
       if (media_no <= 0x0a)
         factor = CDR_1X_SPEED;
@@ -126,8 +133,6 @@
         /* assume DVD for now */
         factor = DVD_1X_SPEED;
     } else {
-      
-      g_warning ("no profile could be retrieved to calculate speed");
       factor = 1;
     }
 
@@ -169,12 +174,23 @@
   return disc_status;
 }
 
+int
+xfburn_device_list_get_media_no ()
+{
+  return media_no;
+}
+
 gboolean
 xfburn_device_refresh_supported_speeds (XfburnDevice * device)
 {
   struct burn_drive_info *drive_info = NULL;
   gboolean ret;
 
+  if (G_UNLIKELY (device == NULL)) {
+    DBG ("Hmm, why can we refresh when there is no drive?");
+    return FALSE;
+  }
+
   if (!burn_initialize ()) {
     g_critical ("Unable to initialize libburn");
     return FALSE;

Modified: xfburn/trunk/xfburn/xfburn-device-list.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-list.h	2008-05-04 00:51:17 UTC (rev 4720)
+++ xfburn/trunk/xfburn/xfburn-device-list.h	2008-05-04 01:22:55 UTC (rev 4721)
@@ -52,6 +52,7 @@
 XfburnDevice * xfburn_device_lookup_by_name (const gchar * name);
 GList * xfburn_device_list_get_list ();
 enum burn_disc_status xfburn_device_list_get_disc_status ();
+int xfburn_device_list_get_media_no ();
 void xfburn_device_list_free ();
 
 gboolean xfburn_device_refresh_supported_speeds (XfburnDevice * device);




More information about the Goodies-commits mailing list