[tepl] ProgressInfoBar: make the class public



commit f3e86f7bbb037b0db1101dce40b24c73e77d7d28
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Nov 9 18:28:34 2020 +0100

    ProgressInfoBar: make the class public
    
    The documentation is not yet written, the API will most probably change.
    TeplInfoBar will also most probably be improved too.

 po/POTFILES.in                |   1 +
 po/POTFILES.skip              |   1 -
 tepl/meson.build              |   4 +-
 tepl/tepl-progress-info-bar.c | 102 +++++++++++++++++++++++++-----------------
 tepl/tepl-progress-info-bar.h |  59 +++++++++++++++++-------
 tepl/tepl.h                   |   1 +
 tests/test-tab.c              |  15 +++----
 7 files changed, 116 insertions(+), 67 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 39b0270..1e0d8e2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,7 @@ tepl/tepl-metadata-parser.c
 tepl/tepl-notebook.c
 tepl/tepl-panel.c
 tepl/tepl-pango.c
+tepl/tepl-progress-info-bar.c
 tepl/tepl-signal-group.c
 tepl/tepl-space-drawer-prefs.c
 tepl/tepl-statusbar.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 5a1d800..af58751 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,3 +1,2 @@
 tepl/tepl-io-error-info-bar.c
-tepl/tepl-progress-info-bar.c
 testsuite/test-file.c
