Permalink
Browse files

gtkui: Update information popup when the playlist is scrolled. Closes #…

  • Loading branch information...
1 parent 90da3f5 commit bf23848a9908be5d9e8f56b78989fa946560cd60 @tallica tallica committed Jan 16, 2012
Showing with 42 additions and 1 deletion.
  1. +4 −0 src/gtkui/ui_playlist_notebook.c
  2. +37 −1 src/gtkui/ui_playlist_widget.c
  3. +1 −0 src/gtkui/ui_playlist_widget.h
@@ -267,9 +267,11 @@ void ui_playlist_notebook_create_tab(gint playlist)
{
GtkWidget *scrollwin, *treeview;
GtkWidget *label, *entry, *ebox, *hbox;
+ GtkAdjustment *vscroll;
gint position = aud_playlist_get_position (playlist);
scrollwin = gtk_scrolled_window_new(NULL, NULL);
+ vscroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrollwin));
treeview = ui_playlist_widget_new(playlist);
g_object_set_data(G_OBJECT(scrollwin), "treeview", treeview);
@@ -316,6 +318,8 @@ void ui_playlist_notebook_create_tab(gint playlist)
g_signal_connect(ebox, "button-press-event", G_CALLBACK(tab_button_press_cb), NULL);
g_signal_connect(ebox, "key-press-event", G_CALLBACK(tab_key_press_cb), NULL);
g_signal_connect(entry, "activate", G_CALLBACK(tab_title_save), ebox);
+ g_signal_connect_swapped (vscroll, "value-changed",
+ G_CALLBACK(ui_playlist_widget_scroll), treeview);
}
void ui_playlist_notebook_populate(void)
@@ -48,6 +48,7 @@ typedef struct {
gint list;
GList * queue;
gint popup_source, popup_pos;
+ gboolean popup_shown;
} PlaylistWidgetData;
static void set_int_from_tuple (GValue * value, const Tuple * tuple, gint field)
@@ -212,6 +213,7 @@ static void shift_rows (void * user, gint row, gint before)
static gboolean popup_show (PlaylistWidgetData * data)
{
audgui_infopopup_show (data->list, data->popup_pos);
+ data->popup_shown = TRUE;
g_source_remove (data->popup_source);
data->popup_source = 0;
@@ -226,7 +228,12 @@ static void popup_hide (PlaylistWidgetData * data)
data->popup_source = 0;
}
- audgui_infopopup_hide ();
+ if (data->popup_shown)
+ {
+ audgui_infopopup_hide ();
+ data->popup_shown = FALSE;
+ }
+
data->popup_pos = -1;
}
@@ -239,6 +246,14 @@ static void popup_trigger (PlaylistWidgetData * data, gint pos)
100, (GSourceFunc) popup_show, data);
}
+static void popup_update (PlaylistWidgetData * data, gint row)
+{
+ popup_hide (data);
+
+ audgui_infopopup_show (data->list, row);
+ data->popup_shown = TRUE;
+}
+
static void mouse_motion (void * user, GdkEventMotion * event, gint row)
{
PlaylistWidgetData * data = (PlaylistWidgetData *) user;
@@ -350,6 +365,7 @@ GtkWidget * ui_playlist_widget_new (gint playlist)
data->queue = NULL;
data->popup_source = 0;
data->popup_pos = -1;
+ data->popup_shown = FALSE;
GtkWidget * list = audgui_list_new (& callbacks, data,
aud_playlist_entry_count (playlist));
@@ -456,3 +472,23 @@ void ui_playlist_widget_update (GtkWidget * widget, gint type, gint at,
audgui_list_update_selection (widget, at, count);
update_queue (widget, data);
}
+
+void ui_playlist_widget_scroll (GtkWidget * widget)
+{
+ PlaylistWidgetData * data = audgui_list_get_user (widget);
+ g_return_if_fail (data);
+
+ gint x, y;
+ gtk_widget_get_pointer (widget, &x, &y);
+ gint row = audgui_list_row_at_point (widget, x, y);
+
+ if (data->popup_shown)
+ {
+ if (row < 0)
+ popup_hide (data);
+ else
+ popup_update (data, row);
+ }
+ else if (data->popup_source)
+ data->popup_pos = row;
+}
@@ -29,6 +29,7 @@ gint ui_playlist_widget_get_playlist (GtkWidget * widget);
void ui_playlist_widget_set_playlist (GtkWidget * widget, gint playlist);
void ui_playlist_widget_update (GtkWidget * widget, gint type, gint at,
gint count);
+void ui_playlist_widget_scroll (GtkWidget * widget);
enum {PW_COL_NUMBER, PW_COL_TITLE, PW_COL_ARTIST, PW_COL_YEAR, PW_COL_ALBUM,
PW_COL_TRACK, PW_COL_QUEUED, PW_COL_LENGTH, PW_COL_PATH, PW_COL_FILENAME,

0 comments on commit bf23848

Please sign in to comment.