[easytag/wip/musicbrainz-support] Use GtkToggleButton and GtkBox instead of GtkToggleToolButton and GtkToolbar for Bread Crumb
- From: Abhinav Jangda <abhijangda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support] Use GtkToggleButton and GtkBox instead of GtkToggleToolButton and GtkToolbar for Bread Crumb
- Date: Thu, 15 May 2014 13:08:36 +0000 (UTC)
commit 475110ffb3b01abb8ac550d2cf2039ff1aecdfe7
Author: Abhinav <abhijangda hotmail com>
Date: Thu May 15 18:37:02 2014 +0530
Use GtkToggleButton and GtkBox instead of GtkToggleToolButton and GtkToolbar for Bread Crumb
data/musicbrainz_dialog.glade | 56 +++++++++++++----------
src/mbentityview.c | 100 +++++++++++++++++++++++-----------------
2 files changed, 88 insertions(+), 68 deletions(-)
---
diff --git a/data/musicbrainz_dialog.glade b/data/musicbrainz_dialog.glade
index 415f3cf..92126dd 100755
--- a/data/musicbrainz_dialog.glade
+++ b/data/musicbrainz_dialog.glade
@@ -1,36 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkImage" id="image12">
+ <object class="GtkImage" id="findimage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-find</property>
</object>
- <object class="GtkImage" id="image13">
+ <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="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="image8">
+ <object class="GtkImage" id="image12">
<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="image13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="findimage">
+ <object class="GtkImage" id="image14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">5</property>
+ </object>
+ <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="image14">
+ <object class="GtkImage" id="image9">
<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">gtk-stop</property>
</object>
<object class="GtkImage" id="img_invert_selection">
<property name="visible">True</property>
@@ -47,16 +57,6 @@
<property name="can_focus">False</property>
<property name="stock">easytag-unselect-all</property>
</object>
- <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="image11">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-stop</property>
- </object>
<object class="GtkDialog" id="mbDialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -531,12 +531,18 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkComboBoxText" id="comboboxtext1">
+ <object class="GtkComboBoxText" id="cmbTextSearch">
<property name="width_request">131</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxtext-entry">
+ <property name="can_focus">False</property>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -559,7 +565,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton3">
+ <object class="GtkToolButton" id="toolbtnDown">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton3</property>
@@ -582,7 +588,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton5">
+ <object class="GtkToolButton" id="toolbtnInvertSelection">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton5</property>
@@ -595,7 +601,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton6">
+ <object class="GtkToolButton" id="toolbtnSelectAll">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton6</property>
@@ -608,7 +614,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton7">
+ <object class="GtkToolButton" id="toolbtnUnselectAll">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton7</property>
@@ -621,7 +627,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton8">
+ <object class="GtkToolButton" id="toolbtnToggleRedLines">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton8</property>
@@ -634,7 +640,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="toolbutton9">
+ <object class="GtkToolButton" id="toolbtnRefresh">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton9</property>
diff --git a/src/mbentityview.c b/src/mbentityview.c
index e9311ef..22b9dd2 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -38,9 +38,9 @@ char *columns [MB_ENTITY_TYPE_COUNT][8] = {
/*
* EtMbEntityViewPrivate:
- * @breadCrumbBox: GtkToolbar which represents the BreadCrumbWidget
+ * @breadCrumbBox: GtkBox which represents the BreadCrumbWidget
* @treeView: GtkTreeView to display the recieved music brainz data
- * @breadCrumbNodes: Array of GNode being displayed by the GtkToggleToolButton
+ * @breadCrumbNodes: Array of GNode being displayed by the GtkToggleButton
* @listStore: GtkTreeStore for treeView
* @scrolledWindow: GtkScrolledWindow for treeView
* @mbTreeRoot: Root Node of the Mb5Entity Tree
@@ -58,7 +58,7 @@ typedef struct
GtkWidget *scrolledWindow;
GNode *mbTreeRoot;
GNode *mbTreeCurrentNode;
- GtkToolItem *activeToggleButton;
+ GtkWidget *activeToggleButton;
} EtMbEntityViewPrivate;
/**************
@@ -69,14 +69,14 @@ static void
et_mb_entity_view_class_init (EtMbEntityViewClass *klass);
static void
et_mb_entity_view_init (EtMbEntityView *proj_notebook);
-static GtkToolItem *
-insert_togglebtn_in_toolbar (GtkToolbar *toolbar);
+static GtkWidget *
+insert_togglebtn_in_breadcrumb (GtkBox *breadCrumb);
static void
add_iter_to_list_store (GtkListStore *list_store, GNode *node);
static void
show_data_in_entity_view (EtMbEntityView *entity_view);
static void
-toggle_button_clicked (GtkToolButton *btn, gpointer user_data);
+toggle_button_clicked (GtkWidget *btn, gpointer user_data);
static void
tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data);
@@ -131,17 +131,17 @@ et_mb_entity_view_class_init (EtMbEntityViewClass *klass)
/*
* insert_togglebtn_in_toolbar:
- * @toolbar: GtkToolbar in which GtkToggleToolButton will be inserted
+ * @toolbar: GtkBox in which GtkToggleToolButton will be inserted
*
- * Returns: GtkToolItem inserted in GtkToolbar.
- * Insert a GtkToggleToolButton in GtkToolbar.
+ * Returns: GtkWidget inserted in GtkBox.
+ * Insert a GtkToggleButton in GtkBox.
*/
-static GtkToolItem *
-insert_togglebtn_in_toolbar (GtkToolbar *toolbar)
+static GtkWidget *
+insert_togglebtn_in_breadcrumb (GtkBox *breadCrumb)
{
- GtkToolItem *btn;
- btn = gtk_toggle_tool_button_new ();
- gtk_toolbar_insert (toolbar, btn, -1);
+ GtkWidget *btn;
+ btn = gtk_toggle_button_new ();
+ gtk_box_pack_start (breadCrumb, btn, FALSE, FALSE, 2);
return btn;
}
@@ -327,21 +327,22 @@ show_data_in_entity_view (EtMbEntityView *entity_view)
/*
* toggle_button_clicked:
- * @btn: The GtkToolButton clicked.
+ * @btn: The GtkToggleButton clicked.
* @user_data: User Data passed to the handler.
*
- * The singal handler for GtkToggleToolButton's clicked signal.
+ * The singal handler for GtkToggleButton's clicked signal.
*/
static void
-toggle_button_clicked (GtkToolButton *btn, gpointer user_data)
+toggle_button_clicked (GtkWidget *btn, gpointer user_data)
{
EtMbEntityView *entity_view;
EtMbEntityViewPrivate *priv;
+ GList *children;
entity_view = ET_MB_ENTITY_VIEW (user_data);
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
- if (btn == GTK_TOOL_BUTTON (priv->activeToggleButton))
+ if (btn == priv->activeToggleButton)
{
return;
}
@@ -357,9 +358,9 @@ toggle_button_clicked (GtkToolButton *btn, gpointer user_data)
FALSE);
}
- priv->mbTreeCurrentNode = priv->breadCrumbNodes[gtk_toolbar_get_item_index (GTK_TOOLBAR
(priv->breadCrumbBox),
- GTK_TOOL_ITEM (btn))];
- priv->activeToggleButton = GTK_TOOL_ITEM (btn);
+ children = gtk_container_get_children (GTK_CONTAINER (priv->breadCrumbBox));
+ priv->mbTreeCurrentNode = priv->breadCrumbNodes[g_list_index (children, btn)];
+ priv->activeToggleButton = btn;
show_data_in_entity_view (entity_view);
}
@@ -378,7 +379,7 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
{
EtMbEntityView *entity_view;
EtMbEntityViewPrivate *priv;
- GtkToolItem *toggle_btn;
+ GtkWidget *toggle_btn;
int depth;
GtkTreeIter iter;
gchar *entity_name;
@@ -406,18 +407,12 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
return;
}
- toggle_btn = insert_togglebtn_in_toolbar (GTK_TOOLBAR (priv->breadCrumbBox));
- priv->breadCrumbNodes [gtk_toolbar_get_n_items (GTK_TOOLBAR (priv->breadCrumbBox)) - 1] =
priv->mbTreeCurrentNode;
-
- for (depth = gtk_toolbar_get_n_items (GTK_TOOLBAR (priv->breadCrumbBox));
- depth < MB_ENTITY_TYPE_COUNT; depth++)
- {
- priv->breadCrumbNodes [depth] = NULL;
- }
+ toggle_btn = insert_togglebtn_in_breadcrumb (GTK_BOX (priv->breadCrumbBox));
+ priv->breadCrumbNodes [g_list_length (gtk_container_get_children (GTK_CONTAINER (priv->breadCrumbBox)))
- 1] = priv->mbTreeCurrentNode;
if (priv->activeToggleButton)
{
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->activeToggleButton),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->activeToggleButton),
FALSE);
}
@@ -426,11 +421,8 @@ tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
G_CALLBACK (toggle_button_clicked), entity_view);
priv->activeToggleButton = toggle_btn;
gtk_tree_model_get_iter (priv->listStore, &iter, path);
- /* TODO: Toggle Tool Button not setting the label */
gtk_tree_model_get (priv->listStore, &iter, 0, &entity_name, -1);
- printf ("entity_name %s\n", entity_name);
- gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (toggle_btn), NULL);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toggle_btn), entity_name);
+ gtk_button_set_label (GTK_BUTTON (toggle_btn), entity_name);
gtk_widget_show_all (GTK_WIDGET (priv->breadCrumbBox));
show_data_in_entity_view (entity_view);
}
@@ -449,7 +441,7 @@ et_mb_entity_view_init (EtMbEntityView *entity_view)
gtk_orientable_set_orientation (GTK_ORIENTABLE (entity_view), GTK_ORIENTATION_VERTICAL);
/* Adding child widgets */
- priv->breadCrumbBox = gtk_toolbar_new ();
+ priv->breadCrumbBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
priv->treeView = gtk_tree_view_new ();
priv->scrolledWindow = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (priv->scrolledWindow), priv->treeView);
@@ -478,16 +470,38 @@ void
et_mb_entity_view_set_tree_root (EtMbEntityView *entity_view, GNode *treeRoot)
{
EtMbEntityViewPrivate *priv;
- GtkToolItem *btn;
+ GtkWidget *btn;
+ GNode *child;
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
priv->mbTreeRoot = treeRoot;
priv->mbTreeCurrentNode = treeRoot;
- btn = insert_togglebtn_in_toolbar (GTK_TOOLBAR (priv->breadCrumbBox));
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (btn), "Artists");
- priv->breadCrumbNodes [0] = treeRoot;
- priv->activeToggleButton = btn;
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (btn), TRUE);
- show_data_in_entity_view (entity_view);
+ btn = insert_togglebtn_in_breadcrumb (GTK_BOX (priv->breadCrumbBox));
+ child = g_node_first_child (treeRoot);
+ if (child)
+ {
+ switch (((EtMbEntity *)child->data)->type)
+ {
+ case MB_ENTITY_TYPE_ARTIST:
+ gtk_button_set_label (GTK_BUTTON (btn), "Artists");
+ break;
+
+ case MB_ENTITY_TYPE_ALBUM:
+ gtk_button_set_label (GTK_BUTTON (btn), "Album");
+ break;
+
+ case MB_ENTITY_TYPE_TRACK:
+ gtk_button_set_label (GTK_BUTTON (btn), "Track");
+ break;
+
+ default:
+ break;
+ }
+
+ priv->breadCrumbNodes [0] = treeRoot;
+ priv->activeToggleButton = btn;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (btn), TRUE);
+ show_data_in_entity_view (entity_view);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]