gui/filter: Add functions for getting the SearchEntry and ComboBox
And take this chance to rename o_search -> filter_search. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
ad29c520d4
commit
b9916706f1
10
gui/queue.c
10
gui/queue.c
|
@ -90,7 +90,6 @@ static gboolean __queue_visible_func(GtkTreeModel *model, GtkTreeIter *iter,
|
||||||
void __queue_filter(GtkSearchEntry *entry, gpointer data)
|
void __queue_filter(GtkSearchEntry *entry, gpointer data)
|
||||||
{
|
{
|
||||||
const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
|
const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||||
GtkComboBox *combo = GTK_COMBO_BOX(gui_builder_widget("filter_how"));
|
|
||||||
|
|
||||||
if (!gq_queue)
|
if (!gq_queue)
|
||||||
return;
|
return;
|
||||||
|
@ -100,7 +99,7 @@ void __queue_filter(GtkSearchEntry *entry, gpointer data)
|
||||||
}
|
}
|
||||||
if (strlen(text) > 0) {
|
if (strlen(text) > 0) {
|
||||||
gq_queue->gq_search = g_str_tokenize_and_fold(text, NULL, NULL);
|
gq_queue->gq_search = g_str_tokenize_and_fold(text, NULL, NULL);
|
||||||
gq_queue->gq_active = gtk_combo_box_get_active(combo);
|
gq_queue->gq_active = gtk_combo_box_get_active(gui_filter_how());
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter(gui_filter_get());
|
gtk_tree_model_filter_refilter(gui_filter_get());
|
||||||
|
@ -109,15 +108,14 @@ void __queue_filter(GtkSearchEntry *entry, gpointer data)
|
||||||
|
|
||||||
void __queue_filter_how_changed(int n)
|
void __queue_filter_how_changed(int n)
|
||||||
{
|
{
|
||||||
__queue_filter(GTK_SEARCH_ENTRY(gui_builder_widget("o_search")), NULL);
|
__queue_filter(gui_filter_search(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_queue_init(void)
|
void gui_queue_init(void)
|
||||||
{
|
{
|
||||||
gtk_tree_model_filter_set_visible_func(gui_filter_get(),
|
gtk_tree_model_filter_set_visible_func(gui_filter_get(),
|
||||||
__queue_visible_func,
|
__queue_visible_func,
|
||||||
gui_builder_object("o_search"),
|
NULL, NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gui_queue *gui_queue_alloc(struct playlist *playlist, struct queue *queue,
|
struct gui_queue *gui_queue_alloc(struct playlist *playlist, struct queue *queue,
|
||||||
|
@ -151,7 +149,7 @@ void gui_queue_free(struct queue *queue)
|
||||||
void gui_queue_show(struct gui_queue *queue)
|
void gui_queue_show(struct gui_queue *queue)
|
||||||
{
|
{
|
||||||
GtkButton *random = GTK_BUTTON(gui_builder_widget("o_random"));
|
GtkButton *random = GTK_BUTTON(gui_builder_widget("o_random"));
|
||||||
GtkEntry *search = GTK_ENTRY(gui_builder_widget("o_search"));
|
GtkEntry *search = GTK_ENTRY(gui_filter_search());
|
||||||
bool has_random = false;
|
bool has_random = false;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,16 @@ struct track *gui_filter_path_get_track(GtkTreePath *);
|
||||||
/* Called to convert a filter model path into a queue index. */
|
/* Called to convert a filter model path into a queue index. */
|
||||||
unsigned int gui_filter_path_get_index(GtkTreePath *);
|
unsigned int gui_filter_path_get_index(GtkTreePath *);
|
||||||
|
|
||||||
|
/* Called to access the filter search-entry. */
|
||||||
|
static inline GtkSearchEntry *gui_filter_search(void)
|
||||||
|
{
|
||||||
|
return GTK_SEARCH_ENTRY(gui_builder_widget("filter_search"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called to access the filter-how chooser. */
|
||||||
|
static inline GtkComboBox *gui_filter_how(void)
|
||||||
|
{
|
||||||
|
return GTK_COMBO_BOX(gui_builder_widget("filter_how"));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OCARINA_GUI_FILTER_H */
|
#endif /* OCARINA_GUI_FILTER_H */
|
||||||
|
|
|
@ -843,7 +843,7 @@ audio-volume-medium</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="o_search">
|
<object class="GtkSearchEntry" id="filter_search">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
|
|
|
@ -46,7 +46,7 @@ static void test_queue()
|
||||||
GtkEntry *search;
|
GtkEntry *search;
|
||||||
struct queue q;
|
struct queue q;
|
||||||
|
|
||||||
search = GTK_ENTRY(gui_builder_widget("o_search"));
|
search = GTK_ENTRY(gui_filter_search());
|
||||||
random = GTK_TOGGLE_BUTTON(gui_builder_widget("o_random"));
|
random = GTK_TOGGLE_BUTTON(gui_builder_widget("o_random"));
|
||||||
|
|
||||||
/* Test initialization */
|
/* Test initialization */
|
||||||
|
@ -96,7 +96,7 @@ static void test_tracks()
|
||||||
struct gui_queue *gq;
|
struct gui_queue *gq;
|
||||||
GtkEntry *search;
|
GtkEntry *search;
|
||||||
|
|
||||||
search = GTK_ENTRY(gui_builder_widget("o_search"));
|
search = GTK_ENTRY(gui_filter_search());
|
||||||
|
|
||||||
gq = gui_queue(playlist_get_queue(PL_SYSTEM, "Collection"));
|
gq = gui_queue(playlist_get_queue(PL_SYSTEM, "Collection"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue