gui/sidebar: Add a right click menu
Implements #112: Add sidebar right-click menu Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
31cda0eebd
commit
64e27c1221
|
@ -211,17 +211,23 @@ bool __gui_sidebar_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
|||
gpointer data)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
bool ret = true;
|
||||
|
||||
if (event->type != GDK_2BUTTON_PRESS ||
|
||||
event->button != GDK_BUTTON_MIDDLE)
|
||||
return false;
|
||||
if (!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (event->button == GDK_BUTTON_SECONDARY) {
|
||||
gtk_tree_view_set_cursor(treeview, path, NULL, false);
|
||||
gtk_menu_popup_at_pointer(gui_sidebar_menu(), (GdkEvent *)event);
|
||||
} else if (event->type == GDK_2BUTTON_PRESS &&
|
||||
event->button == GDK_BUTTON_MIDDLE) {
|
||||
__gui_sidebar_do_rename(path);
|
||||
} else
|
||||
ret = false;
|
||||
|
||||
gtk_tree_path_free(path);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void __gui_sidebar_resized(GtkPaned *pane, GParamSpec *pspec, gpointer data)
|
||||
|
|
|
@ -106,6 +106,12 @@ static inline GtkTreeView *gui_sidebar_treeview()
|
|||
return GTK_TREE_VIEW(gui_builder_widget("sidebar_treeview"));
|
||||
}
|
||||
|
||||
/* Called to get the sidebar right-click menu. */
|
||||
static inline GtkMenu *gui_sidebar_menu()
|
||||
{
|
||||
return GTK_MENU(gui_builder_widget("rc_sidebar"));
|
||||
}
|
||||
|
||||
/* Called to get the random button. */
|
||||
static inline GtkToggleButton *gui_random_button()
|
||||
{
|
||||
|
|
|
@ -88,6 +88,58 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="image25">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">dialog-ok</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image26">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">edit-delete</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image27">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">document-edit</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="rc_sidebar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label" translatable="yes">Select Playlist</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image25</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="__gui_sidebar_select" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label" translatable="yes">Rename Playlist</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image27</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="__gui_sidebar_rename" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label" translatable="yes">Delete Playlist</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image26</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="__gui_sidebar_delete" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
|
Loading…
Reference in New Issue