gui/view: Add "New Playlist" menu options
And pop up a dialog mox to ask the user for the name of the new playlist. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
1b9101cf26
commit
e2d4dd61fb
60
gui/view.c
60
gui/view.c
|
@ -8,6 +8,7 @@
|
||||||
#include <gui/model.h>
|
#include <gui/model.h>
|
||||||
#include <gui/queue.h>
|
#include <gui/queue.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
static const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
||||||
|
@ -174,10 +175,16 @@ void __view_column_clicked(GtkTreeViewColumn *col, gpointer data)
|
||||||
g_timeout_add_seconds(3, __view_dec_sort, NULL);
|
g_timeout_add_seconds(3, __view_dec_sort, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct view_add_data {
|
||||||
|
enum playlist_type_t vad_type;
|
||||||
|
gchar *vad_name;
|
||||||
|
};
|
||||||
|
|
||||||
static void __view_add_to_playlist(GtkTreeModel *model, GtkTreePath *path,
|
static void __view_add_to_playlist(GtkTreeModel *model, GtkTreePath *path,
|
||||||
GtkTreeIter *iter, gpointer data)
|
GtkTreeIter *iter, gpointer data)
|
||||||
{
|
{
|
||||||
playlist_add(PL_SYSTEM, (gchar *)data, __view_filter_get_track(path));
|
struct view_add_data *vad = (struct view_add_data *)data;
|
||||||
|
playlist_add(vad->vad_type, vad->vad_name, __view_filter_get_track(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __view_delete_selection(GtkTreeSelection *selection)
|
static void __view_delete_selection(GtkTreeSelection *selection)
|
||||||
|
@ -194,20 +201,60 @@ static void __view_delete_selection(GtkTreeSelection *selection)
|
||||||
g_list_free_full(rows, (GDestroyNotify) gtk_tree_path_free);
|
g_list_free_full(rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *__view_get_new_playlist_name(void)
|
||||||
|
{
|
||||||
|
gchar *text = NULL;
|
||||||
|
GtkWidget *entry = gtk_entry_new();
|
||||||
|
GtkWidget *dialog = gtk_dialog_new_with_buttons("New Playlist Name?",
|
||||||
|
GTK_WINDOW(gui_builder_widget("o_window")),
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
|
||||||
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
|
_("_OK"), GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||||
|
|
||||||
|
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
|
||||||
|
gtk_entry_set_activates_default(GTK_ENTRY(entry), true);
|
||||||
|
gtk_container_add(GTK_CONTAINER(content), entry);
|
||||||
|
gtk_widget_show_all(dialog);
|
||||||
|
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
|
text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
|
||||||
|
gtk_widget_destroy(dialog);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
static void __view_process_selection(GtkTreeView *treeview, unsigned int keyval)
|
static void __view_process_selection(GtkTreeView *treeview, unsigned int keyval)
|
||||||
{
|
{
|
||||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||||
|
struct view_add_data vad_data;
|
||||||
|
gchar *text = NULL;
|
||||||
|
|
||||||
switch (keyval) {
|
switch (keyval) {
|
||||||
case GDK_KEY_f:
|
case GDK_KEY_f:
|
||||||
|
vad_data.vad_type = PL_SYSTEM;
|
||||||
|
vad_data.vad_name = "Favorites";
|
||||||
gtk_tree_selection_selected_foreach(selection,
|
gtk_tree_selection_selected_foreach(selection,
|
||||||
__view_add_to_playlist,
|
__view_add_to_playlist,
|
||||||
"Favorites");
|
&vad_data);
|
||||||
|
break;
|
||||||
|
case GDK_KEY_p:
|
||||||
|
text = __view_get_new_playlist_name();
|
||||||
|
if (!text || !playlist_new(PL_USER, text))
|
||||||
|
break;
|
||||||
|
vad_data.vad_type = PL_USER;
|
||||||
|
vad_data.vad_name = text;
|
||||||
|
gtk_tree_selection_selected_foreach(selection,
|
||||||
|
__view_add_to_playlist,
|
||||||
|
&vad_data);
|
||||||
|
g_free(text);
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_q:
|
case GDK_KEY_q:
|
||||||
|
vad_data.vad_type = PL_SYSTEM;
|
||||||
|
vad_data.vad_name = "Queued Tracks";
|
||||||
gtk_tree_selection_selected_foreach(selection,
|
gtk_tree_selection_selected_foreach(selection,
|
||||||
__view_add_to_playlist,
|
__view_add_to_playlist,
|
||||||
"Queued Tracks");
|
&vad_data);
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_Delete:
|
case GDK_KEY_Delete:
|
||||||
__view_delete_selection(selection);
|
__view_delete_selection(selection);
|
||||||
|
@ -258,6 +305,11 @@ void __view_rc_add_hidden(GtkMenuItem *item, gpointer data)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __view_rc_add_new(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
__view_process_selection(view_treeview, GDK_KEY_p);
|
||||||
|
}
|
||||||
|
|
||||||
bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,6 @@
|
||||||
<property name="margin_right">10</property>
|
<property name="margin_right">10</property>
|
||||||
<property name="icon_name">media-playlist-repeat</property>
|
<property name="icon_name">media-playlist-repeat</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkImage" id="image18">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="icon_name">emblem-documents</property>
|
|
||||||
<property name="icon_size">1</property>
|
|
||||||
</object>
|
|
||||||
<object class="GtkImage" id="image19">
|
<object class="GtkImage" id="image19">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -27,50 +21,16 @@
|
||||||
<property name="icon_name">emblem-favorite</property>
|
<property name="icon_name">emblem-favorite</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkMenu" id="o_menu">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="o_add_to_playlist">
|
|
||||||
<property name="label" translatable="yes">Add to Playlist</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="image">image18</property>
|
|
||||||
<property name="use_stock">False</property>
|
|
||||||
<child type="submenu">
|
|
||||||
<object class="GtkMenu" id="menu2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="o_add_to_favorites">
|
|
||||||
<property name="label" translatable="yes">Favorites</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="image">image20</property>
|
|
||||||
<property name="use_stock">False</property>
|
|
||||||
<signal name="activate" handler="__view_rc_add_favorites" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="o_add_to_hidden">
|
|
||||||
<property name="label" translatable="yes">Hidden</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="image">image19</property>
|
|
||||||
<property name="use_stock">False</property>
|
|
||||||
<signal name="activate" handler="__view_rc_add_hidden" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkImage" id="image21">
|
<object class="GtkImage" id="image21">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="icon_name">folder-new</property>
|
<property name="icon_name">folder-new</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkImage" id="image22">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">document-new</property>
|
||||||
|
</object>
|
||||||
<object class="GtkMenu" id="menu1">
|
<object class="GtkMenu" id="menu1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -84,6 +44,61 @@
|
||||||
<signal name="activate" handler="__collection_choose" swapped="no"/>
|
<signal name="activate" handler="__collection_choose" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem">
|
||||||
|
<property name="label" translatable="yes">Playlist</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image22</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
<signal name="activate" handler="__view_rc_add_new" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<object class="GtkImage" id="image23">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">document-new</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkMenu" id="o_menu">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem">
|
||||||
|
<property name="label" translatable="yes">Add to New Playlist</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image23</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
<signal name="activate" handler="__view_rc_add_new" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="o_add_to_favorites">
|
||||||
|
<property name="label" translatable="yes">Add to Favorites</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image20</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
<signal name="activate" handler="__view_rc_add_favorites" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="o_add_to_hidden">
|
||||||
|
<property name="label" translatable="yes">Add to Hidden</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image19</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
<signal name="activate" handler="__view_rc_add_hidden" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparatorMenuItem">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkImage" id="image9">
|
<object class="GtkImage" id="image9">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
Loading…
Reference in New Issue