gui/tempq: Remove tempq.c
Temporary queues are being replaced by the Queued Tracks playlist. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
69b39ea717
commit
69e628f505
|
@ -10,7 +10,6 @@
|
|||
#include <gui/playlist.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <gui/tempq.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/window.h>
|
||||
|
||||
|
@ -24,7 +23,7 @@ const static gchar *OCARINA_NAME = "org.gtk.ocarina-debug";
|
|||
|
||||
struct core_init_data init_data = {
|
||||
&playlist_ops,
|
||||
&tempq_ops,
|
||||
NULL,
|
||||
&audio_ops,
|
||||
};
|
||||
|
||||
|
|
15
gui/queue.c
15
gui/queue.c
|
@ -56,13 +56,6 @@ void __queue_repeat(GtkToggleButton *button, gpointer data)
|
|||
Q_REPEAT);
|
||||
}
|
||||
|
||||
void __queue_disabled(GtkSwitch *enabled, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
__queue_toggle_flag(gtk_switch_get_active(enabled),
|
||||
gui_builder_widget("o_treeview"),
|
||||
Q_ENABLED);
|
||||
}
|
||||
|
||||
static gboolean __queue_visible_func(GtkTreeModel *model, GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
|
@ -169,31 +162,26 @@ void gui_queue_free(struct queue *queue)
|
|||
|
||||
void gui_queue_show(struct gui_queue *queue)
|
||||
{
|
||||
GtkTreeView *view = GTK_TREE_VIEW(gui_builder_widget("o_treeview"));
|
||||
GtkButton *random = GTK_BUTTON(gui_builder_widget("o_random"));
|
||||
GtkButton *repeat = GTK_BUTTON(gui_builder_widget("o_repeat"));
|
||||
GtkSwitch *enabled = GTK_SWITCH(gui_builder_widget("o_enable"));
|
||||
GtkEntry *search = GTK_ENTRY(gui_builder_widget("o_search"));
|
||||
bool has_random = false, has_repeat = false, is_enabled = false;;
|
||||
bool has_random = false, has_repeat = false;
|
||||
gchar *text;
|
||||
|
||||
gq_queue = queue;
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(random), gui_queue_can_random(queue));
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(repeat), gui_queue_can_repeat(queue));
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(enabled), gui_queue_can_disable(queue));
|
||||
|
||||
if (queue) {
|
||||
has_random = queue_has_flag(queue->gq_queue, Q_RANDOM);
|
||||
has_repeat = queue_has_flag(queue->gq_queue, Q_REPEAT);
|
||||
is_enabled = queue_has_flag(queue->gq_queue, Q_ENABLED);
|
||||
gui_view_set_queue(queue->gq_queue);
|
||||
} else
|
||||
gui_view_set_queue(NULL);
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(random), has_random);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(repeat), has_repeat);
|
||||
gtk_switch_set_active(GTK_SWITCH(enabled), is_enabled);
|
||||
|
||||
/*
|
||||
* Some GTK themes have trouble with toggle buttons,
|
||||
|
@ -201,7 +189,6 @@ void gui_queue_show(struct gui_queue *queue)
|
|||
*/
|
||||
gtk_widget_set_sensitive(gtk_button_get_image(random), has_random);
|
||||
gtk_widget_set_sensitive(gtk_button_get_image(repeat), has_repeat);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(view), is_enabled);
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(search), queue != NULL);
|
||||
|
||||
|
|
51
gui/tempq.c
51
gui/tempq.c
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tempq.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/sidebar.h>
|
||||
|
||||
#define TEMPQ_FLAGS (GQ_CAN_RANDOM | GQ_CAN_REPEAT | GQ_CAN_DISABLE)
|
||||
|
||||
static void *__tempq_init(struct queue *queue, void *data)
|
||||
{
|
||||
return gui_queue_alloc(NULL, queue, "Queued Tracks", TEMPQ_FLAGS);
|
||||
}
|
||||
|
||||
static void __tempq_deinit(struct queue *queue)
|
||||
{
|
||||
gui_queue_free(queue);
|
||||
}
|
||||
|
||||
static void __tempq_added(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
gui_queue_model_add(queue, pos);
|
||||
tempq_save(queue, Q_ENABLED);
|
||||
}
|
||||
|
||||
static bool __tempq_erase(struct queue *queue, struct track *track)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void __tempq_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
gui_queue_model_remove(queue, pos);
|
||||
tempq_save(queue, Q_ENABLED);
|
||||
}
|
||||
|
||||
static void __tempq_cleared(struct queue *queue, unsigned int n)
|
||||
{
|
||||
gui_queue_model_clear(queue, n);
|
||||
}
|
||||
|
||||
struct queue_ops tempq_ops = {
|
||||
.qop_init = __tempq_init,
|
||||
.qop_deinit = __tempq_deinit,
|
||||
.qop_added = __tempq_added,
|
||||
.qop_erase = __tempq_erase,
|
||||
.qop_removed = __tempq_removed,
|
||||
.qop_cleared = __tempq_cleared,
|
||||
.qop_save = tempq_save,
|
||||
.qop_updated = gui_queue_model_update,
|
||||
};
|
26
gui/view.c
26
gui/view.c
|
@ -4,7 +4,6 @@
|
|||
#include <core/audio.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/settings.h>
|
||||
#include <core/tempq.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/model.h>
|
||||
#include <gui/queue.h>
|
||||
|
@ -175,12 +174,6 @@ void __view_column_clicked(GtkTreeViewColumn *col, gpointer data)
|
|||
g_timeout_add_seconds(3, __view_dec_sort, NULL);
|
||||
}
|
||||
|
||||
static void __view_add_to_queue(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
queue_add(data, __view_filter_get_track(path));
|
||||
}
|
||||
|
||||
static void __view_add_to_playlist(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
|
@ -204,17 +197,8 @@ static void __view_delete_selection(GtkTreeSelection *selection)
|
|||
static void __view_process_selection(GtkTreeView *treeview, unsigned int keyval)
|
||||
{
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
struct queue *queue;
|
||||
|
||||
switch (keyval) {
|
||||
case GDK_KEY_KP_0 ... GDK_KEY_KP_9:
|
||||
keyval = (keyval - GDK_KEY_KP_0) + GDK_KEY_0;
|
||||
case GDK_KEY_0 ... GDK_KEY_9:
|
||||
queue = tempq_get(keyval - GDK_KEY_0);
|
||||
if (queue)
|
||||
gtk_tree_selection_selected_foreach(selection,
|
||||
__view_add_to_queue, queue);
|
||||
break;
|
||||
case GDK_KEY_f:
|
||||
gtk_tree_selection_selected_foreach(selection,
|
||||
__view_add_to_playlist,
|
||||
|
@ -279,9 +263,7 @@ bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
|||
{
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
GtkMenu *menu = GTK_MENU(gui_builder_widget("o_menu"));
|
||||
unsigned int i, size = tempq_count();
|
||||
GtkTreePath *path;
|
||||
gchar *name;
|
||||
|
||||
if (event->button != 3)
|
||||
return false;
|
||||
|
@ -295,14 +277,6 @@ bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
|||
}
|
||||
|
||||
/* Determine which menu items can be shown */
|
||||
gtk_widget_set_visible(gui_builder_widget("o_new_queue"), size < 10);
|
||||
gtk_widget_set_visible(gui_builder_widget("o_add_to_queue"), size > 0);
|
||||
for (i = 0; i < 10; i++) {
|
||||
name = g_strdup_printf("o_queue_%d", i);
|
||||
gtk_widget_set_visible(gui_builder_widget(name), i < size);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_TEMPQ_H
|
||||
#define OCARINA_GUI_TEMPQ_H
|
||||
|
||||
/* Temporary queue operations passed to core_init() */
|
||||
extern struct queue_ops tempq_ops;
|
||||
|
||||
#endif /* OCARINA_GUI_TEMPQ_H */
|
|
@ -9,18 +9,6 @@
|
|||
<property name="margin_right">10</property>
|
||||
<property name="icon_name">media-playlist-repeat</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image12">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">document-new</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image13">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">list-add</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image18">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
@ -42,121 +30,6 @@
|
|||
<object class="GtkMenu" id="o_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_new_queue">
|
||||
<property name="label" translatable="yes">New Queue</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image12</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="__view_rc_new_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_queue">
|
||||
<property name="label" translatable="yes">Add to Queue</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image13</property>
|
||||
<property name="use_stock">False</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_0">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 0</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 1</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 2</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 3</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 4</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 6</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 7</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 8</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="o_queue_9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Queue 9</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="__view_rc_add_to_queue" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_playlist">
|
||||
<property name="label" translatable="yes">Add to Playlist</property>
|
||||
|
@ -961,21 +834,6 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="o_enable">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin_right">8</property>
|
||||
<property name="active">True</property>
|
||||
<signal name="notify::active" handler="__queue_disabled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
|
@ -1233,10 +1091,9 @@
|
|||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
<widgets>
|
||||
<widget name="button1"/>
|
||||
<widget name="buttonbox4"/>
|
||||
<widget name="o_pause_after"/>
|
||||
<widget name="o_enable"/>
|
||||
<widget name="button1"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
|
@ -1245,7 +1102,6 @@
|
|||
<widget name="o_pause_after"/>
|
||||
<widget name="buttonbox2"/>
|
||||
<widget name="filter_how"/>
|
||||
<widget name="o_enable"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="sizegroup1">
|
||||
|
|
|
@ -35,22 +35,18 @@ static void test_queue()
|
|||
{
|
||||
GtkToggleButton *random, *repeat;
|
||||
GtkWidget *random_img, *repeat_img;
|
||||
GtkTreeView *treeview;
|
||||
struct gui_queue *gq;
|
||||
GtkSwitch *enable;
|
||||
GtkEntry *search;
|
||||
struct queue q;
|
||||
|
||||
search = GTK_ENTRY(gui_builder_widget("o_search"));
|
||||
enable = GTK_SWITCH(gui_builder_widget("o_enable"));
|
||||
random = GTK_TOGGLE_BUTTON(gui_builder_widget("o_random"));
|
||||
repeat = GTK_TOGGLE_BUTTON(gui_builder_widget("o_repeat"));
|
||||
random_img = gtk_button_get_image(GTK_BUTTON(random));
|
||||
repeat_img = gtk_button_get_image(GTK_BUTTON(repeat));
|
||||
treeview = GTK_TREE_VIEW(gui_builder_widget("o_treeview"));
|
||||
|
||||
/* Test initialization */
|
||||
queue_init(&q, 0, &test_ops, NULL);
|
||||
queue_init(&q, Q_ENABLED, &test_ops, NULL);
|
||||
gq = gui_queue(&q);
|
||||
|
||||
g_assert_true(gui_queue_can_random(gq));
|
||||
|
@ -64,15 +60,12 @@ static void test_queue()
|
|||
|
||||
gtk_entry_set_text(search, "Test text");
|
||||
|
||||
/* Show a queue where random, repeat, and switch are disabled */
|
||||
/* Show a queue where random and repeat are disabled */
|
||||
gui_queue_show(gq);
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(random)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(repeat)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(enable)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(treeview)));
|
||||
g_assert_false(gtk_toggle_button_get_active(random));
|
||||
g_assert_false(gtk_toggle_button_get_active(repeat));
|
||||
g_assert_false(gtk_switch_get_active(enable));
|
||||
g_assert_false(gtk_widget_get_sensitive(random_img));
|
||||
g_assert_false(gtk_widget_get_sensitive(repeat_img));
|
||||
g_assert_cmpstr(gtk_entry_get_text(search), ==, "");
|
||||
|
@ -95,26 +88,14 @@ static void test_queue()
|
|||
g_assert_false(gtk_widget_get_sensitive(repeat_img));
|
||||
g_assert_false(queue_has_flag(&q, Q_REPEAT));
|
||||
|
||||
/* Test clicking enabled switch. */
|
||||
gtk_switch_set_active(enable, true);
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(treeview)));
|
||||
g_assert_true(queue_has_flag(&q, Q_ENABLED));
|
||||
|
||||
gtk_switch_set_active(enable, false);
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(treeview)));
|
||||
g_assert_false(queue_has_flag(&q, Q_ENABLED));
|
||||
|
||||
/* Show a queue where random, repeat, and switch are enabled */
|
||||
/* Show a queue where random and repeat are enabled */
|
||||
gq->gq_flags = GQ_CAN_RANDOM | GQ_CAN_REPEAT | GQ_CAN_DISABLE;
|
||||
q.q_flags = Q_RANDOM | Q_REPEAT | Q_ENABLED;
|
||||
gui_queue_show(gq);
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(random)));
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(repeat)));
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(enable)));
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(treeview)));
|
||||
g_assert_true(gtk_toggle_button_get_active(random));
|
||||
g_assert_true(gtk_toggle_button_get_active(repeat));
|
||||
g_assert_true(gtk_switch_get_active(enable));
|
||||
g_assert_true(gtk_widget_get_sensitive(random_img));
|
||||
g_assert_true(gtk_widget_get_sensitive(repeat_img));
|
||||
|
||||
|
@ -123,11 +104,8 @@ static void test_queue()
|
|||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(search)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(random)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(repeat)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(enable)));
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(treeview)));
|
||||
g_assert_false(gtk_toggle_button_get_active(random));
|
||||
g_assert_false(gtk_toggle_button_get_active(repeat));
|
||||
g_assert_false(gtk_switch_get_active(enable));
|
||||
g_assert_false(gtk_widget_get_sensitive(random_img));
|
||||
g_assert_false(gtk_widget_get_sensitive(repeat_img));
|
||||
|
||||
|
|
Loading…
Reference in New Issue