[easytag/wip/musicbrainz-support] Implemented Double Clicking for Automatic Search. And Refresh for Automatic Search



commit 1efe5ff8fa392ad5e8285797fbd1db847171c838
Author: Abhinav <abhijangda hotmail com>
Date:   Sat Jul 12 15:05:11 2014 +0530

    Implemented Double Clicking for Automatic Search. And Refresh for Automatic Search

 src/mb_search.c          |    6 ++++++
 src/mbentityview.c       |   21 +++++++++++++++++----
 src/musicbrainz_dialog.c |   37 +++++++++++++++++++++++++++++++++++--
 3 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
index 502e05a..1b9f579 100755
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -353,6 +353,12 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
             goto err;
         }
     }
+    else if (child_type == MB_ENTITY_KIND_ALBUM &&
+             parent_type == MB_ENTITY_KIND_FREEDBID)
+    {
+        return et_musicbrainz_search (parent_mbid, child_type, root, error,
+                                      cancellable);
+    }
 
     CHECK_CANCELLED(cancellable);
     mb5_query_delete (query);
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 73e97b5..f4c7a62 100755
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -711,8 +711,8 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
                           G_CALLBACK (toggle_button_clicked), entity_view);
         priv->active_toggle_button = toggle_btn;
     
-        gtk_tree_model_get (priv->list_store, &thread_data->iter, 0, &entity_name,
-                            -1);
+        gtk_tree_model_get (priv->list_store, &thread_data->iter, 0,
+                            &entity_name, -1);
         gtk_button_set_label (GTK_BUTTON (toggle_btn), entity_name);
         gtk_widget_show_all (GTK_WIDGET (priv->bread_crumb_box));
     }
@@ -753,6 +753,7 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
     gchar *status_msg;
     gchar parent_entity_str [NAME_MAX_SIZE];
     gchar *child_entity_type_str;
+    MbEntityKind to_search;
 
     child_entity_type_str = NULL;
     thread_data = g_async_result_get_user_data (G_ASYNC_RESULT (res));
@@ -782,6 +783,7 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
                            mbid, sizeof (mbid));
         mb5_artist_get_name (((EtMbEntity *)thread_data->child->data)->entity,
                              parent_entity_str, sizeof (parent_entity_str));
+        to_search = MB_ENTITY_KIND_ALBUM;
     }
     else if (((EtMbEntity *)thread_data->child->data)->type ==
              MB_ENTITY_KIND_ALBUM)
@@ -791,6 +793,16 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
                             mbid, sizeof (mbid));
         mb5_release_get_title (((EtMbEntity *)thread_data->child->data)->entity,
                                parent_entity_str, sizeof (parent_entity_str));
+        to_search = MB_ENTITY_KIND_TRACK;
+    }
+    else if (((EtMbEntity *)thread_data->child->data)->type ==
+             MB_ENTITY_KIND_FREEDBID)
+    {
+        child_entity_type_str = g_strdup ("Albums ");
+        mb5_freedbdisc_get_title (((EtMbEntity *)thread_data->child->data)->entity,
+                                  mbid, sizeof (mbid));
+        g_stpcpy (parent_entity_str, mbid);
+        to_search = MB_ENTITY_KIND_ALBUM;
     }
 
     error = NULL;
@@ -811,7 +823,7 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
         return;
     }
 
