[easytag/wip/musicbrainz-support-merge: 7/75] FIXME (split) Added more verbose Status Bar Messages and comments
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 7/75] FIXME (split) Added more verbose Status Bar Messages and comments
- Date: Sat, 30 Aug 2014 07:46:35 +0000 (UTC)
commit 28226221d4c3153aa042c11392461e622ab8e282
Author: Abhinav <abhijangda hotmail com>
Date: Sun May 25 12:11:33 2014 +0530
FIXME (split) Added more verbose Status Bar Messages and comments
Added function et_show_status_msg_in_idle to show messages in Status Bar
in a thread safe manner. Added more messages depicting more information.
src/mb_search.c | 99 +++++++++++++++++++++++++++++++++++++--------
src/mbentityview.c | 86 ++++++++++++++++++++++++++++++++-------
src/musicbrainz_dialog.c | 100 +++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 247 insertions(+), 38 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
index f64865d..ad6f8c7 100644
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -19,6 +19,7 @@
*/
#include "mb_search.h"
+#include "musicbrainz_dialog.h"
/*
* et_mb5_search_error_quark:
@@ -74,9 +75,14 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
int i;
Mb5ReleaseList list;
Mb5Artist artist;
+ gchar *message;
+
artist = mb5_metadata_get_artist (metadata);
list = mb5_artist_get_releaselist (artist);
param_values[0] = "artists release-groups";
+ message = g_strdup_printf ("Found %d Album(s)", mb5_release_list_size (list));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
for (i = 0; i < mb5_release_list_size (list); i++)
{
@@ -85,14 +91,26 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
if (release)
{
Mb5Metadata metadata_release;
- gchar release_mbid [NAME_MAX_SIZE];
+ gchar buf [NAME_MAX_SIZE];
GNode *node;
EtMbEntity *entity;
- mb5_release_get_id ((Mb5Release)release,
- release_mbid,
- sizeof (release_mbid));
+ int size;
+
+ 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));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
+
+ size = mb5_release_get_id ((Mb5Release)release,
+ buf,
+ sizeof (buf));
+ buf [size] = '\0';
metadata_release = mb5_query_query (query, "release",
- release_mbid, "",
+ buf, "",
1, param_names,
param_values);
entity = g_malloc (sizeof (EtMbEntity));
@@ -139,24 +157,39 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
if (medium)
{
Mb5Metadata metadata_recording;
- gchar recording_mbid [NAME_MAX_SIZE];
+ gchar buf [NAME_MAX_SIZE];
GNode *node;
EtMbEntity *entity;
Mb5TrackList track_list;
int j;
+ int size;
+ gchar *message;
track_list = mb5_medium_get_tracklist (medium);
+ message = g_strdup_printf ("Found %d Track(s)", mb5_track_list_size (list));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
for (j = 0; j < mb5_track_list_size (track_list); j++)
{
Mb5Recording recording;
recording = mb5_track_get_recording (mb5_track_list_item (track_list, j));
- mb5_recording_get_id (recording,
- recording_mbid,
- sizeof (recording_mbid));
+ size = mb5_recording_get_title (recording, buf,
+ sizeof (buf));
+ buf [size] = '\0';
+ message = g_strdup_printf ("Retrieving %s (%d/%d)",
+ buf, j,
+ mb5_track_list_size (track_list));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
+
+ size = mb5_recording_get_id (recording,
+ buf,
+ sizeof (buf));
+
metadata_recording = mb5_query_query (query, "recording",
- recording_mbid, "",
+ buf, "",
1, param_names,
param_values);
entity = g_malloc (sizeof (EtMbEntity));
@@ -316,19 +349,35 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
for (i = 0; i < mb5_release_list_size (list); i++)
{
Mb5Release release;
+ gchar *message;
+
+ message = g_strdup_printf ("Found %d Album(s)", mb5_release_list_size (list));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
+
release = mb5_release_list_item (list, i);
if (release)
{
Mb5Metadata metadata_release;
- gchar release_mbid [NAME_MAX_SIZE];
+ gchar buf [NAME_MAX_SIZE];
GNode *node;
EtMbEntity *entity;
+ int size;
+
+ 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));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
mb5_release_get_id ((Mb5Release)release,
- release_mbid,
- sizeof (release_mbid));
+ buf,
+ sizeof (buf));
metadata_release = mb5_query_query (query, "release",
- release_mbid, "",
+ buf, "",
1, param_names,
param_values);
entity = g_malloc (sizeof (EtMbEntity));
@@ -364,25 +413,39 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
{
int i;
Mb5RecordingList list;
+ gchar *message;
list = mb5_metadata_get_recordinglist (metadata);
param_names [0] = "inc";
param_values[0] = "releases artists";
+ message = g_strdup_printf ("Found %d Track(s)",
+ mb5_recording_list_size (list));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
for (i = 0; i < mb5_recording_list_size (list); i++)
{
Mb5Recording recording;
Mb5Metadata metadata_recording;
- gchar recording_mbid [NAME_MAX_SIZE];
+ gchar buf [NAME_MAX_SIZE];
GNode *node;
EtMbEntity *entity;
+ int size;
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));
+ et_show_status_msg_in_idle (message);
+ g_free (message);
+
mb5_recording_get_id (recording,
- recording_mbid,
- sizeof (recording_mbid));
+ buf,
+ sizeof (buf));
metadata_recording = mb5_query_query (query, "recording",
- recording_mbid, "",
+ buf, "",
1, param_names,
param_values);
entity = g_malloc (sizeof (EtMbEntity));
diff --git a/src/mbentityview.c b/src/mbentityview.c
index f91fc03..f532467 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -816,6 +816,12 @@ et_mb_entity_view_new ()
return GTK_WIDGET (g_object_new (et_mb_entity_view_get_type (), NULL));
}
+/*
+ * et_mb_entity_view_set_tree_root:
+ * @entity_view: EtMbEntityView
+ *
+ * To select all rows.
+ */
void
et_mb_entity_view_select_all (EtMbEntityView *entity_view)
{
@@ -825,6 +831,12 @@ et_mb_entity_view_select_all (EtMbEntityView *entity_view)
gtk_tree_selection_select_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)));
}
+/*
+ * et_mb_entity_view_unselect_all:
+ * @entity_view: EtMbEntityView
+ *
+ * To unselect all rows.
+ */
void
et_mb_entity_view_unselect_all (EtMbEntityView *entity_view)
{
@@ -834,6 +846,12 @@ et_mb_entity_view_unselect_all (EtMbEntityView *entity_view)
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)));
}
+/*
+ * et_mb_entity_view_toggle_red_lines:
+ * @entity_view: EtMbEntityView
+ *
+ * To toggle the state of red lines being displayed.
+ */
void
et_mb_entity_view_toggle_red_lines (EtMbEntityView *entity_view)
{
@@ -845,6 +863,12 @@ et_mb_entity_view_toggle_red_lines (EtMbEntityView *entity_view)
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
}
+/*
+ * et_mb_entity_view_invert_selection:
+ * @entity_view: EtMbEntityView
+ *
+ * To select the unselected rows and unselect the selected rows.
+ */
void
et_mb_entity_view_invert_selection (EtMbEntityView *entity_view)
{
@@ -873,6 +897,12 @@ et_mb_entity_view_invert_selection (EtMbEntityView *entity_view)
while (gtk_tree_model_iter_next (priv->filter, &filter_iter));
}
+/*
+ * et_mb_entity_view_get_current_level:
+ * @entity_view: EtMbEntityView
+ *
+ * Get the current level at which search results are shown
+ */
int
et_mb_entity_view_get_current_level (EtMbEntityView *entity_view)
{
@@ -888,6 +918,12 @@ et_mb_entity_view_get_current_level (EtMbEntityView *entity_view)
return n;
}
+/*
+ * et_mb_entity_view_search_in_results:
+ * @entity_view: EtMbEntityView
+ *
+ * To search in the results obtained
+ */
void
et_mb_entity_view_search_in_results (EtMbEntityView *entity_view,
const gchar *text)
@@ -900,52 +936,72 @@ et_mb_entity_view_search_in_results (EtMbEntityView *entity_view,
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
}
+/*
+ * et_mb_entity_view_select_up:
+ * @entity_view: EtMbEntityView
+ *
+ * To select the row above the current row.
+ */
void
et_mb_entity_view_select_up (EtMbEntityView *entity_view)
{
EtMbEntityViewPrivate *priv;
GtkTreeSelection *selection;
GtkTreeIter iter;
+ GList *selected_rows;
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
-
- if (!gtk_tree_selection_iter_is_selected (selection, &iter))
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &priv->filter);
+ gtk_tree_model_get_iter (priv->filter, &iter,
+ (g_list_first (selected_rows)->data));
+ if (!gtk_tree_model_iter_next (priv->filter, &iter))
{
- return;
- }
-
- if (!gtk_tree_model_iter_previous (priv->filter, &iter))
- {
- return;
+ goto exit;
}
gtk_tree_selection_select_iter (selection, &iter);
+
+ exit:
+ g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
}
+/*
+ * et_mb_entity_view_select_down:
+ * @entity_view: EtMbEntityView
+ *
+ * To select the row below the current row.
+ */
void
et_mb_entity_view_select_down (EtMbEntityView *entity_view)
{
EtMbEntityViewPrivate *priv;
GtkTreeSelection *selection;
GtkTreeIter iter;
+ GList *selected_rows;
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
-
- if (!gtk_tree_selection_iter_is_selected (selection, &iter))
- {
- return;
- }
-
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &priv->filter);
+ gtk_tree_model_get_iter (priv->filter, &iter,
+ g_list_last (selected_rows)->data);
if (!gtk_tree_model_iter_next (priv->filter, &iter))
{
- return;
+ goto exit;
}
gtk_tree_selection_select_iter (selection, &iter);
+
+ exit:
+ g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
}
+/*
+ * et_mb_entity_view_refresh_current_level:
+ * @entity_view: EtMbEntityView
+ *
+ * To re download data from MusicBrainz Server at the current level.
+ */
void
et_mb_entity_view_refresh_current_level (EtMbEntityView *entity_view)
{
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 88598b2..de3dc21 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -74,6 +74,14 @@ manual_search_callback (GObject *source, GAsyncResult *res,
gtk_combo_box_text_get_active_text (combo_box));
}
+/*
+ * et_show_status_msg_in_idle_cb:
+ * @obj: Source Object
+ * @res: GAsyncResult
+ * @user_data: User data
+ *
+ * Callback function for Displaying StatusBar Message.
+ */
static void
et_show_status_msg_in_idle_cb (GObject *obj, GAsyncResult *res,
gpointer user_data)
@@ -84,6 +92,14 @@ et_show_status_msg_in_idle_cb (GObject *obj, GAsyncResult *res,
g_object_unref (res);
}
+/*
+ * et_show_status_msg_in_idle_cb:
+ * @obj: Source Object
+ * @res: GAsyncResult
+ * @user_data: User data
+ *
+ * Function to Display StatusBar Message.
+ */
void
et_show_status_msg_in_idle (gchar *message)
{
@@ -96,6 +112,14 @@ et_show_status_msg_in_idle (gchar *message)
g_simple_async_result_complete_in_idle (async_res);
}
+/*
+ * et_show_status_msg_in_idle_cb:
+ * @obj: Source Object
+ * @res: GAsyncResult
+ * @user_data: User data
+ *
+ * Callback function for Displaying StatusBar Message.
+ */
void
mb5_search_error_callback (GObject *source, GAsyncResult *res,
gpointer user_data)
@@ -144,11 +168,11 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
}
/*
- * btn_manual_find_clicked:
- * @btn: The source GtkButton
- * @user_data: User data passed
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
*
- * Signal Handler for "clicked" signal of mbSearchButton.
+ * Signal Handler for "clicked" signal of btnManualFind.
*/
static void
btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
@@ -184,42 +208,91 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
mb5_search_cancellable);
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnToggleRedLines.
+ */
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));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnUp.
+ */
static void
tool_btn_up_clicked (GtkWidget *btn, gpointer user_data)
{
et_mb_entity_view_select_up (ET_MB_ENTITY_VIEW (entityView));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnDown.
+ */
static void
tool_btn_down_clicked (GtkWidget *btn, gpointer user_data)
{
et_mb_entity_view_select_down (ET_MB_ENTITY_VIEW (entityView));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnInvertSelection.
+ */
static void
tool_btn_invert_selection_clicked (GtkWidget *btn, gpointer user_data)
{
et_mb_entity_view_invert_selection (ET_MB_ENTITY_VIEW (entityView));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnSelectAll.
+ */
static void
tool_btn_select_all_clicked (GtkWidget *btn, gpointer user_data)
{
et_mb_entity_view_select_all (ET_MB_ENTITY_VIEW (entityView));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of toolbtnUnselectAll.
+ */
static void
tool_btn_unselect_all_clicked (GtkWidget *btn, gpointer user_data)
{
et_mb_entity_view_unselect_all (ET_MB_ENTITY_VIEW (entityView));
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of btnManualStop.
+ */
static void
tool_btn_refersh_clicked (GtkWidget *btn, gpointer user_data)
{
@@ -232,17 +305,31 @@ tool_btn_refersh_clicked (GtkWidget *btn, gpointer user_data)
}
}
+/*
+ * btn_manual_stop_clicked:
+ * @btn: GtkButton
+ * @user_data: User data
+ *
+ * Signal Handler for "clicked" signal of btnManualStop.
+ */
static void
btn_manual_stop_clicked (GtkWidget *btn, gpointer user_data)
{
g_cancellable_cancel (mb5_search_cancellable);
}
+/*
+ * entry_tree_view_search_changed:
+ * @editable: GtkEditable for which handler is called
+ * @user_data: User data
+ *
+ * Signal Handler for "changed" signal of entryTreeViewSearch.
+ */
static void
entry_tree_view_search_changed (GtkEditable *editable, gpointer user_data)
{
et_mb_entity_view_search_in_results (ET_MB_ENTITY_VIEW (entityView),
- gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
"entryTreeViewSearch"))));
+ gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
"entryTreeViewSearch"))));
}
/*
@@ -300,6 +387,9 @@ et_open_musicbrainz_dialog ()
g_signal_connect (gtk_builder_get_object (builder, "toolbtnInvertSelection"),
"clicked", G_CALLBACK (tool_btn_invert_selection_clicked),
NULL);
+ g_signal_connect (gtk_builder_get_object (builder, "toolbtnToggleRedLines"),
+ "clicked", G_CALLBACK (tool_btn_toggle_red_lines_clicked),
+ NULL);
g_signal_connect_after (gtk_builder_get_object (builder, "entryTreeViewSearch"),
"changed",
G_CALLBACK (entry_tree_view_search_changed),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]