brasero r613 - in trunk: . src



Author: lmedinas
Date: Mon Jan 21 21:37:07 2008
New Revision: 613
URL: http://svn.gnome.org/viewvc/brasero?rev=613&view=rev

Log:
2008-01-21  Luis Medinas  <lmedinas svn gnome org>

        * src/Makefile.am:
        * src/brasero-eject-dialog.c: 
(brasero_eject_dialog_drive_changed),
        (_eject_async), (brasero_eject_dialog_activate),
        (brasero_eject_dialog_class_init), (brasero_eject_dialog_init),
        (brasero_eject_dialog_new):
        * src/brasero-eject-dialog.h:
        * src/brasero-menu.h:
        * src/main.c: (on_eject_cb), (brasero_app_add_recent):

        Initial import of the eject dialog tool.
        Also limit the recent files to 5.



Added:
   trunk/src/brasero-eject-dialog.c
   trunk/src/brasero-eject-dialog.h
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/brasero-menu.h
   trunk/src/main.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Jan 21 21:37:07 2008
@@ -58,6 +58,8 @@
 	brasero-disc-copy-dialog.h         \
 	brasero-blank-dialog.c         \
 	brasero-blank-dialog.h         \
+	brasero-eject-dialog.c		\
+	brasero-eject-dialog.h		\
 	brasero-metadata.c         \
 	brasero-metadata.h         \
 	brasero-filtered-window.c         \

Added: trunk/src/brasero-eject-dialog.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-eject-dialog.c	Mon Jan 21 21:37:07 2008
@@ -0,0 +1,139 @@
+/***************************************************************************
+ *            
+ *
+ *  Copyright  2008  Philippe Rouquier <brasero-app wanadoo fr>
+ *  Copyright  2008  Luis Medinas <lmedinas gmail com>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+
+#include <nautilus-burn-drive.h>
+
+#include "brasero-eject-dialog.h"
+#include "brasero-tool-dialog.h"
+#include "brasero-ncb.h"
+#include "burn-debug.h"
+#include "brasero-utils.h"
+#include "burn.h"
+
+G_DEFINE_TYPE (BraseroEjectDialog, brasero_eject_dialog, BRASERO_TYPE_TOOL_DIALOG);
+
+static void
+brasero_eject_dialog_drive_changed (BraseroToolDialog *dialog,
+				    NautilusBurnDrive *drive)
+{
+	brasero_tool_dialog_set_valid (dialog, BRASERO_MEDIUM_VALID (NCB_MEDIA_GET_STATUS (drive)));
+}
+
+static gpointer
+_eject_async (gpointer data)
+{
+	NautilusBurnDrive *drive = NAUTILUS_BURN_DRIVE (data);
+
+	nautilus_burn_drive_eject (drive);
+	nautilus_burn_drive_unref (drive);
+
+	return NULL;
+}
+
+static gboolean
+brasero_eject_dialog_activate (BraseroToolDialog *dialog,
+			       NautilusBurnDrive *drive)
+{
+	/* In here we could also remove the lock held by any app (including 
+	 * brasero) through nautilus_burn_drive_unlock. We'd need a warning
+	 * dialog though which would identify why the lock is held and even
+	 * better which application is holding the lock so the user does know
+	 * if he can take the risk to remove the lock. */
+
+	/* NOTE 2: we'd need also the ability to reset the drive through a SCSI
+	 * command. The problem is brasero may need to be privileged then as
+	 * cdrecord/cdrdao seem to be. */
+
+	GError *error = NULL;
+
+	BRASERO_BURN_LOG ("Asynchronous ejection");
+	nautilus_burn_drive_ref (drive);
+	g_thread_create (_eject_async, drive, FALSE, &error);
+	if (error) {
+		g_warning ("Could not create thread %s\n", error->message);
+		g_error_free (error);
+
+		nautilus_burn_drive_unref (drive);
+		nautilus_burn_drive_eject (drive);
+	}
+
+
+	/* we'd need also to check what are the results of our operations namely
+	 * if we succeded to eject. To do that, the problem is the same as above
+	 * that is, since ejection can take time (a drive needs to slow down if
+	 * it was reading before ejection), we can't check if the drive is still
+	 * closed now as ejection is not instantaneous.
+	 * A message box announcing the results of the operation would be a good
+	 * thing as well probably. */
+
+	BraseroMedia media;
+
+	media = NCB_MEDIA_GET_STATUS (brasero_burn_session_get_src_drive (dialog));
+
+
+	if (media == BRASERO_MEDIUM_NONE
+	    || (media & (BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) == 0) {
+	  	nautilus_burn_drive_unref (drive);
+		nautilus_burn_drive_eject (drive);
+	}
+	
+	return BRASERO_BURN_OK;
+}
+
+static void
+brasero_eject_dialog_class_init (BraseroEjectDialogClass *klass)
+{
+	BraseroToolDialogClass *tool_dialog_class = BRASERO_TOOL_DIALOG_CLASS (klass);
+
+	tool_dialog_class->activate = brasero_eject_dialog_activate;
+	tool_dialog_class->drive_changed = brasero_eject_dialog_drive_changed;
+}
+
+static void
+brasero_eject_dialog_init (BraseroEjectDialog *obj)
+{
+	brasero_tool_dialog_set_button (BRASERO_TOOL_DIALOG (obj),
+					_("_Eject"),
+					NULL,
+					NULL);
+}
+
+GtkWidget *
+brasero_eject_dialog_new ()
+{
+	return BRASERO_EJECT_DIALOG (g_object_new (BRASERO_TYPE_EJECT_DIALOG,
+						   "title", ("Eject Disc"),
+						   NULL));
+}
+