-    if (!et_musicbrainz_search_in_entity (((EtMbEntity *)thread_data->child->data)->type + 1,
+    if (!et_musicbrainz_search_in_entity (to_search,
                                           ((EtMbEntity *)thread_data->child->data)->type,
                                           mbid, thread_data->child, &error,
                                           cancellable))
@@ -859,7 +871,8 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
 
     child = g_node_nth_child (priv->mb_tree_current_node,
                               depth);
-    search_in_levels (ET_MB_ENTITY_VIEW (user_data), child, &filter_iter, FALSE);
+    search_in_levels (ET_MB_ENTITY_VIEW (user_data), child, &filter_iter,
+                      FALSE);
 }
 
 static void
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 9353bc9..7d0aeb5 100755
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -58,6 +58,7 @@ typedef enum
 {
     ET_MB_SEARCH_TYPE_MANUAL,
     ET_MB_SEARCH_TYPE_SELECTED,
+    ET_MB_SEARCH_TYPE_AUTOMATIC,
 } EtMbSearchType;
 
 typedef struct
@@ -87,6 +88,11 @@ typedef struct
 
 typedef struct
 {
+    EtMbSearch parent;
+} EtMbAutomaticSearch;
+
+typedef struct
+{
     GNode *mb_tree_root;
     GSimpleAsyncResult *async_result;
     EtMbSearch *search;
@@ -118,6 +124,8 @@ static void
 btn_close_clicked (GtkWidget *button, gpointer data);
 static void
 bt_selected_find_clicked (GtkWidget *widget, gpointer user_data);
+static void
+btn_automatic_search_clicked (GtkWidget *button, gpointer data);
 /*************
  * Functions *
  *************/
@@ -136,6 +144,9 @@ et_mb_destroy_search (EtMbSearch **search)
             g_list_free_full (((EtMbSelectedSearch *)(*search))->list_iter,
                               (GDestroyNotify)gtk_tree_iter_free);
         }
+        else if ((*search)->type == ET_MB_SEARCH_TYPE_AUTOMATIC)
+        {
+        }
 
         g_free (*search);
     }
@@ -162,6 +173,14 @@ et_mb_set_selected_search (EtMbSearch **search, GList *list_files)
     ((EtMbSelectedSearch *)(*search))->list_iter = list_files;
 }
 
+static void
+et_mb_set_automatic_search (EtMbSearch **search)
+{
+    et_mb_destroy_search (search);
+    *search = g_malloc (sizeof (EtMbAutomaticSearch));
+    (*search)->type = ET_MB_SEARCH_TYPE_AUTOMATIC;
+}
+
 /*
  * manual_search_callback:
  * @source: Source Object
@@ -306,7 +325,8 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
     }
 
     thread_data = (ManualSearchThreadData *)g_async_result_get_user_data (G_ASYNC_RESULT (res));
-    status_msg = g_strdup_printf (_("Searching %s"), thread_data->text_to_search);
+    status_msg = g_strdup_printf (_("Searching %s"),
+                                  thread_data->text_to_search);
     et_show_status_msg_in_idle (status_msg);
     g_free (status_msg);
 
@@ -516,9 +536,21 @@ tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
         //EtMbSelectedSearch *search;
 
         //search = (EtMbSelectedSearch *)mb_dialog_priv->search;
+        free_mb_tree (&mb_dialog_priv->mb_tree_root);
+        mb_dialog_priv->mb_tree_root = g_node_new (NULL);
         et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
         bt_selected_find_clicked (NULL, NULL);
     }
+    else if (mb_dialog_priv->search->type == ET_MB_SEARCH_TYPE_AUTOMATIC)
+    {
+        //EtMbSelectedSearch *search;
+
+        //search = (EtMbSelectedSearch *)mb_dialog_priv->search;
+        free_mb_tree (&mb_dialog_priv->mb_tree_root);
+        mb_dialog_priv->mb_tree_root = g_node_new (NULL);
+        et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
+        btn_automatic_search_clicked (NULL, NULL);
+    }
 }
 
 /*
@@ -897,6 +929,7 @@ freedbid_search_callback (GObject *source, GAsyncResult *res,
     g_object_unref (res);
     g_free (user_data);
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
+    et_mb_set_automatic_search (&mb_dialog_priv->search);
 
     if (exit_on_complete)
     {
@@ -1060,7 +1093,7 @@ btn_automatic_search_clicked (GtkWidget *button, gpointer data)
                         0, _("Starting MusicBrainz Search"));
     mb_dialog_priv->async_result = g_simple_async_result_new (NULL,
                                                               freedbid_search_callback,
-                                                              cddb_discid,
+                                                              g_strdup("24028103"),
                                                               btn_automatic_search_clicked);
     g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
                                          freedbid_search_thread_func, 0,


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