[rhythmbox] shell: remove progress display from the statusbar



commit 3d8fdababe904a071e59af17521411062d61b0b3
Author: Jonathan Matthew <jonathan d14n org>
Date:   Tue May 14 22:15:18 2013 +1000

    shell: remove progress display from the statusbar
    
    The task list is going to replace this.  Mostly.

 rhythmdb/rhythmdb.c             |   45 --------------
 rhythmdb/rhythmdb.h             |    2 -
 shell/rb-shell.c                |    3 +-
 shell/rb-statusbar.c            |  126 +-------------------------------------
 shell/rb-statusbar.h            |    3 +-
 shell/rb-track-transfer-queue.c |   54 -----------------
 shell/rb-track-transfer-queue.h |    5 --
 7 files changed, 6 insertions(+), 232 deletions(-)
---
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index 766c160..74967e3 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -4413,51 +4413,6 @@ rhythmdb_entry_gather_metadata (RhythmDB *db,
        return metadata;
 }
 
-static gboolean
-queue_is_empty (GAsyncQueue *queue)
-{
-       return g_async_queue_length (queue) <= 0;
-}
-
-/**
- * rhythmdb_is_busy:
- * @db: a #RhythmDB.
- *
- * Checks if the database has events to process.  This probably isn't
- * very useful.
- *
- * Returns: whether the #RhythmDB has events to process.
- */
-gboolean
-rhythmdb_is_busy (RhythmDB *db)
-{
-       return (!db->priv->action_thread_running ||
-               db->priv->stat_thread_running ||
-               !queue_is_empty (db->priv->event_queue) ||
-               !queue_is_empty (db->priv->action_queue) ||
-               (db->priv->outstanding_stats != NULL));
-}
-
-/**
- * rhythmdb_get_progress_info:
- * @db: a #RhythmDB.
- * @text: used to return progress text
- * @progress: used to return progress fraction
- *
- * Provides progress information for rhythmdb operations, if any are running.
- */
-void
-rhythmdb_get_progress_info (RhythmDB *db, char **text, float *progress)
-{
-       if (db->priv->stat_thread_running && db->priv->stat_thread_count > 0) {
-               g_free (*text);
-               *text = g_strdup_printf (_("Checking (%d/%d)"),
-                                        db->priv->stat_thread_done,
-                                        db->priv->stat_thread_count);
-               *progress = ((float)db->priv->stat_thread_done /
-                            (float)db->priv->stat_thread_count);
-       }
-}
 
 /**
  * rhythmdb_compute_status_normal:
diff --git a/rhythmdb/rhythmdb.h b/rhythmdb/rhythmdb.h
index 308d523..23ee7b9 100644
--- a/rhythmdb/rhythmdb.h
+++ b/rhythmdb/rhythmdb.h
@@ -451,8 +451,6 @@ GValue *    rhythmdb_entry_request_extra_metadata   (RhythmDB *db, RhythmDBEntry *ent
 RBStringValueMap* rhythmdb_entry_gather_metadata       (RhythmDB *db, RhythmDBEntry *entry);
 void           rhythmdb_emit_entry_extra_metadata_notify (RhythmDB *db, RhythmDBEntry *entry, const gchar 
*property_name, const GValue *metadata);
 
-gboolean       rhythmdb_is_busy                        (RhythmDB *db);
-void           rhythmdb_get_progress_info              (RhythmDB *db, char **text, float *progress);
 char *         rhythmdb_compute_status_normal          (gint n_songs, glong duration,
                                                         guint64 size,
                                                         const char *singular,
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 9f3ebfc..790f03a 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -555,8 +555,7 @@ construct_widgets (RBShell *shell)
        gtk_widget_show (GTK_WIDGET (shell->priv->header));
        g_settings_bind (shell->priv->settings, "time-display", shell->priv->header, "show-remaining", 
G_SETTINGS_BIND_DEFAULT);
 
-       shell->priv->statusbar = rb_statusbar_new (shell->priv->db,
-                                                  shell->priv->track_transfer_queue);
+       shell->priv->statusbar = rb_statusbar_new (shell->priv->db);
        gtk_widget_show (GTK_WIDGET (shell->priv->statusbar));
 
        g_signal_connect_object (shell->priv->display_page_tree, "selected",
diff --git a/shell/rb-statusbar.c b/shell/rb-statusbar.c
index 10e92a9..155ef4f 100644
--- a/shell/rb-statusbar.c
+++ b/shell/rb-statusbar.c
@@ -37,7 +37,6 @@
 #include <gtk/gtk.h>
 
 #include "rb-statusbar.h"
-#include "rb-track-transfer-queue.h"
 #include "rb-debug.h"
 
 /**
@@ -77,22 +76,11 @@ static gboolean poll_status (RBStatusbar *status);
 static void rb_statusbar_sync_status (RBStatusbar *status);
 static void rb_statusbar_page_status_changed_cb (RBDisplayPage *page,
                                                   RBStatusbar *statusbar);
-static void rb_statusbar_transfer_progress_cb (RBTrackTransferQueue *queue,
-                                              int done,
-                                              int total,
-                                              double fraction,
-                                              int time_left,
-                                              RBStatusbar *statusbar);
 
 struct RBStatusbarPrivate
 {
         RBDisplayPage *selected_page;
-       RBTrackTransferQueue *transfer_queue;
-
         RhythmDB *db;
-
-        GtkWidget *progress;
-
         guint status_poll_id;
 };
 
@@ -101,7 +89,6 @@ enum
         PROP_0,
         PROP_DB,
         PROP_PAGE,
-       PROP_TRANSFER_QUEUE
 };
 
 G_DEFINE_TYPE (RBStatusbar, rb_statusbar, GTK_TYPE_STATUSBAR)
@@ -141,19 +128,6 @@ rb_statusbar_class_init (RBStatusbarClass *klass)
                                                               "RBDisplayPage object",
                                                               RB_TYPE_DISPLAY_PAGE,
                                                               G_PARAM_READWRITE));
-       /**
-        * RBStatusbar::transfer-queue:
-        *
-        * The #RBTrackTransferQueue instance
-        */
-       g_object_class_install_property (object_class,
-                                        PROP_TRANSFER_QUEUE,
-                                        g_param_spec_object ("transfer-queue",
-                                                             "RBTrackTransferQueue",
-                                                             "RBTrackTransferQueue instance",
-                                                             RB_TYPE_TRACK_TRANSFER_QUEUE,
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
        g_type_class_add_private (klass, sizeof (RBStatusbarPrivate));
 }
 
@@ -163,15 +137,6 @@ rb_statusbar_init (RBStatusbar *statusbar)
        statusbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (statusbar,
                                                       RB_TYPE_STATUSBAR,
                                                       RBStatusbarPrivate);
-
-        statusbar->priv->progress = gtk_progress_bar_new ();
-       gtk_widget_set_size_request (statusbar->priv->progress, -1, 10);
-
-        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (statusbar->priv->progress), 1.0);
-        gtk_widget_hide (statusbar->priv->progress);
-
-        gtk_box_pack_start (GTK_BOX (statusbar),
-                            GTK_WIDGET (statusbar->priv->progress), FALSE, TRUE, 0);
 }
 
 static void
@@ -201,11 +166,6 @@ rb_statusbar_dispose (GObject *object)
                statusbar->priv->selected_page = NULL;
        }
 
-       if (statusbar->priv->transfer_queue != NULL) {
-               g_object_unref (statusbar->priv->transfer_queue);
-               statusbar->priv->transfer_queue = NULL;
-       }
-
         G_OBJECT_CLASS (rb_statusbar_parent_class)->dispose (object);
 }
 
@@ -260,14 +220,6 @@ rb_statusbar_set_property (GObject *object,
                rb_statusbar_sync_status (statusbar);
 
                 break;
-       case PROP_TRANSFER_QUEUE:
-               statusbar->priv->transfer_queue = g_value_dup_object (value);
-               g_signal_connect_object (G_OBJECT (statusbar->priv->transfer_queue),
-                                        "transfer-progress",
-                                        G_CALLBACK (rb_statusbar_transfer_progress_cb),
-                                        statusbar,
-                                        0);
-               break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -290,9 +242,6 @@ rb_statusbar_get_property (GObject *object,
         case PROP_PAGE:
                 g_value_set_object (value, statusbar->priv->selected_page);
                 break;
-        case PROP_TRANSFER_QUEUE:
-                g_value_set_object (value, statusbar->priv->transfer_queue);
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -331,28 +280,9 @@ poll_status (RBStatusbar *status)
 static void
 rb_statusbar_sync_status (RBStatusbar *status)
 {
-        gboolean changed = FALSE;
         char *status_text = NULL;
        char *progress_text = NULL;
        float progress = 999;
-       int time_left = 0;
-
-        /*
-         * Behaviour of status bar:
-        * - use page's status text
-        * - use page's progress value and text, unless transfer queue provides something
-        * - if no page progress value or transfer progress value and library is busy,
-        *    pulse the progress bar
-         */
-        
-       /* library busy? */
-        if (rhythmdb_is_busy (status->priv->db)) {
-               progress = -1.0f;
-
-               /* see if it wants to provide more details */
-               rhythmdb_get_progress_info (status->priv->db, &progress_text, &progress);
-               changed = TRUE;
-        }
 
        /* get page details */
         if (status->priv->selected_page) {
@@ -361,59 +291,29 @@ rb_statusbar_sync_status (RBStatusbar *status)
                        status_text ? status_text : "", progress_text ? progress_text : "", progress);
        }
 
-       /* get transfer details */
-       rb_track_transfer_queue_get_status (status->priv->transfer_queue,
-                                           &status_text,
-                                           &progress_text,
-                                           &progress,
-                                           &time_left);
-
         /* set up the status text */
         if (status_text) {
                 gtk_statusbar_pop (GTK_STATUSBAR (status), 0);
                 gtk_statusbar_push (GTK_STATUSBAR (status), 0, status_text);
-               g_free (status_text);
         }
 
-        /* set up the progress bar */
-       if (progress > (1.0f - EPSILON)) {
-               gtk_widget_hide (status->priv->progress);
-       } else {
-                gtk_widget_show (status->priv->progress);
-
-                if (progress < EPSILON) {
-                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (status->priv->progress));
-                        changed = TRUE;
-                } else {
-                        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (status->priv->progress),
-                                                       progress);
-                }
-               gtk_progress_bar_set_text (GTK_PROGRESS_BAR (status->priv->progress),
-                                          progress_text);
-       }
-
        g_free (progress_text);
