[tepl] ProgressInfoBar: some progress
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] ProgressInfoBar: some progress
- Date: Wed, 11 Nov 2020 14:33:50 +0000 (UTC)
commit 3a7b510faf27e0d8c230fd3e955761678c3048f9
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 11 15:31:28 2020 +0100
ProgressInfoBar: some progress
tepl/tepl-progress-info-bar.c | 47 ++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/tepl/tepl-progress-info-bar.c b/tepl/tepl-progress-info-bar.c
index 871d80a..9069be4 100644
--- a/tepl/tepl-progress-info-bar.c
+++ b/tepl/tepl-progress-info-bar.c
@@ -13,6 +13,7 @@ struct _TeplProgressInfoBarPrivate
{
GtkLabel *label;
GtkProgressBar *progress_bar;
+ guint has_cancel_button : 1;
};
enum
@@ -30,6 +31,8 @@ static void
set_has_cancel_button (TeplProgressInfoBar *info_bar,
gboolean has_cancel_button)
{
+ info_bar->priv->has_cancel_button = has_cancel_button != FALSE;
+
if (has_cancel_button)
{
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
@@ -44,13 +47,12 @@ tepl_progress_info_bar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- //TeplProgressInfoBar *info_bar = TEPL_PROGRESS_INFO_BAR (object);
+ TeplProgressInfoBar *info_bar = TEPL_PROGRESS_INFO_BAR (object);
switch (prop_id)
{
case PROP_HAS_CANCEL_BUTTON:
- // TODO
- //g_value_set_boolean (value, [...]);
+ g_value_set_boolean (value, info_bar->priv->has_cancel_button);
break;
default:
@@ -79,6 +81,17 @@ tepl_progress_info_bar_set_property (GObject *object,
}
}
+static void
+tepl_progress_info_bar_dispose (GObject *object)
+{
+ TeplProgressInfoBar *info_bar = TEPL_PROGRESS_INFO_BAR (object);
+
+ info_bar->priv->label = NULL;
+ info_bar->priv->progress_bar = NULL;
+
+ G_OBJECT_CLASS (tepl_progress_info_bar_parent_class)->dispose (object);
+}
+
static void
tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
{
@@ -86,13 +99,14 @@ tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
object_class->get_property = tepl_progress_info_bar_get_property;
object_class->set_property = tepl_progress_info_bar_set_property;
+ object_class->dispose = tepl_progress_info_bar_dispose;
properties[PROP_HAS_CANCEL_BUTTON] =
g_param_spec_boolean ("has-cancel-button",
"has-cancel-button",
"",
TRUE,
- G_PARAM_WRITABLE |
+ G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
@@ -102,29 +116,20 @@ tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
static void
tepl_progress_info_bar_init (TeplProgressInfoBar *info_bar)
{
- GtkGrid *vgrid;
- GtkWidget *content_area;
-
info_bar->priv = tepl_progress_info_bar_get_instance_private (info_bar);
- vgrid = GTK_GRID (gtk_grid_new ());
- gtk_orientable_set_orientation (GTK_ORIENTABLE (vgrid), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (vgrid, 6);
-
info_bar->priv->label = tepl_info_bar_create_label ();
- gtk_container_add (GTK_CONTAINER (vgrid),
- GTK_WIDGET (info_bar->priv->label));
+ gtk_widget_show (GTK_WIDGET (info_bar->priv->label));
+ tepl_info_bar_add_content_widget (TEPL_INFO_BAR (info_bar),
+ GTK_WIDGET (info_bar->priv->label),
+ TEPL_INFO_BAR_LOCATION_ALONGSIDE_ICON);
info_bar->priv->progress_bar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
gtk_widget_set_hexpand (GTK_WIDGET (info_bar->priv->progress_bar), TRUE);
- gtk_container_add (GTK_CONTAINER (vgrid),
- GTK_WIDGET (info_bar->priv->progress_bar));
-
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
- gtk_container_add (GTK_CONTAINER (content_area),
- GTK_WIDGET (vgrid));
-
- gtk_widget_show_all (GTK_WIDGET (vgrid));
+ gtk_widget_show (GTK_WIDGET (info_bar->priv->progress_bar));
+ tepl_info_bar_add_content_widget (TEPL_INFO_BAR (info_bar),
+ GTK_WIDGET (info_bar->priv->progress_bar),
+ TEPL_INFO_BAR_LOCATION_BELOW_ICON);
}
TeplProgressInfoBar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]