chiark / gitweb /
Start on popup menu for Disobedience choose tab. Mostly this is
[disorder] / disobedience / choose-menu.c
CommitLineData
6982880f
RK
1/*
2 * This file is part of DisOrder
3 * Copyright (C) 2008 Richard Kettlewell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20#include "disobedience.h"
21#include "popup.h"
22#include "choose.h"
23
24/** @brief Popup menu */
25static GtkWidget *choose_menu;
26
27static int choose_selectall_sensitive(void attribute((unused)) *extra) {
28 return TRUE;
29}
30
31static void choose_selectall_activate(GtkMenuItem attribute((unused)) *item,
32 gpointer attribute((unused)) userdata) {
33 gtk_tree_selection_select_all(choose_selection);
34}
35
36static int choose_selectnone_sensitive(void attribute((unused)) *extra) {
37 return gtk_tree_selection_count_selected_rows(choose_selection) > 0;
38}
39
40static void choose_selectnone_activate(GtkMenuItem attribute((unused)) *item,
41 gpointer attribute((unused)) userdata) {
42 gtk_tree_selection_unselect_all(choose_selection);
43}
44
45static int choose_play_sensitive(void attribute((unused)) *extra) {
46 return FALSE; /* TODO */
47}
48
49static void choose_play_activate(GtkMenuItem attribute((unused)) *item,
50 gpointer attribute((unused)) userdata) {
51 /* TODO */
52}
53
54static int choose_properties_sensitive(void attribute((unused)) *extra) {
55 return FALSE; /* TODO */
56}
57
58static void choose_properties_activate(GtkMenuItem attribute((unused)) *item,
59 gpointer attribute((unused)) userdata) {
60 /* TODO */
61}
62
63/** @brief Pop-up menu for choose */
64static struct menuitem choose_menuitems[] = {
65 {
66 "Play track",
67 choose_play_activate,
68 choose_play_sensitive,
69 0,
70 0
71 },
72 {
73 "Track properties",
74 choose_properties_activate,
75 choose_properties_sensitive,
76 0,
77 0
78 },
79 {
80 "Select all tracks",
81 choose_selectall_activate,
82 choose_selectall_sensitive,
83 0,
84 0
85 },
86 {
87 "Deselect all tracks",
88 choose_selectnone_activate,
89 choose_selectnone_sensitive,
90 0,
91 0
92 },
93};
94
95const struct tabtype choose_tabtype = {
96 choose_properties_sensitive,
97 choose_selectall_sensitive,
98 choose_selectnone_sensitive,
99 choose_properties_activate,
100 choose_selectall_activate,
101 choose_selectnone_activate,
102 0,
103 0
104};
105
106/** @brief Called when a mouse button is pressed or released */
107gboolean choose_button_event(GtkWidget attribute((unused)) *widget,
108 GdkEventButton *event,
109 gpointer attribute((unused)) user_data) {
110 if(event->type == GDK_BUTTON_RELEASE && event->button == 2) {
111 /* Middle click release - play track */
112 //ensure_selected(choose_view, event);
113 /* TODO */
114 } else if(event->type == GDK_BUTTON_PRESS && event->button == 3) {
115 /* Right click press - pop up the menu */
116 ensure_selected(GTK_TREE_VIEW(choose_view), event);
117 popup(&choose_menu, event,
118 choose_menuitems, sizeof choose_menuitems / sizeof *choose_menuitems,
119 0);
120 return TRUE;
121 }
122 return FALSE;
123}
124
125/*
126Local Variables:
127c-basic-offset:2
128comment-column:40
129fill-column:79
130indent-tabs-mode:nil
131End:
132*/