-
-        if (status->priv->status_poll_id == 0 && changed)
-                status->priv->status_poll_id = g_timeout_add (250, (GSourceFunc) poll_status, status);
+       g_free (status_text);
 }
 
 /**
  * rb_statusbar_new:
  * @db: the #RhythmDB instance
- * @transfer_queue: the #RBTrackTransferQueue
  *
  * Creates the status bar widget.
  *
  * Return value: the status bar widget
  */
 RBStatusbar *
-rb_statusbar_new (RhythmDB *db,
-                 RBTrackTransferQueue *queue)
+rb_statusbar_new (RhythmDB *db)
 {
         RBStatusbar *statusbar = g_object_new (RB_TYPE_STATUSBAR,
                                                "db", db,
-                                              "transfer-queue", queue,
                                                NULL);
 
         g_return_val_if_fail (statusbar->priv != NULL, NULL);
@@ -422,28 +322,10 @@ rb_statusbar_new (RhythmDB *db,
 }
 
 static void
-add_status_poll (RBStatusbar *statusbar)
+rb_statusbar_page_status_changed_cb (RBDisplayPage *page, RBStatusbar *statusbar)
 {
+       rb_debug ("source status changed");
         if (statusbar->priv->status_poll_id == 0)
                 statusbar->priv->status_poll_id =
                         g_idle_add ((GSourceFunc) poll_status, statusbar);
 }
-
-static void
-rb_statusbar_page_status_changed_cb (RBDisplayPage *page, RBStatusbar *statusbar)
-{
-       rb_debug ("source status changed");
-       add_status_poll (statusbar);
-}
-
-static void
-rb_statusbar_transfer_progress_cb (RBTrackTransferQueue *queue,
-                                  int done,
-                                  int total,
-                                  double progress,
-                                  int time_left,
-                                  RBStatusbar *statusbar)
-{
-       rb_debug ("transfer progress changed");
-       add_status_poll (statusbar);
-}
diff --git a/shell/rb-statusbar.h b/shell/rb-statusbar.h
index d5a5847..ec992f6 100644
--- a/shell/rb-statusbar.h
+++ b/shell/rb-statusbar.h
@@ -62,8 +62,7 @@ struct _RBStatusbarClass
 
 GType                  rb_statusbar_get_type   (void);
 
-RBStatusbar *          rb_statusbar_new        (RhythmDB *db,
-                                                RBTrackTransferQueue *transfer_queue);
+RBStatusbar *          rb_statusbar_new        (RhythmDB *db);
 
 void                   rb_statusbar_set_page   (RBStatusbar *statusbar,
                                                 RBDisplayPage *page);
diff --git a/shell/rb-track-transfer-queue.c b/shell/rb-track-transfer-queue.c
index 19531e9..c6a089e 100644
--- a/shell/rb-track-transfer-queue.c
+++ b/shell/rb-track-transfer-queue.c
@@ -552,60 +552,6 @@ rb_track_transfer_queue_cancel_batch (RBTrackTransferQueue *queue,
        }
 }
 
