[easytag/wip/musicbrainz-support-merge: 35/71] Split et_musicbrainz_search into different parts
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 35/71] Split et_musicbrainz_search into different parts
- Date: Sun, 31 Aug 2014 20:17:31 +0000 (UTC)
commit b2f607107d55051521ffd27ae2337c2623138622
Author: Abhinav <abhijangda hotmail com>
Date: Fri Jul 25 15:05:06 2014 +0530
Split et_musicbrainz_search into different parts
Implemented once function for each Mb5Entity Search
src/mb_search.c | 786 +++++++++++++++++++++++++++-------------------
src/mbentityview.c | 35 +--
src/mbentityview.h | 2 +
src/musicbrainz_dialog.c | 112 ++++---
src/musicbrainz_dialog.h | 4 +-
5 files changed, 549 insertions(+), 390 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
index f7822bf..a1f0603 100644
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -436,24 +436,62 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
return FALSE;
}
-/*
- * et_musicbrainz_search:
- * @string: String to search in MusicBrainz database.
- * @type: Type of entity to search.
- * @root: Root of the mbTree.
- * @error: GError.
- *
- * To search for an entity in MusicBrainz Database.
- *
- * Returns: TRUE if successfull, FALSE if not.
- */
-gboolean
-et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
- GError **error, GCancellable *cancellable)
+static void
+et_musicbrainz_set_error_from_query (Mb5Query query, tQueryResult result,
+ GError **error)
+{
+ char error_message[256];
+
+ g_return_if_fail (error == NULL || *error == NULL);
+ mb5_query_get_lasterrormessage (query, error_message,
+ sizeof(error_message));
+
+ switch (result)
+ {
+ case eQuery_ConnectionError:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_CONNECTION, error_message);
+ break;
+
+ case eQuery_Timeout:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_TIMEOUT, error_message);
+ break;
+
+ case eQuery_AuthenticationError:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_AUTHENTICATION, error_message);
+ break;
+
+ case eQuery_FetchError:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_FETCH, error_message);
+ break;
+
+ case eQuery_RequestError:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_REQUEST, error_message);
+ break;
+
+ case eQuery_ResourceNotFound:
+ g_set_error (error, ET_MB5_SEARCH_ERROR,
+ ET_MB5_SEARCH_ERROR_RESOURCE_NOT_FOUND,
+ error_message);
+ break;
+
+ default:
+ break;
+ }
+
+ g_assert (error == NULL || *error != NULL);
+}
+
+static gboolean
+et_musicbrainz_search_artist (gchar *string, GNode *root, GError **error,
+ GCancellable *cancellable)
{
Mb5Query query;
Mb5Metadata metadata;
- char error_message[256];
tQueryResult result;
char *param_values[2];
char *param_names[2];
@@ -463,357 +501,368 @@ et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
param_names[0] = "query";
param_names[1] = "limit";
param_values[1] = SEARCH_LIMIT_STR;
+ CHECK_CANCELLED(cancellable);
query = mb5_query_new (USER_AGENT, server, port);
+ param_values[0] = g_strconcat ("artist:", string, NULL);
+ metadata = mb5_query_query (query, "artist", "", "", 2, param_names,
+ param_values);
+ g_free (param_values[0]);
+ result = mb5_query_get_lastresult (query);
- if (g_cancellable_is_cancelled (cancellable))
- {
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_CANCELLED,
- _("Operation cancelled by user"));
- mb5_query_delete (query);
- g_assert (error == NULL || *error != NULL);
- return FALSE;
- }
-
- if (type == MB_ENTITY_KIND_ARTIST)
+ if (result == eQuery_Success)
{
- param_values[0] = g_strconcat ("artist:", string, NULL);
- metadata = mb5_query_query (query, "artist", "", "", 2, param_names,
- param_values);
- g_free (param_values[0]);
- result = mb5_query_get_lastresult (query);
-
- if (result == eQuery_Success)
+ if (metadata)
{
- if (metadata)
- {
- int i;
- Mb5ArtistList list;
- list = mb5_metadata_get_artistlist (metadata);
+ int i;
+ Mb5ArtistList list;
+ list = mb5_metadata_get_artistlist (metadata);
- for (i = 0; i < mb5_artist_list_size (list); i++)
- {
- Mb5Artist artist;
+ for (i = 0; i < mb5_artist_list_size (list); i++)
+ {
+ Mb5Artist artist;
- CHECK_CANCELLED(cancellable);
- artist = mb5_artist_list_item (list, i);
+ CHECK_CANCELLED(cancellable);
+ artist = mb5_artist_list_item (list, i);
- if (artist)
- {
- GNode *node;
- EtMbEntity *entity;
- entity = g_slice_new (EtMbEntity);
- entity->entity = mb5_artist_clone (artist);
- entity->type = MB_ENTITY_KIND_ARTIST;
- entity->is_red_line = FALSE;
- node = g_node_new (entity);
- g_node_append (root, node);
- }
+ if (artist)
+ {
+ GNode *node;
+ EtMbEntity *entity;
+ entity = g_slice_new (EtMbEntity);
+ entity->entity = mb5_artist_clone (artist);
+ entity->type = MB_ENTITY_KIND_ARTIST;
+ entity->is_red_line = FALSE;
+ node = g_node_new (entity);
+ g_node_append (root, node);
}
}
-
- mb5_metadata_delete (metadata);
- }
- else
- {
- goto err;
}
- }
- else if (type == MB_ENTITY_KIND_ALBUM)
+ mb5_metadata_delete (metadata);
+ }
+ else
{
- param_values[0] = g_strconcat ("release:", string, NULL);
- metadata = mb5_query_query (query, "release", "", "", 2, param_names,
- param_values);
- result = mb5_query_get_lastresult (query);
- g_free (param_values[0]);
-
- if (result == eQuery_Success)
- {
- if (metadata)
- {
- int i;
- Mb5ReleaseList list;
- gchar *message;
+ goto err;
+ }
- list = mb5_metadata_get_releaselist (metadata);
- param_names[0] = "inc";
- param_values[0] = "artists release-groups";
- message = g_strdup_printf (ngettext (_("Found %d Albums"),
- _("Found %d Albums"),
- mb5_release_list_size (list)),
- mb5_release_list_size (list));
-#ifndef TEST
- et_show_status_msg_in_idle (message);
-#endif
- g_free (message);
+ mb5_query_delete (query);
+ CHECK_CANCELLED(cancellable);
- for (i = 0; i < mb5_release_list_size (list); i++)
- {
- Mb5Release release;
+ return TRUE;
- CHECK_CANCELLED(cancellable);
- release = mb5_release_list_item (list, i);
+ err:
+ et_musicbrainz_set_error_from_query (query, result, error);
+ mb5_query_delete (query);
+ g_assert (error == NULL || *error != NULL);
- if (release)
- {
- Mb5Metadata metadata_release;
- gchar buf[NAME_MAX_SIZE];
- GNode *node;
- EtMbEntity *entity;
- int size;
+ return FALSE;
+}
- size = mb5_release_get_title ((Mb5Release)release,
- buf, sizeof (buf));
- buf[size] = '\0';
- message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
- buf, i,
- mb5_release_list_size (list));
-#ifndef TEST
- et_show_status_msg_in_idle (message);
-#endif
- g_free (message);
+static gboolean
+et_musicbrainz_search_album (gchar *string, GNode *root, GError **error,
+ GCancellable *cancellable)
+{
+ Mb5Query query;
+ Mb5Metadata metadata;
+ tQueryResult result;
+ char *param_values[2];
+ char *param_names[2];
- mb5_release_get_id ((Mb5Release)release,
- buf,
- sizeof (buf));
- CHECK_CANCELLED(cancellable);
- metadata_release = mb5_query_query (query, "release",
- buf, "",
- 1, param_names,
- param_values);
- CHECK_CANCELLED(cancellable);
- entity = g_slice_new (EtMbEntity);
- entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
- entity->type = MB_ENTITY_KIND_ALBUM;
- entity->is_red_line = FALSE;
- node = g_node_new (entity);
- g_node_append (root, node);
- mb5_metadata_delete (metadata_release);
- }
- }
- }
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- mb5_metadata_delete (metadata);
- }
- else
- {
- goto err;
- }
- }
+ param_names[0] = "query";
+ param_names[1] = "limit";
+ param_values[1] = SEARCH_LIMIT_STR;
+ CHECK_CANCELLED(cancellable);
+ query = mb5_query_new (USER_AGENT, server, port);
+ param_values[0] = g_strconcat ("release:", string, NULL);
+ metadata = mb5_query_query (query, "release", "", "", 2, param_names,
+ param_values);
+ result = mb5_query_get_lastresult (query);
+ g_free (param_values[0]);
- else if (type == MB_ENTITY_KIND_TRACK)
+ if (result == eQuery_Success)
{
- param_values[0] = g_strconcat ("recordings:", string, NULL);
- metadata = mb5_query_query (query, "recording", "", "", 2,
- param_names, param_values);
- result = mb5_query_get_lastresult (query);
- g_free (param_values[0]);
-
- if (result == eQuery_Success)
+ if (metadata)
{
- if (metadata)
- {
- int i;
- Mb5RecordingList list;
- gchar *message;
-
- list = mb5_metadata_get_recordinglist (metadata);
- param_names[0] = "inc";
- param_values[0] = "releases artists artist-credits release-groups";
- message = g_strdup_printf (ngettext (_("Found %d Track"),
- _("Found %d Tracks"),
- mb5_recording_list_size (list)),
- mb5_recording_list_size (list));
+ int i;
+ Mb5ReleaseList list;
+ gchar *message;
+
+ list = mb5_metadata_get_releaselist (metadata);
+ param_names[0] = "inc";
+ param_values[0] = "artists release-groups";
+ message = g_strdup_printf (ngettext (_("Found %d Albums"),
+ _("Found %d Albums"),
+ mb5_release_list_size (list)),
+ mb5_release_list_size (list));
#ifndef TEST
- et_show_status_msg_in_idle (message);
+ et_show_status_msg_in_idle (message);
#endif
- g_free (message);
+ g_free (message);
- for (i = 0; i < mb5_recording_list_size (list); i++)
+ for (i = 0; i < mb5_release_list_size (list); i++)
+ {
+ Mb5Release release;
+
+ CHECK_CANCELLED(cancellable);
+ release = mb5_release_list_item (list, i);
+
+ if (release)
{
- Mb5Recording recording;
- Mb5Metadata metadata_recording;
+ Mb5Metadata metadata_release;
gchar buf[NAME_MAX_SIZE];
GNode *node;
EtMbEntity *entity;
int size;
- CHECK_CANCELLED(cancellable);
- recording = mb5_recording_list_item (list, i);
- size = mb5_recording_get_title (recording, buf, sizeof (buf));
+ size = mb5_release_get_title ((Mb5Release)release,
+ buf, sizeof (buf));
buf[size] = '\0';
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, i,
- mb5_track_list_size (list));
+ mb5_release_list_size (list));
#ifndef TEST
et_show_status_msg_in_idle (message);
#endif
g_free (message);
- mb5_recording_get_id (recording,
- buf,
- sizeof (buf));
- metadata_recording = mb5_query_query (query, "recording",
- buf, "",
- 1, param_names,
- param_values);
+ mb5_release_get_id ((Mb5Release)release,
+ buf,
+ sizeof (buf));
+ CHECK_CANCELLED(cancellable);
+ metadata_release = mb5_query_query (query, "release",
+ buf, "",
+ 1, param_names,
+ param_values);
CHECK_CANCELLED(cancellable);
entity = g_slice_new (EtMbEntity);
- entity->entity = mb5_recording_clone (mb5_metadata_get_recording (metadata_recording));
- entity->type = MB_ENTITY_KIND_TRACK;
+ entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
+ entity->type = MB_ENTITY_KIND_ALBUM;
entity->is_red_line = FALSE;
node = g_node_new (entity);
g_node_append (root, node);
- mb5_metadata_delete (metadata_recording);
+ mb5_metadata_delete (metadata_release);
}
}
-
- mb5_metadata_delete (metadata);
}
- else
- {
- goto err;
- }
- }
- else if (type == MB_ENTITY_KIND_DISCID)
+ mb5_metadata_delete (metadata);
+ }
+ else
{
- param_names[0] = "toc";
- param_values[0] = "";
- metadata = mb5_query_query (query, "discid", string, "", 1, param_names,
- param_values);
- result = mb5_query_get_lastresult (query);
+ goto err;
+ }
- if (result == eQuery_Success)
+ mb5_query_delete (query);
+ CHECK_CANCELLED(cancellable);
+
+ return TRUE;
+
+ err:
+ et_musicbrainz_set_error_from_query (query, result, error);
+ mb5_query_delete (query);
+ g_assert (error == NULL || *error != NULL);
+
+ return FALSE;
+}
+
+static gboolean
+et_musicbrainz_search_track (gchar *string, GNode *root, GError **error,
+ GCancellable *cancellable)
+{
+ Mb5Query query;
+ Mb5Metadata metadata;
+ tQueryResult result;
+ char *param_values[2];
+ char *param_names[2];
+
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ param_names[0] = "query";
+ param_names[1] = "limit";
+ param_values[1] = SEARCH_LIMIT_STR;
+ CHECK_CANCELLED(cancellable);
+ query = mb5_query_new (USER_AGENT, server, port);
+ param_values[0] = g_strconcat ("recordings:", string, NULL);
+ metadata = mb5_query_query (query, "recording", "", "", 2,
+ param_names, param_values);
+ result = mb5_query_get_lastresult (query);
+ g_free (param_values[0]);
+
+ if (result == eQuery_Success)
+ {
+ if (metadata)
{
- if (metadata)
+ int i;
+ Mb5RecordingList list;
+ gchar *message;
+
+ list = mb5_metadata_get_recordinglist (metadata);
+ param_names[0] = "inc";
+ param_values[0] = "releases artists artist-credits release-groups";
+ message = g_strdup_printf (ngettext (_("Found %d Track"),
+ _("Found %d Tracks"),
+ mb5_recording_list_size (list)),
+ mb5_recording_list_size (list));
+#ifndef TEST
+ et_show_status_msg_in_idle (message);
+#endif
+ g_free (message);
+
+ for (i = 0; i < mb5_recording_list_size (list); i++)
{
- int i;
- Mb5ReleaseList list;
- gchar *message;
- Mb5Disc disc;
+ Mb5Recording recording;
+ Mb5Metadata metadata_recording;
+ gchar buf[NAME_MAX_SIZE];
+ GNode *node;
+ EtMbEntity *entity;
+ int size;
- disc = mb5_metadata_get_disc (metadata);
- list = mb5_disc_get_releaselist (disc);
- param_names[0] = "inc";
- param_values[0] = "artists release-groups";
- message = g_strdup_printf (ngettext (_("Found %d Album"),
- _("Found %d Albums"),
- mb5_release_list_size (list)),
- mb5_release_list_size (list));
+ CHECK_CANCELLED(cancellable);
+ recording = mb5_recording_list_item (list, i);
+ size = mb5_recording_get_title (recording, buf, sizeof (buf));
+ buf[size] = '\0';
+ message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
+ buf, i,
+ mb5_track_list_size (list));
#ifndef TEST
et_show_status_msg_in_idle (message);
#endif
g_free (message);
- for (i = 0; i < mb5_release_list_size (list); i++)
- {
- Mb5Release release;
+ mb5_recording_get_id (recording,
+ buf,
+ sizeof (buf));
+ metadata_recording = mb5_query_query (query, "recording",
+ buf, "",
+ 1, param_names,
+ param_values);
+ CHECK_CANCELLED(cancellable);
+ entity = g_slice_new (EtMbEntity);
+ entity->entity = mb5_recording_clone (mb5_metadata_get_recording (metadata_recording));
+ entity->type = MB_ENTITY_KIND_TRACK;
+ entity->is_red_line = FALSE;
+ node = g_node_new (entity);
+ g_node_append (root, node);
+ mb5_metadata_delete (metadata_recording);
+ }
+ }
- CHECK_CANCELLED(cancellable);
- release = mb5_release_list_item (list, i);
+ mb5_metadata_delete (metadata);
+ }
+ else
+ {
+ goto err;
+ }
- if (release)
- {
- Mb5Metadata metadata_release;
- gchar buf[NAME_MAX_SIZE];
- GNode *node;
- EtMbEntity *entity;
- int size;
+ mb5_query_delete (query);
+ CHECK_CANCELLED(cancellable);
- size = mb5_release_get_title ((Mb5Release)release, buf,
- sizeof (buf));
- buf[size] = '\0';
- message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
- buf, i,
- mb5_release_list_size (list));
-#ifndef TEST
- et_show_status_msg_in_idle (message);
-#endif
- g_free (message);
+ return TRUE;
- mb5_release_get_id ((Mb5Release)release,
- buf,
- sizeof (buf));
- metadata_release = mb5_query_query (query, "release",
- buf, "",
- 1, param_names,
- param_values);
- CHECK_CANCELLED(cancellable);
- entity = g_slice_new (EtMbEntity);
- entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
- entity->type = MB_ENTITY_KIND_ALBUM;
- entity->is_red_line = FALSE;
- node = g_node_new (entity);
- g_node_append (root, node);
- mb5_metadata_delete (metadata_release);
- }
- }
- }
+ err:
+ et_musicbrainz_set_error_from_query (query, result, error);
+ mb5_query_delete (query);
+ g_assert (error == NULL || *error != NULL);
- mb5_metadata_delete (metadata);
- }
- else
- {
- goto err;
- }
- }
- else if (type == MB_ENTITY_KIND_FREEDBID)
- {
- param_values[0] = g_strconcat ("discid:", string, NULL);
- metadata = mb5_query_query (query, "freedb", "", "", 2, param_names,
- param_values);
- result = mb5_query_get_lastresult (query);
- g_free (param_values[0]);
+ return FALSE;
+}
- if (result == eQuery_Success)
- {
- if (metadata)
- {
- int i;
- Mb5FreeDBDiscList list;
- gchar *message;
+static gboolean
+et_musicbrainz_search_discid (gchar *string, GNode *root, GError **error,
+ GCancellable *cancellable)
+{
+ Mb5Query query;
+ Mb5Metadata metadata;
+ tQueryResult result;
+ char *param_values[2];
+ char *param_names[2];
+
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ param_names[0] = "query";
+ param_names[1] = "limit";
+ param_values[1] = SEARCH_LIMIT_STR;
+ CHECK_CANCELLED(cancellable);
+ query = mb5_query_new (USER_AGENT, server, port);
+ param_names[0] = "toc";
+ param_values[0] = "";
+ metadata = mb5_query_query (query, "discid", string, "", 1, param_names,
+ param_values);
+ result = mb5_query_get_lastresult (query);
- list = mb5_metadata_get_freedbdisclist (metadata);
- message = g_strdup_printf (ngettext (_("Found %d Result"),
- _("Found %d Results"),
- mb5_freedbdisc_list_size (list)),
- mb5_freedbdisc_list_size (list));
+ if (result == eQuery_Success)
+ {
+ if (metadata)
+ {
+ int i;
+ Mb5ReleaseList list;
+ gchar *message;
+ Mb5Disc disc;
+
+ disc = mb5_metadata_get_disc (metadata);
+ list = mb5_disc_get_releaselist (disc);
+ param_names[0] = "inc";
+ param_values[0] = "artists release-groups";
+ message = g_strdup_printf (ngettext (_("Found %d Album"),
+ _("Found %d Albums"),
+ mb5_release_list_size (list)),
+ mb5_release_list_size (list));
#ifndef TEST
- et_show_status_msg_in_idle (message);
+ et_show_status_msg_in_idle (message);
#endif
- g_free (message);
+ g_free (message);
- for (i = 0; i < mb5_freedbdisc_list_size (list); i++)
- {
- Mb5FreeDBDisc freedbdisc;
+ for (i = 0; i < mb5_release_list_size (list); i++)
+ {
+ Mb5Release release;
- CHECK_CANCELLED(cancellable);
- freedbdisc = mb5_freedbdisc_list_item (list, i);
+ CHECK_CANCELLED(cancellable);
+ release = mb5_release_list_item (list, i);
- if (freedbdisc)
- {
- gchar buf[NAME_MAX_SIZE];
- GNode *node;
- EtMbEntity *entity;
- int size;
+ if (release)
+ {
+ Mb5Metadata metadata_release;
+ gchar buf[NAME_MAX_SIZE];
+ GNode *node;
+ EtMbEntity *entity;
+ int size;
- size = mb5_freedbdisc_get_title (freedbdisc,
- buf, sizeof (buf));
- buf[size] = '\0';
- entity = g_slice_new (EtMbEntity);
- entity->entity = mb5_freedbdisc_clone (freedbdisc);
- entity->type = MB_ENTITY_KIND_FREEDBID;
- entity->is_red_line = FALSE;
- node = g_node_new (entity);
- g_node_append (root, node);
- }
+ size = mb5_release_get_title ((Mb5Release)release, buf,
+ sizeof (buf));
+ buf[size] = '\0';
+ message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
+ buf, i,
+ mb5_release_list_size (list));
+#ifndef TEST
+ et_show_status_msg_in_idle (message);
+#endif
+ g_free (message);
+ mb5_release_get_id ((Mb5Release)release,
+ buf,
+ sizeof (buf));
+ metadata_release = mb5_query_query (query, "release",
+ buf, "",
+ 1, param_names,
+ param_values);
+ CHECK_CANCELLED(cancellable);
+ entity = g_slice_new (EtMbEntity);
+ entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
+ entity->type = MB_ENTITY_KIND_ALBUM;
+ entity->is_red_line = FALSE;
+ node = g_node_new (entity);
+ g_node_append (root, node);
+ mb5_metadata_delete (metadata_release);
}
}
-
- mb5_metadata_delete (metadata);
}
+
+ mb5_metadata_delete (metadata);
+ }
+ else
+ {
+ goto err;
}
mb5_query_delete (query);
@@ -822,51 +871,142 @@ et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
return TRUE;
err:
- mb5_query_get_lasterrormessage (query, error_message,
- sizeof(error_message));
+ et_musicbrainz_set_error_from_query (query, result, error);
+ mb5_query_delete (query);
+ g_assert (error == NULL || *error != NULL);
- switch (result)
- {
- case eQuery_ConnectionError:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_CONNECTION, error_message);
- break;
+ return FALSE;
+}
- case eQuery_Timeout:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_TIMEOUT, error_message);
- break;
+static gboolean
+et_musicbrainz_search_freedbid (gchar *string, GNode *root, GError **error,
+ GCancellable *cancellable)
+{
+ Mb5Query query;
+ Mb5Metadata metadata;
+ tQueryResult result;
+ char *param_values[2];
+ char *param_names[2];
- case eQuery_AuthenticationError:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_AUTHENTICATION, error_message);
- break;
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ param_names[0] = "query";
+ param_names[1] = "limit";
+ param_values[1] = SEARCH_LIMIT_STR;
+ CHECK_CANCELLED(cancellable);
+ query = mb5_query_new (USER_AGENT, server, port);
+ param_values[0] = g_strconcat ("discid:", string, NULL);
+ metadata = mb5_query_query (query, "freedb", "", "", 2, param_names,
+ param_values);
+ result = mb5_query_get_lastresult (query);
+ g_free (param_values[0]);
- case eQuery_FetchError:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_FETCH, error_message);
- break;
+ if (result == eQuery_Success)
+ {
+ if (metadata)
+ {
+ int i;
+ Mb5FreeDBDiscList list;
+ gchar *message;
+
+ list = mb5_metadata_get_freedbdisclist (metadata);
+ message = g_strdup_printf (ngettext (_("Found %d Result"),
+ _("Found %d Results"),
+ mb5_freedbdisc_list_size (list)),
+ mb5_freedbdisc_list_size (list));
+#ifndef TEST
+ et_show_status_msg_in_idle (message);
+#endif
+ g_free (message);
- case eQuery_RequestError:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_REQUEST, error_message);
- break;
+ for (i = 0; i < mb5_freedbdisc_list_size (list); i++)
+ {
+ Mb5FreeDBDisc freedbdisc;
- case eQuery_ResourceNotFound:
- g_set_error (error, ET_MB5_SEARCH_ERROR,
- ET_MB5_SEARCH_ERROR_RESOURCE_NOT_FOUND,
- error_message);
- break;
+ CHECK_CANCELLED(cancellable);
+ freedbdisc = mb5_freedbdisc_list_item (list, i);
- default:
- break;
+ if (freedbdisc)
+ {
+ gchar buf[NAME_MAX_SIZE];
+ GNode *node;
+ EtMbEntity *entity;
+ int size;
+
+ size = mb5_freedbdisc_get_title (freedbdisc,
+ buf, sizeof (buf));
+ buf[size] = '\0';
+ entity = g_slice_new (EtMbEntity);
+ entity->entity = mb5_freedbdisc_clone (freedbdisc);
+ entity->type = MB_ENTITY_KIND_FREEDBID;
+ entity->is_red_line = FALSE;
+ node = g_node_new (entity);
+ g_node_append (root, node);
+ }
+ }
+ }
+
+ mb5_metadata_delete (metadata);
+ }
+ else
+ {
+ goto err;
}
+ mb5_query_delete (query);
+ CHECK_CANCELLED(cancellable);
+
+ return TRUE;
+
+ err:
+ et_musicbrainz_set_error_from_query (query, result, error);
+ mb5_query_delete (query);
g_assert (error == NULL || *error != NULL);
+
return FALSE;
}
/*
+ * et_musicbrainz_search:
+ * @string: String to search in MusicBrainz database.
+ * @type: Type of entity to search.
+ * @root: Root of the mbTree.
+ * @error: GError.
+ *
+ * To search for an entity in MusicBrainz Database.
+ *
+ * Returns: TRUE if successfull, FALSE if not.
+ */
+gboolean
+et_musicbrainz_search (gchar *string, MbEntityKind type, GNode *root,
+ GError **error, GCancellable *cancellable)
+{
+ switch (type)
+ {
+ case MB_ENTITY_KIND_ARTIST:
+ return et_musicbrainz_search_artist (string, root, error,
+ cancellable);
+
+
+ case MB_ENTITY_KIND_ALBUM:
+ return et_musicbrainz_search_album (string, root, error,
+ cancellable);
+
+ case MB_ENTITY_KIND_TRACK:
+ return et_musicbrainz_search_track (string, root, error,
+ cancellable);
+
+ case MB_ENTITY_KIND_DISCID:
+ return et_musicbrainz_search_discid (string, root, error,
+ cancellable);
+ case MB_ENTITY_KIND_FREEDBID:
+ return et_musicbrainz_search_freedbid (string, root, error,
+ cancellable);
+ default:
+ return FALSE;
+ }
+}
+
+/*
* free_mb_tree:
* @node: Root of the tree to start freeing with.
*
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 8ad2b0c..6e33db4 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -30,9 +30,7 @@
#include "log.h"
#include "musicbrainz_dialog.h"
-#define ET_MB_ENTITY_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- ET_MB_ENTITY_VIEW_TYPE, \
- EtMbEntityViewPrivate))
+#define ET_MB_ENTITY_VIEW_GET_PRIVATE(obj) (obj->priv)
G_DEFINE_TYPE (EtMbEntityView, et_mb_entity_view, GTK_TYPE_BOX)
@@ -69,7 +67,7 @@ enum ET_MB_DISPLAY_RESULTS
*
* Private data for EtMbEntityView.
*/
-typedef struct
+struct _EtMbEntityViewPrivate
{
GtkWidget *bread_crumb_box;
GNode *bread_crumb_nodes[MB_ENTITY_KIND_COUNT];
@@ -84,7 +82,7 @@ typedef struct
gboolean toggle_red_lines;
const gchar *text_to_search_in_results;
GtkTreeViewColumn *color_column;
-} EtMbEntityViewPrivate;
+};
/*
* SearchInLevelThreadData:
@@ -509,11 +507,11 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
int i, total_cols, type;
GList *list_cols, *list;
GType *types;
- static const gchar *columns[MB_ENTITY_KIND_COUNT][10] = {
+ static const gchar *column_names[MB_ENTITY_KIND_COUNT][4] = {
{N_("Name"), N_("Gender"), N_("Type")},
{N_("Name"), N_("Artist"), N_("Type")},
- {"Name", "Album", "Artist", "Time"},
- {"FreeDB ID", "Title", "Artist"}
+ {N_("Name"), N_("Album"), N_("Artist"), N_("Time")},
+ {N_("FreeDB ID"), N_("Title"), N_("Artist")}
};
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
@@ -573,7 +571,7 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
{
types[i] = G_TYPE_STRING;
renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (columns[type][i],
+ column = gtk_tree_view_column_new_with_attributes (column_names[type][i],
renderer, "text",
i, "foreground-rgba",
total_cols, NULL);
@@ -723,7 +721,7 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
g_slice_free (SearchInLevelThreadData, thread_data);
et_music_brainz_dialog_stop_set_sensitive (FALSE);
- if (exit_on_complete)
+ if (et_music_brainz_get_exit_on_complete ())
{
gtk_dialog_response (GTK_DIALOG (mbDialog),
GTK_RESPONSE_DELETE_EVENT);
@@ -933,7 +931,12 @@ search_in_levels (EtMbEntityView *entity_view, GNode *child,
static void
et_mb_entity_view_init (EtMbEntityView *entity_view)
{
- EtMbEntityViewPrivate *priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+ EtMbEntityViewPrivate *priv;
+
+ priv = entity_view->priv = G_TYPE_INSTANCE_GET_PRIVATE (entity_view,
+ et_mb_entity_view_get_type (),
+ EtMbEntityViewPrivate);
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (entity_view),
GTK_ORIENTATION_VERTICAL);
@@ -951,12 +954,8 @@ et_mb_entity_view_init (EtMbEntityView *entity_view)
FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (entity_view), priv->scrolled_window,
TRUE, TRUE, 2);
- priv->mb_tree_root = NULL;
- priv->mb_tree_current_node = NULL;
- 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);
}
@@ -1296,15 +1295,9 @@ et_mb_entity_view_clear_all (EtMbEntityView *entity_view)
static void
et_mb_entity_view_finalize (GObject *object)
{
- EtMbEntityView *entity_view;
- EtMbEntityViewPrivate *priv;
-
g_return_if_fail (object != NULL);
g_return_if_fail (IS_ET_MB_ENTITY_VIEW(object));
- entity_view = ET_MB_ENTITY_VIEW (object);
- priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
- g_clear_object (&priv->list_store);
G_OBJECT_CLASS (et_mb_entity_view_parent_class)->finalize(object);
}
diff --git a/src/mbentityview.h b/src/mbentityview.h
index a19c798..c756542 100644
--- a/src/mbentityview.h
+++ b/src/mbentityview.h
@@ -50,6 +50,7 @@ G_BEGIN_DECLS
* Declaration *
***************/
+typedef struct _EtMbEntityViewPrivate EtMbEntityViewPrivate;
/*
* EtMbEntityView:
* @vbox: GtkBox, parent class of EtMbEntityView
@@ -60,6 +61,7 @@ G_BEGIN_DECLS
typedef struct
{
GtkBox vbox;
+ EtMbEntityViewPrivate *priv;
} EtMbEntityView;
/*
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 282688e..cadce3e 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -161,9 +161,11 @@ typedef struct
EtMbSearch *search;
GtkTreeModel *tag_choice_store;
GtkWidget *tag_choice_dialog;
+ GtkWidget *entityView;
} MusicBrainzDialogPrivate;
static MusicBrainzDialogPrivate *mb_dialog_priv;
+static gboolean exit_on_complete;
/*
* ManualSearchThreadData:
@@ -274,6 +276,12 @@ et_initialize_tag_choice_dialog (void);
* Functions *
*************/
+gboolean
+et_music_brainz_get_exit_on_complete (void)
+{
+ return exit_on_complete;
+}
+
/*
* et_mb_destroy_search:
* @search: EtMbSearch
@@ -283,22 +291,32 @@ et_initialize_tag_choice_dialog (void);
static void
et_mb_destroy_search (EtMbSearch **search)
{
- if (*search)
+ g_return_if_fail (search);
+
+ if (!*search)
+ {
+ return;
+ }
+
+ switch ((*search)->type)
{
- if ((*search)->type == ET_MB_SEARCH_TYPE_MANUAL)
+ case ET_MB_SEARCH_TYPE_MANUAL:
{
g_free (((EtMbManualSearch *)(*search))->to_search);
- g_slice_free (EtMbManualSearch, (EtMbManualSearch *)*search);
+ g_slice_free (EtMbManualSearch, (EtMbManualSearch *)(*search));
+ break;
}
- else if ((*search)->type == ET_MB_SEARCH_TYPE_SELECTED)
+ case ET_MB_SEARCH_TYPE_SELECTED:
{
g_list_free_full (((EtMbSelectedSearch *)(*search))->list_iter,
(GDestroyNotify)gtk_tree_iter_free);
- g_slice_free (EtMbSelectedSearch, (EtMbSelectedSearch *)*search);
+ g_slice_free (EtMbSelectedSearch, (EtMbSelectedSearch *)(*search));
+ break;
}
- else if ((*search)->type == ET_MB_SEARCH_TYPE_AUTOMATIC)
+ case ET_MB_SEARCH_TYPE_AUTOMATIC:
{
- g_slice_free (EtMbAutomaticSearch, (EtMbAutomaticSearch *)*search);
+ g_slice_free (EtMbAutomaticSearch, (EtMbAutomaticSearch *)(*search));
+ break;
}
}
}
@@ -316,12 +334,15 @@ static void
et_mb_set_search_manual (EtMbSearch **search, gchar *to_search,
GNode *node, MbEntityKind type)
{
+ EtMbManualSearch *manual_search;
+
et_mb_destroy_search (search);
- *search = (EtMbSearch *)g_slice_new (EtMbManualSearch);
- ((EtMbManualSearch *)(*search))->to_search = g_strdup (to_search);
+ manual_search = g_slice_new (EtMbManualSearch);
+ manual_search->to_search = g_strdup (to_search);
+ manual_search->parent_node = node;
+ manual_search->to_search_type = type;
+ *search = (EtMbSearch *)manual_search;
(*search)->type = ET_MB_SEARCH_TYPE_MANUAL;
- ((EtMbManualSearch *)(*search))->parent_node = node;
- ((EtMbManualSearch *)(*search))->to_search_type = type;
}
/*
@@ -382,7 +403,7 @@ manual_search_callback (GObject *source, GAsyncResult *res,
return;
}
- et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
+ et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
"statusbar")), 0, _("Searching Completed"));
@@ -397,7 +418,7 @@ manual_search_callback (GObject *source, GAsyncResult *res,
((ManualSearchThreadData *)user_data)->text_to_search,
mb_dialog_priv->mb_tree_root,
((ManualSearchThreadData *)user_data)->type);
- g_slice_free (ManualSearchThreadData, user_data);
+ g_slice_free (ManualSearchThreadData, (ManualSearchThreadData *)user_data);
}
/*
@@ -568,7 +589,7 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
mb_dialog_priv->mb_tree_root = g_node_new (NULL);
}
- et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
cb_manual_search = GTK_WIDGET (gtk_builder_get_object (builder,
"cbManualSearch"));
thread_data = g_slice_new (ManualSearchThreadData);
@@ -577,9 +598,10 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
mb5_search_cancellable = g_cancellable_new ();
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
"statusbar")), 0, _("Starting MusicBrainz Search"));
- mb_dialog_priv->async_result = g_simple_async_result_new (NULL, manual_search_callback,
- thread_data,
- btn_manual_find_clicked);
+ mb_dialog_priv->async_result = g_simple_async_result_new (NULL,
+ manual_search_callback,
+ thread_data,
+ btn_manual_find_clicked);
g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
manual_search_thread_func, 0,
mb5_search_cancellable);
@@ -596,7 +618,7 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_toggle_red_lines_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_toggle_red_lines (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_toggle_red_lines (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -609,7 +631,7 @@ tool_btn_toggle_red_lines_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_up_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_select_up (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_select_up (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -622,7 +644,7 @@ tool_btn_up_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_down_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_select_down (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_select_down (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -635,7 +657,7 @@ tool_btn_down_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_invert_selection_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_invert_selection (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_invert_selection (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -648,7 +670,7 @@ tool_btn_invert_selection_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_select_all_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_select_all (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_select_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -661,7 +683,7 @@ tool_btn_select_all_clicked (GtkWidget *btn, gpointer user_data)
static void
tool_btn_unselect_all_clicked (GtkWidget *btn, gpointer user_data)
{
- et_mb_entity_view_unselect_all (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_unselect_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
}
/*
@@ -679,12 +701,12 @@ tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
return;
}
- if (et_mb_entity_view_get_current_level (ET_MB_ENTITY_VIEW (entityView)) >
+ if (et_mb_entity_view_get_current_level (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView)) >
1)
{
/* Current level is more than 1, refereshing means downloading an */
/* entity's children */
- et_mb_entity_view_refresh_current_level (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_refresh_current_level (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
return;
}
@@ -694,7 +716,7 @@ tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
GtkWidget *entry;
manual_search = (EtMbManualSearch *)mb_dialog_priv->search;
- et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
+ et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
free_mb_tree (&mb_dialog_priv->mb_tree_root);
mb_dialog_priv->mb_tree_root = g_node_new (NULL);
entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (builder, "cbManualSearch")));
@@ -707,14 +729,14 @@ tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
{
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));
+ et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
btn_selected_find_clicked (NULL, NULL);
}
else if (mb_dialog_priv->search->type == ET_MB_SEARCH_TYPE_AUTOMATIC)
{
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));
+ et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
btn_automatic_search_clicked (NULL, NULL);
}
}
@@ -745,7 +767,7 @@ btn_manual_stop_clicked (GtkWidget *btn, gpointer user_data)
static void
entry_tree_view_search_changed (GtkEditable *editable, gpointer user_data)
{
- et_mb_entity_view_search_in_results (ET_MB_ENTITY_VIEW (entityView),
+ et_mb_entity_view_search_in_results (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
"entryTreeViewSearch"))));
}
@@ -772,7 +794,7 @@ selected_find_callback (GObject *source, GAsyncResult *res,
return;
}
- et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
+ et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Searching Completed"));
@@ -1039,7 +1061,7 @@ discid_search_callback (GObject *source, GAsyncResult *res,
return;
}
- et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
+ et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Searching Completed"));
@@ -1173,7 +1195,7 @@ freedbid_search_callback (GObject *source, GAsyncResult *res,
return;
}
- et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
+ et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Searching Completed"));
@@ -1377,14 +1399,14 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
* et_music_brainz_dialog_stop_set_sensitive:
* @sensitive: gboolean
*
- * Set btnStop and entityView as sensitive according to @sensitive.
+ * Set btnStop and mb_dialog_priv->entityView as sensitive according to @sensitive.
*/
void
et_music_brainz_dialog_stop_set_sensitive (gboolean sensitive)
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "btnStop")),
sensitive);
- gtk_widget_set_sensitive (entityView, !sensitive);
+ gtk_widget_set_sensitive (mb_dialog_priv->entityView, !sensitive);
}
/*
@@ -1447,7 +1469,7 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
return;
}
- if (!et_mb_entity_view_get_selected_entity_list (ET_MB_ENTITY_VIEW (entityView),
+ if (!et_mb_entity_view_get_selected_entity_list (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
&track_iter_list))
{
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
@@ -1474,7 +1496,7 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
EtMbEntity *album_entity;
gchar album[NAME_MAX_SIZE];
- album_entity = et_mb_entity_view_get_current_entity (ET_MB_ENTITY_VIEW (entityView));
+ album_entity = et_mb_entity_view_get_current_entity (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
mb5_release_get_title (album_entity->entity, album, sizeof (album));
for (list_iter1 = track_iter_list; list_iter1;
@@ -1524,10 +1546,6 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
{
et_apply_track_tag_to_et_file (et_entity->entity,
best_et_file);
- while (gtk_events_pending ())
- {
- gtk_main_iteration ();
- }
}
}
}
@@ -1537,7 +1555,7 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
EtMbEntity *album_entity;
gchar album[NAME_MAX_SIZE];
- album_entity = et_mb_entity_view_get_current_entity (ET_MB_ENTITY_VIEW (entityView));
+ album_entity = et_mb_entity_view_get_current_entity (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
mb5_release_get_title (album_entity->entity, album, sizeof (album));
list_iter2 = file_iter_list;
@@ -1703,7 +1721,12 @@ void
et_music_brainz_dialog_destroy (GtkWidget *widget)
{
et_mb_destroy_search (&mb_dialog_priv->search);
- gtk_widget_destroy (mb_dialog_priv->tag_choice_dialog);
+
+ if (GTK_IS_WIDGET (mb_dialog_priv->tag_choice_dialog))
+ {
+ gtk_widget_destroy (mb_dialog_priv->tag_choice_dialog);
+ }
+
gtk_widget_destroy (widget);
g_object_unref (G_OBJECT (builder));
free_mb_tree (&mb_dialog_priv->mb_tree_root);
@@ -1735,6 +1758,7 @@ et_initialize_tag_choice_dialog (void)
mb_dialog_priv->tag_choice_store = GTK_TREE_MODEL (list_store);
gtk_tree_view_set_model (GTK_TREE_VIEW (tag_choice_list),
mb_dialog_priv->tag_choice_store);
+ g_object_unref (list_store);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Title",
@@ -1817,11 +1841,11 @@ et_open_musicbrainz_dialog ()
mb_dialog_priv->mb_tree_root = g_node_new (NULL);
mb_dialog_priv->search = NULL;
exit_on_complete = FALSE;
- entityView = et_mb_entity_view_new ();
+ mb_dialog_priv->entityView = et_mb_entity_view_new ();
mbDialog = GTK_WIDGET (gtk_builder_get_object (builder, "mbDialog"));
gtk_widget_set_size_request (mbDialog, 660, 500);
gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "centralBox")),
- entityView, TRUE, TRUE, 2);
+ mb_dialog_priv->entityView, TRUE, TRUE, 2);
et_initialize_tag_choice_dialog ();
cb_search = GTK_WIDGET (gtk_builder_get_object (builder, "cbManualSearch"));
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
index 1b2503c..7bcf4c3 100644
--- a/src/musicbrainz_dialog.h
+++ b/src/musicbrainz_dialog.h
@@ -31,8 +31,6 @@
GtkBuilder *builder;
GtkWidget *mbDialog;
-GtkWidget *entityView;
-gboolean exit_on_complete;
/**************
* Prototypes *
@@ -49,5 +47,7 @@ void
et_music_brainz_dialog_stop_set_sensitive (gboolean sensitive);
void
et_music_brainz_dialog_destroy (GtkWidget *widget);
+gboolean
+et_music_brainz_get_exit_on_complete (void);
#endif /* __MUSICBRAINZ_DIALOG_H__ */
#endif /* ENABLE_MUSICBRAINZ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]