# HG changeset patch # User mf0102 <0102@gmx.at> # Date 1216318912 -7200 # Node ID e14398ef086894ddf31a9d243dfa8d95ec68720e # Parent cc107c7ec07f06b0e19d0ddc8d0807d97207cc9b remove some code duplication diff -r cc107c7ec07f -r e14398ef0868 src/audacious/ui_playlist_widget.c --- a/src/audacious/ui_playlist_widget.c Thu Jul 17 20:17:32 2008 +0200 +++ b/src/audacious/ui_playlist_widget.c Thu Jul 17 20:21:52 2008 +0200 @@ -40,35 +40,38 @@ playback_initiate(); } +static void +ui_playlist_widget_set_title_active(GtkTreeModel *model, gint pos, + gboolean active) +{ + GtkTreeIter iter; + GtkTreePath *path; + gchar *path_str; + + path_str = g_strdup_printf("%d", pos); + path = gtk_tree_path_new_from_string(path_str); + gtk_tree_model_get_iter(model, &iter, path); + + gtk_list_store_set(GTK_LIST_STORE(model), &iter, + 3, active ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, -1); + + g_free(path_str); + gtk_tree_path_free(path); +} + void ui_playlist_widget_set_current(GtkWidget *treeview, gint pos) { GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path; - gchar *p; - + gint old_pos; + model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); - - gint old_pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(treeview), "current")); + old_pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(treeview), "current")); - if (old_pos != -1) { - p = g_strdup_printf("%d", old_pos); - path = gtk_tree_path_new_from_string(p); - gtk_tree_model_get_iter(model, &iter, path); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, 3, PANGO_WEIGHT_NORMAL, -1); - g_free(p); - gtk_tree_path_free(path); - } - - if (pos != -1) { - p = g_strdup_printf("%d", pos); - path = gtk_tree_path_new_from_string(p); - gtk_tree_model_get_iter(model, &iter, path); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, 3, PANGO_WEIGHT_BOLD, -1); - g_free(p); - gtk_tree_path_free(path); - } + if (old_pos != -1) + ui_playlist_widget_set_title_active(model, old_pos, FALSE); + if (pos != -1) + ui_playlist_widget_set_title_active(model, pos, TRUE); g_object_set_data(G_OBJECT(treeview), "current", GINT_TO_POINTER(pos)); }