-/**
- * rb_track_transfer_queue_get_status:
- * @queue: the #RBTrackTransferQueue
- * @text: returns the status bar text
- * @progress_text: returns the progress bar text
- * @progress: returns the progress fraction
- * @time_left: returns the estimated number of seconds remaining
- *
- * Retrieves transfer status information.  Works similarly to
- * #rb_source_get_status.
- *
- * Return value: TRUE if transfer status information is returned
- */
-gboolean
-rb_track_transfer_queue_get_status (RBTrackTransferQueue *queue,
-                                   char **text,
-                                   char **progress_text,
-                                   float *progress,
-                                   int *time_left)
-{
-       int total;
-       int done;
-       double transfer_progress;
-
-       if (queue->priv->current == NULL) {
-               return FALSE;
-       }
-
-       g_object_get (queue->priv->current,
-                     "total-entries", &total,
-                     "done-entries", &done,
-                     "progress", &transfer_progress,
-                     NULL);
-       if (total > 0) {
-               char *s;
-
-               if (transfer_progress >= 0) {
-                       s = g_strdup_printf (_("Transferring track %d out of %d (%.0f%%)"),
-                                            done + 1, total, transfer_progress * 100);
-               } else {
-                       s = g_strdup_printf (_("Transferring track %d out of %d"),
-                                            done + 1, total);
-               }
-
-               g_free (*progress_text);
-               *progress_text = s;
-               *progress = transfer_progress;
-
-               *time_left = estimate_time_left (queue, transfer_progress);
-
-               return TRUE;
-       }
-       return FALSE;
-}
 
 struct FindBatchData
 {
diff --git a/shell/rb-track-transfer-queue.h b/shell/rb-track-transfer-queue.h
index dc7cf9a..a588029 100644
--- a/shell/rb-track-transfer-queue.h
+++ b/shell/rb-track-transfer-queue.h
@@ -70,11 +70,6 @@ void                 rb_track_transfer_queue_start_batch     (RBTrackTransferQueue *queue,
                                                                 RBTrackTransferBatch *batch);
 void                   rb_track_transfer_queue_cancel_batch    (RBTrackTransferQueue *queue,
                                                                 RBTrackTransferBatch *batch);
-gboolean               rb_track_transfer_queue_get_status      (RBTrackTransferQueue *queue,
-                                                                char **text,
-                                                                char **progress_text,
-                                                                float *progress,
-                                                                int *time_left);
 GList *                        rb_track_transfer_queue_find_batch_by_source (RBTrackTransferQueue *queue,
                                                                 RBSource *source);
 


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