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

David Mohr squisher at xfce.org
Wed May 28 16:17:32 CEST 2008


Author: squisher
Date: 2008-05-28 14:17:32 +0000 (Wed, 28 May 2008)
New Revision: 4854

Modified:
   xfburn/trunk/xfburn/xfburn-burn-data-composition-base-dialog.c
   xfburn/trunk/xfburn/xfburn-device-box.c
   xfburn/trunk/xfburn/xfburn-device-box.h
Log:
Cleaning up setting of status label, make label grayed out when insensitive

Modified: xfburn/trunk/xfburn/xfburn-burn-data-composition-base-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-burn-data-composition-base-dialog.c	2008-05-28 13:25:41 UTC (rev 4853)
+++ xfburn/trunk/xfburn/xfburn-burn-data-composition-base-dialog.c	2008-05-28 14:17:32 UTC (rev 4854)
@@ -308,6 +308,7 @@
   gboolean valid_disc;
 
   gtk_widget_set_sensitive (priv->frame_device, !gtk_toggle_button_get_active (button));
+  xfburn_device_box_set_sensitive (XFBURN_DEVICE_BOX (priv->device_box), !gtk_toggle_button_get_active (button));
   
   gtk_widget_set_sensitive (priv->hbox_iso, gtk_toggle_button_get_active (button));
   gtk_widget_set_sensitive (priv->check_eject, !gtk_toggle_button_get_active (button));

Modified: xfburn/trunk/xfburn/xfburn-device-box.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-box.c	2008-05-28 13:25:41 UTC (rev 4853)
+++ xfburn/trunk/xfburn/xfburn-device-box.c	2008-05-28 14:17:32 UTC (rev 4854)
@@ -88,6 +88,7 @@
   GtkWidget *combo_speed;
 
   GtkWidget *status_label;
+  gchar *status_text;
 
   GtkWidget *hbox_mode_selection;
   GtkWidget *combo_mode;
@@ -107,6 +108,7 @@
 static void xfburn_device_box_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
 static void xfburn_device_box_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 
+static void status_label_update (XfburnDeviceBoxPrivate *priv);
 static void update_status_label_visibility ();
 static XfburnDevice * get_selected_device (XfburnDeviceBoxPrivate *priv);
 static void cb_speed_refresh_clicked (GtkButton *button, XfburnDeviceBox *box);
@@ -302,6 +304,7 @@
 
   /* status label */
   priv->status_label = gtk_label_new ("");
+  priv->status_text = "";
   gtk_widget_show (priv->status_label);
   gtk_box_pack_start (GTK_BOX (box), priv->status_label, FALSE, FALSE, 0);
 
@@ -507,6 +510,25 @@
   gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combo_speed), gtk_tree_model_iter_n_children (model, NULL) - 1);
 }
 
