[brasero] Turn BraseroStatus into a GObject to ease binding creation
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Turn BraseroStatus into a GObject to ease binding creation
- Date: Sun, 8 Nov 2009 14:01:03 +0000 (UTC)
commit f61a773a44048118f2ac5268124b3202e928eb2b
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Fri Nov 6 13:03:57 2009 +0100
Turn BraseroStatus into a GObject to ease binding creation
libbrasero-burn/brasero-burn-dialog.c | 2 +-
libbrasero-burn/brasero-session-cfg.c | 6 +-
libbrasero-burn/brasero-session.c | 4 +-
libbrasero-burn/brasero-src-image.c | 2 +-
libbrasero-burn/brasero-status-dialog.c | 8 +-
libbrasero-burn/brasero-status.c | 140 +++++++++++++++++++-------
libbrasero-burn/brasero-status.h | 29 +++++-
libbrasero-burn/brasero-track-data.h | 14 ++-
libbrasero-burn/brasero-track-type-private.h | 2 +-
src/brasero-audio-disc.c | 2 +-
src/brasero-data-disc.c | 6 +-
src/brasero-project.c | 14 ++--
src/brasero-video-disc.c | 2 +-
src/brasero-video-tree-model.c | 6 +-
14 files changed, 167 insertions(+), 70 deletions(-)
---
diff --git a/libbrasero-burn/brasero-burn-dialog.c b/libbrasero-burn/brasero-burn-dialog.c
index c0b7824..68256f9 100644
--- a/libbrasero-burn/brasero-burn-dialog.c
+++ b/libbrasero-burn/brasero-burn-dialog.c
@@ -2148,7 +2148,7 @@ brasero_burn_dialog_wait_for_ready_state (BraseroBurnDialog *dialog)
result = brasero_burn_session_get_status (priv->session, status);
}
- brasero_status_free (status);
+ g_object_unref (status);
return (result == BRASERO_BURN_OK);
}
diff --git a/libbrasero-burn/brasero-session-cfg.c b/libbrasero-burn/brasero-session-cfg.c
index cb0d0b6..c32c62f 100644
--- a/libbrasero-burn/brasero-session-cfg.c
+++ b/libbrasero-burn/brasero-session-cfg.c
@@ -1052,7 +1052,7 @@ brasero_session_cfg_update (BraseroSessionCfg *self)
status = brasero_status_new ();
result = brasero_burn_session_get_status (BRASERO_BURN_SESSION (self), status);
if (result == BRASERO_BURN_NOT_READY) {
- brasero_status_free (status);
+ g_object_unref (status);
priv->is_valid = BRASERO_SESSION_NOT_READY;
g_signal_emit (self,
@@ -1067,7 +1067,7 @@ brasero_session_cfg_update (BraseroSessionCfg *self)
error = brasero_status_get_error (status);
if (error) {
if (error->code == BRASERO_BURN_ERROR_EMPTY) {
- brasero_status_free (status);
+ g_object_unref (status);
g_error_free (error);
priv->is_valid = BRASERO_SESSION_EMPTY;
@@ -1080,7 +1080,7 @@ brasero_session_cfg_update (BraseroSessionCfg *self)
g_error_free (error);
}
}
- brasero_status_free (status);
+ g_object_unref (status);
/* Make sure there is a source */
source = brasero_track_type_new ();
diff --git a/libbrasero-burn/brasero-session.c b/libbrasero-burn/brasero-session.c
index c2a844f..ed69b1e 100644
--- a/libbrasero-burn/brasero-session.c
+++ b/libbrasero-burn/brasero-session.c
@@ -535,14 +535,14 @@ brasero_burn_session_get_status (BraseroBurnSession *session,
if (result == BRASERO_BURN_NOT_READY)
not_ready ++;
else if (result != BRASERO_BURN_OK) {
- brasero_status_free (track_status);
+ g_object_unref (track_status);
return brasero_track_get_status (track, status);
}
if (brasero_status_get_progress (track_status) != -1.0)
done += brasero_status_get_progress (track_status);
}
- brasero_status_free (track_status);
+ g_object_unref (track_status);
if (not_ready > 0) {
if (status) {
diff --git a/libbrasero-burn/brasero-src-image.c b/libbrasero-burn/brasero-src-image.c
index d066f4e..ec9d723 100644
--- a/libbrasero-burn/brasero-src-image.c
+++ b/libbrasero-burn/brasero-src-image.c
@@ -257,7 +257,7 @@ brasero_src_image_update (BraseroSrcImage *self)
end:
- brasero_status_free (status);
+ g_object_unref (status);
if (string) {
/* This is hackish and meant to avoid ellipsization to make the
* label to small. */
diff --git a/libbrasero-burn/brasero-status-dialog.c b/libbrasero-burn/brasero-status-dialog.c
index a717fa0..ffb9f84 100644
--- a/libbrasero-burn/brasero-status-dialog.c
+++ b/libbrasero-burn/brasero-status-dialog.c
@@ -164,13 +164,13 @@ brasero_status_dialog_wait_for_ready_state (BraseroStatusDialog *dialog)
if (result != BRASERO_BURN_NOT_READY) {
brasero_status_dialog_session_ready (dialog);
- brasero_status_free (status);
+ g_object_unref (status);
priv->id = 0;
return FALSE;
}
brasero_status_dialog_update (dialog, status);
- brasero_status_free (status);
+ g_object_unref (status);
return TRUE;
}
@@ -311,7 +311,7 @@ brasero_status_dialog_wait_for_session (BraseroStatusDialog *dialog)
result = brasero_burn_session_get_status (priv->session, status);
if (result != BRASERO_BURN_NOT_READY) {
brasero_status_dialog_session_ready (dialog);
- brasero_status_free (status);
+ g_object_unref (status);
return;
}
@@ -344,7 +344,7 @@ brasero_status_dialog_wait_for_session (BraseroStatusDialog *dialog)
brasero_track_type_free (track_type);
brasero_status_dialog_update (dialog, status);
- brasero_status_free (status);
+ g_object_unref (status);
priv->id = g_timeout_add (200,
(GSourceFunc) brasero_status_dialog_wait_for_ready_state,
dialog);
diff --git a/libbrasero-burn/brasero-status.c b/libbrasero-burn/brasero-status.c
index ea7f007..81d898e 100644
--- a/libbrasero-burn/brasero-status.c
+++ b/libbrasero-burn/brasero-status.c
@@ -35,27 +35,33 @@
#include "brasero-status.h"
-struct _BraseroStatus {
- BraseroBurnResult res;
- GError *error;
+typedef struct _BraseroStatusPrivate BraseroStatusPrivate;
+struct _BraseroStatusPrivate
+{
+ BraseroBurnResult res;
+ GError * error;
gdouble progress;
- gchar *current_action;
+ gchar * current_action;
};
+#define BRASERO_STATUS_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_STATUS, BraseroStatusPrivate))
+
+G_DEFINE_TYPE (BraseroStatus, brasero_status, G_TYPE_OBJECT);
+
+
/**
* brasero_status_new:
*
- * Creates a new #BraseroStatus structure.
- * Free it with brasero_status_free ().
+ * Creates a new #BraseroStatus object.
*
- * Return value: a #BraseroStatus pointer.
+ * Return value: a #BraseroStatus.
**/
BraseroStatus *
brasero_status_new (void)
{
- return g_new0 (BraseroStatus, 1);
+ return g_object_new (BRASERO_TYPE_STATUS, NULL);
}
/**
@@ -64,18 +70,14 @@ brasero_status_new (void)
*
* Frees #BraseroStatus structure.
*
+ * Deprecated since 2.29.2.
+ *
**/
-void
+G_GNUC_DEPRECATED void
brasero_status_free (BraseroStatus *status)
{
- if (status->error)
- g_error_free (status->error);
-
- if (status->current_action)
- g_free (status->current_action);
-
- g_free (status);
+ g_object_unref (status);
}
/**
@@ -94,8 +96,13 @@ brasero_status_free (BraseroStatus *status)
BraseroBurnResult
brasero_status_get_result (BraseroStatus *status)
{
+ BraseroStatusPrivate *priv;
+
g_return_val_if_fail (status != NULL, BRASERO_BURN_ERR);
- return status->res;
+ g_return_val_if_fail (BRASERO_IS_STATUS (status), BRASERO_BURN_ERR);
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+ return priv->res;
}
/**
@@ -111,14 +118,19 @@ brasero_status_get_result (BraseroStatus *status)
gdouble
brasero_status_get_progress (BraseroStatus *status)
{
+ BraseroStatusPrivate *priv;
+
g_return_val_if_fail (status != NULL, -1.0);
- if (status->res == BRASERO_BURN_OK)
+ g_return_val_if_fail (BRASERO_IS_STATUS (status), -1.0);
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+ if (priv->res == BRASERO_BURN_OK)
return 1.0;
- if (status->res != BRASERO_BURN_NOT_READY)
+ if (priv->res != BRASERO_BURN_NOT_READY)
return -1.0;
- return status->progress;
+ return priv->progress;
}
/**
@@ -134,11 +146,16 @@ brasero_status_get_progress (BraseroStatus *status)
GError *
brasero_status_get_error (BraseroStatus *status)
{
+ BraseroStatusPrivate *priv;
+
g_return_val_if_fail (status != NULL, NULL);
- if (status->res != BRASERO_BURN_ERR)
+ g_return_val_if_fail (BRASERO_IS_STATUS (status), NULL);
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+ if (priv->res != BRASERO_BURN_ERR)
return NULL;
- return g_error_copy (status->error);
+ return g_error_copy (priv->error);
}
/**
@@ -156,12 +173,17 @@ gchar *
brasero_status_get_current_action (BraseroStatus *status)
{
gchar *string;
+ BraseroStatusPrivate *priv;
g_return_val_if_fail (status != NULL, NULL);
- if (status->res != BRASERO_BURN_NOT_READY)
+ g_return_val_if_fail (BRASERO_IS_STATUS (status), NULL);
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+
+ if (priv->res != BRASERO_BURN_NOT_READY)
return NULL;
- string = g_strdup (status->current_action);
+ string = g_strdup (priv->current_action);
return string;
}
@@ -177,9 +199,15 @@ brasero_status_get_current_action (BraseroStatus *status)
void
brasero_status_set_completed (BraseroStatus *status)
{
+ BraseroStatusPrivate *priv;
+
g_return_if_fail (status != NULL);
- status->res = BRASERO_BURN_OK;
- status->progress = 1.0;
+ g_return_if_fail (BRASERO_IS_STATUS (status));
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+
+ priv->res = BRASERO_BURN_OK;
+ priv->progress = 1.0;
}
/**
@@ -199,13 +227,19 @@ brasero_status_set_not_ready (BraseroStatus *status,
gdouble progress,
const gchar *current_action)
{
+ BraseroStatusPrivate *priv;
+
g_return_if_fail (status != NULL);
- status->res = BRASERO_BURN_NOT_READY;
- status->progress = progress;
+ g_return_if_fail (BRASERO_IS_STATUS (status));
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+
+ priv->res = BRASERO_BURN_NOT_READY;
+ priv->progress = progress;
- if (status->current_action)
- g_free (status->current_action);
- status->current_action = g_strdup (current_action);
+ if (priv->current_action)
+ g_free (priv->current_action);
+ priv->current_action = g_strdup (current_action);
}
/**
@@ -221,13 +255,47 @@ void
brasero_status_set_error (BraseroStatus *status,
GError *error)
{
+ BraseroStatusPrivate *priv;
+
g_return_if_fail (status != NULL);
+ g_return_if_fail (BRASERO_IS_STATUS (status));
+
+ priv = BRASERO_STATUS_PRIVATE (status);
+
+ priv->res = BRASERO_BURN_ERR;
+ priv->progress = -1.0;
+
+ if (priv->error)
+ g_error_free (priv->error);
+ priv->error = error;
+}
+
+static void
+brasero_status_init (BraseroStatus *object)
+{}
+
+static void
+brasero_status_finalize (GObject *object)
+{
+ BraseroStatusPrivate *priv;
+
+ priv = BRASERO_STATUS_PRIVATE (object);
+ if (priv->error)
+ g_error_free (priv->error);
+
+ if (priv->current_action)
+ g_free (priv->current_action);
+
+ G_OBJECT_CLASS (brasero_status_parent_class)->finalize (object);
+}
+
+static void
+brasero_status_class_init (BraseroStatusClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
- status->res = BRASERO_BURN_ERR;
- status->progress = -1.0;
+ g_type_class_add_private (klass, sizeof (BraseroStatusPrivate));
- if (status->error)
- g_error_free (status->error);
- status->error = error;
+ object_class->finalize = brasero_status_finalize;
}
diff --git a/libbrasero-burn/brasero-status.h b/libbrasero-burn/brasero-status.h
index eca91ab..12932fa 100644
--- a/libbrasero-burn/brasero-status.h
+++ b/libbrasero-burn/brasero-status.h
@@ -32,13 +32,37 @@
#define _BRASERO_STATUS_H_
#include <glib.h>
+#include <glib-object.h>
#include <brasero-enums.h>
G_BEGIN_DECLS
+#define BRASERO_TYPE_STATUS (brasero_status_get_type ())
+#define BRASERO_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_STATUS, BraseroStatus))
+#define BRASERO_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_STATUS, BraseroStatusClass))
+#define BRASERO_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_STATUS))
+#define BRASERO_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_STATUS))
+#define BRASERO_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_STATUS, BraseroStatusClass))
+
+typedef struct _BraseroStatusClass BraseroStatusClass;
typedef struct _BraseroStatus BraseroStatus;
+struct _BraseroStatusClass
+{
+ GObjectClass parent_class;
+};
+
+struct _BraseroStatus
+{
+ GObject parent_instance;
+};
+
+GType brasero_status_get_type (void) G_GNUC_CONST;
+
+BraseroStatus *
+brasero_status_new (void);
+
typedef enum {
BRASERO_STATUS_OK = 0,
BRASERO_STATUS_ERROR,
@@ -46,10 +70,7 @@ typedef enum {
BRASERO_STATUS_INFORMATION
} BraseroStatusType;
-BraseroStatus *
-brasero_status_new (void);
-
-void
+G_GNUC_DEPRECATED void
brasero_status_free (BraseroStatus *status);
BraseroBurnResult
diff --git a/libbrasero-burn/brasero-track-data.h b/libbrasero-burn/brasero-track-data.h
index 6cf873e..9dc6816 100644
--- a/libbrasero-burn/brasero-track-data.h
+++ b/libbrasero-burn/brasero-track-data.h
@@ -37,11 +37,19 @@
G_BEGIN_DECLS
-struct _BraseroGraftPt {
+/**
+ * BraseroGraftPt:
+ * @uri: a URI
+ * @path: a file path
+ *
+ * A pair of strings describing:
+ * @uri the actual current location of the file
+ * @path the path of the file on the future ISO9660/UDF/... filesystem
+ **/
+typedef struct _BraseroGraftPt {
gchar *uri;
gchar *path;
-};
-typedef struct _BraseroGraftPt BraseroGraftPt;
+} BraseroGraftPt;
void
brasero_graft_point_free (BraseroGraftPt *graft);
diff --git a/libbrasero-burn/brasero-track-type-private.h b/libbrasero-burn/brasero-track-type-private.h
index 24ae7ad..2070420 100644
--- a/libbrasero-burn/brasero-track-type-private.h
+++ b/libbrasero-burn/brasero-track-type-private.h
@@ -39,7 +39,7 @@ struct _BraseroTrackType {
BraseroTrackDataType type;
union {
BraseroImageFormat img_format; /* used with IMAGE type */
- BraseroMedia media; /* used with DISC types */
+ BraseroMedia media; /* used with DISC types */
BraseroImageFS fs_type;
BraseroStreamFormat stream_format;
} subtype;
diff --git a/src/brasero-audio-disc.c b/src/brasero-audio-disc.c
index 5de8a54..ac76daf 100644
--- a/src/brasero-audio-disc.c
+++ b/src/brasero-audio-disc.c
@@ -988,7 +988,7 @@ brasero_audio_disc_session_changed (BraseroSessionCfg *session,
g_free (uri);
}
}
- brasero_status_free (status);
+ g_object_unref (status);
if (should_use_dts
&& brasero_burn_session_tag_lookup (BRASERO_BURN_SESSION (session), BRASERO_SESSION_STREAM_AUDIO_FORMAT, NULL) != BRASERO_BURN_OK)
diff --git a/src/brasero-data-disc.c b/src/brasero-data-disc.c
index e8d8cc5..1426b96 100644
--- a/src/brasero-data-disc.c
+++ b/src/brasero-data-disc.c
@@ -1463,14 +1463,14 @@ brasero_data_disc_set_track (BraseroDataDisc *disc,
brasero_track_get_status (BRASERO_TRACK (track), status);
if (brasero_status_get_result (status) == BRASERO_BURN_OK) {
- brasero_status_free (status);
+ g_object_unref (status);
gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (priv->filter), TRUE);
return BRASERO_DISC_OK;
}
if (brasero_status_get_result (status) != BRASERO_BURN_NOT_READY) {
- brasero_status_free (status);
+ g_object_unref (status);
return BRASERO_DISC_ERROR_UNKNOWN;
}
@@ -1497,7 +1497,7 @@ brasero_data_disc_set_track (BraseroDataDisc *disc,
gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (priv->filter), FALSE);
- brasero_status_free (status);
+ g_object_unref (status);
return BRASERO_DISC_OK;
}
diff --git a/src/brasero-project.c b/src/brasero-project.c
index ffa245b..19a3d0f 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -895,17 +895,17 @@ brasero_project_is_valid (BraseroSessionCfg *session,
BraseroProject *project)
{
BraseroSessionError valid;
- BraseroStatus *status;
GdkWindow *window;
GdkCursor *cursor;
GtkAction *action;
/* Update the cursor */
- status = brasero_status_new ();
- brasero_burn_session_get_status (BRASERO_BURN_SESSION (session), status);
-
window = gtk_widget_get_window (GTK_WIDGET (project));
if (window) {
+ BraseroStatus *status;
+
+ status = brasero_status_new ();
+ brasero_burn_session_get_status (BRASERO_BURN_SESSION (session), status);
if (brasero_status_get_result (status) == BRASERO_BURN_NOT_READY) {
cursor = gdk_cursor_new (GDK_WATCH);
gdk_window_set_cursor (window, cursor);
@@ -913,9 +913,9 @@ brasero_project_is_valid (BraseroSessionCfg *session,
}
else
gdk_window_set_cursor (window, NULL);
- }
- brasero_status_free (status);
+ g_object_unref (status);
+ }
valid = brasero_session_cfg_get_error (project->priv->session);
@@ -1303,7 +1303,7 @@ brasero_project_check_status (BraseroProject *project)
status = brasero_status_new ();
brasero_burn_session_get_status (BRASERO_BURN_SESSION (project->priv->session), status);
result = brasero_status_get_result (status);
- brasero_status_free (status);
+ g_object_unref (status);
if (result == BRASERO_BURN_ERR) {
/* At the moment the only error possible is an empty project */
diff --git a/src/brasero-video-disc.c b/src/brasero-video-disc.c
index e1ce3bc..0d8d320 100644
--- a/src/brasero-video-disc.c
+++ b/src/brasero-video-disc.c
@@ -500,7 +500,7 @@ brasero_video_disc_session_changed (BraseroSessionCfg *session,
BRASERO_TRACK (track));
}
}
- brasero_status_free (status);
+ g_object_unref (status);
}
static void
diff --git a/src/brasero-video-tree-model.c b/src/brasero-video-tree-model.c
index 5536662..87ec9f9 100644
--- a/src/brasero-video-tree-model.c
+++ b/src/brasero-video-tree-model.c
@@ -284,7 +284,7 @@ brasero_video_tree_model_get_value (GtkTreeModel *model,
else
g_value_set_string (value, "image-missing");
- brasero_status_free (status);
+ g_object_unref (status);
return;
case BRASERO_VIDEO_TREE_MODEL_THUMBNAIL:
@@ -318,7 +318,7 @@ brasero_video_tree_model_get_value (GtkTreeModel *model,
g_value_set_object (value, pixbuf);
g_object_unref (pixbuf);
- brasero_status_free (status);
+ g_object_unref (status);
return;
case BRASERO_VIDEO_TREE_MODEL_SIZE:
@@ -339,7 +339,7 @@ brasero_video_tree_model_get_value (GtkTreeModel *model,
else
g_value_set_string (value, _("(loadingâ?¦)"));
- brasero_status_free (status);
+ g_object_unref (status);
return;
case BRASERO_VIDEO_TREE_MODEL_EDITABLE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]