[brasero] Move code for checking missing elements for plugins to BraseroBurn and add a signal
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Move code for checking missing elements for plugins to BraseroBurn and add a signal
- Date: Sun, 29 Nov 2009 21:37:03 +0000 (UTC)
commit 84eccd54a35d62bcd02519c7ed31d96afc7c2547
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Sun Nov 29 22:33:53 2009 +0100
Move code for checking missing elements for plugins to BraseroBurn and add a signal
Check beforehand if session could be run even if it had these missing items to avoid inconsistent error message
libbrasero-burn/brasero-burn-dialog.c | 183 +++++++++++--------------------
libbrasero-burn/brasero-burn.c | 100 +++++++++++++++++
libbrasero-burn/brasero-burn.h | 4 +
libbrasero-burn/brasero-error.h | 2 +
libbrasero-burn/libbrasero-marshal.list | 1 +
5 files changed, 171 insertions(+), 119 deletions(-)
---
diff --git a/libbrasero-burn/brasero-burn-dialog.c b/libbrasero-burn/brasero-burn-dialog.c
index 8a0c273..9ec5ef4 100644
--- a/libbrasero-burn/brasero-burn-dialog.c
+++ b/libbrasero-burn/brasero-burn-dialog.c
@@ -1461,6 +1461,66 @@ brasero_burn_dialog_activity_stop (BraseroBurnDialog *dialog,
}
static BraseroBurnResult
+brasero_burn_dialog_install_missing_cb (BraseroBurn *burn,
+ BraseroPluginErrorType type,
+ const gchar *detail,
+ gpointer user_data)
+{
+ BraseroBurnDialogPrivate *priv = BRASERO_BURN_DIALOG_PRIVATE (user_data);
+ GCancellable *cancel;
+ BraseroPK *package;
+ GdkWindow *window;
+ gboolean res;
+ int xid = 0;
+
+ gtk_widget_set_sensitive (GTK_WIDGET (user_data), FALSE);
+
+ /* Get the xid */
+ window = gtk_widget_get_window (user_data);
+ xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (window));
+
+ package = brasero_pk_new ();
+ cancel = g_cancellable_new ();
+ priv->cancel_plugin = cancel;
+ switch (type) {
+ case BRASERO_PLUGIN_ERROR_MISSING_APP:
+ res = brasero_pk_install_missing_app (package, detail, xid, cancel);
+ break;
+
+ case BRASERO_PLUGIN_ERROR_MISSING_LIBRARY:
+ res = brasero_pk_install_missing_library (package, detail, xid, cancel);
+ break;
+
+ case BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN:
+ res = brasero_pk_install_gstreamer_plugin (package, detail, xid, cancel);
+ break;
+
+ default:
+ res = FALSE;
+ break;
+ }
+
+ if (package) {
+ g_object_unref (package);
+ package = NULL;
+ }
+
+ gtk_widget_set_sensitive (GTK_WIDGET (user_data), TRUE);
+ if (g_cancellable_is_cancelled (cancel)) {
+ g_object_unref (cancel);
+ return BRASERO_BURN_CANCEL;
+ }
+
+ priv->cancel_plugin = NULL;
+ g_object_unref (cancel);
+
+ if (!res)
+ return BRASERO_BURN_ERR;
+
+ return BRASERO_BURN_RETRY;
+}
+
+static BraseroBurnResult
brasero_burn_dialog_setup_session (BraseroBurnDialog *dialog,
GError **error)
{
@@ -1472,6 +1532,10 @@ brasero_burn_dialog_setup_session (BraseroBurnDialog *dialog,
priv->burn = brasero_burn_new ();
g_signal_connect (priv->burn,
+ "install-missing",
+ G_CALLBACK (brasero_burn_dialog_install_missing_cb),
+ dialog);
+ g_signal_connect (priv->burn,
"insert-media",
G_CALLBACK (brasero_burn_dialog_insert_disc_cb),
dialog);
@@ -2205,121 +2269,6 @@ brasero_burn_dialog_wait_for_ready_state (BraseroBurnDialog *dialog)
return (result == BRASERO_BURN_OK);
}
-static BraseroBurnResult
-brasero_burn_dialog_install_missing (BraseroPluginErrorType type,
- const gchar *detail,
- gpointer user_data)
-{
- BraseroBurnDialogPrivate *priv = BRASERO_BURN_DIALOG_PRIVATE (user_data);
- GCancellable *cancel;
- BraseroPK *package;
- gboolean res;
- int xid = 0;
-
- /* Get the xid */
- xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (GTK_WIDGET (user_data)->window));
-
- package = brasero_pk_new ();
- cancel = g_cancellable_new ();
- priv->cancel_plugin = cancel;
- switch (type) {
- case BRASERO_PLUGIN_ERROR_MISSING_APP:
- res = brasero_pk_install_missing_app (package, detail, xid, cancel);
- break;
-
- case BRASERO_PLUGIN_ERROR_MISSING_LIBRARY:
- res = brasero_pk_install_missing_library (package, detail, xid, cancel);
- break;
-
- case BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN:
- res = brasero_pk_install_gstreamer_plugin (package, detail, xid, cancel);
- break;
-
- default:
- res = FALSE;
- break;
- }
-
- if (package) {
- g_object_unref (package);
- package = NULL;
- }
-
- if (g_cancellable_is_cancelled (cancel)) {
- g_object_unref (cancel);
- return BRASERO_BURN_CANCEL;
- }
-
- priv->cancel_plugin = NULL;
- g_object_unref (cancel);
-
- if (!res)
- return BRASERO_BURN_ERR;
-
- return BRASERO_BURN_RETRY;
-}
-
-static BraseroBurnResult
-brasero_burn_dialog_list_missing (BraseroPluginErrorType type,
- const gchar *detail,
- gpointer user_data)
-{
- GString *string = user_data;
-
- if (type == BRASERO_PLUGIN_ERROR_MISSING_APP) {
- g_string_append_c (string, '\n');
- /* Translators: %s is the name of a missing application */
- g_string_append_printf (string, _("%s (application)"), detail);
- }
- else if (type == BRASERO_PLUGIN_ERROR_MISSING_LIBRARY) {
- g_string_append_c (string, '\n');
- /* Translators: %s is the name of a missing library */
- g_string_append_printf (string, _("%s (library)"), detail);
- }
- else if (type == BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN) {
- g_string_append_c (string, '\n');
- /* Translators: %s is the name of a missing Gstreamer plugin */
- g_string_append_printf (string, _("%s (Gstreamer plugin)"), detail);
- }
-
- return BRASERO_BURN_OK;
-}
-
-static gboolean
-brasero_burn_dialog_check_plugin_errors (BraseroBurnDialog *dialog)
-{
- BraseroBurnDialogPrivate *priv;
- BraseroBurnResult result;
- GString *string;
-
- priv = BRASERO_BURN_DIALOG_PRIVATE (dialog);
- gtk_widget_set_sensitive (GTK_WIDGET (dialog), FALSE);
-
- result = brasero_session_foreach_plugin_error (priv->session,
- brasero_burn_dialog_install_missing,
- dialog);
- if (result == BRASERO_BURN_CANCEL)
- return FALSE;
-
- gtk_widget_set_sensitive (GTK_WIDGET (dialog), TRUE);
-
- if (result == BRASERO_BURN_OK)
- return TRUE;
-
- string = g_string_new (_("Please install the following manually and try again:"));
- brasero_session_foreach_plugin_error (priv->session,
- brasero_burn_dialog_list_missing,
- string);
-
- brasero_utils_message_dialog (GTK_WIDGET (dialog),
- _("All required applications and libraries are not installed."),
- string->str,
- GTK_MESSAGE_ERROR);
- g_string_free (string, TRUE);
-
- return FALSE;
-}
-
/**
* brasero_burn_dialog_run:
* @dialog: a #BraseroBurnDialog
@@ -2352,10 +2301,6 @@ brasero_burn_dialog_run (BraseroBurnDialog *dialog,
if (!brasero_burn_dialog_wait_for_ready_state (dialog))
return FALSE;
- /* Make sure all plugins are ready */
- if (!brasero_burn_dialog_check_plugin_errors (dialog))
- return FALSE;
-
/* disable autoconfiguration */
if (BRASERO_IS_SESSION_CFG (priv->session))
brasero_session_cfg_disable (BRASERO_SESSION_CFG (priv->session));
diff --git a/libbrasero-burn/brasero-burn.c b/libbrasero-burn/brasero-burn.c
index e5d43bc..e9f9577 100644
--- a/libbrasero-burn/brasero-burn.c
+++ b/libbrasero-burn/brasero-burn.c
@@ -136,6 +136,7 @@ typedef enum {
ACTION_CHANGED_SIGNAL,
DUMMY_SUCCESS_SIGNAL,
EJECT_FAILURE_SIGNAL,
+ INSTALL_MISSING_SIGNAL,
LAST_SIGNAL
} BraseroBurnSignalType;
@@ -1660,6 +1661,66 @@ start:
}
static BraseroBurnResult
+brasero_burn_install_missing (BraseroPluginErrorType error,
+ const gchar *details,
+ gpointer user_data)
+{
+ GValue instance_and_params [3];
+ GValue return_value;
+
+ instance_and_params [0].g_type = 0;
+ g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (user_data));
+ g_value_set_instance (instance_and_params, user_data);
+
+ instance_and_params [1].g_type = 0;
+ g_value_init (instance_and_params + 1, G_TYPE_INT);
+ g_value_set_int (instance_and_params + 1, error);
+
+ instance_and_params [2].g_type = 0;
+ g_value_init (instance_and_params + 2, G_TYPE_STRING);
+ g_value_set_string (instance_and_params + 2, details);
+
+ return_value.g_type = 0;
+ g_value_init (&return_value, G_TYPE_INT);
+ g_value_set_int (&return_value, BRASERO_BURN_ERROR);
+
+ g_signal_emitv (instance_and_params,
+ brasero_burn_signals [INSTALL_MISSING_SIGNAL],
+ 0,
+ &return_value);
+
+ g_value_unset (instance_and_params);
+
+ return g_value_get_int (&return_value);
+}
+
+static BraseroBurnResult
+brasero_burn_list_missing (BraseroPluginErrorType type,
+ const gchar *detail,
+ gpointer user_data)
+{
+ GString *string = user_data;
+
+ if (type == BRASERO_PLUGIN_ERROR_MISSING_APP) {
+ g_string_append_c (string, '\n');
+ /* Translators: %s is the name of a missing application */
+ g_string_append_printf (string, _("%s (application)"), detail);
+ }
+ else if (type == BRASERO_PLUGIN_ERROR_MISSING_LIBRARY) {
+ g_string_append_c (string, '\n');
+ /* Translators: %s is the name of a missing library */
+ g_string_append_printf (string, _("%s (library)"), detail);
+ }
+ else if (type == BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN) {
+ g_string_append_c (string, '\n');
+ /* Translators: %s is the name of a missing Gstreamer plugin */
+ g_string_append_printf (string, _("%s (Gstreamer plugin)"), detail);
+ }
+
+ return BRASERO_BURN_OK;
+}
+
+static BraseroBurnResult
brasero_burn_check_session_consistency (BraseroBurn *burn,
BraseroTrackType *output,
GError **error)
@@ -1690,6 +1751,34 @@ brasero_burn_check_session_consistency (BraseroBurn *burn,
return BRASERO_BURN_ERR;
}
+ /* Check missing applications/GStreamer plugins.
+ * This is the best place. */
+ result = brasero_burn_session_can_burn (priv->session, FALSE);
+ if (result != BRASERO_BURN_OK)
+ return result;
+
+ result = brasero_session_foreach_plugin_error (priv->session,
+ brasero_burn_install_missing,
+ burn);
+ if (result != BRASERO_BURN_OK) {
+ if (result != BRASERO_BURN_CANCEL) {
+ GString *string;
+
+ string = g_string_new (_("Please install the following required applications and libraries manually and try again:"));
+ brasero_session_foreach_plugin_error (priv->session,
+ brasero_burn_list_missing,
+ string);
+ g_set_error (error,
+ BRASERO_BURN_ERROR,
+ BRASERO_BURN_ERROR_MISSING_APP_AND_PLUGIN,
+ string->str);
+
+ g_string_free (string, TRUE);
+ }
+
+ return BRASERO_BURN_ERR;
+ }
+
/* No need to check if a burner was set as this
* is done when locking. */
@@ -3061,6 +3150,17 @@ brasero_burn_class_init (BraseroBurnClass *klass)
brasero_marshal_INT__OBJECT,
G_TYPE_INT, 1,
BRASERO_TYPE_DRIVE);
+ brasero_burn_signals [INSTALL_MISSING_SIGNAL] =
+ g_signal_new ("install_missing",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BraseroBurnClass,
+ install_missing),
+ NULL, NULL,
+ brasero_marshal_INT__INT_STRING,
+ G_TYPE_INT, 2,
+ G_TYPE_INT,
+ G_TYPE_STRING);
}
static void
diff --git a/libbrasero-burn/brasero-burn.h b/libbrasero-burn/brasero-burn.h
index bbbfcc0..333d47a 100644
--- a/libbrasero-burn/brasero-burn.h
+++ b/libbrasero-burn/brasero-burn.h
@@ -84,6 +84,10 @@ typedef struct {
glong time_remaining);
void (*action_changed) (BraseroBurn *obj,
BraseroBurnAction action);
+
+ BraseroBurnResult (*install_missing) (BraseroBurn *obj,
+ BraseroPluginErrorType error,
+ const gchar *detail);
} BraseroBurnClass;
GType brasero_burn_get_type (void);
diff --git a/libbrasero-burn/brasero-error.h b/libbrasero-burn/brasero-error.h
index b862f11..490ee7e 100644
--- a/libbrasero-burn/brasero-error.h
+++ b/libbrasero-burn/brasero-error.h
@@ -74,6 +74,8 @@ typedef enum {
BRASERO_BURN_ERROR_BAD_CHECKSUM,
+ BRASERO_BURN_ERROR_MISSING_APP_AND_PLUGIN,
+
/* these are not necessarily error */
BRASERO_BURN_WARNING_CHECKSUM,
BRASERO_BURN_WARNING_INSERT_AFTER_COPY
diff --git a/libbrasero-burn/libbrasero-marshal.list b/libbrasero-burn/libbrasero-marshal.list
index c682022..d47f44c 100644
--- a/libbrasero-burn/libbrasero-marshal.list
+++ b/libbrasero-burn/libbrasero-marshal.list
@@ -2,6 +2,7 @@ INT:VOID
INT:INT
INT:STRING
INT:OBJECT
+INT:INT,STRING
INT:OBJECT,INT,INT
INT:POINTER,BOOLEAN
BOOLEAN:VOID
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]