[easytag/wip/musicbrainz-support-appwin-merge: 19/82] Use MB_ENTITY_KIND



commit 1b61e6e96a6e73379f66fd30f2fa1427cdf29224
Author: Abhinav <abhijangda hotmail com>
Date:   Sun Jun 22 22:07:22 2014 +0530

    Use MB_ENTITY_KIND
    
    Change MB_ENTITY_TYPE_* to MB_ENTITY_KIND_*

 src/mb_search.c          |   40 ++++++++++----------
 src/mb_search.h          |   22 +++++-----
 src/mbentityview.c       |   93 +++++++++++++++++++++++++++------------------
 src/mbentityview.h       |    3 +-
 src/musicbrainz_dialog.c |   49 +++++++++++++++++++-----
 tests/error.xml          |    1 +
 6 files changed, 129 insertions(+), 79 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
old mode 100644
new mode 100755
index d907a11..acbfa1e
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -64,8 +64,8 @@ et_musicbrainz_search_set_server_port (gchar *_server, int _port)
  * Returns: TRUE if successful, FALSE if not.
  */
 gboolean
-et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
-                                 enum MB_ENTITY_TYPE parent_type,
+et_musicbrainz_search_in_entity (MbEntityKind child_type,
+                                 MbEntityKind parent_type,
                                  gchar *parent_mbid, GNode *root,
                                  GError **error, GCancellable *cancellable)
 {
@@ -88,8 +88,8 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
     param_names [0] = "inc";
     query = mb5_query_new ("easytag", server, port);
 
-    if (child_type == MB_ENTITY_TYPE_ALBUM &&
-        parent_type == MB_ENTITY_TYPE_ARTIST)
+    if (child_type == MB_ENTITY_KIND_ALBUM &&
+        parent_type == MB_ENTITY_KIND_ARTIST)
     {
         param_values [0] = "releases";
         metadata = mb5_query_query (query, "artist", parent_mbid, "", 1,
@@ -171,7 +171,7 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
                                                             param_values);
                         entity = g_malloc (sizeof (EtMbEntity));
                         entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                        entity->type = MB_ENTITY_TYPE_ALBUM;
+                        entity->type = MB_ENTITY_KIND_ALBUM;
                         entity->is_red_line = FALSE;
                         node = g_node_new (entity);
                         g_node_append (root, node);
@@ -187,8 +187,8 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
             goto err;
         }
     }
-    else if (child_type == MB_ENTITY_TYPE_TRACK &&
-             parent_type == MB_ENTITY_TYPE_ALBUM)
+    else if (child_type == MB_ENTITY_KIND_TRACK &&
+             parent_type == MB_ENTITY_KIND_ALBUM)
     {
         param_values [0] = "recordings";
         metadata = mb5_query_query (query, "release", parent_mbid, "", 1,
@@ -269,7 +269,7 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
                                                                   param_values);
                             entity = g_malloc (sizeof (EtMbEntity));
                             entity->entity = mb5_recording_clone (mb5_metadata_get_recording 
(metadata_recording));
-                            entity->type = MB_ENTITY_TYPE_TRACK;
+                            entity->type = MB_ENTITY_KIND_TRACK;
                             entity->is_red_line = FALSE;
                             node = g_node_new (entity);
                             g_node_append (root, node);
@@ -348,7 +348,7 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
  * Returns: TRUE if successfull, FALSE if not.
  */
 gboolean
-et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
+et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
                        GError **error, GCancellable *cancellable)
 {
     Mb5Query query;
@@ -375,7 +375,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
         return FALSE;
     }
 
-    if (type == MB_ENTITY_TYPE_ARTIST)
+    if (type == MB_ENTITY_KIND_ARTIST)
     {
         param_values [0] = g_strconcat ("artist:", string, NULL);
         metadata = mb5_query_query (query, "artist", "", "", 2, param_names,
@@ -414,7 +414,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
                         EtMbEntity *entity;
                         entity = g_malloc (sizeof (EtMbEntity));
                         entity->entity = mb5_artist_clone (artist);
-                        entity->type = MB_ENTITY_TYPE_ARTIST;
+                        entity->type = MB_ENTITY_KIND_ARTIST;
                         entity->is_red_line = FALSE;
                         node = g_node_new (entity);
                         g_node_append (root, node);
@@ -430,7 +430,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
         }
     }
 
