[Goodies-commits] r3985 - xfmpc/trunk/src
Mike Massonnet
mmassonnet at xfce.org
Sat Feb 23 16:15:47 CET 2008
Author: mmassonnet
Date: 2008-02-23 15:15:47 +0000 (Sat, 23 Feb 2008)
New Revision: 3985
Modified:
xfmpc/trunk/src/playlist.c
xfmpc/trunk/src/playlist.h
Log:
New public function xfmpc_playlist_select_row
* src/playlist.c,
src/playlist.h:
- Replace COLUMN_IS_CURRENT with COLUMN_WEIGHT
- Move code from cb_playlist_changed to new function xfmpc_playlist_select_row
Modified: xfmpc/trunk/src/playlist.c
===================================================================
--- xfmpc/trunk/src/playlist.c 2008-02-23 14:25:44 UTC (rev 3984)
+++ xfmpc/trunk/src/playlist.c 2008-02-23 15:15:47 UTC (rev 3985)
@@ -53,7 +53,7 @@
COLUMN_ID,
COLUMN_SONG,
COLUMN_LENGTH,
- COLUMN_IS_CURRENT,
+ COLUMN_WEIGHT,
N_COLUMNS,
};
@@ -162,7 +162,7 @@
GtkTreeViewColumn *column =
gtk_tree_view_column_new_with_attributes ("Song", cell,
"text", COLUMN_SONG,
- "weight", COLUMN_IS_CURRENT,
+ "weight", COLUMN_WEIGHT,
NULL);
g_object_set (G_OBJECT (column),
"expand", TRUE,
@@ -177,7 +177,7 @@
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview),
-1, "Length", cell,
"text", COLUMN_LENGTH,
- "weight", COLUMN_IS_CURRENT,
+ "weight", COLUMN_WEIGHT,
NULL);
/* Scrolled window */
@@ -236,7 +236,7 @@
COLUMN_ID, id,
COLUMN_SONG, song,
COLUMN_LENGTH, length,
- COLUMN_IS_CURRENT, is_current ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
+ COLUMN_WEIGHT, is_current ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
-1);
}
@@ -248,17 +248,26 @@
gtk_list_store_clear (priv->store);
}
+void
+xfmpc_playlist_select_row (XfmpcPlaylist *playlist,
+ gint i)
+{
+ XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST_GET_PRIVATE (playlist);
+
+ GtkTreePath *path = gtk_tree_path_new_from_indices (i, -1);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->treeview), path, NULL, TRUE, 0.42, 0);
+ gtk_tree_path_free (path);
+}
+
static void
cb_playlist_changed (XfmpcPlaylist *playlist)
{
XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST_GET_PRIVATE (playlist);
- gchar *song;
- gchar *length;
- gint id;
- gint current;
+ gchar *song, *length;
+ gint id, current;
gboolean count = priv->autocenter;
gint i = 0;
- GtkTreePath *path;
current = xfmpc_mpdclient_get_id (playlist->mpdclient);
@@ -273,12 +282,7 @@
}
if (priv->autocenter)
- {
- path = gtk_tree_path_new_from_indices (i, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->treeview), path, NULL, TRUE, 0.5, 0);
- gtk_tree_path_free (path);
- }
+ xfmpc_playlist_select_row (playlist, i);
}
static void
Modified: xfmpc/trunk/src/playlist.h
===================================================================
--- xfmpc/trunk/src/playlist.h 2008-02-23 14:25:44 UTC (rev 3984)
+++ xfmpc/trunk/src/playlist.h 2008-02-23 15:15:47 UTC (rev 3985)
@@ -46,6 +46,9 @@
gboolean is_current);
void xfmpc_playlist_clear (XfmpcPlaylist *playlist);
+void xfmpc_playlist_select_row (XfmpcPlaylist *playlist,
+ gint i);
+
G_END_DECLS
#endif
More information about the Goodies-commits
mailing list