diff --git a/tepl/meson.build b/tepl/meson.build
index 3528a88..ed8490c 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -25,6 +25,7 @@ tepl_public_headers = [
   'tepl-notebook.h',
   'tepl-panel.h',
   'tepl-pango.h',
+  'tepl-progress-info-bar.h',
   'tepl-space-drawer-prefs.h',
   'tepl-statusbar.h',
   'tepl-style-scheme-chooser-widget.h',
@@ -62,6 +63,7 @@ tepl_public_c_files = [
   'tepl-notebook.c',
   'tepl-panel.c',
   'tepl-pango.c',
+  'tepl-progress-info-bar.c',
   'tepl-space-drawer-prefs.c',
   'tepl-statusbar.c',
   'tepl-style-scheme-chooser-widget.c',
@@ -80,7 +82,6 @@ TEPL_PRIVATE_HEADERS = [
   'tepl-io-error-info-bar.h',
   'tepl-metadata-attic.h',
   'tepl-metadata-parser.h',
-  'tepl-progress-info-bar.h',
   'tepl-signal-group.h',
   'tepl-window-actions-edit.h',
   'tepl-window-actions-file.h',
@@ -93,7 +94,6 @@ tepl_private_c_files = [
   'tepl-io-error-info-bar.c',
   'tepl-metadata-attic.c',
   'tepl-metadata-parser.c',
-  'tepl-progress-info-bar.c',
   'tepl-signal-group.c',
   'tepl-window-actions-edit.c',
   'tepl-window-actions-file.c',
diff --git a/tepl/tepl-progress-info-bar.c b/tepl/tepl-progress-info-bar.c
index 7d1368e..871d80a 100644
--- a/tepl/tepl-progress-info-bar.c
+++ b/tepl/tepl-progress-info-bar.c
@@ -1,14 +1,20 @@
 /* SPDX-FileCopyrightText: 2005 - Paolo Maggi
- * SPDX-FileCopyrightText: 2016 - Sébastien Wilmet <swilmet gnome org>
+ * SPDX-FileCopyrightText: 2016, 2020 - Sébastien Wilmet <swilmet gnome org>
  * SPDX-License-Identifier: LGPL-3.0-or-later
  */
 
-/* Modified version of GeditProgressInfoBar. */
+/* Inspired by GeditProgressInfoBar. */
 
 #include "config.h"
 #include "tepl-progress-info-bar.h"
 #include <glib/gi18n-lib.h>
 
+struct _TeplProgressInfoBarPrivate
+{
+       GtkLabel *label;
+       GtkProgressBar *progress_bar;
+};
+
 enum
 {
        PROP_0,
@@ -18,15 +24,7 @@ enum
 
 static GParamSpec *properties[N_PROPERTIES];
 
-struct _TeplProgressInfoBar
-{
-       TeplInfoBar parent_instance;
-
-       GtkLabel *label;
-       GtkProgressBar *progress_bar;
-};
-
-G_DEFINE_TYPE (TeplProgressInfoBar, _tepl_progress_info_bar, TEPL_TYPE_INFO_BAR)
+G_DEFINE_TYPE_WITH_PRIVATE (TeplProgressInfoBar, tepl_progress_info_bar, TEPL_TYPE_INFO_BAR)
 
 static void
 set_has_cancel_button (TeplProgressInfoBar *info_bar,
@@ -41,17 +39,38 @@ set_has_cancel_button (TeplProgressInfoBar *info_bar,
 }
 
 static void
-_tepl_progress_info_bar_set_property (GObject      *object,
-                                     guint         prop_id,
-                                     const GValue *value,
-                                     GParamSpec   *pspec)
+tepl_progress_info_bar_get_property (GObject    *object,
+                                     guint       prop_id,
+                                     GValue     *value,
+                                     GParamSpec *pspec)
+{
+       //TeplProgressInfoBar *info_bar = TEPL_PROGRESS_INFO_BAR (object);
+
+       switch (prop_id)
+       {
+               case PROP_HAS_CANCEL_BUTTON:
+                       // TODO
+                       //g_value_set_boolean (value, [...]);
+                       break;
+
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                       break;
+       }
+}
+
+static void
+tepl_progress_info_bar_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
 {
-       TeplProgressInfoBar *bar = TEPL_PROGRESS_INFO_BAR (object);
+       TeplProgressInfoBar *info_bar = TEPL_PROGRESS_INFO_BAR (object);
 
        switch (prop_id)
        {
                case PROP_HAS_CANCEL_BUTTON:
-                       set_has_cancel_button (bar, g_value_get_boolean (value));
+                       set_has_cancel_button (info_bar, g_value_get_boolean (value));
                        break;
 
                default:
@@ -61,15 +80,16 @@ _tepl_progress_info_bar_set_property (GObject      *object,
 }
 
 static void
-_tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
+tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       object_class->set_property = _tepl_progress_info_bar_set_property;
+       object_class->get_property = tepl_progress_info_bar_get_property;
+       object_class->set_property = tepl_progress_info_bar_set_property;
 
        properties[PROP_HAS_CANCEL_BUTTON] =
                g_param_spec_boolean ("has-cancel-button",
-                                     "Has Cancel Button",
+                                     "has-cancel-button",
                                      "",
                                      TRUE,
                                      G_PARAM_WRITABLE |
@@ -80,23 +100,25 @@ _tepl_progress_info_bar_class_init (TeplProgressInfoBarClass *klass)
 }
 
 static void
-_tepl_progress_info_bar_init (TeplProgressInfoBar *info_bar)
+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->label = tepl_info_bar_create_label ();
+       info_bar->priv->label = tepl_info_bar_create_label ();
        gtk_container_add (GTK_CONTAINER (vgrid),
-                          GTK_WIDGET (info_bar->label));
+                          GTK_WIDGET (info_bar->priv->label));
 
-       info_bar->progress_bar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
-       gtk_widget_set_hexpand (GTK_WIDGET (info_bar->progress_bar), TRUE);
+       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->progress_bar));
+                          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),
@@ -106,8 +128,8 @@ _tepl_progress_info_bar_init (TeplProgressInfoBar *info_bar)
 }
 
 TeplProgressInfoBar *
-_tepl_progress_info_bar_new (const gchar *markup,
-                            gboolean     has_cancel_button)
+tepl_progress_info_bar_new (const gchar *markup,
+                           gboolean     has_cancel_button)
 {
        TeplProgressInfoBar *info_bar;
 
@@ -117,44 +139,44 @@ _tepl_progress_info_bar_new (const gchar *markup,
                                 "has-cancel-button", has_cancel_button,
                                 NULL);
 
-       _tepl_progress_info_bar_set_markup (info_bar, markup);
+       tepl_progress_info_bar_set_markup (info_bar, markup);
 
        return info_bar;
 }
 
 void
-_tepl_progress_info_bar_set_markup (TeplProgressInfoBar *info_bar,
-                                   const gchar         *markup)
+tepl_progress_info_bar_set_markup (TeplProgressInfoBar *info_bar,
+                                  const gchar         *markup)
 {
        g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (info_bar));
        g_return_if_fail (markup != NULL);
 
-       gtk_label_set_markup (info_bar->label, markup);
+       gtk_label_set_markup (info_bar->priv->label, markup);
 }
 
 void
-_tepl_progress_info_bar_set_text (TeplProgressInfoBar *info_bar,
-                                 const gchar         *text)
+tepl_progress_info_bar_set_text (TeplProgressInfoBar *info_bar,
+                                const gchar         *text)
 {
        g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (info_bar));
        g_return_if_fail (text != NULL);
 
-       gtk_label_set_text (info_bar->label, text);
+       gtk_label_set_text (info_bar->priv->label, text);
 }
 
 void
-_tepl_progress_info_bar_set_fraction (TeplProgressInfoBar *info_bar,
-                                     gdouble              fraction)
+tepl_progress_info_bar_set_fraction (TeplProgressInfoBar *info_bar,
+                                    gdouble              fraction)
 {
        g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (info_bar));
 
-       gtk_progress_bar_set_fraction (info_bar->progress_bar, fraction);
+       gtk_progress_bar_set_fraction (info_bar->priv->progress_bar, fraction);
 }
 
 void
