Code

status_bar: remove the status bar clock (option "display-time")
[ncmpc.git] / src / screen_keydef.c
index b947dd8f0ebf022634efedfa9781bb4fa5bfe94f..44b191c26d0a40672473faf6c94b7193b66ca8f7 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2010 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,7 @@
 #include "conf.h"
 #include "screen.h"
 #include "screen_utils.h"
+#include "options.h"
 #include "Compiler.h"
 
 #include <assert.h>
@@ -145,19 +146,24 @@ apply_keys(void)
 static int
 save_keys(void)
 {
-       if (!check_user_conf_dir()) {
-               screen_status_printf(_("Error: Unable to create directory ~/.ncmpc - %s"),
-                                    strerror(errno));
-               screen_bell();
-               return -1;
+       char *allocated = NULL;
+       const char *filename = options.key_file;
+       if (filename == NULL) {
+               if (!check_user_conf_dir()) {
+                       screen_status_printf(_("Error: Unable to create directory ~/.ncmpc - %s"),
+                                            strerror(errno));
+                       screen_bell();
+                       return -1;
+               }
+
+               filename = allocated = build_user_key_binding_filename();
        }
 
-       char *filename = build_user_key_binding_filename();
        FILE *f = fopen(filename, "w");
        if (f == NULL) {
                screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
                screen_bell();
-               g_free(filename);
+               g_free(allocated);
                return -1;
        }
 
@@ -166,7 +172,7 @@ save_keys(void)
        else
                screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
 
-       g_free(filename);
+       g_free(allocated);
        return fclose(f);
 }
 
@@ -189,13 +195,6 @@ check_subcmd_length(void)
 static void
 keydef_paint(void);
 
-static void
-keydef_repaint(void)
-{
-       keydef_paint();
-       wrefresh(lw->w);
-}
-
 /** lw->start the last time switch_to_subcmd_mode() was called */
 static unsigned saved_start = 0;
 
@@ -210,7 +209,7 @@ switch_to_subcmd_mode(int cmd)
        list_window_reset(lw);
        check_subcmd_length();
 
-       keydef_repaint();
+       keydef_paint();
 }
 
 static void
@@ -224,7 +223,7 @@ switch_to_command_mode(void)
 
        lw->start = saved_start;
 
-       keydef_repaint();
+       keydef_paint();
 }
 
 /**
@@ -251,7 +250,7 @@ delete_key(int cmd_index, int key_index)
        screen_status_printf(_("Deleted"));
 
        /* repaint */
-       keydef_repaint();
+       keydef_paint();
 
        /* update key conflict flags */
        check_key_bindings(cmds, NULL, 0);
@@ -294,7 +293,7 @@ overwrite_key(int cmd_index, int key_index)
        check_subcmd_length();
 
        /* repaint */
-       keydef_repaint();
+       keydef_paint();
 
        /* update key conflict flags */
        check_key_bindings(cmds, NULL, 0);
@@ -434,7 +433,7 @@ keydef_cmd(gcc_unused struct mpdclient *c, command_t cmd)
                return false;
 
        if (list_window_cmd(lw, cmd)) {
-               keydef_repaint();
+               keydef_paint();
                return true;
        }
 
@@ -484,7 +483,7 @@ keydef_cmd(gcc_unused struct mpdclient *c, command_t cmd)
        case CMD_LIST_FIND_NEXT:
        case CMD_LIST_RFIND_NEXT:
                screen_find(lw, cmd, list_callback, NULL);
-               keydef_repaint();
+               keydef_paint();
                return true;
 
        default: