gui/collection: add button for adding library paths

This is easier than responding to events from the treeview.  Let's just
pop up a dialog and let the user select from there, rather than doing
something complicated with a stack.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-05-11 10:20:21 -04:00 committed by Anna Schumaker
parent 62e1b27b6c
commit 73c70678bb
2 changed files with 55 additions and 6 deletions

View File

@ -10,6 +10,7 @@
#include <gui/idle.h>
#include <gui/playlist.h>
#include <gui/sidebar.h>
#include <glib/gi18n.h>
enum collection_sidebar_columns {
C_SB_IMAGE,
@ -155,6 +156,31 @@ void __collection_add(GtkButton *button, GtkFileChooser *chooser)
g_free(filename);
}
void __collection_choose(GtkButton *button, gpointer data)
{
GtkFileFilter *filter;
GtkWidget *dialog;
gint res;
filter = gtk_file_filter_new();
gtk_file_filter_add_mime_type(filter, "inode/directory");
dialog = gtk_file_chooser_dialog_new("Chooser a Path",
GTK_WINDOW(gui_builder_widget("o_window")),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT)
__collection_add(button, GTK_FILE_CHOOSER(dialog));
gtk_widget_destroy(dialog);
g_object_unref(filter);
}
void __collection_selection_changed(GtkTreeSelection *selection,
GtkFileChooser *chooser)
{

View File

@ -215,6 +215,11 @@
</object>
</child>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">folder-new</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -322,8 +327,8 @@
<property name="icon_name">media-skip-backward</property>
</object>
</child>
<accelerator key="n" signal="clicked" modifiers="GDK_SHIFT_MASK"/>
<accelerator key="AudioPrev" signal="clicked"/>
<accelerator key="n" signal="clicked" modifiers="GDK_SHIFT_MASK"/>
</object>
<packing>
<property name="expand">False</property>
@ -357,8 +362,8 @@
<property name="icon_size">5</property>
</object>
</child>
<accelerator key="space" signal="clicked"/>
<accelerator key="AudioPlay" signal="clicked"/>
<accelerator key="space" signal="clicked"/>
</object>
<packing>
<property name="expand">False</property>
@ -391,8 +396,8 @@
<property name="icon_size">5</property>
</object>
</child>
<accelerator key="space" signal="clicked"/>
<accelerator key="AudioPlay" signal="clicked"/>
<accelerator key="space" signal="clicked"/>
</object>
<packing>
<property name="expand">False</property>
@ -425,8 +430,8 @@
<property name="icon_name">media-skip-forward</property>
</object>
</child>
<accelerator key="n" signal="clicked"/>
<accelerator key="AudioNext" signal="clicked"/>
<accelerator key="n" signal="clicked"/>
</object>
<packing>
<property name="expand">False</property>
@ -825,6 +830,7 @@
<property name="margin_left">2</property>
<property name="margin_right">3</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkButtonBox" id="buttonbox2">
<property name="visible">True</property>
@ -842,7 +848,7 @@
<property name="inconsistent">True</property>
<signal name="toggled" handler="__audio_favorite" swapped="no"/>
<child>
<object class="GtkImage" id="image6">
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-favorite</property>
@ -864,7 +870,7 @@
<property name="tooltip_text" translatable="yes">Hide this track from the Collection</property>
<signal name="toggled" handler="__audio_hide" swapped="no"/>
<child>
<object class="GtkImage" id="image7">
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close</property>
@ -890,6 +896,7 @@
<property name="can_focus">True</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="margin_right">1</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="viewport1">
@ -1048,6 +1055,22 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Add Library Path</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image3</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="__collection_choose" 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="resize">False</property>