ui_menuitem(.label = "Fullscreen");
ui_menu_toggleitem(.label = "View Sidebar", .varname = "sidebar", .onchange = ActionViewSidebarCB);
ui_menuseparator();
- ui_menu_toggleitem(.label = "Adjust Window Size", .varname = "adjustwindowsize", .onchange = ActionViewAdjustWindowSizeCB);
+ ui_menu_toggleitem(.label = "Adjust Window Size", .varname = "adjustwindowsize");
}
ui_menu("Preferences") {
ui_menu_toggleitem(.label = "Single Instance", .varname = "singleinstance", .onchange = ActionPrefSingleInstanceCB);
MainWindow *window = WindowCreate(display);
toplevel_window = window->obj->window;
if(settings->disable_adjust_window_size) {
- window->adjustWindowSize = FALSE;
- XtVaSetValues(window->viewAdjustWindowSize, XmNset, FALSE, NULL);
+ ui_set(window->adjustWindowSize, 0);
}
// random numbers used for creating tmp dirs and for random playback
}
if(settings->single_instance) {
- // this will trigger the Single Instance menu button event handler
- // and enable the single instance mode if possible
- XmToggleButtonGadgetSetState(window->prefSingleInstanceButton, True, True);
+ enable_single_instance_mode(window);
}
WindowShow(window);
}
MainWindow *win = event->window;
win->playlist.playback = event->intval ? PLAYBACK_REPEAT : PLAYBACK_STOP;
- ui_set(win->_playbackRepeatList, 0);
- ui_set(win->_playbackAutoPlay, 0);
- ui_set(win->_playbackRandom, 0);
+ ui_set(win->playbackRepeatList, 0);
+ ui_set(win->playbackAutoPlay, 0);
+ ui_set(win->playbackRandom, 0);
}
void ActionPlayRepeatList(UiEvent *event, void *userdata) {
}
MainWindow *win = event->window;
win->playlist.playback = event->intval ? PLAYBACK_REPEAT_LIST : PLAYBACK_STOP;
- ui_set(win->_playbackRepeat, 0);
- ui_set(win->_playbackRandom, 0);
- ui_set(win->_playbackAutoPlay, 0);
+ ui_set(win->playbackRepeat, 0);
+ ui_set(win->playbackRandom, 0);
+ ui_set(win->playbackAutoPlay, 0);
}
void ActionPlayAutoPlayCB(UiEvent *event, void *userdata) {
}
MainWindow *win = event->window;
win->playlist.playback = event->intval ? PLAYBACK_AUTOPLAY : PLAYBACK_STOP;
- ui_set(win->_playbackRepeat, 0);
- ui_set(win->_playbackRepeatList, 0);
- ui_set(win->_playbackRandom, 0);
+ ui_set(win->playbackRepeat, 0);
+ ui_set(win->playbackRepeatList, 0);
+ ui_set(win->playbackRandom, 0);
}
void ActionPlayRandomCB(UiEvent *event, void *userdata) {
}
MainWindow *win = event->window;
win->playlist.playback = event->intval ? PLAYBACK_RANDOM : PLAYBACK_STOP;
- ui_set(win->_playbackRepeat, 0);
- ui_set(win->_playbackRepeatList, 0);
- ui_set(win->_playbackAutoPlay, 0);
+ ui_set(win->playbackRepeat, 0);
+ ui_set(win->playbackRepeatList, 0);
+ ui_set(win->playbackAutoPlay, 0);
}
void ActionPlayPreviousCB(UiEvent *event, void *userdata) {
WindowShowSidebar(win, event->intval);
}
-void ActionViewAdjustWindowSizeCB(UiEvent *event, void *userdata) {
- if(event->set) {
- return;
- }
- MainWindow *win = event->window;
- win->adjustWindowSize = event->intval;
-}
-
void ActionPrefSingleInstanceCB(UiEvent *event, void *userdata) {
if(event->set) {
return;
}
- MainWindow *win = event->window;
- win->singleInstance = event->intval;
+ MainWindow *win = event->window;
Display *dp = ui_motif_get_display();
- if(!win->singleInstance) {
+ if(!event->intval) {
ShutdownInstanceSocket(dp);
return;
}
- Bool disable_item = False;
- if(CreateSingleInstanceSocket(dp, &disable_item)) {
- // TODO: err
- disable_item = True;
+ enable_single_instance_mode(win);
+}
+
+int enable_single_instance_mode(MainWindow *win) {
+ Display *dp = ui_motif_get_display();
+
+ int error = 0;
+ if(CreateSingleInstanceSocket(dp, &error)) {
+ // TODO: err msg
+ error = 1;
}
- if(disable_item) {
- win->singleInstance = 0;
- //XmToggleButtonGadgetSetState(w, False, False);
- ui_set(win->_singleInstance, 0);
+
+ if(error) {
+ ui_set(win->singleInstance, 0);
+ } else {
+ ui_set(win->singleInstance, 1);
}
+ return error;
}
typedef struct MainWindow {
UiObject *obj;
- Widget player_widget;
- Widget sidebar_scrolledwindow;
- Widget sidebar;
+ UIWIDGET player_widget;
+ UIWIDGET sidebar_scrolledwindow;
+ UIWIDGET sidebar;
UIWIDGET listview; // TODO: maybe this can be removed
UIWIDGET listview_scrolledwindow;
bool buttongrab; // TODO: can this be removed
bool pwbuttonpressed;
- UiInteger *_sidebarVisible;
- UiInteger *_playbackRepeat;
- UiInteger *_playbackRepeatList;
- UiInteger *_playbackAutoPlay;
- UiInteger *_playbackRandom;
- UiInteger *_adjustWindowSize;
- UiInteger *_singleInstance;
+ UiInteger *sidebarVisible;
+ UiInteger *playbackRepeat;
+ UiInteger *playbackRepeatList;
+ UiInteger *playbackAutoPlay;
+ UiInteger *playbackRandom;
+ UiInteger *adjustWindowSize;
+ UiInteger *singleInstance;
UiInteger *splitview;
-
- Widget playRepeatTrackButton;
- Widget playRepeatListButton;
- Widget playAutoPlayButton;
- Widget playRandom;
- Widget viewSidebarButton;
- Widget viewAdjustWindowSize;
- Widget prefSingleInstanceButton;
-
PlayList playlist;
- bool adjustWindowSize;
- bool singleInstance;
-
Time player_event_time;
Time button_press_time;
double motion_playback_time;
void ActionViewAdjustWindowSizeCB(UiEvent *event, void *userdata);
void ActionPrefSingleInstanceCB(UiEvent *event, void *userdata);
+int enable_single_instance_mode(MainWindow *win);
+
#ifdef __cplusplus
}
void PlayListSetMode(MainWindow *win, PlaybackMode mode) {
win->playlist.playback = mode;
- XtVaSetValues(win->playRepeatTrackButton, XmNset, mode == PLAYBACK_REPEAT, NULL);
- XtVaSetValues(win->playRepeatListButton, XmNset, mode == PLAYBACK_REPEAT_LIST, NULL);
- XtVaSetValues(win->playAutoPlayButton, XmNset, mode == PLAYBACK_RANDOM, NULL);
- XtVaSetValues(win->playRandom, XmNset, mode == PLAYBACK_AUTOPLAY, NULL);
+ ui_set(win->playbackRepeat, mode == PLAYBACK_REPEAT);
+ ui_set(win->playbackRepeatList, mode == PLAYBACK_REPEAT_LIST);
+ ui_set(win->playbackAutoPlay, mode == PLAYBACK_AUTOPLAY);
+ ui_set(win->playbackRandom, mode == PLAYBACK_RANDOM);
}
int PlayListGetNextFromHistory(MainWindow *win) {
UiContext *ctx = obj->ctx;
obj->window = window;
window->obj = obj;
- window->_sidebarVisible = ui_int_new(ctx, "sidebar");
- window->_playbackRepeat = ui_int_new(ctx, "repeat");
- window->_playbackRepeatList = ui_int_new(ctx, "repeatlist");
- window->_playbackRandom = ui_int_new(ctx, "random");
- window->_playbackAutoPlay = ui_int_new(ctx, "autoplay");
- window->_adjustWindowSize = ui_int_new(ctx, "adjustwindowsize");
- window->_singleInstance = ui_int_new(ctx, "singleinstance");
+ window->sidebarVisible = ui_int_new(ctx, "sidebar");
+ window->playbackRepeat = ui_int_new(ctx, "repeat");
+ window->playbackRepeatList = ui_int_new(ctx, "repeatlist");
+ window->playbackRandom = ui_int_new(ctx, "random");
+ window->playbackAutoPlay = ui_int_new(ctx, "autoplay");
+ window->adjustWindowSize = ui_int_new(ctx, "adjustwindowsize");
+ window->singleInstance = ui_int_new(ctx, "singleinstance");
window->splitview = ui_int_new(ctx, NULL);
ui_set(window->splitview, 400);
PlayListInit(window);
- window->adjustWindowSize = true; // auto adjust window size by default
+ ui_set(window->adjustWindowSize, true);
return window;
}
ui_window_fullscreen(win->obj, enableFullscreen);
}
-static void PrefSingleInstanceCB(Widget w, void *udata, void *cdata) {
- MainWindow *win = udata;
- win->singleInstance = XmToggleButtonGadgetGetState(w);
-
- Display *dp = XtDisplay(w);
-
- if(!win->singleInstance) {
- ShutdownInstanceSocket(dp);
- return;
- }
-
- Bool disable_item = False;
- if(CreateSingleInstanceSocket(dp, &disable_item)) {
- // TODO: err
- disable_item = True;
- }
- if(disable_item) {
- win->singleInstance = 0;
- XmToggleButtonGadgetSetState(w, False, False);
- }
-}
-
void WindowAdjustAspectRatio(MainWindow *win) {
if(!win->player) return;
if(!win->player->isactive || win->player->width <= 0 || win->player->height <= 0) return;