PROP_0,
PROP_TITLE,
PROP_LABEL,
+ PROP_WITH_LABEL,
+ PROP_WITH_PERCENTAGE,
PROP_WITH_CANCEL_BUTTON
};
static void solipa_progress_window_on_cancel_clicked (GtkButton *button,
gpointer user_data);
+static void solipa_progress_window_dispose (GObject *gobject);
+static void solipa_progress_window_finalize (GObject *gobject);
+
#define SOLIPA_PROGRESS_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_SOLIPA_PROGRESS_WINDOW, SolipaProgressWindowPrivate))
typedef struct _SolipaProgressWindowPrivate SolipaProgressWindowPrivate;
GtkWidget *label;
GtkWidget *progress;
GtkWidget *btn_cancel;
+
+ gboolean with_percentage;
};
G_DEFINE_TYPE (SolipaProgressWindow, solipa_progress_window, G_TYPE_OBJECT)
object_class->set_property = solipa_progress_window_set_property;
object_class->get_property = solipa_progress_window_get_property;
+ object_class->dispose = solipa_progress_window_dispose;
+ object_class->finalize = solipa_progress_window_finalize;
g_object_class_install_property (object_class, PROP_TITLE,
g_param_spec_string ("title",
"",
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_WITH_LABEL,
+ g_param_spec_boolean ("with-label",
+ "With label",
+ "With label",
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class, PROP_WITH_PERCENTAGE,
+ g_param_spec_boolean ("with-percentage",
+ "With percentage",
+ "With percentage",
+ FALSE,
+ G_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_WITH_CANCEL_BUTTON,
g_param_spec_boolean ("with-cancel-button",
"With cancel button",
solipa_progress_window_init (SolipaProgressWindow *solipa_progress_window)
{
SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+ priv->with_percentage = FALSE;
}
/**
priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "w_progress"));
priv->label = GTK_WIDGET (gtk_builder_get_object (builder, "label13"));
priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "progressbar1"));
+ priv->btn_cancel = GTK_WIDGET (gtk_builder_get_object (builder, "button8"));
- g_signal_connect (gtk_builder_get_object (builder, "button8"), "clicked",
+ g_signal_connect (G_OBJECT (priv->btn_cancel), "clicked",
G_CALLBACK (solipa_progress_window_on_cancel_clicked), (gpointer)solipa_progress_window);
return solipa_progress_window;
SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (progressw);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->progress));
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), "");
}
void
solipa_progress_window_set_fraction (SolipaProgressWindow *progressw, gdouble fraction)
{
+ gchar *text;
+
g_return_if_fail (IS_SOLIPA_PROGRESS_WINDOW (progressw));
SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (progressw);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), fraction);
+ text = g_strdup_printf ("%.2f%%", fraction * 100.0);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), text);
+ g_free (text);
}
/* PRIVATE */
gtk_label_set_text (GTK_LABEL (priv->label), g_strstrip (g_value_dup_string (value)));
break;
+ case PROP_WITH_LABEL:
+ gtk_widget_set_visible (priv->label, g_value_get_boolean (value));
+ break;
+
+ case PROP_WITH_PERCENTAGE:
+ priv->with_percentage = g_value_get_boolean (value);
+ break;
+
case PROP_WITH_CANCEL_BUTTON:
gtk_widget_set_visible (priv->btn_cancel, g_value_get_boolean (value));
break;
g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->label)));
break;
+ case PROP_WITH_LABEL:
+ g_value_set_boolean (value, gtk_widget_get_visible (priv->label));
+ break;
+
+ case PROP_WITH_PERCENTAGE:
+ g_value_set_boolean (value, priv->with_percentage);
+ break;
+
case PROP_WITH_CANCEL_BUTTON:
g_value_set_boolean (value, gtk_widget_get_visible (priv->btn_cancel));
break;
gtk_widget_destroy (priv->dialog);
g_object_unref (user_data);
}
+}
+
+static void
+solipa_progress_window_dispose (GObject *gobject)
+{
+ SolipaProgressWindow *solipa_progress_window = (SolipaProgressWindow *)gobject;
+ SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+ if (priv->dialog != NULL)
+ {
+ gtk_widget_destroy (priv->dialog);
+ priv->dialog = NULL;
+ }
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+solipa_progress_window_finalize (GObject *gobject)
+{
+ SolipaProgressWindow *solipa_progress_window = (SolipaProgressWindow *)gobject;
+ SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
}
\ No newline at end of file