[Xfce4-commits] <xfburn:master> Add setting to quit right after successfully burning an image

David Mohr noreply at xfce.org
Sun Nov 18 05:56:01 CET 2012


Updating branch refs/heads/master
         to a92f2afe680e16aeed00914e7cd6739101063ad8 (commit)
       from 76303ab55ef129f09612037b87815b6f704489b3 (commit)

commit a92f2afe680e16aeed00914e7cd6739101063ad8
Author: David Mohr <david at mcbf.net>
Date:   Sat Nov 17 21:54:06 2012 -0700

    Add setting to quit right after successfully burning an image

 xfburn/xfburn-burn-image-dialog.c |   16 ++++++++++++++--
 xfburn/xfburn-progress-dialog.c   |   34 ++++++++++++++++++++++++++++++++++
 xfburn/xfburn-progress-dialog.h   |    2 ++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/xfburn/xfburn-burn-image-dialog.c b/xfburn/xfburn-burn-image-dialog.c
index 0ca304f..44e5d12 100644
--- a/xfburn/xfburn-burn-image-dialog.c
+++ b/xfburn/xfburn-burn-image-dialog.c
@@ -50,6 +50,7 @@ typedef struct {
   gboolean eject;
   gboolean dummy;
   gboolean burnfree;
+  gboolean quit;
 
   struct burn_disc *disc;
   struct burn_session *session;
@@ -68,6 +69,7 @@ typedef struct
 
   GtkWidget *check_eject;
   GtkWidget *check_burnfree;
+  GtkWidget *check_quit;
   GtkWidget *check_dummy;
 
   GtkWidget *burn_button;
@@ -221,6 +223,11 @@ xfburn_burn_image_dialog_init (XfburnBurnImageDialog * obj)
   gtk_widget_show (priv->check_burnfree);
   gtk_box_pack_start (GTK_BOX (vbox), priv->check_burnfree, FALSE, FALSE, BORDER);
 
+  priv->check_quit = gtk_check_button_new_with_mnemonic (_("_Quit after successful completion"));
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_quit), xfburn_settings_get_boolean("quit_after_success", FALSE));
+  gtk_widget_show (priv->check_quit);
+  gtk_box_pack_start (GTK_BOX (vbox), priv->check_quit, FALSE, FALSE, BORDER);
+
   /* action buttons */
   button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
   gtk_widget_show (button);
@@ -428,11 +435,17 @@ cb_dialog_response (XfburnBurnImageDialog * dialog, gint response_id, gpointer u
     XfburnBurnImageDialogPrivate *priv = XFBURN_BURN_IMAGE_DIALOG_GET_PRIVATE (dialog);
 
     GtkWidget *dialog_progress;
+    gboolean quit;
 
     dialog_progress = xfburn_progress_dialog_new (GTK_WINDOW (dialog));
     gtk_window_set_transient_for (GTK_WINDOW (dialog_progress), gtk_window_get_transient_for (GTK_WINDOW (dialog)));
     gtk_widget_hide (GTK_WIDGET (dialog));
-    
+
+    quit = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(priv->check_quit));
+    xfburn_settings_set_boolean ("quit_after_success", quit);
+
+    g_object_set (G_OBJECT (dialog_progress), "quit", quit, NULL);
+
     priv->params->dialog_progress = dialog_progress;
     gtk_widget_show (dialog_progress);
     
@@ -588,7 +601,6 @@ cb_clicked_ok (GtkButton *button, gpointer user_data)
   }
 }
 
-
 /* public */
 GtkWidget *
 xfburn_burn_image_dialog_new (void)
diff --git a/xfburn/xfburn-progress-dialog.c b/xfburn/xfburn-progress-dialog.c
index 1272e03..1448bf4 100644
--- a/xfburn/xfburn-progress-dialog.c
+++ b/xfburn/xfburn-progress-dialog.c
@@ -38,6 +38,11 @@
 
 #define XFBURN_PROGRESS_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFBURN_TYPE_PROGRESS_DIALOG, XfburnProgressDialogPrivate))
 
+enum {
+  BURNING_DONE,
+  LAST_SIGNAL,
+};
+
 /* struct */
 typedef struct
 {
@@ -46,6 +51,7 @@ typedef struct
   gboolean animate;
   int ani_index;
   gboolean stop;
+  gboolean quit;
   
   GtkWidget *label_action;
   GtkWidget *progress_bar;
@@ -59,6 +65,8 @@ typedef struct
 } XfburnProgressDialogPrivate;
 
 /* globals */
+static guint signals[LAST_SIGNAL];
+
 static void xfburn_progress_dialog_class_init (XfburnProgressDialogClass * klass);
 static void xfburn_progress_dialog_init (XfburnProgressDialog * sp);
 
