[gnome-builder/wip/gtk4-port: 103/1774] libide/gtk: move pulse helpers to libide-gtk




commit e54296091b7d4fc4007b6ec3b0db01a69943acf1
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 28 14:22:00 2022 -0700

    libide/gtk: move pulse helpers to libide-gtk

 src/libide/gtk/ide-gtk.c         | 54 ++++++++++++++++++++++++++++++++++++++++
 src/libide/gtk/ide-gtk.h         | 14 +++++++----
 src/libide/gui/ide-gui-global.c  | 54 ----------------------------------------
 src/libide/gui/ide-gui-private.h |  2 --
 4 files changed, 63 insertions(+), 61 deletions(-)
---
diff --git a/src/libide/gtk/ide-gtk.c b/src/libide/gtk/ide-gtk.c
index 9ac1f74ee..423441d55 100644
--- a/src/libide/gtk/ide-gtk.c
+++ b/src/libide/gtk/ide-gtk.c
@@ -92,3 +92,57 @@ ide_gtk_show_uri_on_window (GtkWindow    *window,
 
   return TRUE;
 }
+
+static gboolean
+ide_gtk_progress_bar_tick_cb (gpointer data)
+{
+  GtkProgressBar *progress = data;
+
+  g_assert (GTK_IS_PROGRESS_BAR (progress));
+
+  gtk_progress_bar_pulse (progress);
+  gtk_widget_queue_draw (GTK_WIDGET (progress));
+
+  return G_SOURCE_CONTINUE;
+}
+
+void
+ide_gtk_progress_bar_stop_pulsing (GtkProgressBar *progress)
+{
+  guint tick_id;
+
+  g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
+
+  tick_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress), "PULSE_ID"));
+
+  if (tick_id != 0)
+    {
+      g_source_remove (tick_id);
+      g_object_set_data (G_OBJECT (progress), "PULSE_ID", NULL);
+    }
+
+  gtk_progress_bar_set_fraction (progress, 0.0);
+}
+
+void
+ide_gtk_progress_bar_start_pulsing (GtkProgressBar *progress)
+{
+  guint tick_id;
+
+  g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
+
+  if (g_object_get_data (G_OBJECT (progress), "PULSE_ID"))
+    return;
+
+  gtk_progress_bar_set_fraction (progress, 0.0);
+  gtk_progress_bar_set_pulse_step (progress, .5);
+
+  /* We want lower than the frame rate, because that is all that is needed */
+  tick_id = g_timeout_add_full (G_PRIORITY_LOW,
+                                500,
+                                ide_gtk_progress_bar_tick_cb,
+                                g_object_ref (progress),
+                                g_object_unref);
+  g_object_set_data (G_OBJECT (progress), "PULSE_ID", GUINT_TO_POINTER (tick_id));
+  ide_gtk_progress_bar_tick_cb (progress);
+}
diff --git a/src/libide/gtk/ide-gtk.h b/src/libide/gtk/ide-gtk.h
index a24a95688..5e8d6557e 100644
--- a/src/libide/gtk/ide-gtk.h
+++ b/src/libide/gtk/ide-gtk.h
@@ -31,11 +31,15 @@
 G_BEGIN_DECLS
 
 IDE_AVAILABLE_IN_ALL
-gboolean ide_gtk_show_uri_on_window (GtkWindow   *window,
-                                     const char  *uri,
-                                     gint64       timestamp,
-                                     GError     **error);
+gboolean ide_gtk_show_uri_on_window          (GtkWindow       *window,
+                                              const char      *uri,
+                                              gint64           timestamp,
+                                              GError         **error);
 IDE_AVAILABLE_IN_ALL
-void     ide_gtk_window_present     (GtkWindow   *window);
+void     ide_gtk_window_present              (GtkWindow       *window);
+IDE_AVAILABLE_IN_ALL
+void      ide_gtk_progress_bar_start_pulsing (GtkProgressBar  *progress);
+IDE_AVAILABLE_IN_ALL
+void      ide_gtk_progress_bar_stop_pulsing  (GtkProgressBar  *progress);
 
 G_END_DECLS
diff --git a/src/libide/gui/ide-gui-global.c b/src/libide/gui/ide-gui-global.c
index 1ce6fede9..c56b82aca 100644
--- a/src/libide/gui/ide-gui-global.c
+++ b/src/libide/gui/ide-gui-global.c
@@ -221,60 +221,6 @@ ide_widget_get_workspace (GtkWidget *widget)
   return IDE_WORKSPACE (gtk_widget_get_root (widget));
 }
 
-static gboolean
-ide_gtk_progress_bar_tick_cb (gpointer data)
-{
-  GtkProgressBar *progress = data;
-
-  g_assert (GTK_IS_PROGRESS_BAR (progress));
-
-  gtk_progress_bar_pulse (progress);
-  gtk_widget_queue_draw (GTK_WIDGET (progress));
-
-  return G_SOURCE_CONTINUE;
-}
-
-void
-_ide_gtk_progress_bar_stop_pulsing (GtkProgressBar *progress)
-{
-  guint tick_id;
-
-  g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
-
-  tick_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress), "PULSE_ID"));
-
-  if (tick_id != 0)
-    {
-      g_source_remove (tick_id);
-      g_object_set_data (G_OBJECT (progress), "PULSE_ID", NULL);
-    }
-
-  gtk_progress_bar_set_fraction (progress, 0.0);
-}
-
-void
-_ide_gtk_progress_bar_start_pulsing (GtkProgressBar *progress)
-{
-  guint tick_id;
-
-  g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
-
-  if (g_object_get_data (G_OBJECT (progress), "PULSE_ID"))
-    return;
-
-  gtk_progress_bar_set_fraction (progress, 0.0);
-  gtk_progress_bar_set_pulse_step (progress, .5);
-
-  /* We want lower than the frame rate, because that is all that is needed */
-  tick_id = g_timeout_add_full (G_PRIORITY_LOW,
-                                500,
-                                ide_gtk_progress_bar_tick_cb,
-                                g_object_ref (progress),
-                                g_object_unref);
-  g_object_set_data (G_OBJECT (progress), "PULSE_ID", GUINT_TO_POINTER (tick_id));
-  ide_gtk_progress_bar_tick_cb (progress);
-}
-
 static void
 show_parents (GtkWidget *widget)
 {
diff --git a/src/libide/gui/ide-gui-private.h b/src/libide/gui/ide-gui-private.h
index 874d0cd05..b5a080dd6 100644
--- a/src/libide/gui/ide-gui-private.h
+++ b/src/libide/gui/ide-gui-private.h
@@ -63,8 +63,6 @@ gboolean  _ide_workbench_is_last_workspace      (IdeWorkbench        *self,
                                                  IdeWorkspace        *workspace);
 void      _ide_header_bar_init_shortcuts        (IdeHeaderBar        *self);
 void      _ide_header_bar_show_menu             (IdeHeaderBar        *self);
-void      _ide_gtk_progress_bar_start_pulsing   (GtkProgressBar      *progress);
-void      _ide_gtk_progress_bar_stop_pulsing    (GtkProgressBar      *progress);
 void      _ide_surface_set_fullscreen           (IdeSurface          *self,
                                                  gboolean             fullscreen);
 


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