gui/collection: Remove library paths with the Delete key
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
0afe46b5df
commit
2cae2cd525
|
@ -72,6 +72,33 @@ void __collection_toggled(GtkCellRendererToggle *toggle, gchar *path,
|
|||
__collection_set_library(&iter, library);
|
||||
}
|
||||
|
||||
bool __collection_keypress(GtkTreeView *treeview, GdkEventKey *event,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
struct library *library = NULL;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GList *rows;
|
||||
|
||||
if (event->keyval != GDK_KEY_Delete)
|
||||
return false;
|
||||
|
||||
rows = gtk_tree_selection_get_selected_rows(selection, &c_model);
|
||||
path = rows->data;
|
||||
|
||||
if (gtk_tree_model_get_iter(c_model, &iter, path))
|
||||
library = __collection_get_library(&iter);
|
||||
if (!library)
|
||||
goto out;
|
||||
|
||||
collection_remove(library);
|
||||
gtk_tree_store_remove(GTK_TREE_STORE(c_model), &iter);
|
||||
out:
|
||||
g_list_free_full(rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
return true;
|
||||
}
|
||||
|
||||
void __collection_add(GtkButton *button, GtkFileChooser *chooser)
|
||||
{
|
||||
gchar *filename = gtk_file_chooser_get_filename(chooser);
|
||||
|
|
|
@ -18,6 +18,7 @@ void __sidebar_resize() {}
|
|||
#ifdef TEST_NEED_COLLECTION
|
||||
void __collection_activated() {}
|
||||
void __collection_add() {}
|
||||
void __collection_keypress() {}
|
||||
void __collection_selection_changed() {}
|
||||
void __collection_toggled() {}
|
||||
#endif /* TEST_NEED_COLLECTION */
|
||||
|
|
|
@ -283,8 +283,8 @@
|
|||
<property name="icon_name">media-skip-backward</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="AudioPrev" signal="clicked"/>
|
||||
<accelerator key="n" signal="clicked" modifiers="GDK_SHIFT_MASK"/>
|
||||
<accelerator key="AudioPrev" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -318,8 +318,8 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -352,8 +352,8 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -386,8 +386,8 @@
|
|||
<property name="icon_name">media-playback-stop</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="space" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
<accelerator key="AudioPlay" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
<accelerator key="space" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -420,8 +420,8 @@
|
|||
<property name="icon_name">media-skip-forward</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="AudioNext" signal="clicked"/>
|
||||
<accelerator key="n" signal="clicked"/>
|
||||
<accelerator key="AudioNext" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -627,6 +627,7 @@
|
|||
<property name="show_expanders">False</property>
|
||||
<property name="level_indentation">10</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<signal name="key-press-event" handler="__collection_keypress" swapped="no"/>
|
||||
<signal name="row-activated" handler="__collection_activated" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection2">
|
||||
|
|
Loading…
Reference in New Issue