Added: trunk/src/brasero-eject-dialog.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-eject-dialog.h	Mon Jan 21 21:37:07 2008
@@ -0,0 +1,60 @@
+/***************************************************************************
+ *            
+ *
+ *  Copyright  2008  Philippe Rouquier <brasero-app wanadoo fr>
+ *  Copyright  2008  Luis Medinas <lmedinas gmail com>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef BRASERO_EJECT_DIALOG_H
+#define BRASERO_EJECT_DIALOG_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtkwidget.h>
+
+#include "brasero-tool-dialog.h"
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_EJECT_DIALOG         (brasero_eject_dialog_get_type ())
+#define BRASERO_EJECT_DIALOG(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_EJECT_DIALOG, BraseroEjectDialog))
+#define BRASERO_EJECT_DIALOG_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), BRASERO_TYPE_EJECT_DIALOG, BraseroEjectDialogClass))
+#define BRASERO_IS_EJECT_DIALOG(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), BRASERO_TYPE_EJECT_DIALOG))
+#define BRASERO_IS_EJECT_DIALOG_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), BRASERO_TYPE_EJECT_DIALOG))
+#define BRASERO_EJECT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), BRASERO_TYPE_EJECT_DIALOG, BraseroEjectDialogClass))
+
+typedef struct _BraseroEjectDialog BraseroEjectDialog;
+typedef struct _BraseroEjectDialogPrivate BraseroEjectDialogPrivate;
+typedef struct _BraseroEjectDialogClass BraseroEjectDialogClass;
+
+struct _BraseroEjectDialog {
+	BraseroToolDialog parent;
+};
+
+struct _BraseroEjectDialogClass {
+	BraseroToolDialogClass parent_class;
+};
+
+GType brasero_eject_dialog_get_type ();
+GtkWidget *brasero_eject_dialog_new ();
+
+G_END_DECLS
+
+#endif /* BRASERO_Eject_DIALOG_H */

Modified: trunk/src/brasero-menu.h
==============================================================================
--- trunk/src/brasero-menu.h	(original)
+++ trunk/src/brasero-menu.h	Mon Jan 21 21:37:07 2008
@@ -42,6 +42,7 @@
 #include "brasero-app.h"
 
 void on_prefs_cb (GtkAction *action, BraseroApp *app);
+void on_eject_cb (GtkAction *action, BraseroApp *app);
 void on_erase_cb (GtkAction *action, BraseroApp *app);
 void on_integrity_check_cb (GtkAction *action, BraseroApp *app);
 
@@ -61,6 +62,9 @@
 	{"Plugins", NULL, N_("P_lugins"), NULL,
 	 N_("Choose plugins for brasero"), G_CALLBACK (on_prefs_cb)},
 
+	{"Eject", NULL, N_("E_ject"), NULL,
+	 N_("Eject media"), G_CALLBACK (on_eject_cb)},
+
 	{"Erase", "media-optical-blank", N_("_Erase..."), NULL,
 	 N_("Erase a disc"), G_CALLBACK (on_erase_cb)},
 
@@ -97,6 +101,7 @@
 	    "</menu>"
 	    "<menu action='ToolMenu'>"
 		"<placeholder name='DiscPlaceholder'/>"
+		"<menuitem action='Eject'/>"
 		"<menuitem action='Erase'/>"
 		"<menuitem action='Check'/>"
 	    "</menu>"

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Mon Jan 21 21:37:07 2008
@@ -59,6 +59,7 @@
 #include "brasero-ncb.h"
 #include "brasero-pref.h"
 #include "burn-debug.h"
+#include "burn.h"
 
 static GConfClient *client;
 gchar *project_uri;
@@ -177,6 +178,23 @@
 }
 
 void
+on_eject_cb (GtkAction *action, BraseroApp *app)
+{
+       GtkWidget *dialog;
+       GtkWidget *toplevel;
+  
+       dialog = brasero_eject_dialog_new();
+       toplevel = gtk_widget_get_toplevel (app->mainwin);
+       
+       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+       gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+       gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+
+       gtk_widget_show_all (dialog);
+       
+}
+
+void
 on_integrity_check_cb (GtkAction *action, BraseroApp *app)
 {
 	GtkWidget *dialog;
@@ -390,7 +408,7 @@
 
 	gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (action), TRUE);
 
-	gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (action), 20);
+	gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (action), 5);
 
 	gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (action), TRUE);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]