[rhythmbox] android: tell user to unlock and enable MTP if no storage found



commit c69e4fdefb2c97fd02fcb6b50887a474c55472d0
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Feb 3 07:34:06 2016 +1000

    android: tell user to unlock and enable MTP if no storage found
    
    In Marshmallow, at least, you need to enable MTP each time the device is
    connected.  Doing so makes the usb device disappear (which removes the existing
    source) and reappear (creating a new one), so we don't need a button to trigger
    a rescan here.  Perhaps this is different for older versions though.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744775

 plugins/android/rb-android-source.c |   39 +++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/plugins/android/rb-android-source.c b/plugins/android/rb-android-source.c
index 0f75ec8..b9eddb5 100644
--- a/plugins/android/rb-android-source.c
+++ b/plugins/android/rb-android-source.c
@@ -94,6 +94,9 @@ typedef struct
        GList *query_storage;
        guint64 storage_free_space_next;
        guint64 storage_capacity_next;
+
+       GtkWidget *grid;
+       GtkWidget *info_bar;
 } RBAndroidSourcePrivate;
 
 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
@@ -170,10 +173,21 @@ static void
 music_dirs_done (RBAndroidSource *source)
 {
        RBAndroidSourcePrivate *priv = GET_PRIVATE(source);
-       rb_debug ("finished checking for music dirs");
+
        rhythmdb_import_job_start (priv->import_job);
 
-       update_free_space (source);
+       if (priv->storage == NULL) {
+               GtkWidget *label;
+
+               rb_debug ("no storage areas found");
+               label = gtk_label_new (_("No storage areas found on this device. You may need to unlock it 
and enable MTP."));
+               gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR 
(priv->info_bar))), label);
+               gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->info_bar), GTK_MESSAGE_INFO);
+               gtk_widget_show_all (priv->info_bar);
+       } else {
+               rb_debug ("finished checking for music dirs");
+               update_free_space (source);
+       }
 }
 
 
@@ -730,6 +744,12 @@ impl_delete_thyself (RBDisplayPage *page)
        RB_DISPLAY_PAGE_CLASS (rb_android_source_parent_class)->delete_thyself (page);
 }
 
+static void
+impl_pack_content (RBBrowserSource *source, GtkWidget *content)
+{
+       RBAndroidSourcePrivate *priv = GET_PRIVATE (source);
+       gtk_grid_attach (GTK_GRID (priv->grid), content, 0, 1, 1, 1);
+}
 
 static void
 rb_android_source_init (RBAndroidSource *source)
@@ -746,10 +766,18 @@ impl_constructed (GObject *object)
        RBShell *shell;
        char **output_formats;
 
-       RB_CHAIN_GOBJECT_METHOD (rb_android_source_parent_class, constructed, object);
        source = RB_ANDROID_SOURCE (object);
-
        priv = GET_PRIVATE (source);
+       priv->grid = gtk_grid_new ();
+
+       RB_CHAIN_GOBJECT_METHOD (rb_android_source_parent_class, constructed, object);
+
+       priv->info_bar = gtk_info_bar_new ();
+       gtk_grid_attach (GTK_GRID (priv->grid), priv->info_bar, 0, 0, 1, 1);
+
+       gtk_container_add (GTK_CONTAINER (source), priv->grid);
+       gtk_widget_show_all (priv->grid);
+       gtk_widget_hide (priv->info_bar);
 
        rb_device_source_set_display_details (RB_DEVICE_SOURCE (source));
 
@@ -905,6 +933,7 @@ rb_android_source_class_init (RBAndroidSourceClass *klass)
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
        RBDisplayPageClass *page_class = RB_DISPLAY_PAGE_CLASS (klass);
        RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
+       RBBrowserSourceClass *browser_class = RB_BROWSER_SOURCE_CLASS (klass);
        RBMediaPlayerSourceClass *mps_class = RB_MEDIA_PLAYER_SOURCE_CLASS (klass);
 
        object_class->set_property = impl_set_property;
@@ -916,6 +945,8 @@ rb_android_source_class_init (RBAndroidSourceClass *klass)
        page_class->delete_thyself = impl_delete_thyself;
        page_class->selected = impl_selected;
 
+       browser_class->pack_content = impl_pack_content;
+
        source_class->can_delete = impl_can_delete;
        source_class->delete_selected = impl_delete_selected;
        source_class->can_move_to_trash = (RBSourceFeatureFunc) rb_false_function;


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