static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *args, int nargs);
static void FileOpenCB(Widget w, void *udata, void *cdata);
+static void FileQuitCB(Widget w, void *udata, void *cdata);
+static void PlayRepeatCB(Widget w, void *udata, void *cdata);
static void ViewFullscreenCB(Widget w, void *udata, void *cdata);
static void WindowRealized(MainWindow *win);
}
static void window_close_handler(Widget window, void *udata, void *cdata) {
- WindowClosePlayer(main_window);
- ApplicationExit();
+ FileQuitCB(window, NULL, NULL);
}
static unsigned int keycodeF;
return menuItem;
}
+/*
+ * Creates a XmToggleButton menu item
+ */
+static Widget createToggleMenuItem(
+ Widget menu,
+ char *name,
+ char *label,
+ char mnemonic,
+ Boolean defaultValue,
+ const char *accelerator,
+ char *accelerator_text,
+ XtCallbackProc callback,
+ void *cbData)
+{
+ Arg args[16];
+ int n = 0;
+
+ XmString s1 = XmStringCreateSimple(label);
+ XtSetArg(args[n], XmNlabelString, s1); n++;
+ XtSetArg(args[n], XmNmnemonic, mnemonic); n++;
+ XtSetArg(args[n], XmNset, defaultValue); n++;
+ XmString at = NULL;
+ if(accelerator && accelerator_text) {
+ at = XmStringCreateSimple(accelerator_text);
+ XtSetArg(args[n], XmNaccelerator, accelerator); n++;
+ XtSetArg(args[n], XmNacceleratorText, at); n++;
+ }
+
+ Widget menuItem = XmCreateToggleButtonGadget(menu, name, args, n);
+ XtManageChild(menuItem);
+ XmStringFree(s1);
+ if(at) XmStringFree(at);
+
+ if(callback) {
+ XtAddCallback(menuItem, XmNvalueChangedCallback, (XtCallbackProc)callback, cbData);
+ }
+
+ return menuItem;
+}
+
static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *mbargs, int nmbargs) {
Widget menubar = XmCreateMenuBar(parent, "menubar", mbargs, nmbargs);
XtManageChild(menubar);
// menus
XmString s = XmStringCreateSimple("File");
- Widget fileMenuItem = XtVaCreateManagedWidget(
+ XtVaCreateManagedWidget(
"menuitem",
xmCascadeButtonWidgetClass,
menubar,
Widget fileMenu = XmVaCreateSimplePulldownMenu(menubar, "menu", 0, NULL, NULL);
s = XmStringCreateSimple("Playback");
- Widget playMenuItem = XtVaCreateManagedWidget(
+ XtVaCreateManagedWidget(
"menuitem",
xmCascadeButtonWidgetClass,
menubar,
// file menu
createMenuItem(fileMenu, "fileOpen", "Open...", 'O', "Ctrl<Key>O", "Ctrl+O", FileOpenCB, NULL);
+ createMenuItem(fileMenu, "fileQuit", "Exit", 'E', "Ctrl<Key>Q", "Ctrl+Q", FileQuitCB, NULL);
+
+ // play menu
+ createToggleMenuItem(playMenu, "playRepeatTrack", "Repeat", 'R', False, NULL, NULL, PlayRepeatCB, win);
// view menu
createMenuItem(viewMenu, "viewFullscreen", "Fullscreen", 'F', "<Key>F", "F", ViewFullscreenCB, NULL);
XtManageChild(dialog);
}
+static void FileQuitCB(Widget w, void *udata, void *cdata) {
+ WindowClosePlayer(main_window);
+ ApplicationExit();
+}
+
+static void PlayRepeatCB(Widget w, void *udata, void *cdata) {
+ MainWindow *win = udata;
+ win->repeatTrack = XmToggleButtonGadgetGetState(w);
+}
+
static void ViewFullscreenCB(Widget w, void *udata, void *cdata) {
if(main_window->fullscreen) {
WindowFullscreen(main_window, FALSE);