+static void
+status_label_update (XfburnDeviceBoxPrivate *priv)
+{
+  gchar * text;
+  gboolean sensitive;
+
+  sensitive = GTK_WIDGET_SENSITIVE (priv->combo_device);
+
+  //DBG ("sensitive = %d", sensitive);
+
+  if (sensitive)
+    text = g_strdup_printf ("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">%s</span>", priv->status_text);
+  else
+    text = g_strdup_printf ("<span weight=\"bold\" foreground=\"gray\" stretch=\"semiexpanded\">%s</span>", priv->status_text);
+
+  gtk_label_set_markup (GTK_LABEL(priv->status_label), text);
+  g_free (text);
+}
+
 static gboolean
 check_disc_validity (XfburnDeviceBoxPrivate *priv)
 {
@@ -522,21 +544,26 @@
     if (!priv->valid_disc) {
       switch (disc_status) {
         case BURN_DISC_EMPTY:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Drive is empty!</span>"));
+          priv->status_text = _("Drive is empty!");
+          status_label_update (priv);
           break;
         case BURN_DISC_FULL:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Inserted disc is full!</span>"));
+          priv->status_text = _("Inserted disc is full!");
+          status_label_update (priv);
           break;
         case BURN_DISC_UNSUITABLE:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Inserted disc is unsuitable!</span>"));
+          priv->status_text = _("Inserted disc is unsuitable!");
+          status_label_update (priv);
           break;
         case BURN_DISC_UNGRABBED:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">No access to drive (mounted?)</span>"));
+          priv->status_text = _("No access to drive (mounted?)");
+          status_label_update (priv);
           break;
         default:
           /* if there is no detected device, then don't print an error message as it is expected to not have a disc status */
           if (get_selected_device (priv) != NULL) {
-            gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Error determining disc!</span>"));
+            priv->status_text = _("Error determining disc!");
+            status_label_update (priv);
             DBG ("weird disc_status = %d", disc_status);
           }
       }
@@ -551,27 +578,34 @@
         case XFBURN_PROFILE_DVD_MINUS_R_DL:
         case XFBURN_PROFILE_DVD_PLUS_R:
         case XFBURN_PROFILE_DVD_PLUS_R_DL:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Write-once disc, no blanking possible</span>"));
+          priv->status_text = _("Write-once disc, no blanking possible");
+          status_label_update (priv);
           break;
         case XFBURN_PROFILE_DVD_PLUS_RW:
-          gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">DVD+RW does not need blanking</span>"));
+          priv->status_text = _("DVD+RW does not need blanking");
+          status_label_update (priv);
           break;
         default:
           switch (disc_status) {
             case BURN_DISC_EMPTY:
-              gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Drive is empty!</span>"));
+              priv->status_text = _("Drive is empty!");
+              status_label_update (priv);
               break;
             case BURN_DISC_BLANK:
-              gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Inserted disc is already blank!</span>"));
+              priv->status_text = _("Inserted disc is already blank!");
+              status_label_update (priv);
               break;
             case BURN_DISC_UNSUITABLE:
-              gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Inserted disc is unsuitable!</span>"));
+              priv->status_text = _("Inserted disc is unsuitable!");
+              status_label_update (priv);
               break;
             case BURN_DISC_UNGRABBED:
-              gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">No access to drive (mounted?)</span>"));
+              priv->status_text = _("No access to drive (mounted?)");
+              status_label_update (priv);
               break;
             default:
-              gtk_label_set_markup (GTK_LABEL(priv->status_label), _("<span weight=\"bold\" foreground=\"darkred\" stretch=\"semiexpanded\">Error determining disc!</span>"));
+              priv->status_text = _("Error determining disc!");
+              status_label_update (priv);
               DBG ("weird disc_status = %d", disc_status);
           }
       }
@@ -580,7 +614,8 @@
 
   gtk_widget_set_sensitive (priv->combo_speed, priv->valid_disc);
   if (priv->valid_disc)
-    gtk_label_set_text (GTK_LABEL(priv->status_label), "");
+    priv->status_text = _("");
+    status_label_update (priv);
   return priv->valid_disc;
 }
 
@@ -753,6 +788,17 @@
   return speed;
 }
 
+void xfburn_device_box_set_sensitive (XfburnDeviceBox *box, gboolean sensitivity)
+{
+  XfburnDeviceBoxPrivate *priv = XFBURN_DEVICE_BOX_GET_PRIVATE (box);
+
+  /* why do we need to explicitly set this? It gets grayed out even
+   * without this call! */
+  gtk_widget_set_sensitive (priv->combo_device, sensitivity);
+  //DBG ("sensitive = %d", GTK_WIDGET_SENSITIVE (GTK_WIDGET (box)));
+  status_label_update (priv);
+}
+
 XfburnWriteMode
 xfburn_device_box_get_mode (XfburnDeviceBox *box)
 {

Modified: xfburn/trunk/xfburn/xfburn-device-box.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-box.h	2008-05-28 13:25:41 UTC (rev 4853)
+++ xfburn/trunk/xfburn/xfburn-device-box.h	2008-05-28 14:17:32 UTC (rev 4854)
@@ -82,8 +82,8 @@
 XfburnDevice *xfburn_device_box_get_selected_device (XfburnDeviceBox *box);
 
 gint xfburn_device_box_get_speed (XfburnDeviceBox *box);
-
 XfburnWriteMode xfburn_device_box_get_mode (XfburnDeviceBox *box);
+void xfburn_device_box_set_sensitive (XfburnDeviceBox *box, gboolean sensitivity);
 
 G_END_DECLS
 #endif




More information about the Goodies-commits mailing list