[easytag/wip/musicbrainz-support-merge: 5/48] Implemented Invert Selection and Toggle Red Lines
- From: Abhinav Jangda <abhijangda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 5/48] Implemented Invert Selection and Toggle Red Lines
- Date: Mon, 11 Aug 2014 11:48:08 +0000 (UTC)
commit 888a97032eca241bb623312cf2735746cb43419f
Author: Abhinav <abhijangda hotmail com>
Date: Wed May 21 22:49:43 2014 +0530
Implemented Invert Selection and Toggle Red Lines
data/musicbrainz_dialog.ui | 44 ++++++++++------
src/mbentityview.c | 124 ++++++++++++++++++++++++++++++++++++++++----
src/mbentityview.h | 4 ++
src/musicbrainz_dialog.c | 13 ++++-
4 files changed, 155 insertions(+), 30 deletions(-)
---
diff --git a/data/musicbrainz_dialog.ui b/data/musicbrainz_dialog.ui
index 09288f1..38547a2 100755
--- a/data/musicbrainz_dialog.ui
+++ b/data/musicbrainz_dialog.ui
@@ -6,56 +6,56 @@
<property name="can_focus">False</property>
<property name="stock">gtk-find</property>
</object>
- <object class="GtkImage" id="image10">
+ <object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-find</property>
</object>
- <object class="GtkImage" id="image11">
+ <object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="image12">
+ <object class="GtkImage" id="img_invert_selection">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-find</property>
+ <property name="stock">easytag-invert-selection</property>
</object>
- <object class="GtkImage" id="image13">
+ <object class="GtkImage" id="img_red_lines">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-stop</property>
+ <property name="stock">easytag-red-lines</property>
</object>
- <object class="GtkImage" id="image14">
+ <object class="GtkImage" id="img_unselect_all">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-missing-image</property>
- <property name="icon-size">5</property>
+ <property name="stock">easytag-unselect-all</property>
</object>
- <object class="GtkImage" id="image8">
+ <object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-find</property>
</object>
- <object class="GtkImage" id="image9">
+ <object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="img_invert_selection">
+ <object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">easytag-invert-selection</property>
+ <property name="stock">gtk-find</property>
</object>
- <object class="GtkImage" id="img_red_lines">
+ <object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">easytag-red-lines</property>
+ <property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="img_unselect_all">
+ <object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">easytag-unselect-all</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">5</property>
</object>
<object class="GtkDialog" id="mbDialog">
<property name="can_focus">False</property>
@@ -288,6 +288,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Start Manual Search
</property>
<property name="image">findimage</property>
</object>
<packing>
@@ -301,6 +302,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Stop Manual
Search</property>
<property name="image">stopimage</property>
</object>
<packing>
@@ -544,6 +546,7 @@
<property name="width_request">131</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Type the text to search
in the results</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
@@ -564,6 +567,7 @@
<object class="GtkToolButton" id="toolbtnUp">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Up</property>
<property name="label" translatable="yes">toolbutton3</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-up</property>
@@ -577,6 +581,7 @@
<object class="GtkToolButton" id="toolbtnDown">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Down</property>
<property name="label" translatable="yes">toolbutton3</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-go-down</property>
@@ -600,6 +605,7 @@
<object class="GtkToolButton" id="toolbtnInvertSelection">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Invert Selections</property>
<property name="label" translatable="yes">toolbutton5</property>
<property name="use_underline">True</property>
<property name="icon_widget">img_invert_selection</property>
@@ -613,6 +619,7 @@
<object class="GtkToolButton" id="toolbtnSelectAll">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Select All</property>
<property name="label" translatable="yes">toolbutton6</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-select-all</property>
@@ -626,6 +633,7 @@
<object class="GtkToolButton" id="toolbtnUnselectAll">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Unselect All</property>
<property name="label" translatable="yes">toolbutton7</property>
<property name="use_underline">True</property>
<property name="icon_widget">img_unselect_all</property>
@@ -639,6 +647,7 @@
<object class="GtkToggleToolButton" id="toolbtnToggleRedLines">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Toggle Red Lines</property>
<property name="label" translatable="yes">toolbutton8</property>
<property name="use_underline">True</property>
<property name="icon_widget">img_red_lines</property>
@@ -652,6 +661,7 @@
<object class="GtkToolButton" id="toolbtnRefresh">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Refresh</property>
<property name="label" translatable="yes">toolbutton9</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-refresh</property>
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 50f75ca..4f979b6 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -67,6 +67,9 @@ typedef struct
GNode *mb_tree_root;
GNode *mb_tree_current_node;
GtkWidget *active_toggle_button;
+ GtkTreeModel *filter;
+ gboolean search_or_red;
+ gboolean toggle_red_lines;
} EtMbEntityViewPrivate;
typedef struct
@@ -95,11 +98,56 @@ toggle_button_clicked (GtkWidget *btn, gpointer user_data);
static void
tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data);
-
+static gboolean
+tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer data);
/*************
* Functions *
*************/
+static gboolean
+tree_filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer data)
+{
+ EtMbEntityViewPrivate *priv;
+
+ priv = (EtMbEntityViewPrivate *)data;
+
+ if (!priv->search_or_red)
+ {
+ gchar *value;
+
+ if (gtk_tree_model_get_n_columns (model) == 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)
+ {
+ 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)
+ {
+ gtk_tree_model_get (model, iter, MB_TRACK_COLUMNS_N, &value, -1);
+ }
+ else
+ {
+ return TRUE;
+ }
+
+ if (g_strcmp0 (value, "black") == 0)
+ {
+ g_free (value);
+ return TRUE;
+ }
+
+ g_free (value);
+
+ return priv->toggle_red_lines;
+ }
+
+ return TRUE;
+}
+
/*
* et_mb_entity_view_get_type
*
@@ -193,8 +241,9 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
{
case MB_ENTITY_TYPE_ARTIST:
mb5_artist_get_name ((Mb5Artist)entity, name, sizeof (name));
- printf ("name %s\n", name);
- gtk_list_store_append (list_store, &iter);
+ //gtk_list_store_append (list_store, &iter);
+ gtk_list_store_insert_with_values (list_store, &iter, -1,
+ MB_ARTIST_COLUMNS_N, "black", -1);
gtk_list_store_set (list_store, &iter,
MB_ARTIST_COLUMNS_NAME, name, -1);
@@ -209,13 +258,11 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
if (((EtMbEntity *)node->data)->is_red_line)
{
- printf ("IS RED\n");
gtk_list_store_set (list_store, &iter,
MB_ARTIST_COLUMNS_N, "red", -1);
}
else
{
- printf ("IS BLACK\n");
gtk_list_store_set (list_store, &iter,
MB_ARTIST_COLUMNS_N, "black", -1);
}
@@ -225,7 +272,9 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
case MB_ENTITY_TYPE_ALBUM:
mb5_release_get_title ((Mb5Release)entity, name,
sizeof (name));
- gtk_list_store_append (list_store, &iter);
+ //gtk_list_store_append (list_store, &iter);
+ gtk_list_store_insert_with_values (list_store, &iter, -1,
+ MB_ALBUM_COLUMNS_N, "black", -1);
gtk_list_store_set (list_store, &iter,
MB_ALBUM_COLUMNS_NAME, name, -1);
@@ -421,10 +470,17 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
"text", total_cols, NULL);
priv->list_store = GTK_TREE_MODEL (gtk_list_store_newv (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),
+ tree_filter_visible_func, priv,
+ NULL);
g_free (types);
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->list_store);
- g_object_unref (priv->list_store);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->filter);
+ //TODO: see if this is required
+ //g_object_unref (priv->list_store);
+ g_object_unref (priv->filter);
add_iter_to_list_store (GTK_LIST_STORE (priv->list_store),
g_node_first_child (priv->mb_tree_current_node));
}
@@ -595,11 +651,14 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
EtMbEntityViewPrivate *priv;
GNode *child;
int depth;
+ GtkTreeIter filter_iter;
GtkTreeIter iter;
entity_view = ET_MB_ENTITY_VIEW (user_data);
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
- gtk_tree_model_get_iter (priv->list_store, &iter, path);
+ gtk_tree_model_get_iter (priv->filter, &filter_iter, path);
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (priv->filter), &iter,
+ &filter_iter);
depth = 0;
while (gtk_tree_model_iter_previous (priv->list_store, &iter))
@@ -607,7 +666,6 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
depth++;
}
- printf ("depth %d\n", depth);
child = g_node_nth_child (priv->mb_tree_current_node,
depth);
@@ -620,7 +678,8 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
thread_data = g_malloc (sizeof (SearchInLevelThreadData));
thread_data->entity_view = ET_MB_ENTITY_VIEW (user_data);
thread_data->child = child;
- gtk_tree_model_get_iter (priv->list_store, &thread_data->iter, path);
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (priv->filter),
&thread_data->iter,
+ &filter_iter);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, "Starting MusicBrainz Search");
async_result = g_simple_async_result_new (NULL,
@@ -661,6 +720,7 @@ et_mb_entity_view_init (EtMbEntityView *entity_view)
priv->mb_tree_root = NULL;
priv->mb_tree_current_node = NULL;
priv->active_toggle_button = NULL;
+ priv->toggle_red_lines = TRUE;
g_signal_connect (G_OBJECT (priv->tree_view), "row-activated",
G_CALLBACK (tree_view_row_activated), entity_view);
@@ -747,3 +807,45 @@ et_mb_entity_view_unselect_all (EtMbEntityView *entity_view)
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)));
}
+<<<<<<< HEAD
+=======
+
+void
+et_mb_entity_view_toggle_red_lines (EtMbEntityView *entity_view)
+{
+ EtMbEntityViewPrivate *priv;
+
+ priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+ priv->search_or_red = FALSE;
+ priv->toggle_red_lines = !priv->toggle_red_lines;
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
+}
+
+void
+et_mb_entity_view_invert_selection (EtMbEntityView *entity_view)
+{
+ EtMbEntityViewPrivate *priv;
+ GtkTreeIter filter_iter;
+ GtkTreeSelection *selection;
+
+ priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
+ if (!gtk_tree_model_get_iter_first (priv->filter, &filter_iter))
+ {
+ return FALSE;
+ }
+
+ do
+ {
+ if (!gtk_tree_selection_iter_is_selected (selection, &filter_iter))
+ {
+ gtk_tree_selection_select_iter (selection, &filter_iter);
+ }
+ else
+ {
+ gtk_tree_selection_unselect_iter (selection, &filter_iter);
+ }
+ }
+ while (gtk_tree_model_iter_next (priv->filter, &filter_iter));
+}
+>>>>>>> 081b366... Implemented Invert Selection and Toggle Red Lines
diff --git a/src/mbentityview.h b/src/mbentityview.h
index 46ba3fc..68db1e0 100644
--- a/src/mbentityview.h
+++ b/src/mbentityview.h
@@ -106,4 +106,8 @@ void
et_mb_entity_view_select_all (EtMbEntityView *entity_view);
void
et_mb_entity_view_unselect_all (EtMbEntityView *entity_view);
+void
+et_mb_entity_view_toggle_red_lines (EtMbEntityView *entity_view);
+void
+et_mb_entity_view_invert_selection (EtMbEntityView *entity_view);
#endif /* __MB_ENTITY_VIEW_H__ */
\ No newline at end of file
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 6063a3d..13e56c6 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -60,12 +60,18 @@ static void
manual_search_callback (GObject *source, GAsyncResult *res,
gpointer user_data)
{
+ GtkComboBoxText *combo_box;
+
et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, "Searching Completed");
g_object_unref (res);
g_free (user_data);
+
+ combo_box = GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, "cbManualSearch"));
+ gtk_combo_box_text_append_text (combo_box,
+ gtk_combo_box_text_get_active_text (combo_box));
}
static void
@@ -181,7 +187,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));
}
static void
@@ -199,7 +205,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));
}
static void
@@ -269,6 +275,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, "toolbtnInvertSelection"),
+ "clicked", G_CALLBACK (tool_btn_invert_selection_clicked),
+ NULL);
/* Fill Values in cb_manual_search_in */
cb_manual_search_in = GTK_WIDGET (gtk_builder_get_object (builder,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]