@@ -80,6 +88,7 @@ enum
   PROP_STATUS,
   PROP_SHOW_BUFFERS,
   PROP_ANIMATE,
+  PROP_QUIT,
   PROP_STOP,
 };
 
@@ -157,9 +166,17 @@ xfburn_progress_dialog_class_init (XfburnProgressDialogClass * klass)
   g_object_class_install_property (object_class, PROP_ANIMATE,
                                    g_param_spec_boolean ("animate", "Show an animation", "Show an animation",
                                                          FALSE, G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_QUIT,
+                                   g_param_spec_boolean ("quit", "Quit", "Quit after successful completion",
+                                                         FALSE, G_PARAM_READWRITE));
   g_object_class_install_property (object_class, PROP_STOP,
                                    g_param_spec_boolean ("stop", "Stop the burning process", "Stop the burning process",
                                                          FALSE, G_PARAM_READABLE));
+  /* signals */
+  signals[BURNING_DONE] = g_signal_new ("burning-done", XFBURN_TYPE_PROGRESS_DIALOG, G_SIGNAL_ACTION,
+                                          G_STRUCT_OFFSET (XfburnProgressDialogClass, burning_done),
+                                          NULL, NULL, g_cclosure_marshal_VOID__VOID,
+                                          G_TYPE_NONE, 0);
 }
 
 static void
@@ -262,6 +279,9 @@ xfburn_progress_dialog_get_property (GObject * object, guint prop_id, GValue * v
   case PROP_ANIMATE:
     g_value_set_boolean (value, priv->animate);
     break;
+  case PROP_QUIT:
+    g_value_set_boolean (value, priv->quit);
+    break;
   case PROP_STOP:
     g_value_set_boolean (value, priv->stop);
     break;
@@ -289,6 +309,9 @@ xfburn_progress_dialog_set_property (GObject * object, guint prop_id, const GVal
     priv->ani_index = 0;
     //DBG ("Set animate to %d", priv->animate);
     break;
+  case PROP_QUIT:
+    priv->quit = g_value_get_boolean (value);
+    break;
   case PROP_STOP:
     DBG ("this should not be allowed...");
     priv->stop = g_value_get_boolean (value);
@@ -528,6 +551,9 @@ xfburn_progress_dialog_set_progress_bar_fraction (XfburnProgressDialog * dialog,
     case XFBURN_PROGRESS_DIALOG_STATUS_RUNNING:
       text = g_strdup ("100%");
       break;
+    case XFBURN_PROGRESS_DIALOG_STATUS_META_DONE:
+      g_warning ("Invalid progress dialog state");
+      break;
     case XFBURN_PROGRESS_DIALOG_STATUS_FAILED:
       text = g_strdup (_("Failed"));
       break;
@@ -587,9 +613,17 @@ xfburn_progress_dialog_set_status (XfburnProgressDialog * dialog, XfburnProgress
 void
 xfburn_progress_dialog_set_status_with_text (XfburnProgressDialog * dialog, XfburnProgressDialogStatus status, const gchar * text)
 {
+  XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
+
   xfburn_progress_dialog_set_status (dialog, status);
+
   gdk_threads_enter ();
   set_action_text (dialog, status, text);
+  if (status > XFBURN_PROGRESS_DIALOG_STATUS_META_DONE) {
+    g_signal_emit (G_OBJECT (dialog), signals[BURNING_DONE], 0);
+    if (status == XFBURN_PROGRESS_DIALOG_STATUS_COMPLETED && priv->quit)
+      g_idle_add ((GSourceFunc) gtk_main_quit, NULL );
+  }
   gdk_threads_leave ();
 }
 
diff --git a/xfburn/xfburn-progress-dialog.h b/xfburn/xfburn-progress-dialog.h
index 7c1e47e..386c9f8 100644
--- a/xfburn/xfburn-progress-dialog.h
+++ b/xfburn/xfburn-progress-dialog.h
@@ -34,6 +34,7 @@ typedef enum
 {
   XFBURN_PROGRESS_DIALOG_STATUS_STOPPING,
   XFBURN_PROGRESS_DIALOG_STATUS_RUNNING,
+  XFBURN_PROGRESS_DIALOG_STATUS_META_DONE,
   XFBURN_PROGRESS_DIALOG_STATUS_FAILED,
   XFBURN_PROGRESS_DIALOG_STATUS_CANCELLED,
   XFBURN_PROGRESS_DIALOG_STATUS_COMPLETED
@@ -58,6 +59,7 @@ typedef struct
 typedef struct
 {
   GtkDialogClass parent_class;
+  void (*burning_done) (XfburnProgressDialog *progress);
 } XfburnProgressDialogClass;
 
 


More information about the Xfce4-commits mailing list