-    else if (type == MB_ENTITY_TYPE_ALBUM)
+    else if (type == MB_ENTITY_KIND_ALBUM)
     {
         param_values [0] = g_strconcat ("release:", string, NULL);
         metadata = mb5_query_query (query, "release", "", "", 2, param_names,
@@ -501,7 +501,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
                                                             param_values);
                         entity = g_malloc (sizeof (EtMbEntity));
                         entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                        entity->type = MB_ENTITY_TYPE_ALBUM;
+                        entity->type = MB_ENTITY_KIND_ALBUM;
                         entity->is_red_line = FALSE;
                         node = g_node_new (entity);
                         g_node_append (root, node);
@@ -518,7 +518,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
         }
     }
 
-    else if (type == MB_ENTITY_TYPE_TRACK)
+    else if (type == MB_ENTITY_KIND_TRACK)
     {
         param_values [0] = g_strconcat ("recordings:", string, NULL);
         metadata = mb5_query_query (query, "recording", "", "", 2,
@@ -584,7 +584,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
                                                           param_values);
                     entity = g_malloc (sizeof (EtMbEntity));
                     entity->entity = mb5_recording_clone (mb5_metadata_get_recording (metadata_recording));
-                    entity->type = MB_ENTITY_TYPE_TRACK;
+                    entity->type = MB_ENTITY_KIND_TRACK;
                     entity->is_red_line = FALSE;
                     node = g_node_new (entity);
                     g_node_append (root, node);
@@ -600,7 +600,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
         }
     }
 
-    else if (type == MB_ENTITY_TYPE_DISCID)
+    else if (type == MB_ENTITY_KIND_DISCID)
     {
         param_names[0] = "toc";
         param_values [0] = "";
@@ -673,7 +673,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
                                                             param_values);
                         entity = g_malloc (sizeof (EtMbEntity));
                         entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                        entity->type = MB_ENTITY_TYPE_ALBUM;
+                        entity->type = MB_ENTITY_KIND_ALBUM;
                         entity->is_red_line = FALSE;
                         node = g_node_new (entity);
                         g_node_append (root, node);
@@ -755,17 +755,17 @@ free_mb_tree (GNode *node)
 
     if (et_entity)
     {
-        if (et_entity->type == MB_ENTITY_TYPE_ARTIST)
+        if (et_entity->type == MB_ENTITY_KIND_ARTIST)
         {
             mb5_artist_delete ((Mb5Artist)et_entity->entity);
         }
 
-        else if (et_entity->type == MB_ENTITY_TYPE_ALBUM)
+        else if (et_entity->type == MB_ENTITY_KIND_ALBUM)
         {
             mb5_release_delete ((Mb5Release)et_entity->entity);
         }
 
-        else if (et_entity->type == MB_ENTITY_TYPE_TRACK)
+        else if (et_entity->type == MB_ENTITY_KIND_TRACK)
         {
             mb5_recording_delete ((Mb5Recording)et_entity->entity);
         }
diff --git a/src/mb_search.h b/src/mb_search.h
old mode 100644
new mode 100755
index c7add97..9ca25f6
--- a/src/mb_search.h
+++ b/src/mb_search.h
@@ -69,19 +69,19 @@ typedef enum
     ET_MB5_SEARCH_ERROR_DISCID,
 } EtMB5SearchError;
 
-enum MB_ENTITY_TYPE
+typedef enum _MbEntityKind
 {
-    MB_ENTITY_TYPE_ARTIST = 0,
-    MB_ENTITY_TYPE_ALBUM,
-    MB_ENTITY_TYPE_TRACK,
-    MB_ENTITY_TYPE_COUNT,
-    MB_ENTITY_TYPE_DISCID,
-};
+    MB_ENTITY_KIND_ARTIST = 0,
+    MB_ENTITY_KIND_ALBUM,
+    MB_ENTITY_KIND_TRACK,
+    MB_ENTITY_KIND_COUNT,
+    MB_ENTITY_KIND_DISCID,
+} MbEntityKind;
 
 typedef struct
 {
     Mb5Entity entity;
-    enum MB_ENTITY_TYPE type;
+    MbEntityKind type;
     gboolean is_red_line;
 } EtMbEntity;
 
@@ -92,12 +92,12 @@ typedef struct
 void
 et_musicbrainz_search_set_server_port (gchar *server, int port);
 gboolean
-et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
-                                 enum MB_ENTITY_TYPE parent_type,
+et_musicbrainz_search_in_entity (MbEntityKind child_type,
+                                 MbEntityKind parent_type,
                                  gchar *parent_mbid, GNode *root,
                                  GError **error, GCancellable *cancellable);
 gboolean
-et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
+et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
                        GError **error, GCancellable *cancellable);
 void
 free_mb_tree (GNode *node);
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 7814ea0..3f96dc7 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -38,7 +38,7 @@ G_DEFINE_TYPE (EtMbEntityView, et_mb_entity_view, GTK_TYPE_BOX)
  * Declaration *
  ***************/
 
-char *columns [MB_ENTITY_TYPE_COUNT][8] = {
+char *columns [MB_ENTITY_KIND_COUNT][8] = {
     {"Name", "Gender", "Type"},
     {"Name", "Artist", "Type"},
     {"Name", "Album", "Artist", "Time"},
@@ -79,7 +79,7 @@ static GSimpleAsyncResult *async_result;
 typedef struct
 {
     GtkWidget *bread_crumb_box;
-    GNode *bread_crumb_nodes[MB_ENTITY_TYPE_COUNT];
+    GNode *bread_crumb_nodes[MB_ENTITY_KIND_COUNT];
     GtkWidget *tree_view;
     GtkTreeModel *list_store;
     GtkWidget *scrolled_window;
@@ -131,8 +131,7 @@ static gboolean
 tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
                           gpointer data);
 static void
-et_mb_entity_view_destroy (GtkWidget *object);
-
+et_mb_entity_view_finalize (GObject *object);
 /*************
  * Functions *
  *************/
@@ -152,7 +151,9 @@ tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
                           gpointer data)
 {
     EtMbEntityViewPrivate *priv;
+    int columns;
 
+    columns = gtk_tree_model_get_n_columns (model);
     priv = (EtMbEntityViewPrivate *)data;
 
     if (priv->search_or_red == ET_MB_DISPLAY_RESULTS_ALL)
@@ -179,17 +180,15 @@ tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
     {
         gchar *value;
 
-        if (gtk_tree_model_get_n_columns (model) == MB_ARTIST_COLUMNS_N + 1)
+        if (columns == MB_ARTIST_COLUMNS_N + 1)
         {
             gtk_tree_model_get (model, iter, MB_ARTIST_COLUMNS_N, &value, -1);
         }
-        else if (gtk_tree_model_get_n_columns (model) ==
-                 MB_ALBUM_COLUMNS_N + 1)
+        else if (columns == MB_ALBUM_COLUMNS_N + 1)
         {
             gtk_tree_model_get (model, iter, MB_ALBUM_COLUMNS_N, &value, -1);
         }
-        else if (gtk_tree_model_get_n_columns (model) ==
-                 MB_TRACK_COLUMNS_N + 1)
+        else if (columns == MB_TRACK_COLUMNS_N + 1)
         {
             gtk_tree_model_get (model, iter, MB_TRACK_COLUMNS_N, &value, -1);
         }
@@ -221,11 +220,8 @@ tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
 static void
 et_mb_entity_view_class_init (EtMbEntityViewClass *klass)
 {
-    GtkWidgetClass *widget_class;
-
     g_type_class_add_private (klass, sizeof (EtMbEntityViewPrivate));
-    widget_class = GTK_WIDGET_CLASS (klass);
-    widget_class->destroy = et_mb_entity_view_destroy;
+    G_OBJECT_CLASS (klass)->finalize = et_mb_entity_view_finalize;
 }
 
 /*
@@ -255,7 +251,7 @@ static void
 add_iter_to_list_store (GtkListStore *list_store, GNode *node)
 {
     /* Traverse node in GNode and add it to list_store */
-    enum MB_ENTITY_TYPE type;
+    MbEntityKind type;
     Mb5ArtistCredit artist_credit;
     Mb5NameCreditList name_list;
     Mb5ReleaseGroup release_group;
@@ -276,10 +272,11 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
 
         switch (type)
         {
-            case MB_ENTITY_TYPE_ARTIST:
+            case MB_ENTITY_KIND_ARTIST:
                 mb5_artist_get_name ((Mb5Artist)entity, name, sizeof (name));
                 gtk_list_store_insert_with_values (list_store, &iter, -1,
-                                        MB_ARTIST_COLUMNS_N, "black", -1);
+                                                   MB_ARTIST_COLUMNS_N,
+                                                   "black", -1);
                 gtk_list_store_set (list_store, &iter,
                                     MB_ARTIST_COLUMNS_NAME, name, -1);
 
@@ -306,7 +303,7 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
 
                 break;
 
-            case MB_ENTITY_TYPE_ALBUM:
+            case MB_ENTITY_KIND_ALBUM:
                 mb5_release_get_title ((Mb5Release)entity, name,
                                        sizeof (name));
                 gtk_list_store_insert_with_values (list_store, &iter, -1,
@@ -356,7 +353,7 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                                     MB_ALBUM_COLUMNS_TYPE, name, -1);
                 break;
 
-            case MB_ENTITY_TYPE_TRACK:
+            case MB_ENTITY_KIND_TRACK:
                 mb5_recording_get_title ((Mb5Recording)entity, name,
                                          sizeof (name));
                 gtk_list_store_append (list_store, &iter);
@@ -423,8 +420,8 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                                     name, -1);
                 break;
 
-            case MB_ENTITY_TYPE_COUNT:
-            case MB_ENTITY_TYPE_DISCID:
+            case MB_ENTITY_KIND_COUNT:
+            case MB_ENTITY_KIND_DISCID:
                 break;
  
         }
@@ -480,15 +477,15 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
     type = ((EtMbEntity *)(g_node_first_child (priv->mb_tree_current_node)->data))->type;
     switch (type)
     {
-        case MB_ENTITY_TYPE_ARTIST:
+        case MB_ENTITY_KIND_ARTIST:
             total_cols = MB_ARTIST_COLUMNS_N;
             break;
 
-        case MB_ENTITY_TYPE_ALBUM:
+        case MB_ENTITY_KIND_ALBUM:
             total_cols = MB_ALBUM_COLUMNS_N;
             break;
 
-        case MB_ENTITY_TYPE_TRACK:
+        case MB_ENTITY_KIND_TRACK:
             total_cols = MB_TRACK_COLUMNS_N;
             break;
 
@@ -511,8 +508,14 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
 
     /* Setting the colour column */
     types [total_cols] = G_TYPE_STRING;
+    //if (priv->list_store == NULL)
     priv->list_store = GTK_TREE_MODEL (gtk_list_store_newv (total_cols + 1,
                                                             types));
+    /*else FIXME:
+    {
+        gtk_list_store_clear (GTK_LIST_STORE (priv->list_store));
+        gtk_list_store_set_column_types (GTK_LIST_STORE (priv->list_store), total_cols + 1, types);
+    }*/
     priv->filter = GTK_TREE_MODEL (gtk_tree_model_filter_new (priv->list_store,
                                                               NULL));
     gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (priv->filter),
@@ -679,12 +682,12 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
     }
 
     if (((EtMbEntity *)thread_data->child->data)->type ==
-        MB_ENTITY_TYPE_TRACK)
+        MB_ENTITY_KIND_TRACK)
     {
         return;
     }
     else if (((EtMbEntity *)thread_data->child->data)->type ==
-             MB_ENTITY_TYPE_ARTIST)
+             MB_ENTITY_KIND_ARTIST)
     {
         child_entity_type_str = g_strdup ("Albums ");
         mb5_artist_get_id (((EtMbEntity *)thread_data->child->data)->entity,
@@ -693,7 +696,7 @@ search_in_levels_thread_func (GSimpleAsyncResult *res, GObject *obj,
                              parent_entity_str, sizeof (parent_entity_str));
     }
     else if (((EtMbEntity *)thread_data->child->data)->type ==
-             MB_ENTITY_TYPE_ALBUM)
+             MB_ENTITY_KIND_ALBUM)
     {
         child_entity_type_str = g_strdup ("Tracks ");
         mb5_release_get_id (((EtMbEntity *)thread_data->child->data)->entity,
@@ -771,7 +774,7 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
                               depth);
 
     if (((EtMbEntity *)child->data)->type ==
-        MB_ENTITY_TYPE_TRACK)
+        MB_ENTITY_KIND_TRACK)
     {
         return;
     }