-_tepl_progress_info_bar_pulse (TeplProgressInfoBar *info_bar)
+tepl_progress_info_bar_pulse (TeplProgressInfoBar *info_bar)
 {
        g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (info_bar));
 
-       gtk_progress_bar_pulse (info_bar->progress_bar);
+       gtk_progress_bar_pulse (info_bar->priv->progress_bar);
 }
diff --git a/tepl/tepl-progress-info-bar.h b/tepl/tepl-progress-info-bar.h
index 5e569f7..9eae0d3 100644
--- a/tepl/tepl-progress-info-bar.h
+++ b/tepl/tepl-progress-info-bar.h
@@ -1,39 +1,66 @@
 /* SPDX-FileCopyrightText: 2005 - Paolo Maggi
- * SPDX-FileCopyrightText: 2016 - Sébastien Wilmet <swilmet gnome org>
+ * SPDX-FileCopyrightText: 2016, 2020 - Sébastien Wilmet <swilmet gnome org>
  * SPDX-License-Identifier: LGPL-3.0-or-later
  */
 
 #ifndef TEPL_PROGRESS_INFO_BAR_H
 #define TEPL_PROGRESS_INFO_BAR_H
 
+#if !defined (TEPL_H_INSIDE) && !defined (TEPL_COMPILATION)
+#error "Only <tepl/tepl.h> can be included directly."
+#endif
+
 #include <gtk/gtk.h>
-#include "tepl-info-bar.h"
+#include <tepl/tepl-info-bar.h>
 
 G_BEGIN_DECLS
 
-#define TEPL_TYPE_PROGRESS_INFO_BAR (_tepl_progress_info_bar_get_type ())
-G_DECLARE_FINAL_TYPE (TeplProgressInfoBar, _tepl_progress_info_bar,
-                     TEPL, PROGRESS_INFO_BAR,
-                     TeplInfoBar)
+#define TEPL_TYPE_PROGRESS_INFO_BAR             (tepl_progress_info_bar_get_type ())
+#define TEPL_PROGRESS_INFO_BAR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
TEPL_TYPE_PROGRESS_INFO_BAR, TeplProgressInfoBar))
+#define TEPL_PROGRESS_INFO_BAR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
TEPL_TYPE_PROGRESS_INFO_BAR, TeplProgressInfoBarClass))
+#define TEPL_IS_PROGRESS_INFO_BAR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
TEPL_TYPE_PROGRESS_INFO_BAR))
+#define TEPL_IS_PROGRESS_INFO_BAR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
TEPL_TYPE_PROGRESS_INFO_BAR))
+#define TEPL_PROGRESS_INFO_BAR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
TEPL_TYPE_PROGRESS_INFO_BAR, TeplProgressInfoBarClass))
+
+typedef struct _TeplProgressInfoBar         TeplProgressInfoBar;
+typedef struct _TeplProgressInfoBarClass    TeplProgressInfoBarClass;
+typedef struct _TeplProgressInfoBarPrivate  TeplProgressInfoBarPrivate;
+
+struct _TeplProgressInfoBar
+{
+       TeplInfoBar parent;
+
+       TeplProgressInfoBarPrivate *priv;
+};
+
+struct _TeplProgressInfoBarClass
+{
+       TeplInfoBarClass parent_class;
+
+       gpointer padding[12];
+};
+
+_TEPL_EXTERN
+GType                  tepl_progress_info_bar_get_type                 (void);
 
