[tepl] ProgressInfoBar: improve the new() function
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] ProgressInfoBar: improve the new() function
- Date: Wed, 11 Nov 2020 15:38:14 +0000 (UTC)
commit bb8feee9d73c01fc60862102c1b9aad5cf30b2f7
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 11 16:33:57 2020 +0100
ProgressInfoBar: improve the new() function
tepl/tepl-progress-info-bar.c | 20 ++++++++++++++++----
tepl/tepl-progress-info-bar.h | 21 +++++++++++----------
tests/test-tab.c | 3 ++-
3 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/tepl/tepl-progress-info-bar.c b/tepl/tepl-progress-info-bar.c
index 9069be4..23fcc8e 100644
--- a/tepl/tepl-progress-info-bar.c
+++ b/tepl/tepl-progress-info-bar.c
@@ -132,19 +132,31 @@ tepl_progress_info_bar_init (TeplProgressInfoBar *info_bar)
TEPL_INFO_BAR_LOCATION_BELOW_ICON);
}
+/**
+ * tepl_progress_info_bar_new:
+ * @icon_name: (nullable):
+ * @markup: (nullable):
+ * @has_cancel_button:
+ *
+ * Returns: a new #TeplProgressInfoBar.
+ * Since: 6.0
+ */
TeplProgressInfoBar *
-tepl_progress_info_bar_new (const gchar *markup,
+tepl_progress_info_bar_new (const gchar *icon_name,
+ const gchar *markup,
gboolean has_cancel_button)
{
TeplProgressInfoBar *info_bar;
- g_return_val_if_fail (markup != NULL, NULL);
-
info_bar = g_object_new (TEPL_TYPE_PROGRESS_INFO_BAR,
+ "icon-name", icon_name,
"has-cancel-button", has_cancel_button,
NULL);
- tepl_progress_info_bar_set_markup (info_bar, markup);
+ if (markup != NULL)
+ {
+ tepl_progress_info_bar_set_markup (info_bar, markup);
+ }
return info_bar;
}
diff --git a/tepl/tepl-progress-info-bar.h b/tepl/tepl-progress-info-bar.h
index 9eae0d3..ce7af58 100644
--- a/tepl/tepl-progress-info-bar.h
+++ b/tepl/tepl-progress-info-bar.h
@@ -41,26 +41,27 @@ struct _TeplProgressInfoBarClass
};
_TEPL_EXTERN
-GType tepl_progress_info_bar_get_type (void);
+GType tepl_progress_info_bar_get_type (void);
_TEPL_EXTERN
-TeplProgressInfoBar * tepl_progress_info_bar_new (const gchar *markup,
- gboolean has_cancel_button);
+TeplProgressInfoBar * tepl_progress_info_bar_new (const gchar *icon_name,
+ const gchar *markup,
+ gboolean has_cancel_button);
_TEPL_EXTERN
-void tepl_progress_info_bar_set_markup (TeplProgressInfoBar *info_bar,
- const gchar *markup);
+void tepl_progress_info_bar_set_markup (TeplProgressInfoBar *info_bar,
+ const gchar *markup);
_TEPL_EXTERN
-void tepl_progress_info_bar_set_text (TeplProgressInfoBar *info_bar,
- const gchar *text);
+void tepl_progress_info_bar_set_text (TeplProgressInfoBar *info_bar,
+ const gchar *text);
_TEPL_EXTERN
-void tepl_progress_info_bar_set_fraction (TeplProgressInfoBar *info_bar,
- gdouble fraction);
+void tepl_progress_info_bar_set_fraction (TeplProgressInfoBar *info_bar,
+ gdouble fraction);
_TEPL_EXTERN
-void tepl_progress_info_bar_pulse (TeplProgressInfoBar *info_bar);
+void tepl_progress_info_bar_pulse (TeplProgressInfoBar *info_bar);
G_END_DECLS
diff --git a/tests/test-tab.c b/tests/test-tab.c
index 65836c8..0947c4c 100644
--- a/tests/test-tab.c
+++ b/tests/test-tab.c
@@ -50,7 +50,8 @@ progress_cb (GtkButton *button,
{
TeplProgressInfoBar *info_bar;
- info_bar = tepl_progress_info_bar_new ("File loading... The full and very long path is: "
+ info_bar = tepl_progress_info_bar_new ("document-save",
+ "File loading... The full and very long path is: "
"/home/seb/a/very/long/path/like/this/is/beautiful"
"/but/is/it/correctly/wrapped/in/the/info/bar/that"
"/is/the/question",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]