@@ -818,10 +821,11 @@ et_mb_entity_view_init (EtMbEntityView *entity_view)
     priv->bread_crumb_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
     priv->tree_view = gtk_tree_view_new ();
     priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
     gtk_container_add (GTK_CONTAINER (priv->scrolled_window),
                        priv->tree_view);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
-                                    GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
     gtk_box_pack_start (GTK_BOX (entity_view), priv->bread_crumb_box,
                         FALSE, FALSE, 2);
     gtk_box_pack_start (GTK_BOX (entity_view), priv->scrolled_window,
@@ -831,7 +835,7 @@ et_mb_entity_view_init (EtMbEntityView *entity_view)
     priv->active_toggle_button = NULL;
     priv->toggle_red_lines = TRUE;
     priv->search_or_red = ET_MB_DISPLAY_RESULTS_ALL;
-
+    priv->list_store = NULL;
     g_signal_connect (G_OBJECT (priv->tree_view), "row-activated",
                       G_CALLBACK (tree_view_row_activated), entity_view);
 }
@@ -876,15 +880,15 @@ et_mb_entity_view_set_tree_root (EtMbEntityView *entity_view, GNode *treeRoot)
     {
         switch (((EtMbEntity *)child->data)->type)
         {
-            case MB_ENTITY_TYPE_ARTIST:
+            case MB_ENTITY_KIND_ARTIST:
                 gtk_button_set_label (GTK_BUTTON (btn), _("Artists"));
                 break;
 
-            case MB_ENTITY_TYPE_ALBUM:
+            case MB_ENTITY_KIND_ALBUM:
                 gtk_button_set_label (GTK_BUTTON (btn), _("Albums"));
                 break;
 
-            case MB_ENTITY_TYPE_TRACK:
+            case MB_ENTITY_KIND_TRACK:
                 gtk_button_set_label (GTK_BUTTON (btn), _("Tracks"));
                 break;
 
@@ -1092,14 +1096,11 @@ et_mb_entity_view_select_down (EtMbEntityView *entity_view)
     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
     selected_rows = gtk_tree_selection_get_selected_rows (selection,
                                                           &priv->filter);
-<<<<<<< HEAD
     if (!selected_rows)
     {
         return;
     }
 
-=======
->>>>>>> d1b3578... Coding Style Improvements and Converted Strings to Translatable Strings
     gtk_tree_model_get_iter (priv->filter, &iter,
                              g_list_last (selected_rows)->data);
     if (!gtk_tree_model_iter_next (priv->filter, &iter))
@@ -1124,6 +1125,19 @@ et_mb_entity_view_refresh_current_level (EtMbEntityView *entity_view)
 {
 }
 
+void
+et_mb_entity_view_clear_all (EtMbEntityView *entity_view)
+{
+    EtMbEntityViewPrivate *priv;
+
+    priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+
+    if (GTK_IS_LIST_STORE (priv->list_store))
+    {
+        gtk_list_store_clear (GTK_LIST_STORE (priv->list_store));
+    }
+}
+
 /*
  * et_mb_entity_view_destroy:
  * @object: EtMbEntityView
@@ -1131,7 +1145,7 @@ et_mb_entity_view_refresh_current_level (EtMbEntityView *entity_view)
  * Overloaded destructor for EtMbEntityView.
  */
 static void
-et_mb_entity_view_destroy (GtkWidget *object)
+et_mb_entity_view_finalize (GObject *object)
 {
     EtMbEntityView *entity_view;
     EtMbEntityViewPrivate *priv;
@@ -1141,6 +1155,7 @@ et_mb_entity_view_destroy (GtkWidget *object)
 
     entity_view = ET_MB_ENTITY_VIEW (object);
     priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+<<<<<<< HEAD
 
     if (GTK_IS_LIST_STORE (priv->list_store))
     {
@@ -1151,4 +1166,8 @@ et_mb_entity_view_destroy (GtkWidget *object)
     {
         (*GTK_WIDGET_CLASS (et_mb_entity_view_parent_class)->destroy)(object);
     }
+=======
+    g_clear_object (&priv->list_store);
+    G_OBJECT_CLASS (et_mb_entity_view_parent_class)->finalize(object);
+>>>>>>> 4b51406... Some Improvements after review
 }
diff --git a/src/mbentityview.h b/src/mbentityview.h
old mode 100644
new mode 100755
index f6abde6..8f63f3d
--- a/src/mbentityview.h
+++ b/src/mbentityview.h
@@ -122,7 +122,8 @@ void
 et_mb_entity_view_select_up (EtMbEntityView *entity_view);
 void
 et_mb_entity_view_select_down (EtMbEntityView *entity_view);
-
+void
+et_mb_entity_view_clear_all (EtMbEntityView *entity_view);
 G_END_DECLS
 
 #endif /* __MB_ENTITY_VIEW_H__ */
\ No newline at end of file
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
old mode 100644
new mode 100755
index 12cb059..5e6952c
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -42,6 +42,12 @@ static GSimpleAsyncResult *async_result;
 
 typedef struct
 {
+    GNode *mb_tree_root;
+    GSimpleAsyncResult *async_result;
+} MusicBrainzDialog;
+
+typedef struct
+{
     GHashTable *hash_table;
 } SelectedFindThreadData;
 /*
@@ -189,8 +195,7 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
     }
 
     thread_data = (ManualSearchThreadData *)g_async_result_get_user_data (G_ASYNC_RESULT (res));
-    status_msg = g_strconcat (_("Searching "), thread_data->text_to_search,
-                              NULL);
+    status_msg = g_strdup_printf (_("Searching %s"), thread_data->text_to_search);
     et_show_status_msg_in_idle (status_msg);
     g_free (status_msg);
 
@@ -244,17 +249,24 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
     int type;
     ManualSearchThreadData *thread_data;
 
+    cb_manual_search_in = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                              "cbManualSearchIn"));
+    type = gtk_combo_box_get_active (GTK_COMBO_BOX (cb_manual_search_in));
+
+    if (type == -1)
+    {
+        return;
+    }
+
     if (g_node_first_child (mb_tree_root))
     {
         free_mb_tree (mb_tree_root);
         mb_tree_root = g_node_new (NULL);
     }
  
+    et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
     cb_manual_search = GTK_WIDGET (gtk_builder_get_object (builder,
                                                            "cbManualSearch"));
-    cb_manual_search_in = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                              "cbManualSearchIn"));
-    type = gtk_combo_box_get_active (GTK_COMBO_BOX (cb_manual_search_in));
     thread_data = g_malloc (sizeof (ManualSearchThreadData));
     thread_data->type = type;
     thread_data->text_to_search = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cb_manual_search));
@@ -355,7 +367,7 @@ tool_btn_unselect_all_clicked (GtkWidget *btn, gpointer user_data)
  * Signal Handler for "clicked" signal of btnManualStop.
  */
 static void
-tool_btn_refersh_clicked (GtkWidget *btn, gpointer user_data)
+tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
 {
     /* TODO: Implement Refresh Operation */
     if (et_mb_entity_view_get_current_level (ET_MB_ENTITY_VIEW (entityView)) >
@@ -377,7 +389,10 @@ tool_btn_refersh_clicked (GtkWidget *btn, gpointer user_data)
 static void
 btn_manual_stop_clicked (GtkWidget *btn, gpointer user_data)
 {
-    g_cancellable_cancel (mb5_search_cancellable);
+    if (G_IS_CANCELLABLE (mb5_search_cancellable))
+    {
+        g_cancellable_cancel (mb5_search_cancellable);
+    }
 }
 
 /*
@@ -435,7 +450,7 @@ selected_find_thread_func (GSimpleAsyncResult *res, GObject *obj,
 
     while (iter)
     {
-        if (!et_musicbrainz_search ((gchar *)iter->data, MB_ENTITY_TYPE_ALBUM,
+        if (!et_musicbrainz_search ((gchar *)iter->data, MB_ENTITY_KIND_ALBUM,
                                     mb_tree_root, &error, cancellable))
         {
             g_simple_async_report_gerror_in_idle (NULL,
@@ -611,7 +626,7 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
         return;
     }
 
-    if (!et_musicbrainz_search (discid, MB_ENTITY_TYPE_DISCID, mb_tree_root,
+    if (!et_musicbrainz_search (discid, MB_ENTITY_KIND_DISCID, mb_tree_root,
                                 &error, cancellable))
     {
         g_simple_async_report_gerror_in_idle (NULL,
@@ -642,6 +657,12 @@ btn_discid_search (GtkWidget *button, gpointer data)
                                          mb5_search_cancellable);
 }
 
+static void
+btn_close_clicked (GtkWidget *button, gpointer data)
+{
+    gtk_dialog_response (GTK_DIALOG (mbDialog), GTK_RESPONSE_CLOSE);
+}
+
 /*
  * et_open_musicbrainz_dialog:
  *
@@ -698,6 +719,9 @@ et_open_musicbrainz_dialog ()
     g_signal_connect (gtk_builder_get_object (builder, "toolbtnToggleRedLines"),
                       "clicked", G_CALLBACK (tool_btn_toggle_red_lines_clicked),
                       NULL);
+    g_signal_connect (gtk_builder_get_object (builder, "toolbtnRefresh"),
+                      "clicked", G_CALLBACK (tool_btn_refresh_clicked),
+                      NULL);
     g_signal_connect (gtk_builder_get_object (builder, "btnSelectedFind"),
                       "clicked", G_CALLBACK (bt_selected_find_clicked),
                       NULL);
@@ -710,6 +734,9 @@ et_open_musicbrainz_dialog ()
     g_signal_connect (gtk_builder_get_object (builder, "btnDiscStop"),
                       "clicked", G_CALLBACK (btn_manual_stop_clicked),
                       NULL);
+    g_signal_connect (gtk_builder_get_object (builder, "btnClose"),
+                      "clicked", G_CALLBACK (btn_close_clicked),
+                      NULL);
     g_signal_connect_after (gtk_builder_get_object (builder, "entryTreeViewSearch"),
                             "changed",
                             G_CALLBACK (entry_tree_view_search_changed),
@@ -723,9 +750,11 @@ et_open_musicbrainz_dialog ()
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb_manual_search_in), "Album");
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb_manual_search_in), "Track");
 
+    gtk_combo_box_set_active (GTK_COMBO_BOX (cb_manual_search_in), 1);
+
     gtk_widget_show_all (mbDialog);
     gtk_dialog_run (GTK_DIALOG (mbDialog));
     gtk_widget_destroy (mbDialog);
     g_object_unref (G_OBJECT (builder));
     free_mb_tree (mb_tree_root);
-}
\ No newline at end of file
+}
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
old mode 100644
new mode 100755
diff --git a/tests/error.xml b/tests/error.xml
index c04a5cb..147cdd1 100644
--- a/tests/error.xml
+++ b/tests/error.xml
@@ -1 +1,2 @@
 <?xml version="1.0" standalone="yes"?>
+<error><text>Invalid mbid.</text><text>For usage, please see: 
http://musicbrainz.org/development/mmd</text></error>


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