-G_GNUC_INTERNAL
-TeplProgressInfoBar *  _tepl_progress_info_bar_new                     (const gchar *markup,
+_TEPL_EXTERN
+TeplProgressInfoBar *  tepl_progress_info_bar_new                      (const gchar *markup,
                                                                         gboolean     has_cancel_button);
 
-G_GNUC_INTERNAL
-void                   _tepl_progress_info_bar_set_markup              (TeplProgressInfoBar *info_bar,
+_TEPL_EXTERN
+void                   tepl_progress_info_bar_set_markup               (TeplProgressInfoBar *info_bar,
                                                                         const gchar         *markup);
 
-G_GNUC_INTERNAL
-void                   _tepl_progress_info_bar_set_text                (TeplProgressInfoBar *info_bar,
+_TEPL_EXTERN
+void                   tepl_progress_info_bar_set_text                 (TeplProgressInfoBar *info_bar,
                                                                         const gchar         *text);
 
-G_GNUC_INTERNAL
-void                   _tepl_progress_info_bar_set_fraction            (TeplProgressInfoBar *info_bar,
+_TEPL_EXTERN
+void                   tepl_progress_info_bar_set_fraction             (TeplProgressInfoBar *info_bar,
                                                                         gdouble              fraction);
 
-G_GNUC_INTERNAL
-void                   _tepl_progress_info_bar_pulse                   (TeplProgressInfoBar *info_bar);
+_TEPL_EXTERN
+void                   tepl_progress_info_bar_pulse                    (TeplProgressInfoBar *info_bar);
 
 G_END_DECLS
 
diff --git a/tepl/tepl.h b/tepl/tepl.h
index d5cf1d3..100b844 100644
--- a/tepl/tepl.h
+++ b/tepl/tepl.h
@@ -36,6 +36,7 @@
 #include <tepl/tepl-notebook.h>
 #include <tepl/tepl-panel.h>
 #include <tepl/tepl-pango.h>
+#include <tepl/tepl-progress-info-bar.h>
 #include <tepl/tepl-space-drawer-prefs.h>
 #include <tepl/tepl-statusbar.h>
 #include <tepl/tepl-style-scheme-chooser-widget.h>
diff --git a/tests/test-tab.c b/tests/test-tab.c
index f233f92..ce41f42 100644
--- a/tests/test-tab.c
+++ b/tests/test-tab.c
@@ -1,9 +1,8 @@
-/* SPDX-FileCopyrightText: 2016 - Sébastien Wilmet <swilmet gnome org>
+/* SPDX-FileCopyrightText: 2016, 2020 - Sébastien Wilmet <swilmet gnome org>
  * SPDX-License-Identifier: LGPL-3.0-or-later
  */
 
 #include <tepl/tepl.h>
-#include "tepl/tepl-progress-info-bar.h"
 #include "tepl/tepl-io-error-info-bar.h"
 #include <stdlib.h>
 
@@ -42,13 +41,13 @@ progress_cb (GtkButton *button,
 {
        TeplProgressInfoBar *info_bar;
 
-       info_bar = _tepl_progress_info_bar_new ("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",
-                                               TRUE);
+       info_bar = tepl_progress_info_bar_new ("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",
+                                              TRUE);
 
-       _tepl_progress_info_bar_set_fraction (info_bar, 0.3);
+       tepl_progress_info_bar_set_fraction (info_bar, 0.3);
 
        g_signal_connect (info_bar,
                          "response",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]