gui/view: Scroll to the current queue's iterator position
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d5c365ddf0
commit
f328b1686d
|
@ -6,6 +6,7 @@
|
||||||
#include <core/string.h>
|
#include <core/string.h>
|
||||||
#include <gui/audio.h>
|
#include <gui/audio.h>
|
||||||
#include <gui/builder.h>
|
#include <gui/builder.h>
|
||||||
|
#include <gui/view.h>
|
||||||
|
|
||||||
|
|
||||||
static inline void __audio_set_label(const gchar *label, const gchar *size,
|
static inline void __audio_set_label(const gchar *label, const gchar *size,
|
||||||
|
@ -35,6 +36,7 @@ static void __audio_load(struct track *track)
|
||||||
playlist_has(PL_HIDDEN, track));
|
playlist_has(PL_HIDDEN, track));
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui_builder_widget("o_favorite")),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui_builder_widget("o_favorite")),
|
||||||
playlist_has(PL_FAVORITED, track));
|
playlist_has(PL_FAVORITED, track));
|
||||||
|
gui_view_scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __audio_change_state(GstState state)
|
static void __audio_change_state(GstState state)
|
||||||
|
|
|
@ -82,6 +82,7 @@ void __queue_filter(GtkSearchEntry *entry, gpointer data)
|
||||||
if (strlen(text) > 0)
|
if (strlen(text) > 0)
|
||||||
filter_search(text, &gq_queue->gq_visible);
|
filter_search(text, &gq_queue->gq_visible);
|
||||||
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(gq_queue->gq_filter));
|
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(gq_queue->gq_filter));
|
||||||
|
gui_view_scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text,
|
struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text,
|
||||||
|
|
23
gui/view.c
23
gui/view.c
|
@ -341,4 +341,27 @@ void gui_view_set_model(GtkTreeModelFilter *filter)
|
||||||
view_sort_count = 0;
|
view_sort_count = 0;
|
||||||
__view_display_sorting("");
|
__view_display_sorting("");
|
||||||
__view_set_sort_indicators();
|
__view_set_sort_indicators();
|
||||||
|
|
||||||
|
gui_view_scroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_view_scroll()
|
||||||
|
{
|
||||||
|
struct queue *queue = __view_filter_get_queue();
|
||||||
|
GtkTreePath *real, *path;
|
||||||
|
|
||||||
|
if (!queue || (int)queue->q_cur.it_pos < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
real = gtk_tree_path_new_from_indices(queue->q_cur.it_pos, -1);
|
||||||
|
path = gtk_tree_model_filter_convert_child_path_to_path(view_filter, real);
|
||||||
|
|
||||||
|
if (path) {
|
||||||
|
gtk_tree_view_scroll_to_cell(view_treeview, path,
|
||||||
|
NULL, TRUE, 0.5, 0.5);
|
||||||
|
gtk_tree_view_set_cursor(view_treeview, path, NULL, false);
|
||||||
|
gtk_tree_path_free(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_path_free(real);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
/* Called to initialize structures needed by the treeview. */
|
/* Called to initialize structures needed by the treeview. */
|
||||||
void gui_view_init();
|
void gui_view_init();
|
||||||
|
|
||||||
|
/* Called to scroll the GUI treeview to the queue's current position. */
|
||||||
|
void gui_view_scroll();
|
||||||
|
|
||||||
/* Called to set the currently displayed model. */
|
/* Called to set the currently displayed model. */
|
||||||
void gui_view_set_model(GtkTreeModelFilter *);
|
void gui_view_set_model(GtkTreeModelFilter *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue