Commit a15e9efc authored by Jorn Baayen's avatar Jorn Baayen
Browse files

nodes seem to be working relatively well now

parent 4a6828b6
2002-10-18 Jorn Baayen <jorn@nl.linux.org>
* lib/widgets/rb-tree-model-node.c:
(rb_tree_model_node_set_property):
* library/rb-library-xml-thread.c: (rb_library_xml_thread_init),
(rb_library_xml_thread_new), (rb_library_xml_thread_set_property),
(thread_main):
* library/rb-library.c: (rb_library_finalize):
* library/rb-node.c: (rb_node_dispose), (child_changed),
(rb_node_set_property), (rb_node_save_to_xml),
(rb_node_new_from_xml), (real_add_child), (rb_node_add_child),
(real_remove_child), (rb_node_remove_child):
* shell/main.c: (main), (rb_handle_cmdline):
* shell/rb-shell-player.c: (rb_shell_player_finalize):
* shell/rb-shell.c: (rb_shell_finalize), (rb_shell_corba_quit),
(rb_shell_construct), (rb_shell_show):
* views/rb-group-view.c: (remove_nodes), (rb_group_view_delete):
* views/rb-library-view.c: (delete_nodes),
(rb_library_view_delete):
Nodes seem to be working relatively well now.
2002-10-15 Jorn Baayen <jorn@nl.linux.org>
* lib/widgets/rb-node-view.c: (rb_node_view_set_property),
......
......@@ -298,7 +298,6 @@ rb_tree_model_node_set_property (GObject *object,
case PROP_FILTER_PARENT:
{
RBNode *old = model->priv->filter_parent;
RBNode *to_hide = NULL;
int i = -1;
model->priv->filter_parent = g_value_get_object (value);
......@@ -320,13 +319,6 @@ rb_tree_model_node_set_property (GObject *object,
if (is_root)
i++;
if (l == kids->len - 1) /* HACK: do not hide all nodes, so we don't
trigger build_level in the filtermodel */
{
to_hide = node;
continue;
}
if (model->priv->old_filter_artist != NULL)
{
if (rb_node_song_has_artist (RB_NODE_SONG (node),
......@@ -399,9 +391,6 @@ rb_tree_model_node_set_property (GObject *object,
G_CALLBACK (filter_parent_child_removed_cb),
G_OBJECT (model), 0);
}
if (to_hide != NULL)
rb_tree_model_node_update_node (model, to_hide, -1);
}
break;
case PROP_FILTER_ARTIST:
......
......@@ -147,8 +147,6 @@ rb_library_xml_thread_init (RBLibraryXMLThread *thread)
{
thread->priv = g_new0 (RBLibraryXMLThreadPrivate, 1);
thread->priv->lock = g_mutex_new ();
thread->priv->object = thread;
}
......@@ -186,8 +184,6 @@ rb_library_xml_thread_new (RBLibrary *library,
"filename", filename,
NULL));
g_return_val_if_fail (library_xml_thread->priv != NULL, NULL);
return library_xml_thread;
}
......@@ -205,18 +201,23 @@ rb_library_xml_thread_set_property (GObject *object,
thread->priv->library = g_value_get_object (value);
break;
case PROP_FILE_NAME:
if (thread->priv->filename != NULL)
g_free (thread->priv->filename);
thread->priv->filename = g_strdup (g_value_get_string (value));
if (g_file_test (thread->priv->filename, G_FILE_TEST_EXISTS) == TRUE)
{
thread->priv->lock = g_mutex_new ();
thread->priv->thread = g_thread_create ((GThreadFunc) thread_main,
thread->priv, TRUE, NULL);
}
else
{
done_loading (thread->priv);
g_free (thread->priv->filename);
g_free (thread->priv);
thread->priv = NULL;
}
break;
default:
......@@ -252,8 +253,6 @@ thread_main (RBLibraryXMLThreadPrivate *priv)
{
int media_files = 0;
static RBProfiler *p = NULL;
priv->finished_preloading = FALSE;
while (TRUE)
......@@ -268,17 +267,16 @@ thread_main (RBLibraryXMLThreadPrivate *priv)
g_mutex_free (priv->lock);
if (priv->doc != NULL)
xmlFreeDoc (priv->doc);
g_free (priv->filename);
g_free (priv);
priv->object->priv = NULL;
rb_profiler_dump (p);
rb_profiler_free (p);
g_thread_exit (NULL);
}
if (priv->initialized_file == FALSE)
{
char *tmp;
priv->doc = xmlParseFile (priv->filename);
if (priv->doc == NULL)
......@@ -297,8 +295,6 @@ thread_main (RBLibraryXMLThreadPrivate *priv)
g_free (tmp);
priv->initialized_file = TRUE;
p = rb_profiler_new ("XML loader thread");
}
if (priv->child == NULL && priv->dead == FALSE)
......@@ -312,7 +308,8 @@ thread_main (RBLibraryXMLThreadPrivate *priv)
if (node == NULL)
continue;
if (rb_node_has_child (rb_library_get_all_songs (priv->library), node)) {
if (rb_node_has_child (rb_library_get_all_songs (priv->library), node))
{
const char *location;
location = rb_node_get_property_string (node,
......
......@@ -182,7 +182,7 @@ rb_library_finalize (GObject *object)
g_object_unref (G_OBJECT (library->priv->walker_thread));
g_object_unref (G_OBJECT (library->priv->main_queue));
g_object_unref (G_OBJECT (library->priv->walker_queue));
rb_library_save (library);
/* unref all songs. this will set a nice chain of recursive unrefs in motion */
......
......@@ -308,6 +308,8 @@ rb_node_dispose (GObject *object)
g_static_rw_lock_writer_unlock (id_to_node_lock);
GDK_THREADS_ENTER ();
/* remove from DAG */
g_hash_table_foreach (node->priv->parents,
(GHFunc) remove_child,
......@@ -325,15 +327,13 @@ rb_node_dispose (GObject *object)
g_static_rw_lock_writer_unlock (child->priv->lock);
}
GDK_THREADS_ENTER ();
write_lock_to_read_lock (node);
g_signal_emit (G_OBJECT (node), rb_node_signals[DESTROYED], 0);
read_lock_to_write_lock (node);
GDK_THREADS_LEAVE ();
g_static_rw_lock_reader_unlock (node->priv->lock);
g_static_rw_lock_writer_unlock (node->priv->lock);
GDK_THREADS_LEAVE ();
G_OBJECT_CLASS (parent_class)->dispose (object);
}
......@@ -482,19 +482,15 @@ child_changed (long id,
RBNodeParent *node_info,
RBNode *node)
{
g_static_rw_lock_writer_lock (node_info->node->priv->lock);
g_static_rw_lock_reader_lock (node_info->node->priv->lock);
GDK_THREADS_ENTER ();
write_lock_to_read_lock (node_info->node);
write_lock_to_read_lock (node);
g_signal_emit (G_OBJECT (node_info->node), rb_node_signals[CHILD_CHANGED], 0, node);
read_lock_to_write_lock (node_info->node);
read_lock_to_write_lock (node);
GDK_THREADS_LEAVE ();
g_static_rw_lock_writer_unlock (node_info->node->priv->lock);
g_static_rw_lock_reader_unlock (node_info->node->priv->lock);
}
static void
......@@ -532,6 +528,8 @@ rb_node_set_property (RBNode *node,
g_return_if_fail (property_id >= 0);
g_return_if_fail (value != NULL);
GDK_THREADS_ENTER ();
g_static_rw_lock_writer_lock (node->priv->lock);
new = g_new0 (GValue, 1);
......@@ -541,6 +539,8 @@ rb_node_set_property (RBNode *node,
real_set_property (node, property_id, new);
g_static_rw_lock_writer_unlock (node->priv->lock);
GDK_THREADS_LEAVE ();
}
gboolean
......@@ -842,31 +842,31 @@ rb_node_save_to_xml (RBNode *node,
switch (G_VALUE_TYPE (value))
{
case G_TYPE_STRING:
xmlSetProp (value_xml_node, "value", g_value_get_string (value));
xmlNodeSetContent (value_xml_node, g_value_get_string (value));
break;
case G_TYPE_BOOLEAN:
xml = g_strdup_printf ("%d", g_value_get_boolean (value));
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
break;
case G_TYPE_INT:
xml = g_strdup_printf ("%d", g_value_get_int (value));
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
break;
case G_TYPE_LONG:
xml = g_strdup_printf ("%ld", g_value_get_long (value));
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
break;
case G_TYPE_FLOAT:
xml = g_strdup_printf ("%f", g_value_get_float (value));
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
break;
case G_TYPE_DOUBLE:
xml = g_strdup_printf ("%f", g_value_get_double (value));
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
break;
case G_TYPE_POINTER:
......@@ -880,7 +880,7 @@ rb_node_save_to_xml (RBNode *node,
g_static_rw_lock_reader_lock (prop_node->priv->lock);
xml = g_strdup_printf ("%ld", prop_node->priv->id);
xmlSetProp (value_xml_node, "value", xml);
xmlNodeSetContent (value_xml_node, xml);
g_free (xml);
g_static_rw_lock_reader_unlock (prop_node->priv->lock);
......@@ -890,8 +890,6 @@ rb_node_save_to_xml (RBNode *node,
g_assert_not_reached ();
break;
}
xmlSetProp (value_xml_node, "value", xml);
}
g_hash_table_foreach (node->priv->parents,
......@@ -924,6 +922,8 @@ rb_node_new_from_xml (xmlNodePtr xml_node)
type = g_type_from_name (xml);
g_free (xml);
GDK_THREADS_ENTER ();
node = RB_NODE (g_object_new (type,
"id", id,
NULL));
......@@ -945,7 +945,13 @@ rb_node_new_from_xml (xmlNodePtr xml_node)
parent = rb_node_get_from_id (parent_id);
if (parent != NULL)
{
g_static_rw_lock_writer_lock (parent->priv->lock);
real_add_child (parent, node);
g_static_rw_lock_writer_unlock (parent->priv->lock);
}
} else if (strcmp (xml_child->name, "property") == 0) {
GType value_type;
GValue *value;
......@@ -959,7 +965,7 @@ rb_node_new_from_xml (xmlNodePtr xml_node)
value_type = g_type_from_name (xml);
g_free (xml);
xml = xmlGetProp (xml_child, "value");
xml = xmlNodeGetContent (xml_child);
value = g_new0 (GValue, 1);
g_value_init (value, value_type);
......@@ -1003,16 +1009,14 @@ rb_node_new_from_xml (xmlNodePtr xml_node)
}
}
GDK_THREADS_ENTER ();
write_lock_to_read_lock (node);
g_signal_emit (G_OBJECT (node), rb_node_signals[RESTORED], 0);
read_lock_to_write_lock (node);
g_static_rw_lock_reader_unlock (node->priv->lock);
GDK_THREADS_LEAVE ();
g_static_rw_lock_writer_unlock (node->priv->lock);
return node;
}
......@@ -1037,8 +1041,6 @@ real_add_child (RBNode *node,
GINT_TO_POINTER (node->priv->id),
node_info);
GDK_THREADS_ENTER ();
write_lock_to_read_lock (node);
write_lock_to_read_lock (child);
......@@ -1046,8 +1048,6 @@ real_add_child (RBNode *node,
read_lock_to_write_lock (node);
read_lock_to_write_lock (child);
GDK_THREADS_LEAVE ();
}
void
......@@ -1057,6 +1057,8 @@ rb_node_add_child (RBNode *node,
g_return_if_fail (RB_IS_NODE (node));
g_return_if_fail (RB_IS_NODE (child));
GDK_THREADS_ENTER ();
g_static_rw_lock_writer_lock (node->priv->lock);
g_static_rw_lock_writer_lock (child->priv->lock);
......@@ -1064,6 +1066,8 @@ rb_node_add_child (RBNode *node,
g_static_rw_lock_writer_unlock (node->priv->lock);
g_static_rw_lock_writer_unlock (child->priv->lock);
GDK_THREADS_LEAVE ();
}
static void
......@@ -1074,8 +1078,6 @@ real_remove_child (RBNode *node,
{
RBNodeParent *node_info;
GDK_THREADS_ENTER ();
write_lock_to_read_lock (node);
write_lock_to_read_lock (child);
......@@ -1125,8 +1127,6 @@ real_remove_child (RBNode *node,
g_hash_table_remove (child->priv->parents,
GINT_TO_POINTER (node->priv->id));
}
GDK_THREADS_LEAVE ();
}
void
......@@ -1136,6 +1136,8 @@ rb_node_remove_child (RBNode *node,
g_return_if_fail (RB_IS_NODE (node));
g_return_if_fail (RB_IS_NODE (child));
GDK_THREADS_ENTER ();
g_static_rw_lock_writer_lock (node->priv->lock);
g_static_rw_lock_writer_lock (child->priv->lock);
......@@ -1143,6 +1145,8 @@ rb_node_remove_child (RBNode *node,
g_static_rw_lock_writer_unlock (node->priv->lock);
g_static_rw_lock_writer_unlock (child->priv->lock);
GDK_THREADS_LEAVE ();
}
gboolean
......
......@@ -68,6 +68,8 @@ main (int argc, char **argv)
GNOME_PARAM_APP_DATADIR, DATADIR,
NULL);
gdk_threads_init ();
#ifdef ENABLE_NLS
/* initialize i18n */
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
......@@ -155,7 +157,7 @@ rb_handle_cmdline (char **argv, int argc)
return;
}
for (i = 0; i < argc; i++)
for (i = 1; i < argc; i++)
{
char *tmp;
......
......@@ -272,7 +272,8 @@ rb_shell_player_finalize (GObject *object)
g_return_if_fail (shell_player->priv != NULL);
g_object_unref (G_OBJECT (shell_player->priv->mixer));
/* FIXME hangs somewhere in gstreamer .. */
/*g_object_unref (G_OBJECT (shell_player->priv->mixer));*/
if (shell_player->priv->remote != NULL)
g_object_unref (G_OBJECT (shell_player->priv->remote));
......
......@@ -419,8 +419,6 @@ rb_shell_finalize (GObject *object)
gtk_widget_hide (shell->priv->window);
gtk_widget_hide (GTK_WIDGET (shell->priv->tray_icon));
rb_shell_player_stop (shell->priv->player_shell);
while (gtk_events_pending ())
gtk_main_iteration ();
eel_gconf_monitor_remove ("/apps/rhythmbox");
......@@ -447,7 +445,11 @@ rb_shell_finalize (GObject *object)
g_free (shell->priv->sidebar_layout_file);
g_object_unref (G_OBJECT (shell->priv->clipboard_shell));
/* hack to make the gdk thread lock available for freeing
* the library.. evil */
GDK_THREADS_LEAVE ();
g_object_unref (G_OBJECT (shell->priv->library));
GDK_THREADS_ENTER ();
if (shell->priv->remote != NULL)
g_object_unref (G_OBJECT (shell->priv->remote));
......@@ -482,7 +484,11 @@ rb_shell_corba_quit (PortableServer_Servant _servant,
{
RBShell *shell = RB_SHELL (bonobo_object (_servant));
GDK_THREADS_ENTER ();
rb_shell_quit (shell);
GDK_THREADS_LEAVE ();
}
static void
......@@ -616,8 +622,8 @@ rb_shell_construct (RBShell *shell)
if (gul_toolbar_listen_to_gconf (toolbar, CONF_TOOLBAR_SETUP) == FALSE)
{
/* FIXME: make this a dialog? */
g_warning ("An incorrect toolbar configuration has been found, \
resetting to the default");
g_warning ("An incorrect toolbar configuration has been found,"
"resetting to the default");
/* this is to make sure we get a toolbar, even if the
setup is wrong or there is no schema */
......@@ -752,8 +758,6 @@ rb_shell_show (RBLibrary *library,
/* GO GO GO */
rb_shell_sync_window_visibility (shell);
gtk_widget_show_all (GTK_WIDGET (shell->priv->tray_icon));
while (gtk_events_pending ())
gtk_main_iteration ();
}
char *
......@@ -1610,15 +1614,18 @@ static void
rb_shell_sync_window_visibility (RBShell *shell)
{
gboolean visible;
static int window_x = 0;
static int window_y = 0;
static int window_x = -1;
static int window_y = -1;
visible = eel_gconf_get_boolean (CONF_STATE_WINDOW_VISIBLE);
if (visible == TRUE)
{
gtk_window_move (GTK_WINDOW (shell->priv->window), window_x,
window_y);
if (window_x >= 0 && window_y >= 0)
{
gtk_window_move (GTK_WINDOW (shell->priv->window), window_x,
window_y);
}
gtk_widget_show_now (shell->priv->window);
}
else
......
......@@ -955,10 +955,9 @@ rb_group_view_paste (RBViewClipboard *clipboard,
}
}
static void
rb_group_view_delete (RBViewClipboard *clipboard)
static gboolean
remove_nodes (RBGroupView *view)
{
RBGroupView *view = RB_GROUP_VIEW (clipboard);
GList *sel, *l;
sel = g_list_copy (rb_node_view_get_selection (view->priv->songs));
......@@ -967,6 +966,16 @@ rb_group_view_delete (RBViewClipboard *clipboard)
rb_node_remove_child (view->priv->group, RB_NODE (l->data));
}
g_list_free (sel);
return FALSE;
}
static void
rb_group_view_delete (RBViewClipboard *clipboard)
{
RBGroupView *view = RB_GROUP_VIEW (clipboard);
g_idle_add ((GSourceFunc) remove_nodes, view);
}
static void
......
......@@ -993,10 +993,9 @@ rb_library_view_paste (RBViewClipboard *clipboard,
{
}
static void
rb_library_view_delete (RBViewClipboard *clipboard)
static gboolean
delete_nodes (RBLibraryView *view)
{
RBLibraryView *view = RB_LIBRARY_VIEW (clipboard);
GList *sel, *l;
sel = g_list_copy (rb_node_view_get_selection (view->priv->songs));
......@@ -1005,6 +1004,16 @@ rb_library_view_delete (RBViewClipboard *clipboard)
rb_library_remove_node (view->priv->library, RB_NODE (l->data));
}
g_list_free (sel);
return FALSE;
}
static void
rb_library_view_delete (RBViewClipboard *clipboard)
{
RBLibraryView *view = RB_LIBRARY_VIEW (clipboard);
g_idle_add ((GSourceFunc) delete_nodes, view);
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment