[brasero] Make functions used in BraseroIO and BraseroMetadata objects use a parent window when they need to s
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Make functions used in BraseroIO and BraseroMetadata objects use a parent window when they need to s
- Date: Tue, 3 Nov 2009 13:38:27 +0000 (UTC)
commit 26e6ae807d7239520b77de0517efa84a9764409a
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Mon Nov 2 14:48:03 2009 +0100
Make functions used in BraseroIO and BraseroMetadata objects use a parent window when they need to spawn an authentification dialog for example
libbrasero-utils/brasero-io.c | 51 +++++++++++++++++++++++++++++++++-
libbrasero-utils/brasero-io.h | 8 +++++
libbrasero-utils/brasero-metadata.c | 31 ++++++++++++++++++++-
libbrasero-utils/brasero-metadata.h | 7 +++++
src/brasero-app.c | 23 +++++++++++++++
5 files changed, 117 insertions(+), 3 deletions(-)
---
diff --git a/libbrasero-utils/brasero-io.c b/libbrasero-utils/brasero-io.c
index 5a228ee..90ff491 100644
--- a/libbrasero-utils/brasero-io.c
+++ b/libbrasero-utils/brasero-io.c
@@ -42,6 +42,8 @@
#include <gio/gio.h>
+#include <gdk/gdkx.h>
+
#include <gtk/gtk.h>
#ifdef BUILD_PLAYLIST
@@ -100,6 +102,9 @@ struct _BraseroIOPrivate
guint progress_id;
GSList *progress;
+
+ BraseroIOGetParentWinCb win_callback;
+ gpointer win_user_data;
};
#define BRASERO_IO_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_IO, BraseroIOPrivate))
@@ -587,11 +592,19 @@ brasero_io_mount_enclosing_volume (BraseroIO *self,
GError **error)
{
GMount *mounted;
+ GtkWindow *parent;
+ BraseroIOPrivate *priv;
GMountOperation *operation;
BraseroIOMount mount = { NULL, };
- /* FIXME: need a way to get a parent window for the operation */
- operation = gtk_mount_operation_new (NULL);
+ priv = BRASERO_IO_PRIVATE (self);
+
+ if (priv->win_callback)
+ parent = priv->win_callback (priv->win_user_data);
+
+ if (parent)
+ operation = gtk_mount_operation_new (parent);
+
g_file_mount_enclosing_volume (file,
G_MOUNT_MOUNT_NONE,
operation,
@@ -2316,6 +2329,24 @@ brasero_io_register (GObject *object,
return base;
}
+static int
+ brasero_io_xid_for_metadata (gpointer user_data)
+{
+ BraseroIOPrivate *priv;
+
+ priv = BRASERO_IO_PRIVATE (user_data);
+ if (priv->win_callback) {
+ int xid;
+ GtkWindow *parent;
+
+ parent = priv->win_callback (priv->win_user_data);
+ xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (GTK_WIDGET (parent)->window));
+ return xid;
+ }
+
+ return 0;
+}
+
static void
brasero_io_init (BraseroIO *object)
{
@@ -2332,8 +2363,10 @@ brasero_io_init (BraseroIO *object)
* a thread. */
metadata = brasero_metadata_new ();
priv->metadatas = g_slist_prepend (priv->metadatas, metadata);
+ brasero_metadata_set_get_xid_callback (metadata, brasero_io_xid_for_metadata, object);
metadata = brasero_metadata_new ();
priv->metadatas = g_slist_prepend (priv->metadatas, metadata);
+ brasero_metadata_set_get_xid_callback (metadata, brasero_io_xid_for_metadata, object);
}
static gboolean
@@ -2452,3 +2485,17 @@ brasero_io_shutdown (void)
singleton = NULL;
}
}
+
+void
+brasero_io_set_parent_window_callback (BraseroIOGetParentWinCb callback,
+ gpointer user_data)
+{
+ BraseroIOPrivate *priv;
+ BraseroIO *self;
+
+ self = brasero_io_get_default ();
+ priv = BRASERO_IO_PRIVATE (self);
+ priv->win_callback = callback;
+ priv->win_user_data = user_data;
+ g_object_unref (self);
+}
diff --git a/libbrasero-utils/brasero-io.h b/libbrasero-utils/brasero-io.h
index 7797605..3c50f84 100644
--- a/libbrasero-utils/brasero-io.h
+++ b/libbrasero-utils/brasero-io.h
@@ -32,6 +32,7 @@
#define _BRASERO_IO_H_
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "brasero-async-task-manager.h"
@@ -161,6 +162,13 @@ brasero_io_return_result (const BraseroIOJobBase *base,
GError *error,
BraseroIOResultCallbackData *callback_data);
+
+typedef GtkWindow * (* BraseroIOGetParentWinCb) (gpointer user_data);
+
+void
+brasero_io_set_parent_window_callback (BraseroIOGetParentWinCb callback,
+ gpointer user_data);
+
void
brasero_io_shutdown (void);
diff --git a/libbrasero-utils/brasero-metadata.c b/libbrasero-utils/brasero-metadata.c
index 2fc24a7..1de0f44 100644
--- a/libbrasero-utils/brasero-metadata.c
+++ b/libbrasero-utils/brasero-metadata.c
@@ -85,6 +85,9 @@ struct BraseroMetadataPrivate {
gint listeners;
+ BraseroMetadataGetXidCb xid_callback;
+ gpointer xid_user_data;
+
guint started:1;
guint moved_forward:1;
guint prev_level_mes:1;
@@ -116,6 +119,30 @@ G_DEFINE_TYPE (BraseroMetadata, brasero_metadata, G_TYPE_OBJECT)
static GSList *downloading = NULL;
static GSList *downloaded = NULL;
+static int
+brasero_metadata_get_xid (BraseroMetadata *metadata)
+{
+ BraseroMetadataPrivate *priv;
+
+ priv = BRASERO_METADATA_PRIVATE (metadata);
+ if (!priv->xid_callback)
+ return 0;
+
+ return priv->xid_callback (priv->xid_user_data);
+}
+
+void
+brasero_metadata_set_get_xid_callback (BraseroMetadata *metadata,
+ BraseroMetadataGetXidCb callback,
+ gpointer user_data)
+{
+ BraseroMetadataPrivate *priv;
+
+ priv = BRASERO_METADATA_PRIVATE (metadata);
+ priv->xid_callback = callback;
+ priv->xid_user_data = user_data;
+}
+
struct _BraseroMetadataGstDownload {
gchar *detail;
@@ -976,8 +1003,8 @@ brasero_metadata_install_plugins_abort (BraseroMetadataGstDownload *download)
GSList *iter;
BraseroMetadataPrivate *priv;
- priv = BRASERO_METADATA_PRIVATE (iter->data);
for (iter = download->objects; iter; iter = iter->next) {
+ priv = BRASERO_METADATA_PRIVATE (iter->data);
g_error_free (priv->error);
priv->error = NULL;
@@ -1065,6 +1092,7 @@ brasero_metadata_is_downloading (const gchar *detail)
if (!strcmp (download->detail, detail))
return download;
}
+
return NULL;
}
@@ -1130,6 +1158,7 @@ brasero_metadata_install_missing_plugins (BraseroMetadata *self)
/* FIXME: we'd need the main window here to set it modal */
context = gst_install_plugins_context_new ();
+ gst_install_plugins_context_set_xid (context, brasero_metadata_get_xid (self));
status = gst_install_plugins_async ((gchar **) details->pdata,
context,
brasero_metadata_install_plugins_result,
diff --git a/libbrasero-utils/brasero-metadata.h b/libbrasero-utils/brasero-metadata.h
index 11349b3..8799642 100644
--- a/libbrasero-utils/brasero-metadata.h
+++ b/libbrasero-utils/brasero-metadata.h
@@ -147,6 +147,13 @@ gboolean
brasero_metadata_get_result (BraseroMetadata *metadata,
BraseroMetadataInfo *info,
GError **error);
+
+typedef int (*BraseroMetadataGetXidCb) (gpointer user_data);
+
+void
+brasero_metadata_set_get_xid_callback (BraseroMetadata *metadata,
+ BraseroMetadataGetXidCb callback,
+ gpointer user_data);
G_END_DECLS
#endif /* METADATA_H */
diff --git a/src/brasero-app.c b/src/brasero-app.c
index 62337b2..0ff967d 100644
--- a/src/brasero-app.c
+++ b/src/brasero-app.c
@@ -33,6 +33,7 @@
#include <unique/unique.h>
#include "brasero-misc.h"
+#include "brasero-io.h"
#include "brasero-app.h"
#include "brasero-setting.h"
@@ -1541,6 +1542,26 @@ brasero_app_run_mainwin (BraseroApp *app)
return TRUE;
}
+static GtkWindow *
+brasero_app_get_io_parent_window (gpointer user_data)
+{
+ BraseroAppPrivate *priv;
+
+ priv = BRASERO_APP_PRIVATE (user_data);
+ if (!priv->mainwin) {
+ if (priv->parent)
+ return GTK_WINDOW (priv->parent);
+ }
+ else {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (priv->mainwin));
+ return GTK_WINDOW (toplevel);
+ }
+
+ return NULL;
+}
+
static void
brasero_app_init (BraseroApp *object)
{
@@ -1557,6 +1578,8 @@ brasero_app_init (BraseroApp *object)
g_set_application_name (_("Brasero Disc Burner"));
gtk_window_set_default_icon_name ("brasero");
+
+ brasero_io_set_parent_window_callback (brasero_app_get_io_parent_window, object);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]