[nautilus] progress-info-widget: use constructed instead of new for initialization
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] progress-info-widget: use constructed instead of new for initialization
- Date: Wed, 26 Oct 2016 18:12:25 +0000 (UTC)
commit ebaa70c16770bd4214b339d9e7390510ed7e7b80
Author: Carlos Soriano <csoriano gnome org>
Date: Wed Oct 26 20:10:39 2016 +0200
progress-info-widget: use constructed instead of new for initialization
As recommended in the docs, constructed should be used for initialize
the class when it needs some construct-only properties set (or not)
The new handler should only be a wrapper around g_object_new.
Patch made by Nacho, thanks!
src/nautilus-progress-info-widget.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/nautilus-progress-info-widget.c b/src/nautilus-progress-info-widget.c
index 1cf350b..3d24133 100644
--- a/src/nautilus-progress-info-widget.c
+++ b/src/nautilus-progress-info-widget.c
@@ -123,6 +123,15 @@ nautilus_progress_info_widget_constructed (GObject *obj)
G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->constructed (obj);
+ if (nautilus_progress_info_get_is_finished (self->priv->info))
+ {
+ gtk_button_set_image (GTK_BUTTON (self->priv->button), self->priv->done_image);
+ }
+
+ gtk_widget_set_sensitive (self->priv->button,
+ !nautilus_progress_info_get_is_finished (self->priv->info) &&
+ !nautilus_progress_info_get_is_cancelled (self->priv->info));
+
g_signal_connect_swapped (self->priv->info,
"changed",
G_CALLBACK (update_data), self);
@@ -210,20 +219,7 @@ nautilus_progress_info_widget_class_init (NautilusProgressInfoWidgetClass *klass
GtkWidget *
nautilus_progress_info_widget_new (NautilusProgressInfo *info)
{
- NautilusProgressInfoWidget *self;
-
- self = g_object_new (NAUTILUS_TYPE_PROGRESS_INFO_WIDGET,
+ return g_object_new (NAUTILUS_TYPE_PROGRESS_INFO_WIDGET,
"info", info,
NULL);
-
- if (nautilus_progress_info_get_is_finished (self->priv->info))
- {
- gtk_button_set_image (GTK_BUTTON (self->priv->button), self->priv->done_image);
- }
-
- gtk_widget_set_sensitive (self->priv->button,
- !nautilus_progress_info_get_is_finished (self->priv->info) &&
- !nautilus_progress_info_get_is_cancelled (self->priv->info));
-
- return GTK_WIDGET (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]