[goobox] show a message bar while fetching the disc information



commit 46afa225bca2eceb241defb4bb781f24322a6b4f
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Apr 14 12:56:23 2013 +0200

    show a message bar while fetching the disc information

 src/goo-player.c |   22 ++++++++++++++-
 src/goo-window.c |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 99 insertions(+), 3 deletions(-)
---
diff --git a/src/goo-player.c b/src/goo-player.c
index 02e3906..3c32f24 100644
--- a/src/goo-player.c
+++ b/src/goo-player.c
@@ -104,10 +104,26 @@ destroy_pipeline (GooPlayer *player)
 
 
 static void
+action_start (GooPlayer       *self,
+             GooPlayerAction  action)
+{
+       g_signal_emit (G_OBJECT (self),
+                      goo_player_signals[START],
+                      0,
+                      action,
+                      NULL);
+}
+
+
+static void
 action_done (GooPlayer       *self,
             GooPlayerAction  action)
 {
-       g_signal_emit_by_name (G_OBJECT (self), "done", action, NULL);
+       g_signal_emit (G_OBJECT (self),
+                      goo_player_signals[DONE],
+                      0,
+                      action,
+                      NULL);
 }
 
 
@@ -579,6 +595,8 @@ album_info_from_disc_id_ready_cb (GObject      *source_object,
 
                album_list_free (albums);
        }
+       else
+               action_done (player, GOO_PLAYER_ACTION_METADATA);
 }
 
 
@@ -612,6 +630,8 @@ get_cd_info_from_device_ready_cb (GObject      *source_object,
                return;
        }
 
+       action_start (player, GOO_PLAYER_ACTION_METADATA);
+
        metadata_get_album_info_from_disc_id (player->priv->discid,
                                              player->priv->cancellable,
                                              album_info_from_disc_id_ready_cb,
diff --git a/src/goo-window.c b/src/goo-window.c
index b8e9a26..cca0e38 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -56,6 +56,7 @@
 #define TRAY_TOOLTIP_DELAY 500
 #define AUTOPLAY_DELAY 250
 #define MAX_WINDOW_HEIGHT_PERCENTAGE 0.80
+#define MESSAGE_BAR_RESPONSE_PROPERTIES 1
 
 struct _GooWindowPrivate {
        GtkWidget         *list_view;
@@ -69,6 +70,9 @@ struct _GooWindowPrivate {
        GtkWidget         *file_popup_menu;
        GtkWidget         *cover_popup_menu;
 
+       GtkWidget         *message_bar;
+       GtkWidget         *message_label;
+       GtkWidget         *message_bar_properties_button;
        GtkWidget         *info;
        GtkWidget         *player_bar;
 
@@ -1265,6 +1269,36 @@ notify_current_state (GooWindow       *window,
 
 
 static void
+goo_window_show_message_bar_action (GooWindow  *window,
+                                   const char *message)
+{
+       gtk_label_set_text (GTK_LABEL (window->priv->message_label), message);
+       gtk_info_bar_set_message_type (GTK_INFO_BAR (window->priv->message_bar), GTK_MESSAGE_INFO);
+       gtk_widget_hide (window->priv->message_bar_properties_button);
+       gtk_widget_show (window->priv->message_bar);
+}
+
+
+static void
+goo_window_show_message_bar_result (GooWindow      *window,
+                                   const char     *message,
+                                   GtkMessageType  message_type)
+{
+       gtk_label_set_text (GTK_LABEL (window->priv->message_label), message);
+       gtk_info_bar_set_message_type (GTK_INFO_BAR (window->priv->message_bar), message_type);
+       gtk_widget_hide (window->priv->message_bar_properties_button);
+       gtk_widget_show (window->priv->message_bar);
+}
+
+
+static void
+goo_window_hide_message_bar (GooWindow *window)
+{
+       gtk_widget_hide (window->priv->message_bar);
+}
+
+
+static void
 player_start_cb (GooPlayer       *player,
                 GooPlayerAction  action,
                 GooWindow       *window)
@@ -1275,6 +1309,7 @@ player_start_cb (GooPlayer       *player,
        case GOO_PLAYER_ACTION_PLAY:
        case GOO_PLAYER_ACTION_METADATA:
                notify_current_state (window, action);
+               goo_window_show_message_bar_action (window, _("Searching disc information…"));
                break;
 
        default:
@@ -1565,6 +1600,12 @@ player_done_cb (GooPlayer       *player,
                goo_window_update_album (window);
                goo_window_update_titles (window);
                window_update_title (window);
+               if (window->priv->album->title == NULL) {
+                       goo_window_show_message_bar_result (window, _("No information found for this disc"), 
GTK_MESSAGE_WARNING);
+                       gtk_widget_show (window->priv->message_bar_properties_button);
+               }
+               else
+                       goo_window_hide_message_bar (window);
                auto_fetch_cover_image (window);
                break;
 
@@ -2028,6 +2069,25 @@ _goo_window_enable_media_keys (GooWindow *window)
 
 
 static void
+message_bar_response_cb (GtkInfoBar *info_bar,
+                        int         response_id,
+                        gpointer    user_data)
+{
+       GooWindow *window = user_data;
+
+       switch (response_id) {
+       case GTK_RESPONSE_CLOSE:
+               goo_window_hide_message_bar (window);
+               break;
+       case MESSAGE_BAR_RESPONSE_PROPERTIES:
+               activate_action_properties (NULL, window);
+               goo_window_hide_message_bar (window);
+               break;
+       }
+}
+
+
+static void
 goo_window_construct (GooWindow    *window,
                      BraseroDrive *drive)
 {
@@ -2157,10 +2217,26 @@ goo_window_construct (GooWindow    *window,
                g_object_unref (builder);
         }
 
-       /**/
-
        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 
+       /* message bar */
+
+       window->priv->message_bar = gtk_info_bar_new ();
+       gtk_widget_set_no_show_all (window->priv->message_bar, TRUE);
+       window->priv->message_label = gtk_label_new ("");
+       gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR 
(window->priv->message_bar))), window->priv->message_label);
+       window->priv->message_bar_properties_button = gtk_button_new_from_stock (GTK_STOCK_PROPERTIES);
+       gtk_info_bar_add_action_widget (GTK_INFO_BAR (window->priv->message_bar), 
window->priv->message_bar_properties_button, MESSAGE_BAR_RESPONSE_PROPERTIES);
+       gtk_info_bar_add_button (GTK_INFO_BAR (window->priv->message_bar), GTK_STOCK_CLOSE, 
GTK_RESPONSE_CLOSE);
+       g_signal_connect (window->priv->message_bar,
+                         "response",
+                         G_CALLBACK (message_bar_response_cb),
+                         window);
+       gtk_widget_show (window->priv->message_label);
+       gtk_box_pack_start (GTK_BOX (vbox), window->priv->message_bar, FALSE, FALSE, 0);
+
+       /**/
+
        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
        gtk_widget_set_vexpand (hbox, FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);


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